> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.IUj3pkSsQF7/rev.895
 * 
 * authors: 
 *   frederic.vernier

 * license (unless otherwise specified): 
 *   creative commons attribution-share alike 3.0 license.
 *   https://creativecommons.org/licenses/by-sa/3.0/ 
 */ 



// Pressing Control-R will render this sketch.

int N = 64;
int dists[] = new int[N];
float d = 0;
float t=0;
var tt=0;

void setup() {  // this is run once.   
    
    // set the background color
    background(255);
    
    // canvas size (Variable aren't evaluated. Integers only, please.)
    size(400, 400); 
      
    // smooth edges
    smooth();
    
    // limit the number of frames per second
    frameRate(20);
    noFill();
    colorMode(HSB, 255);
    // set the width of the line. 
} 

void draw() {  // this is run repeatedly.  
    background(255);
    for (int i=0; i<N; i++)
      dists[i] = 3*noise(tt);
    for (int j=0; j<64; j++) {
      strokeWeight(0.4+1*noise(j/100));
      stroke(255-(j*5+tt*45)%255, 128, 128*noise(j/100));
      beginShape();
      int ii = t%N;
      int d0 = dists[0];
      curveVertex(width/2 +d0*cos(ii*TWO_PI/(N)), 
                  height/2+d0*sin(ii*TWO_PI/(N)));
      for (int i=0; i<N-0; i++) {
        ii = (i+t);
        curveVertex(width/2 +dists[i]*cos(ii*TWO_PI/(N)), 
                    height/2+dists[i]*sin(ii*TWO_PI/(N)));
        dists[i]+= 3*noise(tt)+18*abs(noise(dists[i]*cos(i*TWO_PI/N)/10, 
                                     dists[i]*sin(i*TWO_PI/N)/10, t/10)-0.5);
      }
      ii = t%N;
      curveVertex(width/2 +d0*cos(ii*TWO_PI/(N)), 
                  height/2+d0*sin(ii*TWO_PI/(N)));
      curveVertex(width/2 +d0*cos(ii*TWO_PI/(N-1)), 
                  height/2+d0*sin(ii*TWO_PI/(N-1)));
      endShape();
    }
    tt+=0.03;
    t+=noise(tt)-0.5;
}