Imported Upstream version 1.22.4
[platform/upstream/groff.git] / contrib / mom / momdoc / graphical.html
1 <?xml version="1.0" encoding="utf-8"?>
2 <!--
3 This file is part of groff, the GNU roff type-setting system.
4
5 Copyright (C) 2004-2018 Free Software Foundation, Inc.
6 Written by Peter Schaffter (peter@schaffter.ca).
7
8 Permission is granted to copy, distribute and/or modify this document
9 under the terms of the GNU Free Documentation License, Version 1.3 or
10 any later version published by the Free Software Foundation; with no
11 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
12 Texts.
13
14 A copy of the Free Documentation License is included as a file called
15 FDL in the main directory of the groff source package.
16 -->
17
18 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
19 <html xmlns="http://www.w3.org/1999/xhtml">
20
21 <head>
22   <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
23   <title>Mom -- Graphical Objects</title>
24   <link rel="stylesheet" type="text/css" href="stylesheet.css" />
25 </head>
26
27 <body style="background-color: #f5faff;">
28
29 <!-- ==================================================================== -->
30
31 <div id="top" class="page">
32
33 <!-- Navigation links -->
34 <table style="width: 100%;">
35 <tr>
36   <td><a href="toc.html">Back to Table of Contents</a></td>
37   <td style="text-align: right;"><a href="docprocessing.html#top">Next: Document processing</a></td>
38 </tr>
39 </table>
40
41 <h1 class="docs">Graphical objects</h1>
42
43 <div style="text-align: center;">
44 <ul class="no-enumerator" style="margin-left: -2.5em;">
45   <li><a href="#intro-graphical">Introduction to graphical objects</a></li>
46   <li><a href="#behaviour">Graphical objects behaviour</a></li>
47   <li><a href="#order">Order of arguments</a></li>
48   <li><a href="#index-graphical">Index of graphical objects macros</a></li>
49 </ul>
50 </div>
51
52 <div class="rule-medium"><hr/></div>
53
54 <h2 id="intro-graphical" class="docs">Introduction to graphical objects</h2>
55
56 <p>
57 Groff has a number of
58 <a href="definitions.html#inlines">inline escapes</a>
59 for drawing rules, polygons, ellipses and splines.  All begin with
60 <kbd>\D</kbd> (presumably for &#8220;Draw&#8221;) and are documented
61 in the groff info manual:
62 <br/>
63 <span class="pre-in-pp">
64   info groff => Escape index => \D
65 </span>
66 The escapes allow you to draw just about any simple graphical object
67 you can think of, but owing to their syntax, they&#8217;re not always easy
68 to read, which can make tweaking them difficult.  Additionally,
69 while they perform in a <i>consistent</i> manner, they don&#8217;t
70 always perform in an <i>expected</i> manner.
71 </p>
72
73 <p>
74 Experience shows that the most common graphical elements typesetters
75 need are rules (horizontal and vertical), boxes, and circles (or
76 ellipses).  For this reason, mom provides macros
77 to draw these objects in an easy-to-understand way; the results are
78 predictable, and mom&#8217;s syntax makes fixes or tweaks
79 painless.
80 </p>
81
82 <p id="graphical-example">
83 For example, if you want to draw a 2-inch square outline box at the left
84 margin using groff&#8217;s <kbd>\D</kbd> escapes, it looks like this:
85 <br/>
86 <span class="pre-in-pp">
87              back up
88                by
89              weight
90             +-------+
91             |       |
92    \D't 500'\h'-500u'\D'p 2i 0 0 2i -2i 0 0 -2i'
93   |       |          |                        |
94   +-------+          +------------------------+
95    set rule          draw box, 1 line at a time
96     weight
97 </span>
98
99 Obviously, this isn&#8217;t very efficient for something as simple as a
100 box.
101 </p>
102
103 <p>
104 Here&#8217;s the same box, drawn with mom&#8217;s box drawing
105 macro
106 <kbd><a href="#dbx">DBX</a></kbd>:
107 <br/>
108 <span class="pre-in-pp">
109   left margin indent--+  +--box width
110                       |  |
111              .DBX .5  0  2i  2i
112                   |          |
113      rule weight--+          +--box depth
114      (in points)
115 </span>
116 </p>
117
118 <p>
119 Mom&#8217;s graphical object macros allow&mdash;in fact,
120 require&mdash;giving the rule weight (&#8220;thickness&#8221;) for
121 the object (or saying that you want it filled), an indent from the
122 left margin where the object begins, the dimensions of the object,
123 and optionally a colour for the object.
124 </p>
125
126 <p>
127 There are no defaults for the arguments to mom'a graphical object
128 macros, which means you must supply the arguments every time you
129 invoke them.
130 </p>
131
132 <div class="box-tip">
133 <p class="tip">
134 <span class="note">Note:</span>
135 As stated above, mom only provides macros for commonly-used
136 graphical objects (rules, boxes, circles).  More complex objects
137 (polygons, non-straight lines, splines) must be drawn using
138 groff&#8217;s <kbd>\D</kbd> escapes.
139 </p>
140 </div>
141
142 <h3 id="behaviour" class="docs">Graphical object behaviour</h3>
143
144 <p>
145 Mom&#8217;s graphical object macros all behave in the following,
146 carved-in-stone ways:
147 </p>
148 <ol style="margin-top: -.5em; margin-bottom: -.5em;">
149    <li>Objects are drawn from the
150        <a href="definitions.html#baseline">baseline</a>
151        down, including horizontal rules.</li>
152    <li>Objects begin precisely at the left indent supplied as
153        an argument to the macro.</li>
154    <li>Objects are drawn from left to right.</li>
155    <li>Enclosed objects (boxes, circles) are drawn from the
156        perimeter <i>inward</i>.</li>
157    <li>Objects return to their horizontal/vertical point of origin.</li>
158 </ol>
159
160 <p>
161 The consistency means that once you've mastered the very simple
162 order of arguments that applies to invoking graphical object
163 macros, you can draw objects with full confidence that you know
164 exactly where they&#8217;re placed and how much room they
165 occupy.  Furthermore, because all return to their point of origin,
166 you&#8217;ll know exactly where you are on the page.
167 </p>
168
169 <h3 id="order" class="docs">Order of arguments</h3>
170
171 <p>
172 The order of arguments to the graphical object macros is the same
173 for every macro:
174 </p>
175 <ul style="margin-top: -.5em; margin-bottom: -.5em;">
176   <li>the <kbd><span style="text-decoration: underline">W</span></kbd>eight of the rule
177   <ul style="margin-left: -.75em;">
178     <li>if the object is enclosed (i.e. is a box or circle), the
179         weight of the rule if you want the object outlined</li>
180     <li>the single word, <kbd>SOLID</kbd>, may be used in place
181         of the <b>weight</b> argument if you want the
182         object filled</li>
183   </ul></li>
184   <li>the <kbd><span style="text-decoration: underline">I</span></kbd>ndent from the current left margin at
185       which to begin the object</li>
186   <li>the <kbd><span style="text-decoration: underline">L</span></kbd>ength of the object, if applicable</li>
187   <li>the <kbd><span style="text-decoration: underline">D</span></kbd>epth of the object, if applicable</li>
188   <li>the <kbd><span style="text-decoration: underline">C</span></kbd>olour of the object (optional)</li>
189 </ul>
190
191 <p>
192 A simple mnemonic for the order of arguments is &#8220;<b>WILD
193 C</b>ard&#8221;.  If you fix the mnemonic in your brain and apply
194 a little judicious reasoning, you&#8217;ll always remember how to
195 draw graphical objects.  The &#8220;judicious reasoning&#8221; means
196 that, for example, horizontal rules don&#8217;t require a depth and
197 vertical rules don&#8217;t require a length.  Thus, in the case of
198 drawing a horizontal rule, you supply the macro
199 <kbd><a href="#drh">DRH</a></kbd>
200 with only the arguments (from the mnemonic) that apply: <b>W-I-L</b> (and
201 possibly <b>C</b>).
202 </p>
203
204 <div class="macro-list-container">
205 <h3 id="index-graphical" class="macro-list">Graphical objects macros</h3>
206
207 <ul class="macro-list">
208   <li><a href="#drh">DRH</a>
209       &ndash; horizontal rules</li>
210   <li><a href="#drv">DRV</a>
211       &ndash; vertical rules</li>
212   <li><a href="#dbx">DBX</a>
213       &ndash; box</li>
214   <li><a href="#dcl">DCL</a>
215       &ndash; circles or ellipses</li>
216 </ul>
217 </div>
218
219 <!-- -DRH- -->
220
221 <div class="macro-id-overline">
222 <h3 id="drh" class="macro-id">Drawing horizontal rules</h3>
223 </div>
224
225 <div class="box-macro-args">
226 Macro: <b>DRH</b> <kbd class="macro-args">&lt;none&gt; | &lt;weight&gt;  &lt;indent&gt; &lt;length&gt; [&lt;colour&gt;]</kbd>
227 </div>
228
229 <p class="requires">
230 &bull;&nbsp;
231 the argument to <kbd class="normal">&lt;weight&gt;</kbd> is in
232 <a href="definitions.html#picaspoints" class="normal">points</a>,
233 but do <span class="normal">NOT</span> append the
234 <a href="definitions.html#unitsofmeasure">unit of measure</a>,
235 <kbd class="normal">p</kbd>
236 <br/>
237 &bull;&nbsp;
238 <kbd class="normal">&lt;indent&gt;</kbd>
239 and
240 <kbd class="normal">&lt;length&gt;</kbd>
241 require a unit of measure
242 <br/>
243 &bull;&nbsp;
244 arithmetic expressions to
245 <kbd class="normal">&lt;indent&gt;</kbd>
246 and
247 <kbd class="normal">&lt;length&gt;</kbd>
248 must be surrounded by parentheses
249 </p>
250
251 <p>
252 If all you want is to draw a rule from your current left
253 margin to your current right margin (in other words, a &quot;full
254 measure&quot; rule), you may invoke <kbd>.DRH</kbd> without any
255 arguments.
256 </p>
257 <div class="box-tip">
258 <p class="tip">
259 <span class="note">Note:</span>
260 DRH is the only graphical object macro that may be invoked
261 without arguments.  The weight (&#8220;thickness&#8221;) of
262 the rule is determined by the argument you last gave the
263 macro
264 <a href="inlines.html#rule-weight">RULE_WEIGHT</a>.
265 DRH, used this way, is exactly equivalent to entering the
266 <a href="definitions.html#inlines">inline escape</a>, <a
267 href="inlines.html#inline-rule-mom"><kbd>\*[RULE]</kbd></a>.
268 </p>
269 </div>
270
271 <p style="margin-top: -.5em;">
272 To draw horizontal rules of a specified length, you must, at
273 a minimum, supply DRH with the arguments <kbd>weight,</kbd>
274 <kbd>indent</kbd> (measured from the current left margin) and
275 <kbd>length</kbd>.
276 </p>
277
278 <p>
279 Optionally, you may give a <kbd>colour</kbd> argument.  The colour
280 may be either one defined with
281 <a href="color.html#newcolor">NEWCOLOR</a>,
282 or a named X-colour inititialized with
283 <a href="color.html#xcolor">XCOLOR</a>,
284 or an X-colour alias (again, initialized with XCOLOR).
285 </p>
286
287 <p>
288 Say, for example, you want to draw a 1-1/4 point horizontal rule
289 that starts 2 picas from the current left margin and runs for 3
290 inches.  To do so, you'd invoke <kbd>.DRH</kbd> like this:
291 <br/>
292 <span class="pre-in-pp">
293       weight  length
294          |      |
295   .DRH 1.25 2P 3i
296             |
297           indent
298 </span>
299 (Note that the rule weight argument, which is expressed in points,
300 must NOT have the unit of measure <kbd>p</kbd> appended to it.)
301 </p>
302
303 <p>
304 If, in addition, you want the rule blue:
305 <br/>
306 <span class="pre-in-pp">
307   .DRH 1.25 2P 3i blue
308 </span>
309 </p>
310
311 <h3 class="docs">How mom handles the positioning of horizontal rules</h3>
312
313 <p>
314 Horizontal rules are drawn from left to right, and from the baseline
315 down. &#8220;From the baseline down&#8221; means that if you request
316 a rule with a weight of four points, the four points of rule fall
317 entirely below the baseline.
318 </p>
319
320 <p>
321 Furthermore, after the rule is drawn, mom returns you to the current
322 left margin, at the same vertical position on the page as when DRH
323 was invoked.  In other words, DRH causes no movement on the page,
324 either horizontal or vertical.
325 </p>
326
327 <!-- -DRV- -->
328
329 <div class="macro-id-overline">
330 <h3 id="drv" class="macro-id">Drawing vertical rules</h3>
331 </div>
332
333 <div class="box-macro-args">
334 Macro: <b>DRV</b> <kbd class="macro-args">&lt;weight&gt;  &lt;indent&gt; &lt;depth&gt; [&lt;colour&gt;]</kbd>
335 </div>
336
337 <p class="requires">
338 &bull;&nbsp;
339 the argument to <kbd class="normal">&lt;weight&gt;</kbd> is in
340 <a href="definitions.html#picaspoints" class="normal">points</a>,
341 but do <span class="normal">NOT</span> append the
342 <a href="definitions.html#unitsofmeasure">unit of measure</a>,
343 <kbd class="normal">p</kbd>
344 <br/>
345 &bull;&nbsp;
346 <kbd class="normal">&lt;indent&gt;</kbd>
347 and
348 <kbd class="normal">&lt;depth&gt;</kbd>
349 require a unit of measure
350 <br/>
351 &bull;&nbsp;
352 arithmetic expressions to
353 <kbd class="normal">&lt;indent&gt;</kbd>
354 and
355 <kbd class="normal">&lt;depth&gt;</kbd>
356 must be surrounded by parentheses
357 </p>
358
359 <p>
360 To draw vertical rules of a specified length, you must, at
361 a minimum, supply DRV with the arguments <kbd>weight,</kbd>
362 <kbd>indent</kbd> (measured from the current left margin) and
363 <kbd>depth</kbd>.
364 </p>
365
366 <p>
367 Optionally, you may give a <kbd>colour</kbd> argument.  The colour
368 may be either one defined with
369 <a href="color.html#newcolor">NEWCOLOR</a>,
370 or a named X-colour inititialized with
371 <a href="color.html#xcolor">XCOLOR</a>,
372 or an X-colour alias (again, initialized with XCOLOR).
373 </p>
374
375 <p>
376 Say, for example, you want to draw a 3/4-point vertical rule that
377 starts 19-1/2 picas from the current left margin and has a depth of
378 6 centimeters.  To do so, you'd invoke <kbd>.DRV</kbd> like this:
379 <br/>
380 <span class="pre-in-pp">
381        weight   depth
382          |        |
383   .DRV .75 19P+6p 6c
384              |
385            indent
386 </span>
387 (Note that the rule weight argument, which is expressed in points,
388 must NOT have the unit of measure <kbd>p</kbd> appended to it.)
389 </p>
390
391 <p>
392 If, in addition, you want the rule red:
393 <br/>
394 <span class="pre-in-pp">
395   .DRV .75 19P+6p 6c red
396 </span>
397 </p>
398
399 <h3 class="docs">How mom handles the positioning of vertical rules</h3>
400
401 <p>
402 Vertical rules are drawn from the baseline down, and from left to
403 right. &quot;Left to right&quot; means that if you request a rule
404 with a weight of four points, the four points of rule fall entirely
405 to the left of the indent given to DRV.
406 </p>
407
408 <p>
409 Furthermore, after the rule is drawn, mom returns you to the current
410 left margin, at the same vertical position on the page as when DRV
411 was invoked.  In other words, DRV causes no movement on the page,
412 either horizontal or vertical.
413 </p>
414
415 <!-- -DBX- -->
416
417 <div class="macro-id-overline">
418 <h3 id="dbx" class="macro-id">Drawing boxes</h3>
419 </div>
420
421 <div class="box-macro-args">
422 Macro: <b>DBX</b> <kbd class="macro-args">&lt; &lt;weight&gt; | SOLID &gt; &lt;indent&gt; &lt;length&gt; &lt;depth&gt; [&lt;colour&gt;]</kbd>
423 </div>
424
425 <p class="requires">
426 &bull;&nbsp;
427 the argument to <kbd class="normal">&lt;weight&gt;</kbd> is in
428 <a href="definitions.html#picaspoints" class="normal">points</a>,
429 but do <span class="normal">NOT</span> append the
430 <a href="definitions.html#unitsofmeasure">unit of measure</a>
431 <kbd class="normal">p</kbd>
432 <br/>
433 &bull;&nbsp;<kbd class="normal">&lt;indent&gt;</kbd>,
434 <kbd class="normal">&lt;length&gt;</kbd>,
435 and
436 <kbd class="normal">&lt;depth&gt;</kbd>
437 require a unit of measure
438 <br/>
439 &bull;&nbsp;
440 arithmetic expressions to
441 <kbd class="normal">&lt;indent&gt;</kbd>,
442 <kbd class="normal">&lt;length&gt;</kbd>,
443 and
444 <kbd class="normal">&lt;depth&gt;</kbd>
445 must be surrounded by parentheses
446 </p>
447
448 <p>
449 To draw boxes of specified dimensions, you must, at a minimum,
450 supply DBX with the arguments <kbd>weight</kbd> or <kbd>SOLID</kbd>,
451 <kbd>indent</kbd> (measured from the current left margin),
452 <kbd>length</kbd> and <kbd>depth</kbd>.
453 </p>
454
455 <p>
456 Optionally, you may give a <kbd>colour</kbd> argument.  The colour
457 may be either one defined with
458 <a href="color.html#newcolor">NEWCOLOR</a>,
459 or a named X-colour inititialized with
460 <a href="color.html#xcolor">XCOLOR</a>,
461 or an X-colour alias (again, initialized with XCOLOR).
462 </p>
463
464 <p>
465 Say, for example, you want to draw a 1/2 point outline box that
466 starts one inch from the current left margin and has the dimensions 
467 12 picas x 6 picas.  To do so, you'd invoke <kbd>.DBX</kbd> like this:
468 <br/>
469 <span class="pre-in-pp">
470          indent   depth
471            |        |
472   .DBX .5  1i  12P  6P
473         |       |
474      weight   length
475 </span>
476 (Note that the box weight argument, which is expressed in points,
477 must NOT have the unit of measure <kbd>p</kbd> appended to it.)
478 </p>
479
480 <p>
481 If you want the same box, but solid (&#8220;filled&#8221;) rather
482 than drawn as an outline:
483 <br/>
484 <span class="pre-in-pp">
485   .DBX SOLID 1i 12P 6P
486 </span>
487 Additionally, if you want the box green:
488 <br/>
489 <span class="pre-in-pp">
490   .DBX .5 1i 12P 6P green
491    or
492   .DBX SOLID 1i 12P 6P green
493 </span>
494 </p>
495
496 <h3 class="docs">How mom handles the positioning of boxes</h3>
497
498 <p>
499 Boxes are drawn from the baseline down, from left to right, and
500 from the perimeter <i>inward</i>. &#8220;From the perimeter
501 inward&#8221; means that if you request a box weight of six points,
502 the 6-point rules used to draw the outline of the box fall entirely
503 <i>within</i> the dimensions of the box.
504 </p>
505
506 <p>
507 Furthermore, after the box is drawn, mom returns you to the current
508 left margin, at the same vertical position on the page as when DBX
509 was invoked.  In other words, DBX causes no movement on the page,
510 either horizontal or vertical.
511 </p>
512
513 <!-- -DCL- -->
514
515 <div class="macro-id-overline">
516 <h3 id="dcl" class="macro-id">Drawing circles (ellipses)</h3>
517 </div>
518
519 <div class="box-macro-args">
520 Macro: <b>DCL</b> <kbd class="macro-args">&lt; &lt;weight&gt; | SOLID &gt; &lt;indent&gt; &lt;length&gt; &lt;depth&gt; [&lt;colour&gt;]</kbd>
521 </div>
522
523 <p class="requires">
524 &bull;&nbsp;the argument to <kbd class="normal">&lt;weight&gt;</kbd> is in
525 <a href="definitions.html#picaspoints" class="normal">points</a>,
526 but do <span class="normal">NOT</span> append the
527 <a href="definitions.html#unitsofmeasure">unit of measure</a>,
528 <kbd class="normal">p</kbd>
529 <br/>
530 &bull;&nbsp;
531 the arguments
532 <kbd class="normal">&lt;indent&gt;</kbd>,
533 <kbd class="normal">&lt;length&gt;</kbd>
534 and
535 <kbd class="normal">&lt;depth&gt;</kbd>
536 require a unit of measure
537 <br/>
538 &bull;&nbsp;
539 arithmetic expressions to
540 <kbd class="normal">&lt;indent&gt;</kbd>,
541 <kbd class="normal">&lt;length&gt;</kbd>
542 and
543 <kbd class="normal">&lt;depth&gt;</kbd>
544 must be surrounded by parentheses
545 </p>
546
547 <p>
548 To draw circles of specified dimensions, you must, at a minimum,
549 supply DCL with the arguments <kbd>weight</kbd> or <kbd>SOLID</kbd>,
550 <kbd>indent</kbd> (measured from the current left margin),
551 <kbd>length</kbd> and <kbd>depth</kbd>.
552 </p>
553
554 <p>
555 Optionally, you may give a <kbd>colour</kbd> argument.  The colour
556 may be either one defined with
557 <a href="color.html#newcolor">NEWCOLOR</a>,
558 or a named X-colour inititialized with
559 <a href="color.html#xcolor">XCOLOR</a>,
560 or an X-colour alias (again, initialized with XCOLOR).
561 </p>
562
563 <p>
564 Say, for example, you want to draw a 1/2 point outline circle
565 (ellipse, actually, in this case) that starts one inch from the
566 current left margin and has the dimensions 6 centimeters x 3
567 centimeters.  To do so, you'd invoke <kbd>.DCL</kbd> like this:
568 <br/>
569 <span class="pre-in-pp">
570          indent  depth
571            |       |
572   .DCL .5  1i  6c  3c
573         |      |
574      weight  length
575 </span>
576 (Note that the box weight argument, which is expressed in points,
577 must NOT have the unit of measure <kbd>p</kbd> appended to it.)
578 </p>
579
580 <p>
581 If you want the same box, but solid (&#8220;filled&#8221;) rather
582 than drawn as an outline:
583 <br/>
584 <span class="pre-in-pp">
585   .DCL SOLID 1i 6c 3c
586 </span>
587 Additionally, if you want the circle yellow:
588 <br/>
589 <span class="pre-in-pp">
590   .DCL .5 1i 6c 3c yellow
591    or
592   .DCL SOLID 1i 6c 3c yellow
593 </span>
594 </p>
595
596 <h3 class="docs">How mom handles the positioning of circles (ellipses)</h3>
597
598 <p>
599 Circles (ellipses) are drawn from the baseline down, from left
600 to right, and from the perimeter <i>inward</i>. &#8220;From the
601 perimeter inward&#8221; means that if you request a circle weight of
602 six points, the 6-point rule used to draw the outline of the circle
603 or ellipse falls entirely <i>within</i> the dimensions of the
604 circle or ellipse.
605 </p>
606
607 <p>
608 Furthermore, after the circle is drawn, mom returns you to the
609 current left margin, at the same vertical position on the page as
610 when DCL was invoked.  In other words, DCL causes no movement on the
611 page, either horizontal or vertical.
612 </p>
613
614 <div class="rule-long"><hr/></div>
615
616 <!-- Navigation links -->
617 <table style="width: 100%; margin-top: 12px;">
618 <tr>
619   <td style="width: 33%;"><a href="toc.html">Back to Table of Contents</a></td>
620   <td style="width: 33%; text-align: center;"><a href="#top">Top</a></td>
621   <td style="width: 33%; text-align: right;"><a href="docprocessing.html#top">Next: Document processing</a></td>
622 </tr>
623 </table>
624
625 </div>
626
627 <div class="bottom-spacer"><br/></div>
628
629 </body>
630 </html>