ConTeXt supports several color models: [https://en.wikipedia.org/wiki/RGB_color_model RGB] (typically used for screen display),[https://en.wikipedia.org/wiki/CMYK_color_model CMYK] (typically used for printing) as well as [https://en.wikipedia.org/wiki/HSL_and_HSV HSV/HSL] and [https://en.wikipedia.org/wiki/HWB_color_model HWB]. There is also support for [https://en.wikipedia.org/wiki/Spot_color spot colors] (typically used for offset printing) and transparencies. __TOC__
= Before you start ... =
3. To disable colors in a document, use
<texcode>\setupcolors[state=stop]</texcode>
Last [[Documentation|manual dedicated to color]] was issued in 2016
ConTeXt Defining New Colors|supports several color models:
* [https://en.wikipedia.org/wiki/CMYK_color_model CMYK], typically used for printing
* [https://en.wikipedia.org/wiki/RGB_color_model RGB], [https://en.wikipedia.org/wiki/HSL_and_HSV HSV/HSL] and [https://en.wikipedia.org/wiki/HWB_color_model HWB], typically used for screen display,
* [[Transparency]] ([https://en.wikipedia.org/wiki/Transparency_(graphic) Transparency] on wikipedia).
* [[Spot Colors]] typically used for offset printing ([https://en.wikipedia.org/wiki/Spot_color Spot colors] on wikipedia).
| The values for <code>c</code>, <code>m</code>, <code>y</code> and <code>k</code> are floating point number between <code>0</code> and <code>1</code>.
| The value for <code>h</code> (hue) is between <code>0</code> and <code>360</code>; the values for <code>s</code> (saturation), <code>v</code> (value/brightness) are floating point numbers between <code>0</code> and <code>1</code>.
| The value for <code>h</code> (hue) is between <code>0</code> and <code>360</code>; the values for <code>w</code> (whiteness), <code>b</code> (blackness) are floating point numbers between <code>0</code> and <code>1</code>. This mostly unknown color model is also used in CSS3/SVG.
|-
| Hex
| <texcode>\definecolor[...][x=...]</texcode>
For example,
<texcode>\definecolor[lime][x=BFFF00]
This is \color[lime]{a new color}
that we defined</texcode>
| The value for <code>x</code> is a three-byte hexadecimal number where the bytes represent the red, green, and blue values. This follows the HTML and CSS style of defining colors.
|-
|Gray scale
|<texcode>\definecolor[...][s=...]</texcode>
For example,
<texcode>\definecolor[screen][s=0.5]
This is \color[screen]{a new color}
that we defined</texcode>
| The value for <code>s</code> is a floating point number between <code>0</code> and <code>1</code>, representing the grayness value (1 represents white, 0 represents black).
| The values for <code>c</code>, <code>m</code>, <code>y</code> and <code>k</code> are floating point number between <code>0</code> and <code>1</code>.
| The value for <code>h</code> (hue) is between <code>0</code> and <code>360</code>; the values for <code>s</code> (saturation), <code>v</code> (value/brightness) are floating point numbers between <code>0</code> and <code>1</code>.
| The value for <code>h</code> (hue) is between <code>0</code> and <code>360</code>; the values for <code>w</code> (whiteness), <code>b</code> (blackness) are floating point numbers between <code>0</code> and <code>1</code>. This mostly unknown color model is also used in CSS3/SVG.
|-
| Hex
| <texcode>\definecolor[...][x=...]</texcode>
For example,
<texcode>\definecolor[lime][x=BFFF00]
This is \color[lime]{a new color}
that we defined</texcode>
| The value for <code>x</code> is a three-byte hexadecimal number where the bytes represent the red, green, and blue values. This follows the HTML and CSS style of defining colors.
|-
|Gray scale
|<texcode>\definecolor[...][s=...]</texcode>
For example,
<texcode>\definecolor[screen][s=0.5]
This is \color[screen]{a new color}
that we defined</texcode>
| The value for <code>s</code> is a floating point number between <code>0</code> and <code>1</code>, representing the grayness value (1 represents white, 0 represents black).
== Using colors in TikZ Testing if color is defined == To test if a color is defined, use * {{cmd|doifcolor}}* {{cmd|doifcolorelse}} Usage: <texcode>\doifcolor{color-name}{... if branch ... }\doifcolorelse{color-name}{... if branch ...}{... else branch ...}</texcode>
= Viewing pre-defined color =
|}
= Testing if color is defined =
To test if a color is defined, use
* {{cmd|doifcolor}}
* {{cmd|doifcolorelse}}
Usage:
<texcode>
\doifcolor{color-name}{... if branch ... }
\doifcolorelse{color-name}{... if branch ...}{... else branch ...}
</texcode>
= Specialized topics =
* [[Color/Palet|Color Palettes]]
* [[Color/Transparency|Transparency]]
* [[Color/Spot_Colors|Spot Colors]]
= References =
* [http://paletton.com Paletton] - Website to choose color palettes* [http://colorbrewer2.org/ ColorBrewer] - website to choose colors for maps = Further reading and graphics.specialized topics =
* [[Transparency]] * [[Spot Colors]]* References** [http://paletton.com Paletton] - Website to choose color palettes** [http://colorbrewer2.org/ ColorBrewer] - website to choose colors for maps and graphics.** Tina Sutton, Bride M Whelan: The Complete Color Harmony. Rockport Publishers (2004). ISBN 978-1592530311 (recommanded in the mailing list)