This may be simpler and does not use PGraphics; I did something similar with a PGraphics object.
- Generate an array of 1000 stars in setup(),
- Display stars in draw() and update number of stars to display (from 0 to 999) every 2 seconds (120 frames).
float [][] stars;
int count = 0;
void setup()
{
size(500, 500);
stars = new float [1000][3];
for (int i = 0; i<1000; i++)
{
stars[i][0] = ?; // random x
stars[i][1] = ?; // random y
stars[i][2] = ?; // random strokeWeight
}
}
void draw()
{
background(0);
if (frameCount%120==0) //every 2 seconds
count++;
starfield2(count);
if (count>=999) count = 999;
}
void starfield2(int starCount)
{
stroke(255);
for (int i = 0; i<starCount; i++)
{
? //strokeweight from array
? // point from array
}
}