xxxxxxxxxx
32
//hold left button to change background color
//hold right button to change button's color
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
//button1: press to change color
if (mouseX > 150 && mouseX < 250 && mouseY > 150 && mouseY < 250 && mouseIsPressed == true) {
fill(106, 107, 205);
} else {
fill(255);
}
noStroke();
rectMode(CENTER);
rect(200, 200, 100, 100);
//button2: press to change background
if (mouseX > 25 && mouseX < 125 && mouseY > 150 && mouseY < 250) {
if (mouseIsPressed) {
background(0);
}
fill(106, 107, 205);
} else {
fill(255);
}
rectMode(CORNER);
rect(25, 150, 100, 100);
}