xxxxxxxxxx
29
let buttondown = false;
function setup() {
createCanvas(400, 400);
}
function draw() {
console.log(mouseX, mouseY);
// background(220);
rect(100,100,100,100)
if (mouseX > 100 && mouseX < 200 && mouseY > 100 && mouseY < 200){
fill(100)
}
if (mouseX < 100 || mouseX > 200 || mouseY < 100 || mouseY > 200){
fill(255)
}
}
function mousePressed() {
if (mouseX > 100 && mouseX < 200 && mouseY > 100 && mouseY < 200 && buttondown==true) {
fill(255)
buttondown=false;
} else if (mouseX > 100 && mouseX < 200 && mouseY > 100 && mouseY < 200 && buttondown==false){
fill(0)
buttondown=true;
}
}