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 11058 times)
skloopy

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

Thanks Allan that worked great in 68! There's still one problem though. When I opened the ai file in illustrator CS is game me the error Illegal instruction 'S'. I looked in the source for the ai file and this is what i found:
 
Code:
...
399.01892 252.14908 L
399.07095 236.14204 L
411.08066 236.15112 L
S
S
S
...

All I'm doing in the sketch is drawing LINE_STRIPs, and it seems like for every line strip it puts another S entry after the first line strip drawn. I've tested it with different #s of lines and it's always equal to the number of S's.
 
awmartin

WWW
Re: Adobe Illustrator Export Class
« Reply #16 on: Jun 17th, 2004, 5:31pm »

on Jun 16th, 2004, 8:17pm, scloopy wrote:
Thanks Allan that worked great in 68! There's still one problem though. When I opened the ai file in illustrator CS is game me the error Illegal instruction 'S'.
 
All I'm doing in the sketch is drawing LINE_STRIPs, and it seems like for every line strip it puts another S entry after the first line strip drawn. I've tested it with different #s of lines and it's always equal to the number of S's.

 
 
I think you're going to have to give me a little snippet of code that creates the error.  I can't seem to reproduce it myself.  The only thing I can think of is executing beginShape()...endShape() with no vertex() between them, which is a condition I probably should consider in the next build, which I'm getting ready to release in the next day or so.
 
William
 
skloopy

WWW
Re: Adobe Illustrator Export Class
« Reply #17 on: Jun 18th, 2004, 2:06am »

Yeah you're right. I had some code that was leaving objects in there with no vertices in them
 
Thanks for the help and the library! I can't wait till the 69 version is out, if you're gonna make one. I'd use it in 68 but applets from 68 are almost unusable on OS X because of the 68 flicker problem.
 
ryan
 
awmartin

WWW
Re: Adobe Illustrator Export Class
« Reply #18 on: Jun 20th, 2004, 5:10am »

I've just uploaded a new build which I think should help some.  As the website now says, both color modes(RGB and HSB) are now supported, including all ways to specify color(floats, colors, hexadecimal, etc.). The beginWriting() function has been superceded by the exportOneFrame() function for clarity. beginShape()...endShape() doesn't write illegal operators if no vertex() appears between them.
 
Hopefully, that will make retrofitting existing Processing apps a little easier.
 
tobt


Re: Adobe Illustrator Export Class
« Reply #19 on: Jun 20th, 2004, 4:31pm »

Two Questions to this nice Illustrator export:
 
1. I've some problems with including the library to my script. (ok I'm new ...)  
Maybe it would be helpfull when I could look at martins example but the link to the source code is broken ...
 
2. Is it possible to export some images, too?
I cant see a method for this, but I think it should be possible. Am I right?
 
flight404

WWW Email
Re: Adobe Illustrator Export Class
« Reply #20 on: Jun 21st, 2004, 6:54pm »

I am a bit confused by the following...
 
Code:

[ transparency ]
Illustrator assigns transparency (opacity) by object, and apparently doesn't separate stroke and fill transparency. As a result, when transparency is turned on, all objects drawn with either a stroke or fill alpha channel are drawn twice and grouped (once for the stroke and once for the fill). This doesn't apply, however, to vector graphics drawn with ai_beginShape(), where the fill transparency is the one that takes precedence. Objects that are only stroked or only filled, or where the alpha channel is 255, are drawn only once. There are two functions to turn transparency on or off: ai.turnTransparencyOn(); and ai.turnTransparencyOff();. The default is off. I recommend to set this in setup(), but it probably can be done on the fly in loop() as well.

 
I am not proficient with illustrator so I was wondering: Even though my processing sketch changes the stroke alpha of every line it draws right before it draws it (allowing for shading effects from the line alpha used), the ai file ends up using only one alpha (seemingly 100% opaque).  I have tried using turnTransparencyOn() and in the final file, i get the entirety of the illustration at 0% opacity and when i turn up the opacity for the document, i see that all the lines are still at the same stroke alpha as each other.  So, is it possible to allow for different stroke alphas within one document?
 
 
UPDATE-----------------------------------
Ugh!  It seems lately that every time i ask a question, i determine the answer within moments.  I have it working when drawing lines.  But I cannot get it working when using beginShape and vertex.  Is that what this means?   Code:

ai_beginShape() makes a group for TRIANGLE_STRIP and QUAD_STRIP.
« Last Edit: Jun 21st, 2004, 9:11pm by flight404 »  
awmartin

WWW
Re: Adobe Illustrator Export Class
« Reply #21 on: Jun 22nd, 2004, 4:31am »

on Jun 21st, 2004, 6:54pm, flight404 wrote:
UPDATE-----------------------------------
Ugh!  It seems lately that every time i ask a question, i determine the answer within moments.  I have it working when drawing lines.  But I cannot get it working when using beginShape and vertex.  Is that what this means  
Code:
ai_beginShape() makes a group for TRIANGLE_STRIP and QUAD_STRIP.

 
Hi,
 
Sorry this is causing some confusion--I'm working on a better solution to transparency.  To answer your very last question, groups have nothing to do with transparency.  Whenever you draw a TRIANGLE_STRIP or QUAD_STRIP, the library groups all the triangles and quads together, so in Illustrator it appears as a single object.
 
Right now, transparency can't be changed within a beginShape()...endShape() set. Illustrator is very picky in the way it wants its tags written, and I haven't implemented an elegant way to emulate Processing's functionality yet.  For example, Processing lets you specify different fills for each vertex and different strokes for each outline in beginShape...endShape, and it creates the smooth fill gradient on each face, but Illustrator doesn't do this easily.  Also, when the fill and stroke alphas are different, all other functions(rectangle, triangle, etc.) have to be drawn twice: once for the fill, and once for the stroke.  However, having beginShape...endShape draw twice was problematic, but you can put a for{} loop around it yourself and draw the shape once with no stroke, and once with no fill.
 
In the way the library is structured now, transparency is specified once when beginShape() is called, although one could, with some experimentation, figure out how to specify different strokes and fills for various types of shapes inside beginShape...endShape.
 
However, I think the best way to deal with it now is to restructure an application so that loops that happen within beginShape...endShape happen outside of them, specify transparency, stroke, and fill outside of beginShape...endShape, and group the whole thing together with ai.beginGroup()...ai.endGroup().  One could also use triangle() and quad().  It's annoying I know, and I'm working on it.  Here's an example of what I mean:
 
Instead of:
Code:
ai.ai_beginShape( LINES );
for( int i=0;i<255;i+=5 ){
   ai.ai_stroke( 255, 153, 0, i );
   ai.ai_vertex( i, 0 );
   ai.ai_vertex( i, height );
}
ai.ai_endShape();

which won't work, do this:
Code:
ai.beginGroup();
for( int i=0;i<255;i+=5 ){
   ai.ai_stroke( 255, 153, 0, i );
   ai.ai_beginShape( LINES );
   ai.ai_vertex( i, 0 );
   ai.ai_vertex( i, height );
   ai.ai_endShape();
}
ai.endGroup();

 
Not elegant, but it works with the current build.
 
 
awmartin
« Last Edit: Jun 22nd, 2004, 5:01am by awmartin »  
awmartin

WWW
Re: Adobe Illustrator Export Class
« Reply #22 on: Jun 22nd, 2004, 4:43am »

on Jun 20th, 2004, 4:31pm, tobt wrote:
Two Questions to this nice Illustrator export:
 
1. I've some problems with including the library to my script. (ok I'm new ...)  
Maybe it would be helpfull when I could look at martins example but the link to the source code is broken ...
 
2. Is it possible to export some images, too
I cant see a method for this, but I think it should be possible. Am I right

 
Hi,
The example source code link works for me, so I think you may have tried to access it while I was updating it. Let me know if it still doesn't work.  
 
Images are the next big step for the Illustrator library.  There are several issues to address with this, which include:
[1] saving an image first loaded with loadImage() vs saving an image created within Processing,
[2] saving a manipulated image,
[3] whether they should be saved in raster format within the file or by linking to the image,
[4] perspective,
[5] linking to an image with a higher resoluction than what is displayed in the Processing window,
[6] version compatibility.
 
A rudimentary implementation is on its way.  Maybe by the end of the week.
 
awmartin
« Last Edit: Jun 22nd, 2004, 4:46am by awmartin »  
bren

WWW Email
Re: Adobe Illustrator Export Class
« Reply #23 on: Jun 22nd, 2004, 12:26pm »

Quote:
 
I'd use it in 68 but applets from 68 are almost unusable on OS X because of the 68 flicker problem.
 
ryan

 
just a quick note on the flicker problem on OS X which many people may already know. If your sketch flickers when it starts up simply click the yellow minimize button to send it into the dock then click it again to bring it back out of the dock. Flicker will have gone! It's a pain but it works!
« Last Edit: Jun 22nd, 2004, 12:27pm by bren »  
fry

WWW
Re: Adobe Illustrator Export Class
« Reply #24 on: Jun 22nd, 2004, 3:57pm »

+ if this is working in 68 but not in 69, could someone post a diagnosis with the problem in the bugs section?  
 
+ and just to be sure, the flicker problem is (mostly?) done in 69 on macosx, right?
 
+ re: the Tf and "offending command". illustrator does this when you don't have the font installed that's listed in the .ai file. so if you're not using the font's proper postscript name, or you don't have it installed on your machine, you'll just get an error, rather than "the font xxxx is missing." there's some bit of .ai header that sets up what fonts are in the document (which will give you the "font is missing" instead of "error" message) though i've never tracked down the proper set of header (it's not quite obvious, i.e. "DocumentFonts" doesn't do it).
 
flight404

WWW Email
Re: Adobe Illustrator Export Class
« Reply #25 on: Jun 22nd, 2004, 9:13pm »

Thanks for the explanation.  helped a great deal.
 
