I’m a new user of processing and i’m trying to make abstractions drawing with the below code. However I don’t arrive to erase the drawing after a certain amount of frames. Does someone knows how to do this ? Thanks on advance !
(sorry for my English)
thanks for your answer ! However it is not exactly what I meant.
What I would like is to erase one frame when an other one is created. The idea is to get a fluid movement, a continuous erasure for a continuous creation.
Oh! Just put background(0); inside draw, in the first line, instead of inside setup. This will “erase” the image every frame. Everything inside draw is executed once per frame.
You can also use image(img,0,0) if you don‘t want to erase the whole screen. Just modify the size of the img to what you want saved for the Next Frame with a PGraphics and use get(x,y,w,h) to get the Part of the background that you want to keep.
Badly explained, so here‘s an example :
PGraphics sav;
void setup() {
size(600,400);
sav = createGraphics(100,100);
}
void draw() {
background(0); //resets the whole screen to black
image(sav, 0, 0); //places the saved image in the top left, like what iPhone does shortly after saving a screenshot (best example i know...)
ellipse(300,300,50,50);//draw something beautiful you want to keep in the Next frame
sav.beginDraw();
sav.background( get(250,250,350,350)); //saves the image around the ellipse
sav.endDraw();
}