xxxxxxxxxx
51
const ydist = 50;
const xdist = 50;
let n = 0.0;
let m = 0.0;
let pts = [];
function setup() {
createCanvas(400, 400);
stroke(64, 64, 64, 50);
for (let y=0; y<=height; y+=ydist){
pts.push([]);
for (let x=0; x<=width*2; x+=xdist){
let newy = y + noise(y + (x / 100)) * (height - y * 0.25)
pts[pts.length-1].push({x:x, y:newy});
}
}
//noLoop();
}
function draw() {
n=frameCount / 100;
background(220);
translate(width * -0.5, height * -0.2);
for (let i=0; i<height; i+=10) {
fill(map(i, 0, height, 127, 255), map(sin(frameCount/100)*100, -100, 100, 0, 127), 127);
beginShape();
curveVertex(0, height*2);
let inew = floor(i/ydist);
let ioff = i%ydist;
//translate(map(mouseX, 0, width, width * -0.05, width * 0.05), 0)
for (let j=0; j<pts[inew].length; j++) { //
n += 0.005;
let xoff = noise(n) * 100;
if (j < pts[inew].length - 1 && ioff > 0) {
yoff = lerp(pts[inew][j].y, pts[inew+1][j].y, ioff/ydist);
curveVertex(pts[inew][j].x + xoff, yoff);
} else {
curveVertex(pts[inew][j].x + xoff, pts[inew][j].y);
}
}
curveVertex(width*2, height*2);
curveVertex(width*2, height*2);
curveVertex(0, height*2);
endShape(CLOSE);
}
}