2 .de PS \" start picture
3 . \" $1 is height, $2 is width, both in inches
10 .de PE \" end of picture
15 pic, tpic, svgpic \- troff and tex preprocessors for drawing pictures
35 preprocessor for drawing figures on a typesetter.
37 code is contained between
44 \&.PS \f2optional-width\fP \f2optional-height\fP
49 or in a file mentioned in a
57 is present, the picture is made that many inches wide,
58 regardless of any dimensions used internally.
59 The height is scaled in the same proportion unless
66 the typesetting position after printing is restored to what it was
71 is a list of elements:
73 \f2primitive attribute-list\fP
74 \f2placename\fP : \f2element\fP
75 \f2placename\fP : \f2position\fP
76 \f2var\fP = \f2expr\fP
78 { \f2element-list\fP }
79 [ \f2element-list\fP ]
80 for \f2var\fP = \f2expr\fP to \f2expr\fP by \f2expr\fP do { \f2anything\fP }
81 if \f2expr\fP then { \f2anything\fP } else { \f2anything\fP }
82 copy \f2file,\fP copy thru \f2macro,\fP copy \f2file\fP thru \fPmacro\fP
83 sh { \f2commandline\fP }
85 reset \f2optional var-list\fP
89 Elements are separated by newlines or semicolons;
90 a long element may be continued by ending the line with a backslash.
91 Comments are introduced by a
93 and terminated by a newline.
94 Variable names begin with a lower case letter;
95 place names begin with upper case.
96 Place and variable names retain their values
97 from one picture to the next.
100 the current position moves in the current direction
103 (default)) by the size of the primitive.
104 The current position and direction are saved upon entry
107 block and restored upon exit.
108 Elements within a block enclosed in
110 are treated as a unit;
111 the dimensions are determined by the extreme points
112 of the contained objects.
113 Names, variables, and direction of motion within a block are local to that block.
116 is any line that begins with a period.
117 Such a line is assumed to make sense in the context where it appears;
118 generally, this means only size and font changes.
125 box circle ellipse arc line arrow spline move \f2text-list\fP
133 is a sequence of zero or more attributes;
134 each attribute consists of a keyword, perhaps followed by a value.
137 h(eigh)t \f2expr\fP wid(th) \f2expr\fP
138 rad(ius) \f2expr\fP diam(eter) \f2expr\fP
139 up \f2opt-expr\fP down \f2opt-expr\fP
140 right \f2opt-expr\fP left \f2opt-expr\fP
141 from \f2position\fP to \f2position\fP
142 at \f2position\fP with \f2corner\fP
143 by \f2expr, expr\fP then
144 dotted \f2opt-expr\fP dashed \f2opt-expr\fP
145 chop \f2opt-expr\fP -> <- <->
148 \f2text-list\fP \f2expr\fP
150 Missing attributes and values are filled in from defaults.
151 Not all attributes make sense for all primitives;
152 irrelevant ones are silently ignored.
155 causes the geometrical center to be put at the specified place;
157 causes the position on the object to be put at the specified place.
158 For lines, splines and arcs,
162 refer to arrowhead size.
165 implies motion in the current direction.
167 Text is normally an attribute of some primitive;
168 by default it is placed at the geometrical center of the object.
169 Stand-alone text is also permitted.
171 is a list of text items:
174 "..." \f2positioning ...\fP
175 sprintf("\f2format\fP", \f2expr\fP, \f2...\fP) \f2positioning ...\fP
177 center ljust rjust above below
179 If there are multiple text items for some primitive,
180 they are arranged vertically and centered except as qualified.
181 Positioning requests apply to each item independently.
182 Text items may contain
184 commands for size and font changes, local motions, etc.,
185 but make sure that these are balanced
186 so that the entering state is restored before exiting.
188 A position is ultimately an
190 coordinate pair, but it may be specified in other ways.
194 \f2place\fP ± \f2expr, expr\fP
195 \f2place\fP ± ( \f2expr, expr\fP )
196 ( \f2position\fP,\f2 position\fP ) \f2x\fP\fR from one, \f2y\fP\fR the other\fP
197 \f2expr\fP [\fLof the way\fP] between \f2position\fP and \f2position\fP
198 \f2expr\fP < \f2position\fP , \f2position\fP >
204 \f2placename\fP \f2optional-corner\fP
205 \f2corner\fP of \f2placename\fP
206 \f2nth\fP \f2primitive\fP \f2optional-corner\fP
207 \f2corner\fP of \f2nth\fP \f2primitive\fP
212 is one of the eight compass points
213 or the center or the start or end of a primitive.
215 \f2 optional-corner\fP:
216 .n .e .w .s .ne .se .nw .sw .c .start .end
218 top bot left right start end
220 Each object in a picture has an ordinal number;
225 \f2n\fPth\f2, n\fPth last
228 The built-in variables and their default values are:
231 boxwid 0.75 boxht 0.5
232 circlerad 0.25 arcrad 0.25
233 ellipsewid 0.75 ellipseht 0.5
234 linewid 0.5 lineht 0.5
235 movewid 0.5 moveht 0.5
237 arrowwid 0.05 arrowht 0.1
238 dashwid 0.1 arrowhead 2
241 These may be changed at any time,
242 and the new values remain in force from picture to picture until changed again
246 Variables changed within
250 revert to their previous value upon exit from the block.
251 Dimensions are divided by
257 are evaluated in floating point.
258 All numbers representing dimensions are taken to be in inches.
261 \f2expr\fP \f2op\fP \f2expr\fP
267 \f2place\fP .x \f2place\fP .y \f2place\fP .ht \f2place\fP .wid \f2place\fP .rad
268 sin(\f2expr\fP) cos(\f2expr\fP) atan2(\f2expr,expr\fP) log(\f2expr\fP) exp(\f2expr\fP)
269 sqrt(\f2expr\fP) max(\f2expr,expr\fP) min(\f2expr,expr\fP) int(\f2expr\fP) rand()
271 + - * / % < <= > >= == != && ||
278 statements are not part of the grammar.
280 define \f2name\fP { \f2replacement text\fP }
287 in the replacement text
288 will be replaced by the corresponding arguments if
292 \f2name\fP(\f2arg1\fP, \f2arg2\fP, ...)
294 Non-existent arguments are replaced by null strings.
296 may contain newlines.
299 statement removes the definition of a macro.
304 preprocessor that accepts
307 It produces Tex commands that define a box called
309 which contains the picture.
310 The box may be output this way:
313 \ecenterline{\ebox\egraph}
318 language and produces a Scalable Vector Graphics (SVG) image
319 suitable for use in HTML documents.
322 arrow "input" above; box "process"; arrow "output" above
325 circle rad .1 with .w at A.e
326 circle rad .05 at 0.5 <A.c, A.ne>
327 circle rad .065 at 0.5 <A.c, A.ne>
328 spline from last circle.nw left .25 then left .05 down .05
329 arc from A.c to A.se rad 0.5
330 for i = 1 to 10 do { line from A.s+.025*i,.01*i down i/50 }
334 arrow "input" above; box "process"; arrow "output" above
337 circle rad .1 with .w at A.e
338 circle rad .05 at 0.5 <A.c, A.ne>
339 circle rad .065 at 0.5 <A.c, A.ne>
340 spline from last circle.nw left .25 then left .05 down .05
341 arc from A.c to A.se rad 0.5
342 for i = 1 to 10 do { line from A.s+.025*i,.01*i down i/50 }
352 ``PIC\(ema Graphics Language for Typesetting'',
354 Unix Research System Programmer's Manual,
355 Tenth Edition, Volume 2
358 is only lightly tested.
359 It should handle troff commands in text output.