Skip to content

Instantly share code, notes, and snippets.

@PullJosh
Created August 5, 2015 23:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PullJosh/ecfe9895229dbfa82d21 to your computer and use it in GitHub Desktop.
Save PullJosh/ecfe9895229dbfa82d21 to your computer and use it in GitHub Desktop.
PullJosh's First GIF (Processing)
// IMPORTANT: Will only work if you have this: http://extrapixel.github.io/gif-animation/
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
noStroke();
}
void draw() {
background(0);
float dir = PI * frames / float(totalFrames);
fill(255);
ellipse(width / 2, height / 2, 100, 100);
fill(0);
rectPts(width / 2 + sin(dir) * -100,height / 2 + cos(dir) * -100, width/2 + sin(dir) * 100, height / 2 + cos(dir) * 100);
export();
}
void export() {
if(frames < totalFrames) {
gifExport.setDelay(20);
gifExport.addFrame();
frames++;
} else {
gifExport.finish();
frames++;
println("gif saved");
exit();
}
}
void rectPts(float x1, float y1, float x2, float y2) {
rect(x1, y1, x2 - x1, y2 - y1);
}
@an-OK-squirrel
Copy link

lefirstgif

@an-OK-squirrel
Copy link

Haha you don't like my spam? :p Hopefully you're using Processing 3, it's cool. :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment