Hi, I'm new to Processing and programing in general. My apologies if this has been addressed elsewhere, but I couldn't find what I needed in the reference or other forums. I have a basic program that is structured like this:
void setup () {
// set size/background
}
void draw () {
// draw random shapes
noLoop ();
}
void mousePressed() {
saveFrame ("rs-###.jpg");
}
void keyPressed() {
setup();
redraw();
}
The idea is that the program draws a set of random shapes. If I press a key on the keyboard, it resets and draws a new set of random shapes. If I get something I like, I click the mouse and it saves a JPEG.
What I'd like to do now is get a PDF in place of a JPEG when I click the mouse. But all I can figure out is this:
import processing.pdf.*;
void setup () {
// set size/background
beginRecord(PDF, "rs-###.pdf");
}
void draw () {
// draw random shapes
noLoop ();
endRecord();
}
void mousePressed() {
saveFrame ("rs-###.jpg");
}
void keyPressed() {
setup();
redraw();
}
which saves a PDF every time the draw function is run. The problem is that I only want to save a PDF after I see what the draw function does (and would like to trigger the save with mousePressed), but it seems that I need to start recording before the draw function even runs to capture the results. Any help would be greatly appreciated!