xxxxxxxxxx
58
let ColorGauche1 = 0;
let ColorGauche2 = 0;
let ColorDroit1 = 0;
let ColorDroit2 = 0;
function setup() {
createCanvas(window.innerWidth, window.innerHeight);//le canvas s'adapte à la taille de la fenêtre
noStroke();//pas de filet autour des rectangles
//random rectangles
ColorGauche1 = random(255);
ColorGauche2 = random(255);
ColorDroit1 = random(255);
ColorDroit2 = random(255);
}
function draw() {
background(220);
//rectangle gauche haut
fill(ColorGauche1);
rect(0, 0, width / 2, height / 2);
//rectangle gauche bas
fill(ColorGauche2);
rect(0, height / 2, width / 2, height / 2);
//rectangle droit 1
fill(ColorDroit1);
rect(width / 2, 0, width / 2, height);
//rectangle droit 2
fill(ColorDroit2);
rect(width / 2, 0, width / 4, height);
//120 = 2 secondes
if (frameCount % 120 == 0) {
ColorGauche1 = color(random(255), random(255), random(255));
}
if (frameCount % 100 == 0) {
ColorGauche2 = color(random(255), random(255), random(255));
}
if (frameCount % 60 == 0) {
ColorDroit1 = color(random(255), random(255), random(255));
}
if (frameCount % 15 == 0) {
ColorDroit2 = color(random(255), random(255), random(255));
}
}