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-2014 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 the
11 Invariant Sections being this comment section, with no Front-Cover
12 Texts, and with no Back-Cover Texts.
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
263 macro, <a href="inlines.html#rule-weight">RULE_WEIGHT</a>.
264 DRH, used this way, is exactly equivalent to entering the
265 <a href="definitions.html#inlines">inline escape</a>, <a
266 href="inlines.html#inline-rule-mom"><kbd>\*[RULE]</kbd></a>.
270 <p style="margin-top: -.5em;">
271 To draw horizontal rules of a specified length, you must, at
272 a minimum, supply DRH with the arguments <kbd>weight,</kbd>
273 <kbd>indent</kbd> (measured from the current left margin) and
278 Optionally, you may give a <kbd>colour</kbd> argument. The colour
279 may be either one defined with
280 <a href="color.html#newcolor">NEWCOLOR</a>,
281 or a named X-colour inititialized with
282 <a href="color.html#xcolor">XCOLOR</a>,
283 or an X-colour alias (again, initialized with XCOLOR).
287 Say, for example, you want to draw a 1-1/4 point horizontal rule
288 that starts 2 picas from the current left margin and runs for 3
289 inches. To do so, you'd invoke <kbd>.DRH</kbd> like this:
291 <span class="pre-in-pp">
298 (Note that the rule weight argument, which is expressed in points,
299 must NOT have the unit of measure <kbd>p</kbd> appended to it.)
303 If, in addition, you want the rule blue:
305 <span class="pre-in-pp">
310 <h3 class="docs">How mom handles the positioning of horizontal rules</h3>
313 Horizontal rules are drawn from left to right, and from the baseline
314 down. “From the baseline down” means that if you request
315 a rule with a weight of four points, the four points of rule fall
316 entirely below the baseline.
320 Furthermore, after the rule is drawn, mom returns you to the current
321 left margin, at the same vertical position on the page as when DRH
322 was invoked. In other words, DRH causes no movement on the page,
323 either horizontal or vertical.
328 <div class="macro-id-overline">
329 <h3 id="drv" class="macro-id">Drawing vertical rules</h3>
332 <div class="box-macro-args">
333 Macro: <b>DRV</b> <kbd class="macro-args"><weight> <indent> <depth> [<colour>]</kbd>
338 the argument to <kbd class="normal"><weight></kbd> is in
339 <a href="definitions.html#picaspoints" class="normal">points</a>,
340 but do <span class="normal">NOT</span> append the
341 <a href="definitions.html#unitsofmeasure">unit of measure</a>,
342 <kbd class="normal">p</kbd>
345 <kbd class="normal"><indent></kbd>
347 <kbd class="normal"><depth></kbd>
348 require a unit of measure
351 arithmetic expressions to
352 <kbd class="normal"><indent></kbd>
354 <kbd class="normal"><depth></kbd>
355 must be surrounded by parentheses
359 To draw vertical rules of a specified length, you must, at
360 a minimum, supply DRV with the arguments <kbd>weight,</kbd>
361 <kbd>indent</kbd> (measured from the current left margin) and
366 Optionally, you may give a <kbd>colour</kbd> argument. The colour
367 may be either one defined with
368 <a href="color.html#newcolor">NEWCOLOR</a>,
369 or a named X-colour inititialized with
370 <a href="color.html#xcolor">XCOLOR</a>,
371 or an X-colour alias (again, initialized with XCOLOR).
375 Say, for example, you want to draw a 3/4-point vertical rule that
376 starts 19-1/2 picas from the current left margin and has a depth of
377 6 centimeters. To do so, you'd invoke <kbd>.DRV</kbd> like this:
379 <span class="pre-in-pp">
386 (Note that the rule weight argument, which is expressed in points,
387 must NOT have the unit of measure <kbd>p</kbd> appended to it.)
391 If, in addition, you want the rule red:
393 <span class="pre-in-pp">
394 .DRV .75 19P+6p 6c red
398 <h3 class="docs">How mom handles the positioning of vertical rules</h3>
401 Vertical rules are drawn from the baseline down, and from left to
402 right. "Left to right" means that if you request a rule
403 with a weight of four points, the four points of rule fall entirely
404 to the left of the indent given to DRV.
408 Furthermore, after the rule is drawn, mom returns you to the current
409 left margin, at the same vertical position on the page as when DRV
410 was invoked. In other words, DRV causes no movement on the page,
411 either horizontal or vertical.
416 <div class="macro-id-overline">
417 <h3 id="dbx" class="macro-id">Drawing boxes</h3>
420 <div class="box-macro-args">
421 Macro: <b>DBX</b> <kbd class="macro-args">< <weight> | SOLID > <indent> <length> <depth> [<colour>]</kbd>
426 the argument to <kbd class="normal"><weight></kbd> is in
427 <a href="definitions.html#picaspoints" class="normal">points</a>,
428 but do <span class="normal">NOT</span> append the
429 <a href="definitions.html#unitsofmeasure">unit of measure</a>
430 <kbd class="normal">p</kbd>
432 • <kbd class="normal"><indent></kbd>,
433 <kbd class="normal"><length></kbd>,
435 <kbd class="normal"><depth></kbd>
436 require a unit of measure
439 arithmetic expressions to
440 <kbd class="normal"><indent></kbd>,
441 <kbd class="normal"><length></kbd>,
443 <kbd class="normal"><depth></kbd>
444 must be surrounded by parentheses
448 To draw boxes of specified dimensions, you must, at a minimum,
449 supply DBX with the arguments <kbd>weight</kbd> or <kbd>SOLID</kbd>,
450 <kbd>indent</kbd> (measured from the current left margin),
451 <kbd>length</kbd> and <kbd>depth</kbd>.
455 Optionally, you may give a <kbd>colour</kbd> argument. The colour
456 may be either one defined with
457 <a href="color.html#newcolor">NEWCOLOR</a>,
458 or a named X-colour inititialized with
459 <a href="color.html#xcolor">XCOLOR</a>,
460 or an X-colour alias (again, initialized with XCOLOR).
464 Say, for example, you want to draw a 1/2 point outline box that
465 starts one inch from the current left margin and has the dimensions
466 12 picas x 6 picas. To do so, you'd invoke <kbd>.DBX</kbd> like this:
468 <span class="pre-in-pp">
475 (Note that the box weight argument, which is expressed in points,
476 must NOT have the unit of measure <kbd>p</kbd> appended to it.)
480 If you want the same box, but solid (“filled”) rather
481 than drawn as an outline:
483 <span class="pre-in-pp">
486 Additionally, if you want the box green:
488 <span class="pre-in-pp">
489 .DBX .5 1i 12P 6P green
491 .DBX SOLID 1i 12P 6P green
495 <h3 class="docs">How mom handles the positioning of boxes</h3>
498 Boxes are drawn from the baseline down, from left to right, and
499 from the perimeter <i>inward</i>. “From the perimeter
500 inward” means that if you request a box weight of six points,
501 the 6-point rules used to draw the outline of the box fall entirely
502 <i>within</i> the dimensions of the box.
506 Furthermore, after the box is drawn, mom returns you to the current
507 left margin, at the same vertical position on the page as when DBX
508 was invoked. In other words, DBX causes no movement on the page,
509 either horizontal or vertical.
514 <div class="macro-id-overline">
515 <h3 id="dcl" class="macro-id">Drawing circles (ellipses)</h3>
518 <div class="box-macro-args">
519 Macro: <b>DCL</b> <kbd class="macro-args">< <weight> | SOLID > <indent> <length> <depth> [<colour>]</kbd>
523 • the argument to <kbd class="normal"><weight></kbd> is in
524 <a href="definitions.html#picaspoints" class="normal">points</a>,
525 but do <span class="normal">NOT</span> append the
526 <a href="definitions.html#unitsofmeasure">unit of measure</a>,
527 <kbd class="normal">p</kbd>
531 <kbd class="normal"><indent></kbd>,
532 <kbd class="normal"><length></kbd>
534 <kbd class="normal"><depth></kbd>
535 require a unit of measure
538 arithmetic expressions to
539 <kbd class="normal"><indent></kbd>,
540 <kbd class="normal"><length></kbd>
542 <kbd class="normal"><depth></kbd>
543 must be surrounded by parentheses
547 To draw circles of specified dimensions, you must, at a minimum,
548 supply DCL with the arguments <kbd>weight</kbd> or <kbd>SOLID</kbd>,
549 <kbd>indent</kbd> (measured from the current left margin),
550 <kbd>length</kbd> and <kbd>depth</kbd>.
554 Optionally, you may give a <kbd>colour</kbd> argument. The colour
555 may be either one defined with
556 <a href="color.html#newcolor">NEWCOLOR</a>,
557 or a named X-colour inititialized with
558 <a href="color.html#xcolor">XCOLOR</a>,
559 or an X-colour alias (again, initialized with XCOLOR).
563 Say, for example, you want to draw a 1/2 point outline circle
564 (ellipse, actually, in this case) that starts one inch from the
565 current left margin and has the dimensions 6 centimeters x 3
566 centimeters. To do so, you'd invoke <kbd>.DCL</kbd> like this:
568 <span class="pre-in-pp">
575 (Note that the box weight argument, which is expressed in points,
576 must NOT have the unit of measure <kbd>p</kbd> appended to it.)
580 If you want the same box, but solid (“filled”) rather
581 than drawn as an outline:
583 <span class="pre-in-pp">
586 Additionally, if you want the circle yellow:
588 <span class="pre-in-pp">
589 .DCL .5 1i 6c 3c yellow
591 .DCL SOLID 1i 6c 3c yellow
595 <h3 class="docs">How mom handles the positioning of circles (ellipses)</h3>
598 Circles (ellipses) are drawn from the baseline down, from left
599 to right, and from the perimeter <i>inward</i>. “From the
600 perimeter inward” means that if you request a circle weight of
601 six points, the 6-point rule used to draw the outline of the circle
602 or ellipse falls entirely <i>within</i> the dimensions of the
607 Furthermore, after the circle is drawn, mom returns you to the
608 current left margin, at the same vertical position on the page as
609 when DCL was invoked. In other words, DCL causes no movement on the
610 page, either horizontal or vertical.
613 <div class="rule-long"><hr/></div>
615 <!-- Navigation links -->
616 <table style="width: 100%; margin-top: 12px;">
618 <td style="width: 33%;"><a href="toc.html">Back to Table of Contents</a></td>
619 <td style="width: 33%; text-align: center;"><a href="#top">Top</a></td>
620 <td style="width: 33%; text-align: right;"><a href="docprocessing.html#top">Next: Document processing</a></td>
626 <div class="bottom-spacer"><br/></div>
630 <!-- vim: fileencoding=utf-8: nomodified: -->