Hi, I have a code where I intend circles to appear on the canvas at different timing, then enlarge and disappear. Despite my attempts, they all seem to appear simultaneously.
Anything wrong with setTimeout here? Thanks.
let x = [20, 40, 60, 80, 100, 120];
let y = [30, 90, 60, 120, 180, 150];
let ts = [1, 4, 6, 8, 10, 12];
let i
function setup() {
createCanvas(720, 400);
}
function draw() {
background(255);
for (let i = 0; i < 6; i++) {
stroke(255, 0, 0);
ellipse(2 * x[i], 2 * y[i], 2, 2)
setTimeout(enlargingCircle(2 * x[i], 2 * y[i]), ts[i] * 1000);
}
}
function enlargingCircle(xpos, ypos) {
fill(0, 0, 20, 255 - frameCount);
if (frameCount <= 60) {
ellipse(xpos, ypos, frameCount, frameCount);
}
}