topical media & game development
graphic-processing-algorithm-Appendix-p312-3-p312-3.pde / pde
float [] xp = new float[0];
float [] yp = new float[0];
void setup(){
size(200,200);
}
void draw(){
for(int i=1; i<xp.length; i++)
if(xp[i]>0 && xp[i-1]>0) //skip
line(xp[i-1],yp[i-1],xp[i],yp[i]);
for(int i=0; i<xp.length; i++)
if(xp[i]>0)ellipse(xp[i],yp[i],4,4);
}
void mousePressed(){
xp = append(xp,mouseX);
yp = append(yp,mouseY);
}
void keyPressed(){
xp = append(xp,-1); //mark end of line
yp = append(yp,-1);
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.