Newbie - trying to change colors

So what I want is to change the color of the background of this processing project. I keep being told that a } bracket is missing and an expecting EOF (not sure what that means).

Can anyone point out what it is that I am doing wrong?
I have setup in place, draw, specify a size, make sure all the }{ match. HELP! :wink:


void setup(){
  size (600,600);
}
void draw(){
  
}
if (mouseX < width/3){
  background (255);
} else if (mouseX < 2*width/3){
  background (127);
} else {
  background (0);
}

If I run this, I get a project window with color 255 that does not change. Its supposed to change when moving the mouse. (Its an example from Learning Processing). I am not sure why its not working.


if (mouseX < width/3){
  background (255);
} else if (mouseX < 2*width/3){
  background (127);
} else {
  background (0);
}
1 Like

your ifs are outside draw

void setup() {
  size (600, 600);
}
void draw() {
  if (mouseX < width/3) {
    background (255);
  } else if (mouseX < 2*width/3) {
    background (127);
  } else {
    background (0);
  }
}

you can format the code you paste with the </> button :slight_smile:

1 Like

Thank you for the troubleshooting lesson. Its highly appreciated. :slightly_smiling_face: