
Most designers and programmers whose paths I've crossed have heard of PostScript but don't know much about it. I think it's a hidden gem. Not only is it a fascinating programming language which can be used to create generative drawings and save you hours of time through automation, but you can also use it as an intermediary format to transfer output from other languages such as Flash ActionScript or Java / Processing into Adobe Illustrator.
Copy and paste this into a text editor (NotePad or TextEdit), save it as 'simple.ps' and then open it in Illustrator.
%!PS-Adobe-3.0 0 0 moveto 100 100 lineto stroke showpage
This little snippet gives the following result:

A line from 0,0 to 100,100. Amazing, eh? Not really, but the point is that the code is really simple to understand and we're only using the line drawing command. If you go slow and learn one command at a time, you can eventually do some pretty interesting and useful things.
There are lots of PostScript tutorials on the web that will explain the basic concepts. One thing to note is that PostScript is stack based which means you push numbers onto the stack before operating on them. In raw code it makes it look like you're doing things backwards and can seem off-putting. In practise it's very simple and logical.
The essential guide to PostScript is the PLRM or 'red book'. I bought a copy of this years ago and it's pretty big at 800 pages! But thanks to the generosity of Adobe you can now download it online;
[PDF] PostScript Language Reference Manual, third edition
Once you've learned a few commands you'll be able to achieve a lot with very little. Here's something more advanced using a for-loop in conjunction with graphics transformation;
%!PS-Adobe-3.0
0.75 setlinewidth
0.75 setgray
0 3 360 {
newpath
gsave
0 0 moveto
rotate
100 0 rlineto
stroke
grestore
} for
showpage
Produces the following result:

Which is starting to look a bit more interesting, and like something that might be tricky to create purely 'by hand' in Illustrator. I've used techniques based on this to create images for quite a few projects over the years. The Design Week book cover was created using PostScript as were the Kingston University posters.
I've put the source for these into a small download. You'll need Illustrator or some other PostScript viewer to see them.
[ZIP] Download PostScript examples
Probably the best use of PostScript from a modern designer/programmer's perspective is as an intermediary format. With not much programming you can easily take output from Flash and get it into Illustrator.

For the Generation Press website I created a simple toy on the homepage which lets visitors generate their own pattern. It's a nice example of something created in Flash which would look great as a high-resolution printout.
Here's the toy wrapped into a demo application.
To use, click to start drawing. Once the drawing has finished, click 'Show PostScript' to see the code. This code doesn't update live because Flash isn't fast enough, so wait until the drawing has finished before viewing it. All the application does is output the same drawing commands as PostScript-style commands into the text window;
The ps() function outputs the code to the text window;

Now you can copy and paste this code into a text editor. Save it with a '.ps' extension and then load into Illustrator:

The image on the right is magnified to show that the drawing is made up of a series of small lines created by the lineto command in the PostScript code.
So that demonstrates the basic principle. PostScript is a very powerful language and you can do all kinds of other fun things with it, particularly when you start to redefine the built in lineto and curveto commands to do something else... but that's a story for another day.
Previous: Site Update / Next: Sizer
That rocks! I am going to give it a go.
lovely. is there a way to pre input the values so that the resulting flash animation runs without user imput?
Hi bruno - yes there is, that’s how the original works on the Generation Press website. You just need your own variation on the following (excuse the short var names!):
wonderful, thank you.
Hi Simon
I’ve tried to copy the postscript code into TextEdit, as you suggest, but it won’t let me save with a .ps suffix.
Any tips as to what I’m doing wrong?
Thanks
Adam
Adam - no idea what’s wrong there. Does it help if you enable ’show all file extensions’ in the Finder preferences? Can you try just saving the file and then rename it in the Finder?
Hi Simon,
Awesome! Thanks for making this available. I was able to copy the postscript text from Simon’s web page into an application called Editra that I downloaded from VersionTracker for Mac OS, (it’s free) then save that as .ps document. Those opened fine in Illustrator CS3 if the object was fairly simple. If the rendering on the web site was complex I kept getting an error message in Illustrator saying couldn’t open for an unknown reason when I tried to open the .ps file. Any suggestions for getting a more complex object to open?
Hi Rick
Hmm - haven’t really pushed the limits like you have! If you can mail me a file that won’t open in Illustrator, I’ll have a play around. There are other programs that will open .ps files by the way - Apple Preview on the Mac for one, but also GhostView/GSView might be worth a try; http://pages.cs.wisc.edu/~ghost/
If you want to put code in to Textedit on Mac OS X you need to make sure it is set to plain text note RTF.
You can set the default in preferences I think although I’m on a PC so can’t check right now.