PDF save another newbie question please help!!
in
Core Library Questions
•
11 months ago
So I am trying to write images created with processing to a pdf to no avail.
I borrowed the script from the resources page. the last bit at the end is supposed to keep the script from writing thousands of frames but unfortunately it is writing many images. I would like to just write one pdf at a time from the image at mouse press or even better at keypress.
Any help would be greatly appreciated. Thanks in advance for any tips!
Here is the code im using and where it is placed in the script.
at top of script
int maxnum = 201;
int cnt = 0;
// minimum distance to draw connections
int mind = 333;
import processing.pdf.*;
boolean record;
at begin void draw
void draw() {
if (record) {
// Note that #### will be replaced with the frame number. Fancy!
beginRecord(PDF, "frame-####.pdf");
}
// move cities
for (int c=0;c<num;c++) {
cities[c].move();
at end of script
for (int i=0;i<11;i++) {
float a = 0.1-i/110.0;
stroke(red(c),green(c),blue(c),a*256);
point(ox1+(x1-ox1)*sin(p + sin(i*w)),oy1+(y1-oy1)*sin(p + sin(i*w)));
point(ox1+(x1-ox1)*sin(p - sin(i*w)),oy1+(y1-oy1)*sin(p - sin(i*w)));
}
line(mouseX, mouseY, width/2, height/2);
if (record) {
endRecord();
record = false;
}
}
}
// Use a keypress so thousands of files aren't created
void mousePressed() {
record = true;
}
Any help would be greatly appreciated. Thanks in advance for any tips!
Here is the code im using and where it is placed in the script.
at top of script
int maxnum = 201;
int cnt = 0;
// minimum distance to draw connections
int mind = 333;
import processing.pdf.*;
boolean record;
at begin void draw
void draw() {
if (record) {
// Note that #### will be replaced with the frame number. Fancy!
beginRecord(PDF, "frame-####.pdf");
}
// move cities
for (int c=0;c<num;c++) {
cities[c].move();
at end of script
for (int i=0;i<11;i++) {
float a = 0.1-i/110.0;
stroke(red(c),green(c),blue(c),a*256);
point(ox1+(x1-ox1)*sin(p + sin(i*w)),oy1+(y1-oy1)*sin(p + sin(i*w)));
point(ox1+(x1-ox1)*sin(p - sin(i*w)),oy1+(y1-oy1)*sin(p - sin(i*w)));
}
line(mouseX, mouseY, width/2, height/2);
if (record) {
endRecord();
record = false;
}
}
}
// Use a keypress so thousands of files aren't created
void mousePressed() {
record = true;
}
1