Lab 3: PostScript

6.005 Elements of Software Construction
Spring 2008
Due: Friday, March 14

In this lab, you will get a quick introduction to the PostScript language, which you will be using in your project.

Before Lab

Before coming to lab, please do the following:

The Lab

Running your first PostScript programs

Ghostscript is an interpreter, which gives you a prompt and lets you type Postscript code interactively and see its results. Ghostview is file viewer, which runs a Postscript file and displays the resulting picture.

Start Ghostscript (on Athena/Linux/Mac, run the command gs). You should see a prompt. Type the following Postscript code:

2 3 add pstack

You should see it display 5. (The pstack command prints the current contents of the stack, which is useful for debugging.)

Now create a file called square.ps with the following contents, and open it in Ghostview (gv on Athena and Linux, Preview on Mac):

newpath
1.5 setlinewidth
72 72 moveto
72 0 rlineto
0 72 rlineto
-72 0 rlineto
closepath
stroke
showpage

This program creates a 1-inch square located 1 inch above and 1 inch to the right of the page's bottom left corner. (PostScript uses typographic units: 1 inch is 72 "points").

Working through a PostScript tutorial

Work through this guide to PostScript, focusing on the following sections:

The first five sections are contiguous, so you can go from one to the other by starting at the first and just clicking "next page".

Do the following exercises:

Creating your own PostScript program

Write a PostScript program that draws a rough representation of MIT's dome (as shown, for example, here). Your program should at least draw some columns and a semicircle for the dome itself. We suggest that you sketch your design on paper first, marking your intended dimensions. To draw a circle, you will need to use the arc command, described in the tutorial here.
Checkoff. Find a TA or another member of the course staff and demonstrate your PostScript creations to be checked off on this lab.