Changes

Jump to navigation Jump to search
390 bytes added ,  21:13, 6 March 2020
add links to HSV/HSL and HBW color models, some text changes (replace MkII syntax)
ConTeXt supports two several color models: [httphttps://en.wikipedia.org/wiki/RGB_color_model RGB] (typically used for screen display) and ,[httphttps://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 [httphttps://en.wikipedia.org/wiki/Spot_color spot colors] (typically used for offset printing) and transparencies.
= Before you start ... =
1. It is It’s usually a bad style to use explicit color switches in the text. It is It’s better to define a semantic command that takes care of the color switching. For example, instead of using <code>\color[red]{important text}</code>, define
<texcode>
\definehighlight[important][color=red]
and then use <code>\important{important text}</code> in the text.
2. Colors are not enabled by default in MkII. To enabled enable colors in MkII, use
<texcode>\setupcolors[state=start]</texcode>
| 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>.
|-
| HSV /HSL color model
|<texcode>\definecolor[...][h=.., s=.., v=..]</texcode>
For example,
This is \color[lime]{a new color}
that we defined</texcode>
| 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>. |-| HWB color model|<texcode>\definecolor[...][h=.., w=.., b=..]</texcode> For example,<texcode>\definecolor[something][h=75, w=0.5, b=.1] This is \color[something]{a new color}that we defined</texcode>| 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[...][hx=...]</texcode>
For example,
<texcode>\definecolor[lime][hx=BFFF00]
This is \color[lime]{a new color}
that we defined</texcode>
|<texcode>\definecolor[...][s=...]</texcode>
For example,
<texcode>\definecolor[screen][gs=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).
|}
 
'''Note''': The key-values are overloaded. For example, <code>h</code> is used for both HSV model and Hex model; <code>s</code> is used for both HSV model and grayscale model. The distinction is made based on the presence or absence of the <code>v</code> key.
== Cloning existing colors ==

Navigation menu