Skip to content

Instantly share code, notes, and snippets.

@PullJosh
Created August 25, 2015 19:00
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 PullJosh/117f64d2dacfbf3110ef to your computer and use it in GitHub Desktop.
Save PullJosh/117f64d2dacfbf3110ef to your computer and use it in GitHub Desktop.
Tiled Loader
import gifAnimation.*;
GifMaker gifExport;
int frames = 0;
int totalFrames = 120;
public void setup() {
smooth();
size(360, 360);
gifExport = new GifMaker(this, "export.gif", 100);
gifExport.setRepeat(0); // make it an "endless" animation
}
void draw() {
background(255);
fill(#3388ee);
noStroke();
for(int x = -3; x < 3; x = x + 1) {
for(int y = -3; y < 3; y = y + 1) {
pair(width / 2 + 120 * x, height / 2 + 120 * y);
}
}
export();
}
void export() {
if(frames < totalFrames) {
gifExport.setDelay(20);
gifExport.addFrame();
frames++;
} else {
gifExport.finish();
frames++;
println("gif saved");
exit();
}
}
void pair(int x, int y) {
float loopVal = sin(TWO_PI * frames / float(totalFrames));
float loopVal2 = cos(TWO_PI * frames / float(totalFrames));
ellipse(x, y + loopVal * 60, 20, 20);
ellipse(x + loopVal2 * 60, y, 20, 20);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment