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.
IndexDiscussionGeneral Discussion,  Status › Processing 0100 is still not 1.0...
Page Index Toggle Pages: 1
Processing 0100 is still not 1.0... (Read 4230 times)
Processing 0100 is still not 1.0...
Jan 14th, 2006, 5:10pm
 
...but it does include the first round of PDF export. mac and windows online now, just finishing up and posting the linux version.

have fun!


ABOUT REV 0100 - 13 January 2005

This is a pre-release of the PDF generating code. There will be a couple
other quick releases to follow in the coming days, and this shouldn't be
considered a "stable" release since it's not been tested heavily, but we
wanted to post it for the people who'd like to try it out.

To use it the pdf library, select Sketch -> Import Library -> pdf.
And then choose one of the following methods:

+ to render everything out to a file:

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

 void draw() {
   // draw something good here
 }

 void mousePressed() {
   exit();  // important!
 }

 this will create a sketch that draws only to a file. successive frames
 will be drawn on top of one another. when you're finished, call exit(),
 for instance, inside mousePressed() or a keyPressed() event.
 this will still open a window of size 400x400 but not draw into it.
 future releases won't open the window, since it doesn't work properly
 with sizes larger than the screen size (as might often be the case when
 rendering to a file).

+ if you want to record just a single frame, use beginRecord() and
 endRecord() inside draw:

 void draw() {
   beginRecord(PDF, "frame-####.pdf");
   // your awesome drawing happens here.
   endRecord();  // saves the file
 }

 this can also be triggered by a mouse press. the #### will cause a
 four digit "frame" number to be inserted into the filename.

+ if you want to record the entire thing to a file at the same time as
 drawing to the screen (i.e. save out an interactive drawing), do this:

 void setup() {
   size(400, 400);
   // etc
   beginRecord(PDF, "everything.pdf");
 }

 void draw() {
   // do your worst
 }

 // this needn't be mousePressed, but you need to call this somewhere
 // when you're done, to ensure that the pdf file properly closes.
 void mousePressed() {
   endRecord();
 }

Caveats with PDF rendering:

+ anything bitmapped works very poorly. so it's no good for images.

+ use createFont() with a truetype font (some opentype also work) to
 make fonts work properly. any font that shows up in PFont.list()
 should work. if you don't use createFont(), they'll likely show up
 bitmappy and gross like images. the shape of the characters may be
 weird in some cases, there seems to be a java bug with cubic vs.
 quadric splines. looking into a workaround if necessary.

+ rendering from 3D isn't yet supported, but coming soon.

+ exit() is really important when using PDF with size()
Re: Processing 0100 is still not 1.0...
Reply #1 - Jan 14th, 2006, 5:55pm
 
If pdf is going to support 3d, does this mean we might see a java2d-based engine that supports 3d?

I haven't tried out the new version yet, because I don't have anything 2d I can immediately think of that I could test out with this, but from your description, it sounds like the API interface into the pdf engine is a bit messy.

The begin record method makes sense, but I'm wondering if the size() version should only render out one frame.  Without any kind of visual feedback, you'd have no idea how many frames have been rendered, and it seems like you'll end up with a lot of redundant overlap in the pdf file?  Or maybe some option for specifying the number of frames to render before exiting.

Anyway, sounds great, will check it out now.
Re: Processing 0100 is still not 1.0...
Reply #2 - Jan 14th, 2006, 7:08pm
 
what would a java2d engine that supports 3D do? (or what would it do that P3D does not?) i'm not sure i follow.

if you want to render a single frame using size(), use noLoop() just the same as you would any other sketch. in other cases, when you don't use background(), you need to have things accumulate into the file over multiple frames, the same as they would on the screen.

and when you need the visual feedback, you use the recordXxx() methods so that you can see both.
Re: Processing 0100 is still not 1.0...
Reply #3 - Jan 14th, 2006, 7:36pm
 
It would give you a more flash-style vector 3d, and potentially hardware optimized polygon and antialiased stroke drawing.

As for the noLoop() thing, I was merely making the comment on the pdf support being somewhat confusing for beginners, how it's setup now is not exactly intuitive.  The record statements are fine.

I tried using non-interactive mode and the pdf file is corrupt:
Code:
import processing.pdf.*;

size(200,200,PDF,"test.pdf");

line(0,0,100,100);

exit();

More specifically, the file size is 0.  Adding/removing exit() makes no difference.  Same with background/stroke.

