Skip to content

Instantly share code, notes, and snippets.

@Tsarpf
Forked from jordanorelli/gif_example.pde
Created January 15, 2017 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tsarpf/564399520ae3341b8d2b75af8b5a2a67 to your computer and use it in GitHub Desktop.
Save Tsarpf/564399520ae3341b8d2b75af8b5a2a67 to your computer and use it in GitHub Desktop.
make an animated gif with Processing
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();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment