When sketch loads I need draw to...

I have these buttons working, but I need the draw function to show dayBackground(); when it first loads? Right now it is just grey. Any help would be awesome.

int x1 = 50;
int y1 = 50;
int w1 = 100;
int h1= 75;

int x2 = 300;
int y2 = 50;
int w2 = 100;
int h2 = 75;

boolean night = false;
boolean day = true;

void setup() {
  size(600,600); 
}

void dayBackground(){
  background(255);
}

void nightBackground(){
  background(0);
}

void draw() {
  button1();
  button2();


}

void button1(){  
  fill(175);
  rect(x1,y1,w1,h1);
  fill(0);
  text ("Night", 110, 110);
}

void button2(){  
  fill(175);
  rect(x2,y2,w2,h2);
  fill(0);
  text ("Day", 350, 110);
}


void mousePressed() {
 if (mouseX > x1 && mouseX < x1+w1 && mouseY > y1 && mouseY < y1+h1){
    night = !night;
    nightBackground();
 }else if(mouseX > x2 && mouseX < x2+w2 && mouseY > y2 && mouseY < y2+h2){
    day = !day;
    dayBackground();
 }

}
Tagged:

Answers

Sign In or Register to comment.