* doc/pic.ms: Mention that compass points of line objects are
[s-roff.git] / doc / pic.ms
blobae1102e1001544361589d529086970632c77c5a0
1 .\" Copyright (C) 2006, 2007, 2008
2 .\"   Free Software Foundation, Inc.
3 .\"      Written by Eric S. Raymond <esr@thyrsus.com>
4 .\" 
5 .\" This file is part of groff.
6 .\" 
7 .\" groff is free software; you can redistribute it and/or modify it under
8 .\" the terms of the GNU General Public License as published by the Free
9 .\" Software Foundation; either version 2, or (at your option) any later
10 .\" version.
11 .\" 
12 .\" groff is distributed in the hope that it will be useful, but WITHOUT ANY
13 .\" WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 .\" FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 .\" for more details.
16 .\" 
17 .\" You should have received a copy of the GNU General Public License along
18 .\" with groff; see the file COPYING.  If not, write to the Free Software
19 .\" Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
20 .\"
21 .\" For tolerably obvious reason, this needs to be processed through PIC.
22 .\" It also needs to be processed through TBL and EQN.  Use "groff -p -e -t".
23 .\" There is no hope that this will ever look right under nroff.
24 .\"
25 .\" Comments beginning with %% are cut lines so portions of this
26 .\" document can be automatically extracted.  %%TUTORIAL%% begins the
27 .\" tutorial part; %%REFERENCE%% the reference part.  %%POSTLUDE%% the
28 .\" bibliography and end matter after the reference part.  
29 .\"
30 .\" This document was written for free use and redistribution by
31 .\" Eric S. Raymond <esr@thyrsus.com> in August 1995.  It has been put
32 .\" under the GPL in March 2006.
33 .\"
34 .\"     $Id$    
37 .\" Set a proper TeX and LaTeX
38 .ie t \{\
39 .  ds tx T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X\"
40 .  ds lx L\h'-0.36m'\v'-0.22v'\s-2A\s0\h'-0.15m'\v'0.22v'\*(tx\"
41 .\}
42 .el \{\
43 .  ds tx TeX\"
44 .  ds lx LaTeX\"
45 .\}
47 .\" Centered caption for figure.  Assumes previous .KS
48 .de CE
49 .  ce 1
50 Figure \\n[H1]-\\$1
51 .  sp 1
52 .  KE
55 .\" Definitions end here
58 .TL
59 Making Pictures With GNU PIC
60 .AU
61 Eric S. Raymond
62 .AI
63 \[la]\fIesr@snark.thyrsus.com\fP\[ra]
64 .AB
65 The \fBpic\fP language is a \fBtroff\fP extension that makes it easy
66 to create and alter box-and-arrow diagrams of the kind frequently used
67 in technical papers and textbooks.  This paper is both an introduction
68 to and reference for \fIgpic\/\fP(1), the implementation distributed by
69 the Free Software Foundation for use with \fIgroff\/\fP(1).
70 .AE
71 .\"%%TUTORIAL%%
74 .NH 1
75 Introduction to PIC
77 .NH 2
78 Why PIC?
79 .PP
80 The \fBpic\fP language provides an easy way to write procedural
81 box-and-arrow diagrams to be included in \fBtroff\fP documents.  The
82 language is sufficiently flexible to be quite useful for state charts,
83 Petri-net diagrams, flow charts, simple circuit schematics, jumper
84 layouts, and other kinds of illustration involving repetitive uses of
85 simple geometric forms and splines.  Because these descriptions are
86 procedural and object-based, they are both compact and easy to modify.
87 .PP
88 The \fIgpic\/\fP(1) implementation of \fBpic\fP is distributed by the
89 Free Software Foundation for use with their \fIgroff\/\fP(1)
90 implementation of \fBtroff\fP.  Because both implementations are
91 widely available in source form for free, they are good bets for
92 writing very portable documentation.
94 .NH 2
95 PIC Versions
96 .PP
97 The original 1984 pre-\fIditroff\/\fP(1) version of \fBpic\fP is long
98 obsolete.  The rewritten 1991 version is still available as part of
99 the Documenter's Work Bench module of System V.
101 Where differences between Documenter's Work Bench (1991) \fBpic\fP and GNU
102 \fBpic\fP need to be described, original \fBpic\fP is referred to as
103 \[lq]DWB pic\[rq].  Details on the history of the program are given at the
104 end of this document.
106 In this document, the \fIgpic\/\fP(1) extensions are marked as such.
109 .NH 1
110 Invoking PIC
112 Every \fBpic\fP description is a little program, which gets compiled
113 by \fIpic\/\fP(1) into \fIgtroff\/\fP(1) macros.  Programs that process or
114 display \fIgtroff\/\fP(1) output need not know or care that parts of the
115 image began life as \fBpic\fP descriptions.
117 The \fIpic\/\fP(1) program tries to translate anything between \fB.PS\fP
118 and \fB.PE\fP markers, and passes through everything else.  The normal
119 definitions of \fB.PS\fP and \fB.PE\fP in the \fIms\fP macro package
120 and elsewhere have also the side-effect of centering the \fBpic\fP output
121 on the page.
123 .NH 2
124 PIC Error Messages
126 If you make a \fBpic\fP syntax error, \fIgpic\/\fP(1) issues an
127 error message in the standard \fIgcc\/\fP(1)-like syntax.  A typical
128 error message looks like this,
132 pic:pic.ms:<nnn>: parse error before `<token>'
133 pic:pic.ms:<nnn>: giving up on this picture
138 where \[la]nnn\[ra] is a line number, and \[la]token\[ra] is a token near (usually
139 just after) the error location.
142 .NH 1
143 Basic PIC Concepts
145 Pictures are described procedurally, as collections of objects
146 connected by motions.  Normally, \fBpic\fP tries to string together
147 objects left-to-right in the sequence they are described, joining them
148 at visually natural points.  Here is an example illustrating the
149 flow of data in \fBpic\fP processing:
152 ellipse "document";
153 arrow;
154 box width 0.6 "\fIgpic\/\fP(1)"
155 arrow;
156 box width 1.1 "\fIgtbl\/\fP(1) or \fIgeqn\/\fP(1)" "(optional)" dashed;
157 arrow;
158 box width 0.6 "\fIgtroff\/\fP(1)";
159 arrow;
160 ellipse "PostScript"
162 .CE "1: Flow of \fBpic\fP data"
164 This was produced from the following \fBpic\fP program:
167 .ps -1
168 .vs -1
170 \&.PS
171 ellipse "document";
172 arrow;
173 box width 0.6 "\efIpic\e/\efP(1)"
174 arrow;
175 box width 1.1 "\efIgtbl\e/\efP(1) or \efIgeqn\e/\efP(1)" "(optional)" dashed;
176 arrow;
177 box width 0.6 "\efIgtroff\e/\efP(1)";
178 arrow;
179 ellipse "PostScript"
180 \&.PE
185 This little program illustrates several \fBpic\fP basics.  Firstly, we
186 see how to invoke three object types; ellipses, arrows, and boxes.  We
187 see how to declare text lines to go within an object (and that text
188 can have font changes in it).  We see how to change the line style of
189 an object from solid to dashed.  And we see that a box can be made
190 wider than its default size to accommodate more text (we'll discuss
191 this facility in detail in the next section).
193 We also get to see \fBpic\fP's simple syntax.  Statements are ended by
194 newlines or semicolons.  String quotes are required around all text
195 arguments, whether or not they contain spaces.  In general, the order
196 of command arguments and modifiers like \[lq]width 1.2\[rq] or
197 \[lq]dashed\[rq] doesn't matter, except that the order of text arguments
198 is significant.
200 Here are all but one of the basic \fBpic\fP objects at their default sizes:
203 box "box";
204 move;
205 line "line" "";
206 move;
207 arrow "arrow" "";
208 move;
209 circle "circle";
210 move;
211 ellipse "ellipse";
212 move;
213 arc; down; move; "arc"
215 .CE "2: Basic \fBpic\fP objects"
217 The missing simple object type is a \fIspline\fP.  There is also a way
218 to collect objects into \fIblock composites\fP which allows you to
219 treat the whole group as a single object (resembling a box) for many
220 purposes.  We'll describe both of these later on.
222 The box, ellipse, circle, and block composite objects are \fIclosed\/\fR;
223 lines, arrows, arcs and splines are \fIopen\fP.  This distinction
224 is often important in explaining command modifiers.
226 Figure \n[H1]-2 was produced by the following \fBpic\fP program,
227 which introduces some more basic concepts:
231 \&.PS
232 box "box";
233 move;
234 line "line" "";
235 move;
236 arrow "arrow" "";
237 move;
238 circle "circle";
239 move;
240 ellipse "ellipse";
241 move;
242 arc; down; move; "arc"
243 \&.PE
245 .ft R
248 The first thing to notice is the \fImove\fP command, which moves a
249 default distance (1/2 inch) in the current movement direction.
251 Secondly, see how we can also decorate lines and arrows with text.
252 The line and arrow commands each take two arguments here, specifying
253 text to go above and below the object.  If you wonder why one argument
254 would not do, contemplate the output of \fBarrow "ow!"\fP:
257 arrow "ow!"
259 .CE "3: Text centered on an arrow"
261 When a command takes one text string, \fBpic\fP tries to place it at
262 the object's geometric center.  As you add more strings, \fBpic\fP
263 treats them as a vertical block to be centered.  The program
267 line "1";
268 line "1" "2";
269 line "1" "2" "3";
270 line "1" "2" "3" "4";
271 line "1" "2" "3" "4" "5";
273 .ft R
276 for example, gives you this:
278 .sp 2
280 line "1";
281 line "1" "2";
282 line "1" "2" "3";
283 line "1" "2" "3" "4";
284 line "1" "2" "3" "4" "5";
286 .sp 2
287 .CE "4: Effects of multiple text arguments"
289 The last line of Figure 3.2's program, `\fBarc; down; move;
290 "arc"\fP', describing the captioned arc, introduces several new ideas.
291 Firstly, we see how to change the direction in which objects are
292 joined.  Had we written \fBarc; move; "arc"\fP,
293 omitting \fBdown\fP the caption would have been joined to the top
294 of the arc, like this:
297 arc; move; "arc";
299 .CE "5: Result of \fBarc; move; \"arc\"\fP"
301 This is because drawing an arc changes the default direction to the
302 one its exit end points at.  To reinforce this point, consider:
305 arc cw; move; "arc";
307 .CE "6: Result of \fBarc cw; move; \"arc\"\fP"
309 All we've done differently here is specify \[lq]cw\[rq] for a clockwise arc
310 (\[lq]ccw\[rq] specifies counter-clockwise direction).
311 Observe how it changes the default direction to down, rather than up.
313 Another good way to see this via with the following program:
317 line; arc; arc cw; line
319 .ft R
322 which yields:
325 line; arc; arc cw; line;
327 .CE "7: Result of \fBline; arc; arc cw; line\fP"
329 Notice that we did not have to specify \[lq]up\[rq] for the second arc to be
330 joined to the end of the first.
332 Finally, observe that a string, alone, is treated as text to be
333 surrounded by an invisible box of a size either specified by width
334 and height attributes or by the defaults \fBtextwid\fR and
335 \fBtextht\fR.  Both are initially zero (because we don't know the
336 default font size).
339 .NH 1 
340 Sizes and Spacing
342 Sizes are specified in inches.  If you don't like inches, it's
343 possible to set a global style variable \fBscale\fP that changes the
344 unit.  Setting \fBscale = 2.54\fP effectively changes the internal
345 unit to centimeters (all other size variable values are scaled
346 correspondingly).
348 .NH 2
349 Default Sizes of Objects
351 Here are the default sizes for \fBpic\fP objects:
352 .TS H
353 center, tab(@), linesize(2);
354 lb | lb
355 l | l.
356 .sp 2p
357 Object@Default Size
358 .sp 2p
360 .sp 2p
362 box@0.75" wide by 0.5" high
363 circle@0.5" diameter
364 ellipse@0.75" wide by 0.5" high
365 arc@0.5" radius
366 line@0.5" long
367 arrow@0.5" long
368 .sp 5p
372 The simplest way to think about these defaults is that they make the
373 other basic objects fit snugly into a default-sized box.
375 .NH 2
376 Objects Do Not Stretch!
378 Text is rendered in the current font with normal troff line spacing.
379 Boxes, circles, and ellipses do \fInot\fP automatically resize to fit
380 enclosed text.  Thus, if you say \fBbox "this text far too long for a
381 default box"\fP you'll get this:
384 box "this text is far too long for a default box"
386 .CE "1: Boxes do not automatically resize"
388 which is probably not the effect you want.
390 .NH 2
391 Resizing Boxes
393 To change the box size, you can specify a box width with the \[lq]width\[rq]
394 modifier:
397 box width 3 "this text is far too long for a default box"
399 .CE "2: Result of \fBbox width 3 \"text far too long\"\fP"
401 This modifier takes a dimension in inches.  There is also a \[lq]height\[rq]
402 modifier that changes a box's height.  The \fBwidth\fP keyword may
403 be abbreviated to \fBwid\fP; the \fBheight\fP keyword to \fBht\fP.
405 .NH 2
406 Resizing Other Object Types
408 To change the size of a circle, give it a \fBrad[ius]\fP or
409 \fBdiam[eter]\fP modifier; this changes the radius or diameter of the
410 circle, according to the numeric argument that follows.
413 {circle rad 0.1; move down 0.2 from last circle .s; "0.1"};
414 move; circle rad 0.2 "0.2"; move; circle rad 0.3 "0.3";
416 .CE "3: Circles with increasing radii"
418 The \fBmove\fP command can also take a dimension, which just tells
419 it how many inches to move in the current direction.
421 Ellipses are sized to fit in the rectangular box defined by their
422 axes, and can be resized with \fBwidth\fP and \fBheight\fP like boxes.
424 You can also change the radius of curvature of an arc with \fBrad[ius]\fP
425 (which specifies the radius of the circle of which the arc is a segment).
426 Larger values yield flatter arcs.
429 {arc rad 0.1; move down 0.3 from last arc .center; "0.1"};
430 move;
431 {arc rad 0.2; move down 0.4 from last arc .center; "0.2"};
432 move;
433 {arc rad 0.3; move down 0.5 from last arc .center; "0.3"};
435 .CE "4: \fBarc rad\fP with increasing radii"
437 Observe that because an arc is defined as a quarter circle, increasing
438 the radius also increases the size of the arc's bounding box.
440 .NH 2
441 The `same' Keyword
443 In place of a dimension specification, you can use the keyword
444 \fBsame\fR.  This gives the object the same size as the previous one
445 of its type.  As an example, the program
449 \&.PS
450 box; box wid 1 ht 1; box same; box
451 \&.PE
456 gives you
459 box; box wid 1 ht 1; box same; box
461 .CE "5: The \fBsame\fP keyword"
464 .NH 1
465 Generalized Lines and Splines
467 .NH 2
468 Diagonal Lines
470 It is possible to specify diagonal lines or arrows by adding multiple \fBup\fP,
471 \fBdown\fP, \fBleft\fP, and \fBright\fP modifiers to the line object.
472 Any of these can have a multiplier.  To understand the effects, think
473 of the drawing area as being gridded with standard-sized boxes.
476 # Draw a demonstration up left arrow with grid box overlay
477 define gridarrow
479         move right 0.1
480         [
481                 {arrow up left $1;}
482                 box wid 0.5 ht 0.5 dotted with .nw at last arrow .end;
483                 for i = 2 to ($1 / 0.5) do {
484                         box wid 0.5 ht 0.5 dotted with .sw at last box .se;
485                 }
486                 move down from last arrow .center;
487                 [
488                         if ( $1 == boxht ) then {
489                                 "\fBline up left\fP"
490                         } else {
491                                 sprintf("\fBarrow up left %g\fP", $1)
492                         }
493                 ]
494         ] 
495         move right 0.1 from last [] .e;
497 gridarrow(0.5);
498 gridarrow(1);
499 gridarrow(1.5);
500 gridarrow(2);
501 undef gridarrow
503 .CE "1: Diagonal arrows (dotted boxes show the implied 0.5-inch grid)"
505 .NH 2
506 Multi-Segment Line Objects
508 A \[lq]line\[rq] or \[lq]arrow\[rq] object may actually be a path
509 consisting of any number of segments of varying lengths and directions.
510 To describe a path, connect several line or arrow commands with the
511 keyword \fBthen\fP.
514 define zigzag { $1 right 1 then down .5 left 1 then right 1 }
515 zigzag(line); 
517 .CE "2: \fBline right 1 then down .5 left 1 then right 1\fP"
519 If a path starts with \fBthen\fP, the first segment is assumed to be into
520 the current direction, using the default length.
522 .NH 2
523 Spline Objects
525 If you start a path with the \fBspline\fP keyword, the path vertices
526 are treated as control points for a spline curve fit.
529 [zigzag(spline);]
530 move down 0.2 from last [] .s;
531 "The spline curve..."
532 move right from last [] .e;
534         zigzag(line dashed);
535         spline from start of last line right 1 then down .5 left 1 then right 1;
536         "1" at last spline .start + (-0.1, 0);
537         "2" at last spline .start + (1.1, 0);
538         "3" at last spline .end + (-1.1, 0);
539         "4" at last spline .end + (0.1, 0);
541 move down 0.2 from last [] .s;
542 "...with tangents displayed"
543 undef zigzag;
545 .CE "3: \fBspline right 1 then down .5 left 1 then right 1\fP"
547 You can describe many natural-looking but irregular curves this
548 way.  For example: 
551 [spline right then up then left then down ->;]
552 move down 0.2 from last [] .s;
553 ["\fBspline right then up then left then down ->;\fP"]
554 move right 3 from last [] .se;
555 "\fBspline left then up right then down right ->;\fP"
556 move up 0.2;
557 [spline left then up right then down right ->;]
559 .CE "4: Two more spline examples"
561 Note the arrow decorations.  Arrowheads can be applied naturally to
562 any path-based object, line or spline.  We'll see how in the next
563 section.
566 .NH 1
567 Decorating Objects
569 .NH 2
570 Dashed Objects
572 We've already seen that the modifier \fBdashed\fP can change the line
573 style of an object from solid to dashed.  GNU \fBgpic\fP permits you to
574 dot or dash ellipses, circles, and arcs (and splines in \*[tx] mode
575 only); some versions of DWB may only permit dashing of lines and
576 boxes.  It's possible to change the dash interval by specifying a
577 number after the modifier.
581 box dashed "default";
582 move;
583 box dashed 0.05 "0.05";
584 move;
585 box dashed 0.1 "0.1";
586 move;
587 box dashed 0.15 "0.15";
588 move;
589 box dashed 0.2 "0.2";
591 .CE "1: Dashed objects"
593 .NH 2
594 Dotted Objects
596 Another available qualifier is \fBdotted\fP.  GNU \fBgpic\fP permits
597 you to dot or dash ellipses, circles, and arcs (and splines in \*[tx]
598 mode only); some versions of DWB may only permit dashing of lines and
599 boxes.  It too can be suffixed with a number to specify the interval
600 between dots:
603 box dotted "default";
604 move;
605 box dotted 0.05 "0.05";
606 move;
607 box dotted 0.1 "0.1";
608 move;
609 box dotted 0.15 "0.15";
610 move;
611 box dotted 0.2 "0.2";
613 .CE "2: Dotted objects"
615 .NH 2
616 Rounding Box Corners
618 It is also possible, in GNU \fBgpic\fP only, to modify a box so it has
619 rounded corners:
622 box rad 0.05 "rad 0.05";
623 move;
624 box rad 0.1 "rad 0.1";
625 move;
626 box rad 0.15 "rad 0.15"; 
627 move;
628 box rad 0.2 "rad 0.2"; 
629 move;
630 box rad 0.25 "rad 0.25"; 
632 .CE "3: \fBbox rad\fP with increasing radius values"
634 Radius values higher than half the minimum box dimension are silently
635 truncated to that value.
637 .NH 2
638 Slanted Boxes
640 GNU \fBgpic\fP supports slanted boxes:
643 box wid 1.2 xslanted 0.1 "xslanted 0.1";
644 move;
645 box wid 1.2 yslanted -0.1 "yslanted -0.1";
646 move;
647 box wid 1.2 xslanted -0.2 yslanted 0.1 "xslanted -0.2" "yslanted 0.1";
649 .CE "4: Various slanted boxes.
651 The \fBxslanted\fP and \fByslanted\fP attributes specify the x and
652 y\~offset, respectively, of the box's upper right corner from its default
653 position.
655 .NH 2
656 Arrowheads
658 Lines and arcs can be decorated as well.  Any line or arc (and any
659 spline as well) can be decorated with arrowheads by adding one or more
660 as modifiers:
663 line <- ->
665 .CE "5: Double-headed line made with  \fBline <- ->\fP"
667 In fact, the \fBarrow\fP command is just shorthand for \fBline ->\fP.  And
668 there is a double-head modifier <->, so the figure above could have been made
669 with \fBline <->\fP.
671 Arrowheads have a \fBwidth\fP attribute, the distance across the rear;
672 and a \fBheight\fP attribute, the length of the arrowhead along the shaft.
674 Arrowhead style is controlled by the style variable \fBarrowhead\fP.
675 The DWB and GNU versions interpret it differently.  DWB defaults to
676 open arrowheads and an \fBarrowhead\fP value of\~2; the Kernighan
677 paper says a value of\~7 makes solid arrowheads.  GNU \fBgpic\fP
678 defaults to solid arrowheads and an \fBarrowhead\fP value of\~1; a
679 value of\~0 produces open arrowheads.  Note that solid arrowheads are
680 always filled with the current outline color.
682 .NH 2
683 Line Thickness
685 It's also possible to change the line thickness of an object (this is
686 a GNU extension, DWB \fBpic\fP doesn't support it).  
687 The default thickness of the lines used to draw objects is controlled by the
688 .B linethick
689 variable.
690 This gives the thickness of lines in points.
691 A negative value means use the default thickness:
692 in \*[tx] output mode, this means use a thickness of 8 milliinches;
693 in \*[tx] output mode with the
694 .B -c
695 option, this means use the line thickness specified by
696 .B .ps
697 lines; in troff output mode, this means use a thickness proportional
698 to the pointsize.  A zero value means draw the thinnest possible line
699 supported by the output device.  Initially it has a value of -1.
700 There is also a \fBthickness\fP attribute (which can be abbreviated to
701 \fBthick\fP).  For example, \fBcircle thickness 1.5\fP would draw a
702 circle using a line with a thickness of 1.5 points.  The thickness of
703 lines is not affected by the value of the
704 .B scale
705 variable, nor by any width or height given in the
706 .B .PS
707 line.
709 .NH 2
710 Invisible Objects
712 The modifier \fBinvis[ible]\fP makes an object entirely invisible.  This
713 used to be useful for positioning text in an invisible object that is
714 properly joined to neighboring ones.  Newer DWB versions and GNU
715 \fBpic\fP treat stand-alone text in exactly this way.
717 .NH 2
718 Filled Objects
720 It is possible to fill boxes, circles, and ellipses.  The
721 modifier \fBfill[ed]\fP accomplishes this.  You can suffix it with a fill
722 value; the default is given by the style variable \fBfillval\fP.
724 DWB \fBpic\fP and \fBgpic\fP have opposite conventions for fill values
725 and different defaults.  DWB \fBfillval\fP defaults to 0.3 and smaller
726 values are darker; GNU \fBfillval\fP uses 0 for white and 1 for black.
729 circle fill; move; circle fill 0.4; move; circle fill 0.9;
731 .CE "6: \fBcircle fill; move; circle fill 0.4; move; circle fill 0.9;\fR"
733 GNU \fBgpic\fP makes some additional guarantees.  A fill value greater
734 than 1 can also be used: this means fill with the shade of gray that
735 is currently being used for text and lines.  Normally this is
736 black, but output devices may provide a mechanism for changing this.
737 The invisible attribute does not affect the filling of objects.  Any
738 text associated with a filled object is added after the object
739 has been filled, so that the text is not obscured by the filling.
741 The closed-object modifier \fBsolid\fP is equivalent to \fBfill\fP
742 with the darkest fill value (DWB \fBpic\fP had this capability but
743 mentioned it only in a reference section).  
745 .NH 2
746 Colored Objects
748 As a GNU extension, three additional modifiers are available to specify
749 colored objects.  \fBoutline\fP sets the color of the outline, \fBshaded\fP
750 the fill color, and \fBcolor\fP sets both.  All three keywords expect a
751 suffix specifying the color.  Example:
754 box color "yellow"; arrow color "cyan"; circle shaded "green" outline "black";
756 .CE "7: \fBbox color ""yellow""; arrow color ""cyan""; \
757 circle shaded ""green"" outline ""black"";\fR"
759 Alternative spellings are \fBcolour\fP, \fBcolored\fP, \fBcoloured\fP,
760 and \fBoutlined\fP.
762 Currently, color support is not available in \*[tx] mode.  Predefined color
763 names for \fIgroff\/\fP(1) are in the device macro files, for example
764 \f(CWps.tmac\fP; additional colors can be defined with the \fB.defcolor\fP
765 request (see the manual page of GNU \fItroff\/\fP(1) for more details).
767 \fBpic\fP assumes that at the beginning of a picture both glyph and fill
768 color are set to the default value.
771 .NH 1
772 More About Text Placement
774 By default, text is centered at the geometric center of the object it is
775 associated with.  The modifier \fBljust\fP causes the left end to be
776 at the specified point (which means that the text lies to the right of
777 the specified place!), the modifier \fBrjust\fP puts the right end at
778 the place.  The modifiers \fBabove\fP and \fBbelow\fP center the text
779 one half line space in the given direction.
781 Text attributes can be combined:
784 [line up "ljust text" ljust;] 
785 move 1.5;
786 [line up "rjust text" rjust;] 
787 move;
788 [arrow 1 "ljust above" ljust above;]
789 move;
790 [arrow 1 "rjust below" rjust below;]
792 .CE "1: Text attributes"
794 What actually happens is that \fIn\fP text strings are centered in a box
795 that is \fBtextwid\fP wide by \fBtextht\fP high.  Both these variables
796 are initially zero (that is \fBpic\fR's way of not making assumptions
797 about \fI[tg]roff\/\fP(1)'s default point size).
799 In GNU \fBgpic\fR, objects can have an
800 .B aligned
801 attribute.
802 This only works if the postprocessor is
803 \fBgrops\fP.
804 Any text associated with an object having the
805 .B aligned
806 attribute is rotated about the center of the object
807 so that it is aligned in the direction from the start point
808 to the end point of the object.
809 Note that this attribute has no effect for objects whose start and
810 end points are coincident.
813 .NH 1
814 More About Direction Changes
816 We've already seen how to change the direction in which objects are
817 composed from rightwards to downwards.  Here are some more
818 illustrative examples:
821 down;
823         "\fBright; box; arrow; circle; arrow; ellipse\fP";
824         move 0.2;
825         [right; box; arrow; circle; arrow; ellipse;]
827 move down 0.3 from last [] .s;
829         "\fBleft; box; arrow; circle; arrow; ellipse\fP"
830         move 0.2;
831         [left; box; arrow; circle; arrow; ellipse;]
833 # move down 0.3 from last [] .sw;
834 # To re-join this illustrations, delete everything from here down to
835 # the next #-comment, and uncomment the move line above
837 .CE "1: Effects of different motion directions (right and left)"
840 # To re-join this illustrations, delete everything down to here, then
841 # comment out the next `down' line.
842 # Don't forget to re-number the figures following!
843 down;
845         "\fBdown; box; arrow; circle; arrow; ellipse;\fP"
846         move 0.2;
847         box; arrow; circle; arrow; ellipse;
849 move right 2 from last [] .e;
851         up; box; arrow; circle; arrow; ellipse;
852         move 0.2;
853         "\fBup; box; arrow; circle; arrow; ellipse;\fP"
856 .CE "2: Effects of different motion directions (up and down)"
858 Something that may appear surprising happens if you change directions 
859 in the obvious way:
862 box; arrow; circle; down; arrow; ellipse
864 .CE "3: \fBbox; arrow; circle; down; arrow; ellipse\fP"
866 You might have expected that program to yield this:
869 box; arrow; circle; move to last circle .s; down; arrow; ellipse
871 .CE "4: More intuitive?"
873 But, in fact, to get Figure \*[SN]3 you have to do this:
877 \&.PS
878 box;
879 arrow;
880 circle;
881 move to last circle .s;
882 down;
883 arrow;
884 ellipse
885 \&.PE
890 Why is this?  Because the exit point for the current direction is
891 already set when you draw the object.  The second arrow in Figure
892 \*[SN]2 dropped downwards from the circle's attachment point for an
893 object to be joined to the right.
895 The meaning of the command \fBmove to last circle .s\fP should be obvious.
896 In order to see how it generalizes, we'll need to go into detail on two
897 important topics; locations and object names.
900 .NH 1
901 Naming Objects
903 The most natural way to name locations in \fBpic\fP is relative to
904 objects.  In order to do this, you have to be able you have to be able
905 to name objects.  The \fBpic\fP language has rich facilities for this
906 that try to emulate the syntax of English.
908 .NH 2
909 Naming Objects By Order Of Drawing
911 The simplest (and generally the most useful) way to name an object is
912 with a \fBlast\fP clause.  It needs to be followed by an object type
913 name; \fBbox\fP, \fBcircle\fP, \fBellipse\fP, \fBline\fP, \fBarrow\fP,
914 \fBspline\fP, \fB""\fP, or \fB[]\fP (the last type refers to a \fIcomposite
915 object\fP which we'll discuss later).  So, for example, the \fBlast
916 circle\fP clause in the program attached to Figure \*[SN]3 refers to the
917 last circle drawn.
919 More generally, objects of a given type are implicitly numbered
920 (starting from\~1).  You can refer to (say) the third ellipse in the
921 current picture with \fB3rd ellipse\fP, or to the first box as \fB1st
922 box\fP, or to the fifth text string (which isn't an attribute to another
923 object) as \fB5th ""\fP.
925 Objects are also numbered backwards by type from the last one.
926 You can say \fB2nd last box\fP to get the second-to-last box, or
927 \fB3rd last ellipse\fP to get the third-to-last ellipse.
929 In places where \fIn\/\fBth\fR is allowed, \fB`\fIexpr\/\fB'th\fR is
930 also allowed.  Note that
931 .B 'th
932 is a single token: no space is allowed between the
933 .B '
934 and the \fBth\fP.
935 For example,
940 for i = 1 to 4 do {
941    line from `i'th box.nw to `i+1'th box.se
947 .NH 2
948 Naming Objects With Labels
950 You can also specify an object by referring to a label.  A label is a
951 word (which must begin with a capital letter) followed by a colon;
952 you declare it by placing it immediately before the object drawing command.
953 For example, the program
957 \&.PS
958 A: box "first" "object"
959 move;
960 B: ellipse "second" "object"
961 move;
962 arrow right at A .r;
963 \&.PE
968 declares labels \fBA\fP and \fBB\fP for its first and second objects.
969 Here's what that looks like:
972 A: box "first" "object"
973 move;
974 B: ellipse "second" "object"
975 move;
976 arrow right at A .r;
978 .CE "1: Example of label use"
979 The \fBat\fP statement in the fourth line uses the label \fBA\fP (the
980 behavior of \fBat\fP is explained in the next section).  We'll
981 see later on that labels are most useful for referring to block composite
982 objects.  
984 Labels are not constants but variables (you can view colon as a sort
985 of assignment).  You can say something like \fBA: A + (1,0);\fP
986 and the effect is to reassign the label \fBA\fR to designate a
987 position one inch to the right of its old value. 
990 .NH 1
991 Describing locations
993 The location of points can be described in many different ways.  All these
994 forms are interchangeable as for as the \fBpic\fP language syntax is
995 concerned; where you can use one, any of the others that would make 
996 semantic sense are allowed.
998 The special label \fBHere\fR always refers to the current position.
1000 .NH 2
1001 Absolute Coordinates
1003 The simplest is absolute coordinates in inches; \fBpic\fP uses a
1004 Cartesian system with (0,0) at the lower left corner of the virtual
1005 drawing surface for each picture (that is, X increases to the right
1006 and Y increases upwards).  An absolute location may always be written in the
1007 conventional form as two comma-separated numbers surrounded by
1008 parentheses (and this is recommended for clarity).  In contexts where
1009 it creates no ambiguity, the pair of X and Y coordinates suffices
1010 without parentheses.
1012 It is a good idea to avoid absolute coordinates, however.  They tend
1013 to make picture descriptions difficult to understand and modify.
1014 Instead, there are quite a number of ways to specify locations
1015 relative to \fBpic\fP objects and previous locations.
1017 Another possibility of surprise is the fact that \fBpic\fP crops the
1018 picture to the smallest bounding box before writing it out.  For
1019 example, if you have a picture consisting of a small box with its lower
1020 left corner at (2,2) and another small box with its upper right corner
1021 at (5,5), the width and height of the image are both 3\~units and
1022 not\~5.  To get the origin at (0,0) included, simply add an invisible
1023 object to the picture, positioning the object's left corner at (0,0).
1025 .NH 2
1026 Locations Relative to Objects
1028 The symbol \fBHere\fP always refers to the position of the last object
1029 drawn or the destination of the last \fBmove\fP.
1031 Alone and unqualified, a \fBlast circle\fP or any other way of
1032 specifying a closed-object or arc location refers as a position to the
1033 geometric center of the object.  Unqualified, the name of a line or
1034 spline object refers to the position of the object start.
1036 Also, \fBpic\fP objects have quite a few named locations
1037 associated with them.  One of these is the object center, which can be
1038 indicated (redundantly) with the suffix \fB.center\fP (or just \fB.c\fP).
1039 Thus, \fBlast circle \&.center\fP is equivalent to \fBlast
1040 circle\fP.
1041 .NH 3
1042 Locations Relative to Closed Objects
1044 Every closed object (box, circle, ellipse, or block composite) also
1045 has eight compass points associated with it;
1048 define dot {circle fill rad 0.02 at $1}
1050 define compass { [
1051         ME: $1;
1052         dot(ME.c);  "\fB .c\fP"  at ME .c ljust;
1053         dot(ME.n);  "\fB.n\fP"   at ME .n above
1054         dot(ME.ne); "\fB .ne\fP" at ME .ne above
1055         dot(ME.e);  "\fB .e\fP"  at ME .e ljust
1056         dot(ME.se); "\fB .se\fP" at ME .se below
1057         dot(ME.s);  "\fB.s\fP"   at ME .s below
1058         dot(ME.sw); "\fB.sw \fP" at ME .sw below
1059         dot(ME.w);  "\fB.w \fP"  at ME .w rjust
1060         dot(ME.nw); "\fB.nw \fP" at ME .nw above
1061 ] }
1062 compass(box wid 1.5 ht 1);
1063 move right from last [] .e;
1064 compass(circle diam 1);
1065 move right from last [] .e;
1066 compass(ellipse wid 1.5 ht 1);
1068 .CE "1: Compass points"
1070 these are the locations where eight compass rays from the geometric center
1071 would intersect the figure.  So when we say \fBlast circle .s\fP we are
1072 referring to the south compass point of the last circle drawn.  The
1073 explanation of Figure 7.3's program is now complete.
1075 (In case you dislike compass points, the names \fB.top\fP,
1076 \&\fB.bottom\fP, \fB.left\fP and \fB.right\fP are synonyms for \fB.n\fP,
1077 \&\fB.s\fP, \fB.e\fP, and \fB.w\fP respectively; they can even be
1078 abbreviated to \fB.t\fP, \fB.b\fP, \fB.l\fP and \fB.r\fP).
1080 The names \fBcenter\fP, \fBtop\fP, \fBbottom\fP, \fBleft\fP, \fBright\fP,
1081 \fBnorth\fP, \fBsouth\fP, \fBeast\fP, and \fBwest\fP can also be used
1082 (without the leading dot) in a prefix form marked by \fBof\fP; thus,
1083 \fBcenter of last circle\fP and \fBtop of 2nd last ellipse\fP are both
1084 valid object references.  Finally, the names \fBleft\fP and \fBright\fP
1085 can be prefixed with \fBupper\fP and \fBlower\fP which both have the
1086 obvious meaning.
1088 Arc objects also have compass point; they are the compass points of
1089 the implied circle.
1091 Non-closed objects (line, arrow, or spline) have compass points too, but
1092 the locations of them are completely arbitrary.  In particular, different
1093 \fBpic\fP implementations return different locations.
1094 .NH 3
1095 Locations Relative to Open Objects
1097 Every open object (line, arrow, arc, or spline) has three named
1098 points: \fB.start\fP, \fB.center\fP (or \fB.c\fP), and \fB.end\fP.  They
1099 can also be used without leading dots in the \fBof\fP prefix form.
1100 The center of an arc is the center of its circle, but the center of
1101 a line, path, or spline is halfway between its endpoints.
1104 define critical {
1105         [ ME: $1;
1106                 dot(ME.c);     "\fB.center\fP" rjust at ME.center + (-0.1, 0.1)
1107                 dot(ME.start); "\fB.start\fP"  rjust at ME.start  + (-0.1, 0.1)
1108                 dot(ME.end);   "\fB.end\fP"    rjust at ME.end    + (-0.1, 0.1)
1109         ]
1111 critical(line up right 1);
1112 move right 1 from last [] .e;
1113 critical(arc rad 0.5 cw);
1114 move down 0.5 from 2nd last [] .s;
1115 critical(line right 1 then down .5 left 1 then right 1);
1116 move right 1 from last [] .e;
1117 critical(spline right 1 then up right then left then left 1);
1119 .CE "2: Special points on open objects"
1122 .NH 2
1123 Ways of Composing Positions
1125 Once you have two positions to work with, there are several ways to
1126 combine them to specify new positions.
1127 .NH 3
1128 Vector Sums and Displacements
1130 Positions may be added or subtracted to yield a new position (to be
1131 more precise, you can only add a position and an expression pair; the
1132 latter must be on the right side of the addition or subtraction sign).
1133 The result is the conventional vector sum or difference of coordinates.
1134 For example, \fBlast box .ne + (0.1, 0)\fP is a valid position.  This 
1135 example illustrates a common use, to define a position slightly offset
1136 from a named one (say, for captioning purposes).
1137 .NH 3
1138 Interpolation Between Positions
1140 A position may be interpolated between any two positions.  The syntax
1141 is `\fIfraction\fP \fBof the way between\fP \fIposition1\fP \fBand\fP
1142 \fIposition2\fP'.  For example, you can say \fB1/3 of the way between
1143 here and last ellipse .ne\fP.  The fraction may be in
1144 numerator/denominator form or may be an ordinary number (values are
1145 \fInot\fP restricted to [0,1]).  As an alternative to this verbose
1146 syntax, you can say `\fIfraction\fP  \fB<\,\fP\fIposition1\fP \fB,\fP
1147 \fIposition2\/\fP\fB>\fP'; thus, the example could also be written as
1148 \fB1/3 <here, last ellipse>\fP.
1151 arrow up right;
1152 P: 1/3 of the way between last arrow .start and last arrow .end;
1153 dot(P); move right 0.1; "P";
1155 .CE "3: \fBP: 1/3 of the way between last arrow .start and last arrow .end\fP"
1157 This facility can be used, for example, to draw double connections.
1160 A: box "yin"; move;
1161 B: box "yang";
1162 arrow right at 1/4 <A.e,A.ne>;
1163 arrow left  at 1/4 <B.w,B.sw>;
1165 .CE "4: Doubled arrows"
1167 You can get Figure \n[H1]-4 from the following program:
1171 \&.PS
1172 A: box "yin"; move;
1173 B: box "yang";
1174 arrow right at 1/4 <A.e,A.ne>;
1175 arrow left  at 1/4 <B.w,B.sw>;
1176 \&.PE
1181 Note the use of the short form for interpolating points.
1182 .NH 3
1183 Projections of Points
1185 Given two positions \fIp\fP and \fIq\fP, the position
1186 \fB(\,\fP\fIp\fP\fB,\fP \fIq\fP\fB)\fP has the X coordinate of \fIp\fP
1187 and the Y coordinate of \fIq\fP.  This can be helpful in placing an
1188 object at one of the corners of the virtual box defined by two other
1189 objects.
1192 box invis wid 2 height 1;
1193 dot(last box .ne); "\fB(B,A)\fP is here" ljust at last circle + (0.1, 0.1);
1194 dot(last box .se); "B" ljust at last circle + (0.1, -0.1)
1195 dot(last box .sw); "\fB(A,B)\fP is here" rjust at last circle + (-0.1, -0.1);
1196 dot(last box .nw); "A" ljust at last circle + (-0.1, 0.1)
1198 .CE "5: Using (\fIx\fP, \fIy\fP) composition"
1200 .NH 2
1201 Using Locations
1203 There are four ways to use locations; \fBat\fP, \fBfrom\fP, \fBto\fP,
1204 and \fBwith\fP.  All four are object modifiers; that is, you use them
1205 as suffixes to a drawing command.
1207 The \fBat\fP modifier says to draw a closed object or arc with its
1208 center at the following location, or to draw a line/spline/arrow
1209 starting at the following location.
1211 The \fBto\fP modifier can be used alone to specify a move destination.
1212 The \fBfrom\fP modifier can be used alone in the same way as \fBat\fP.
1214 The \fBfrom\fP and \fBto\fP modifiers can be used with a \fBline\fR or
1215 \fBarc\fR command to specify start and end points of the object.  In
1216 conjunction with named locations, this offers a very flexible
1217 mechanism for connecting objects.  For example, the following program
1221 \&.PS
1222 box "from"
1223 move 0.75;
1224 ellipse "to"
1225 arc cw from 1/3 of the way \e
1226     between last box .n and last box .ne to last ellipse .n;
1227 \&.PE
1232 yields:
1235 box "from"
1236 move 0.75;
1237 ellipse "to"
1238 arc cw from 1/3 of the way \
1239     between last box .n and last box .ne to last ellipse .n;
1241 .CE "6: A tricky connection specified with English-like syntax"
1243 The \fBwith\fP modifier allows you to identify a named attachment
1244 point of an object (or a position within the object) with another point.
1245 This is very useful for connecting objects in a natural way.  For an
1246 example, consider these two programs:
1250         [
1251                 box wid 0.5 ht 0.5;
1252                 box wid 0.75 ht 0.75;
1253         ]
1254         move down 0.3 from last [] .s 0.1;
1255         "\fBbox wid 0.5 ht 0.5; box wid 0.75 ht 0.75\fP"
1257 move from last [].e 1.5
1259         [
1260                 box wid 0.5 ht 0.5;
1261                 box wid 0.75 ht 0.75 with .sw at last box .se;
1262         ]
1263         move down 0.3 from last [] .s 0.1;
1264         box invisible "\fBbox wid 0.5 ht 0.5;\fP" \
1265           "\fBbox wid 0.75 ht 0.75 with .sw at last box .se;\fP"
1268 .CE "7: Using the \fBwith\fP modifier for attachments"
1270 .NH 2
1271 The `chop' Modifier
1273 When drawing lines between circles that don't intersect them at a
1274 compass point, it is useful to be able to shorten a line by the radius 
1275 of the circle at either or both ends.  Consider the following program:
1279 \&.PS
1280 circle "x"
1281 circle "y" at 1st circle - (0.4, 0.6) 
1282 circle "z" at 1st circle + (0.4, -0.6) 
1283 arrow from 1st circle to 2nd circle chop 
1284 arrow from 2nd circle to 3rd circle chop 
1285 arrow from 3rd circle to 1st circle chop 
1286 \&.PE
1291 It yields the following:
1294 circle "x"
1295 circle "y" at 1st circle - (0.4, 0.6) 
1296 circle "z" at 1st circle + (0.4, -0.6) 
1297 arrow from 1st circle to 2nd circle chop 
1298 arrow from 2nd circle to 3rd circle chop 
1299 arrow from 3rd circle to 1st circle chop 
1301 .CE "8: The \fBchop\fR modifier"
1303 Notice that the \fBchop\fR attribute moves arrowheads rather than
1304 stepping on them.  By default, the \fBchop\fR modifier shortens both
1305 ends of the line by \fBcirclerad\fR.  By suffixing it with a number
1306 you can change the amount of chopping.
1308 If you say \fBline .\|.\|.\& chop \fIr1\fP chop \fIr2\fP\fR with \fIr1\fP
1309 and \fIr2\fP both numbers, you can vary the amount of chopping at both
1310 ends.  You can use this in combination with trigonometric functions
1311 to write code that deals with more complex intersections.
1314 .NH 1
1315 Object Groups
1317 There are two different ways to group objects in \fBpic\fP; \fIbrace
1318 grouping\fP and \fIblock composites\fP.
1320 .NH 2
1321 Brace Grouping
1323 The simpler method is simply to group a set of objects within curly
1324 bracket or brace characters.  On exit from this grouping, the current
1325 position and direction are restored to their value when the opening
1326 brace was encountered.
1328 .NH 2
1329 Block Composites
1331 A block composite object is created a series of commands enclosed by
1332 square brackets.  The composite can be treated for most purposes like
1333 a single closed object, with the size and shape of its bounding box.
1334 Here is an example.  The program fragment
1338 A: [
1339     circle;
1340     line up 1 at last circle .n;
1341     line down 1 at last circle .s;
1342     line right 1 at last circle .e;
1343     line left 1 at last circle .w;
1344     box dashed with .nw at last circle .se + (0.2, -0.2); 
1345     Caption: center of last box;
1351 yields the block in figure \n[H1]-1, which we show both with and
1352 without its attachment points.  The block's location becomes the
1353 value of \fBA\fP.
1356 define junction {
1357         circle;
1358         line up 1 at last circle .n;
1359         line down 1 at last circle .s;
1360         line right 1 at last circle .e;
1361         line left 1 at last circle .w;
1362         box dashed with .nw at last circle .se + (0.2, -0.2); 
1363         Caption: center of last box;
1365 [junction();]
1366 move;
1367 compass([junction()]);
1369 .CE "1: A sample composite object"
1371 To refer to one of the composite's attachment points, you can say
1372 (for example) \fBA .s\fP.  For purposes of object naming, composites
1373 are a class.  You could write \fBlast [] .s\fP as an equivalent
1374 reference, usable anywhere a location is needed.  This construction is
1375 very important for putting together large, multi-part diagrams.
1376 .PP 
1377 Blocks are also a variable-scoping mechanism, like a \fIgroff\/\fP(1)
1378 environment.  All variable assignments done inside a block are undone
1379 at the end of it.  To get at values within a block, write a name of
1380 the block followed by a dot, followed by the label you
1381 want.  For example, we could refer the the center of the box in the
1382 above composite as \fBlast [] .Caption\fP or \fBA.Caption\fP.
1384 This kind of reference to a label can be used in any way any other
1385 location can be.  For example, if we added \fB"Hi!" at A.Caption\fP
1386 the result would look like this:
1389 A: [junction();]
1390 "Hi!" at A.Caption;
1392 .CE "2: Adding a caption using interior labeling"
1394 You can also use interior labels in either part of a \fBwith\fR
1395 modifier.  This means that the example composite could be placed
1396 relative to its caption box by a command containing \fBwith A.Caption
1397 at\fP.
1399 Note that both width and height of the block composite object are always
1400 positive:
1404         [
1405                 box wid -0.5 ht 0.5
1406                 box wid 0.75 ht 0.75
1407         ]
1408         move down 0.3 from last [].s 0.1
1409         "\fBbox wid -0.5 ht 0.5; box wid 0.75 ht 0.75\fP"
1411 move from last [].e 2
1413         [
1414                 [ box wid -0.5 ht 0.5 ]
1415                 box wid 0.75 ht 0.75
1416         ]
1417         move down 0.3 from last [].s 0.1
1418         "\fB[box wid -0.5 ht 0.5]; box wid 0.75 ht 0.75\fP"
1421 .CE "3: Composite block objects always have positive width and height
1423 Blocks may be nested.  This means you can use block attachment points
1424 to build up complex diagrams hierarchically, from the inside out.
1425 Note that \fBlast\fP and the other sequential naming mechanisms
1426 don't look inside blocks, so if you have a program that looks 
1427 like 
1431 \&.PS
1432 P: [box "foo"; ellipse "bar"];
1433 Q: [
1434         [box "baz"; ellipse "quxx"]
1435         "random text";
1436    ]
1437 arrow from 2nd last [];
1438 \&.PE
1443 the arrow in the last line is attached to object \fBP\fP, not 
1444 object \fBQ\fP.
1446 In DWB \fBpic\fP, only references one level deep into enclosed blocks
1447 were permitted.  GNU \fBgpic\fP removes this restriction.
1449 The combination of block variable scoping, assignability of labels and
1450 the macro facility that we'll describe later on can be used to
1451 simulate functions with local variables (just wrap the macro body in
1452 block braces).
1455 .NH 1
1456 Style Variables
1458 There are a number of global style variables in \fBpic\fR that can be used to
1459 change its overall behavior.  We've mentioned several of them in
1460 previous sections.  They're all described here.  For each variable,
1461 the default is given.
1462 .TS H
1463 center, tab(@), linesize(2);
1464 lb | lb | lb
1465 l | n | l.
1466 .sp 2p
1467 Style Variable@Default@What It Does
1468 .sp 2p
1470 .sp 2p
1472 boxht@0.5@Default height of a box
1473 boxwid@0.75@Default width of a box
1474 lineht@0.5@Default length of vertical line
1475 linewid@0.75@Default length of horizontal line
1476 linethick@-1@Default line thickness
1477 arcrad @0.25@Default radius of an arc
1478 circlerad@0.25@Default radius of a circle
1479 ellipseht@0.5@Default height of an ellipse
1480 ellipsewid@0.75@Default width of an ellipse
1481 moveht@0.5@Default length of vertical move
1482 movewid@0.75@Default length of horizontal move
1483 textht@0@Default height of box enclosing a text object
1484 textwid@0@Default width of box enclosing a text object
1485 arrowht@0.1@Length of arrowhead along shaft
1486 arrowwid@0.05@Width of rear of arrowhead
1487 arrowhead@1@Enable/disable arrowhead filling
1488 dashwid@0.05@Interval for dashed lines
1489 maxpswid@11@Maximum width of picture
1490 maxpsht@8.5@Maximum height of picture
1491 scale@1@Unit scale factor
1492 fillval@0.5@Default fill value
1493 .sp 5p
1496 Any of these variables can be set with a simple assignment statement.
1497 For example:
1500 [boxht=1; boxwid=0.3; movewid=0.2; box; move; box; move; box; move; box;]
1502 .CE "1: \fBboxht=1; boxwid=0.3; movewid=0.2; box; move; box; move; box; move; box;\fP"
1504 In GNU \fBpic\fR, setting the \fBscale\fR variable re-scales all
1505 size-related state variables so that their values remain equivalent in
1506 the new units.
1508 The command \fBreset\fP resets all style variables to their defaults.
1509 You can give it a list of variable names as arguments (optionally
1510 separated by commas), in which case it resets only those.
1512 State variables retain their values across pictures until reset.
1515 .NH 1
1516 Expressions, Variables, and Assignment
1518 A number is a valid expression, of course (all numbers are stored
1519 internally as floating-point).  Decimal-point notation is acceptable;
1520 in GNU \fBgpic\fR, scientific notation in C's `e' format (like
1521 \f(CW5e-2\fP) is accepted.
1523 Anywhere a number is expected, the language also accepts a
1524 variable.  Variables may be the built-in style variable described in
1525 the last section, or new variables created by assignment.
1527 DWB \fBpic\fP supports only the ordinary assignment via \fB=\fP, which
1528 defines the variable (on the left side of the equal sign) in the current
1529 block if it is not already defined there, and then changes the value (on
1530 the right side) in the current block.  The variable is not visible outside
1531 of the block.  This is similar to the C\~programming language where a
1532 variable within a block shadows a variable with the same name outside of
1533 the block.
1535 GNU \fBgpic\fP supports an alternate form of assignment using \fB:=\fP.
1536 The variable must already be defined, and the value is assigned to
1537 that variable without creating a variable local to the current block.
1538 For example, this
1545   x:=3
1546   y=3
1548 print x " " y
1552 prints \fB3 5\fP.
1554 You can use the height, width, radius, and x and y coordinates of any
1555 object or corner in expressions.  If \fBA\fP is an object label or name,
1556 all the following are valid:
1560 A.x                  # x coordinate of the center of A
1561 A.ne.y               # y coordinate of the northeast corner of A
1562 A.wid                # the width of A
1563 A.ht                 # and its height
1564 2nd last circle.rad  # the radius of the 2nd last circle
1569 Note the second expression, showing how to extract a corner coordinate.
1571 Basic arithmetic resembling those of C operators are available; \fB+\fP,
1572 \fB*\fP, \fB-\fP, \fB/\fP, and \fB%\fP.  So is \fB^\fP for exponentiation.
1573 Grouping is permitted in the usual way using parentheses.  GNU \fBgpic\fP
1574 allows logical operators to appear in expressions; \fB!\&\fP (logical
1575 negation, not factorial), \fB&&\fP, \fB|\||\fP, \fB==\fP, \fB!=\fP,
1576 \fB>=\fP, \fB<=\fP, \fB<\fP, \fB>\fP.
1578 Various built-in functions are supported: \fBsin(\fIx\fB)\fR,
1579 \fBcos(\fIx\fB)\fR, \fBlog(\fIx\fB)\fR, \fBexp(\fIx\fB)\fR,
1580 \fBsqrt(\fIx\fB)\fR, \fBmax(\fIx\fB,\fIy\fB)\fR,
1581 \fBatan2(\fIx\fB,\fIy\fB)\fR, \fBmin(\fIx\fB,\fIy\fB)\fR,
1582 \fBint(\fIx\fB)\fR, \fBrand()\fP, and \fBsrand()\fP.
1583 Both \fBexp\fP and \fBlog\fP are
1584 base\~10; \fBint\fP does integer truncation; \fBrand()\fP returns a
1585 random number in [0-1), and \fBsrand()\fP sets the seed for 
1586 a new sequence of pseudo-random numbers to be returned by \fBrand()\fP
1587 (\fBsrand()\fP is a GNU extension).
1589 GNU \fBgpic\fP also documents a one-argument form or rand,
1590 \fBrand(\fIx\fB)\fR, which returns a random number between 1 and
1591 \fIx\fP, but this is deprecated and may be removed in a future
1592 version.
1594 The function \fBsprintf()\fP behaves like a C \fIsprintf\/\fP(3)
1595 function that only takes %, %e, %f, and %g format strings.
1598 .NH 1
1599 Macros
1601 You can define macros in \fBpic\fP, with up to 32 arguments (up to 16
1602 on EBCDIC platforms).  This is useful for diagrams with
1603 repetitive parts.  In conjunction with the scope rules for block
1604 composites, it effectively gives you the ability to write functions.
1606 The syntax is
1609 \fBdefine\fP \fIname\fP \fB{\fP \fIreplacement text \fB}\fP
1613 This defines \fIname\fR as a macro to be replaced by the replacement
1614 text (not including the braces).  The macro may be called as 
1617 \fIname\fB(\fIarg1, arg2, \|.\|.\|.\& argn\fB)\fR
1621 The arguments (if any) are substituted for tokens \fB$1\fP, \fB$2\fP
1622 \&.\|.\|.\& \fB$n\fP
1623 appearing in the replacement text.
1625 As an example of macro use, consider this:
1629 .ps -1
1630 .vs -1
1631 \&.PS
1632 # Plot a single jumper in a box, $1 is the on-off state.
1633 define jumper { [
1634     shrinkfactor = 0.8;
1635     Outer: box invis wid 0.45 ht 1;
1637     # Count on end ] to reset these
1638     boxwid = Outer.wid * shrinkfactor / 2;
1639     boxht  = Outer.ht  * shrinkfactor / 2;
1641     box fill (!$1) with .s at center of Outer;
1642     box fill ($1)  with .n at center of Outer;
1643 ] }
1645 # Plot a block of six jumpers.
1646 define jumperblock {
1647     jumper($1);
1648     jumper($2);
1649     jumper($3);
1650     jumper($4);
1651     jumper($5);
1652     jumper($6);
1654     jwidth  = last [].Outer.wid;
1655     jheight = last [].Outer.ht;
1657     box with .nw at 6th last [].nw wid 6*jwidth ht jheight;
1659     # Use {} to avoid changing position from last box draw.
1660     # This is necessary so move in any direction works as expected
1661     {"Jumpers in state $1$2$3$4$5$6" at last box .s + (0,-0.2);}
1664 # Sample macro invocations.
1665 jumperblock(1,1,0,0,1,0);
1666 move;
1667 jumperblock(1,0,1,0,1,1);
1668 \&.PE
1675 It yields the following:
1678 # Plot a single jumper in a box, $1 is the on-off state.
1679 define jumper { [
1680     shrinkfactor = 0.8;
1681     Outer: box invis wid 0.45 ht 1;
1683     # Count on end ] to reset these
1684     boxwid = Outer.wid * shrinkfactor / 2;
1685     boxht  = Outer.ht  * shrinkfactor / 2;
1687     box fill (!$1) with .s at center of Outer;
1688     box fill ($1)  with .n at center of Outer;
1689 ] }
1691 # Plot a block of six jumpers
1692 define jumperblock {
1693     jumper($1);
1694     jumper($2);
1695     jumper($3);
1696     jumper($4);
1697     jumper($5);
1698     jumper($6);
1700     jwidth  = last [].Outer.wid;
1701     jheight = last [].Outer.ht;
1703     box with .nw at 6th last [].nw wid 6*jwidth ht jheight;
1705     # Use {} to avoid changing position from last box draw.
1706     # This is necessary so move in any direction works as expected
1707     {"Jumpers in state $1$2$3$4$5$6" at last box .s + (0,-0.2);}
1710 # Sample macro invocations
1711 jumperblock(1,1,0,0,1,0);
1712 move 0.25;
1713 jumperblock(1,0,1,0,1,1);
1715 .CE "1: Sample use of a macro"
1717 This macro example illustrates how you can combine [], brace grouping,
1718 and variable assignment to write true functions.
1720 One detail the example above does not illustrate is the fact that
1721 macro argument parsing is not token-oriented.  If you call
1722 \fBjumper(\ 1\ )\fP, the value of $1 is \fB"\ 1\ "\fP.  You could
1723 even call \fBjumper(big\ string)\fP to give $1 the value
1724 \fB"big\ string"\fP.
1726 If you want to pass in a coordinate pair, you can avoid getting
1727 tripped up by the comma by wrapping the pair in parentheses.
1729 Macros persist through pictures.  To undefine a macro, say \fBundef\fP
1730 \fIname\fR; for example,
1732 \f(CWundef jumper\fP
1733 \f(CWundef jumperblock\fP
1736 would undefine the two macros in the jumper block example.
1739 .NH 1
1740 Import/Export Commands
1742 Commands that import or export data between \fBpic\fR and its
1743 environment are described here.
1745 .NH 2
1746 File and Table Insertion
1748 The statement
1750 \f(CWcopy\fP \fIfilename\fR
1753 inserts the contents of \fIfilename\fR in the \fBpic\fP input stream.
1754 Any \fB.PS\fP/\fB.PE\fP pair in the file is ignored.  You
1755 can use this to include pre-generated images.
1757 A variant of this statement replicates the \fBcopy thru\fP feature of
1758 \fIgrap\fP(1).  The call
1760 \f(CWcopy\fP \fIfilename\fR \f(CWthru\fP \fImacro\fP
1763 calls \fImacro\fP (which may be either a name or replacement text)
1764 on the arguments obtained by breaking each line of the file into
1765 blank-separated fields.  The macro may have up to 9\~arguments.  The
1766 replacement text may be delimited by braces or by a pair of instances
1767 of any character not appearing in the rest of the text.
1769 If you write
1771 \f(CWcopy\fP \f(CWthru\fP \fImacro\fP
1774 omitting the filename, lines to be parsed are taken from the input
1775 source up to the next \fB.PE\fP.
1777 In either of the last two \fBcopy\fP commands, GNU \fBgpic\fP permits a
1778 trailing `\fBuntil\fP \fIword\/\fP' clause to be added which terminates
1779 the copy when the first word matches the argument (the default
1780 behavior is therefore equivalent to \fBuntil .PE\fP).
1782 Accordingly, the command
1788 \&.PS
1789 copy thru % circle at ($1,$2) % until "END"
1790 1 2
1791 3 4
1792 5 6
1795 \&.PE
1801 is equivalent to
1807 \&.PS
1808 circle at (1,2)
1809 circle at (3,4)
1810 circle at (5,6)
1812 \&.PE
1818 .NH 2
1819 Debug Messages
1821 The command \fBprint\fR accepts any number of arguments, concatenates
1822 their output forms, and writes the result to standard error.  Each
1823 argument must be an expression, a position, or a text string.
1825 .NH 2
1826 Escape to Post-Processor
1828 If you write
1830 \fBcommand\fR \fIarg\fR\|.\|.\|.
1833 \fBpic\fP concatenates the arguments and pass them through as a line
1834 to troff or \*[tx].  Each
1835 .I arg
1836 must be an expression, a position, or text.
1837 This has a similar effect to a line beginning with
1838 .B .
1840 \fB\e\fR\|,
1841 but allows the values of variables to be passed through.
1843 For example,
1848 \&.PS
1849 x = 14
1850 command ".ds string x is " x "."
1851 \&.PE
1852 \e*[string]
1857 prints
1860 x is 14.
1864 .NH 2
1865 Executing Shell Commands
1867 The command 
1869 \f(CWsh\fP \f(CW{\fP \fIanything.\|.\|.\fP \f(CW}\fP
1872 macro-expands the text in braces, then executes it as a shell command.
1873 This could be used to generate images or data tables for later
1874 inclusion.  The delimiters shown as {} here may also be two copies of
1875 any one character not present in the shell command text.  In either
1876 case, the body may contain balanced {} pairs.  Strings in the body
1877 may contain balanced or unbalanced braces in any case.
1880 .NH 1
1881 Control-flow constructs
1883 The \fBpic\fP language provides conditionals and looping.  For
1884 example,
1888 pi = atan2(0,-1);
1889 for i = 0 to 2 * pi by 0.1 do {
1890     "-" at (i/2, 0);
1891     "." at (i/2, sin(i)/2);
1892     ":" at (i/2, cos(i)/2);
1898 which yields this:
1901 pi = atan2(0,-1);
1902 for i = 0 to 2 * pi by 0.1 do {
1903     "-" at (i/2, 0);
1904     "." at (i/2, sin(i)/2);
1905     ":" at (i/2, cos(i)/2);
1908 .CE "1: Plotting with a \fBfor\fP loop"
1910 The syntax of the \fBfor\fP statement is:
1912 \fBfor\fR \fIvariable\fR \fB=\fR \fIexpr1\/\fR \fBto\fR \fIexpr2\/\fR \
1913 [\fBby\fR [\fB*\fR]\fIexpr3\/\fR] \fBdo\fR \fIX\fR \fIbody\fR \fIX\fR
1915 The semantics are as follows:  Set
1916 .I variable
1917 to \fIexpr1\fR.
1918 While the value of
1919 .I variable
1920 is less than or equal to
1921 \fIexpr2\fR,
1923 .I body
1924 and increment
1925 .I variable
1927 \fIexpr3\fR;
1929 .B by
1930 is not given, increment
1931 .I variable
1932 by\~1.
1934 .I expr3
1935 is prefixed by\~\c
1936 .B *
1937 then
1938 .I variable
1939 is multiplied instead by
1940 \fIexpr3\fR.
1941 The value of
1942 .I expr3
1943 can be negative for the additive case;
1944 .I variable
1945 is then tested whether it is greater than or equal to
1946 \fIexpr2\fR.
1947 For the multiplicative case,
1948 .I expr3
1949 must be greater than zero.
1950 If the constraints aren't met, the loop isn't executed.
1951 .I X
1952 can be any character not occurring in
1953 \fIbody\fR; or the two \fIX\/\fPs may be paired braces (as in the
1954 \fBsh\fR command).
1956 The syntax of the \fBif\fP statement is as follows:
1958 \fBif\fR \fIexpr\fR \fBthen\fR \fIX\fR \fIif-true\fR \fIX\fR \
1959 [\fBelse\fR \fIY\fR \fIif-false\fR \fIY\/\fR]
1961 Its semantics are as follows: Evaluate
1962 \fIexpr\fR;
1963 if it is non-zero then do
1964 \fIif-true\fR,
1965 otherwise do
1966 \fIif-false\fR.
1967 .I X
1968 can be any character not occurring in
1969 \fIif-true\fR.
1970 .I Y
1971 can be any character not occurring in
1972 \fIif-false\fR.
1974 Eithe or both of the
1975 .I X
1977 .I Y
1978 pairs may instead be balanced pairs of
1979 braces ({ and\~}) as in the \fBsh\fR command.  In either case, the
1980 \fIif-true\fR may contain balanced pairs of braces.  None of these
1981 delimiters are seen inside strings.
1983 All the usual relational operators my be used in conditional expressions;
1984 \fB!\&\fP (logical negation, not factorial), \fB&&\fP, \fB|\||\fP, \fB==\fP,
1985 \fB!=\fP, \fB>=\fP, \fB<=\fP, \fB<\fP, \fB>\fP.
1987 String comparison is also supported using \fB==\fP and \fB!=\fP.  String
1988 comparisons may need to be parenthesized to avoid syntactic
1989 ambiguities.
1992 .NH 1
1993 Interface To [gt]roff
1995 The output of \fBpic\fP is \fB[gt]roff\fP drawing commands.  The GNU
1996 \fIgpic\/\fP(1) command warns that it relies on drawing extensions
1997 present in \fIgroff\/\fP(1) that are not present in \fItroff\/\fP(1).
1999 .NH 2
2000 Scaling Arguments
2002 The DWB \fIpic\/\fP(1) program accepts one or two arguments to
2003 \&\fB.PS\fP, which is interpreted as a width and height in inches to
2004 which the results of \fIpic\/\fP(1) should be scaled (width and height
2005 scale independently).  If there is only one argument, it is
2006 interpreted as a width to scale the picture to, and height is
2007 scaled by the same proportion.
2009 GNU \fBgpic\fP is less general; it accepts a single width to scale
2010 to, or a zero width and a maximum height to scale to.  With
2011 two non-zero arguments, it scales to the maximum height.
2013 .NH 2
2014 How Scaling is Handled
2016 When \fBpic\fP processes a picture description on input, it passes
2017 \fB.PS\fP and \fB.PE\fP through to the postprocessor.  The \fB.PS\fP
2018 gets decorated with two numeric arguments which are the X and
2019 Y\~dimensions of the picture in inches.  The post-processor can use
2020 these to reserve space for the picture and center it.
2022 The GNU incarnation of the \fBms\fP macro package, for example, includes
2023 the following definitions:
2026 .ps -1
2027 .vs -1
2029 \&.de PS
2030 \&.br
2031 \&.sp \e\en[DD]u
2032 \&.ie \e\en[.$]<2 .@error bad arguments to PS (not preprocessed with pic?)
2033 \&.el \e{\e
2034 \&.     ds@need (u;\e\e$1)+1v
2035 \&.     in +(u;\e\en[.l]-\e\en[.i]-\e\e$2/2>?0)
2036 \&.\e}
2037 \&..
2038 \&.de PE
2039 \&.par@reset
2040 \&.sp \e\en[DD]u+.5m
2041 \&..
2048 Equivalent definition is supplied by GNU \fIpic\/\fP(1) if you use
2049 the \-mpic option; this should make it usable with macro pages other
2050 than \fIms\/\fR(1).
2052 If \fB.PF\fP is used instead of \fB.PE\fP, the \fBtroff\fP position is
2053 restored to what it was at the picture start (Kernighan notes that
2054 the\~F stands for \[lq]flyback\[rq]).
2056 The invocation
2058 \&\fB.PS <\,\fP\fIfile\fP
2061 causes the contents of \fIfile\fP to replace the \fB.PS\fP line.  This
2062 feature is deprecated; use `\fBcopy\fP \fIfile\fR' instead).
2064 .NH 2
2065 PIC and [gt]roff commands
2067 By default, input lines that begin with a period are passed to the
2068 postprocessor, embedded at the corresponding point in the output.
2069 Messing with horizontal or vertical spacing is an obvious recipe for
2070 bugs, but point size and font changes are usually safe.
2072 Point sizes and font changes are also safe within text strings, as
2073 long as they are undone before the end of string.
2075 The state of \fB[gt]roff\fP's fill mode is preserved across pictures.
2077 .NH 2
2078 PIC and EQN
2080 The Kernighan paper notes that there is a subtle problem with
2081 complicated equations inside \fBpic\fR pictures; they come out wrong if
2082 \fIeqn\/\fP(1) has to leave extra vertical space for the equation.
2083 If your equation involves more than subscripts and superscripts, you
2084 must add to the beginning of each equation the extra information
2085 \fBspace\~0\fP.  He gives the following example:
2089 arrow
2090 box "$space 0 {H( omega )} over {1 - H( omega )}$"
2091 arrow
2096 delim @@
2100 arrow
2101 box "@space 0 {H( omega )} over {1 - H( omega )}@"
2102 arrow
2104 .CE "1: Equations within pictures"
2106 .NH 2
2107 Absolute Positioning of Pictures
2109 A \fBpic\fP picture is positioned vertically by troff at the current
2110 position.  The topmost position possible on a page is not the paper edge
2111 but a position which is one baseline lower so that the first row of glyphs
2112 is visible.  To make a picture really start at the paper edge you have
2113 to make the baseline-to-baseline distance zero, this is, you must set the
2114 vertical spacing to\~0 (using \fB.vs\fP) before starting the picture.
2117 .NH 1
2118 Interface to TeX
2121 \*[tx] mode is enabled by the
2122 .B \-t
2123 option.
2124 In \*[tx] mode, pic defines a vbox called
2125 .B \egraph
2126 for each picture; the name can be changed with the pseudo-variable
2127 .B figname
2128 (which is actually a specially parsed command).
2129 You must yourself print that vbox using, for example, the command
2133 \ecenterline{\ebox\egraph}
2136 Actually, since the vbox has a height of zero (it is defined with \evtop)
2137 this produces slightly more vertical space above the picture than
2138 below it;
2142 \ecenterline{\eraise 1em\ebox\egraph}
2145 would avoid this.
2147 To make the vbox having a positive height and a depth of zero (as used
2148 e.g.\& by \*(lx's \f(CW\%graphics.sty\fP), define the following macro in
2149 your document:
2153 \edef\egpicbox#1{%
2154   \evbox{\eunvbox\ecsname #1\eendcsname\ekern 0pt}}
2159 Now you can simply say
2160 .B \egpicbox{graph}
2161 instead of \ebox\egraph.
2163 You must use a \*[tx] driver that supports the
2164 .B tpic
2165 specials, version\~2.
2167 Lines beginning with
2168 .B \e
2169 are passed through transparently; a
2170 .B %
2171 is added to the end of the line to avoid unwanted spaces.
2172 You can safely use this feature to change fonts or to
2173 change the value of \fB\ebaselineskip\fP.
2174 Anything else may well produce undesirable results; use at your own risk.
2175 Lines beginning with a period are not given any special treatment.
2177 The \*[tx] mode of \fIpic\/\fP(1) does \fInot\fP translate \fBtroff\fP
2178 font and size changes included in text strings!
2180 Here an example how to use \fBfigname\fP.
2184 \&.PS
2185 figname = foo;
2186 \&...
2187 \&.PE
2189 \&.PS
2190 figname = bar;
2191 \&...
2192 \&.PE
2194 \ecenterline{\ebox\efoo \ehss \ebox\ebar}
2199 Use this feature sparsingly and only if really needed:
2200 A different name means a new box register in \*[tx], and the maximum number
2201 of box registers is only 256.
2202 Also be careful not to use a predefined \*[tx] or \*[lx] macro name as
2203 an argument to \fBfigname\fP since this inevitably causes an error.
2206 .NH 1
2207 Obsolete Commands
2209 GNU \fIgpic\/\fP(1)  has a command
2211 \fBplot\fR \fIexpr\fR [\fB"\fItext\fB"\fR]
2213 This is a text object which is constructed by using
2214 .I text
2215 as a format string for sprintf
2216 with an argument of
2217 \fIexpr\fP.
2219 .I text
2220 is omitted a format string of \fB"%g"\fP is used.
2221 Attributes can be specified in the same way as for a normal text
2222 object.
2223 Be very careful that you specify an appropriate format string;
2224 \fBpic\fP does only very limited checking of the string.
2225 This is deprecated in favour of
2226 \fBsprintf\fP.
2229 .NH 1
2230 Some Larger Examples
2232 Here are a few larger examples, with complete source code.
2233 One of our earlier examples is generated in an instructive way using a
2234 for loop:
2237 .ps -1
2238 .vs -1
2240 \&.PS
2241 # Draw a demonstration up left arrow with grid box overlay
2242 define gridarrow
2244     move right 0.1
2245     [
2246         {arrow up left $1;}
2247         box wid 0.5 ht 0.5 dotted with .nw at last arrow .end;
2248         for i = 2 to ($1 / 0.5) do
2249         {
2250             box wid 0.5 ht 0.5 dotted with .sw at last box .se;
2251         }
2252         move down from last arrow .center;
2253         [
2254             if ( $1 == boxht ) \e
2255             then { "\efBline up left\efP" } \e
2256             else { sprintf("\efBarrow up left %g\efP", $1) };
2257         ]
2258     ] 
2259     move right 0.1 from last [] .e;
2261 gridarrow(0.5);
2262 gridarrow(1);
2263 gridarrow(1.5);
2264 gridarrow(2);
2265 undef gridarrow
2266 \&.PE
2274 # Draw a demonstration up left arrow with grid box overlay
2275 define gridarrow
2277         move right 0.1
2278         [
2279                 {arrow up left $1;}
2280                 box wid 0.5 ht 0.5 dotted with .nw at last arrow .end;
2281                 for i = 2 to ($1 / 0.5) do
2282                 {
2283                         box wid 0.5 ht 0.5 dotted with .sw at last box .se;
2284                 }
2285                 move down from last arrow .center;
2286                 [
2287                         if ( $1 == boxht ) \
2288                         then { "\fBline up left\fP" } \
2289                         else { sprintf("\fBarrow up left %g\fP", $1) };
2290                 ]
2291         ] 
2292         move right 0.1 from last [] .e;
2294 gridarrow(0.5);
2295 gridarrow(1);
2296 gridarrow(1.5);
2297 gridarrow(2);
2298 undef gridarrow
2300 .CE "1: Diagonal arrows (dotted boxes show the implied 0.5-inch grid)"
2302 Here's an example concocted to demonstrate layout of a large,
2303 multiple-part pattern:
2306 .ps -1
2307 .vs -1
2309 \&.PS
2310 define filter {box ht 0.25 rad 0.125}
2311 lineht = 0.25;
2312 Top: [
2313     right;
2314     box "\efBms\efR" "sources";
2315     move;
2316     box "\efBHTML\efR" "sources";
2317     move;
2318     box "\efBlinuxdoc-sgml\efP" "sources" wid 1.5;
2319     move;
2320     box "\efBTexinfo\efP" "sources";
2322     line down from 1st box .s lineht;
2323     A: line down;
2324     line down from 2nd box .s; filter "\efBhtml2ms\efP";
2325     B: line down;
2326     line down from 3rd box .s; filter "\efBformat\efP";
2327     C: line down;
2328     line down from 4th box .s; filter "\efBtexi2roff\efP";
2329     D: line down;
2331 move down 1 from last [] .s;
2332 Anchor: box wid 1 ht 0.75 "\efBms\efR" "intermediate" "form";
2333 arrow from Top.A.end to Anchor.nw;
2334 arrow from Top.B.end to 1/3 of the way between Anchor.nw and Anchor.ne;
2335 arrow from Top.C.end to 2/3 of the way between Anchor.nw and Anchor.ne;
2336 arrow from Top.D.end to Anchor.ne
2338     # PostScript column
2339     move to Anchor .sw;
2340     line down left then down ->;
2341     filter "\efBpic\efP";
2342     arrow;
2343     filter "\efBeqn\efP";
2344     arrow;
2345     filter "\efBtbl\efP";
2346     arrow;
2347     filter "\efBgroff\efP";
2348     arrow;
2349     box "PostScript";
2351     # HTML column
2352     move to Anchor .se;
2353     line down right then down ->;
2354     A: filter dotted "\efBpic2img\efP";
2355     arrow;
2356     B: filter dotted "\efBeqn2html\efP";
2357     arrow;
2358     C: filter dotted "\efBtbl2html\efP";
2359     arrow;
2360     filter "\efBms2html\efP";
2361     arrow;
2362     box "HTML";
2364     # Nonexistence caption
2365     box dashed wid 1 at B + (2,0) "These tools" "don't yet exist";
2366     line chop 0 chop 0.1 dashed from last box .nw to A.e ->;
2367     line chop 0 chop 0.1 dashed from last box .w  to B.e ->;
2368     line chop 0 chop 0.1 dashed from last box .sw to C.e ->;
2370 \&.PE
2378 define filter {box ht 0.25 rad 0.125}
2379 lineht = 0.25;
2380 Top: [
2381     right;
2382     box "\fBms\fR" "sources";
2383     move;
2384     box "\fBHTML\fR" "sources";
2385     move;
2386     box "\fBlinuxdoc-sgml\fP" "sources" wid 1.5;
2387     move;
2388     box "\fBTexinfo\fP" "sources";
2390     line down from 1st box .s lineht;
2391     A: line down;
2392     line down from 2nd box .s; filter "\fBhtml2ms\fP";
2393     B: line down;
2394     line down from 3rd box .s; filter "\fBformat\fP";
2395     C: line down;
2396     line down from 4th box .s; filter "\fBtexi2roff\fP";
2397     D: line down;
2399 move down 1 from last [] .s;
2400 Anchor: box wid 1 ht 0.75 "\fBms\fR" "intermediate" "form";
2401 arrow from Top.A.end to Anchor.nw;
2402 arrow from Top.B.end to 1/3 of the way between Anchor.nw and Anchor.ne;
2403 arrow from Top.C.end to 2/3 of the way between Anchor.nw and Anchor.ne;
2404 arrow from Top.D.end to Anchor.ne
2406     # PostScript column
2407     move to Anchor .sw;
2408     line down left then down ->;
2409     filter "\fBpic\fP";
2410     arrow;
2411     filter "\fBeqn\fP";
2412     arrow;
2413     filter "\fBtbl\fP";
2414     arrow;
2415     filter "\fBgroff\fP";
2416     arrow;
2417     box "PostScript";
2419     # HTML column
2420     move to Anchor .se;
2421     line down right then down ->;
2422     A: filter dotted "\fBpic2img\fP";
2423     arrow;
2424     B: filter dotted "\fBeqn2html\fP";
2425     arrow;
2426     C: filter dotted "\fBtbl2html\fP";
2427     arrow;
2428     filter "\fBms2html\fP";
2429     arrow;
2430     box "HTML";
2432     # Nonexistence caption
2433     box dashed wid 1 at B + (2,0) "These tools" "don't yet exist";
2434     line chop 0 chop 0.1 dashed from last box .nw to A.e ->;
2435     line chop 0 chop 0.1 dashed from last box .w  to B.e ->;
2436     line chop 0 chop 0.1 dashed from last box .sw to C.e ->;
2439 .CE "2: Hypothetical production flow for dual-mode publishing"
2443 # a three-dimensional block
2445 # tblock(<width>, <height>, <text>)
2447 define tblock { [
2448   box ht $2 wid $1 \
2449       color "gold" outlined "black" \
2450       xslanted 0 yslanted 0 \
2451       $3;
2452   box ht .1 wid $1 \
2453       color "yellow" outlined "black" \
2454       xslanted .1 yslanted 0 \
2455       with .sw at last box .nw;
2456   box ht $2 wid .1 \
2457       color "goldenrod" outlined "black" \
2458       xslanted 0 yslanted .1 \
2459       with .nw at 2nd last box .ne;
2460 ] }
2462 tblock(1, .5, "Master" "1");
2463 move -.1
2464 tblock(.5, 1, "Slave");
2466 .CE "3: Three-dimensional Boxes"
2468 Here the source code for figure \n[H1]-3:
2472 \&.PS
2473 # a three-dimensional block
2475 # tblock(<width>, <height>, <text>)
2477 define tblock { [
2478   box ht $2 wid $1 \e
2479       color "gold" outlined "black" \e
2480       xslanted 0 yslanted 0 \e
2481       $3;
2482   box ht .1 wid $1 \e
2483       color "yellow" outlined "black" \e
2484       xslanted .1 yslanted 0 \e
2485       with .sw at last box .nw;
2486   box ht $2 wid .1 \e
2487       color "goldenrod" outlined "black" \e
2488       xslanted 0 yslanted .1 \e
2489       with .nw at 2nd last box .ne;
2490 ] }
2492 tblock(1, .5, "Master" "1");
2493 move -.1
2494 tblock(.5, 1, "Slave");
2495 \&.PE
2497 .ft R
2502 .NH 1
2503 PIC Reference
2505 This is an annotated grammar of \fBpic\fP.
2507 .NH 2
2508 Lexical Items
2510 In general, \fBpic\fP is a free-format, token-oriented language that
2511 ignores whitespace outside strings.  But certain lines and contructs
2512 are specially interpreted at the lexical level:
2514 A comment begins with \fB#\fP and continues to \fB\en\fP (comments may
2515 also follow text in a line).  A line beginning with a period or
2516 backslash may be interpreted as text to be passed through to the
2517 post-processor, depending on command-line options.  An end-of-line
2518 backslash is interpreted as a request to continue the line; the
2519 backslash and following newline are ignored.
2522 Here are the grammar terminals:
2523 .IP \s[-1]INT\s[0]
2524 A positive integer.
2525 .IP \s[-1]NUMBER\s[0]
2526 A floating point numeric constant.  May contain a decimal point or be
2527 expressed in scientific notation in the style of \fIprintf\/\fP(3)'s %e
2528 escape.  A trailing `i' or `I' (indicating the unit `inch') is ignored.
2529 .IP \s[-1]TEXT\s[0]
2530 A string enclosed in double quotes.  A double quote within \s[-1]TEXT\s[0]
2531 must be preceded by a backslash.  Instead of \s[-1]TEXT\s[0] you can use
2534 sprintf ( TEXT [, <expr> ...] )
2538 except after the `until' and `last' keywords, and after all ordinal
2539 keywords (`th' and friends).
2540 .IP \s[-1]VARIABLE\s[0]
2541 A string starting with a character from the set [a-z], optionally
2542 followed by one or more characters of the set [a-zA-Z0-9_].
2543 (Values of variables are preserved across pictures.)
2544 .IP \s[-1]LABEL\s[0]
2545 A string starting with a character from the set [A-Z], optionally
2546 followed by one or more characters of the set [a-zA-Z0-9_].
2547 .IP \s[-1]COMMAND-LINE\s[0]
2548 A line starting with a command character (`.' in groff mode, `\e' in
2549 \*[tx] mode).
2550 .IP \s[-1]BALANCED-TEXT\s[0]
2551 A string either enclosed by `{' and `}' or with \fIX\fP and \fIX\fP,
2552 where \fIX\fP doesn't occur in the string.
2553 .IP \s[-1]BALANCED-BODY\s[0]
2554 Delimiters as in \s[-1]BALANCED-TEXT\s[0]; the body is interpreted as
2555 `\fB\[la]command\[ra].\|.\|.\fP'.
2556 .IP \s[-1]FILENAME\s[0]
2557 The name of a file.  This has the same semantics as \s[-1]TEXT\s[0].
2558 .IP \s[-1]MACRONAME\s[0]
2559 Either \s[-1]VARIABLE\s[0] or \s[-1]LABEL\s[0].
2562 .NH 2
2563 Semi-Formal Grammar
2565 Tokens not enclosed in \[la]\|\[ra] are literals, except:
2566 .IP 1.
2567 \fB\en\fP is a newline.
2568 .IP 2.
2569 Three dots is a suffix meaning `replace with 0 or more repetitions
2570 of the preceding element(s).
2571 .IP 3.
2572 An enclosure in square brackets has its usual meaning of `this clause is
2573 optional'.
2574 .IP 4.
2575 Square-bracket-enclosed portions within tokens are optional.  Thus,
2576 `h\^[eigh]\^t' matches either `height' or `ht'.
2578 If one of these special tokens has to be referred to literally, it is
2579 surrounded with single quotes.
2581 The top-level \fBpic\fP object is a picture.
2584 <picture> ::=
2585   .PS [NUMBER [NUMBER]]\en
2586   <statement> ...
2587   .PE \en
2591 The arguments, if present, represent the width and height of the picture,
2592 causing \fBpic\fR to attempt to scale it to the given dimensions in
2593 inches.  In no case, however, the X and Y\~dimensions of the
2594 picture exceed the values of the style variables \fBmaxpswid\fP and
2595 \fBmaxpsheight\fP (which default to the normal 8.5\^i by 11\^i page size).
2597 If the ending `.PE' is replaced by `.PF', the page vertical position is
2598 restored to its value at the time `.PS' was encountered.  Another
2599 alternate form of invocation is `.PS\ <\s[-1]FILENAME\s[0]', which
2600 replaces the `.PS' line with a file to be interpreted by \fBpic\fR (but
2601 this feature is deprecated).
2603 The `.PS', `.PE', and `.PF' macros to perform centering and scaling are
2604 normally supplied by the post-processor.
2606 In the following, either `|' or a new line starts an alternative.
2609 <statement> ::=
2610   <command> ;
2611   <command> \en
2616 <command> ::=
2617   <primitive> [<attribute>]
2618   LABEL : [;] <command>
2619   LABEL : [;] <command> [<position>]
2620   { <command> ... }
2621   VARIABLE [:] = <any-expr>
2622   figname = MACRONAME
2623   up | down | left | right
2624   COMMAND-LINE
2625   command <print-arg> ...
2626   print <print-arg> ...
2627   sh BALANCED-TEXT
2628   copy FILENAME
2629   copy [FILENAME] thru MACRONAME [until TEXT]
2630   copy [FILENAME] thru BALANCED-BODY [until TEXT]
2631   for VARIABLE = <expr> to <expr> [by [*] <expr>] do BALANCED-BODY
2632   if <any-expr> then BALANCED-BODY [else BALANCED-BODY]
2633   reset [VARIABLE [[,] VARIABLE ...]]
2638 <print-arg> ::=
2639   TEXT
2640   <expr>
2641   <position>
2645 The current position and direction are saved on entry to a `{\ .\|.\|.\ }'
2646 construction and restored on exit from it.
2648 Note that in `if' constructions, newlines can only occur in
2649 \s[-1]BALANCED-BODY\s[0].  This means that
2653 { ... }
2654 else
2655 { ... }
2659 fails.  You have to use the braces on the same line as the keywords:
2662 if {
2663 \&...
2664 } else {
2665 \&...
2670 This restriction doesn't hold for the body after the `do' in a `for'
2671 construction.
2673 At the beginning of each picture, `figname' is reset to the vbox name
2674 `graph'; this command has only a meaning in \*[tx] mode.  While the grammar
2675 rules allow digits and the underscore in the value of `figname', \*[tx]
2676 normally accepts uppercase and lowercase letters only as box names
2677 (you have to use `\ecsname' if you really need to circumvent this
2678 limitation).
2681 <any-expr> ::=
2682   <expr>
2683   <text-expr>
2684   <any-expr> <logical-op> <any-expr>
2685   ! <any-expr>
2690 <logical-op> ::=
2691   == | != | && | '||'
2696 <text-expr> ::=
2697   TEXT == TEXT
2698   TEXT != TEXT
2702 Logical operators are handled specially by \fBpic\fP since they can
2703 deal with text strings also.  \fBpic\fP uses \%\fIstrcmp\/\fP(3) to test
2704 for equality of strings; an empty string is considered as `false' for
2705 `&&' and `|\||'.
2708 <primitive> ::=
2709   box                   \fR# closed object \[em] rectangle\fP
2710   circle                \fR# closed object \[em] circle\fP
2711   ellipse               \fR# closed object \[em] ellipse\fP
2712   arc                   \fR# open object \[em] quarter-circle\fP
2713   line                  \fR# open object \[em] line\fP
2714   arrow                 \fR# open object \[em] line with arrowhead\fP
2715   spline                \fR# open object \[em] spline curve\fP
2716   move
2717   TEXT TEXT ...         \fR# text within invisible box\fP
2718   plot <expr> TEXT      \fR# formatted text\fP
2719   '[' <command> ... ']'
2723 Drawn objects within `[\ .\|.\|.\ ]' are treated as a single composite
2724 object with a rectangular shape (that of the bounding box of all the
2725 elements).  Variable and label assignments within a block are local to
2726 the block.  Current direction of motion is restored to the value at start
2727 of block upon exit.  Position is \fInot\fR restored (unlike `{\ }');
2728 instead, the current position becomes the exit position for the current
2729 direction on the block's bounding box.
2732 <attribute> ::=
2733   h[eigh]t <expr>       \fR# set height of closed figure \fP
2734   wid[th] <expr>        \fR# set width of closed figure \fP
2735   rad[ius] <expr>       \fR# set radius of circle/arc \fP
2736   diam[eter] <expr>     \fR# set diameter of circle/arc \fP
2737   up [<expr>]           \fR# move up \fP
2738   down [<expr>]         \fR# move down \fP
2739   left [<expr>]         \fR# move left \fP
2740   right [<expr>]        \fR# move right \fP
2741   from <position>       \fR# set from position of open figure\fP
2742   to <position>         \fR# set to position of open figure\fP
2743   at <position>         \fR# set center of open figure\fP
2744   with <path>           \fR# fix corner/named point at specified location\fP
2745   with <position>       \fR# fix position of object at specified location\fP
2746   by <expr-pair>        \fR# set object's attachment point\fP
2747   then                  \fR# sequential segment composition\fP
2748   dotted [<expr>]       \fR# set dotted line style\fP
2749   dashed [<expr>]       \fR# set dashed line style\fP
2750   thick[ness] <expr>    \fR# set thickness of lines\fP
2751   chop [<expr>]         \fR# chop end(s) of segment\fP
2752   '->' | '<-' | '<->'   \fR# decorate with arrows\fP
2753   invis[ible]           \fR# make primitive invisible\fP
2754   solid                 \fR# make closed figure solid\fP
2755   fill[ed] [<expr>]     \fR# set fill density for figure\fP
2756   xscaled <expr>        \fR# slant box into x direction\fP
2757   yscaled <expr>        \fR# slant box into y direction\fP
2758   colo[u]r[ed] TEXT     \fR# set fill and outline color for figure\fP
2759   outline[d] TEXT       \fR# set outline color for figure\fP
2760   shaded TEXT           \fR# set fill color for figure\fP
2761   same                  \fR# copy size of previous object\fP
2762   cw | ccw              \fR# set orientation of curves\fP
2763   ljust | rjust         \fR# adjust text horizontally\fP
2764   above | below         \fR# adjust text vertically\fP
2765   aligned               \fR# align parallel to object\fP
2766   TEXT TEXT ...         \fR# text within object\fP
2767   <expr>                \fR# motion in the current direction\fR
2771 Missing attributes are supplied from defaults; inappropriate ones are
2772 silently ignored.  For lines, splines, and arcs, height and width
2773 refer to arrowhead size.
2775 The `at' primitive sets the center of the current object.  The
2776 `with' attribute fixes the specified feature of the given object
2777 to a specified location.  (Note that `with' is incorrectly described
2778 in the Kernighan paper.)
2780 The `by' primitive is not documented in the tutorial portion of
2781 the Kernighan paper, and should probably be considered unreliable.
2783 The primitive `arrow' is a synonym for `line\ ->'.
2785 Text is normally an attribute of some object, in which case successive
2786 strings are vertically stacked and centered on the object's center by
2787 default.  Standalone text is treated as though placed in an invisible
2788 box.
2790 A text item consists of a string or sprintf-expression, optionally
2791 followed by positioning information.  Text (or strings specified with
2792 `sprintf') may contain [gtn]roff font changes, size changes, and local
2793 motions, provided those changes are undone before the end of the current
2794 item.
2796 A position is an (x,y) coordinate pair.  There are lots of different
2797 ways to specify positions:
2800 <position> ::=
2801   <position-not-place>
2802   <place>
2803   ( <position> )
2808 <position-not-place> ::=
2809   <expr-pair>
2810   <position> + <expr-pair>
2811   <position> - <expr-pair>
2812   ( <position> , <position> )
2813   <expr> [of the way] between <position> and <position>
2814   <expr> '<' <position> , <position> '>'
2819 <expr-pair> ::=
2820   <expr> , <expr>
2821   ( expr-pair )
2826 <place> ::=
2827   <label>
2828   <label> <corner>
2829   <corner> [of] <label>
2830   Here
2835 <label> ::=
2836   LABEL [. LABEL ...]
2837   <nth-primitive>
2842 <corner> ::=
2843   .n | .e | .w | .s
2844   .ne | .se | .nw | .sw
2845   .c[enter] | .start | .end
2846   .t[op] | .b[ot[tom]] | .l[eft] | .r[ight]
2847   left | right | <top-of> | <bottom-of>
2848   <north-of> | <south-of> | <east-of> | <west-of>
2849   <center-of> | <start-of> | <end-of>
2850   upper left | lower left | upper right | lower right
2855 <\,\f(CIxxx\/\fP-of> ::=
2856   \f(CIxxx\fP                   \fR# followed by `of'\fP
2861 <nth-primitive> ::=
2862   <ordinal> <object-type>
2863   [<ordinal>] last <object-type>
2868 <ordinal> ::=
2869   INT th
2870   INT st | INT nd | INT rd
2871   ` <any-expr> 'th
2876 <object-type> ::=
2877   box
2878   circle
2879   ellipse
2880   arc
2881   line
2882   arrow
2883   spline
2884   '[]'
2885   TEXT
2889 As Kernighan notes, \[lq]since barbarisms like \fB1th\fP and \fB3th\fP are
2890 barbaric, synonyms like \fB1st\fP and \fB3rd\fP are accepted as well.\[rq]
2891 Objects of a given type are numbered from 1 upwards in order of
2892 declaration; the \fBlast\fP modifier counts backwards.
2894 The \[lq]'th\[rq] form (which allows you to select a previous object with
2895 an expression, as opposed to a numeric literal) is not documented in DWB's
2896 \fIpic\/\fR(1).
2898 The \[la]\,\fIxxx\/\fP-of\|\[ra] rule is special: The lexical parser checks whether
2899 \fIxxx\fP is followed by the token `of' without eliminating it so that
2900 the grammar parser can still see `of'.  Valid examples of specifying a
2901 place with corner and label are thus
2904 A .n
2905 \&.n of A
2906 \&.n A
2907 north of A
2911 while
2914 north A
2915 A north
2918 both cause a syntax error.  (DWB \fBpic\fP also allows the weird form
2919 `A\ north\ of'.)
2921 Here the special rules for the `with' keyword using a path:
2924 <path> ::=
2925   <relative-path>
2926   ( <relative-path> , <relative-path> )
2931 <relative-path> ::=
2932   <corner>
2933   . LABEL [. LABEL ...] [<corner>]
2937 The following style variables control output:
2938 .TS H
2939 center tab(@), linesize(2);
2940 lb | lb | lb
2941 l | n | l.
2942 .sp 2p
2943 Style Variable@Default@What It Does
2944 .sp 2p
2946 .sp 2p
2948 boxht@0.5@Default height of a box
2949 boxwid@0.75@Default height of a box
2950 lineht@0.5@Default length of vertical line
2951 linewid@0.75@Default length of horizontal line
2952 arcrad @0.25@Default radius of an arc
2953 circlerad@0.25@Default radius of a circle
2954 ellipseht@0.5@Default height of an ellipse
2955 ellipsewid@0.75@Default width of an ellipse
2956 moveht@0.5@Default length of vertical move
2957 movewid@0.75@Default length of horizontal move
2958 textht@0@Default height of box enclosing a text object
2959 textwid@0@Default width of box enclosing a text object
2960 arrowht@0.1@Length of arrowhead along shaft
2961 arrowwid@0.05@Width of rear of arrowhead
2962 arrowhead@1@Enable/disable arrowhead filling
2963 dashwid@0.05@Interval for dashed lines
2964 maxpswid@11@Maximum width of picture
2965 maxpsht@8.5@Maximum height of picture
2966 scale@1@Unit scale factor
2967 fillval@0.5@Default fill value
2968 .sp 5p
2971 Any of these can be set by assignment, or reset using the \fBreset\fP
2972 statement.  Style variables assigned within `[\ ]' blocks are restored to
2973 their beginning-of-block value on exit; top-level assignments persist
2974 across pictures.  Dimensions are divided by \fBscale\fR on output.
2976 All \fBpic\fP expressions are evaluated in floating point; units
2977 are always inches (a trailing `i' or `I' is ignored).  Expressions have
2978 the following simple grammar, with semantics very similar to
2979 C\~expressions:
2982 <expr> ::=
2983   VARIABLE
2984   NUMBER
2985   <place> <place-attribute>
2986   <expr> <op> <expr>
2987   - <expr>
2988   ( <any-expr> )
2989   ! <expr>
2990   <func1> ( <any-expr> )
2991   <func2> ( <any-expr> , <any-expr> )
2992   rand ( )
2997 <place-attribute>
2998  .x | .y | .h[eigh]t | .wid[th] | .rad
3003 <op> ::=
3004   + | - | * | / | % | ^ | '<' | '>' | '<=' | '>='
3009 <func1> ::=
3010   sin | cos | log | exp | sqrt | int | rand | srand
3015 <func2> ::=
3016   atan2 | max | min
3020 Both \fBexp\fP and \fBlog\fP are base 10; \fBint\fP does integer
3021 truncation; and \fBrand()\fP returns a random number in [0-1).
3023 There are \fBdefine\fP and \fBundef\fR statements which are not part
3024 of the grammar (they behave as pre-processor macros to the language).
3025 These may be used to define pseudo-functions.
3028 \fBdefine\fP \fIname\fP \fB{\fP \fIreplacement-text\fP \fB}\fP
3032 This defines \fIname\fR as a macro to be replaced by the replacement
3033 text (not including the braces).  The macro may be called as 
3036 \fIname\/\fB(\,\fIarg1, arg2, .\|.\|., argn\fB\/)\fR
3040 The arguments (if any) are substituted for tokens $1, $2 .\|.\|.\& $n
3041 appearing in the replacement text.  To undefine a macro, say \fBundef\fP
3042 \fIname\fR, specifying the name to be undefined.
3043 .\"%%POSTLUDE%%
3046 .NH 1
3047 History and Acknowledgements
3049 Original \fBpic\fP was written to go with Joseph Ossanna's original
3050 \fItroff\/\fP(1) by Brian Kernighan, and later re-written by Kernighan
3051 with substantial enhancements (apparently as part of the evolution of
3052 \fItroff\/\fP(1) into \fIditroff\/\fP(1) to generate
3053 device-independent output).
3055 The language had been inspired by some earlier graphics languages
3056 including \fBideal\fP and \fBgrap\fP.  Kernighan credits Chris van Wyk
3057 (the designer of \fBideal\fP) with many of the ideas that went into
3058 \fBpic\fP.
3060 .\" the original definitions of EQ and EN cause insertion of vertical
3061 .\" space which is not appropriate here
3062 .de EQ
3064 .de EN
3067 delim $$
3069 The \fBpic\fP language was originally described by Brian Kernighan in
3070 Bell Labs Computing Science Technical Report #116 (you can obtain a
3071 PostScript copy of the revised version, [1], by sending a mail message to
3072 \fInetlib@research.att.com\fP with a body of `send 116 from
3073 research/cstr').  There have been two revisions, in 1984 and 1991.
3075 The document you are reading effectively subsumes Kernighan's
3076 description; it was written to fill in lacun\[ae] in the exposition and
3077 integrate in descriptions of the GNU \fIgpic\/\fP(1) features.
3079 The GNU \fBgpic\fR implementation was written by James Clark
3080 \[la]\,\fIjjc@jclark.com\/\fP\[ra].  It is currently maintained by Werner
3081 Lemberg \[la]\,\fIwl@gnu.org\/\fP\[ra].
3084 .NH 1
3085 Bibliography
3086 .IP 1.
3087 Kernighan, B. W.  \fBPIC \[em] A Graphics Language for Typesetting
3088 (Revised User Manual)\fP.  Bell Labs Computing Science Technical Report
3089 #116, December 1991.
3090 .IP 2.
3091 Van Wyk, C. J.  \fBA high-level language for specifying pictures\fP.
3092 \fIACM Transactions On Graphics\fP 1,2 (1982) 163-182.
3094 .\" end of pic.ms