xxxxxxxxxx
38
let x = 0;
let y = 0;
let dim = 50.0;
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
x = x + 2.5;
// If the shape goes off the canvas, reset the position
if (x > width + dim) {
x = -dim;
}
push();
let noiseLevel = width;
let noiseScale = 0.002;
for (let j = 0; j < width; j += 1) {
// Scale input coordinates.
let nx = noiseScale * j;
let nt = noiseScale * x;
// Compute noise value.
let y = noiseLevel * noise(nx, nt);
// Render.
line(x, 0, x, y);
}
pop();
push();
translate(x, 0);
circle(0, height / 2, dim);
stroke("black");
pop();
}