
What is Postscript? 

A programming language whose instructions, when read by a Postscript interpreter, produce graphical output. Typically, Postscript programs are written by other programs like Adobe Illustrator or dvips. These are never meant to be read by humans. This talk, however, is about Postscript programs written by humans. Postscript has two beautiful features: (1) everything (well, almost) is drawn to within the accuracy of the output device and (2) everything is easily scaled. 

Basic operations 

Computations are performed on a "stack"


Graphical operations 

Postscript's coordinate system


Drawing lines 

100 100 moveto 450 600 lineto stroke 

Drawing circles 

300 300 100 0 360 arc stroke 

Filling circles 

300 300 100 0 360 arc gsave 0.8 setgray fill grestore 10 setlinewidth stroke 

Drawing Bezier curves 

200 200 moveto 100 500 500 300 400 550 curveto stroke 

Displaying text 

100 100 moveto (g) show 

The coordinate transformation 



Translations 



Rotations 



Scaling 



Homogeneous coordinates 

Everything produced is passed through an affine coordinate transformation from user space into device space. This transformation has the form or in the language of linear transformations 


This is typically expressed in homogeneous coordinates In this formalism, 

General transformations 



General transformations 



What do you mean everything? 

Well, everything: lines, curves and text are all described in user space, then transformed into device space before rendered. To understand how this works, let's take a look under the hood. 

What can Postscript do? 

Apparently, not much: ultimately everything in Postscript is described in terms of lines and Bezier curveseven circular arcs:


and text 

There is, however, a great benefit to be gained. 

How does Postscript render graphical information? 

Postscript draws a line between two points



recursively by drawing the lines between the endpoints and midpoint



and again and again



until finally


Bezier curves 

The four points define the curve where 


These can be built recursively as well.



The curve splits into two other Bezier curves whose control points are
easily obtained.



Just keep dividing the smaller pieces



until


So what? 

This means that to transform a line or a curve, all we need to do is
transform the control points. That's easy.


But why would you want to write your own code? 

The Economics of Computing



Postscript is a full fledged programming language with loops and other good things.




From geometry 

The Elements, Book I, Proposition 1



The Nine Point Circle


From calculus 



Introducting Wooody, the loveable star of Toy Tale 



Wooody emotes 



Three dimensional drawing 



Orthogonal projection 



Perspective projection 






More homogeneous coordinates 

and then 


Let's see: we need so we'll take We can accomplish this by 

Shadows are obtained in the same way 



Resources 

Adobe, creators of Postscript Ghostscript, a free Postscript interpreter and viewer Guide to Postscript Programming Bill Casselman's Geometry and Postscript, a text book used to teach PostScript within a Geometry course. Bill Casselman's Mathematical Graphics resources page. Peter Kleiweg's
Postscript page
P.S. All figures have been drawn in Postscript.
