Postscript Operators 'a'


abs num1 abs num2
returns the absolute value of num1.
The type of the result is the same as the type of num1 unless num1 is the most negative integer, in which case the result is a real.

EXAMPLE:
4.5 abs 4.5
-3 abs 3
0 abs 0

ERRORS: stackunderflow, typecheck

SEE ALSO: neg



·
add num1 num2 add sum

returns the sum of num1 and num2.
If both operands are integers and the result is within integer range, the result is an integer; otherwise, the result is a real.

EXAMPLE:

3 4 add 7

9.9 1.1 add 11.0

ERRORS: stackunderflow, typecheck, undefinedresult

SEE ALSO: div, mul, sub, idiv, mod




aload array aload array0 ... arrayn-1 array

packedarray aload packedarray0 ... packedarrayn-1 packedarray

successively pushes all n elements of array or packedarray on the operand stack (where n is the length of the operand), and finally pushes the operand itself.

EXAMPLE:
[23 (ab) -6] aload 23 (ab) -6 [23 (ab) -6]

ERRORS: invalidaccess, stackoverflow, stackunderflow, typecheck

SEE ALSO: astore, get, getinterval




anchorsearch string seek anchorsearch
post match true (if found)
string false (if not found)

determines if the string seek matches the initial substring of string
(that is, string is at least as long as seek and the corresponding characters are equal).
If it matches, anchorsearch splits string into two segments: match, the portion of string that matches seek, and post, the remainder of string; it then pushes the string objects post and match and the boolean true. If not, anchorsearch pushes the original string and the boolean false. anchorsearch is a special case of the search operator.

EXAMPLE:
(abbc) (ab) anchorsearch (bc) (ab) true
(abbc) (bb) anchorsearch (abbc) false
(abbc) (bc) anchorsearch (abbc) false
(abbc) (B) anchorsearch (abbc) false

ERRORS: invalidaccess, stackoverflow, stackunderflow, typecheck

SEE ALSO: search, token




and bool1 bool2 and bool3
int1 int1 and int1

If the operands are booleans, and returns their logical conjunction. If the operands are integers, and returns the bitwise and of their binary representations.

EXAMPLE:
true true and true % a complete truth table
true false and false
false true and false
false false and false

99 1 and 1
52 7 and 4

ERRORS: stackunderflow, typecheck

SEE ALSO: or, xor, not, true, false




arc x y r ang1 ang2 arc -

appends a counterclockwise arc of a circle to the current path, possibly preceded by a straight line segment. The arc has (x, y) as center, r as radius, ang1 the angle of a vector from (x, y) of length r to the first endpoint of the arc, and ang2 the angle of a vector from (x, y) of length r to the second endpoint of the arc.

If there is a current point, the arc operator includes a straight line segment from the current point to the first endpoint of this arc and then adds the arc into the current path. If the current path is empty, the arc operator does not produce the initial straight line segment. In any event, the second endpoint of the arc becomes the new current point.

Angles are measured in degrees counterclockwise from the positive x-axis of the current user coordinate system. The curve produced is circular in user space. If user space is scaled non-uniformly (i.e., differently in x and y) arc will produce elliptical curves in device space.

The operators that produce arcs ( arc, arcn, arct, and arcto represent them internally as one or more Bezier cubic curves. This is done with sufficient accuracy that a faithful rendition of an arc is produced. However, a program that reads the constructed path using pathforall will encounter curveto segments where arcs were specified originally.

EXAMPLE:
newpath 0 0 moveto 0 0 1 0 45 arc closepath

This constructs a 1-unit radius, 45-degree "pie slice."

ERRORS: limitcheck, stackunderflow, typecheck

SEE ALSO: arcn, arct, arcto, curveto




arcn x y r ang1 ang2 arcn -

(arc negative) behaves like arc, but arcn builds its arc segment in a clockwise direction in user space.

EXAMPLE:
newpath 0 0 2 0 90 arc 0 0 1 90 0 arcn closepath

This constructs a 2-unit radius, 1-unit wide, 90-degree "windshield wiper swath."

ERRORS: limitcheck, stackunderflow, typecheck

SEE ALSO: arc, arct, arcto, curveto




arct x1 y1 x2 y2 r arct - 2

appends an arc of a circle to the current path, possibly preceded by a straight line segment. The arc is defined by a radius r and two tangent lines.The tangent lines are those drawn from the current point, here called (x0, y0), to (x1, y1), and from (x1, y1) to (x2, y2). If the current point is undefined, arct executes the error nocurrentpoint.

The center of the arc is located within the inner angle between the tangent lines. It is the only point located at distance r in a direction perpendicular to both lines. The arc begins at the first tangent point (xt1, yt1) on the first tangent line, passes between its center and the point (x1, y1), and ends at the second tangent point (xt2, yt2) on the second tangent line.

Before constructing the arc, arct adds a straight line segment from the current point (x0, y0) to (xt1, yt1), unless those points are the same. In any event, (xt2, yt2) becomes the new current point.

The curve produced is circular in user space. If user space is scaled non-uniformly (i.e., differently in x and y) arct will produce elliptical curves in device space.

If the two tangent lines are collinear, arct merely appends a straight line segment from (x0, y0) to (x1, y1), considering the arc to be part of a degenerate circle with radius 0 at that point.

EXAMPLE:
newpath 0 0 moveto
0 4 4 4 1 arct
4 4 lineto

This constructs a 4-unit wide, 4-unit high right angle with a 1-unit radius "rounded corner."

ERRORS: limitcheck, nocurrentpoint, stackunderflow, typecheck, undefinedresult

SEE ALSO: arc, arcn, arcto, curveto




arcto x1 y1 x2 y2 r arcto xt1 yt1 xt2 yt2

produces the same effect as arct. It also returns the two tangent point coordinates (xt1, yt1) and (xt2, yt2) in user space.
arcto is not allowed as an element of a user path, whereas arct is allowed.

ERRORS: limitcheck, nocurrentpoint, stackunderflow, typecheck, undefinedresult

SEE ALSO: arc, arcn, arcto, curveto


Troubleshooting index



array int array array

creates an array of length int, each of whose elements is initialized with a null object, and pushes this array on the operand stack. The int operand must be a non-negative integer not greater than the maximum allowable array length . The array is allocated in local or global VM according to the current VM allocation mode.

EXAMPLE:
3 array [null null null]

ERRORS: limitcheck, rangecheck, stackunderflow, typecheck, VMerror

SEE ALSO: [, ], aload, astore, packedarray




ashow ax ay string ashow -

paints the characters of string in a manner similar to show. But while doing so, ashow adjusts the width of each character shown by adding ax to the character's x width and ay to its y width, thus modifying the spacing between characters. The numbers ax and ay are x and y displacements in the user coordinate system, not in the character coordinate system.

This operator enables a string of text to be fitted to a specific width by adjusting all the spaces between characters by a uniform amount.

EXAMPLE:
/Helvetica findfont 12 scalefont setfont
14 61 moveto (Normal spacing) show
14 47 moveto 4 0 (Wide spacing) ashow

ERRORS: invalidaccess, invalidfont, nocurrentpoint, stackunderflow, typecheck

SEE ALSO: show, awidthshow, cshow, kshow, widthshow, xshow, xyshow, yshow




astore any0 ... anyn-1 array astore array

stores the objects any0 through anyn-1 from the operand stack into array, where n is the length of array. The astore operator first removes the array operand from the stack and determines its length. It then removes that number of objects from the stack, storing the topmost one into element n - 1 of array and the bottommost one into element 0 of array. Finally, it pushes array back on the stack. Note that astore cannot be performed on packed arrays.

If the value of array is in global VM and any of any0 ... anyn-1 are composite objects whose values are in local VM, an invalidaccess error occurs.

EXAMPLE:
(a) (bcd) (ef) 3 array astore [(a) (bcd) (ef)]

This creates a three element array, stores the strings (a), (bcd), and (ef) into it as elements 0, 1, and 2, and leaves the array object on the operand stack.

ERRORS: invalidaccess, stackunderflow, typecheck,

SEE ALSO: aload, put, putinterval




atan num den atan angle

returns the angle (in degrees between 0 and 360) whose tangent is num/den. Either num or den may be zero, but not both. The signs of num and den determine the quadrant in which the result will lie: a positive num yields a result in the positive y plane, a positive den yields a result in the positive x plane. The result is a real.

EXAMPLE:
0 1 atan 0.0
1 0 atan 90.0
-100 0 atan 270.0
4 4 atan 45.0

ERRORS: stackunderflow, typecheck, undefinedresult

SEE ALSO: cos, sin




awidthshow cx cy char ax ay string awidthshow -

paints the characters of string in a manner similar to show, but combines the special effects of ashow and widthshow. awidthshow adjusts the width of each character shown by adding ax to its x width and ay to its y width, thus modifying the spacing between characters. Furthermore, awidthshow modifies the width of each occurrence of the character char by an additional amount (cx, cy). The interpretation of char is as described for the widthshow operator.

This operator enables fitting a string of text to a specific width by adjusting all of the spaces between characters by a uniform amount, while independently controlling the width of some specific character, such as the space character.

EXAMPLE:
/Helvetica findfont 12 scalefont setfont
30 60 moveto (Normal spacing) show
30 46 moveto 6 0 8#040 .5 0 (Wide spacing) awidthshow

ERRORS: invalidaccess, invalidfont, nocurrentpoint, rangecheck, stackunderflow, typecheck

SEE ALSO: ashow, cshow, kshow, show, widthshow, xshow, xyshow, yshow


Back to Postscript index



Back to Postscript index

Original file name: psopera