Skip to content

Instantly share code, notes, and snippets.

@gregberger
Created May 29, 2015 20:48
Show Gist options
  • Save gregberger/2ebf5c12e5ecf550fd0e to your computer and use it in GitHub Desktop.
Save gregberger/2ebf5c12e5ecf550fd0e to your computer and use it in GitHub Desktop.
import gifAnimation.*;
PImage image;
GifMaker gifExport;
void setup() {
image = loadImage("brocoli.jpg");
size(image.width,image.height);
gifExport = new GifMaker(this, "export.gif");
gifExport.setRepeat(0); // make it an "endless" animation
gifExport.setTransparent(0,0,0);
}
void draw() {
image.loadPixels();
int resolution = width*height;
for (int i =1; i<resolution-1; i++) {
image.pixels[i] = image.pixels[i]+frameCount*(7<<2&i<<4|9);
}
image.updatePixels();
image(image, 0, 0);
gifExport.setDelay(1);
gifExport.addFrame();
}
void keyPressed() {
if (key == ' ') {
save("brocoli-"+millis()+".png");
} else if (key == 's') {
gifExport.finish();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment