summaryrefslogtreecommitdiff
path: root/contrib/mom/momdoc/graphical.html
blob: a622a0fb55811cd2d31b8ada868a1078a2ce0b14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
<?xml version="1.0" encoding="iso-8859-1"?>
<!--
This file is part of groff, the GNU roff type-setting system.

Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
Written by Peter Schaffter.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1 or
any later version published by the Free Software Foundation; with the
Invariant Sections being this comment section, with no Front-Cover
Texts, and with no Back-Cover Texts.

A copy of the Free Documentation License is included as a file called
FDL in the main directory of the groff source package.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1"/>
<title>Mom -- Graphical Objects</title>
</head>
<body bgcolor="#dfdfdf">

<!-- ==================================================================== -->

<a name="TOP"></a>

<p>
<a href="docprocessing.html#TOP">Next</a>&nbsp;&nbsp;
<a href="color.html#TOP">Prev</a>&nbsp;&nbsp;
<a href="toc.html">Back to Table of Contents</a>
</p>

<h1 align="center"><a name="COLOR_INTRO"><u>Graphical objects</u></a></h1>

<p>
<a href="#INTRO_GRAPHICAL">Introduction to graphical objects</a>

<ul>
    <li><a href="#BEHAVIOUR">Graphical object behaviour</a></li>
    <li><a href="#ORDER">Order of arguments</a></li>
</ul>

<a href="#MACROS_GRAPHICAL">Index of graphical object macros</a>
</p>

<a name="INTRO_GRAPHICAL"><h2><u>Introduction to graphical objects</u></h2></a>

<p>
<strong>Groff</strong> has a number of
<a href="definitions.html#TERMS_INLINES">inline escapes</a>
for drawing rules, polygons, ellipses and splines.  All begin with
<kbd>\D</kbd> (presumably for &quot;Draw&quot;) and are documented
in the <strong>groff</strong> info manual:

<pre>
    info groff => Escape index => \D
</pre>
</p>

<p>
The escapes allow you to draw just about any simple graphical object
you can think of, but owing to their syntax, they're not always easy
to read, which can make tweaking them difficult.  Additionally,
while they perform in a <em>consistent</em> manner, they don't
always perform in an <em>expected</em> manner.
</p>

<p>
Experience shows that the most common graphical elements typesetters
need are rules (horizontal and vertical), boxes, and circles (or
ellipses).  For this reason, <strong>mom</strong> provides macros
to draw these objects in an easy-to-understand way; the results are
predictable, and <strong>mom</strong>'s syntax makes fixes or tweaks
painless.
</p>

<a name="GRAPHICAL_EXAMPLE"></a>

<p>
For example, if you want to draw a 2-inch square outline box at the left
margin using <strong>groff</strong>'s <kbd>\D</kbd> escapes, it looks like this:

<pre>
              back up
                by
               weight
             +-------+
             |       |
    \D't 500'\h'-500u'\D'p 2i 0 0 2i -2i 0 0 -2i'
   |       |          |                        |
   +-------+          +------------------------+
    set rule          draw box, 1 line at a time
     weight
</pre>

Obviously, this isn't very efficient for something as simple as a
box.
</p>

<p>
Here's the same box, drawn with <strong>mom</strong>'s box drawing
macro,
<a href="#DBX">DBX</a>:

<pre>
left margin indent-+  +-box width
                   |  |
          .DBX .5  0  2i  2i
                |         |
   rule weight--+         +-box depth
   (in points)
</pre>
</p>

<p>
<strong>Mom</strong>'s graphical object macros allow &mdash; in fact,
require &mdash; giving the rule weight (&quot;thickness&quot;) for the
object (or saying that you want it filled), an indent from the left
margin where the object begins, the dimensions of the object, and
optionally a colour for the object.
</p>

<p>
There are no defaults for the arguments to <strong>mom</strong>'a
graphical object macros, which means you must supply the arguments
every time you invoke them.
</p>

