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
|
<h3 class="section">Color Names</h3> <p>A color name is text (usually in a string) that specifies a color. Symbolic names such as ‘<samp>black</samp>’, ‘<samp>white</samp>’, ‘<samp>red</samp>’, etc., are allowed; use <kbd>M-x list-colors-display</kbd> to see a list of defined names. You can also specify colors numerically in forms such as ‘<samp>#<var>rgb</var></samp>’ and ‘<samp>RGB:<var>r</var>/<var>g</var>/<var>b</var></samp>’, where <var>r</var> specifies the red level, <var>g</var> specifies the green level, and <var>b</var> specifies the blue level. You can use either one, two, three, or four hex digits for <var>r</var>; then you must use the same number of hex digits for all <var>g</var> and <var>b</var> as well, making either 3, 6, 9 or 12 hex digits in all. (See the documentation of the X Window System for more details about numerical RGB specification of colors.) </p> <p>These functions provide a way to determine which color names are valid, and what they look like. In some cases, the value depends on the <em>selected frame</em>, as described below; see <a href="input-focus">Input Focus</a>, for the meaning of the term “selected frame”. </p> <p>To read user input of color names with completion, use <code>read-color</code> (see <a href="high_002dlevel-completion">read-color</a>). </p> <dl> <dt id="color-defined-p">Function: <strong>color-defined-p</strong> <em>color &optional frame</em>
</dt> <dd>
<p>This function reports whether a color name is meaningful. It returns <code>t</code> if so; otherwise, <code>nil</code>. The argument <var>frame</var> says which frame’s display to ask about; if <var>frame</var> is omitted or <code>nil</code>, the selected frame is used. </p> <p>Note that this does not tell you whether the display you are using really supports that color. When using X, you can ask for any defined color on any kind of display, and you will get some result—typically, the closest it can do. To determine whether a frame can really display a certain color, use <code>color-supported-p</code> (see below). </p> <p>This function used to be called <code>x-color-defined-p</code>, and that name is still supported as an alias. </p>
</dd>
</dl> <dl> <dt id="defined-colors">Function: <strong>defined-colors</strong> <em>&optional frame</em>
</dt> <dd>
<p>This function returns a list of the color names that are defined and supported on frame <var>frame</var> (default, the selected frame). If <var>frame</var> does not support colors, the value is <code>nil</code>. </p> <p>This function used to be called <code>x-defined-colors</code>, and that name is still supported as an alias. </p>
</dd>
</dl> <dl> <dt id="color-supported-p">Function: <strong>color-supported-p</strong> <em>color &optional frame background-p</em>
</dt> <dd>
<p>This returns <code>t</code> if <var>frame</var> can really display the color <var>color</var> (or at least something close to it). If <var>frame</var> is omitted or <code>nil</code>, the question applies to the selected frame. </p> <p>Some terminals support a different set of colors for foreground and background. If <var>background-p</var> is non-<code>nil</code>, that means you are asking whether <var>color</var> can be used as a background; otherwise you are asking whether it can be used as a foreground. </p> <p>The argument <var>color</var> must be a valid color name. </p>
</dd>
</dl> <dl> <dt id="color-gray-p">Function: <strong>color-gray-p</strong> <em>color &optional frame</em>
</dt> <dd><p>This returns <code>t</code> if <var>color</var> is a shade of gray, as defined on <var>frame</var>’s display. If <var>frame</var> is omitted or <code>nil</code>, the question applies to the selected frame. If <var>color</var> is not a valid color name, this function returns <code>nil</code>. </p></dd>
</dl> <dl> <dt id="color-values">Function: <strong>color-values</strong> <em>color &optional frame</em>
</dt> <dd>
<p>This function returns a value that describes what <var>color</var> should ideally look like on <var>frame</var>. If <var>color</var> is defined, the value is a list of three integers, which give the amount of red, the amount of green, and the amount of blue. Each integer ranges in principle from 0 to 65535, but some displays may not use the full range. This three-element list is called the <em>rgb values</em> of the color. </p> <p>If <var>color</var> is not defined, the value is <code>nil</code>. </p> <div class="example"> <pre class="example">(color-values "black")
⇒ (0 0 0)
(color-values "white")
⇒ (65535 65535 65535)
(color-values "red")
⇒ (65535 0 0)
(color-values "pink")
⇒ (65535 49344 52171)
(color-values "hungry")
⇒ nil
</pre>
</div> <p>The color values are returned for <var>frame</var>’s display. If <var>frame</var> is omitted or <code>nil</code>, the information is returned for the selected frame’s display. If the frame cannot display colors, the value is <code>nil</code>. </p> <p>This function used to be called <code>x-color-values</code>, and that name is still supported as an alias. </p>
</dd>
</dl><div class="_attribution">
<p class="_attribution-p">
Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
<a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Color-Names.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Color-Names.html</a>
</p>
</div>
|