POSTSCRIPT EXERCISES




 1. What do the following Postscript programs do?

 (a)   %!
       200 200 moveto 
       100 100 rlineto 
       200 300 moveto 
       100 -100 rlineto
       stroke showpage

 (b)   %!
       100 -100 200 300 100 100 200 200
       moveto rlineto moveto rlineto
       stroke showpage

 (c)   %!
       200 200 moveto 300 300 lineto 200 300 moveto 300 200 lineto
       stroke showpage


 2. Write a Postscript program to draw a "T".


 3. What do the following Postscript program do?

    Note: the command "fill" is similar to "stroke" except that it fills in
    the entire region enclosed by the current path.

 (a)   %!
       256   0 moveto
       512 256 lineto
       256 512 lineto
       0   256 lineto
       256   0 lineto fill

 (b)   %!
       256   0 moveto
       512 256 lineto stroke
       256 512 lineto
       0   256 lineto
       256   0 lineto fill


 4. What does the following Postscript program do?

    Note: the command "d rotate" command changes the orientation of the turtle
    d degrees counterclockwise. The turtle's orientation remains rotated for all
    future commands, including moveto.

 (a)   %!
       128 128 moveto
       256 0 rlineto 72 rotate
       256 0 rlineto 72 rotate
       256 0 rlineto 72 rotate
       256 0 rlineto 72 rotate
       256 0 rlineto 72 rotate
       stroke

 (b)   %!
       128 128 moveto 256 0 rlineto 90 rotate 256 0 rlineto stroke
       256 -320 moveto 0 -128 rlineto stroke


*5. What does the following Postscript program do?

       %!
       306 396 translate
       -90 rotate

       6 {
          -100 0 translate
             0 0 moveto
          2 1 8 {
             100 8 div mul
             dup 0 exch
             -180 180 arc
         } for
         100 0 translate
         360 6 div rotate
      } repeat
      eofill
      showpage