xxxxxxxxxx
31
let num = 40;
let x = [];
let y = [];
function setup() {
createCanvas(windowWidth, windowHeight);
noStroke();
noCursor();
for(i = 0; i < num; i++){
x[i] = 0;
y[i] = 0;
}
}
function draw() {
background(0);
//Copy array values from back to front
for(i = num-1; i > 0; i--){
x[i] = x[i - 1];
y[i] = y[i - 1];
}
x[0] = mouseX; //set the first element
y[0] = mouseY;
for(i = 0; i < num; i++){
fill(i * 4);
circle(x[i], y[i], 240);
}
}