string art
var angle = 0;
function setup() {
createCanvas(400, 300);
background(200);
}
function draw() {
background(89, 190, 209);
var waveLx1 = 0;
var waveLx2 = 0;
var waveLy = height/40;
var dy1 = height/40;
var dx1 = width/30;
var dx2 = height/150;
var i = 0;
stroke(43, 58, 140);
line(0, 300, 101, 55); //for second wave
stroke(27, 85, 145);
line(125, 300, 200, 105); //for third wave
//first wave
for (i = 0; i < 400; i += 1) {
stroke(37, 36, 94);
line(waveLx1, 300, waveLx2, waveLy);
// x moves in opposite directions
waveLx1 += dx1;
waveLx2 -= dx2;
waveLy += dy1; // increase y value
}
push();
//second wave
translate(100, 50);
waveLx1 = 0;
waveLx2 = 0;
waveLy = height/40;
dy1 = height/40;
dx1 = width/10;
dx2 = height/100;
i = 0;
for (i = 0; i < 400; i += 1) {
stroke(43, 58, 140);
line(waveLx1, 300, waveLx2, waveLy);
// x moves in opposite directions
waveLx1 += dx1;
waveLx2 -= dx2;
waveLy += dy1; // increase y value
}
pop();
push();
//third wave
translate(200, 100);
waveLx1 = 0;
waveLx2 = 0;
waveLy = height/40;
dy1 = height/40;
dx1 = width/5;
dx2 = height/100;
i = 0;
for (i = 0; i < 400; i += 1) {
stroke(27, 85, 145);
line(waveLx1, 300, waveLx2, waveLy);
// x moves in opposite directions
waveLx1 += dx1;
waveLx2 -= dx2;
waveLy += dy1; // increase y value
}
pop();
push();
//rotating sun
translate(335, 70);
noStroke();
fill(240, 180, 87);
ellipse(0, 0, 40, 40);
for (var i = 0 ; i <360; i+=10) {
rotate(radians(angle));
stroke(240, 180, 87);
strokeWeight(2);
line(0, 0, 50, 0);
line(0, 0, 50*cos(radians(i)), 50*sin(radians(i)));
angle = angle + 1;
}
pop();
//clouds
noStroke();
ellipse(265, 100, 35, 35);
ellipse(245, 105, 25, 25);
ellipse(285, 105, 25, 25);
ellipse(345, 135, 35, 35);
ellipse(360, 140, 35, 35);
ellipse(375, 140, 25, 25);
ellipse(330, 140, 25, 25);
}
I was inspired by the string art image of a beach below. I drew out the basic shapes on illustrator which helped determine the points of the initial lines. The most challenging part was figuring out how to keep the sun rotating.