Computer Languages History
(Click or use local copy.)
 CS 3723/3721
 Programming Languages
 Spring 2005

 Recitation 12
 Postscript Programs
    Week 12: Apr 11-15
 Due (on time): 2005-04-18  23:59:59
 Due (late):        2005-04-22  23:59:59

Recitation 12 must be submitted following directions at: submissions with deadlines
  • 2005-04-18  23:59:59 (that's Monday, 18 April 2005, 11:59:59 pm) for full credit.
  • 2005-04-22  23:59:59 (that's Friday, 22 April 2005, 11:59:59 pm) for 75% credit.


A. Postscript program: A Knot: You are to write a single Postscript program that will draw versions of a simple knot, including the 3 below.

Part A: Three versions of a Postscript Knot Program
x: 4, vertices labeledx: 8x: 12

You should make x a variable inside the program. You should draw the three line segments that make up the "knot" with linewidth 2*x, and allow a "gap" at either end of each line segment of width x. (The end of each line segment is then a distance of 2*x from the center of the other line segments.) The numbers in the left-hand picture give the coordinates of each corner of the paths used. Notice that these are just whole "inches". You can then get the three pictures above by taking x equal to the value above each picture. (Of course without the numbers in the left-hand picture.) What will the picture look like when x has value 24?


B. Postscript program: Return Address: You are to write a Postscript program that will create the return address and "postage paid" announcement exactly as shown below. (Click on the image to get a PDF file with this as a portion, exactly as shown and described here except that it is not at the top of the page.)

Part B: Return Address for a mailing

For full credit, include the following features:

The image above is an actual image, 8.5 inches wide, taken from a program that met the requirements above. If you have trouble meeting the above requirements, just fake it as well as you can, and try to make your output look as close to the above as possible.


C. Postscript program: Circles: You are to write a Postscript program that will draw an array of n circles, each of radius r and the centers of these circles should be arranged around a central point in a circle of radius s. These parameters should be variables in your program:

The pictures below give a little more information: In the last 4 pictures the first circle is drawn wider and in red. The circle of the centers of circles is drawn in "CornflowerBlue".

Part C: Circles
n:10, r:100, s:100n: 20, r:100, s:100n: 40, r:100, s:100
n:40, r:50, s:150n: 20, r:150, s:50n: 30, r:110, s:90

Implementation: There are several simple ways to program this in Postscript. You should center everything at the origin, translate to the center of the page, and draw everything.

You can let an angle th take on the necessary successive values. Then the center of each circle of radius r will be at the point (s*cos(th), s*sin(th), and you can draw each circle.

Alternatively, you can draw one circle and keep rotating by the successive angle: 360/n.


What you should submit: In the normal way you should submit the Postscript source for each of the required three programs:

Then during or before the next class meeting: Wednesday, 20 April 2005 submit actual computer printouts (in person or under my door) containing:

  1. Postscript source of the three programs.
  2. Pictures of runs for the following cases:


Revision date: 2005-04-12. (Please use ISO 8601, the International Standard Date and Time Notation.)