xxxxxxxxxx
37
const lines = 10;
const bg = 255;
const stepSize = 20;
const maxHeight = 50;
function setup() {
createCanvas(400, 400);
noLoop();
}
function draw() {
background(bg);
fill(bg);
for(let y = 0; y < height; y += height/(lines + 1)) {
drawLine(y);
}
}
function drawLine(y) {
beginShape();
curveVertex(0, y);
curveVertex(0, y);
let x = 0;
while(x < width) {
curveVertex(x, y - maxHeight * random(0.2, 1) * volatility(x));
x += stepSize;
}
curveVertex(width, y);
curveVertex(width, y);
endShape();
}
function volatility(x) {
let t = (x/width) -0.25;
return (0.5 * sin((t * TAU))) + 0.5;
}