xxxxxxxxxx
40
function setup() {
createCanvas(1800, 1800);
//noLoop();
}
function draw() {
background(0);
let yStep = 20;
let f = 64.0 * mouseX/width;
let wSize = (width + 40)/f;
let h = 2.5;
noStroke();
for (var y=0; y<height; y+=yStep) {
wave(-20 , y+2*h, width+20, -h, f);
wave(-20 + (2*wSize), y-2*h, width+20, h, f);
}
}
function wave(x, y, w, h, f) {
let mult = 1;
let xStep = w/f;
beginShape();
vertex(x, y+2*h);
vertex(x, y+2*h);
for (var i=0; i<f; i++) {
curveVertex(x+i*xStep, y+(h*mult));
mult*= -1;
}
vertex(x+w, y+2*h);
vertex(x+w, y+2*h);
vertex(x, y+2*h);
vertex(x, y+2*h);
endShape();
}
function keyPressed() {
if (key === 's') {
saveFrames('sashikoWaves', 'png', 1, 1);
}
}