int rectX,rectY;

int rectSize=90;


color rectColor;

color baseColor;


boolean rectOver=false;


void setup(){

  size(640,360);

  rectColor=color(0);

  baseColor=color(102);

  rectX=width/2-rectSize/2;

  rectY=height/2-rectSize/2;

}


void draw(){

   update(mouseX,mouseY);

   noStroke();

   if(rectOver){

     background(rectColor);

   }else {

     background(baseColor); 

   }

   

   stroke(255);

   fill(rectColor);

   rect(rectX,rectY,rectSize,rectSize);

}


void update(int x,int y){

  if(overRect(rectX,rectY,rectSize,rectSize)){

    rectOver=true;

  }else{

    rectOver=false;

  }

}


boolean overRect(int x,int y,int width,int height){

   if(mouseX>=x && mouseX<=x+width &&

   mouseY>=y && mouseY<y+height){

     return true;

   }else{

     return false;

   }

   

}