Loading...
Logo
Processing Forum
Hi,

Relative noob here, just wanted to ask a quick question.

On this page http://processing.org/tutorials/overview/ - the Overview tutorial - there's this example code:
void setup() { 
      size(400, 400);
      stroke(255);
}

void draw() {
      line(150, 25, mouseX, mouseY);
}

void mousePressed() {
      background(192, 64, 0);
}
It says "... when the mouse is pressed, the screen is cleared via the background() function". This is true; however, if I use that code it also starts me with a grey background that changes to orange on pressing the mouse, because there's no background colour specified in the setup.

I feel that a more correct version would be:
void setup() { 
      size(400, 400);
      stroke(255);
      background(192, 64, 0);
}

void draw() {
      line(150, 25, mouseX, mouseY);
}

void mousePressed() {
      background(192, 64, 0);
}
... that way the background is already orange when the sketch runs, and clears the drawing on mouse click back to orange.

Just wondering because this would be pretty confusing to the ultra-new user.

Replies(2)

Yeah, you're right.

You can file this whole explanation as an issue here: https://github.com/processing/processing-web/issues

If accepted, the developers can change/clarify the example.