Hi, I am new to Processing and using the examples in the PDF library I am trying to write a code for one of my artworks. I need to save into one PDF a particular selection of frames.
I have adapted the code for the example “PDF Multiple pages” and managed to write something that does the trick.
I’ll add the code below.
My question: You can see from the example that I have created an array with the frame count numbers where I would like to have a new page in my PDF.
What I can’t work out is how to change “fc[5]” on line 31
else if ( frameCount == fc[5] )
into a general test that asks the question: if the frameCount is ANY of the integers listed in the array fc then do pdf.nextPage.
So I would like it to cycle through all the values in the array. I have tried to use the “for” loop but had no success.
My code:
import processing.pdf.*;
PFont font;
int [] fc = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 }; // array of framecounts to save in PDF
void setup() {
size(400, 400, PDF, "filename02_##.pdf");
}
void draw() {
line(0, 0, frameCount * 4, height);
fill(0);
textSize(8);
text( frameCount, frameCount*4, (height-10));
println(frameCount);
PGraphicsPDF pdf = (PGraphicsPDF) g; // Get the renderer
// this creates 5 pages, each with all frames up to a frame count
if (frameCount == fc[9]) {
println((frameCount)+ " EXIT" );
exit();
} else if ( frameCount == fc[5] ) {//this records frames 1-8 on one page. INSTEAD OF typing fc[5] how can I cycle through the values of the array?
pdf.nextPage ();
} else if ( frameCount == fc[6] ) { //this records frames 9-13 on one page
pdf.nextPage ();
} else if ( frameCount == fc[7] ) {//this records frames 14-21 on one page
pdf.nextPage ();
} else if ( frameCount == fc[8] ) { //this records frame 22-34
pdf.nextPage (); // and the last page records frame 35-98, making it 5 page PDF.
}
}
Many thanks for your time!