In Processing, I need the rectangle in the middle of the window appear as purple and the background yellow when the mouse is hovering within the rectangle. When the mouse is anywhere else on the screen (touching the background) the rectangle should be yellow and the background should be purple. I've achieved my goal, but am wondering if there's a more concise way to write this code, or if there are alternative approaches?
void setup ()
{
size(500, 500);
}
void draw()
{
background(205, 86, 219); // purple
rectMode(CENTER);
fill(231, 240, 111); // yellow
rect(250, 250, 250, 200);
if (mouseX >= 125 && mouseX <= 375 && mouseY >= 100 && mouseY <= 300)
{
background(231, 240, 111); // yellow
fill(205, 86, 219); // purple
rect(250, 250, 250, 200);
}
}