<p>
<strong>NOTE:</strong> As stated above, <strong>mom</strong> only
provides macros for commonly-used graphical objects (rules, boxes,
circles) only.  More complex objects (polygons, non-straight lines,
splines) must be drawn using <strong>groff</strong>'s <kbd>\D</kbd>
escapes.
</p>

<a name="BEHAVIOUR"><h3><u>Graphical object behaviour</u></h3></a>

<p>
<strong>Mom</strong>'s graphical object macros all behave in the
following, carved-in-stone ways:

<ol>
     <li>Objects are drawn from the
         <a href="definitions.html#TERMS_BASELINE">baseline</a>
         down, including horizontal rules.</li>
     <li>Objects begin precisely at the left indent supplied as
         an argument to the macro.</li>
     <li>Objects are drawn from left to right.</li>
     <li>Enclosed objects (boxes, circles) are drawn from the
         perimeter <em>inward</em>.</li>
     <li>Objects return to their horizontal/vertical point of origin.</li>
</ol>

The consistency means that once you've mastered the very simple
order of arguments that applies to invoking graphical object
macros, you can draw objects with full confidence that you know
exactly where they're placed and how much room they occupy.
Furthermore, because all return to their point of origin, you'll
know exactly where you are on the page.
</p>

<a name="ORDER"><h3><u>Order of arguments</u></h3></a>

<p>
The order of arguments to the graphical object macros is the same
for every macro:

<ul>
    <li>the <strong>Weight</strong> of the rule</li>
    <ul>
        <li>if the object is enclosed (i.e. is a box or circle), the
            weight of the rule if you want the object outlined</li>
        <li>the single word <kbd>SOLID</kbd> may be used in place
            of the <strong>weight</strong> argument if you want the
            object filled</li>
    </ul>
    <li>the <strong>Indent</strong> from the current left margin at
        which to begin the object</li>
    <li>the <strong>Length</strong> of the object, if applicable</li>
    <li>the <strong>Depth</strong> of the object, if applicable</li>
    <li>the <strong>Colour</strong> of the object (optional)</li>
</ul>
</p>

<p>
A simple mnemonic for the order of arguments is &quot;WILD C&quot;.
If you fix the mnemonic in your brain and apply a little judicious
reasoning, you'll always remember how to draw graphical objects.
The &quot;judicious reasoning&quot; means that, for example,
horizontal rules don't require a depth and vertical rules don't
require a length.  Thus, in the case of drawing a horizontal rule,
you supply the macro,
<a href="#DRH">DRH</a>,
with only the arguments (from the mnemonic) that apply: W-I-L (and
possibly C).
</p>

<a name="MACROS_GRAPHICAL"><h3><u>Index of graphical object macros</u></h3></a>

<ul>
    <li><a href="#DRH">DRH</a>
        &mdash; horizontal rule</li>
    <li><a href="#DRV">DRV</a>
        &mdash; vertical rule</li>
    <li><a href="#DBX">DBX</a>
        &mdash; box</li>
    <li><a href="#DCL">DCL</a>
        &mdash; circle or ellipse</li>
</ul>

<!-- -DRH- -->

<hr width="66%" align="left"/>

<a name="DRH"><h3><u>Drawing horizontal rules</u></h3></a>

<p>
<nobr>Macro: <strong>DRH</strong> <kbd>&lt;none&gt; | &lt;rule weight&gt;  &lt;indent&gt; &lt;length&gt; [&lt;colour&gt;]</kbd></nobr>
<br/>

<em>*The argument to</em> <kbd>&lt;rule weight&gt;</kbd> <em>is
in</em>
<a href="definitions.html#TERMS_PICASPOINTS">points</a>,
<em>but do </em> NOT <em>append the</em>
<a href="definitions.html#TERMS_UNITSOFMEASURE">unit of
measure</a>, <kbd>p</kbd>.
<br/>

<em>*The arguments,</em> <kbd>&lt;indent&gt;</kbd> <em>and</em>
<kbd>&lt;length&gt;</kbd>, <em>require a unit of measure.</em>
</p>

<p>
If all you want is to draw a rule from your current left
margin to your current right margin (in other words, a &quot;full
measure&quot; rule), you may invoke <kbd>.DRH</kbd> without any
arguments.  (Note that <strong>DRH</strong> is the only graphical
object macro that may be invoked without arguments.)  The weight of
the rule is determined by the argument you last gave the macro,
<a href="inlines.html#RULE_WEIGHT">RULE_WEIGHT</a>.
<strong>DRH</strong>, used this way, is exactly equivalent to
entering the
<a href="definitions.html#TERMS_INLINES">inline escape</a>,
<a href="inlines.html#INLINE_RULE_MOM"><kbd>\*[RULE]</kbd></a>.
</p>

<p>
To draw horizontal rules of a specified length, you must, at a
minimum, supply
<strong>DRH</strong> with the arguments
<kbd><nobr>rule weight,</nobr> indent</kbd> (measured from the
current left margin) and <kbd>length</kbd>.
</p>

<p>
Optionally, you may give a <kbd>colour</kbd> argument.
The colour may be either one defined with
<a href="color.html#NEWCOLOR">NEWCOLOR</a>,
or a named X-colour inititialized with
<a href="color.html#XCOLOR">XCOLOR</a>,
or an X-colour alias (again, initialized with
<strong>XCOLOR</strong>).
</p>

<p>
Say, for example, you want to draw a 1-1/4 point horizontal rule
that starts 2 picas from the current left margin and runs for 3
inches.  To do so, you'd invoke <kbd>.DRH</kbd> like this:

<pre>
         weight length
           |      |
    .DRH 1.125 2P 3i
               |
             indent
</pre>

(Note that the rule weight argument, which is expressed in points,
must NOT have the unit of measure <kbd>p</kbd> appended to it.)
</p>

<p>
If, in addition, you want the rule blue:

<pre>
    .DRH 1.125 2P 3i blue
</pre>
</p>

<h3><u>How mom handles the positioning of horizontal rules</u></h3>

<p>
Horizontal rules are drawn from left to right, and from the baseline
down. &quot;From the baseline down&quot; means that if you request
a rule with a weight of four points, the four points of rule fall
entirely below the baseline.
</p>

<p>
Furthermore, after the rule is drawn, <strong>mom</strong> returns
you to the current left margin, at the same vertical position on
the page as when <strong>DRH</strong> was invoked.  In other words,
<strong>DRH</strong> causes no movement on the page, either
horizontal or vertical.
</p>

<!-- -DRV- -->

<hr width="33%" align="left"/>

<a name="DRV"><h3><u>Drawing vertical rules</u></h3></a>

<p>
<nobr>Macro: <strong>DRV</strong> <kbd>&lt;rule weight&gt;  &lt;indent&gt; &lt;depth&gt; [&lt;colour&gt;]</kbd></nobr>
<br/>

<em>*The argument to</em> <kbd>&lt;rule weight&gt;</kbd> <em>is
in</em>
<a href="definitions.html#TERMS_PICASPOINTS">points</a>,
<em>but do </em> NOT <em>append the</em>
<a href="definitions.html#TERMS_UNITSOFMEASURE">unit of
measure</a>, <kbd>p</kbd>.
<br/>

<em>*The arguments,</em> <kbd>&lt;indent&gt;</kbd> <em>and</em>
<kbd>&lt;depth&gt;</kbd>, <em>require a unit of measure.</em>
</p>

<p>
To draw vertical rules of a specified length, you must, at a
minimum, supply
<strong>DRV</strong> with the arguments
<kbd><nobr>rule weight,</nobr> indent</kbd> (measured from the
current left margin) and <kbd>depth</kbd>.
</p>

<p>
Optionally, you may give a <kbd>colour</kbd> argument.
The colour may be either one defined with
<a href="color.html#NEWCOLOR">NEWCOLOR</a>,
or a named X-colour inititialized with
<a href="color.html#XCOLOR">XCOLOR</a>,
or an X-colour alias (again, initialized with
<strong>XCOLOR</strong>).
</p>

<p>
Say, for example, you want to draw a 3/4-point vertical rule that
starts 19-1/2 picas from the current left margin and has a depth of
6 centimeters.  To do so, you'd invoke <kbd>.DRV</kbd> like this:

<pre>
         weight   depth
           |        |
    .DRV .75 19P+6p 6c
               |
             indent
</pre>

(Note that the rule weight argument, which is expressed in points,
must NOT have the unit of measure <kbd>p</kbd> appended to it.)
</p>

<p>
If, in addition, you want the rule red:

<pre>
    .DRV .75 19P+6p 6c red
</pre>
</p>

<h3><u>How mom handles the positioning of vertical rules</u></h3>

<p>
Vertical rules are drawn from the baseline down, and from left to
right. &quot;Left to right&quot; means that if you request a rule
with a weight of four points, the four points of rule fall entirely
to the left of the indent given to <strong>DRV</strong>.
</p>

<p>
Furthermore, after the rule is drawn, <strong>mom</strong> returns
you to the current left margin, at the same vertical position
on the page as when <strong>DRV</strong> was invoked.  In other
words, <strong>DRV</strong> causes no movement on the page, either
horizontal or vertical.
</p>

<!-- -DBX- -->

<hr width="33%" align="left"/>

<a name="DBX"><h3><u>Drawing boxes</u></h3></a>

<p>
<nobr>Macro: <strong>DBX</strong> <kbd>&lt; &lt;rule weight&gt; | SOLID &gt; &lt;indent&gt; &lt;length&gt; &lt;depth&gt; [&lt;colour&gt;]</kbd></nobr>
<br/>

<em>*The argument to</em> <kbd>&lt;rule weight&gt;</kbd> <em>is
in</em>
<a href="definitions.html#TERMS_PICASPOINTS">points</a>,
<em>but do </em> NOT <em>append the</em>
<a href="definitions.html#TERMS_UNITSOFMEASURE">unit of
measure</a>, <kbd>p</kbd>.
<br/>

<em>*The arguments,</em> <kbd>&lt;indent&gt;</kbd><em>,</em>
<kbd>&lt;length&gt;</kbd> <em>and</em> <kbd>&lt;depth&gt;</kbd>
<em>require a unit of measure.</em>
</p>

<p>
To draw boxes of specified dimensions, you must, at a minimum,
supply <strong>DBX</strong> with the arguments <kbd><nobr>rule
weight</nobr></kbd> or <kbd>SOLID</kbd>, <kbd>indent</kbd>
(measured from the current left margin), <kbd>length</kbd> and
<kbd>depth</kbd>.
</p>

<p>
Optionally, you may give a <kbd>colour</kbd> argument.
The colour may be either one defined with
<a href="color.html#NEWCOLOR">NEWCOLOR</a>,
or a named X-colour inititialized with
<a href="color.html#XCOLOR">XCOLOR</a>,
or an X-colour alias (again, initialized with
<strong>XCOLOR</strong>).
</p>

<p>
Say, for example, you want to draw a 1/2 point outline box that
starts one inch from the current left margin and has the dimensions 
12 picas x 6 picas.  To do so, you'd invoke <kbd>.DBX</kbd> like this:

<pre>
           indent   depth
             |        |
    .DBX .5  1i  12P  6P
          |       |
       weight   length
</pre>

(Note that the box weight argument, which is expressed in points,
must NOT have the unit of measure <kbd>p</kbd> appended to it.)
</p>

If you want the same box, but solid (&quot;filled&quot;) rather
than drawn as an outline:

<pre>
    .DBX SOLID 1i 12P 6P
</pre>

<p>
Additionally, if you want the box green:

<pre>
    .DBX .5 1i 12P 6P green
     or
    .DBX SOLID 1i 12P 6P green
</pre>
</p>

<h3><u>How mom handles the positioning of boxes</u></h3>

<p>
Boxes are drawn from the baseline down, from left to right, and
from the perimeter <em>inward</em>. &quot;From the perimeter
inward&quot; means that if you request a box weight of six points,
the 6-point rules used to draw the outline of the box fall entirely
<em>within</em> the dimensions of the box.
</p>

<p>
Furthermore, after the box is drawn, <strong>mom</strong> returns
you to the current left margin, at the same vertical position
on the page as when <strong>DBX</strong> was invoked.  In other
words, <strong>DBX</strong> causes no movement on the page, either
horizontal or vertical.
</p>

<!-- -DCL- -->

<hr width="33%" align="left"/>

<a name="DCL"><h3><u>Drawing circles (ellipses)</u></h3></a>

<p>
<nobr>Macro: <strong>DCL</strong> <kbd>&lt; &lt;rule weight&gt; | SOLID &gt; &lt;indent&gt; &lt;length&gt; &lt;depth&gt; [&lt;colour&gt;]</kbd></nobr>
<br/>

<em>*The argument to</em> <kbd>&lt;rule weight&gt;</kbd> <em>is
in</em>
<a href="definitions.html#TERMS_PICASPOINTS">points</a>,
<em>but do </em> NOT <em>append the</em>
<a href="definitions.html#TERMS_UNITSOFMEASURE">unit of
measure</a>, <kbd>p</kbd>.
<br/>

<em>*The arguments,</em> <kbd>&lt;indent&gt;</kbd><em>,</em>
<kbd>&lt;length&gt;</kbd> <em>and</em> <kbd>&lt;depth&gt;</kbd>
<em>require a unit of measure.</em>
</p>

<p>
To draw circles of specified dimensions, you must, at a minimum,
supply <strong>DCL</strong> with the arguments <kbd><nobr>rule
weight</nobr></kbd> or <kbd>SOLID</kbd>, <kbd>indent</kbd>
(measured from the current left margin), <kbd>length</kbd> and
<kbd>depth</kbd>.
</p>

<p>
Optionally, you may give a <kbd>colour</kbd> argument.
The colour may be either one defined with
<a href="color.html#NEWCOLOR">NEWCOLOR</a>,
or a named X-colour inititialized with
<a href="color.html#XCOLOR">XCOLOR</a>,
or an X-colour alias (again, initialized with
<strong>XCOLOR</strong>).
</p>

<p>
Say, for example, you want to draw a 1/2 point outline circle
(ellipse, actually, in this case) that starts one inch from the
current left margin and has the dimensions 6 centimeters x 3
centimeters.  To do so, you'd invoke <kbd>.DCL</kbd> like this:

<pre>
           indent  depth
             |       |
    .DCL .5  1i  6c  3c
          |      |
       weight   ength
</pre>

(Note that the box weight argument, which is expressed in points,
must NOT have the unit of measure <kbd>p</kbd> appended to it.)
</p>

If you want the same box, but solid (&quot;filled&quot;) rather
than drawn as an outline:

<pre>
    .DCL SOLID 1i 6c 3c
</pre>

<p>
Additionally, if you want the circle yellow:

<pre>
    .DCL .5 1i 6c 3c yellow
     or
    .DCL SOLID 1i 6c 3c yellow
</pre>
</p>

<h3><u>How mom handles the positioning of circles (ellipses)</u></h3>

<p>
Circles (ellipses) are drawn from the baseline down, from left
to right, and from the perimeter <em>inward</em>. &quot;From the
perimeter inward&quot; means that if you request a box weight of six
points, the 6-point rule used to draw the outline of the circle or
ellipse falls entirely <em>within</em> the dimensions of the circle
or ellipse.
</p>

<p>
Furthermore, after the circle is drawn, <strong>mom</strong> returns
you to the current left margin, at the same vertical position
on the page as when <strong>DCL</strong> was invoked.  In other
words, <strong>DCL</strong> causes no movement on the page, either
horizontal or vertical.
</p>

<hr/>

<p>
<a href="docprocessing.html#TOP">Next</a>&nbsp;&nbsp;
<a href="color.html#TOP">Prev</a>&nbsp;&nbsp;
<a href="#TOP">Top</a>&nbsp;&nbsp;
<a href="toc.html">Back to Table of Contents</a>
</p>

</body>
</html>

<!-- vim: fileencoding=latin1: nomodified:
-->