xxxxxxxxxx
27
// current x, y
let x, y;
// previous x, y
let px, py;
function setup() {
createCanvas(windowWidth, windowHeight);
background(255);
// initialize variables
x = 0;
y = height / 2;
px = x;
py = y;
}
function draw() {
// move x by 1 pixel to the right every frame
x++; // same as x = x + 1
y = (noise(frameCount * 0.01) - 0.5) * height / 4 + height / 2;
line(px, py, x, y);
// set previous to current
px = x;
py = y;
}