Difference between revisions of "Command/definecolor"

From Wiki
Jump to navigation Jump to search
m (Colors --> Color)
Line 94: Line 94:
 
</texcode>
 
</texcode>
  
Regarding the key « a », which means transparency alternative method, there are a certain number of values (actually at least 13, from 0 to 12) whose meanings can be seen from below:
+
Regarding the key {{code|a}}, which means transparency alternative method, there are a certain number of values (actually at least 13, from 0 to 12) whose meanings can be seen from below:
  
 
<texcode>
 
<texcode>
Line 110: Line 110:
 
\definetransparency [difference] [11]
 
\definetransparency [difference] [11]
 
\definetransparency [exclusion]  [12]
 
\definetransparency [exclusion]  [12]
 +
</texcode>
 +
 +
=== 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:
 +
 +
<texcode>
 +
% direct clone, processed by TeX
 +
\definecolor[ColorA][red]
 +
% fails, ColorA not known to Lua
 +
\definecolor[ColorB][.5(ColorA)]
 +
</texcode>
 +
 +
Writing it as a fake fraction works.
 +
 +
<texcode>
 +
% definition in terms of fraction, processed by Lua.
 +
\definecolor[ColorA][1.0(red)]
 +
% succeeds
 +
\definecolor[ColorB][.5(ColorA)]
 +
</texcode>
 +
 
</texcode>
 
</texcode>
  
 
== Example ==
 
== Example ==
<!-- Please fill in an example if you can -->
+
<context>
 +
 
 +
</context>
  
 
== See also ==
 
== See also ==

Revision as of 01:00, 4 December 2012

\definecolor

Syntax

\definecolor[...][...,...=...,...]
[...] name
r number red channel (RGB)
g number green channel (RGB)
b number blue channel (RGB)
c number cyan channel (CMYK)
m number magenta channel (CMYK)
y number yellow channel (CMYK)
k number black channel (CMYK)
s number gray value (Grayscale), if v isn't set
h number hue (HSB)
s number saturation (HSB)
v number brightness/value (HSB)
t number transparency factor
a number alternative (transparency method)
p number spotcolor percentage
e text spotcolor name
x text Hexadecimal RGB value (like in HTML), only with hex module

Description

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

To use hexadecimal colors in mkii you need to load the proper module first:

\setupcolor[hex]

Then the colors can be specified with

\definecolor[hex-red][h=FF0000]

Regarding the key a, which means transparency alternative method, there are a certain number of values (actually at least 13, from 0 to 12) whose meanings can be seen from below:

\definetransparency [none]        [0]
\definetransparency [normal]      [1]
\definetransparency [multiply]    [2]
\definetransparency [screen]      [3]
\definetransparency [overlay]     [4]
\definetransparency [softlight]   [5]
\definetransparency [hardlight]   [6]
\definetransparency [colordodge]  [7]
\definetransparency [colorburn]   [8]
\definetransparency [darken]      [9]
\definetransparency [lighten]    [10]
\definetransparency [difference] [11]
\definetransparency [exclusion]  [12]

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 in terms of fraction, processed by Lua.
\definecolor[ColorA][1.0(red)]
% succeeds
\definecolor[ColorB][.5(ColorA)]

</texcode>

Example

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: