Debian Codegraph @

contrib/mom/momdoc/color.html

raw
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-2020 Free Software Foundation, Inc.
6 Written by Peter Schaffter ([email protected]).
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 -- Colour</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="graphical.html#top">Next: Graphical objects</a></td>
38 </tr>
39 </table>
40
41 <h1 class="docs">Coloured text</h1>
42
43 <div style="text-align: center;">
44 <a href="#index-color">List of color macros</a>
45 </div>
46
47 <div class="rule-medium"><hr/></div>
48
49 <h2 class="docs">Introduction</h2>
50
51 <p>
52 Mom&#8217;s support for coloured text is straightforward. You begin
53 by telling mom about the colours you want with
54 <a href="#newcolor">NEWCOLOR</a>
55 or
56 <a href="#xcolor">XCOLOR</a>.
57 Afterwards, any time you want text to be coloured, you either colour
58 it with an
59 <a href="definitions.html#inlines">inline escape</a>
60 that contains the colour name (e.g. <kbd><span class="nobr">\*[red]</span></kbd>
61 or <kbd><span class="nobr">\*[blue]</span></kbd>) or invoke the macro
62 <a href="#color">COLOR</a>
63 with the name of the colour you want.
64 </p>
65
66 <p id="color-example">
67 For example, say you want to have the name &#8220;Jack&#8221; in the
68 sentence &#8220;All work and no play makes Jack a dull boy&#8221;
69 appear in yellow. You&#8217;d begin by telling mom about the colour,
70 yellow. There are two ways of doing this; see
71 <a href="#newcolor">NEWCOLOR</a>
72 and
73 <a href="#xcolor">XCOLOR</a>
74 for a full explanation of the difference between the two.
75 </p>
76
77 <p>
78 If you use XCOLOR, you&#8217;d enter this:
79 <br/>
80 <span class="pre-in-pp">
81 .XCOLOR yellow
82 </span>
83 If you use NEWCOLOR, you might enter:
84 <br/>
85 <span class="pre-in-pp">
86 .NEWCOLOR yellow RGB #FFFF00
87 </span>
88 </p>
89
90 <p id="color-example2" style="margin-top: -1em;">
91 After defining or initializing the colour yellow you&#8217;d
92 colourise the name, Jack, either with an inline escape
93 <br/>
94 <span class="pre-in-pp">
95 All work and no play makes \*[yellow]Jack\*[black] a dull boy.
96 </span>
97 or with the
98 <a href="#color">COLOR</a>
99 macro
100 <br/>
101 <span class="pre-in-pp">
102 All work and no play makes
103 .COLOR yellow
104 Jack
105 .COLOR black
106 a dull boy.
107 </span>
108 Notice, in both examples, that a) you have to set the colour back
109 to black after &#8220;Jack,&#8221; and b) you don&#8217;t have to
110 define or initialize the colour, black. Mom predefines it for you.
111 </p>
112
113 <p>
114 For information on using colour during
115 <a href="docprocessing.html#intro-macros-docprocessing">document processing</a>,
116 see
117 <a href="docprocessing.html#color">Colour support in document processing</a>.
118 </p>
119
120 <div class="box-tip">
121 <p class="tip">
122 <span class="note">Note:</span>
123 Mom&#8217;s colour support is for text only. She doesn&#8217;t
124 support &#8220;fill&#8221; (or &#8220;background&#8221;) colour for
125 solid, enclosed graphical objects (polygons, ellipses) drawn with
126 groff&#8217;s <kbd>\D</kbd>
127 <a href="definitions.html#inlines">inline escapes</a>,
128 although you may give a colour as one of the arguments to
129 mom&#8217;s &#8220;box&#8221; and &#8220;circle&#8221; macros,
130 <a href="graphical.html#dbx">DBX</a>
131 and
132 <a href="graphical.html#dcl">DCL</a>
133 when the first argument to these macros is <kbd>SOLID</kbd>.
134 </p>
135 </div>
136
137 <div class="box-tip">
138 <p class="tip">
139 <span class="experts">Experts:</span>
140 If you&#8217;re accustomed to using groff&#8217;s
141 <kbd>.defcolor</kbd> to define colours, and groff&#8217;s inline
142 <kbd>\m[&lt;colorname&gt;]</kbd> to call them, you may continue to
143 do so without confusing mom.
144 </p>
145 </div>
146
147 <div class="macro-list-container">
148 <h3 id="index-color" class="macro-list">Coloured text macros</h3>
149
150 <ul class="macro-list">
151 <li><a href="#newcolor">NEWCOLOR</a></li>
152 <li><a href="#xcolor">XCOLOR</a></li>
153 <li><a href="#color">COLOR</a></li>
154 <li><a href="#color-inline">\*[&lt;colourname&gt;]</a> (inline escape)</li>
155 </ul>
156 </div>
157
158 <div class="rule-medium" style="margin-bottom: 1.5em;"><hr/></div>
159
160 <!-- -NEWCOLOR- -->
161
162 <div class="macro-id-overline">
163 <h3 id="newcolor" class="macro-id">Creating (initializing) a colour with NEWCOLOR</h3>
164 </div>
165
166 <div class="box-macro-args">
167 Macro: <b>NEWCOLOR</b> <kbd class="macro-args">&lt;colour name&gt; [&lt;colour scheme&gt;] &lt;colour components&gt;</kbd>
168 </div>
169
170 <p>
171 NEWCOLOR lets you create a colour, rather like an artist mixing
172 paint on a palette. The colour isn&#8217;t used immediately;
173 NEWCOLOR merely tells mom how to mix the colour when you need it.
174 If you haven&#8217;t invoked <kbd>.NEWCOLOR</kbd> (or
175 <kbd><a href="#xcolor">.XCOLOR</a></kbd>),
176 mom doesn&#8217;t have a clue what you mean when you reference a
177 colour (with
178 <a href="#color">COLOR</a>
179 or
180 <a href="#color-inline"><kbd><span class="nobr">\*[&lt;colour name&gt;]</span></kbd></a>).
181 </p>
182
183 <p>
184 The first argument to NEWCOLOR is a name for your colour. It
185 can be anything you like&mdash;provided it&#8217;s just one word
186 long&mdash;and can be caps, lower case, or any combination of the
187 two.
188 </p>
189
190 <p>
191 The second argument, which is entirely optional, is the
192 &#8220;colour scheme&#8221; you want mom to use when mixing the
193 colour. Valid arguments are
194 <br/>
195 <span class="pre-in-pp">
196 RGB (3 components: red green blue)
197 CYM (3 components: cyan yellow magenta)
198 CMYK (4 components: cyan magenta yellow black)
199 GRAY (1 component)
200 </span>
201 If you omit the second argument, mom assumes you
202 want RGB.
203 </p>
204
205 <p>
206 The final argument is the components of your colour. This can be
207 hexadecimal string starting with a pound sign (<kbd>#</kbd>) (for
208 colour values in the 0-255 range) or two pound signs (<kbd>##</kbd>)
209 (for colour values in the 0-65535 range), or it can be a series of
210 decimal digits, separated by spaces, one digit per component, with
211 the argument enclosed in double quotes. (If this is all gibberish
212 to you, see
213 <a href="#color-tip">Tips for newbies</a>.)
214 </p>
215
216 <p>
217 Thus, to tell mom about a colour named &#8220;YELLOW&#8221;, you
218 could enter one of the following:
219 <br/>
220 <span class="pre-in-pp">
221 .NEWCOLOR YELLOW #FFFF00 \"or ##FFFFFFFF0000 or "1 1 0"
222 .NEWCOLOR YELLOW RGB #FFFF00 \"or ##FFFFFFFF0000 or "1 1 0"
223 .NEWCOLOR YELLOW CMY #0000FF \"or ##0000FFFF0000 or "0 0 1"
224 .NEWCOLOR YELLOW CMYK #0000FF00 \"or ##00000000FFFF0000 or "0 0 1 0"
225 </span>
226 After you&#8217;ve told mom about a colour, you can then get her to
227 set text in that colour either with the
228 <a href="definitions.html#inlines">inline escape</a>,
229 <a href="#color-inline"><kbd><span class="nobr">\*[&lt;colourname&gt;]</span></kbd></a>,
230 or the macro
231 <a href="#color">COLOR</a>.
232 (See the
233 <a href="#color-example">example</a>,
234 above.)
235 </p>
236
237 <div class="box-tip">
238 <p class="tip-top">
239 <span class="note">Note:</span>
240 The colourname you give to NEWCOLOR may be used with groff&#8217;s
241 <kbd>\m[&lt;colourname&gt;]</kbd> inline escape (the <kbd>\m</kbd>
242 escape is used to set text and rule colours). Thus, assuming
243 a colourname &#8220;blueblack&#8221; set with NEWCOLOR,
244 <kbd><span class="nobr">\*[blueblack]</span></kbd> and <kbd>\m[blueblack]</kbd>
245 are equivalent. Furthermore, the colourname can be given as an
246 argument to <b>groff</b>&#8217;s
247 <a href="definitions.html#primitives">primitive</a>
248 request, <kbd>.gcolor</kbd> (which does the same thing as
249 <kbd>\m[&lt;colourname&gt;]</kbd>).
250 </p>
251
252 <p class="tip-bottom">
253 Equally, the colourname may be used with
254 <kbd>\M[&lt;colourname&gt;]</kbd> and <kbd>.fcolor</kbd>, which set
255 the &#8220;fill&#8221; colour for solid graphical objects.
256 </p>
257 </div>
258
259 <div class="box-tip">
260 <p id="color-tip" class="tip-top">
261 <span class="tip">Tips for newbies:</span>
262 Colour manipulation can be tremendously confusing if you don&#8217;t
263 have a background in graphic arts or computing. My advice, if colour
264 intimidates you, is to stick to using mom&#8217;s default RGB colour
265 scheme, and to fire up a colour chooser that gives you the RGB values
266 you want for the colour you select. Plug those values into the
267 components argument to NEWCOLOR, and you&#8217;ll get the colour
268 you want. Both the KDE and gnome desktops have colour selectors
269 that provide you with the shorter RGB hexadecimal string. If
270 you&#8217;re not running KDE or gnome, the X utility, xcolorsel,
271 provides you with a similar functionality, although it only provides
272 RGB values for 256 pre-defined colours. If you use xcolorsel, be
273 sure to click the button &#8220;Display format&#8221; and select
274 &#8220;8 bit truncated rgb&#8221;.
275 </p>
276
277 <p class="tip-bottom">
278 Alternatively, you can use mom&#8217;s simpler
279 <kbd><a href="#xcolor">XCOLOR</a></kbd>
280 macro to initialize one of the 256 pre-defined X colours by
281 supplying the name of the colour as an argument.
282 </p>
283 </div>
284
285 <!-- -XCOLOR- -->
286
287 <div class="macro-id-overline">
288 <h3 id="xcolor" class="macro-id">Initializing a colour with XCOLOR</h3>
289 </div>
290
291 <div class="box-macro-args">
292 Macro: <b>XCOLOR</b> <kbd class="macro-args">&lt;X colourname&gt; [&lt;alias&gt;]</kbd>
293 </div>
294
295 <p class="requires">
296 <kbd style="font-style: normal">&lt;X colourname&gt;</kbd> <i>must be all one word, all lower case.</i>
297 <br/>
298 (See
299 <a href="#xcolor-names" style="font-style: normal;">Finding X colour names</a>
300 for how to get a list of valid colour names.)
301 </p>
302
303 <p>
304 XCOLOR is similar to NEWCOLOR in that it tells mom to initialize a
305 colour, but it&#8217;s easier to use. All you have to do is pass
306 it, as an argument, the valid name of one of the 256 pre-defined
307 X colours. The name must be all one word, and, breaking with mom
308 policy, it must be entered in lower case.
309 </p>
310
311 <p>
312 For example, if you want to initialize the X colour, coral, all you
313 have to do is enter
314 <br/>
315 <span class="pre-in-pp">
316 .XCOLOR coral
317 </span>
318 Afterwards
319 <br/>
320 <span class="pre-in-pp">
321 .COLOR coral
322 </span>
323
324 will colourise subsequent text coral until you instruct mom to
325 return to black, or some other pre-defined, initialized colour.
326 (The
327 <a href="definitions.html#inlines">inline escape</a>
328 <kbd><span class="nobr">\*[coral]</span></kbd> will equally colourise text coral
329 after you&#8217;ve initialized the colour with XCOLOR.)
330 </p>
331
332 <p>
333 The downside of XCOLOR is that you can&#8217;t create custom
334 colours. This restriction, however, is mitigated by the fact that
335 for many users, 256 colours is more than enough to play around with.
336 </p>
337
338 <p>
339 While some X colours have fanciful names (peachpuff, papayawhip,
340 thistle, snow), many are self-explanatory and self-descriptive
341 in ordinary colour terms. &#8220;blue&#8221; is pure (rgb)
342 blue, &#8220;green&#8221; is pure (rgb) green, and so on.
343 Furthermore, for many X colours, there exist four variants, each
344 representing increasingly darker shades of the same colour.
345 For example, &#8220;blue1&#8221; is a relatively bright blue;
346 &#8220;blue2&#8221;, &#8220;blue3&#8221; and &#8220;blue4&#8221; are
347 increasingly darker shades. For that reason, you may find XCOLOR is
348 a better choice than NEWCOLOR when it comes to initializing common
349 colours.
350 </p>
351
352 <p>
353 The whimsical nature of X colour names sometimes makes for names
354 that are long to type in, e.g. &#8220;mediumspringgreen&#8221;. The
355 optional second argument to XCOLOR allows you to come up with more
356 convenient name by which to reference the colour. For example, you
357 could enter
358 <br/>
359 <span class="pre-in-pp">
360 .XCOLOR mediumspringgreen mygreen
361 </span>
362 or
363 <span class="pre-in-pp">
364 .XCOLOR mediumspringgreen MYGREEN
365 </span>
366 so that whenever you want text mediumspringgreen-ed, you can use
367 either <kbd>.COLOR&nbsp;mygreen</kbd> (or <kbd>.COLOR&nbsp;MYGREEN</kbd>)
368 or the inline escape
369 <kbd>\*[mygreen]</kbd> (or <kbd>\*[MYGREEN]</kbd>.)
370 </p>
371
372 <h3 id="xcolor-names" class="docs">Finding X colour names</h3>
373
374 <p>
375 There are two ways of finding the names of the pre-defined X
376 colours. One is to consult the file, rgb.txt, included with all
377 X11 installations. The location of the file on a Debian GNU/Linux
378 distribution is typically /etc/X11/rgb.txt. Other distributions and
379 other X installations may have the file in another location. The
380 file lists the colour names, but doesn&#8217;t show you what the
381 colours actually look like.
382 </p>
383
384 <p>
385 A better way to get the colour names, as well as to see what the
386 colours look like, is to fire up a colour chooser (like xcolorsel)
387 that both lists the colour names and shows a swatch of the colour
388 as well.
389 </p>
390
391 <p>
392 Whichever method you use to find X colour names, remember that the
393 names, passed as arguments to XCOLOR, must be all one word, all in
394 lower case.
395 </p>
396
397 <div class="box-tip">
398 <p class="tip-top">
399 <span class="note">Note:</span>
400 Both the colourname and the alias you give to XCOLOR may be
401 used with groff&#8217;s <kbd>\m[&lt;colourname&gt;]</kbd>
402 inline escape (the <kbd>\m</kbd> escape is used to set
403 text and rule colours). Thus, assuming an X-colourname
404 &#8220;mediumspringgreen&#8221; set with
405 XCOLOR, and an alias, &#8220;mygreen&#8221;,
406 <kbd><span class="nobr">\*[mediumspringgreen]</span></kbd>,
407 <kbd><span class="nobr">\m[mediumspringgreen]</span></kbd>,
408 <kbd><span class="nobr">\*[mygreen]</span></kbd> and
409 <kbd><span class="nobr">\m[mygreen]</span></kbd> are all equivalent.
410 Furthermore, both the colourname and the alias can be given as an
411 argument to groff&#8217;s
412 <a href="definitions.html#primitives">primitive</a>
413 request, <kbd>.gcolor</kbd> (which does the same thing as
414 <kbd><span class="nobr">\m[&lt;colourname&gt;]</span></kbd>).
415 </p>
416
417 <p class="tip-bottom">
418 The colourname initialized with XCOLOR <i>but not the
419 alias</i> may also be used with groff&#8217;s inline escape,
420 <kbd>\M[&lt;colorname&gt;]</kbd>, and the corresponding primitive,
421 <kbd>.fcolor</kbd>, both of which set the &#8220;fill&#8221; colour
422 for solid graphical objects. If you need a colour initialized with
423 XCOLOR for <kbd>\M</kbd> or <kbd>.fcolor</kbd>, you MUST give the
424 full colourname; the alias won&#8217;t work.
425 </p>
426 </div>
427
428 <!-- -COLOR- -->
429
430 <div class="macro-id-overline">
431 <h3 id="color" class="macro-id">Invoking a colour</h3>
432 </div>
433
434 <div class="box-macro-args">
435 Macro: <b>COLOR</b> <kbd class="macro-args">&lt;colourname&gt;</kbd>
436 </div>
437
438 <p id="color-inline" class="requires" style="font-style: normal;">
439 Inline: <kbd>\*[&lt;colourname&gt;]</kbd>
440 </p>
441
442 <p>
443 Once you&#8217;ve told mom about a colour (via
444 <a href="#newcolor">NEWCOLOR</a>
445 or
446 <a href="#xcolor">XCOLOR</a>,
447 you use either the macro COLOR or the
448 <a href="definitions.html#inlines">inline escape</a>,
449 <kbd><span class="nobr">\*[&lt;colourname&gt;]</span></kbd>, to cause mom to set
450 subsequent text in that colour. See the
451 <a href="#color-example2">example</a>,
452 above, which shows both in action.
453 </p>
454
455 <div class="box-tip">
456 <p class="tip-top">
457 <span class="note">Note:</span>
458 You can use the <kbd><span class="nobr">\*[&lt;colourname&gt;]</span></kbd>
459 inline escape in any
460 <a href="docprocessing.html#top">document processing</a>
461 macro that takes a
462 <a href="definitions.html#stringargument">string argument</a>.
463 However, you must remember to reset the colour at the end of the
464 argument (typically with <kbd><span class="nobr">\*[black]</span></kbd>) unless
465 you want all subsequent invocations of that particular macro to be
466 colourised.
467 </p>
468
469 <p>
470 Furthermore, if you use
471 <kbd><span class="nobr">\*[&lt;colourname&gt;]</span></kbd> in the string
472 argument passed to
473 <a href="docelement.html#heading">HEADING&nbsp;&lt;n&gt;</a>
474 and you&#8217;ve requested that the heading level be numbered, the
475 numbers themselves will not be colourised, only the text you pass to
476 the macro. If you wish the numbers to be colourised along with the
477 text, you must explicitly tell mom with
478 <a href="docelement.html#heading-style">HEADING_STYLE&nbsp;&lt;n&gt;</a>.
479 </p>
480
481 <p class="tip-bottom">
482 For colourising underscored text, see
483 <a href="goodies.html#underscore-color">Colourising underscored text</a>
484 in the notes at the end of
485 <a href="goodies.html#underscore">UNDERSCORE</a>.
486 </p>
487 </div>
488
489 <div class="rule-long"><hr/></div>
490
491 <!-- Navigation links -->
492 <table style="width: 100%; margin-top: 12px;">
493 <tr>
494 <td style="width: 33%;"><a href="toc.html">Back to Table of Contents</a></td>
495 <td style="width: 33%; text-align: center;"><a href="#top">Top</a></td>
496 <td style="width: 33%; text-align: right;"><a href="graphical.html#top">Next: Graphical objects</a></td>
497 </tr>
498 </table>
499
500 </div>
501
502 <div class="bottom-spacer"><br/></div>
503
504 </body>
505 </html>