Tuesday, October 12, 2010

Line Drawing

float x;
float y;
float px;
float py;
float easing= .05;

void setup() {
size(700,700);
background(255);
smooth();
stroke(random(255), random(255), random(255), random(255));
}

void draw() {
float targetX=mouseX;
x += (targetX-x) *easing;
float targetY=mouseY;
y+= (targetY-y) *easing;
float weight = dist(x,y, px, py);
strokeWeight(weight);
line(x,y, px, py);
py=y;
px=x;
if(mousePressed==true){
stroke(random(255), random(255), random(255), random(255));
}
}