Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.