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.
IndexProgramming Questions & HelpSyntax Questions › Mashup : Tom Carden + PDF output = gray PDF
Page Index Toggle Pages: 1
Mashup : Tom Carden + PDF output = gray PDF (Read 536 times)
Mashup : Tom Carden + PDF output = gray PDF
Jun 7th, 2006, 6:06pm
 
I have been experimenting with a simple particle system created by Tom Carden back in 2005.  I am trying to get a nice PDF of it to post it as inspiration.  However the PDF output is coming through as gray.

I've attached the beginRaw and endRaw functions at the beginning and end of the draw function and is trigerred via pressing the s key.

The PDF codes works wonders in a number of other borrow experiments, (all are importing th eopenGL library whether that makes any difference i am not sure).

Help is greatly appreciated.

Here is the draw function

   if(dosave) {
   // set up PGraphicsPDF for use with beginRaw()
   PGraphicsPDF pdf=(PGraphicsPDF)beginRaw(PDF, "pdf_complex_out.pdf");

   // set default Illustrator stroke styles and paint background rect.
   pdf.strokeJoin(MITER);
   pdf.strokeCap(SQUARE);
   pdf.fill(255);
   /*pdf.noStroke();
   pdf.rect(0,0, width,height);*/
 }

 // move and draw particles
 stroke(0,4); // use lower alpha for finer detail
 
 beginShape(POINTS);
 for (int i = 0; i < particle.length; i++) {
   particle[i].step();
   vertex(particle[i].x,particle[i].y);
 }
 endShape();
 
 
 
 // reset on mouse click
 if (mousePressed) {
   scatter();
 }
if(dosave) {
   endRaw();
   dosave=false;
 }

void keyPressed() {
 if(key=='s') dosave=true;
}
Re: Mashup : Tom Carden + PDF output = gray PDF
Reply #1 - Jun 7th, 2006, 9:16pm
 
You only initialize the PDF graphics object. you'll need to draw to it, too using this method.

//move and draw particles

pdf.stroke (0,4);

blah blah
Re: Mashup : Tom Carden + PDF output = gray PDF
Reply #2 - Jun 7th, 2006, 10:07pm
 
is there a way i can take a snapshot of what is already drawn on the "stage" and transfer that to a pdf.  Or do i have to write to the PDF and not the screen?

Not sure if this has anything to do with it but, this particle code uses the P3D renderer
Re: Mashup : Tom Carden + PDF output = gray PDF
Reply #3 - Jun 8th, 2006, 11:00am
 
The gray you're seeing is most likely just the default gray rectangle that is drawn as a background in the PDF. When using  the beginRaw() / endRaw() functions you do not need to draw to it explicitly, but if I am not mistaken it will not draw points.

PDF so far only draws triangles and lines, which means that ellipses, lines, rects etc. are fine but points and beginShape(POINTS) are not. Try replacing "vertex(particle[i].x,particle[i].y);" with "rect(particle[i].x,particle[i].y,1,1);".
Re: Mashup : Tom Carden + PDF output = gray PDF
Reply #4 - Jun 8th, 2006, 3:56pm
 
watz & mark_h thank you for the very helpfull replies.  You've saved me fro mgrowing bald.  

My goal is to print these wonderfull particles on paper so I think i will take the jpeg route instead.  Not optimal for printing but definately a step in the right direction.
Page Index Toggle Pages: 1