Code
int x1 = 100;
int y1 = 100;
int w1 = 200;
int h1 = 200;
int x2 = 100;
int y2 = 100;
int w2 = 100;
int h2 = 100;
void setup(){
size(300,300);
background(255);
noStroke();
}
void draw(){
if (mouseX >= x1 && mouseY >= y1 && mouseX <= w1 && mouseY <= h1){
fill (255,0,0);
rect(x1,y1, w1-100,h1-100);
}
}else{
(mouseX >= x1 && mouseY >= y1 && mouseX <= w1 && mouseY <= h1){
fill (0,0,0);
rect(x2,y2, w2,h2);
}
}
if (mouseX >= x1+(100) && mouseY >= y1 +(100) && mouseX <= w1 && mouseY <= h1){
fill (255,0,0);
rect(x1,y1, w1-50,h1-50);
}
}else {
(mouseX >= x1+100 && mouseY >= y1+100 && mouseX <= w1 && mouseY <= h1){
fill (0,0,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