Filling window with points

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?:frowning_face::frowning_face:

This is the code:

//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;
      
    }
    
  }
  
}
1 Like

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.

1 Like

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 :joy: