xxxxxxxxxx
42
var cx=200,
cy=200,
cw=220,
ch=220;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220,30);
rect(cx,cy,cw,ch);
if (overRect(cx,cy,cw*2,ch*2)){
noStroke();
fill(220,30,100);
} else{
stroke(255,200,0);
strokeWeight(50);
fill(0,255,200);
rect(cx,cy,cw,ch);
}
function overRect(x,y,w,h){
rectMode(CENTER);
if(mouseX>x && mouseX<x+w && mouseY>y && mouseY<y+h){
return true;
} else {
return false;
}
}
}