> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.9YJLHEu5cic/rev.717
 * 
 * authors: 
 *   
 *   Adam Harte

 * 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.

ArrayList dragPoints;
PVector currentVec;
PVector previousVec;


void setup() { 
    background(0);
    size(400, 400);
    smooth();
    frameRate(30);
    
    stroke(204, 102, 0);
    strokeWeight(1);
    
    dragPoints = new ArrayList();
    
} 

void draw() {
    
}

void mouseDragged() {
    currentVec = new PVector(mouseX, mouseY);
    dragPoints.add(currentVec);
    
    if (previousVec != null) {
        line(
            previousVec.x, previousVec.y,
            currentVec.x, currentVec.y
        );
        
        //Loop through some points
        PVector nVec;
        for (int i=0; i<dragPoints.size()-10; i++) {
            nVec = dragPoints.get(i);
            if (currentVec.dist(nVec) <= 30) {
                line(
                    currentVec.x, currentVec.y,
                    nVec.x, nVec.y
                );
            }
        }
        
    }
    
    previousVec = currentVec
}

void mouseReleased() {
    dragPoints.clear();
    previousVec = null;
    currentVec = null;
}