xxxxxxxxxx
21
function setup() {
createCanvas(400, 400);
}
function draw() {
background(255);
rect(150,150,100,100);
if (mouseX >= 150 && mouseX <= 150+100 && mouseY >= 150 && mouseY <= 150+100) {
//if we've rolled over do something
fill(0);
} else {
fill(255);
}
}
// try putting the if statement into a function mousePressed() and see what happens