Perlin Star


  // Perlin Star - Jim Bumgardner
  // 
  // Using noise to permutate the points of a star shape
  
  int nbrPoints = 11;
  float mutateSpeed = .001;
  float rotateSpeed = .0001;
  float innerRatio = 2/9.0;
  
  void setup()
  {
    size(500,500);
    smooth();
    noStroke();
  }
  
  void draw()
  {
    background( #000030 );
    fill( #F6DD08 );
    float orad = height*.3;
    float irad = orad*innerRatio;
    float dev = orad*.8;
  
    pushMatrix();
    translate(width/2,height/2);
    rotate(millis()*.0001);
    float a = TWO_PI/nbrPoints;
    float a2 = a*1.5;
    beginShape();
    for (int i = 0; i < nbrPoints; ++i) {
      vertex( cos( a * i) * (orad+noise(i,0,millis()*mutateSpeed)*dev), sin( a * i) * (orad+noise(i,1,millis()*mutateSpeed)*dev));
      vertex( cos( a * (i+.5)) * irad, sin( a * (i+.5)) * irad);
    }
    endShape(CLOSE);
    popMatrix();
  }