xxxxxxxxxx
49
let a = 'white';
let b = 'white';
let c = 'white';
let m = 0;
let n = false
function setup() {
createCanvas(400, 400);
}
function draw() {
background('white');
// First rectangle
if ((mouseX < width / 3) && n == false) {
m += 1;
n = true
}
else if ((mouseX > width / 3) && n == true){
n = false
}
if (m %2 == 0){
a = 'red';
}
else {
a = 'white';
}
fill(a);
rect(0, 0, width / 3, height);
// Second rectangle
if (mouseX >= width / 3 && mouseX < (2 * width) / 3) {
b = 'red';
} else {
b = 'white';
}
fill(b);
rect(width / 3, 0, width / 3, height);
// Third rectangle
if (mouseX >= (2 * width) / 3) {
c = 'red';
} else {
c = 'white';
}
fill(c);
rect((2 * width) / 3, 0, width / 3, height);
}