Created
December 27, 2017 17:23
-
-
Save takawo/3e66b85c748e5a57cd77fe93de615832 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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