xxxxxxxxxx
39
// https://www.reddit.com/r/p5js/comments/qz8jzg/waves_gradients_and_dashed_lines/
const dx = 200;
const dy = 75;
const h = 75;
const spc = 15;
const num = 10;
const ns = 0.01;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
for(let i = 0; i < num; i ++) {
drawSlice(30 + i * spc, 100 + i * spc * 0.5);
}
}
function drawSlice(x, y) {
beginShape();
fill(255, 255, 0);
for(let i = dx; i >=0; i --) {
let ix = x + i;
let n = noise(ix * ns, y * ns, frameCount * ns * 0.5);
let iy = y + (1 - (i/dx)) * dy;
iy -= (n-0.5) * h;
vertex(ix, iy);
}
fill(255, 100, 0);
vertex(x, y + dy + h);
vertex(x + dx, y + h);
endShape(CLOSE);
}