ch17_03.htm

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

HTM
481
字号
<a name="unut-ch-17-sect-3.5" /><div class="sect2"><h3 class="sect2">17.3.5. Text</h3><p>Text must be placed within quotes.  To break the line, break into two(or more) sets of quotes.Text always appears centered within the object, unless given one of thefollowing arguments:</p><table border="1" cellpadding="3"><tr><td><tt class="literal">ljust</tt></td><td><p>Text appears flush left, vertically centered.</p></td></tr><tr><td><tt class="literal">rjust</tt></td><td><p>Text appears flush right, vertically centered.</p></td></tr><tr><td><tt class="literal">above</tt></td><td><p>Text appears above the center.</p></td></tr><tr><td><tt class="literal">below</tt></td><td><p>Text appears below the center.</p></td></tr></table><p></div><a name="unut-ch-17-sect-3.6" /><div class="sect2"><h3 class="sect2">17.3.6. Object Blocks</h3><p>Several primitives can be combined to make a complex object (for example, an octagon).  This complex object can be treated as a single object by declaring it as a block:</p><blockquote><pre class="code">Object: [     <em class="replaceable"><tt>description</tt></em>      .      .      .]</pre></blockquote><p>Brackets are used as delimiters.  Note that the object is declared asthe name of a place, and hence it must begin with a capital letter.</p></div><a name="unut-ch-17-sect-3.7" /><div class="sect2"><h3 class="sect2">17.3.7. Macros</h3><p>The same sequence of commands can be repeated byusing macros.  The syntax is:</p><blockquote><pre class="code">define <em class="replaceable"><tt>sequence</tt></em> %      <em class="replaceable"><tt>description</tt></em>          .          .          .       %</pre></blockquote><p>Here the percent sign (<tt class="literal">%</tt>) is the delimiter, but you can useany character that isn't in the description.</p><p>Macros can take parameters, expressed in the definitionas <tt class="literal">$1</tt> through <tt class="literal">$9</tt>.  Invoke the macro with the syntax:</p><blockquote><pre class="code"><em class="replaceable"><tt>sequence</em>(<em class="replaceable">value1</em>,<em class="replaceable">value2</em>,<em class="replaceable">...</tt></em>)</pre></blockquote></div><a name="unut-ch-17-sect-3.8" /><div class="sect2"><h3 class="sect2">17.3.8. Positioning</h3><p><a name="IXT-17-123464" />In a <tt class="literal">pic</tt> description, the first action begins at (0,0) unlessotherwise specified with coordinates.  Thus, as objects are placed above and left of the first object,the point (0,0) moves down and right on the drawing.</p><p>All points are ultimately translated by the formatter into x- and y-coordinates.You may therefore refer to a specific point in the picture by incrementingor decrementing the coordinates.  For example:</p><blockquote><pre class="code">2nd ellipse + (.5,0)</pre></blockquote><p>This refers to the position 1/2 inch to the right of the centerof the second ellipse.</p><p>The x- and y-coordinates of an object are the pointwhere the center of the object is placed.You may refer to the x- and y-coordinates of anobject by placing <tt class="literal">.x</tt>or <tt class="literal">.y</tt> at the end.  For example: </p><blockquote><pre class="code">last box.x</pre></blockquote><p>refers to the x-coordinate of the most recent box drawn.You can refer to some of the object's physical attributes in a similar way:</p><table border="1" cellpadding="3"><tr><td><tt class="literal">.x</tt></td><td><p>x-coordinate of object's center.</p></td></tr><tr><td><tt class="literal">.y</tt></td><td><p>y-coordinate of object's center.</p></td></tr><tr><td><tt class="literal">.ht</tt></td><td><p>Height of object.</p></td></tr><tr><td><tt class="literal">.wid</tt></td><td><p>Width of object.</p></td></tr><tr><td><tt class="literal">.rad</tt></td><td><p>Radius of object.</p></td></tr><tr><td><tt class="literal">.</tt><em class="replaceable"><tt>corner</tt></em></td><td><p>One of the object's corners.Corners are described below.</p></td></tr></table><p><p>Unless otherwise positioned, each object begins at the point wherethe last object left off.  However, if a command (or sequence of commands) is set off by curly braces (<tt class="literal">{ }</tt>),<tt class="literal">pic</tt> then returns tothe position before the first brace.</p><a name="unut-ch-17-sect-3.8.1" /><div class="sect3"><h3 class="sect3">17.3.8.1. Positioning between objects</h3><p>There are two waysto refer to a previous object.</p><ul><li><p>Refer to it by order.  For example:</p><blockquote><pre class="code">1st box 3rd box last box 2nd last box</pre></blockquote></li><li><p>Declare it with a name, in initial caps, on its declaration line.For example:</p><blockquote><pre class="code">Line1: line 1.5 right from last box.sw</pre></blockquote></li></ul><p>To refer to a point between two objects, or between two points onthe same object, you may write:</p><blockquote><pre class="code"><em class="replaceable"><tt>fraction of the way between first.position and second.position</tt></em></pre></blockquote><p>or (abbreviated):</p><blockquote><pre class="code"><em class="replaceable"><tt>fraction &lt;first.position, second.position&gt;</tt></em></pre></blockquote></div><a name="unut-ch-17-sect-3.8.2" /><div class="sect3"><h3 class="sect3">17.3.8.2. Corners</h3><p>When you refer to a previous object, <tt class="literal">pic</tt> assumes you mean the object's center unless you specify a corner.  To specify a corner, use either of these forms:</p><blockquote><pre class="code"><em class="replaceable"><tt>.corner</em> <tt class="userinput"><b>of</b></tt> <em class="replaceable">object</tt></em><em class="replaceable"><tt>object.corner</tt></em></pre></blockquote><p>For example:</p><blockquote><pre class="code"><tt class="userinput"><b>.sw of last boxlast box.sw</b></tt></pre></blockquote><p>Valid corners can be specified as any of the following:</p><table border="1" cellpadding="3"><tr><td><tt class="literal">n</tt></td><td>North</td></tr><tr><td><tt class="literal">s</tt></td><td>South</td></tr><tr><td><tt class="literal">e</tt></td><td>East</td></tr><tr><td><tt class="literal">w</tt></td><td>West</td></tr><tr><td><tt class="literal">ne</tt></td><td>Northeast</td></tr><tr><td><tt class="literal">nw</tt></td><td>Northwest</td></tr><tr><td><tt class="literal">se</tt></td><td>Southeast</td></tr><tr><td><tt class="literal">sw</tt></td><td>Southwest</td></tr><tr><td><tt class="literal">t</tt></td><td>Top (same as <tt class="literal">n</tt>)</td></tr><tr><td><tt class="literal">b</tt></td><td>Bottom (same as <tt class="literal">s</tt>)</td></tr><tr><td><tt class="literal">r</tt></td><td>Right (same as <tt class="literal">e</tt>)</td></tr><tr><td><tt class="literal">l</tt></td><td>Left (same as <tt class="literal">w</tt>)</td></tr><tr><td><tt class="literal">start</tt></td><td>Point where drawing of object began</td></tr><tr><td><tt class="literal">end</tt></td><td>Point where drawing of object ended</td></tr></table><p><p>You may also refer to the following parts of an object:</p><table border="1" cellpadding="3"><tr><td><tt class="literal">upper right</tt></td><td><tt class="literal">lower right</tt></td></tr><tr><td><tt class="literal">upper left</tt></td><td><tt class="literal">lower left</tt></td></tr></table><p></div></div><a name="unut-ch-17-sect-3.9" /><div class="sect2"><h3 class="sect2">17.3.9. Expressions</h3><p>Expressions may be used anywhere <tt class="literal">pic</tt>needs a numeric value (such as when specifying coordinatesor amounts of motion).Expressions consist of numeric constants, variables, and operators.</p><p><tt class="literal">pic</tt> recognizes the following operators.</p><table border="1" cellpadding="3"><tr><td><tt class="literal">+</tt></td><td>Addition</td></tr><tr><td><tt class="literal">-</tt></td><td>Subtraction</td></tr><tr><td><tt class="literal">*</tt></td><td>Multiplication</td></tr><tr><td><tt class="literal">/</tt></td><td>Division</td></tr><tr><td><tt class="literal">%</tt></td><td>Modulus (remainder after division)</td></tr><tr><td><tt class="literal">^</tt></td><td><p>Exponentiation</p></td></tr></table><p></div><a name="unut-ch-17-sect-3.10" /><div class="sect2"><h3 class="sect2">17.3.10. Default Values</h3><p>Various systemvariables controlthe default dimensions of objects.You can change these defaults by typing a descriptionline of the form:</p><blockquote><pre class="code"><em class="replaceable"><tt>variable</em> = <em class="replaceable">value</tt></em></pre></blockquote><table border="1" cellpadding="3"><tr><th><em class="emphasis">Variable</em></th><th><em class="emphasis">Default</em></th><th><em class="emphasis">Variable</em></th><th><em class="emphasis">Default</em></th></tr><tr><td><tt class="literal">arcrad</tt></td><td>0.25</td><td><tt class="literal">ellipsewid</tt></td><td>0.75</td></tr><tr><td><tt class="literal">arrowwid</tt></td><td>0.05</td><td><tt class="literal">linewid</tt></td><td>0.5</td></tr><tr><td><tt class="literal">arrowht</tt></td><td>0.1</td><td><tt class="literal">lineht</tt></td><td>0.5</td></tr><tr><td><tt class="literal">boxwid</tt></td><td>0.75</td><td><tt class="literal">movewid</tt></td><td>0.5</td></tr><tr><td><tt class="literal">boxht</tt></td><td>0.5</td><td><tt class="literal">moveht</tt></td><td>0.5</td></tr><tr><td><tt class="literal">circlerad</tt></td><td>0.25</td><td><tt class="literal">scale</tt></td><td>1</td></tr><tr><td><tt class="literal">dashwid</tt></td><td>0.05</td><td><tt class="literal">textht</tt></td><td>0</td></tr><tr><td><tt class="literal">ellipseht</tt></td><td>0.5</td><td><tt class="literal">textwid</tt></td><td>0</td></tr></table><p></div><a name="unut-ch-17-sect-3.11" /><div class="sect2"><h3 class="sect2">17.3.11. pic Examples</h3><p>Input:</p><blockquote><pre class="code">.PSdefine smile %a = $1circle radius a at 0,0arc cw radius a*.75 from a*.5,-a*.25 to -a*.5,-a*.25"\(bu" at a*.33,a*.25"\(bu" at a*-.33,a*.25%smile(.5).PE</pre></blockquote><p>Result:</p><img src="figs/smile.gif" alt="Figure 17.3.11" /><p>Input (from CSTR #116):</p><blockquote><pre class="code">.PSellipse "document"arrowbox "PIC"arrowbox "TBL/EQN" "(optional)" dashedarrowbox "TROFF"arrowellipse "typesetter".PE</pre></blockquote><p>Result:</p><img src="figs/typesetter.gif" alt="Figure 17.3.11" /><a name="IXT-17-123465" /><a name="IXT-17-123466" /><a name="IXT-17-123467" /><a name="IXT-17-123468" /><a name="IXT-17-123469" /><a name="IXT-17-123470" /></div><hr width="684" align="left" /><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"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0" /></a></td><td align="right" valign="top" width="228"><a href="ch17_04.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td align="left" valign="top" width="228">17.2. eqn</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0" /></a></td><td align="right" valign="top" width="228">17.4. refer</td></tr></table></div><hr width="684" align="left" /><img src="../gifs/navbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links" /><p><p><font size="-1"><a href="copyrght.htm">Copyright &copy; 2003</a> O'Reilly &amp; Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,88,96" href="../index.htm"><area shape="rect" coords="90,0,165,96" href="../upt/index.htm"><area shape="rect" coords="168,1,253,107" href="../mac/index.htm"><area shape="rect" coords="255,0,335,97" href="../korn/index.htm"><area shape="rect" coords="337,0,415,109" href="../unixnut/index.htm"><area shape="rect" coords="417,0,512,122" href="../sedawk/index.htm"><area shape="rect" coords="514,0,605,105" href="../lunix/index.htm"><area shape="rect" coords="611,2,694,121" href="../vi/index.htm"></map></body></html>

⌨️ 快捷键说明

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