Hi
I am a complete beginner and am working on the following project:
Create a 500x500 grey area split into 4 equal quadrants. Show one quadrant as blue when the mouse is in that quadrant (all other quadrants shown as gray), when the mouse moves to another quadrant, that quadrant shows as a different colour with the other three as grey etc. same for the other two quadrants. Poor explanation of a very simple sketch! Sorry!
i can make three quadrants work (rd, blue and yellow) but not the fourth (green). What am I doing wrong?? I can’t see for looking now and it’s driving me mad! Hope someone can help…
thanks in advance
Damian
here is my code:
void setup() {
size(500,500);
}
void draw() {
background(50);
//BOTTOM RIGHT: RED
if (mouseX > 250)
if (mouseY > 250)
{
fill(255,0,0);
rect(250,250,250,250);
} else {
fill(50);
rect(0,0,500,500);
}
//TOP RIGHT: BLUE
if (mouseX > 250)
if (mouseY < 250)
{
fill(0,0,250);
rect(250,0,250,250);
} else if (mouseX < 250){
fill(50);
rect(0,0,500,500);
}
//TOP LEFT: GREEN
if (mouseX < 250)
if (mouseY < 250)
{
fill(0,250,0);
rect(0,0,250,250);
} else if (mouseX < 250){
fill(50);
rect(0,0,500,500);
}
//BOTTOM LEFT: YELLOW
if (mouseX < 250)
if (mouseY > 250)
{
fill(255,255,0);
rect(0,250,250,250);
} else {
fill(50);
rect(0,0,500,500);
}
stroke(255);
line(250,0,250,height);
line(width,250,0,250);
}