|
For some brief comments about Ghostscript
object types, stacks, special characters, arrays,
and operators grouped by theme, try
Reference for Ghostscript entities.
Most of the basic Ghostscript operators are mentioned below. The following index will help you get around:
The "USAGE" field for each operator listed indicates the objects at the top of the operand stack (last object listed is the topmost) which are used by the operator. The "RESULT" field indicates only the resulting objects at the top of the operand stack (last listed is the topmost), produced by the operator itself. An operator may have an effect on the graphics state or one of the other stacks as well, but these are not shown in the "RESULT" field. Also, any procedures which are executed as a result of this operator might produce other changes in the operand stack... The following variable names indicate objects of the following types:
i, j, n = integer
x, y, z = any number; real or integer
a, b, c = any type of object, sometimes numbered from 1 to n
e = element of an array of length n, numbered from e0 to en-1
STR, str = longer and shorter string
ARY, ary = longer and shorter array
proc = procedure, in curly brackets (e.g., {lineto stroke})
|
"[" (synonymous with "mark") marks the beginning of a sequence, and "]" completes the sequence, creating an array and leaving it on the operand stack
pops object from operand stack and sends its value (converted to text) to stdout
pops object from operand stack and sends it (converted to text) to stdout(go to top, B)
pushes all elements of the array onto stack, followed by array itself
if str matches initial substring of STR; (remainder) (match) true otherwise; STR false
logical conjunction
appends counterclockwise circular arc to current path, possibly preceeded by straight segment: center (x,y), radius r, from theta = a1 to a2 (degrees)
just like arc, but in clockwise direction
appends circular arc to current path, possibly preceeded by a straight segment; radius r, with tangent lines from current point to (x1,y1) to (x2,y2). The returned values are the coordinates of the two tangent points
creates an n-length array of null objects
prints string, adding spaces (x,y) between characters
determines the length of ary (say n), and then stores the top n stack objects into that array and leaves it on stack
prints string, combining special effects of ashow and widthshow(go to top, A, C)
pushes given dictionary onto the dictionary stack (making it the current dictionary)
number of bytes available for reading. EOF=-1(go to top, B, D)
adds character path outlines of given string, without stroking them, to the current path
pops all operands from stack
pops all operands from stack until it reaches a "mark" (or `['), and pops the mark also
produces new (smaller) clipping path, by intersecting current clipping path with interior of current path
sets current path to current clipping path
closes the file
closes current path, appending a straight segment which connects the current point to starting point
updates CTM (current transformation matrix) with matrix X CTM
replaces value of matr3 with matr1 X matr2
pops n, then duplicates top n operands
replaces first n elements of ARY with those of ary: length of ary = n <= length of ARY
replaces first n characters of STR with str, where length of str = n <= length of STR
copies all n elements of dict1 into length-zero dict2 (of maxlength >= n)
counts operands, pushes number onto stack
counts number of dictionaries currently on the dictionary stack; pushes number on stack
counts number of object on the execution stack; pushes number on stack
counts operands since most recent mark, and pushes this number onto the stack
current dash array and offset
copies current dictionary onto operand stack
returns current file object -- usually "stdin"
current flatness parameter
returns current font dictionary
current brightness value (0-1)
current color, HSB components
current line cap pameter
current line join parameter
current line width value
replaces value of matrix with CTM
current miter limit value
coordinates of current graphics point
current color, RGB components
current halftone screen parameters
current graphics transfer function
appends Bezier cubic section, from current point (x0,y0) to point (x3,y3), onto the current path; (x3,y3) becomes the new current point. This curve follows equation
x = (1-t)^3 x0 + 3t(1-t)^2 x1 + 3t^2(1-t) x2 + t^3 x3
y = (1-t)^3 y0 + 3t(1-t)^2 y1 + 3t^2(1-t) y2 + t^3 y3
for parameter t, 0<=t<=1
converts to integer (truncates)
interprets string, converts to an integer
converts to "literal" (not executable)
Converts to a name object, e.g. (abc) cvn ---> /abc Is executable if string was: (abc) cvx cvn ---> abc
converts to real value
interprets string and converts it to a real number
Represents an integer (the integer part of non-negative value x) with radix j (1<j<36) and converts the representation to a string, returning the string and using it to overwrite initial substring of STR.
converts to string: produces text representation of a and returns that string, overwriting initial substring of STR
converts to executable: makes top stack object executable, not literal(go to top, C, E)
(re)defines key with value
replaces value of matrix with the default transformaton matrix of current device, and pushes it onto stack
registers font as a font dictionary of given name (key)
creates new empty dictionary with maximum capacity n
copies all n elements of the dictionary stack into ARY, and returns the length-n subarray
transforms distance vector (x,y) using CTM
transforms distance vector (x,y) using matrix
duplicates top element of stack(go to top, D, F)
pops the current dictionary off the dictionary stack
produces new (smaller) clipping path, by intersecting current clipping path with interior of current path, using the even-odd rule to determine the latter
overpaints the interior of the current path, using the even-odd rule to determine "interior"
true if equal, otherwise false
dictionary of error handlers
exchanges top 2 elements of stack
pushes operand onto execution stack, executing it immediately
creates array of all n elements of the execution stack, overwriting initial substring of ARY
reduces access attribute of object (string or array) to "execute only" and not readable
terminates execution of innermost enclosing loop (for, loop, repeat, forall)
creates file object, for use by read or write or the previous 2 commands. str2 must be (r) or (w) for "read" or "write", and str1 is the file identifier, e.g. (%stdin)
overpaints the interior of the current path
obtains font dictionary of given name
replaces current path with the path where all "curveto" portions are replaced with equivalent "lineto" segments
delivers any buffered characters
delivers any buffered characters to writefile, or discards remaining characters from readfile
global dictionary of fonts
executes proc repeatedly, each time providing a numerical operand, starting with x1 and stepping toward x2 in increments of dx
executes proc for each element of ary in turn
executes proc on each character (integer 0-255) of str in turn
executes proc on each key-value pair of dict, in some order(go to top, F, I)
numerical or lexical "greater than or equals"
returns the (i+1)th element of ary
gets the (i+1)th character of str
returns the value associated with key
gets the substring of length n, starting with (i+1)th character
returns a subarray of j elements starting with ei (the (i+1)th element of str)
pops the top element from the graphics-state stack and makes that the current graphics state
pops all graphics states more recent than the one preserved by the most recent "save" command (not gsave!) or the bottommost graphics state. Makes it the current graphics state
pushes a copy of the current graphics state onto the graphics-state stack.
numerical or lexical "greater than"(go to top, G, K)
sets matr to [1 0 0 1 0 0]
transforms distance vector (x,y) using the inverse of CTM
transforms distance vector (x,y) using the inverse of matrix
executes proc if bool=true
executes proc1 if bool=true, otherwise executes proc2
paints a rectangular bitmap image, executing proc repeatedly to obtain the image data as characters. W,H are the width and height of the image samle array, bps (bits per sample), either 1,2,4 or 8, indicates how the samples are packed into the character data. matrix indicates how to scale and position the image relative to a unit square at the current point.
like "image", but uses image only as a 1-bps mask to control where to paint the current color. Instead of "bps", the 3rd parameter bool indicates whether to paint on the 1-bits ("true") or 0-bits ("false")
replaces j with a copy of stack element aj, the (j+1)th-topmost element of the remaining stack
replaces current clip path with default clip path (edges of page!)
resets values in graphics state to their default: initmatrix newpath initclip 1 setlinewidth 0 setlinecap 0 setlinejoin [] 0 setdash 0 setgray 10 setmiterlimit
sets the CTM to the default matrix
returns mtrx2, which now is the inverse of mtrx1
transforms coordinates (x,y) using the inverse of CTM
transforms coordinates (x,y) using the inverse of matrix(go to top, I, L)
whether key is an entry in dict
prints the characters of string one at a time, executing proc on consecutive pairs of characters at each step ("kernshow")(go to top, K, M)
numerical or lexical "less than or equals"
number of characters in string
returns the number of elements in array
the number of defined key-value pairs
appends a straight line segment from previous current point to new current point (x,y)
puts the value associated with key onto the stack, but does not execute it
execute procedure repeatedly until the operator "exit" is encountered.
numerical or lexical "less than"(go to top, L, N)
applies matrix to font
same as "[", marking the initial bound of an array
creates an identity matrix
returns maximum capacity of dictionary
starts a new subpath at point (x,y)
logical negation of eq
empties current path, undefines current point
logical negation
bitwise complement(go to top, N, P)
logical disjunction
bitwise inclusive-or(go to top, O, R)
returns the bounding box of the current path in current coordinate system; the x-y values of the lower-left and upper-right corners
executes a procedure on each of the elements of the current path, in order; proc1 on all the "moveto" elements, proc2 on all the "lineto" elements, proc3 on the "curveto" elements, and proc4 on the "closepath" elements
discards top element of stack
writes to standard output
writes prompt (interactive operation)
writes text version of each stack element to stdout, but doesn't change the stack
replaces (i+1)th character of str with ASCII character n
/Arr [1 2 3 4 5 6] def
Arr 1 (X) put
Arr ---> [1 (X) 3 4 5 6]
replaces (i+1)th element of ary with a
associates key with value a in dictionary
overwrites STR, starting at the (i+1)th character, with smaller string str
replaces elements of ARY with those of ary, starting with the (i+1)th element(go to top, P, S)
returns a pseudorandom integer n < 2^31. Don't rely on this random-number-generator being of high quality...
tests "readability" of object a, which is an array, string, file or dictionary
like curveto, but the 3 x-y pairs are relative to current point (x0,y0)
reads the next character from input file and pushes it (as an integer, 0-255) onto stack with "true" -- unless at end of file, in which case it returns only "false"
reads hex-pair characters (0-9A-Fa-f) from file to overwrite STR, ignoring any non-hex characters except End-of-file. Returns successfully-read string and either "false" (if EOF was encountered) or "true"
reads a line of characters from file (terminated by \n), uses them to overwrite the initials characters of STR, and returns the line (as a string) and "true". ("False" if EOF was encountered before EOL). String STR must be long enough to accommodate line
reduces access attribute of object (array, string, file or dictionary) to "read-only"
read characters from file into STR until STR is full or EOF. Returns read portion (as a string) and either "true" or "false", depending on whether EOF was encountered. ALL characters are read literally, including newline
executes procedure n times
restores all values and graphics state to what they were when the most recent "save" was called; more recent graphics states and values are discarded and the virtual memory released
replaces current path with same path in reverse order
like lineto, but the x-y coordinate pair is a measurement relative to the current point (x0,y0), not absolute coordinates
like moveto, but the x-y coordinate pair is a measurement relative to the current point (x0,y0), not absolute coordinates
pops n and i, then performs a circular shift on the top n operands by the amount i (positive or negative)
rotates coordinate axes (CTM) by z degrees
replaces value of given matrix with one in which the coordinate system is rotated by z degrees
returns the current seed for the random-number-generator, which can be used later with srand
executes contents of file represented by str(go to top, R, T)
takes a "snapshot" of all virtual memory (values of all element of composite objects) and also duplicates current graphics state onto the graphics stack
alters the coordinate axes (CTM) by stretching the x-axis by factor sx and that of the y-axis by factor sy
replaces value of given matrix with one in which the coordinate system is scale by z degrees
scales font by linear factor y
looks for a substring of STR which matches str, and returns strZ str strA true if successful: strA is the portion of STR which preceeds the match, and strZ is the portion which follows it. If there is no match, then instead this command returns STR false
sets the dash pattern: ary contains the cyclic on-off distances of the dashes, which begin after an offset of x units from the current point. The array must consist of zero or more positive numbers. The command [] 0 setdash turns off dashing, making lines solid.
sets the flatness parameter to positive number x. This parameter controls how accurately curves are rendered into straight line segments
establishes font to be used by "show"
sets the current color parameter to a gray shade, where black = 0 <= x <= 1 = white.
sets the current color parameter according to hue, saturation and brightness values, which must each lie between 0 and 1. For bright colors use y=z=1. Hue (x) values: 0=red, 0.33=green, 0.67=blue
sets the line cap parameter: i=0: line ends are squared off at the endpoint i=1: line ends are rounded off i=2: line ends are given a projecting square cap
set the line join parameter: i=0: corners are given a miter join (possibly beveled) i=1: corners are given a round join i=2: corners are given a bevel join
sets the line width parameter to x>=0; line width 0 produces the thinnest possible device-resolution line
replaces CTM with given matrix. Don't use this
sets the miter limit parameter to x>=1, which limits the length of sharp corner miters
sets the current color parameter according to red, green, blue values, which must each lie between 0 and 1. Red = 1 0 0. Yellow = 1 1 0. Orange = 1 0.65 0.
sets the current halftone screen definition
sets the function which converts "user gray" values (0-1) into "device gray" values (0-1)
prints string, starting at the current point and using the current font specifications
sends current page to be printed, and starts a new, blank page
makes n the seed value for the random-number-generator
writes text version of each stack element to stdout, but doesn't change the stack
whether named file is still valid (open)
redefines key-value pair in the topmost dictionary where key can be found, or defines a new key-value pair in the current dictionary if no such key exists in any dictionary on the stack
creates a string of n characters, all ASCII 0
calculates the change in the current point which would occur using "show", but doesn't actually draw the string
paints a line on the current path, using the current color, linewidth, dash pattern and other parameters
replaces the current path with the outline of the shape that would result from using "stroke"
dictionary of basic Ghostscript operators(go to top, S, U)
returns "true" is str contains anything besides white space (also returns pieces of original string). Otherwise, false.
transforms coordinates (x,y) using CTM
transforms coordinates (x,y) using matrix
translates coordinate axes (CTM) by (x,y)
replaces value of given matrix with one in which the coordinate system is translated by (x,y)
y is the same type as x, but with the fraction part dropped
returns type name of a(go to top, T, W)
dictionary of global operators(go to top, U, X)
tests "writeability" of object a, which is an array, string, file or dictionary
(returns false if key is not found.)
prints string, adding space (x,y) after each occurence of the given character
appends a single character to output file. char is an integer between 0 and 255
writes string to file as hex digits
writes string to file(go to top, W)
tests "executability" of object a
logical disjunction
bitwise exclusive-or