> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.nZvLJ4pJCUE/rev.1672
 * 
 * authors: 
 *   Clement GALIDIE
 *   

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



int sizeinit=10;

void setup()
{
  size(400, 600);
}

void draw()
{
    if (sizeinit<200) sizeinit=sizeinit+10;
    else
      noLoop();
    
    background(64, 64, 255);
    drawRec(width/3, height, width/3, height-sizeinit, 16, 150, 65);
    drawRec(2*width/3, height, 2*width/3, height-sizeinit*.5, 16, 150, 65);

}


void drawRec(int x1, int y1, int x2, int y2, float p, int a, int b)
{
    stroke(a,b,0);
    strokeWeight(p);
    if (dist(x1,y1,x2,y2)<1) return;
    
    //calcul du prochain point
   int x3 = x2+ (0.1+noise(x1/100.0))*(x2-x1) + noise(y1/100.0)*0.5*(y2-y1);
   int y3 = y2+ (0.1+noise(x1/100.0))*(y2-y1) + noise(y1/100.0)*0.5*(x1-x2);
   int x4 = x2+ (0.1+noise(x2/100.0))*(x2-x1) + noise(y2/100.0)*0.5*(y1-y2);
   int y4 = y2+ (0.1+noise(x2/100.0))*(y2-y1) + noise(y2/100.0)*0.5*(x2-x1);
   line(x1, y1, x2, y2);
   
   //Taille et couleur selon l'étape
    float p2 = p*0.7;
    if (p<1) p2=1;
    int a2= a-15;
    int b2=b+8;
    
    drawRec(x2, y2, x3, y3, p2,a2,b2);
    drawRec(x2,y2,x4,y4, p2,a2,b2);
    
}