FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Tools
(Moderator: REAS)
   Adobe Illustrator Export Class
« No topic | Next topic »

Pages: 1 2 3 
   Author  Topic: Adobe Illustrator Export Class  (Read 11055 times)
awmartin

WWW
Adobe Illustrator Export Class
« on: Jun 1st, 2004, 5:25pm »

I've just written a class that writes Adobe Illustrator files from Processing.  It's meant to record what Processing draws by simply replacing the Processing functions like line() and beginShape() with equivalents that have Illustrator-writing code.  After declaring the exporting object (AIExport ai;), all you have to do is paste "ai.ai_" in front of all the drawing functions you want to write to the .ai file.  For example, you replace line() with ai.ai_line(), or replace stroke() with ai.ai_stroke().
 
It can write lines, rectangles, bezier curves, shapes defined with beginShape...endShape, etc.; you can specify transparency, lineweights, make groups, etc., and specify and write to any number of layers.  It vectorizes what you see in your sketch window, with all the persective distortions, translations, and rotations.  There are some limitations, like the only colorspace I've implemented is RGB, and the curve() and curveVertex() functions aren't there, but most are.
 
The way it operates is to record what is drawn in one frame, essentially one call of loop().  You can record one view, manually record several snapshots that overlap, or specify a framerate and record continuously.
 
Check it out at my website:
http://pantheon.yale.edu/~awm9/aiexport
 
Please read the notes on how to use it. I haven't fully tested it, so I'm sure it's fragile and that there are some bugs somewhere, but I would really like to see if this is useful to anyone, so send me or post your results!
 
william martin [awmartin] YSoA
 
« Last Edit: Jun 6th, 2004, 2:23am by awmartin »  
amoeba

WWW
Re: Adobe Illustrator Export Class
« Reply #1 on: Jun 1st, 2004, 7:26pm »

Wow, that's a substantial piece of work. Nice trick to use the screenX() and screenY() to get transformed coordinates. Does it use 3D sorting, or will 3D shapes get written in the order they are executed?
 
It's certainly much more complete than my SimplePostscript lib, particularly with the transformations and transparency added in. The layer functionality from AI should also be very useful.
 

marius watz // amoeba
http://processing.unlekker.net/
awmartin

WWW
Re: Adobe Illustrator Export Class
« Reply #2 on: Jun 2nd, 2004, 12:23am »

Thanks.  There is no 3D sorting...yet.  Right now it draws in the order the drawing commands are executed, and consequently those drawn first to last are layered back to front on their associated layers, with Layer 1 being on the bottom.  This makes boxes and shapes a little weird at times, but if one is recording moving or changing graphics over time, this might not be such a big problem.  Using groups and layers can make it easier to correct the order once the output is in Illustrator as well.  Transparency also helps.
 
william martin [awmartin]
« Last Edit: Jun 6th, 2004, 2:24am by awmartin »  
awmartin

WWW
Re: Adobe Illustrator Export Class
« Reply #3 on: Jun 11th, 2004, 4:58pm »

For those interested, I've updated the library so everything's contained in a single .jar file.  Just add it to your 'code' folder and you're ready to go.
 
awmartin
 
bren

WWW Email
Re: Adobe Illustrator Export Class
« Reply #4 on: Jun 12th, 2004, 4:17pm »

very very cool - only thing is I can't open the file directly in Photoshop 7 (mac osx) - get a parse error. Opens fine in Freehand 10 but obviously I can't use the transparency stuff. Tried looking at the file with bbedit and seems fine. Any ideas? Haven't got Illustrator on this Mac!
 
bren

WWW Email
Re: Adobe Illustrator Export Class
« Reply #5 on: Jun 12th, 2004, 5:50pm »

I seem to be getting any text I export set at 0,0 for x and y, even though I seem to be setting it in the code? I also get import errors when trying to bring it into Illustrator 10 - "offending operator Tf"?
« Last Edit: Jun 14th, 2004, 1:19pm by bren »  
bren

WWW Email
Re: Adobe Illustrator Export Class
« Reply #6 on: Jun 14th, 2004, 1:17pm »

Given up on the type for now. In the meantime this is a closeup of some ai output from the sonia generated Etude piece:
http://www.brendandawes.com/sketches/etude_closeup.png
 
Check out the transparency!
 
ess

Email
Re: Adobe Illustrator Export Class
« Reply #7 on: Jun 14th, 2004, 2:36pm »

Code:
For those interested, I've updated the library so everything's contained in a single .jar file.  Just add it to your 'code' folder and you're ready to go.  
 
awmartin

 
Hi awmartin,
 
this is kinda a general java question, so bear with me.  I heard this 'code' folder mentioned a couple times and I'd like to find out how this works.  is this a directory used by the PDE to gain access to these commands?
 
Or is this a folder that you place in your webspace to so that your applet has access to it.  And if so, what syntax is used to define the path to it in the webpages where the applet is?
 
I ask because I'd like to use some of the Sun JDBC commands in an applet built with processing but I'm having trouble figuring out how to let processing find them.
 
thanks,
 
ess
 
 
skloopy

WWW
Re: Adobe Illustrator Export Class
« Reply #8 on: Jun 15th, 2004, 10:43pm »

Hey I'm having a little trouble getting the AIExport to work.. When I run the example bezier test or my own sketch, takeSnapShot() throws the error "IncompatableClassChangeError", and when I use dumpSnapShots(), it exports the AI file, but then i freezes the P5 sketch.
 
Any ideas why it's happening? I'm on Mac OS 10.3.4 and P69.
 
Also do you have to wait from the time when you call takeSnapShot() and  dumpSnapShots() ? I'm just askin cuz i wanna take whatevers onscreen and just dump that to an AI file immediatly when the user presses a "save" button.
 
Oh BTW ess, the code folder is a folder you can make beside the data folder in a sketch to hold extra libraries like this one to use with your sketch.
« Last Edit: Jun 15th, 2004, 10:57pm by skloopy »  
awmartin

WWW
Re: Adobe Illustrator Export Class
« Reply #9 on: Jun 16th, 2004, 6:18am »

on Jun 14th, 2004, 1:17pm, bren wrote:
Given up on the type for now. In the meantime this is a closeup of some ai output from the sonia generated Etude piece:
http://www.brendandawes.com/sketches/etude_closeup.png
 
Check out the transparency!

 
This rocks!  Thanks for sharing!
 
It's great that you got some output, and I'll work on the text problem.  I'm using Illustrator CS, and when loading a file with text, it asks whether to update the legacy text or not.  Does Illustrator 10 do the same I've seen the 'offending operator' message before while I was working on type, and the specification for type in the version 7 specs was quite complex.  It seems that type for versions of Illustrator after 7 use a very different method for specifying it.  I'll see if I can implement the newer way and let you know.  Also, if you could give me an example of some minimal code which causes the two errors, maybe I can find out if it's related to the text operators or the operators around them which cause the trouble.
 
As for loading it in Photoshop, I would venture the guess that since the AI exporter from Processing doesn't make a PDF-compatible file, Photoshop won't parse it correctly.  I just loaded one in Freehand and I'm amazed that it even works.  The only thing I can suggest at this point is to save it from Freehand as a .eps file, then load it in Photoshop, but I'm not sure what information you lose by doing this.
 
awmartin
« Last Edit: Jun 16th, 2004, 6:54am by awmartin »  
awmartin

WWW
Re: Adobe Illustrator Export Class
« Reply #10 on: Jun 16th, 2004, 6:32am »

on Jun 15th, 2004, 10:43pm, scloopy wrote:
Hey I'm having a little trouble getting the AIExport to work.. When I run the example bezier test or my own sketch, takeSnapShot() throws the error "IncompatableClassChangeError", and when I use dumpSnapShots(), it exports the AI file, but then i freezes the P5 sketch.
 
Any ideas why it's happening I'm on Mac OS 10.3.4 and P69.
 
Also do you have to wait from the time when you call takeSnapShot() and  dumpSnapShots() I'm just askin cuz i wanna take whatevers onscreen and just dump that to an AI file immediatly when the user presses a "save" button.
 
Oh BTW ess, the code folder is a folder you can make beside the data folder in a sketch to hold extra libraries like this one to use with your sketch.

 
 
If all you're recording is what's being drawn on screen, the best function to use is beginWriting(). This does exacly that. All takeSnapShot() does is exactly what beginWriting() does, except it doesn't write the file--it only records the output.  You have to wait one call of loop(), or one frame, to call dumpSnapShots(). If you do implement beginWriting() and you still get the same error, show me the offending code and we'll go from there.
 
