Does the function draw() clear the screen?

My teacher said that the draw() method run at many times per second, and it always clear the screen.
But it doesn’t seems like it. By his teachings this code should draw nothing as it is run only once. Than it will be erased.

boolean test = true;
void setup(){
  size(640,480);
}
void draw(){
  if(test){
    for(int i = 0; i < 640; i++){
      point(i,240);
    }
    test = false;
  }
}

I do not understand this, or what he said was wrong?

Hello,

This may help:
https://processing.org/reference/draw_.html
https://processing.org/examples/setupdraw.html
https://processing.org/reference/frameRate_.html

:)

Yes, draw runs 60 times per second approx.

No, draw doesn’t clear the canvas

to clear the canvas say background(0); in the first line of draw()


boolean test = true;

void setup() {
  size(640, 480);
  background(190);
}

void draw() {
  background(190); 
  if (test) {
    for (int i = 0; i < 640; i++) {
      point(i, 240);
    }
    test = false;
  }
}

Thank you for your quick answers !
My teacher didn’t even mention the background() method :upside_down_face:
I read the references, now I understand it.

Hello @Tauter ,

Did your instructor provide you with resources?

Such as:

Just curious.

:)

Yes, he said the references in https://processing.org/ is helpful.
Honestly I feel stupid, because my question is clearly answered there.
But besides the references we didn’t get anyhelp like a code example or something like this. Only the tasks descriptions.

@Tauter,

There is a lot there to navigate through. I am finding new things all the time!

Have fun!

:)