xxxxxxxxxx
31
let value =220;
function setup() {
createCanvas(600, 400);
noStroke();
}
function draw() {
background(220);
fill(value);
rect(0,0,200,400);
if (mouseX<width/3) {
fill("red");
rect(0,0,width/3,height);
} else if(mouseX>width/3&&mouseX<2*width/3){
fill("red");
rect(width/3,0,width/3,height);
} else {
fill("red");
rect(2*width/3,0,width/3,height);
}
}
function mousePressed(){
if(value===220){
value="red";
}else{
value=220;
}
}