gif_example shows how to make animated gifs

main
Jordan Orelli 4 years ago
parent 598b9919c0
commit b56196364a

@ -0,0 +1,3 @@
# gif example
Example for writing a Processing sketch that exports an animated gif

@ -0,0 +1,38 @@
import gifAnimation.*;
GifMaker gifExport;
int frames = 0;
int totalFrames = 120;
public void setup() {
smooth();
size(400, 400);
gifExport = new GifMaker(this, "export.gif", 100);
gifExport.setRepeat(0); // make it an "endless" animation
noFill();
stroke(0);
strokeWeight(20);
}
void draw() {
background(255);
float size = 100.0 * sin(TWO_PI * frames / float(totalFrames)) + 200.0;
ellipse(width/ 2.0, height / 2.0, size, size);
export();
}
void export() {
if(frames < totalFrames) {
gifExport.setDelay(20);
gifExport.addFrame();
frames++;
} else {
gifExport.finish();
frames++;
println("gif saved");
exit();
}
}
Loading…
Cancel
Save