Skip to content

Instantly share code, notes, and snippets.

@omundy
Created July 8, 2015 20:44
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 omundy/23c23a9c9623eb2b0abc to your computer and use it in GitHub Desktop.
Save omundy/23c23a9c9623eb2b0abc to your computer and use it in GitHub Desktop.
/**
* Simple animation to illustrate Processing.org HD video export using FFmpeg
* See this post for complete details
* http://owenmundy.com/blog/2013/01/use-processing-and-ffmpeg-to-export-hd-video/
* 2013 Owen Mundy owenmundy.com
*/
float xtheta = 0.0;
float ytheta = 0.0;
int r = 170;
int g = 101;
int b = 220;
int rn = 1;
int gn = 2;
int bn = -1;
int i = 0;
void setup() {
size(1920,1080, OPENGL);
}
void draw() {
lights();
background(255);
noStroke();
if(r <= 160 || r >= 255 ) { rn*=-1; }
if(g <= 160 || g >= 255 ) { gn*=-1; }
if(b <= 160 || b >= 255 ) { bn*=-1; }
r += rn;
g += gn;
b += bn;
fill(r, g, b);
translate (width/2, height/2);
rotateX(xtheta);
rotateY(ytheta);
rectMode(CENTER);
rect(0, 0, width/2, height/2);
xtheta += .01;
ytheta += .02;
saveFile(i++);
}
// export filenames w/leading zeros
void saveFile(int i) {
String istr = i+"";
if (i < 10) { istr = "00000" + i; }
else if (i < 100) { istr = "0000" + i; }
else if (i < 1000) { istr = "000" + i; }
else if (i < 10000) { istr = "00" + i; }
else if (i < 100000) { istr = "0" + i; }
save("p_"+ istr +".jpg");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment