-->

Previous | Table of Contents | Next

Page 213

.PS
copy thru % circle at ($1,$2) % until "END"
1 2
3 4
5 6
END
box
.PE
is equivalent to
.PS
circle at (1,2)
circle at (3,4)
circle at (5,6)
box
.PE
The commands to be performed for each line can also be taken from a macro defined earlier by giving the name of the macro as the argument to thru.
reset variable1, variable2 ... Reset predefined variables variable1, variable2 ... to their default values. If no arguments are given, reset all predefined variables to their default values. Note that assigning a value to scale also causes all predefined variables that control dimensions to be reset to their default values times the new value of scale.
plot expr ["text"] This is a text object which is constructed by using as a format string for text sprintf with an argument of expr. If text is omitted, a format string of %g is used. Attributes can be specified in the same way as for a normal text object. Be very careful that you specify an appropriate format string; pic does only very limited checking of the string. This is deprecated in favor of sprintf.
variable:=expr This is similar to = except variable must already be defined, and the value of variable will be changed only in the innermost block in which it is defined. (By contrast, = defines the variable in the current block if it is not already defined there, and then changes the value in the current block.)

Arguments of the form
XanythingX

are also allowed to be of the form:
anything

In this case, anything can contain balanced occurrences of and .BR. Strings may contain X or imbalanced occurrences of
and .BR.

EXPRESSIONS

The syntax for expressions has been significantly extended:


x^y (exponentiation)

sin(x)

cos(x)

atan2(y,x)

log(x) (base 10)

exp(x) (base 10, ie 10'-.4m'x'.4m')

sqrt(x)

int(x)

rand() (return a random number between 0 and 1)

rand(x) (return a random number between 1 and x; deprecated)

max(e1,e2)

min(e1,e2)

!e

Page 214


e1 && e2

e1 || e2

e1 == e2

e1 != e2

e1 >= e2

e1 > e2

e1 <= e2

e1 < e2

"str1"=="str2"

"str1"!="str2"

String comparison expressions must be parenthesized in some contexts to avoid ambiguity.

OTHER CHANGES

A bare expression, expr, is acceptable as an attribute; it is equivalent to direxpr, where dir is the current direction. For example


line 2i

means draw a line 2 inches long in the current direction.

The maximum width and height of the picture are taken from the variables maxpswid and maxpsht. Initially, these have values 8.5 and 11.

Scientific notation is allowed for numbers. For example


x = 5e_2

Text attributes can be compounded. For example


"foo" above ljust

is legal.

There is no limit to the depth to which blocks can be examined. For example


[A: [B: [C: box ]]] with .A.B.C.sw at 1,2

circle at last [].A.B.C

is acceptable.

Arcs now have compass points determined by the circle of which the arc is a part.

Circles and arcs can be dotted or dashed. In mode, splines can be dotted or dashed.

Boxes can have rounded corners. The rad attribute specifies the radius of the quarter-circles at each corner. If no rad or diam attribute is given, a radius of boxrad is used. Initially, boxrad has a value of 0. A box with rounded corners can be dotted or dashed.

The .PS line can have a second argument specifying a maximum height for the picture. If the width of zero is specified, the width will be ignored in computing the scaling factor for the picture. Note that GNU pic will always scale a picture by the same amount vertically as horizontally. This is different from the DWB 2.0 pic, which may scale a picture by a different amount vertically than horizontally if a height is specified.

Each text object has an invisible box associated with it. The compass points of a text object are determined by this box. The implicit motion associated with the object is also determined by this box. The dimensions of this box are taken from the width and height attributes; if the width attribute is not supplied, then the width will be taken to be textwid; if the height attribute is not supplied, then the height will be taken to be the number of text strings associated with the object times textht. Initially textwid and textht have a value of 0.

In places where a quoted text string can be used, an expression of the form:


sprintf(format,arg,...)

Previous | Table of Contents | Next