// title: doodle // discription: This is a webbased non-printing verson of the // Collaborative Computer Generated Continuous Line Wall Doodle, 2006 // author: Matthew Nelson // date: 05/2006 float cx=0; float cy=0; float px=0; float py=0; float angle; float distance=2.0; float angle_inc=0.1; boolean ready=false; void setup() { size(600,400); background(255); framerate(100); noLoop(); smooth(); fill(0); strokeWeight(3); start_up(); px=cx; py=cy; ready=false; } void draw() { line(cx, cy, px, py); check(); drawing(); } void drawing() { px=cx; py=cy; check_mouse(); cx=get_x(distance,angle,px); cy=get_y(distance,angle,py); } float get_y(float distance, float degree, float prev_y) { float y=distance*cos(degree) + prev_y; return y; } float get_x(float distance, float degree, float prev_x) { float x=distance*sin(degree) + prev_x; return x; } void check() { if(cx>width | cx<0) { noLoop(); delay(6000); setup(); } else if(cy>height | cy<0) { noLoop(); delay(6000); setup(); } } void start_up() { float i=random(0,4); switch(int(i)) { case 0: //Top cx=random(25,width-25); cy=0; angle=0.0; drawing(); break; case 1: //Right cx=width; cy=random(25,height-25); angle=-1.57; drawing(); break; case 2: //Bottom cx=random(25,width-25); cy=height; angle=3.14; drawing(); break; case 3: //Left cx=0; cy=random(25,height-25); angle=1.57; drawing(); break; } } void keyPressed() { switch(keyCode) { case LEFT: if(ready == true) { angle=angle+angle_inc; drawing(); } break; case RIGHT: if(ready == true) { angle=angle-angle_inc; drawing(); } break; case ENTER: ready = true; loop(); break; } } void mousePressed() { ready=true; loop(); } void check_mouse() { if(mouseX > pmouseX) { angle=angle+angle_inc; } else if(mouseX < pmouseX) { angle=angle-angle_inc; } }