We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi folks!
I've created two gif-export-functions in a seperate file to simplify the process of exporting gifs. Now all i have to do is calling the gifsetup-function in the setup and the gifdraw-function in draw.
This is an example for a sketch
int a = 0;
void setup() {
  size(540, 540);
// Call the gifsetup-function
  gifsetup();
}
void draw() {
ellipse(width/2,height/2,a,a);
a++;
// Call the gifdraw-function
// Specify, how many frames shall be recorded
  gifdraw(40);
}
The functions are stored in a separate file (gifexport.pde)
import gifAnimation.*;
GifMaker gifExport;
void gifsetup() {
  println("gifAnimation " + Gif.version());
  gifExport = new GifMaker(this, "export.gif");
  gifExport.setRepeat(0);
  gifExport.setDelay(50);
}
void gifdraw(int frames) {
  gifExport.addFrame();
  if (frameCount == frames) {
    gifExport.finish();
    println("gif saved");
    exit();
  }
}
As you can see, all i have to do to export a gif is calling two functions: 
gifsetup();
in the setup and 
gifdraw(); 
in the draw-section.
Now my question is: Is it possible to simplify the gif-export a bit more? It would be perfect, to just have one lie of code instead of two. Maybe like this
gif(40);
Thanks and enjoy your weekend!
Tim
Answers
Gifdraw could call gifsetup when framecount = 1, removing the need for the line in setup()
Perfect! Thank you, koogs!
gifexport.pde
Here's the same approach for video-export:
Note for mac-users: ffmpeg must to be installed here, even if your processing-folder is located on a different place:
my sketch
videoexport.pde
Does this work for Processing 3?