2 dfc67f9b 2004-05-16 devnull .de PS \" start picture
3 dfc67f9b 2004-05-16 devnull . \" $1 is height, $2 is width, both in inches
4 dfc67f9b 2004-05-16 devnull .if \\$1>0 .sp .35
5 dfc67f9b 2004-05-16 devnull .ie \\$1>0 .nr $1 \\$1
6 dfc67f9b 2004-05-16 devnull .el .nr $1 0
7 dfc67f9b 2004-05-16 devnull .in (\\n(.lu-\\$2)/2u
10 dfc67f9b 2004-05-16 devnull .de PE \" end of picture
12 dfc67f9b 2004-05-16 devnull .if \\n($1>0 .sp .65
15 b546bd6e 2017-07-16 rsc pic, tpic, svgpic \- troff and tex preprocessors for drawing pictures
16 dfc67f9b 2004-05-16 devnull .SH SYNOPSIS
31 dfc67f9b 2004-05-16 devnull .SH DESCRIPTION
34 d32deab1 2020-08-16 rsc .MR troff (1)
35 dfc67f9b 2004-05-16 devnull preprocessor for drawing figures on a typesetter.
37 dfc67f9b 2004-05-16 devnull code is contained between
44 dfc67f9b 2004-05-16 devnull \&.PS \f2optional-width\fP \f2optional-height\fP
45 dfc67f9b 2004-05-16 devnull \f2element-list\fP
49 dfc67f9b 2004-05-16 devnull or in a file mentioned in a
53 dfc67f9b 2004-05-16 devnull .BI .PS " " < file
56 dfc67f9b 2004-05-16 devnull .IR optional-width
57 dfc67f9b 2004-05-16 devnull is present, the picture is made that many inches wide,
58 dfc67f9b 2004-05-16 devnull regardless of any dimensions used internally.
59 dfc67f9b 2004-05-16 devnull The height is scaled in the same proportion unless
60 dfc67f9b 2004-05-16 devnull .IR optional-height
61 dfc67f9b 2004-05-16 devnull is present.
64 dfc67f9b 2004-05-16 devnull is used instead of
65 dfc67f9b 2004-05-16 devnull .BR .PE ,
66 dfc67f9b 2004-05-16 devnull the typesetting position after printing is restored to what it was
67 dfc67f9b 2004-05-16 devnull upon entry.
70 dfc67f9b 2004-05-16 devnull .IR element-list
71 dfc67f9b 2004-05-16 devnull is a list of elements:
73 dfc67f9b 2004-05-16 devnull \f2primitive attribute-list\fP
74 dfc67f9b 2004-05-16 devnull \f2placename\fP : \f2element\fP
75 dfc67f9b 2004-05-16 devnull \f2placename\fP : \f2position\fP
76 dfc67f9b 2004-05-16 devnull \f2var\fP = \f2expr\fP
77 dfc67f9b 2004-05-16 devnull \f2direction\fP
78 dfc67f9b 2004-05-16 devnull { \f2element-list\fP }
79 dfc67f9b 2004-05-16 devnull [ \f2element-list\fP ]
80 dfc67f9b 2004-05-16 devnull for \f2var\fP = \f2expr\fP to \f2expr\fP by \f2expr\fP do { \f2anything\fP }
81 dfc67f9b 2004-05-16 devnull if \f2expr\fP then { \f2anything\fP } else { \f2anything\fP }
82 dfc67f9b 2004-05-16 devnull copy \f2file,\fP copy thru \f2macro,\fP copy \f2file\fP thru \fPmacro\fP
83 dfc67f9b 2004-05-16 devnull sh { \f2commandline\fP }
84 dfc67f9b 2004-05-16 devnull print \f2expr\fP
85 dfc67f9b 2004-05-16 devnull reset \f2optional var-list\fP
86 dfc67f9b 2004-05-16 devnull \f2troff-command\fP
89 dfc67f9b 2004-05-16 devnull Elements are separated by newlines or semicolons;
90 dfc67f9b 2004-05-16 devnull a long element may be continued by ending the line with a backslash.
91 dfc67f9b 2004-05-16 devnull Comments are introduced by a
93 dfc67f9b 2004-05-16 devnull and terminated by a newline.
94 dfc67f9b 2004-05-16 devnull Variable names begin with a lower case letter;
95 dfc67f9b 2004-05-16 devnull place names begin with upper case.
96 dfc67f9b 2004-05-16 devnull Place and variable names retain their values
97 dfc67f9b 2004-05-16 devnull from one picture to the next.
99 dfc67f9b 2004-05-16 devnull After each primitive
100 dfc67f9b 2004-05-16 devnull the current position moves in the current direction
101 dfc67f9b 2004-05-16 devnull .RB ( up , down ,
102 dfc67f9b 2004-05-16 devnull .BR left , right
103 dfc67f9b 2004-05-16 devnull (default)) by the size of the primitive.
104 dfc67f9b 2004-05-16 devnull The current position and direction are saved upon entry
106 dfc67f9b 2004-05-16 devnull .BR { ... }
107 dfc67f9b 2004-05-16 devnull block and restored upon exit.
108 dfc67f9b 2004-05-16 devnull Elements within a block enclosed in
109 dfc67f9b 2004-05-16 devnull .BR [ ... ]
110 dfc67f9b 2004-05-16 devnull are treated as a unit;
111 dfc67f9b 2004-05-16 devnull the dimensions are determined by the extreme points
112 dfc67f9b 2004-05-16 devnull of the contained objects.
113 dfc67f9b 2004-05-16 devnull Names, variables, and direction of motion within a block are local to that block.
115 dfc67f9b 2004-05-16 devnull .IR Troff-command
116 dfc67f9b 2004-05-16 devnull is any line that begins with a period.
117 dfc67f9b 2004-05-16 devnull Such a line is assumed to make sense in the context where it appears;
118 dfc67f9b 2004-05-16 devnull generally, this means only size and font changes.
121 dfc67f9b 2004-05-16 devnull .I primitive
122 dfc67f9b 2004-05-16 devnull objects are:
125 dfc67f9b 2004-05-16 devnull box circle ellipse arc line arrow spline move \f2text-list\fP
127 dfc67f9b 2004-05-16 devnull .L arrow
128 dfc67f9b 2004-05-16 devnull is a synonym for
129 dfc67f9b 2004-05-16 devnull .LR "line ->" .
132 dfc67f9b 2004-05-16 devnull .IR attribute-list
133 dfc67f9b 2004-05-16 devnull is a sequence of zero or more attributes;
134 dfc67f9b 2004-05-16 devnull each attribute consists of a keyword, perhaps followed by a value.
136 dfc67f9b 2004-05-16 devnull .ta .5i 2.5i
137 dfc67f9b 2004-05-16 devnull h(eigh)t \f2expr\fP wid(th) \f2expr\fP
138 dfc67f9b 2004-05-16 devnull rad(ius) \f2expr\fP diam(eter) \f2expr\fP
139 dfc67f9b 2004-05-16 devnull up \f2opt-expr\fP down \f2opt-expr\fP
140 dfc67f9b 2004-05-16 devnull right \f2opt-expr\fP left \f2opt-expr\fP
141 dfc67f9b 2004-05-16 devnull from \f2position\fP to \f2position\fP
142 dfc67f9b 2004-05-16 devnull at \f2position\fP with \f2corner\fP
143 dfc67f9b 2004-05-16 devnull by \f2expr, expr\fP then
144 dfc67f9b 2004-05-16 devnull dotted \f2opt-expr\fP dashed \f2opt-expr\fP
145 dfc67f9b 2004-05-16 devnull chop \f2opt-expr\fP -> <- <->
146 dfc67f9b 2004-05-16 devnull invis same
147 dfc67f9b 2004-05-16 devnull fill \f2opt-expr\fP
148 dfc67f9b 2004-05-16 devnull \f2text-list\fP \f2expr\fP
150 dfc67f9b 2004-05-16 devnull Missing attributes and values are filled in from defaults.
151 dfc67f9b 2004-05-16 devnull Not all attributes make sense for all primitives;
152 dfc67f9b 2004-05-16 devnull irrelevant ones are silently ignored.
153 dfc67f9b 2004-05-16 devnull The attribute
155 dfc67f9b 2004-05-16 devnull causes the geometrical center to be put at the specified place;
157 dfc67f9b 2004-05-16 devnull causes the position on the object to be put at the specified place.
158 dfc67f9b 2004-05-16 devnull For lines, splines and arcs,
159 dfc67f9b 2004-05-16 devnull .L height
161 dfc67f9b 2004-05-16 devnull .L width
162 dfc67f9b 2004-05-16 devnull refer to arrowhead size.
165 dfc67f9b 2004-05-16 devnull implies motion in the current direction.
167 dfc67f9b 2004-05-16 devnull Text is normally an attribute of some primitive;
168 dfc67f9b 2004-05-16 devnull by default it is placed at the geometrical center of the object.
169 dfc67f9b 2004-05-16 devnull Stand-alone text is also permitted.
170 dfc67f9b 2004-05-16 devnull A text list
171 dfc67f9b 2004-05-16 devnull is a list of text items:
173 dfc67f9b 2004-05-16 devnull \f2 text-item\fP:
174 dfc67f9b 2004-05-16 devnull "..." \f2positioning ...\fP
175 dfc67f9b 2004-05-16 devnull sprintf("\f2format\fP", \f2expr\fP, \f2...\fP) \f2positioning ...\fP
176 dfc67f9b 2004-05-16 devnull \f2 positioning\fP:
177 dfc67f9b 2004-05-16 devnull center ljust rjust above below
179 dfc67f9b 2004-05-16 devnull If there are multiple text items for some primitive,
180 dfc67f9b 2004-05-16 devnull they are arranged vertically and centered except as qualified.
181 dfc67f9b 2004-05-16 devnull Positioning requests apply to each item independently.
182 dfc67f9b 2004-05-16 devnull Text items may contain
183 dfc67f9b 2004-05-16 devnull .I troff
184 dfc67f9b 2004-05-16 devnull commands for size and font changes, local motions, etc.,
185 dfc67f9b 2004-05-16 devnull but make sure that these are balanced
186 dfc67f9b 2004-05-16 devnull so that the entering state is restored before exiting.
188 dfc67f9b 2004-05-16 devnull A position is ultimately an
190 dfc67f9b 2004-05-16 devnull coordinate pair, but it may be specified in other ways.
192 dfc67f9b 2004-05-16 devnull \f2 position\fP:
193 dfc67f9b 2004-05-16 devnull \f2expr, expr\fP
194 dfc67f9b 2004-05-16 devnull \f2place\fP ± \f2expr, expr\fP
195 dfc67f9b 2004-05-16 devnull \f2place\fP ± ( \f2expr, expr\fP )
196 dfc67f9b 2004-05-16 devnull ( \f2position\fP,\f2 position\fP ) \f2x\fP\fR from one, \f2y\fP\fR the other\fP
197 dfc67f9b 2004-05-16 devnull \f2expr\fP [\fLof the way\fP] between \f2position\fP and \f2position\fP
198 dfc67f9b 2004-05-16 devnull \f2expr\fP < \f2position\fP , \f2position\fP >
199 dfc67f9b 2004-05-16 devnull ( \f2position\fP )
203 dfc67f9b 2004-05-16 devnull \f2 place\fP:
204 dfc67f9b 2004-05-16 devnull \f2placename\fP \f2optional-corner\fP
205 dfc67f9b 2004-05-16 devnull \f2corner\fP of \f2placename\fP
206 dfc67f9b 2004-05-16 devnull \f2nth\fP \f2primitive\fP \f2optional-corner\fP
207 dfc67f9b 2004-05-16 devnull \f2corner\fP of \f2nth\fP \f2primitive\fP
211 dfc67f9b 2004-05-16 devnull .IR optional-corner
212 dfc67f9b 2004-05-16 devnull is one of the eight compass points
213 dfc67f9b 2004-05-16 devnull or the center or the start or end of a primitive.
215 dfc67f9b 2004-05-16 devnull \f2 optional-corner\fP:
216 dfc67f9b 2004-05-16 devnull .n .e .w .s .ne .se .nw .sw .c .start .end
217 dfc67f9b 2004-05-16 devnull \f2 corner\fP:
218 dfc67f9b 2004-05-16 devnull top bot left right start end
220 dfc67f9b 2004-05-16 devnull Each object in a picture has an ordinal number;
222 dfc67f9b 2004-05-16 devnull refers to this.
224 dfc67f9b 2004-05-16 devnull \f2 nth\fP:
225 dfc67f9b 2004-05-16 devnull \f2n\fPth\f2, n\fPth last
228 dfc67f9b 2004-05-16 devnull The built-in variables and their default values are:
230 dfc67f9b 2004-05-16 devnull .ta .5i 2.5i
231 dfc67f9b 2004-05-16 devnull boxwid 0.75 boxht 0.5
232 dfc67f9b 2004-05-16 devnull circlerad 0.25 arcrad 0.25
233 dfc67f9b 2004-05-16 devnull ellipsewid 0.75 ellipseht 0.5
234 dfc67f9b 2004-05-16 devnull linewid 0.5 lineht 0.5
235 dfc67f9b 2004-05-16 devnull movewid 0.5 moveht 0.5
236 dfc67f9b 2004-05-16 devnull textwid 0 textht 0
237 dfc67f9b 2004-05-16 devnull arrowwid 0.05 arrowht 0.1
238 dfc67f9b 2004-05-16 devnull dashwid 0.1 arrowhead 2
241 dfc67f9b 2004-05-16 devnull These may be changed at any time,
242 dfc67f9b 2004-05-16 devnull and the new values remain in force from picture to picture until changed again
243 dfc67f9b 2004-05-16 devnull or reset by a
244 dfc67f9b 2004-05-16 devnull .L reset
245 dfc67f9b 2004-05-16 devnull statement.
246 dfc67f9b 2004-05-16 devnull Variables changed within
250 dfc67f9b 2004-05-16 devnull revert to their previous value upon exit from the block.
251 dfc67f9b 2004-05-16 devnull Dimensions are divided by
252 dfc67f9b 2004-05-16 devnull .B scale
253 dfc67f9b 2004-05-16 devnull during output.
255 dfc67f9b 2004-05-16 devnull Expressions in
257 dfc67f9b 2004-05-16 devnull are evaluated in floating point.
258 dfc67f9b 2004-05-16 devnull All numbers representing dimensions are taken to be in inches.
260 dfc67f9b 2004-05-16 devnull \f2 expr\fP:
261 dfc67f9b 2004-05-16 devnull \f2expr\fP \f2op\fP \f2expr\fP
262 dfc67f9b 2004-05-16 devnull - \f2expr\fP
263 dfc67f9b 2004-05-16 devnull ! \f2expr\fP
264 dfc67f9b 2004-05-16 devnull ( \f2expr\fP )
265 dfc67f9b 2004-05-16 devnull variable
267 dfc67f9b 2004-05-16 devnull \f2place\fP .x \f2place\fP .y \f2place\fP .ht \f2place\fP .wid \f2place\fP .rad
268 dfc67f9b 2004-05-16 devnull sin(\f2expr\fP) cos(\f2expr\fP) atan2(\f2expr,expr\fP) log(\f2expr\fP) exp(\f2expr\fP)
269 dfc67f9b 2004-05-16 devnull sqrt(\f2expr\fP) max(\f2expr,expr\fP) min(\f2expr,expr\fP) int(\f2expr\fP) rand()
270 dfc67f9b 2004-05-16 devnull \f2 op\fP:
271 dfc67f9b 2004-05-16 devnull + - * / % < <= > >= == != && ||
275 dfc67f9b 2004-05-16 devnull .B define
277 dfc67f9b 2004-05-16 devnull .B undef
278 dfc67f9b 2004-05-16 devnull statements are not part of the grammar.
280 dfc67f9b 2004-05-16 devnull define \f2name\fP { \f2replacement text\fP }
281 dfc67f9b 2004-05-16 devnull undef \f2name\fP
283 dfc67f9b 2004-05-16 devnull Occurrences of
284 dfc67f9b 2004-05-16 devnull .BR $1 ,
285 dfc67f9b 2004-05-16 devnull .BR $2 ,
287 dfc67f9b 2004-05-16 devnull in the replacement text
288 dfc67f9b 2004-05-16 devnull will be replaced by the corresponding arguments if
290 dfc67f9b 2004-05-16 devnull is invoked as
292 dfc67f9b 2004-05-16 devnull \f2name\fP(\f2arg1\fP, \f2arg2\fP, ...)
294 dfc67f9b 2004-05-16 devnull Non-existent arguments are replaced by null strings.
295 dfc67f9b 2004-05-16 devnull Replacement text
296 dfc67f9b 2004-05-16 devnull may contain newlines.
298 dfc67f9b 2004-05-16 devnull .B undef
299 dfc67f9b 2004-05-16 devnull statement removes the definition of a macro.
304 dfc67f9b 2004-05-16 devnull preprocessor that accepts
306 dfc67f9b 2004-05-16 devnull language.
307 dfc67f9b 2004-05-16 devnull It produces Tex commands that define a box called
308 dfc67f9b 2004-05-16 devnull .BR \egraph ,
309 dfc67f9b 2004-05-16 devnull which contains the picture.
310 dfc67f9b 2004-05-16 devnull The box may be output this way:
313 dfc67f9b 2004-05-16 devnull \ecenterline{\ebox\egraph}
318 3ebbd193 2017-06-19 rsc language and produces a Scalable Vector Graphics (SVG) image
319 3ebbd193 2017-06-19 rsc suitable for use in HTML documents.
320 dfc67f9b 2004-05-16 devnull .SH EXAMPLES
322 dfc67f9b 2004-05-16 devnull arrow "input" above; box "process"; arrow "output" above
324 dfc67f9b 2004-05-16 devnull A: ellipse
325 dfc67f9b 2004-05-16 devnull circle rad .1 with .w at A.e
326 dfc67f9b 2004-05-16 devnull circle rad .05 at 0.5 <A.c, A.ne>
327 dfc67f9b 2004-05-16 devnull circle rad .065 at 0.5 <A.c, A.ne>
328 dfc67f9b 2004-05-16 devnull spline from last circle.nw left .25 then left .05 down .05
329 dfc67f9b 2004-05-16 devnull arc from A.c to A.se rad 0.5
330 dfc67f9b 2004-05-16 devnull for i = 1 to 10 do { line from A.s+.025*i,.01*i down i/50 }
334 dfc67f9b 2004-05-16 devnull arrow "input" above; box "process"; arrow "output" above
336 dfc67f9b 2004-05-16 devnull A: ellipse
337 dfc67f9b 2004-05-16 devnull circle rad .1 with .w at A.e
338 dfc67f9b 2004-05-16 devnull circle rad .05 at 0.5 <A.c, A.ne>
339 dfc67f9b 2004-05-16 devnull circle rad .065 at 0.5 <A.c, A.ne>
340 dfc67f9b 2004-05-16 devnull spline from last circle.nw left .25 then left .05 down .05
341 dfc67f9b 2004-05-16 devnull arc from A.c to A.se rad 0.5
342 dfc67f9b 2004-05-16 devnull for i = 1 to 10 do { line from A.s+.025*i,.01*i down i/50 }
344 dfc67f9b 2004-05-16 devnull .SH SOURCE
345 c3674de4 2005-01-11 devnull .B \*9/src/cmd/pic
346 dfc67f9b 2004-05-16 devnull .SH "SEE ALSO"
347 dfc67f9b 2004-05-16 devnull .IR grap (1),
348 d32deab1 2020-08-16 rsc .MR doctype (1) ,
349 d32deab1 2020-08-16 rsc .MR troff (1)
351 dfc67f9b 2004-05-16 devnull B. W. Kernighan,
352 dfc67f9b 2004-05-16 devnull ``PIC\(ema Graphics Language for Typesetting'',
354 dfc67f9b 2004-05-16 devnull Unix Research System Programmer's Manual,
355 dfc67f9b 2004-05-16 devnull Tenth Edition, Volume 2
358 3ebbd193 2017-06-19 rsc is only lightly tested.
359 3ebbd193 2017-06-19 rsc It should handle troff commands in text output.