PDF references:
Basic Topics (from the Blue Book):
- Three types of graphics objects:
- Text: characters in many fonts, positioned and oriented in any way.
- Geometric figures: Drawn using powerful 2-dimensional graphics
operators, using lines, curves, filled regions, color.
- Images: anything that can be digitized.
(See Blue Book, pages 1-2.)
- The imaging model:
- Current page: can place anything anywhere, overwriting old stuff
- Current path: a set of connected lines and curves making a path,
often closed.
- Current clipping path: a closed path within which all drawing occurs.
(See Blue Book, pages 2-3.)
- Initial graphics: (See Blue Book, pages 3-4.)
- The Stack: used for all computations and operators. Postfix notation.
(See Blue Book, page 4, 7-15.)
- Coordinate systems:
x (horizontal) and y (vertical) coordinates,
with (0, 0) in the lower left corner.
Units are Postscipt points, where 1 point =
1/72 inch (in actual publishing, 1 point = 1/72.27 inch.)
(See Blue Book, Chapter 3, pages 17-25.)
- Variables and procedures: (It's getting harder now.)
(See Blue Book, Chapter 4, pages 27-33.)
- Text: (See Blue Book, Chapter 5, pages 35-46.)
- More graphics: (See Blue Book, Chapter 6, pages 47-60.)
- Conditionals and for loops: (See Blue Book, Section 7.1 and
first page of 7.2, pages 61-68.)
- Outline fonts: (See Blue Book, Section 9.4, pages 97-99.)
- Clipping: (See Blue Book, Section 10.1, pages 101-104.)
Example of
overlapping boxes:
This example is from the Blue Book, pages 23, 30, 31:
three different Postscript programs produce exactly the same
three overlapping boxes.
Here are all three listings presented side-by-side:
.html.
Practice with
translate, rotate, and scale:
Consider the following Postscript code that lays out coordinate
axes and numbers the four quadrants (1, 2, 3, 4). The function
that does this leaves the origin at (0, 0). In order to show
the figure, the code below translates the origin to (200, 200).
This code also puts a standard border around the page.
The following examples will only supply new code for the last
few lines (shown in red below).
%!PS-Adobe-2.0
/width 25 def
/outline { % print standard border on page
/Times-Bold findfont 15 scalefont setfont
newpath width width moveto
0 792 width 2 mul sub rlineto
612 width 2 mul sub 0 rlineto
0 -792 width 2 mul add rlineto
closepath stroke
275 width 5 add moveto (Bottom of Page) show
275 792 width sub 15 sub moveto (Top of Page) show
} def
/coord {
/Times-Bold findfont 50 scalefont setfont
20 20 moveto (1) show
-50 20 moveto (2) show
-50 -50 moveto (3) show
20 -50 moveto (4) show
3 setlinewidth
newpath 0 60 moveto 0 -60 lineto stroke
newpath 60 0 moveto -60 0 lineto stroke
} def
outline
%%%%%%% only change what comes after this comment %%%%%%
200 200 translate
coord
showpage
The result of this Postscript is:
.ps, or as .pdf
Now keeping the same functions outline and
coords, try some different
instructions at the end and see what happens. In each case try
to guess what the result will be first and then see what
the result is. (I am leaving off the definition of the function
and leaving off the final showpage.)
Postscript Program | Result |
200 200 translate
rotate 90
coord
|
.ps, or as .pdf |
rotate 90
200 200 translate
coord
|
.ps, or as .pdf |
90 rotate
200 -200 translate
-90 rotate
coord
|
.ps, or as .pdf |
200 200 translate
90 rotate
2 2 scale
coord
|
.ps, or as .pdf |
2 2 scale
200 200 translate
90 rotate
coord
|
.ps, or as .pdf |
1 1 30 {
pop % throw away loop variable
300 150 translate
45 rotate
coord
0.75 0.75 scale
} for % just loops 30 times
|
.ps, or as .pdf |
More complex example:
Here is a second example Postscript file, much more
complicated than the first, stored using the filename
abc3.ps:
%!PS-Adobe-2.0
/path { % path is the outline of the chars ABC
/Times-Bold findfont 200 scalefont setfont
newpath 0 0 moveto (ABC) false charpath
} def
/oneline { % draw one line from the origin
0 0 moveto 450 0 lineto stroke
} def
/lines { % draw 180 lines at 1 degree rotations
180 {1 rotate oneline} repeat
} def
100 300 translate % up to middle of page
3 setlinewidth % thick lines
path stroke % outline the characters
1 setlinewidth % thin lines
path clip % clip to inside of charactes
180 0 translate % to middle of string
lines % draw the lines inside the string
showpage % actually render the page
Open a link to this file as:
.ps, or as .pdf
Other complex examples:
- "Graphic Perspective" Letterhead Stationary 1:
text,
.pdf,
.ps
- "Graphic Perspective" Letterhead Stationary 2:
text,
.pdf,
.ps
- "Graphic Perspective" Letterhead Stationary 2:
text,
.pdf,
.ps
- "UTSA" done with a sheen:
text,
.pdf,
.ps
- Dodecahedron Desk Calendar:
Year 2000:
text,
.pdf,
.ps
Year 2001:
text,
.pdf,
.ps
Year 2002:
text,
.pdf,
.ps
Year 2003:
text,
.pdf,
.ps
- My own UTSA letterhead stationary:
text,
.pdf,
.ps
- Another of my UTSA letterhead stationaries:
text,
.pdf,
.ps
- "Official" UTSA letterhead stationary:
text,
.pdf,
.ps
- Two circles of UTSAs:
.pdf,
.ps
- Conference announcement (Borderline):
Outer Page:
text,
.pdf,
.ps
Inner Page:
text,
.pdf,
.ps
- Poster (presented for its Postscript, not content):
text,
.pdf,
.ps
Same on four pages for cutout and assembly:
text,
.pdf,
.ps
- One-time pad decoder game (in lecture to high school students):
Inner circle:
text,
.pdf,
.ps
Outer circle:
text,
.pdf,
.ps
Revision date: 2002-11-06.
(Please use ISO 8601,
the International Standard Date and Time Notation.)