CS 3721
Programming Languages  
Spring 2013
Recitation 12. 
 Postscript Programs
Week 14: Apr 22 - 26

Submit by hand at the beginning of class, printed on actual sheets of paper. Deadlines are:
  • 2013-04-26  10:05:00 (that's Fri, 26 Apr 2013, 10:05:00 am) for full credit.
  • 2013-04-29  10:05:00 (that's Mon, 29 Apr 2013, 10:05:00 am) for 75% credit.
Note that these will be physically handed in. Teams of two are still permitted.

I will be leaving the country on April 30. The final exam will be proctored by a TA
    on Wed, 8 May 2013, 8-10 am. Seating as with the Second Exam.
I will come back on May 9 to grade the final. (Well, that's the plan.)


A. 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 two fields shown must be exactly 0.5 inch (36 points) from the top of an 8.5-by-11 inch sheet of paper,
  • margins must be exactly 0.5 inch (36 points).
  • The font on the left should be given by Times-Bold findfont 14 scalefont setfont
  • The font on the right should be the same, except 12 point
  • all linewidths should be given by 2 setlinewidth.
  • The length of the lines at the left should be the same as (The University of Texas at San Antonio) stringwidth pop, that is, by the length of this string.
  • lines on the left should be 15 points apart vertically.
  • lines on the right should be 12 points apart vertically.
  • The box on the right should be 132 points wide.
  • Each line of the box on the right should be exactly centered in the middle of the box.

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.


B. 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:

  • n: the number of circles
  • r: the radius of each circle
  • s: the radius of the circle giving the centers of the circles.

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.


C. Business Card: For this recitation, you are to write a program in Postscript that will print a "business card", either for you, or for some fictitious individual or company. Graphic art often uses a principle of "less is more", meaning that a simple design is often more satisfactory than a more complex one. Here are some examples of simple design:

However, this is not an art assignment, and you are not being graded on "good graphic design." Instead I want you to experiment with complicated Postscript code to help learn the language. Here are requirements for the recitation:

  1. The initial card must be exactly 4 inches by 7 inches. (That is, the card must be exactly 288 points by 504 points.)
  2. The outer 4 inch by 7 inch boundary must be stroked with a line of width 3 points.
  3. With one run, translating the card if necessary, print a single copy of your card on a sheet of paper. Again, this must be 4 inches by 7 inches without scaling.
  4. In a separate run, using a scale factor of 0.5 in each direction, produce at least 5 copies of the same card at half size, that is, of size 2 inches by 3.5 inches. The Postscript code that produces these 5 copies must employ a Postscript loop. (See pages 51-52 and Chapter 7 of the Blue Book (PDF, 847k).)
  5. At least one piece of text on the card must either be centered or right justified, using the stringwidth function, so that the text would remain centered or right-justified even if the font size is changed. (See the Blue Book, pages 42-43 for right justification, and pages 58-59 for centering. See also my handout with a card on it.)

Here are some additional features that I would like to see you incorporate into your card:

  1. The use of some ``graphic object'', e.g., some picture made up of one or more paths. For example, a recursive structure like that on pages 73-75 of the Blue Book would be interesting.
  2. Use some color, although your final printout doesn't have to be on a color printer.
  3. The use of an outline around characters in a string. (See the example on page 98 of the Blue Book.)
  4. The use of a clipping path. (See the Blue Book, pages 103-104.)

Finally, try to make it look interesting. Be creative. The card doesn't have to have your real name. Don't copy the book or one another or my cards below. (Some students might submit, say, exactly the "Diamond Cafe" card below with different words stuck it. This would be worth little or no credit.)


Examples of Cards: Two cards from the Blue Book plus one of my own:


What you should submit: You must hand in copy with the Postscript source for the three programs and with images printed from the PDF versions of your source.

The number of points credit you receive will depend on how interesting and complex your Postscript code is. Code that just copies code that you have been supplied will not get much credit compared with original code.

It is permissible to use code from other sources as part of your card, but you must cite this source in the code that you submit.


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