Created
August 25, 2015 19:00
-
-
Save PullJosh/117f64d2dacfbf3110ef to your computer and use it in GitHub Desktop.
Tiled Loader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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