> show canvas only <


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

 * 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[] point1;
int[] point2;
int[] pc;
int[] p1;
int[] p2;
int[] p3;
int randnum = 0;

void setup() {
    background(255);
    size(400, 300);
    strokeWeight(1);
    point1 = {width/2, height/2};
    point2 = {0, 0};
    p1 = {width/2, 0};
    p2 = {0, height};
    p3 = {width, height};
    frameRate(600);
} 

void draw() {
    randnum = int(random(3));
    switch(randnum) {
        case 0: 
            pc = {p1[0], p1[1]};
            break;
        case 1: 
            pc = {p2[0], p2[1]};
            break;
        case 2: 
            pc = {p3[0], p3[1]};
            break;
    }
    point2 = between(point1, pc);
        stroke(0);
        strokeWeight(.1);
    line(point1[0], point1[1], point2[0], point2[1]); //lines
    point1 = point2;
        stroke(255);
        strokeWeight(2);
    line(point1[0], point1[1], point1[0]+1, point1[1]+1); //points
}

int[] between(int[] a, int[] b) {
    int[] temp = {(b[0]+a[0])/2, (b[1]+a[1])/2};
    return temp;
}