As for the 'IncompatibleClassChangeError', I honestly don't have a clue right now.  It may be the fact that you're running on a Mac, or maybe P69, since I'm using P68, but I'll definitely look into it.  No definite ideas now.
 
awmartin
« Last Edit: Jun 16th, 2004, 6:50am by awmartin »  
awmartin

WWW
Re: Adobe Illustrator Export Class
« Reply #11 on: Jun 16th, 2004, 6:42am »

on Jun 14th, 2004, 2:36pm, ess wrote:

Hi awmartin,
 
this is kinda a general java question, so bear with me.  I heard this 'code' folder mentioned a couple times and I'd like to find out how this works.  is this a directory used by the PDE to gain access to these commands
 
Or is this a folder that you place in your webspace to so that your applet has access to it.  And if so, what syntax is used to define the path to it in the webpages where the applet is
 
I ask because I'd like to use some of the Sun JDBC commands in an applet built with processing but I'm having trouble figuring out how to let processing find them.
 
thanks,
 
ess
 

 
Hi ess,
 
scloopy's right.  You can either create the code folder next to the data folder in the sketch in question and then drop AIExport.jar in it, or you can use Sketch->Add File..., and Processing will automatically create the code folder for you.  When you export the sketch to the web, it will include all the files in 'code' and 'data' that you need, but in this case, of course, the applet won't write the .ai file from a browser.
 
awmartin
 
skloopy

WWW
Re: Adobe Illustrator Export Class
« Reply #12 on: Jun 16th, 2004, 8:05am »

on Jun 16th, 2004, 6:32am, awmartin wrote:
If you do implement beginWriting() and you still get the same error, show me the offending code and we'll go from there.

 
I tried to use beginWriting() and that throws the same error. All i was using was the example sketch you have on your site. It's gotta be a 69 thing because it works in 68.
 
Is beginWriting the best way to record if i just want to capture one frame Also I as thinking it'd bee nice to be able to write out to a specific file, like so if you had writing happen when you pressed a key, every time you pressed it i could make a new file.
 
awmartin

WWW
Re: Adobe Illustrator Export Class
« Reply #13 on: Jun 16th, 2004, 4:43pm »

on Jun 16th, 2004, 8:05am, scloopy wrote:
I tried to use beginWriting() and that throws the same error. All i was using was the example sketch you have on your site. It's gotta be a 69 thing because it works in 68.
 
Is beginWriting the best way to record if i just want to capture one frame Also I as thinking it'd bee nice to be able to write out to a specific file, like so if you had writing happen when you pressed a key, every time you pressed it i could make a new file.

 
beginWriting() is meant for exactly that. Here's an example of what I've done before to achieve what you've written:
 
Code:
int fileNum=0;
void keyPressed(){
  if( key=='e' ){
    fileNum++;
    ai.setFileName( "ai_output_" + fileNum + ".ai" );
    ai.beginWriting();
  }
}

 
So that way you get a frame saved to "ai_output_1.ai", another to "ai_output_2.ai", etc., every time the user presses 'e'.
 
I'm going to download P69 and see what the problem is.
 
awmartin
« Last Edit: Jun 16th, 2004, 4:43pm by awmartin »  
bren

WWW Email
Re: Adobe Illustrator Export Class
« Reply #14 on: Jun 16th, 2004, 5:49pm »

on Jun 16th, 2004, 6:18am, awmartin wrote:

It's great that you got some output, and I'll work on the text problem.  I'm using Illustrator CS, and when loading a file with text, it asks whether to update the legacy text or not.  Does Illustrator 10 do the same

 
10 throws up an error and doesn;t mention the legacy text. V Strange! As for parsing into Photoshop, I found the best way was to copy the image from Illustrator than paste into an already presized document in Photoshop. You can then scale the image as big as you need and then click to paste it in. Super dooper hi-res quality graphics with transparency!
 
It would be cool if you could take a look at the text stuff. I'll try and get some code to you to demonstrate the problem. The weird thing is in Freehand the error doesn't come up, just the fact that all the text is at 0,0 - but then it is in Illustrator format.
 
Pages: 1 2 3 

« No topic | Next topic »