Skip to content

Instantly share code, notes, and snippets.

@takawo
Created November 30, 2015 23:15
Show Gist options
  • Save takawo/10a2521df8766557a828 to your computer and use it in GitHub Desktop.
Save takawo/10a2521df8766557a828 to your computer and use it in GitHub Desktop.
import processing.pdf.*;
import java.util.Calendar;
boolean savePDF = false;
void setup() {
size(500, 500);
colorMode(HSB, 360, 100, 100);
}
void draw() {
if (savePDF) beginRecord(PDF, timestamp()+".pdf");
if (savePDF) {
savePDF = false;
endRecord();
}
}
void keyPressed() {
if (key=='s' || key=='S') saveFrame(timestamp()+"_##.png");
if (key=='p' || key=='P') savePDF = true;
}
String timestamp() {
Calendar now = Calendar.getInstance();
return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", now);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment