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
PGraphicsPDF (Read 3122 times)
PGraphicsPDF
Aug 14th, 2008, 2:45am
 
I've been looking at:
http://processing.org/reference/libraries/pdf/index.html

and the "Pausing While Recording (With Screen Display)" example doesn't work (besides the ' missing).

It seems that version 135 has trouble creating a PGraphicsPDF object from "createGraphics". I've been searching about this topic in the board but nothing popped up.

Any suggestion?
Thanks
Re: PGraphicsPDF
Reply #1 - Aug 14th, 2008, 1:44pm
 
sorry about that, it looks like those examples need to be cleaned up a bit. here's a fixed version of the one you mentioned:

Quote:
import processing.pdf.*;

boolean recording;
PGraphicsPDF pdf;

void setup() {
 size(400, 400);
 pdf = (PGraphicsPDF) createGraphics(width, height, PDF, "pause-resume.pdf");
}

void draw() {
 // Be sure not to call background, otherwise your file
 // will just accumulate lots of mess, only to become invisible
 
 // Draw something good here
 if (mousePressed) {
   line(pmouseX, pmouseY, mouseX, mouseY);
 }
}

void keyPressed() {
 if (key == 'r') {
   if (recording) {
     endRecord();
     println("Recording stopped.");
     recording = false;
   } else {
     beginRecord(pdf);
     println("Recording started.");
     recording = true;
   }
 } else if (key == 'q') {
   if (recording) {
     endRecord();
   }
   exit();
 }
}

Re: PGraphicsPDF
Reply #2 - Aug 14th, 2008, 2:42pm
 
Thanks!!!!
Re: PGraphicsPDF
Reply #3 - Aug 23rd, 2008, 3:06pm
 
Thank you for reporting this Herbert. It's fixed online and will be corrected with the software for the next release.
Re: PGraphicsPDF
Reply #4 - Jun 3rd, 2011, 8:47am
 
fry wrote on Aug 14th, 2008, 1:44pm:
sorry about that, it looks like those examples need to be cleaned up a bit. here's a fixed version of the one you mentioned:

Quote:
import processing.pdf.*;

boolean recording;
PGraphicsPDF pdf;

void setup() {
 size(400, 400);
 pdf = (PGraphicsPDF) createGraphics(width, height, PDF, "pause-resume.pdf");
}

void draw() {
 // Be sure not to call background, otherwise your file
 // will just accumulate lots of mess, only to become invisible
 
 // Draw something good here
 if (mousePressed) {
   line(pmouseX, pmouseY, mouseX, mouseY);
 }
}

void keyPressed() {
 if (key == 'r') {
   if (recording) {
     endRecord();
     println("Recording stopped.");
     recording = false;
   } else {
     beginRecord(pdf);
     println("Recording started.");
     recording = true;
   }
 } else if (key == 'q') {
   if (recording) {
     endRecord();
   }
   exit();
 }
}



Unfortunately this example overwrites the previous recording. I mean you can keep in the PDF file only the last sequence of your drawing.
Is there a way you could append the lines over and over or even press a key for nextPage() or something

Thanks in advance
Page Index Toggle Pages: 1