# Filling window with points

**URL:** <https://discourse.processing.org/t/filling-window-with-points/5108>\
**Category:** Coding Questions\
**Created:** [November 2, 2018, 9:07am UTC](https://discourse.processing.org/t/filling-window-with-points/5108 "2018-11-02T09:07:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![techMatt](https://avatars.discourse-cdn.com/v4/letter/t/e47774/32.png) [@techMatt](https://discourse.processing.org/u/techMatt)\
**Post date:** [November 2, 2018, 9:07am UTC](https://discourse.processing.org/t/filling-window-with-points/5108/1 "2018-11-02T09:07:20Z")

</div>

Hello guys, i’m here with my first processing issue. I don’t know why this code doesn’t work. My purpose was filling the entire window with points but i don’t see no points at all. Why?☹☹

This is the code:

```auto
//Program that fills the window with point

int x = 0;
int y = 0;

void setup()
{
  
  size(600, 600);
  background(255);
  stroke(0);
  
}

void loop()
{
  
  while(true) //for(int i = 0; i < 360000; i++)
  {
    
    point(x, y);
    x = x + 1;
    
    if (x == 600) //When the points arrives to the extreme right
    {
      
      x = 0;
      y = y + 1;
      
    }
    
  }
  
}

```

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [November 2, 2018, 9:40am UTC](https://discourse.processing.org/t/filling-window-with-points/5108/2 "2018-11-02T09:40:53Z")

</div>

Normally, sketches have two functions: `setup()` and `draw()`.

Your sketch has two functions, but they are `setup()` and `loop()`.

… Your `loop()` function should be named `draw()`.

Even with that change, the code - as it is now - will not work, because you have an endless loop inside (what will be) `draw()`: `while(true){ }` runs forever. And since what is drawn in draw is only shown to the user when the draw() function is DONE, if it never exist, then nothing is ever drawn.

You should use the for loop you have commented out instead.

Try making these changes and see if it helps. If not, post the code again, with the changes you tried, for more help.

---

<div class="post-metadata">

**Author:** ![techMatt](https://avatars.discourse-cdn.com/v4/letter/t/e47774/32.png) [@techMatt](https://discourse.processing.org/u/techMatt)\
**Post date:** [November 2, 2018, 11:15am UTC](https://discourse.processing.org/t/filling-window-with-points/5108/3 "2018-11-02T11:15:57Z")

</div>

Yes, it works. But i didn’t understand why with the while it doesn’t work. I put the while because a for that runs 360000 times can be replaced with a while (true) and my idea was that when the windows is full of points i simply close the window.

\*\*Edit. I understood my error 😂
