Asking questions about things is also good.
Wheeee!
int numVertices=120; //int(random(30,60));
float[] curtX;
float[] curtY;
float[] nextX;
float[] nextY;
float[] angles;
float[] da;
void setup() {
size(600,600);//,P3D);
curtX = new float[numVertices];
curtY = new float[numVertices];
nextX = new float[numVertices];
nextY = new float[numVertices];
angles = new float[numVertices];
da = new float[numVertices];
// Pick initial random angles.
for (int i=0; i<numVertices; i++) {
angles[i] = i*TWO_PI/float(numVertices); //random(TWO_PI);
da[i] = random(-.05,.05);
}
colorMode(HSB, 255);
background(0);
}
void draw() {
//background(0);
fill(0,0,0,10);
noStroke();
rect(0,0,width,height);
stroke(255);
noFill();
translate(width/2, height/2);
//rotateY(map(millis()%7000,0,7000,0,TWO_PI));
float radius=280;
for (int i=0; i<numVertices; i++) {
angles[i] += da[i];
}
// Convert the random angles to (x,y) positions.
for (int i = 0; i < numVertices; i++) {
curtX[i] = cos(angles[i]) * radius;
curtY[i] = sin(angles[i]) * radius;
}
for( int t = 0; t < 20; t++){
stroke((map(t,0,20,0,128)+map(millis()%7000,0,7000,0,255))%255,255,map(t,3,20,128,255));
draw_polygon(t);
next_gen();
copy_back();
}
stroke(255);
strokeWeight(3);
ellipse(0,0,2*radius, 2*radius);
strokeWeight(1);
}
void draw_polygon(int z) {
beginShape();
for (int i = 0; i<numVertices; i++) {
vertex(curtX[i], curtY[i]);//, -20*z);
}
endShape(CLOSE);
}
void next_gen(){
for( int i = 0; i < numVertices; i++){
nextX[i] = ( curtX[i] + curtX[(i+1)%numVertices] ) / 2.0;
nextY[i] = ( curtY[i] + curtY[(i+1)%numVertices] ) / 2.0;
}
}
void copy_back(){
for( int i = 0; i < numVertices; i++){
curtX[i] = nextX[i];
curtY[i] = nextY[i];
}
}