xxxxxxxxxx
/*-----------------------------
Press Hover Boxes
If you press the mouse two boxes change color
if you hover over the other two boxes they will
Created January 31, 2017
By Jamie Steines
jamie.roberta@gmail.com
-----------------------------*/
int x1=0,x2=300;
int y1=0,y2=300;
int width = 200;
int height = 200;
void setup() {
size(500,500);
background(170);
}
void draw(){
if(mouseX>=x1 && mouseX<=x1+width && mouseY>=y1 && mouseY<=y1+height){
fill(255, 102, 102);
}else{
fill(51, 204, 204);
}
rect(x1,y1,width,height);
if(mouseX>=x2 && mouseX<=x2+width && mouseY>=y2 && mouseY<=y2+height){
fill(51, 204, 204);
}else{
fill(255, 102, 102);
}
rect(x2,y2,width,height);
if(mousePressed){
fill(204, 153, 255);
}else{
fill(204, 255, 153);
}
rect(x1,y2,width,height);
if(mousePressed){
fill(204, 255, 153);
}else{
fill(204, 153, 255);
}
rect(x2,y1,width,height);
}