> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.Ejw8Z$wsejp/rev.2129
 * 
 * authors: 
 *   Nuno Lopes

 * 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 i = 0; 
int j = 0;
int sgnl=1;
int mx=300;
int my=300;
int swtch=0;
float scale=0.0;
float rtt=0.0;

void setup() {  // this is run once.   
    
    // set the background color
    background(0);
    
    // canvas size (Variable aren't evaluated. Integers only, please.)
    size(600, 600); 
      
    // smooth edges
    smooth();
    
    // limit the number of frames per second
    frameRate(30);
    
    // set the width of the line. 
    strokeWeight(1);
} 


void flower(float radius,float rtt){

    float[] rx=new float[311];
    float[] ry=new float[311];
    
   beginShape();
    for(int i=9;i<311;i++){
    rx[i]=mx+(radius*cos(16.*PI*i/300.))*sin(i/48.+rtt);
    ry[i]=my+(radius*cos(16.*PI*i/300.))*cos(i/48.+rtt);
    curveVertex(rx[i],ry[i]);
    fill(200);
    }
    endShape(CLOSE);
}



void draw() {  // this is run repeatedly.  
    if (swtch==1){ 
      mx=mouseX;
      my=mouseY;
     }
    // set the color
   rtt=i*1/150.;    
    // draw the flower
   flower(i,rtt); 
     if (i==200){
    sgnl=-2;}
    if (i<=0) {
        stroke(10,10,10,random(255));    
            //stroke(random(255), random(255), random(255), 100);    
    sgnl=1;
   }
    
    i+=sgnl;   
    fill(255);
    pushMatrix();
    fill(0, 0, 0, 255);
    ellipse(mx,my,5,5);
    popMatrix();
    fill(255);
    
}

void mousePressed() {
  if (swtch==0) {  
    swtch=1;
  } 
  else {
    swtch=0;
  }
}