Never ending loop

Why a loop is never ending a you use de function random as in:

for (int i = 0; i < 1000; i = i+1)
             {
               A = random(i);
               B = random(i);
                point(A,B);
             }

And how can you make it end

the for loop is assigned to choosing a value in the x and y, not to dictating how long the loop runs for. It runs in draw which is an infinite for loop, and therefore it never ends.

If that’s what you wanted you would need a if statement to handle the time constraint.


void setup(){
  size(200,200);
}
int j = 0;
void draw(){
  if (j<100){
  for (int i = 0; i < 100; i ++)
{
float A = random(i);
float B = random(i);
point(A,B);
}}
j++;
}

Thank you veru much…

Another way is to call noLoop() in setup. Then draw runs only once, with no loop, so your for loop runs only once, not 60fps.