# Does the function draw() clear the screen?

**URL:** <https://discourse.processing.org/t/does-the-function-draw-clear-the-screen/19614>\
**Category:** Beginners\
**Tags:** homework\
**Created:** [April 10, 2020, 10:50am UTC](https://discourse.processing.org/t/does-the-function-draw-clear-the-screen/19614 "2020-04-10T10:50:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tauter](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@Tauter](https://discourse.processing.org/u/Tauter)\
**Post date:** [April 10, 2020, 10:50am UTC](https://discourse.processing.org/t/does-the-function-draw-clear-the-screen/19614/1 "2020-04-10T10:50:56Z")

</div>

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.

```auto
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?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 10, 2020, 11:09am UTC](https://discourse.processing.org/t/does-the-function-draw-clear-the-screen/19614/2 "2020-04-10T11:09:06Z")

</div>

Hello,

This may help:  
[https://processing.org/reference/draw\_.html](https://processing.org/reference/draw_.html)  
[https://processing.org/examples/setupdraw.html](https://processing.org/examples/setupdraw.html)  
[https://processing.org/reference/frameRate\_.html](https://processing.org/reference/frameRate_.html)

`:)`

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 10, 2020, 11:35am UTC](https://discourse.processing.org/t/does-the-function-draw-clear-the-screen/19614/3 "2020-04-10T11:35:23Z")

</div>

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()

```auto

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;
  }
}

```

---

<div class="post-metadata">

**Author:** ![Tauter](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@Tauter](https://discourse.processing.org/u/Tauter)\
**Post date:** [April 10, 2020, 12:31pm UTC](https://discourse.processing.org/t/does-the-function-draw-clear-the-screen/19614/4 "2020-04-10T12:31:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 10, 2020, 1:08pm UTC](https://discourse.processing.org/t/does-the-function-draw-clear-the-screen/19614/5 "2020-04-10T13:08:47Z")

</div>

Hello @Tauter ,

Did your instructor provide you with resources?

Such as:

- Processing website:  
[https://processing.org/](https://processing.org/)

- Those available with the Processing PDE (IDE).  
An exploration of the tabs will reveal what is available.

- The Processing Foundation  
[https://processingfoundation.org/](https://processingfoundation.org/)  
Check out the tabs.  
In the education tab there is a reference to the Coding Train.

- The Coding Train:  
[https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1\_aw](https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1_aw)  
[https://thecodingtrain.com/](https://thecodingtrain.com/)

Just curious.

`:)`

---

<div class="post-metadata">

**Author:** ![Tauter](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@Tauter](https://discourse.processing.org/u/Tauter)\
**Post date:** [April 10, 2020, 1:13pm UTC](https://discourse.processing.org/t/does-the-function-draw-clear-the-screen/19614/6 "2020-04-10T13:13:30Z")

</div>

Yes, he said the references in [https://processing.org/](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.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 10, 2020, 1:21pm UTC](https://discourse.processing.org/t/does-the-function-draw-clear-the-screen/19614/7 "2020-04-10T13:21:52Z")

</div>

@Tauter,

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

Have fun!

`:)`
