> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.N9wxX5S2kAv/rev.1316
 * 
 * authors: 
 *   
 *   
 *   
 *   
 *   
 *   
 *   lonnen
 *   
 *   

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



// Fermat's spiral || Vogel's Floret Model
// play with the scale and color

int i = 1,
    j = 0,
    scale = 5;
    
float radius = 0,
      theta = 0,
      xpos = 0,
      ypos = 0;
      PHI = (1 + sqrt(5)) / 2,
      D_PHI = PHI * PHI;

void setup() {
    size(200,200);
    background(#222222);
    noStroke();
    smooth();
    ellipseMode(CENTER);
}

void draw () {
   if ( xpos > width - 20 || height - 20 < ypos ) {
    noLoop();
   }
   i = j++;
   radius = sqrt(i) * scale;
   theta = i * (1 * PI) / D_PHI;
   xpos = (cos(theta) * radius) + width / 2;
   ypos = (-sin(theta) * radius) + height / 2;
   fill(color(ypos % (radius - xpos),
              ypos % (theta - radius),
              xpos % (ypos - theta)));
   ellipse(xpos, ypos, scale, scale );
}