BTW, until this gets working properly in v69, does anyone know if it is possible to up the memory allotment in v68?  I didn't see anything in the properties file.  I am working on a sketch that keeps giving me an out of memory error and I really really really want to get it to print for me.
 
r
 
 
tobt


Re: Adobe Illustrator Export Class
« Reply #26 on: Jul 8th, 2004, 8:36pm »

Hi,
there are some problems ... maybe only for me but I want to know:
1. is it possible to change the illustrator format from 800x600 to a different size? (only a small problem)
 
2. Are there any equivalent methods to:
push()/pop(), rotate() and scale()??
 
3. there are "illegal operators" when I import the following file: (a really huge and urgend prob!!)
 
CODE:
 
  //WORKS ALL RIGHT...
  ai.setLayer(1);
  ai.beginGroup();
    ai.ai_noFill();
    ai.ai_stroke(255, 153, 0, 100);
    ai.ai_beginShape(LINES);
    ai.ai_vertex(200, 0);
    ai.ai_vertex(200, height);
    ai.ai_endShape();
  ai.endGroup();
 
 
  //ILLUSTRATOR IMPORT: ILLEGAL OPERATOR!??
  ai.setLayer(2);
  ai.beginGroup();
    ai.ai_noStroke();
    ai.ai_fill(255, 153, 0, 100);
    ai.ai_beginShape(POLYGON);
    ai.ai_bezierVertex(50, 100);//anker
    ai.ai_bezierVertex(250, 100);//
    ai.ai_bezierVertex(250, 100);//      
    ai.ai_bezierVertex(50, 150);//anker
    ai.ai_endShape();
  ai.endGroup();
 
 
why? where is the difference – the first part works all right?!
Thanks, tobt
« Last Edit: Jul 8th, 2004, 10:32pm by tobt »  
awmartin

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

[new build]
This latest build allows you to change stroke and fill colors and alphas inside beginShape...endShape, and you can specify different stroke and fill transparencies for all shapes except POLYGON.  I've added ai_quad(), which was an oversight.  And it fixes a few bugs, one of which was a missing tag when using bezierVertex.
 
[to do]
raster images.  processing 69 troubles.  text troubles and text in perspective.
 
[for tobt]
1) There are a few answers to your question about the 800x600 default size.  You can change it in Illustrator after you've opened it (under File->Document Setup->Artboard in Illustrator CS).  If you open AIExport.jar with WinZip, you can edit AIHeader1.txt, find "%AI5_ArtSize: 800 600" and change the last two numbers to whatever you want (Illustrator is picky--there's a chance this won't work).  This lets you change the default if you have a size you work with all the time.  Or I could probably put a function to do that in the next build if you think it would be useful.
 
2) The library uses screenX and screenY to determine the 2-dimensional coordinates on the Illustrator artboard.  So push/pop/scale/translate/rotate, etc, all work just as they are.  Equivalents are not required.
 
3) Sorry about this one.  Your code is fine, it's the latest build that was the problem.  Download the library again and it should work.
 
 
awmartin
 
tobt


Re: Adobe Illustrator Export Class
« Reply #28 on: Jul 10th, 2004, 3:02pm »

on Jul 10th, 2004, 6:16am, awmartin wrote:

2) The library uses screenX and screenY to determine the 2-dimensional coordinates on the Illustrator artboard.  So push/pop/scale/translate/rotate, etc, all work just as they are.  Equivalents are not required.
 

 
first: thank you, very good help!
 
then: Can't understand your second hint. Maybe it's better to talk about a simple example. e. g. there is a ellipse, which I want to rotate a few degrees.
 
CODE:
 
  ai.setLayer(2);
  ai.beginGroup();
  ai.ai_noStroke();
  ai.ai_fill(255, 153, 0, 50);
  ai.ai_ellipse(150, 50, 50, 250);
  ai.endGroup();
 
... can you show me how to rotate it
 
awmartin

WWW
Re: Adobe Illustrator Export Class
« Reply #29 on: Jul 10th, 2004, 5:47pm »

Sure. In general, the ultimate goal of the library is to retrofit any Processing application with the AI equivalents, only changing those functions that you wish to export to the AI file. The idea is to export what you see with much greater detail than the pixels on the screen.
 
This means that the only functions that require equivalents are the ones that draw stuff, and scale/pop/push/rotate/etc don't--they just affect the coordinate system, and therefore affect the results from the screenX and screenY Processing functions. This makes the job of writing a 2-dimensional Illustrator document much easier.  So, for your example, let's say you wanted to rotate the ellipse 25 degrees and pop back:
 
Code:
ai.setLayer(2);
ai.beginGroup();
push();
  ai.ai_noStroke();
  ai.ai_fill(255, 153, 0, 50);
  rotate( radians(25) );
  ai.ai_ellipse(150, 50, 50, 250);
pop();
ai.endGroup();

 
push/pop/rotate don't need to write anything to the AI file, so they can appear amidst changing strokes, fills, making groups, etc., just like most any other Processing app.
 
 
awmartin
 
Pages: 1 2 3 

« No topic | Next topic »