1 <?xml version="1.0" encoding="utf-8"?>
3 This file is part of groff, the GNU roff type-setting system.
5 Copyright (C) 2004-2018 Free Software Foundation, Inc.
6 Written by Peter Schaffter (peter@schaffter.ca).
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
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.
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">
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" />
27 <body style="background-color: #f5faff;">
29 <!-- ==================================================================== -->
31 <div id="top" class="page">
33 <!-- Navigation links -->
34 <table style="width: 100%;">
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>
41 <h1 class="docs">Graphical objects</h1>
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>
52 <div class="rule-medium"><hr/></div>
54 <h2 id="intro-graphical" class="docs">Introduction to graphical objects</h2>
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 “Draw”) and are documented
61 in the groff info manual:
63 <span class="pre-in-pp">
64 info groff => Escape index => \D
66 The escapes allow you to draw just about any simple graphical object
67 you can think of, but owing to their syntax, they’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’t
70 always perform in an <i>expected</i> manner.
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’s syntax makes fixes or tweaks
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’s <kbd>\D</kbd> escapes, it looks like this:
86 <span class="pre-in-pp">
92 \D't 500'\h'-500u'\D'p 2i 0 0 2i -2i 0 0 -2i'
94 +-------+ +------------------------+
95 set rule draw box, 1 line at a time
99 Obviously, this isn’t very efficient for something as simple as a
104 Here’s the same box, drawn with mom’s box drawing
106 <kbd><a href="#dbx">DBX</a></kbd>:
108 <span class="pre-in-pp">
109 left margin indent--+ +--box width
113 rule weight--+ +--box depth
119 Mom’s graphical object macros allow—in fact,
120 require—giving the rule weight (“thickness”) 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.
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
132 <div class="box-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’s <kbd>\D</kbd> escapes.
142 <h3 id="behaviour" class="docs">Graphical object behaviour</h3>
145 Mom’s graphical object macros all behave in the following,
146 carved-in-stone ways:
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>
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’re placed and how much room they
165 occupy. Furthermore, because all return to their point of origin,
166 you’ll know exactly where you are on the page.
169 <h3 id="order" class="docs">Order of arguments</h3>
172 The order of arguments to the graphical object macros is the same
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
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>
192 A simple mnemonic for the order of arguments is “<b>WILD
193 C</b>ard”. If you fix the mnemonic in your brain and apply
194 a little judicious reasoning, you’ll always remember how to
195 draw graphical objects. The “judicious reasoning” means
196 that, for example, horizontal rules don’t require a depth and
197 vertical rules don’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
204 <div class="macro-list-container">
205 <h3 id="index-graphical" class="macro-list">Graphical objects macros</h3>
207 <ul class="macro-list">
208 <li><a href="#drh">DRH</a>
209 – horizontal rules</li>
210 <li><a href="#drv">DRV</a>
211 – vertical rules</li>
212 <li><a href="#dbx">DBX</a>
214 <li><a href="#dcl">DCL</a>
215 – circles or ellipses</li>
221 <div class="macro-id-overline">
222 <h3 id="drh" class="macro-id">Drawing horizontal rules</h3>
225 <div class="box-macro-args">
226 Macro: <b>DRH</b> <kbd class="macro-args"><none> | <weight> <indent> <length> [<colour>]</kbd>
231 the argument to <kbd class="normal"><weight></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>
238 <kbd class="normal"><indent></kbd>
240 <kbd class="normal"><length></kbd>
241 require a unit of measure
244 arithmetic expressions to
245 <kbd class="normal"><indent></kbd>
247 <kbd class="normal"><length></kbd>
248 must be surrounded by parentheses
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 "full
254 measure" rule), you may invoke <kbd>.DRH</kbd> without any
257 <div class="box-tip">
259 <span class="note">Note:</span>
260 DRH is the only graphical object macro that may be invoked
261 without arguments. The weight (“thickness”) of
262 the rule is determined by the argument you last gave the
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>.
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
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).
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:
292 <span class="pre-in-pp">
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.)
304 If, in addition, you want the rule blue:
306 <span class="pre-in-pp">
311 <h3 class="docs">How mom handles the positioning of horizontal rules</h3>
314 Horizontal rules are drawn from left to right, and from the baseline
315 down. “From the baseline down” 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.
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.
329 <div class="macro-id-overline">
330 <h3 id="drv" class="macro-id">Drawing vertical rules</h3>
333 <div class="box-macro-args">
334 Macro: <b>DRV</b> <kbd class="macro-args"><weight> <indent> <depth> [<colour>]</kbd>
339 the argument to <kbd class="normal"><weight></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>
346 <kbd class="normal"><indent></kbd>
348 <kbd class="normal"><depth></kbd>
349 require a unit of measure
352 arithmetic expressions to
353 <kbd class="normal"><indent></kbd>
355 <kbd class="normal"><depth></kbd>
356 must be surrounded by parentheses
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
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).
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:
380 <span class="pre-in-pp">
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.)
392 If, in addition, you want the rule red:
394 <span class="pre-in-pp">
395 .DRV .75 19P+6p 6c red
399 <h3 class="docs">How mom handles the positioning of vertical rules</h3>
402 Vertical rules are drawn from the baseline down, and from left to
403 right. "Left to right" 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.
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.
417 <div class="macro-id-overline">
418 <h3 id="dbx" class="macro-id">Drawing boxes</h3>
421 <div class="box-macro-args">
422 Macro: <b>DBX</b> <kbd class="macro-args">< <weight> | SOLID > <indent> <length> <depth> [<colour>]</kbd>
427 the argument to <kbd class="normal"><weight></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>
433 • <kbd class="normal"><indent></kbd>,
434 <kbd class="normal"><length></kbd>,
436 <kbd class="normal"><depth></kbd>
437 require a unit of measure
440 arithmetic expressions to
441 <kbd class="normal"><indent></kbd>,
442 <kbd class="normal"><length></kbd>,
444 <kbd class="normal"><depth></kbd>
445 must be surrounded by parentheses
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>.
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).
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:
469 <span class="pre-in-pp">
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.)
481 If you want the same box, but solid (“filled”) rather
482 than drawn as an outline:
484 <span class="pre-in-pp">
487 Additionally, if you want the box green:
489 <span class="pre-in-pp">
490 .DBX .5 1i 12P 6P green
492 .DBX SOLID 1i 12P 6P green
496 <h3 class="docs">How mom handles the positioning of boxes</h3>
499 Boxes are drawn from the baseline down, from left to right, and
500 from the perimeter <i>inward</i>. “From the perimeter
501 inward” 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.
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.
515 <div class="macro-id-overline">
516 <h3 id="dcl" class="macro-id">Drawing circles (ellipses)</h3>
519 <div class="box-macro-args">
520 Macro: <b>DCL</b> <kbd class="macro-args">< <weight> | SOLID > <indent> <length> <depth> [<colour>]</kbd>
524 • the argument to <kbd class="normal"><weight></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>
532 <kbd class="normal"><indent></kbd>,
533 <kbd class="normal"><length></kbd>
535 <kbd class="normal"><depth></kbd>
536 require a unit of measure
539 arithmetic expressions to
540 <kbd class="normal"><indent></kbd>,
541 <kbd class="normal"><length></kbd>
543 <kbd class="normal"><depth></kbd>
544 must be surrounded by parentheses
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>.
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).
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:
569 <span class="pre-in-pp">
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.)
581 If you want the same box, but solid (“filled”) rather
582 than drawn as an outline:
584 <span class="pre-in-pp">
587 Additionally, if you want the circle yellow:
589 <span class="pre-in-pp">
590 .DCL .5 1i 6c 3c yellow
592 .DCL SOLID 1i 6c 3c yellow
596 <h3 class="docs">How mom handles the positioning of circles (ellipses)</h3>
599 Circles (ellipses) are drawn from the baseline down, from left
600 to right, and from the perimeter <i>inward</i>. “From the
601 perimeter inward” 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
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.
614 <div class="rule-long"><hr/></div>
616 <!-- Navigation links -->
617 <table style="width: 100%; margin-top: 12px;">
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>
627 <div class="bottom-spacer"><br/></div>