Code
void setup(){
size(300,300);
background(255);
noStroke();
}
int x1 = 50;
int y1 = 50;
int x2 = 200;
int y2 = 200;
int w1 = 50;
int h1 = 50;
int w2 = 50;
int h2 = 50;
void draw(){
boolean mouseBox1= ((mouseX>50 && mouseX<100) && (mouseY>50 && mouseY<100));
if (mouseBox1==true){
fill(255,0,0);
rect(x1,y1,w1,h1);
}
else{
fill(0);
rect(x1,y1,w1,h1);
}
boolean mouseBox2= ((mouseX>200 && mouseX<250) && (mouseY>200 && mouseY<250));
if (mouseBox2==true){
fill(255,0,0);
rect(x2,y2,w2,h2);
}
else{
fill(0);
rect(x2,y2,w2,h2);
}
}
...Quiz 030 (September 17): Two Sensitive Square Regions
Statement:Given two rectangles, defined with (x1,y1,w1,h1) and (x2,y2,w2,h2): Create an interactive program such that when the mouse is hovering over a given rectangle, that region is RED, but when the mouse is not hovering within that area, the rectangle is some other color.
hide statement