I always go back to the PDF reference page to answer such questions...
The Pausing While Recording (With Screen Display) entry seems to fit your:
The Pausing While Recording (With Screen Display) entry seems to fit your:
- import processing.pdf.*;
- PGraphicsPDF pg;
- boolean doSave = false;
- int canvasW = 320;
- int canvasH = 240;
- void setup() {
- size(640, 480);
- pg = (PGraphicsPDF)createGraphics(canvasW, canvasH, PDF, "ellipse.pdf");
- }
- void draw() {
- if (doSave) {
- println("saving pdf file");
- beginRecord(pg);
- }
- background(220, 20, 100);
- stroke(255);
- fill(125);
- ellipse(canvasW / 2, canvasH / 2, 50, 50);
- stroke(#00FF00, 50);
- fill(#229933, 50);
- ellipse(width / 2, height / 2, 450, 350);
- if (doSave) {
- endRecord();
- doSave = false;
- println("save complete");
- }
- }
- void keyPressed() {
- if (key == 's' || key == 'S') {
- doSave = true;
- }
- }