> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.rj-Sancvr2U/rev.486
 * 
 * authors: 
 *   Sina Seifee

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



// This sketch builds on a prior work, "start test (Sareh, Farshid, Sina)", created by Farshid Naderi & Sina & sareh peyman & Sina Seifee
// http://studio.sketchpad.cc/sp/pad/view/ro.9PJtfYtVcODIz/rev.2526

// Pressing Control-R will render this sketch.

float time = 0;
float dis,xDis,yDis;
float xStart,yStart,xEnd,yEnd,xMid,yMid;
float xNois,yNois;
void setup() {
    background(255);
    size(400, 500);
    smooth();
    noStroke();
    frameRate(30);
    //strokeWeight(10);
} 
 
void draw() { 
 
    xStart = width/2;
    yStart = 0;
    xEnd = width/2;
    yEnd = height;
    xDis = norm(abs(xEnd-xStart),0,width);
    yDis = norm(abs(yEnd-yStart),0,height);
    dis  = norm(dist(xStart, yStart, xEnd, yEnd),-1000,1000)*300;

    background(255);
    fill(255,0,0);
    
    beginShape();
    curveVertex(xStart, yStart); // control point  (first)
    curveVertex(xStart, yStart); // point of curve (first)
    
    int count = 25;
    count++;
    for (float j=1.0; j<=count; j+=0.25) {
        for (float i=1.0; i<=count; i+=2) {
          float step = i/count;
          
          xMid = lerp(xStart, xEnd,step);
          yMid = lerp(yStart, yEnd,step);
      
          float smoothing = step;
      
          xNois= ((cos(time+i*.2 +j/2)*2)-1)*dis*yDis*smoothing*j + atan(time*i+j+1);
          //yNois= ((cos(time+j*.2 +i/2)*2)-1)*dis*smoothing;
          //strokeWeight(0.01);
          curveVertex(xMid+xNois, yMid+yNois); //mid control point 
          //ellipse(xMid+xNois, yMid+yNois, 10, 10);
        }
    }
    curveVertex(xEnd, yEnd);   // point of curve (last)
    curveVertex(xEnd, yEnd);   // control point  (last)
    endShape();
  
    time+=.005;
}