xfig
to
interactively create a large part of a picture interactively. At run
time, the script fills in the remainder.PostScript is a very powerful graphics language. It is possible to create sophisticated graphics. However, for most applications, a small handful of commands and concepts suffice.
For more information, consult
PostScript Language Tutorial and Cookbook, Adobe Systems, Addison-Wesley
You can change the line width and current color:newpath 20 20 moveto 20 40 lineto 40 40 lineto 40 20 lineto closepath stroke newpath 60 60 moveto 60 80 lineto 80 80 lineto 80 60 lineto closepath fill
2 setlinewidth .5 .5 0 setrgbcolor
Two other useful commands in this context are gsave
and
grestore
. They save and restore the graphics state,
including color, line width, current path, coordinate transformations
and so on.
gsave 72 72 scale %scale by a factor of 72 in x and y 1 1 translate %translate one inch .25 setlinewidth %quarter inch lines %draw a line 0 0 moveto 1 1 lineto stroke grestore %draw a line in the original coordinate system 200 200 moveto 300 300 lineto stroke
You must always go through the first three steps to retrieve a font. In PostScript, strings are denoted with parentheses./Helvetica findfont %load the font dictionary 14 scalefont %scale to 14pt setfont %make this the current font 30 30 moveto (Julius Caeser) show %display text
xfig
, you need to be familiar with PostScript variables.
Moreover, even in simple applications, it is convenient to use the
computational power of PostScript.PostScript maintains a sort of macro dictionary. The macros can expand to data or procedures or other data types. Literal names are denoted by the '/' character in PostScript.
To define a variable or a procedure, use this syntax:
/topmargin 720 def %define constants /leftmargin 72 def /inch { 72 mul } def %define a procedure newpath leftmargin topmargin moveto 3 inch 4 inch lineto stroke
Comments to:
webmaster@geom.umn.edu
Created: May 09 1996 ---
Last modified: Tue Jun 4 22:13:36 1996