xxxxxxxxxx
28
function setup() {
createCanvas(400, 400);
}
function draw() {
if (frameCount < 120) {
// for the first 2 seconds, we will draw draw1
draw1();
} else if (frameCount < 240) {
// after that, and before the first 4 seconds, we will draw draw2
draw2();
} else if (frameCount > 240) {
// otherwise, after 4 seconds, draw draw3
draw3();
}
}
function draw1() {
background("red");
}
function draw2() {
background("blue");
}
function draw3() {
background("green");
}