Command/definecolor

From Wiki
Jump to navigation Jump to search


\definecolor

Summary

The command \definecolor is used to create or copy a named color.

Settings

\definecolor[...][...=...,...]
[...]name
rnumber
gnumber
bnumber
cnumber
mnumber
ynumber
knumber
hnumber
snumber
vnumber
wnumber
xnumber
anumber none normal multiply screen overlay softlight hardlight colordodge colorburn darken lighten difference exclusion hue saturation color luminosity
tnumber

OptionExplanation
color name, must not contain spaces or numbers
r
RGB red channel (0–1)
g
RGB green channel (0–1)
b
RGB blue channel (0–1), HWB blackness (0–1)
c
CMYK cyan channel (0–1)
m
CMYK magenta channel (0–1)
y
CMYK yellow channel (0–1)
k
CMYK black channel (0–1)
h
HSV or HWB hue degree (0–360)
s
Grayscale black value (0–1), HSV saturation (0–1)
v
HSV value (0–1)
w
HWB whiteness (0–1)
x
RGB hex value (as in HTML/CSS)
a
transparency mode (“alternative”), see Transparency and the color manual. You can use the number or the name of a mode.
number mode number
none no transparency
normal also no transparency
multiply colors get darker
screen multiply negatively, colors get lighter
overlay copy together: mixture of multiply and screen, increases contrast
softlight milder version of overlay
hardlight more intense version of overlay
colordodge similar to screen, makes lights lighter and increases contrast
colorburn similar to multiply, increases intensity and contrast
darken use the darker of two colors
lighten use the lighter of two colors
difference same values become black, other colors get inverted
exclusion similar to difference, but more matte
hue upper layer defines the hue, saturation and lightness stay
saturation upper layer defines the saturation, hue and lightness stay
color upper layer defines the hue, luminosity stays; good for coloration
luminosity upper layer defines the luminosity, hue stays
t
transparency value (0–1) – actually, opacity: 1 is opaque, 0 is invisibly transparent

Settings name

\definecolor[...][...]
[...]name
[...]color

OptionExplanation
new name
original (parent) name

Description

\definecolor associates a name with a set of color values, for later use with the \color command.

You can omit 0 values.

Examples

Normal usage

  • % rgb
    \definecolor[bluu][r=.25, g=.1, b=1]
    Hey, \color[bluu]{look at that!}
    
    % hex
    \definecolor[salmon][x=AB5757]
    Hey, \color[salmon]{look at that!}
    
    \definecolor[brightorange][c=0, m=.4325, y=.9286, k=.0118]
    Hey, \color[brightorange]{orange you glad I didn't say banana?}
    
    \definecolor[darknavy][c=.9753, m=.4444, y=0, k=.6824]
    Hey, \color[darknavy]{is this dark navy?}
    

Defining derivative colors

Colors defined in terms of other colors are processed at the Lua end, unless they are direct clones. In that case, the new name is never told to Lua. That means that this does not work:

% direct clone, processed by TeX
\definecolor[ColorA][red]
% fails, ColorA not known to Lua
\definecolor[ColorB][.5(ColorA)]

Writing it as a fake fraction works.

% definition involves a fraction, processed by Lua.
\definecolor[ColorA][1.0(red)]
% succeeds
\definecolor[ColorB][.5(ColorA)]

Notes

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: