xxxxxxxxxx
31
let onRed = false;
let hasLeft = true;
function setup() {
createCanvas(600, 400);
frameRate(1);
}
function draw() {
background(220);
if (mouseX > 0 && mouseX < 200 && mouseY > 0 && mouseY < 400) {
if(hasLeft){
onRed = !onRed;
hasLeft=false;}
}
else{hasLeft=true;}
if (onRed) {
fill("red");
rect(0, 0, 200, 400);
} else {
fill(255);
rect(0, 0, 200, 400);
}
fill(255);
rect(200, 0, 200, 400);
rect(400, 0, 200, 400);
}