The same happens for:
Code:
import processing.pdf.*;

void setup() {
size(200,200,PDF,"test.pdf");
}
void draw() {
background(255);
stroke(0);
line(0,0,100,100);
}
void mousePressed() {
exit();
}


The following does work, however:
Code:
import processing.pdf.*;

void setup() {
size(200,200,PDF,"test.pdf");
}
void draw() {
beginRecord(PDF, "frame-####.pdf");
background(255);
stroke(0);
line(0,0,100,100);

endRecord(); // saves the file
}
void mousePressed() {
exit();
}


It would be interesting if you could somehow make multipage pdf files.

Anyway, looks good when it works, I'll have to play with it more when I get a chance.

Marcello
Re: Processing 0100 is still not 1.0...
Reply #4 - Jan 14th, 2006, 7:53pm
 
Ok, works in 0101.
Re: Processing 0100 is still not 1.0...
Reply #5 - Jan 14th, 2006, 11:30pm
 
Wow. This is great. I made a few drawings, wonderful new feature. This was actually one of the externals we were thinking of writing ourselves. Apparently there's a telepathic feature list function in the Processing community, just think about it and voila! it just pops up in the next release ;-)

fry wrote on Jan 14th, 2006, 5:10pm:
+ anything bitmapped works very poorly. so it's no good for images.


What's the reason for this Can you explain in more detail Is it a Java/PDF problem Is it a resolution problem (vector vs. raster)

fry wrote on Jan 14th, 2006, 5:10pm:
+ rendering from 3D isn't yet supported, but coming soon.


That's f*#!¿&@ great news.

In the atelier we would like to be able to use this as a tool for things that are destined for some layout application. But to my knowledge (limited in these issues) you can't dissect a PDF. Does anyone know how you can pull apart a PDF in some external layout program We would be interrested in integrating Processing-generated imagery into hand-designed software, hence the need to pull apart the vectors, etc.

Of course there's always the Illustrator exporter, but you can't add raster images and I'm crossing my fingers that raster imagery isn't an incomensurable media.
Re: Processing 0100 is still not 1.0...
Reply #6 - Jan 23rd, 2006, 12:07pm
 
Ok, so I've just done some experimentation with the PDF exporter. It's good, but very quickly limited. As you cannot really control all the parameters, it's a little frustrating.

It's nice to be able to pull it into Illustrator and pick at your Processing drawing. This is going to be great for the students here.

Exporting images actually wasn't so bad, but unfortunately tint() isn't supported, so everything is exported at 100% opacity. Obviously it's a lot of work trying to support the *entire* internal library for PDF export, but maybe Ben could give us idea on the planned features/updates?
Re: Processing 0100 is still not 1.0...
Reply #7 - Jan 23rd, 2006, 3:11pm
 
the image stuff for pdf is a low priority. the primary goal for the pdf library is to make high res vector output, so lines/shapes/type/etc are of higher importance than doing bitmaps. obviously image/pixel stuff would be nice (a necessity, generally) but it's not as high a priority as say getting PSound to work properly and to bring back P2D. it's all a matter of how much time i have, and whether anyone contributes their own time to try and get things working.

right now, we're talking to itext using a method that just subclasses a java2d drawing surface.. this seems to be the bottleneck with the pixel stuff, as the drawing surface seems to be pegged at 72dpi. this may be as simple as tweaking some parameters to itext, or i may have to implement pdf a different way in order to get it to work. in one case, it's a day or half day's work, in the latter, it's multiple days.

the 3D stuff will mean that when drawing 3D shapes, all the triangles and lines that are created from those shapes (further down the rendering pipeline) can be grabbed and exported (z sorted) to a file. this isn't done yet, but the hooks are in there and are also a priority to get sorted.

things like creating new pages are on their way too. i'm trying to figure out a clever way to do it via background(), since any call to background (often at the beginning of draw()) basically implies that you're wiping the screen and starting fresh, which makes no sense in a page format, but would make sense as a means for switching to the next page without adding api. for now, it can be done with:

((PGraphicsPDF)g).nextPage();

when size(..., PDF, ...) is used. with beginRecord, you'd do something like:

PGraphicsPDF rec = (PGraphicsPDF) beginRecord(blah, blah...);
and then when you need a new page:
rec.nextPage();

...but in general, nextPage() is a temporary thing and will go away.

also in the pipe is some stuff like not opening a window when size(PDF) is used, and proper documentation/examples of it all.
Page Index Toggle Pages: 1