Skip to content

Instantly share code, notes, and snippets.

@takawo
Created Dec 27, 2017
Embed
What would you like to do?
import processing.pdf.*;
import java.util.Calendar;
boolean savePDF = false;
void setup() {
//settings();
}
void settings() {
int dpi=72;
float width_mm=210;
float height_mm=297;
int width_px=int(width_mm*0.03937*dpi);
int height_px=int(height_mm*0.03937*dpi);
size(width_px, height_px);
}
void draw() {
if (savePDF) beginRecord(PDF, timestamp()+".pdf");
colorMode(HSB, width, height, 100);
// write some code...
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