| <head> |
| <title>pic(1) - Plan 9 from User Space</title> |
| <meta content="text/html; charset=utf-8" http-equiv=Content-Type> |
| </head> |
| <body bgcolor=#ffffff> |
| <table border=0 cellpadding=0 cellspacing=0 width=100%> |
| <tr height=10><td> |
| <tr><td width=20><td> |
| <tr><td width=20><td><b>PIC(1)</b><td align=right><b>PIC(1)</b> |
| <tr><td width=20><td colspan=2> |
| <br> |
| <p><font size=+1><b>NAME </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| pic, tpic – troff and tex preprocessors for drawing pictures<br> |
| |
| </table> |
| <p><font size=+1><b>SYNOPSIS </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>pic</font></tt> [ <i>files</i> ] |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>tpic</font></tt> [ <i>files</i> ]<br> |
| |
| </table> |
| <p><font size=+1><b>DESCRIPTION </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <i>Pic</i> is a <a href="../man1/troff.html"><i>troff</i>(1)</a> preprocessor for drawing figures on a typesetter. |
| <i>Pic</i> code is contained between <tt><font size=+1>.PS</font></tt> and <tt><font size=+1>.PE</font></tt> lines:<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>.PS</font></tt> <i>optional-width optional-height<br> |
| element-list<br> |
| </i><tt><font size=+1>.PE<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| |
| </table> |
| or in a file mentioned in a <tt><font size=+1>.PS</font></tt> line:<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>.PS <</font></tt><i>file |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </i> |
| |
| </table> |
| If <i>optional-width</i> is present, the picture is made that many inches |
| wide, regardless of any dimensions used internally. The height |
| is scaled in the same proportion unless <i>optional-height</i> is present. |
| If <tt><font size=+1>.PF</font></tt> is used instead of <tt><font size=+1>.PE</font></tt>, the typesetting position after |
| printing is restored to what it was upon entry. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| An <i>element-list</i> is a list of elements:<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <i>primitive attribute-list<br> |
| placename</i> <tt><font size=+1>:</font></tt> <i>element<br> |
| placename</i> <tt><font size=+1>:</font></tt> <i>position<br> |
| var</i> <tt><font size=+1>=</font></tt> <i>expr<br> |
| direction<br> |
| </i><tt><font size=+1>{</font></tt> <i>element-list</i> <tt><font size=+1>}<br> |
| [</font></tt> <i>element-list</i> <tt><font size=+1>]<br> |
| for</font></tt> <i>var</i> <tt><font size=+1>=</font></tt> <i>expr</i> <tt><font size=+1>to</font></tt> <i>expr</i> <tt><font size=+1>by</font></tt> <i>expr</i> <tt><font size=+1>do {</font></tt> <i>anything</i> <tt><font size=+1>}<br> |
| if</font></tt> <i>expr</i> <tt><font size=+1>then {</font></tt> <i>anything</i> <tt><font size=+1>} else {</font></tt> <i>anything</i> <tt><font size=+1>}<br> |
| copy</font></tt> <i>file, </i><tt><font size=+1> copy thru</font></tt> <i>macro, </i><tt><font size=+1> copy</font></tt> <i>file</i> <tt><font size=+1>thru</font></tt> <i>macro<br> |
| </i><tt><font size=+1>sh {</font></tt> <i>commandline</i> <tt><font size=+1>}<br> |
| print</font></tt> <i>expr<br> |
| </i><tt><font size=+1>reset</font></tt> <i>optional var-list<br> |
| troff-command<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </i> |
| |
| </table> |
| Elements are separated by newlines or semicolons; a long element |
| may be continued by ending the line with a backslash. Comments |
| are introduced by a <tt><font size=+1>#</font></tt> and terminated by a newline. Variable names |
| begin with a lower case letter; place names begin with upper case. |
| Place and variable names retain their values from |
| one picture to the next. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| After each primitive the current position moves in the current |
| direction (<tt><font size=+1>up</font></tt>,<tt><font size=+1>down</font></tt>, <tt><font size=+1>left</font></tt>,<tt><font size=+1>right</font></tt> (default)) by the size of the primitive. |
| The current position and direction are saved upon entry to a <tt><font size=+1>{</font></tt>...<tt><font size=+1>}</font></tt> |
| block and restored upon exit. Elements within a block enclosed |
| in <tt><font size=+1>[</font></tt>...<tt><font size=+1>]</font></tt> are treated as a unit; the dimensions are |
| determined by the extreme points of the contained objects. Names, |
| variables, and direction of motion within a block are local to |
| that block. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Troff-command</i> is any line that begins with a period. Such a line |
| is assumed to make sense in the context where it appears; generally, |
| this means only size and font changes. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| The <i>primitive</i> objects are:<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>box circle ellipse arc line arrow spline move </font></tt><i> text-list<br> |
| </i> |
| </table> |
| <tt><font size=+1>arrow</font></tt> is a synonym for <tt><font size=+1>line −></font></tt>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| An <i>attribute-list</i> is a sequence of zero or more attributes; each |
| attribute consists of a keyword, perhaps followed by a value.<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>h(eigh)t</font></tt> <i>expr </i><tt><font size=+1> wid(th)</font></tt> <i>expr<br> |
| </i><tt><font size=+1>rad(ius)</font></tt> <i>expr </i><tt><font size=+1> diam(eter)</font></tt> <i>expr<br> |
| </i><tt><font size=+1>up</font></tt> <i>opt-expr </i><tt><font size=+1> down</font></tt> <i>opt-expr<br> |
| </i><tt><font size=+1>right</font></tt> <i>opt-expr </i><tt><font size=+1> left</font></tt> <i>opt-expr<br> |
| </i><tt><font size=+1>from</font></tt> <i>position </i><tt><font size=+1> to</font></tt> <i>position<br> |
| </i><tt><font size=+1>at</font></tt> <i>position </i><tt><font size=+1> with</font></tt> <i>corner<br> |
| </i><tt><font size=+1>by</font></tt> <i>expr, expr </i><tt><font size=+1> then<br> |
| dotted</font></tt> <i>opt-expr </i><tt><font size=+1> dashed</font></tt> <i>opt-expr<br> |
| </i><tt><font size=+1>chop</font></tt> <i>opt-expr </i><tt><font size=+1> −> <− <−><br> |
| invis same<br> |
| fill</font></tt> <i>opt-expr<br> |
| text-list expr<br> |
| </i> |
| </table> |
| |
| </table> |
| Missing attributes and values are filled in from defaults. Not |
| all attributes make sense for all primitives; irrelevant ones |
| are silently ignored. The attribute <tt><font size=+1>at</font></tt> causes the geometrical |
| center to be put at the specified place; <tt><font size=+1>with</font></tt> causes the position |
| on the object to be put at the specified place. For lines, splines |
| and |
| arcs, <tt><font size=+1>height</font></tt> and <tt><font size=+1>width</font></tt> refer to arrowhead size. A bare <i>expr</i> implies |
| motion in the current direction. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| Text is normally an attribute of some primitive; by default it |
| is placed at the geometrical center of the object. Stand-alone |
| text is also permitted. A text list is a list of text items:<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <i>text-item</i><tt><font size=+1>:<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| "..." |
| </table> |
| </font></tt> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <i>positioning ...<br> |
| </i><tt><font size=+1>sprintf("</font></tt><i>format</i><tt><font size=+1>",</font></tt> <i>expr</i><tt><font size=+1>,</font></tt> <i>...</i><tt><font size=+1>)</font></tt> <i>positioning ...<br> |
| </i> |
| </table> |
| <i> positioning</i><tt><font size=+1>:<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| center ljust rjust above below<br> |
| |
| </table> |
| </font></tt> |
| </table> |
| If there are multiple text items for some primitive, they are |
| arranged vertically and centered except as qualified. Positioning |
| requests apply to each item independently. Text items may contain |
| <i>troff</i> commands for size and font changes, local motions, etc., |
| but make sure that these are balanced so that the entering state |
| is restored before exiting. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| A position is ultimately an <i>x,y</i> coordinate pair, but it may be |
| specified in other ways.<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <i>position</i><tt><font size=+1>:<br> |
| </font></tt> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <i>expr, expr<br> |
| place </i><tt><font size=+1>±</font></tt> <i>expr, expr<br> |
| place </i><tt><font size=+1>± (</font></tt> <i>expr, expr</i> <tt><font size=+1>)<br> |
| (</font></tt> <i>position</i><tt><font size=+1>,</font></tt> <i>position</i> <tt><font size=+1>) </font></tt><i> x</i> from one, <i>y</i> the other<br> |
| <i>expr</i> [<tt><font size=+1>of the way</font></tt>] between <i>position</i> and <i>position<br> |
| expr </i>< <i>position</i> , <i>position </i>><br> |
| ( <i>position</i> )<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| |
| </table> |
| <i>place</i><tt><font size=+1>:<br> |
| </font></tt> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <i>placename optional-corner<br> |
| corner</i> <tt><font size=+1>of</font></tt> <i>placename<br> |
| nth primitive optional-corner<br> |
| corner</i> <tt><font size=+1>of</font></tt> <i>nth primitive<br> |
| </i><tt><font size=+1>Here<br> |
| </font></tt> |
| </table> |
| |
| </table> |
| An <i>optional-corner</i> is one of the eight compass points or the center |
| or the start or end of a primitive.<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <i>optional-corner</i><tt><font size=+1>:<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| .n .e .w .s .ne .se .nw .sw .c .start .end<br> |
| |
| </table> |
| </font></tt> <i>corner</i><tt><font size=+1>:<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| top bot left right start end<br> |
| |
| </table> |
| </font></tt> |
| </table> |
| Each object in a picture has an ordinal number; <i>nth</i> refers to |
| this.<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <i>nth</i><tt><font size=+1>:<br> |
| </font></tt> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <i>n</i><tt><font size=+1>th</font></tt><i>, n</i><tt><font size=+1>th last<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| |
| </table> |
| |
| </table> |
| The built-in variables and their default values are:<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>boxwid 0.75 boxht 0.5<br> |
| circlerad 0.25 arcrad 0.25<br> |
| ellipsewid 0.75 ellipseht 0.5<br> |
| linewid 0.5 lineht 0.5<br> |
| movewid 0.5 moveht 0.5<br> |
| textwid 0 textht 0<br> |
| arrowwid 0.05 arrowht 0.1<br> |
| dashwid 0.1 arrowhead 2<br> |
| scale 1<br> |
| </font></tt> |
| </table> |
| |
| </table> |
| These may be changed at any time, and the new values remain in |
| force from picture to picture until changed again or reset by |
| a <tt><font size=+1>reset</font></tt> statement. Variables changed within <tt><font size=+1>[</font></tt> and <tt><font size=+1>]</font></tt> revert to |
| their previous value upon exit from the block. Dimensions are |
| divided by <tt><font size=+1>scale</font></tt> during output. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| Expressions in <i>pic</i> are evaluated in floating point. All numbers |
| representing dimensions are taken to be in inches.<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <i>expr</i><tt><font size=+1>:<br> |
| </font></tt> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <i>expr op expr<br> |
| </i><tt><font size=+1>−</font></tt> <i>expr<br> |
| </i><tt><font size=+1>!</font></tt> <i>expr<br> |
| </i><tt><font size=+1>(</font></tt> <i>expr</i> <tt><font size=+1>)<br> |
| variable<br> |
| number<br> |
| </font></tt><i>place</i> <tt><font size=+1>.x </font></tt><i> place</i> <tt><font size=+1>.y </font></tt><i> place</i> <tt><font size=+1>.ht </font></tt><i> place</i> <tt><font size=+1>.wid </font></tt><i> place</i> <tt><font size=+1>.rad<br> |
| sin(</font></tt><i>expr</i><tt><font size=+1>) cos(</font></tt><i>expr</i><tt><font size=+1>) atan2(</font></tt><i>expr,expr</i><tt><font size=+1>) log(</font></tt><i>expr</i><tt><font size=+1>) exp(</font></tt><i>expr</i><tt><font size=+1>)<br> |
| sqrt(</font></tt><i>expr</i><tt><font size=+1>) max(</font></tt><i>expr,expr</i><tt><font size=+1>) min(</font></tt><i>expr,expr</i><tt><font size=+1>) int(</font></tt><i>expr</i><tt><font size=+1>) rand()<br> |
| </font></tt> |
| </table> |
| <i>op</i><tt><font size=+1>:<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| + − * / % < <= > >= == != && ||<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| </table> |
| </font></tt> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| |
| </table> |
| |
| </table> |
| The <tt><font size=+1>define</font></tt> and <tt><font size=+1>undef</font></tt> statements are not part of the grammar.<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>define</font></tt> <i>name</i> <tt><font size=+1>{</font></tt> <i>replacement text</i> <tt><font size=+1>}<br> |
| undef</font></tt> <i>name<br> |
| </i> |
| </table> |
| |
| </table> |
| Occurrences of <tt><font size=+1>$1</font></tt>, <tt><font size=+1>$2</font></tt>, etc., in the replacement text will be replaced |
| by the corresponding arguments if <i>name</i> is invoked as<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <i>name</i><tt><font size=+1>(</font></tt><i>arg1</i><tt><font size=+1>,</font></tt> <i>arg2</i><tt><font size=+1>, ...)<br> |
| </font></tt> |
| </table> |
| |
| </table> |
| Non-existent arguments are replaced by null strings. Replacement |
| text may contain newlines. The <tt><font size=+1>undef</font></tt> statement removes the definition |
| of a macro. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Tpic</i> is a <a href="../man1/tex.html"><i>tex</i>(1)</a> preprocessor that accepts <i>pic</i> language. It produces |
| Tex commands that define a box called <tt><font size=+1>\graph</font></tt>, which contains the |
| picture. The box may be output this way:<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>\centerline{\box\graph}<br> |
| </font></tt> |
| </table> |
| |
| </table> |
| <p><font size=+1><b>EXAMPLES </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>arrow "input" above; box "process"; arrow "output" above<br> |
| move<br> |
| A: ellipse <br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| circle rad .1 with .w at A.e<br> |
| circle rad .05 at 0.5 <A.c, A.ne><br> |
| circle rad .065 at 0.5 <A.c, A.ne><br> |
| spline from last circle.nw left .25 then left .05 down .05<br> |
| arc from A.c to A.se rad 0.5<br> |
| for i = 1 to 10 do { line from A.s+.025*i,.01*i down i/50 } <br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| </table> |
| </font></tt> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| |
| </table> |
| arrow "input" above; box "process"; arrow "output" above move A: ellipse<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| circle rad .1 with .w at A.e<br> |
| circle rad .05 at 0.5 <A.c, A.ne><br> |
| circle rad .065 at 0.5 <A.c, A.ne><br> |
| spline from last circle.nw left .25 then left .05 down .05<br> |
| arc from A.c to A.se rad 0.5<br> |
| for i = 1 to 10 do { line from A.s+.025*i,.01*i down i/50 }<br> |
| |
| </table> |
| |
| </table> |
| <p><font size=+1><b>SOURCE </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>/usr/local/plan9/src/cmd/pic<br> |
| </font></tt> |
| </table> |
| <p><font size=+1><b>SEE ALSO </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <a href="../man1/grap.html"><i>grap</i>(1)</a>, <a href="../man1/doctype.html"><i>doctype</i>(1)</a>, <a href="../man1/troff.html"><i>troff</i>(1)</a><br> |
| B. W. Kernighan, “PIC--a Graphics Language for Typesetting”, <i>Unix |
| Research System Programmer’s Manual,</i> Tenth Edition, Volume 2<br> |
| |
| </table> |
| |
| <td width=20> |
| <tr height=20><td> |
| </table> |
| <!-- TRAILER --> |
| <table border=0 cellpadding=0 cellspacing=0 width=100%> |
| <tr height=15><td width=10><td><td width=10> |
| <tr><td><td> |
| <center> |
| <a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a> |
| </center> |
| </table> |
| <!-- TRAILER --> |
| </body></html> |