Bonus: Circular Galaxy


int num = 40, circles=80, frames=60;
float theta;
 
void setup() {
  size(540, 540);
}
 
void draw() {
  randomSeed(3453);
  background(0);
  noStroke();
  float angle = 0;
  for (int j=0; j < circles; j++) {
    fill(255, 25);
    float r = random(TWO_PI);
    beginShape(TRIANGLE_STRIP);
    float r2 = random(30, 50);
    for (int i=0; i < num; i++) {
      angle=TWO_PI/num*i+r;
      float offSet=TWO_PI/num*i;
      float d = 120+cos(offSet*3)*r2;
      float x = width/2 +sin(theta+offSet)*10 + sin(angle)*d;
      float y = height/2 + cos(theta+offSet)*10 + cos(angle)*d;
      vertex(x, y);
      ellipse(x, y, 3, 3);
    }  
    endShape(CLOSE);
  }
  theta+=TWO_PI/frames;
  //if (frameCount <= frames) saveFrame("imge-###.gif");
}

Leave a Reply

Your email address will not be published. Required fields are marked *