ch17_03.htm

来自「unix基础教程」· HTM 代码 · 共 481 行 · 第 1/2 页

HTM
481
字号
<html><head><title>pic (UNIX in a Nutshell: System V Edition)</title><link rel="stylesheet" type="text/css" href="../style/style1.css" /><meta name="DC.Creator" content="Arnold Robbins" /><meta name="DC.Format" content="text/xml" scheme="MIME" /><meta name="DC.Language" content="en-US" /><meta name="DC.Publisher" content="O'Reilly &amp; Associates, Inc." /><meta name="DC.Source" scheme="ISBN" content="1-56592-427-4" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="UNIX in a Nutshell: System V Edition" /><meta name="DC.Type" content="Text.Monograph" /></head><body bgcolor="#ffffff"><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home" /><map name="banner-map"><area shape="rect" coords="1,-2,616,66" href="index.htm" alt="Book Title" /><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch17_02.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228" /><td align="right" valign="top" width="228"><a href="ch17_04.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><h2 class="sect1">17.3. pic</h2><p><a name="ch17.troff1b" /><a name="ch17.troff2b" /><a name="ch17.troff3b" /><a name="unut-ch-17-ix-pic-preprocessor" /><a name="unut-ch-17-ix-images-formatting-in-nroff-troff" /><a name="unut-ch-17-ix-graphics-formatting-in-nroff-troff" /><tt class="literal">pic</tt> is a graphics language program that facilitates thedrawing of simple flowcharts and diagrams.<tt class="literal">pic</tt> offers dozens of ways to draw a picture, not onlybecause of the many abbreviations it allows, but because <tt class="literal">pic</tt> tries tocombine the language of geometry with English.  For example, you canspecify a line by its direction, magnitude, and starting point, yet you can often achieve the same effect by simplystating, &#8220;from <em class="emphasis">there</em> to <em class="emphasis">there</em>.&#8221;</p><p><tt class="literal">pic</tt> has the following command-line syntax:</p><blockquote><pre class="code">pic [<em class="replaceable"><tt>files</tt></em>]</pre></blockquote><p>Full descriptions of primitive objects in <tt class="literal">pic</tt> can be ended by starting another line, or with the semicolon character (;).  A singleprimitive description can be continued on the next line, however, byending the first with a backslash character (<tt class="literal">\</tt>). Comments may be placed on lines beginning with the pound sign (<tt class="literal">#</tt>).</p><p>Solaris does not have <tt class="literal">pic</tt>.</p><p>The canonical reference for <tt class="literal">pic</tt> is<em class="citetitle">Bell Labs Computing Science Technical Report #116</em>,by B.W. Kernighan.This paper may be downloaded fromhttp://cm.bell-labs.com/cm/cs/cstr/116.ps.gz.That document describes a newer version of <tt class="literal">pic</tt> withmore features than what is described here, but such features maynot be universally available.You should read it if you plan to do any serious work in <tt class="literal">pic</tt>.</p><a name="unut-ch-17-sect-3.1" /><div class="sect2"><h3 class="sect2">17.3.1. pic Macros</h3><a name="IXT-17-123462" /><table border="1" cellpadding="3"><tr><td><tt class="literal">.PS </tt>[<em class="replaceable"><tt>h</em> [<em class="replaceable">w</em>]]</td><td><p>Start <tt class="literal">pic</tt> description.  <em class="emphasis">h</em> and <em class="emphasis">w</tt></em>, if specified, are the desired height and width of the picture; the full picturecan expand or contract to fill this space.</p></td></tr><tr><td><tt class="literal">.PS &lt;</tt> <em class="replaceable"><tt>file</em></td><td>Read contents of <em class="emphasis">file</tt></em> in place of current line.</td></tr><tr><td><tt class="literal">.PE</tt></td><td>End <tt class="literal">pic</tt> description.</td></tr><tr><td><tt class="literal">.PF</tt></td><td><p>End <tt class="literal">pic</tt> description and return to vertical positionbefore matching <tt class="literal">.PS</tt>.</p></td></tr></table><p><p><tt class="literal">troff</tt> requests or macros embedded in the body ofa picture description are passed through unchanged.They are assumed to make sense at that point.Be careful not to use requests or macros that generate anyhorizontal or vertical motion.</p></div><a name="unut-ch-17-sect-3.2" /><div class="sect2"><h3 class="sect2">17.3.2. Declarations</h3><p>At the beginning of a <tt class="literal">pic</tt> description, you may declare a new scale, and declare any number of variables.<tt class="literal">pic</tt> assumes you want a 1-to-1 scale, where units are inches by default.  You candeclare a different scale, i.e., centimeters,by declaring:</p><blockquote><pre class="code">scale = 2.54</pre></blockquote><p>You may use variables instead of numbers in a description;<tt class="literal">pic</tt> substitutes the variable's value.Instead of: </p><blockquote><pre class="code">line right <em class="replaceable"><tt>n</tt></em></pre></blockquote><p>you may use avariable, for example, <tt class="literal">a</tt>,by declaring at thetop of the description:</p><blockquote><pre class="code">a = <em class="replaceable"><tt>n</tt></em></pre></blockquote><p>You may then write:</p><blockquote><pre class="code">line right a</pre></blockquote><p>Variable names must begin with a lowercase letter.The rest of the name may consist of uppercase or lowercase letters,digits, and underscores.Variables retain their values from picture to picture.</p></div><a name="unut-ch-17-sect-3.3" /><div class="sect2"><h3 class="sect2">17.3.3. Primitives</h3><p><a name="IXT-17-123463" /><tt class="literal">pic</tt> recognizes several basic graphical objects, or primitives.These primitives are specified by the following keywords:</p><table border="1" cellpadding="3"><tr><td><tt class="literal">arc</tt></td><td><tt class="literal">circle</tt></td><td><tt class="literal">move</tt></td></tr><tr><td><tt class="literal">arrow</tt></td><td><tt class="literal">ellipse</tt></td><td><tt class="literal">spline</tt></td></tr><tr><td><tt class="literal">box</tt></td><td><tt class="literal">line</tt></td><td><tt class="literal">"</tt><em class="replaceable"><tt>text</tt></em><tt class="literal">"</tt></td></tr></table><p><a name="unut-ch-17-sect-3.3.1" /><div class="sect3"><h3 class="sect3">17.3.3.1. Syntax</h3><p>Primitives may be followed by relevant options.  Options are discussed later in this section.</p><table border="1" cellpadding="3"><tr><td><tt class="literal">arc</tt> [<tt class="literal">cw</tt>] [<em class="replaceable"><tt>options</tt></em>]</td><td><p>A fraction of a circle (default is 1/4 of a circle).The <tt class="literal">cw</tt> option specifies a clockwise arc;default is counter-clockwise.</p></td></tr><tr><td><tt class="literal">arrow</tt> [<em class="replaceable"><tt>options</tt></em>]</td><td><p>Draw an arrow.  Essentially the same as <tt class="literal">line -&gt;</tt>.</p></td></tr><tr><td><tt class="literal">box</tt> [<em class="replaceable"><tt>options</tt></em>]</td><td><p>Draw a box.</p></td></tr><tr><td><tt class="literal">circle</tt> [<em class="replaceable"><tt>options</tt></em>]</td><td><p>Draw a circle.</p></td></tr><tr><td><tt class="literal">ellipse</tt> [<em class="replaceable"><tt>options</tt></em>]</td><td><p>Draw an ellipse.</p></td></tr><tr><td><tt class="literal">line</tt> [<em class="replaceable"><tt>options</tt></em>]</td><td><p>Draw a line.</p></td></tr><tr><td><tt class="literal">move</tt> [<em class="replaceable"><tt>options</tt></em>]</td><td><p>A change of position in the drawing.  Essentially, an invisible line.</p></td></tr><tr><td><tt class="literal">spline</tt> [<em class="replaceable"><tt>options</tt></em>]</td><td><p>A smooth curve, with the feature that a <tt class="literal">then</tt> optionresults in a gradual (sloped) change in direction.In other words, when drawing a path using <tt class="literal">line</tt>,you get sharp corners each time the path changes direction.With a <tt class="literal">spline</tt>, you instead get a smooth curve.</p></td></tr><tr><td><tt class="literal">"</tt><em class="replaceable"><tt>text</tt></em><tt class="literal">"</tt></td><td><p>Text centered at current point.</p></td></tr></table><p></div></div><a name="unut-ch-17-sect-3.4" /><div class="sect2"><h3 class="sect2">17.3.4. Options</h3><p>The options below are grouped by function.Note that <tt class="literal">at</tt>, <tt class="literal">with</tt>, and <tt class="literal">from</tt> specify points.Points may be expressed as Cartesian coordinates or with respect to previous objects.</p><table border="1" cellpadding="3"><tr><td><p><tt class="literal">right</tt>  [<em class="replaceable"><tt>n</tt></em>]</p><p><tt class="literal">left</tt>  [<em class="replaceable"><tt>n</tt></em>]</p><p><tt class="literal">up</tt>  [<em class="replaceable"><tt>n</tt></em>]</p><p><tt class="literal">down</tt>  [<em class="replaceable"><tt>n</tt></em>]</p></td><td><p>The direction of the primitive; default is the direction in which the previousdescription had been heading.  Create diagonal motion by using two directions on the option line.  Each direction can be followed bya specified length <em class="emphasis">n</em>.</p></td></tr><tr><td><p><tt class="literal">rad  </tt><em class="replaceable"><tt>n</tt></em></p><p><tt class="literal">diam</tt><em class="replaceable"><tt>n</tt></em></p></td><td><p>Create the primitive using radius or diameter <em class="emphasis">n</em>.</p></td></tr><tr><td><p><tt class="literal">ht </tt><em class="replaceable"><tt>n</tt></em></p><p><tt class="literal">wid </tt><em class="replaceable"><tt>n</tt></em></p></td><td><p>Create the primitive using height or width <em class="emphasis">n</em>.For an arrow, line, or spline, height and width refer to arrowhead size.</p></td></tr><tr><td><tt class="literal">same</tt></td><td><p>Create the primitive using the same dimensions specified for the most recent matching primitive.</p></td></tr><tr><td><tt class="literal">at</tt><em class="replaceable"><tt> point</em></td><td><p>Center the primitive at <em class="emphasis">point</tt></em>.  </p></td></tr><tr><td><tt class="literal">with .</tt><em class="replaceable"><tt>part</em><tt class="literal"> at </tt><em class="replaceable">point</em></td><td><p>Designate the <em class="emphasis">part</em> of the primitive to be at <em class="emphasis">point</tt></em>(e.g., <tt class="literal">top</tt>, or a corner).</p></td></tr><tr><td><tt class="literal">from </tt><em class="replaceable"><tt>point1</em><tt class="literal"> to </tt><em class="replaceable">point2</em></td><td><p>Draw the primitive from <em class="emphasis">point1</em> to <em class="emphasis">point2</tt></em>.</p></td></tr><tr><td><tt class="literal">-&gt;</tt></td><td><p>Direct the arrowhead forward.</p></td></tr><tr><td><tt class="literal">&lt;-</tt></td><td><p>Direct the arrowhead backward.</p></td></tr><tr><td><tt class="literal">&lt;-&gt;</tt></td><td><p>Direct the arrowhead both ways.</p></td></tr><tr><td><tt class="literal">chop </tt><em class="replaceable"><tt>n m</em></td><td><p>Chop <em class="emphasis">n</tt></em> from beginning of primitiveand <em class="emphasis">m</em> from end.  With only one argument, the same value is chopped from both ends.With no arguments, chop a default amount(usually <tt class="literal">circlerad</tt>).</p></td></tr><tr><td><p><tt class="literal">dotted</tt></p><p><tt class="literal">dashed</tt></p><p><tt class="literal">invis</tt></p></td><td><p>Draw the primitive using lines that are dotted, dashed, or invisible.(An invisible object still occupies space in the output.)Default is solid lines.</p></td></tr><tr><td><tt class="literal">then</tt> ...</td><td><p>Continue primitive in a new direction.  Relevant only to lines, splines,moves, and arrows.  Can be placed before or after any text.</p></td></tr><tr><td><tt class="literal">"</tt><em class="replaceable"><tt>text</tt></em><tt class="literal">"</tt></td><td><p>Center the text over the center point of the object.The options for text described in the next section may also be used.</p></td></tr></table><p></div>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?