function setup() {
createCanvas(400, 300);
}
function draw() {
// outer curves
drawCurve(0, 0, 0, 200, 12, 6, 40, 'upRight', monochromeColor());
drawCurve(width, 0, width, 200, 10, 5, 60, 'upLeft', monochromeColor());
drawCurve(width, 100, width, height, 8, 4, 60, 'downLeft', monochromeColor());
drawCurve(0, 100, 0, height, 6, 3, 80, 'downRight', monochromeColor());
// inner curves
drawCurve(80, 80,
80, height / 2,
10, 6, 13, 'upRight', monochromeColor());
drawCurve(width - 80, 80,
width - 80, height / 2,
8, 5, 15, 'upLeft', monochromeColor());
drawCurve(width - 80, height / 2,
width - 80, height - 80,
6, 4, 19, 'downLeft', monochromeColor());
drawCurve(80, height / 2, 80,
height - 80, 5,
3, 24, 'downRight', monochromeColor());
// curves in the middle
drawCurve(width / 2, 0, width / 2, height, 20, 10, 40, 'upRight', monochromeColor());
drawCurve(width / 2, 0, width / 2, height, 20, 10, 40, 'upLeft', monochromeColor());
drawCurve(width / 2, 0, width / 2, height, 20, 10, 40, 'downLeft', monochromeColor());
drawCurve(width / 2, 0, width / 2, height, 20, 10, 40, 'downRight', monochromeColor());
noLoop();
}
function monochromeColor(){
return color(255, random(120, 200), random(120, 200))
}
// larger xstep = larger width
// larger ystep = larger height
function drawCurve(x1, y1, x2, y2, xstep, ystep, numOfLines, direction, color){
var i = 0
for (i = 0; i < numOfLines; i ++){
stroke(color);
line(x1, y1, x2, y2);
if (direction === 'downRight'){
// x1 stays the same, y1 increases
// y2 stays the same, x2 increases
y1 += ystep;
x2 += xstep;
} else if (direction === 'upRight'){
y2 -= ystep;
x1 += xstep;
} else if (direction === 'downLeft'){
y1 += ystep;
x2 -= xstep;
} else if (direction === 'upLeft'){
y2 -= ystep
x1 -= xstep
}
}
}
I started by experimenting with curves and how controlling what and how much I added and subtracted from affected the curve (its direction, density, width, height, etc.). This led me to writing a function to draw a curve given different parameters (x1, y1, x2, y2, xstep, ystep, number of lines, direction, color). Finally, I sketched out some curve designs and recreated it using the function I wrote.