xxxxxxxxxx
function setup() {
let w = min(windowWidth, 900);
createCanvas(w, w / 3);
strokeWeight(1);
noFill();
background(0);
}
function drawPerlinCurve(x, y, phase, step, numCurveVertices) {
push();
stroke(200, 100);
circle(x, y, 20);
let noiseScale = 0.004;
beginShape();
for (let i = 0; i < numCurveVertices; i++) {
curveVertex(x, y);
let angle = TWO_PI * noise(x * noiseScale, y * noiseScale, phase * noiseScale);
x += cos(angle) * step;
y += sin(angle) * step;
}
endShape();
pop();
}
//fade previous screen by drawing over with a dark (low-alpha) rectangle
function applyFade() {
push();
fill(0, 16);
rect(0, 0, width, height);
pop();
}
function draw() {
let STEP = 20;
let numCurveVertices = floor(width * 1.5 / STEP);
applyFade();
background(0);
push();
scale(1);
let phase = frameCount / 2;
for (let y = 0; y < height; y += 20) {
drawPerlinCurve(width + 50, y, phase, STEP, numCurveVertices);
}
pop();
}