Difference between revisions of "Command/definecolor"

From Wiki
Jump to navigation Jump to search
m (Reverted edits by Garulfo (talk) to last revision by Hraban)
Tag: Rollback
 
(2 intermediate revisions by 2 users not shown)
Line 49: Line 49:
 
   <tr valign="top" class="second">
 
   <tr valign="top" class="second">
 
     <td class="cmd">[[Command/keyword:h|h]]</td>
 
     <td class="cmd">[[Command/keyword:h|h]]</td>
     <td>[[Command/value:number|number]] hue (HSB)</td>
+
     <td>[[Command/value:number|number]] hue (HSB/HWB, 0–360)</td>
 
   </tr>
 
   </tr>
 
   <tr valign="top" class="second">
 
   <tr valign="top" class="second">
Line 57: Line 57:
 
   <tr valign="top" class="second">
 
   <tr valign="top" class="second">
 
     <td class="cmd">[[Command/keyword:v|v]]</td>
 
     <td class="cmd">[[Command/keyword:v|v]]</td>
     <td>[[Command/value:number|number]] brightness/value (HSB)</td>
+
     <td>[[Command/value:number|number]] brightness/value (HSB), blackness (HWB)</td>
 +
  </tr>
 +
  <tr valign="top" class="second">
 +
    <td class="cmd">[[Command/keyword:w|w]]</td>
 +
    <td>[[Command/value:number|number]] whiteness (HWB)</td>
 
   </tr>
 
   </tr>
 
   <tr valign="top" class="second">
 
   <tr valign="top" class="second">
Line 77: Line 81:
 
   <tr valign="top" class="second">
 
   <tr valign="top" class="second">
 
     <td class="cmd">[[Command/keyword:x|x]]</td>
 
     <td class="cmd">[[Command/keyword:x|x]]</td>
     <td>[[Command/value:text|text]] Hexadecimal RGB value (like in HTML), only with hex module</td>
+
     <td>[[Command/value:text|text]] Hexadecimal RGB value (like in HTML)</td>
 
   </tr>
 
   </tr>
 
</table>
 
</table>
Line 85: Line 89:
 
<code>\color</code> command.  
 
<code>\color</code> command.  
  
To use hexadecimal colors in mkii you need to load the proper module first:
+
 
 +
===Hex colors in MkII===
 +
To use hexadecimal colors in MkII you need to load the proper module first:
  
 
<texcode>
 
<texcode>
Line 93: Line 99:
 
Then the colors can be specified with
 
Then the colors can be specified with
 
<texcode>
 
<texcode>
\definecolor[hex-red][h=FF0000]
+
\definecolor[hex-red][h=FF0000] % it’s h instead of x in MkII
 
</texcode>
 
</texcode>
 +
 +
===Transparency===
  
 
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:
 
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:
Line 136: Line 144:
 
== Example ==
 
== Example ==
 
<context source=yes mode=mkiv>
 
<context source=yes mode=mkiv>
% mode=mkiv
 
 
 
% rgb
 
% rgb
\definecolor[bluu][r=.25, g = .1, b=1]
+
\definecolor[bluu][r=.25, g=.1, b=1]
 
Hey, \color[bluu]{look at that!}
 
Hey, \color[bluu]{look at that!}
  
 
% hex
 
% hex
%\setupcolor[hex] % needed in mkii only
+
\definecolor[salmon][x=AB5757]
\definecolor[salmon][h=AB5757]
 
 
Hey, \color[salmon]{look at that!}
 
Hey, \color[salmon]{look at that!}
  

Latest revision as of 13:46, 8 June 2020

\definecolor

Syntax (autogenerated)

\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


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


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/HWB, 0–360)
s number saturation (HSB)
v number brightness/value (HSB), blackness (HWB)
w number whiteness (HWB)
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)

Description

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


Hex colors in MkII

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] % it’s h instead of x in MkII

Transparency

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

Example

% 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?}

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: