Imported Upstream version 1.23.0
[platform/upstream/groff.git] / doc / groff.html.node / Colors.html
1 <!DOCTYPE html>
2 <html>
3 <!-- Created by GNU Texinfo 7.0.3, https://www.gnu.org/software/texinfo/ -->
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6 <!-- This manual documents GNU troff version 1.23.0.
7
8 Copyright © 1994-2023 Free Software Foundation, Inc.
9
10 Permission is granted to copy, distribute and/or modify this document
11 under the terms of the GNU Free Documentation License, Version 1.3 or
12 any later version published by the Free Software Foundation; with no
13 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
14 copy of the license is included in the section entitled "GNU Free
15 Documentation License". -->
16 <title>Colors (The GNU Troff Manual)</title>
17
18 <meta name="description" content="Colors (The GNU Troff Manual)">
19 <meta name="keywords" content="Colors (The GNU Troff Manual)">
20 <meta name="resource-type" content="document">
21 <meta name="distribution" content="global">
22 <meta name="Generator" content="makeinfo">
23 <meta name="viewport" content="width=device-width,initial-scale=1">
24
25 <link href="index.html" rel="start" title="Top">
26 <link href="Request-Index.html" rel="index" title="Request Index">
27 <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
28 <link href="GNU-troff-Reference.html" rel="up" title="GNU troff Reference">
29 <link href="Strings.html" rel="next" title="Strings">
30 <link href="Manipulating-Type-Size-and-Vertical-Spacing.html" rel="prev" title="Manipulating Type Size and Vertical Spacing">
31 <style type="text/css">
32 <!--
33 a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
34 div.example {margin-left: 3.2em}
35 span.r {font-family: initial; font-weight: normal; font-style: normal}
36 span:hover a.copiable-link {visibility: visible}
37 strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
38 -->
39 </style>
40
41
42 </head>
43
44 <body lang="en">
45 <div class="section-level-extent" id="Colors">
46 <div class="nav-panel">
47 <p>
48 Next: <a href="Strings.html" accesskey="n" rel="next">Strings</a>, Previous: <a href="Manipulating-Type-Size-and-Vertical-Spacing.html" accesskey="p" rel="prev">Manipulating Type Size and Vertical Spacing</a>, Up: <a href="GNU-troff-Reference.html" accesskey="u" rel="up">GNU <code class="code">troff</code> Reference</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Request-Index.html" title="Index" rel="index">Index</a>]</p>
49 </div>
50 <hr>
51 <h3 class="section" id="Colors-1">5.21 Colors</h3>
52 <a class="index-entry-id" id="index-colors"></a>
53
54 <a class="index-entry-id" id="index-stroke-color"></a>
55 <a class="index-entry-id" id="index-color_002c-stroke"></a>
56 <a class="index-entry-id" id="index-fill-color"></a>
57 <a class="index-entry-id" id="index-color_002c-fill"></a>
58 <p>GNU <code class="code">troff</code> supports color output with a variety of color spaces
59 and up to 16 bits per channel.  Some devices, particularly terminals,
60 may be more limited.  When color support is enabled, two colors are
61 current at any given time: the <em class="dfn">stroke color</em>, with which glyphs,
62 rules (lines), and geometric objects like circles and polygons are
63 drawn, and the <em class="dfn">fill color</em>, which can be used to paint the interior
64 of a closed geometric figure.
65 </p>
66 <dl class="first-deffn">
67 <dt class="deffn" id="index-_002ecolor"><span class="category-def">Request: </span><span><strong class="def-name"><code class="t">.color</code></strong> <var class="def-var-arguments">[<span class="r"><i class="slanted">n</i></span>]</var><a class="copiable-link" href='#index-_002ecolor'> &para;</a></span></dt>
68 <dd><a class="index-entry-id" id="index-color"></a>
69 </dd><dt class="deffnx def-cmd-deffn" id="index-_005cn_005b_002ecolor_005d"><span class="category-def">Register: </span><span><strong class="def-name"><code class="t">\n[.color]</code></strong><a class="copiable-link" href='#index-_005cn_005b_002ecolor_005d'> &para;</a></span></dt>
70 <dd><a class="index-entry-id" id="index-_002ecolor-1"></a>
71 <p>If <var class="var">n</var> is missing or non-zero, enable the output of color-related
72 device-independent output commands (this is the default); otherwise,
73 disable them.  This request sets a global flag; it does not produce an
74 input token (see <a class="pxref" href="Gtroff-Internals.html"><code class="code">gtroff</code> Internals</a>).
75 </p>
76 <p>The read-only register <code class="code">.color</code> is&nbsp;1 if colors are enabled,
77 0&nbsp;otherwise.
78 </p>
79 <p>Color can also be disabled with the <samp class="option">-c</samp> command-line option.
80 </p></dd></dl>
81
82 <dl class="first-deffn">
83 <dt class="deffn" id="index-_002edefcolor"><span class="category-def">Request: </span><span><strong class="def-name"><code class="t">.defcolor</code></strong> <var class="def-var-arguments">ident scheme color-component &hellip;</var><a class="copiable-link" href='#index-_002edefcolor'> &para;</a></span></dt>
84 <dd><a class="index-entry-id" id="index-defcolor"></a>
85 <p>Define a color named <var class="var">ident</var>.  <var class="var">scheme</var> selects a color space
86 and determines the quantity of required <var class="var">color-component</var>s; it must
87 be one of &lsquo;<samp class="samp">rgb</samp>&rsquo; (three components), &lsquo;<samp class="samp">cmy</samp>&rsquo; (three), &lsquo;<samp class="samp">cmyk</samp>&rsquo;
88 (four), or &lsquo;<samp class="samp">gray</samp>&rsquo; (one).  &lsquo;<samp class="samp">grey</samp>&rsquo; is accepted as a synonym of
89 &lsquo;<samp class="samp">gray</samp>&rsquo;.  The color components can be encoded as a single
90 hexadecimal value starting with &lsquo;<samp class="samp">#</samp>&rsquo; or &lsquo;<samp class="samp">##</samp>&rsquo;.  The former
91 indicates that each component is in the range 0&ndash;255 (0&ndash;FF), the latter
92 the range 0&ndash;65,535 (0&ndash;FFFF).
93 </p>
94 <div class="example">
95 <div class="group"><pre class="example-preformatted">.defcolor half gray #7f
96 .defcolor pink rgb #FFC0CB
97 .defcolor magenta rgb  ##ffff0000ffff
98 </pre></div></div>
99
100 <a class="index-entry-id" id="index-f-scaling-unit"></a>
101 <a class="index-entry-id" id="index-unit_002c-scaling_002c-f"></a>
102 <a class="index-entry-id" id="index-scaling-unit-f"></a>
103 <p>Alternatively, each color component can be specified as a decimal
104 fraction in the range 0&ndash;1, interpreted using a default scaling
105 unit of&nbsp;<code class="code">f</code>, which multiplies its value by 65,536 (but
106 clamps it at 65,535).
107 </p>
108 <div class="example">
109 <div class="group"><pre class="example-preformatted">.defcolor gray50 rgb 0.5 0.5 0.5
110 .defcolor darkgreen rgb 0.1f 0.5f 0.2f
111 </pre></div></div>
112 </dd></dl>
113
114 <a class="index-entry-id" id="index-default-color"></a>
115 <a class="index-entry-id" id="index-color_002c-default"></a>
116 <p>Each output device has a color named &lsquo;<samp class="samp">default</samp>&rsquo;, which cannot be
117 redefined.  A device&rsquo;s default stroke and fill colors are not
118 necessarily the same.  For the <code class="code">dvi</code>, <code class="code">html</code>, <code class="code">pdf</code>,
119 <code class="code">ps</code>, and <code class="code">xhtml</code> output devices, GNU <code class="code">troff</code>
120 automatically loads a macro file defining many color names at startup.
121 By the same mechanism, the devices supported by <code class="code">grotty</code> recognize
122 the eight standard ISO&nbsp;6429/EMCA-48 color names.<a class="footnote" id="DOCF86" href="groff.html_fot.html#FOOT86"><sup>86</sup></a>
123 </p>
124 <dl class="first-deffn">
125 <dt class="deffn" id="index-_002egcolor"><span class="category-def">Request: </span><span><strong class="def-name"><code class="t">.gcolor</code></strong> <var class="def-var-arguments">[<span class="r"><i class="slanted">color</i></span>]</var><a class="copiable-link" href='#index-_002egcolor'> &para;</a></span></dt>
126 <dd><a class="index-entry-id" id="index-gcolor"></a>
127 </dd><dt class="deffnx def-cmd-deffn" id="index-_005cmc"><span class="category-def">Escape&nbsp;sequence: </span><span><strong class="def-name"><code class="t">\m</code><span class="r"><i class="slanted">c</i></span><code class="t"></code></strong><a class="copiable-link" href='#index-_005cmc'> &para;</a></span></dt>
128 <dd><a class="index-entry-id" id="index-_005cm"></a>
129 </dd><dt class="deffnx def-cmd-deffn" id="index-_005cm_0028co"><span class="category-def">Escape&nbsp;sequence: </span><span><strong class="def-name"><code class="t">\m(</code><span class="r"><i class="slanted">co</i></span><code class="t"></code></strong><a class="copiable-link" href='#index-_005cm_0028co'> &para;</a></span></dt>
130 <dt class="deffnx def-cmd-deffn" id="index-_005cm_005bcolor_005d"><span class="category-def">Escape&nbsp;sequence: </span><span><strong class="def-name"><code class="t">\m[</code><span class="r"><i class="slanted">color</i></span><code class="t">]</code></strong><a class="copiable-link" href='#index-_005cm_005bcolor_005d'> &para;</a></span></dt>
131 <dt class="deffnx def-cmd-deffn" id="index-_005cn_005b_002em_005d"><span class="category-def">Register: </span><span><strong class="def-name"><code class="t">\n[.m]</code></strong><a class="copiable-link" href='#index-_005cn_005b_002em_005d'> &para;</a></span></dt>
132 <dd><a class="index-entry-id" id="index-_002em"></a>
133 <p>Set the stroke color to <var class="var">color</var>.
134 </p>
135 <div class="example">
136 <div class="group"><pre class="example-preformatted">.gcolor red
137 The next words
138 .gcolor
139 \m[red]are in red\m[]
140 and these words are in the previous color.
141 </pre></div></div>
142
143 <p>The escape sequence <code class="code">\m[]</code> restores the previous stroke color, as
144 does a <code class="code">gcolor</code> request without an argument.
145 </p>
146 <a class="index-entry-id" id="index-stroke-color-name-register-_0028_002em_0029"></a>
147 <a class="index-entry-id" id="index-name_002c-stroke-color_002c-register-_0028_002em_0029"></a>
148 <a class="index-entry-id" id="index-color-name_002c-stroke_002c-register-_0028_002em_0029"></a>
149 <p>The name of the current stroke color is available in the read-only
150 string-valued register &lsquo;<samp class="samp">.m</samp>&rsquo;; it is associated with the environment
151 (see <a class="pxref" href="Environments.html">Environments</a>).  It interpolates nothing when the stroke color
152 is the default.
153 </p>
154 <p><code class="code">\m</code> doesn&rsquo;t produce an input token in GNU <code class="code">troff</code>
155 (see <a class="pxref" href="Gtroff-Internals.html"><code class="code">gtroff</code> Internals</a>).  It therefore can be used in requests like
156 <code class="code">mc</code> (which expects a single character as an argument) to change
157 the color on the fly:
158 </p>
159 <div class="example">
160 <div class="group"><pre class="example-preformatted">.mc \m[red]x\m[]
161 </pre></div></div>
162 </dd></dl>
163
164 <dl class="first-deffn">
165 <dt class="deffn" id="index-_002efcolor"><span class="category-def">Request: </span><span><strong class="def-name"><code class="t">.fcolor</code></strong> <var class="def-var-arguments">[<span class="r"><i class="slanted">color</i></span>]</var><a class="copiable-link" href='#index-_002efcolor'> &para;</a></span></dt>
166 <dd><a class="index-entry-id" id="index-fcolor"></a>
167 </dd><dt class="deffnx def-cmd-deffn" id="index-_005cMc"><span class="category-def">Escape&nbsp;sequence: </span><span><strong class="def-name"><code class="t">\M</code><span class="r"><i class="slanted">c</i></span><code class="t"></code></strong><a class="copiable-link" href='#index-_005cMc'> &para;</a></span></dt>
168 <dd><a class="index-entry-id" id="index-_005cM"></a>
169 </dd><dt class="deffnx def-cmd-deffn" id="index-_005cM_0028co"><span class="category-def">Escape&nbsp;sequence: </span><span><strong class="def-name"><code class="t">\M(</code><span class="r"><i class="slanted">co</i></span><code class="t"></code></strong><a class="copiable-link" href='#index-_005cM_0028co'> &para;</a></span></dt>
170 <dt class="deffnx def-cmd-deffn" id="index-_005cM_005bcolor_005d"><span class="category-def">Escape&nbsp;sequence: </span><span><strong class="def-name"><code class="t">\M[</code><span class="r"><i class="slanted">color</i></span><code class="t">]</code></strong><a class="copiable-link" href='#index-_005cM_005bcolor_005d'> &para;</a></span></dt>
171 <dt class="deffnx def-cmd-deffn" id="index-_005cn_005b_002eM_005d"><span class="category-def">Register: </span><span><strong class="def-name"><code class="t">\n[.M]</code></strong><a class="copiable-link" href='#index-_005cn_005b_002eM_005d'> &para;</a></span></dt>
172 <dd><a class="index-entry-id" id="index-_002eM"></a>
173 <p>Set the fill color for objects drawn with <code class="code">\D'&hellip;'</code> escape
174 sequences.  The escape sequence <code class="code">\M[]</code> restores the previous fill
175 color, as does an <code class="code">fcolor</code> request without an argument.
176 </p>
177 <a class="index-entry-id" id="index-background-color-name-register-_0028_002eM_0029"></a>
178 <a class="index-entry-id" id="index-name_002c-background-color_002c-register-_0028_002eM_0029"></a>
179 <a class="index-entry-id" id="index-color-name_002c-background_002c-register-_0028_002eM_0029"></a>
180 <a class="index-entry-id" id="index-fill-color-name-register-_0028_002eM_0029"></a>
181 <a class="index-entry-id" id="index-name_002c-fill-color_002c-register-_0028_002eM_0029"></a>
182 <a class="index-entry-id" id="index-color-name_002c-fill_002c-register-_0028_002eM_0029"></a>
183 <p>The name of the current fill color is available in the read-only
184 string-valued register &lsquo;<samp class="samp">.M</samp>&rsquo;; it is associated with the environment
185 (see <a class="pxref" href="Environments.html">Environments</a>).  It interpolates nothing when the fill color
186 is the default.  <code class="code">\M</code> doesn&rsquo;t produce an input token in GNU
187 <code class="code">troff</code>.
188 </p>
189 <p>Create an ellipse with a red interior as follows.
190 </p>
191 <div class="example">
192 <div class="group"><pre class="example-preformatted">\M[red]\h'0.5i'\D'E 2i 1i'\M[]
193 </pre></div></div>
194 </dd></dl>
195
196
197
198 </div>
199 <hr>
200 <div class="nav-panel">
201 <p>
202 Next: <a href="Strings.html">Strings</a>, Previous: <a href="Manipulating-Type-Size-and-Vertical-Spacing.html">Manipulating Type Size and Vertical Spacing</a>, Up: <a href="GNU-troff-Reference.html">GNU <code class="code">troff</code> Reference</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Request-Index.html" title="Index" rel="index">Index</a>]</p>
203 </div>
204
205
206
207 </body>
208 </html>