xxxxxxxxxx
29
var rollover = false; // Is the mouse over the rect?
function setup() {
createCanvas(600, 400);
// Starting location
x = 300;
y = 200;
// Dimensions
w = 100;
h = 100;
}
function draw() {
background(0);
stroke(225);
strokeWeight(4);
noFill();
//rollover-rect changes color when mouse is inside
if(mouseX > 250 && mouseX < 350 &&mouseY >150 && mouseY < 250){
if(mouseIsPressed){
background(250,0,200);
}
fill(255,0,0);
}
rectMode(CENTER)
rect(x,y,w,h);
}