Hi There!

So I am trying to create a smooth gradation of polygons using **storing**.

I need to dynamically change the amount of points and store them to fade consequently.

However, the code changes all the polygons at the same time…

Bellow is the full code, underneeth it - I highlighted the key moments:

```
int num = 60; // amnt of storing data
int a = 0;
float mouse[] = new float[num];
int numbers[] = new int[num]; // type name[create array] =store= new type[how long is it]
//rn the array has "num" length, filled entirely with zeros 0
// numbers[4] = 100 - [index in the list] = now equals 100
//i need an array length = num, but filled with different numPoints values {5,6,7,4,3,8}
//so I dont need to create an array numPoints...
void setup() {
size(640, 640);
noFill();
}
void draw() {
stroke(200, a);
background(3, 7, 11);
int numPoints = round(random(3,6)); //dynamically change the numPoints
float angle = 0;
float angleStep = 180.0 / numPoints;
float ptx[] = new float[numPoints];
float pty[] = new float[numPoints];
//cycle through the array (indexes), using a different entry on each frame
int idx = frameCount % num; //array index = framecount % num (% - reminder of what is left after division)
mouse[idx] = dist(mouseX, mouseY, width * 0.5, height * 0.5); //each frame = each index in the list = new values
numbers[idx] = numPoints; //each frame = each index = new value
int pts = frameCount % numPoints;
for (int i = 0; i < num; i++) {
int m_idx = (idx + 1 + i) % num; //idx+1 is the smallest (the oldest in the array)
int n_idx = (idx + 1 + i) % num;
beginShape(TRIANGLE_STRIP);
for (int j = 0; j <= numbers[n_idx]; j++) {
float px = (width * 0.5) + cos(radians(angle)) * mouse[m_idx];
float py = (height * 0.5) + sin(radians(angle)) * mouse[m_idx];
angle += angleStep;
ptx[pts] = px;
pty[pts] = py;
vertex(ptx[pts], pty[pts]);
}
endShape();
}
a -= 2;
}
void mouseMoved() {
a = 150;
}
```

In order to dynamically change the number of polygons (for example randomly), I am doing the following:

I create a new array before void setup

`int numbers[] = new int[num];`

Which means that I will have an array length = the num value.

The num here is the amount of stored data.

Now I need to fill each index of the array with different amount of polygons

in **void draw** :

```
int numPoints = round(random(3,6)); //dynamically change the numPoints
int idx = frameCount % num;
numbers[idx] = numPoints;
```

to cycle through the array indexes (each frame = each index = curren numPoints).

then build the shapes based on stored polygons:

```
for (int i = 0; i < num; i++) {
int n_idx = (idx + 1 + i) % num; // /idx+1 is the smallest (the oldest in the array)
beginShape(TRIANGLE_STRIP);
for (int j = 0; j <= numbers[n_idx]; j++) {
float px = (width * 0.5) + cos(radians(angle)) * mouse[m_idx];
float py = (height * 0.5) + sin(radians(angle)) * mouse[m_idx];
angle += angleStep;
vertex(px, py);
}
endShape();
}
```

but as I previously mentioned, it changes all the geometries at once, and does not store the old shapes :C

Could someone please please advice on what am I doing wrong?

p.s. Thank you @ slow_izzm for previously helping with the storing radiuses!