We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
PDF with draw() (Read 431 times)
PDF with draw()
May 27th, 2006, 3:54pm
 
I'm wondering if it's possible to write a PDF file with a  draw() block at a particular point in an animation or interactive drawing that records all previous frames that have been written in the one PDF file.

So far I've managed to record each frame sequentially using the following method:

beginRecord(PDF, "frame-####.pdf");

... drawing stuff ...

endRecord();

This records each frame individually without overlaying them (as would be seen on the screen with this particular code). Is there a way to write a PDF at a particular frame that captures all of the previous frames as well?

Any advice would be gretaly appreciated...

Re: PDF with draw()
Reply #1 - May 27th, 2006, 10:02pm
 
If you don't want to clear whats on the stage, don't use background(color) to clear the stage. That way, each time the draw frame 'loops' the stuff in the background will be overwritten.

Then when you export to PDF, everything on the stage will be recorded.

Is that what you wanted to do?
Re: PDF with draw()
Reply #2 - May 28th, 2006, 3:15am
 
That's not really what I'm trying to do. There is already no background() function at the start of draw(), as I want the frames to accumulate, which they do when playing and viewed on screen, but not when writing a PDF.

To clarify,I've tried something along the lines of the following 2 examples, (sorry, I don't know how to put my code in an indented box).

The first example writes the first frame to PDF only...

---------------------------------------------------------
import processing.pdf.*;


void setup() {  
 size(400, 400, PDF, "filename.pdf");  
}  

void draw() {
stroke(random(255),5);
 line(0,0,random(400),random(400));  
 exit();
}
--------------------------------------------------------

This second example writes each frame as a single PDF, but does not show the previous frames in any one PDF.

---------------------------------------------------------
import processing.pdf.*;


void setup() {  
 size(400, 400);
 
}  

void draw() {  
beginRecord(PDF, "frame-####.pdf");

stroke(random(255),5);
 line(0,0,random(400),random(400));
 endRecord();
}
-----------------------------------------------------------
Essentially, I'd like to be able to capture the result of a program like this at some stage in the course of it's animation as it's seen on screen (with accumulated frames as there is no background() function at the top of the draw() block).

Any ideas?

thanks..



Re: PDF with draw()
Reply #3 - May 28th, 2006, 9:28am
 
Have you tried my 2 methods, pauseRecord() and resumeRecord() that provide the means of stopping and starting what gets drawn to the same PDF.

I don't know if they do what you need, but they are located under suggestions thread.
Re: PDF with draw()
Reply #4 - May 28th, 2006, 9:48am
 
I checked out that thread and now I've got it working perfectly.

thanks!
Page Index Toggle Pages: 1