draw then delete after a number of steps
in
Programming Questions
•
2 years ago
Dear List,
I have the piece of code below. After a number of steps lets say, after drawing 100 lines, I would like to delete the line that I drew first then the second etc. and my script continues infinitely by drawing and deleting.Can somebody suggest how I can achieve this?any hints highly appreciated.
void setup(){
size(500,500);
background(0);
frameRate(20);
}
float x=0,y=250,xn=0,yn=250;
void draw(){
x = x + random(-15,15);
y = y + random(-15,15);
x = constrain(x,0,width);
y = constrain(y,0,height);
line(x,y,xn,yn);
stroke(255,0,0);
ellipse(x,y,3,3);
stroke(0,255,0);
xn = x;
yn = y;
}
1