Changes

Jump to navigation Jump to search
4,934 bytes added ,  21:57, 27 July 2017
m
Grayscale color: 1 = white, 0 = black
< [[Visuals]] | [[Graphics]] >{{Color navbox}}
=Using Colors=
Using colors with ConTeXt is easysupports two color models: [http:* Start with <cmd>setupcolors</cmd><tt>[state=start]</tt>en. Without that, everything appears in greyswikipedia.* RGB and CMYK are enabled by default. If you want only RGB or only CMYK color, use <tt>cmyk=no<org/tt> or <tt>rgb=no<wiki/tt>. Multitone colors see below. * For spot colors, say spot=yes. To eliminate everything except spot colours, leaving a clean file for professional printing, accompany this with rgb=no,cmyk=no. See spot colours below for more details.* Normally all colors are defined in RGB_color_model RGB ''and'' CMYK and get converted if needed.* You find lists of predefined colors in the files <tt>colo-xxx.tex</tt>, load them with <cmd>setupcolor</cmd><tt>[xxx]</tt>:** rgb: some simple colors, loaded by default (with translations typically used for the different interface languages!screen display)** xwi: X-Windows-colors** pra: PRAGMA ADE company colors** emaand [http: Emacs colors* Try the magic <cmd>showcolor</cmd><tt>[xxx]</tt>!* Define your own colors with <cmd>definecolor</cmd><tt>[blablue][r=en.1, g=wikipedia.1, b=1, c=1, m=.1, y=0, k=0, s=.2org/wiki/CMYK_color_model CMYK]</tt> (definition typically used for RGB, CMYK and Grey!printing)* You can define '''transparent''' colors through setting t, e.g. <tt>t=0.5<There is also support for [http:/tt>. Beware, most PDF viewers and printshops can't handle PDF transparences!* Use the color name like <tt>[color=blablue]</tt> in some <tt>\setupen.wikipedia..<org/tt> command.* Typeset single text elements with <cmd>color<wiki/cmd><tt>[blablueSpot_color spot colors]{nice blue text}</tt> or longer sections with <cmd>startcolor</cmd><tt>[blablue] ...</tt> <cmd>stopcolor</cmd>(typically used for offset printing) and transparencies.
(See also "Color and Background" in the manual!)= Before you start ... =
===Sample===1. It is usually a bad style to use explicit color switches in the text. It is 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>
\setupcolorsdefinehighlight[important][statecolor=startred]</texcode>and then use <code>\definecolor[blablue][r=important{important text}</code> in the text. 2.25, g=Colors are not enabled by default in MkII.1To enabled colors in MkII, b=1, c=1, muse<texcode>\setupcolors[state=start]</texcode> 3.1To disable colors in a document, yuse<texcode>\setupcolors[state=0, kstop]</texcode> =0, sBasic Usage =.2]
Here's some \color[blablue]{blue text} inbetween!
\showcolor[rgb]</texcode><context>\setupcolors[state=start]\definecolor[blablue][r=.1To color text, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]use
Here's some <texcode>\color[blabluedefined-color]{blue ... text... } inbetween!</texcode>
\showcolor[rgb]</context>or
=Colorgroups and Palettes=<cmd>definecolorgroup</cmd><tttexcode>\startcolor[name][system][valuesdefined-color] ... text ... \stopcolor</tttexcode>
where <cmdcode>definepaletdefined-color</code> is a color defined using {{cmd|definecolor}}. For example, <code>red<tt/code>[palettename][colorname1=groupcolor:1is one of the predefined colors. So, colorname2=groupcolorwe can use:2, ...]</tt>
Very interesting feature, to be described later... (see manual){| ! width="45%"| ! width="10%"| ! width="45%"| |- | <texcode>Three \color[red]{cool} cats</texcode>||<context mode=mkiv>\starttextThree \color[red]{cool} cats\stoptext</context>|}
=Spot colours=or
To produce a file ready for a clean PDF separation process at your print house, start with:{| ! width="45%"| ! width="10%"| ! width="45%"| |- | <texcode>\starttext\startcolor[red]\input tufte\stopcolor\stoptext</texcode>||<context mode=mkiv>\setuppapersize[A5]\starttext\startcolor[red]\input tufte\stopcolor\stoptext</context>|}
It is also possible to use RGB or CMYK or hex values to color text. The syntax for these is<cmdtexcode>setupcolors\colored[settings]{... text ...}</cmdtexcode>where <ttcode>[rgb=no,cmyk=yes,spot=yes,state=start,overprint=yes]settings</ttcode>are the same settings as used by {{cmd|definecolor}}. For example:
which will set things up for spot colors with CMYK allowed. The last setting ensures that black overprinting your spot colour tints will not knock out the colour - this is important for some types of commercial printing.
Then define your basic spot colour{| ! width="45%"| ! width="10%"| ! width="45%"| |- | <texcode>Three \colored[r=0. Note that the name cannot contain spaces or numbers (but we come to that later):1, g=0.8, b=0.8]{colorful} cats</texcode>||<context mode=mkiv>\starttextThree \colored[r=0.1, g=0.8, b=0.8]{colorful} cats\stoptext</context>|}
<cmd>definecolor</cmd><tt>[PantoneTwoNineFour][c=1,m=.56,y=0,k=.18]</tt>
Now '''Note'''. There is no need to use the color commands directly. Almost all ConTeXt commands accept a <code>color</code> key, and you can define the tints of this ink that you are actually going to use in your document<code>color=defined-color</code>. Let's say you'll have a 100% for headings:For example,
* To color the section titles red, use<cmdtexcode>definespotcolor</cmd><tt>[MyBlue][PantoneTwoNineFour]\setuphead[pcolor=1red]</tttexcode>
And then a 20% tint for nice display boxes:* To color the footnotes red, use<texcode>\setupfootnotes[color=red]</texcode>
<cmd>definespotcolor</cmd><tt>[MyBlueTint][PantoneTwoNineFour][p=etc.2]</tt>
And now you can happily use these named colours:
<texcode>\starttext \color[MyBlue]{Interesting}\stoptext</texcode>= Pre-defined colors =
If you are including graphics made by an external program, you might want to match the colour name used in the graphic with the colour name in your '''ConTeXt''' set-up so that only one colour space is used in the final file. Unfortunately Pantone names and others tend to have spaces and numbers in them, so you need to do a low-level mapping trick from your base name to the name you want embedded in the file:
<cmd>doregisterspotcolorname</cmd><tt>{PantoneTwoNineFour}{PANTONE 294 CV}</tt>== Default pre-defined colors ==
Now your output file should work beautifully with graphics embedded!The following colors are pre-defined in ConTeXt (see {{src|colo-imp-rgb.mkiv}}).
==Using the 'e' key to \definecolor to specify a spot colour name with spaces==
As an update to the above description on defining spot colours, you can now use the 'e' key when defining your spot colours in order to specify the precise colour names to be used by your ConTeXt set{| style="text-up in the output file. For examplealign:right; padding-right: 20px;"!| Name !! Color !style="width: 80px;"| Name !! Color !style="width: 100px;"| Name !! Color !style="width: 100px;"| Name !! Color|-|black||bgcolor="#000"| &nbsp;|white||bgcolor="#FFF"| &nbsp; |-|gray||bgcolor="#E6E6E6"| &nbsp;|lightgray||bgcolor="#D6D6D6"| &nbsp; |middlegray||bgcolor="#B9B9B9"| &nbsp; |darkgray||bgcolor="#999999"| &nbsp; |- |red||bgcolor="#FF0000"| &nbsp;|lightred||bgcolor="#FF0000"| &nbsp; |middlered||bgcolor="#CC0000"| &nbsp; |darkred||bgcolor="#990000"| &nbsp; |-|green||bgcolor="#00FF00"| &nbsp;|lightgreen||bgcolor="#00FF00"| &nbsp; |middlegreen||bgcolor="#00CC00"| &nbsp; |darkgreen||bgcolor="#009900"| &nbsp; |-|blue||bgcolor="#0000FF"| &nbsp;|lightblue||bgcolor="#0000FF"| &nbsp; |middleblue||bgcolor="#0000CC"| &nbsp; |darkblue||bgcolor="#000099"| &nbsp; |-|cyan||bgcolor="#00FFFF" | &nbsp;| &nbsp; ||bgcolor=| &nbsp; |middlecyan||bgcolor="#00CCCC" | &nbsp;|darkcyan||bgcolor="#006666" | &nbsp;|-|magenta||bgcolor="#FF00FF" | &nbsp;| &nbsp; ||bgcolor=| &nbsp; |middlemagenta||bgcolor="CC00CC" | &nbsp;|darkmagenta||bgcolor="660066" | &nbsp;|-|yellow||bgcolor="#FFFF00" | &nbsp;| &nbsp; ||bgcolor=| &nbsp; |middleyellow||bgcolor="CCCC00" | &nbsp;|darkyellow||bgcolor="666600" | &nbsp;
<texcode>% Define spot colours using 'e=....' to specify colour names to use in output file\definecolor [PantoneThreeZeroEight] [c=1,m=.05,y=0,k=.47,e=PANTONE 308 CV]|}
\definecolor [PantoneTwoNineEight] [c=.69,m=.07,yX11 Colors =0,k=0,e=PANTONE 298 CV]
% Define tints In addition to the above basic color, ConTeXt also includes a definition of spot colours to be used in document for colouring text\definespotcolor [DarkBlue] [PantoneThreeZeroEight] the [p=1http://www.w3.org/TR/2002/WD-css3-color-20020219/#x11-color X11 colors]. To load this list ({{src|colo-imp-xwi.mkiv}}), use
<texcode>\definespotcolor usecolors[LightBluexwi] [PantoneTwoNineEight] [p=1]</texcode>
(Tested only on minimal Linux distribution dated 31 Aug 2005 - can others confirm thisto be true across This loads the board now?)following additional colors:
Any {| style="text between a <cmd>startcolor[DarkBlue]</cmd> and <cmd>stopcolor</cmd> should now be assigned to the correct spot colour channel - Pantone 308 CV align: right; padding- on output. More importantly if you include an external figure containing areas of this colour then your text and those parts of the graphic which have the same colour should now appear together in the 'Pantone 308 CV' colour channel on colour separation. right: 20px;"!| Name !! Color !style="width: 80px;"| Name !! Color !style="width: 100px;"| Name !! Color !style="width: 100px;"| Name !! Color|-|-|aliceblue||bgcolor="#EFF7FF"|&nbsp;|antiquewhite||bgcolor="#F9EAD6"|&nbsp;|aquamarine||bgcolor="#7FFFD3"|&nbsp;|azure||bgcolor="#EFFFFF"|&nbsp;|-|beige||bgcolor="#F4F4DB"|&nbsp;|bisque||bgcolor="#FFE2C4"|&nbsp;|black||bgcolor="#000000"|&nbsp;|blanchedalmond||bgcolor="#FFEACC"|&nbsp;|-|blue||bgcolor="#0000FF"|&nbsp;|blueviolet||bgcolor="#892BE2"|&nbsp;|brown||bgcolor="#A52828"|&nbsp;|burlywood||bgcolor="#DDB787"|&nbsp;|-|cadetblue||bgcolor="#5E9EA0"|&nbsp;|chartreuse||bgcolor="#7FFF00"|&nbsp;|chocolate||bgcolor="#D1681E"|&nbsp;|coral||bgcolor="#FF7F4F"|&nbsp;|-|cornflowerblue||bgcolor="#6393ED"|&nbsp;|cornsilk||bgcolor="#FFF7DB"|&nbsp;|cyan||bgcolor="#00FFFF"|&nbsp;|darkgoldenrod||bgcolor="#B7870A"|&nbsp;|-|darkgreen||bgcolor="#006300"|&nbsp;|darkkhaki||bgcolor="#BCB76B"|&nbsp;|darkolivegreen||bgcolor="#546B2D"|&nbsp;|darkorange||bgcolor="#FF8C00"|&nbsp;|-|darkorchid||bgcolor="#9933CC"|&nbsp;|darksalmon||bgcolor="#E8967A"|&nbsp;|darkseagreen||bgcolor="#8EBC8E"|&nbsp;|darkslateblue||bgcolor="#473D8C"|&nbsp;|-|darkturquoise||bgcolor="#00CED1"|&nbsp;|darkviolet||bgcolor="#9300D3"|&nbsp;|deeppink||bgcolor="#FF1493"|&nbsp;|deepskyblue||bgcolor="#00BFFF"|&nbsp;|-|dodgerblue||bgcolor="#1E8EFF"|&nbsp;|firebrick||bgcolor="#B22121"|&nbsp;|floralwhite||bgcolor="#FFF9EF"|&nbsp;|forestgreen||bgcolor="#218C21"|&nbsp;|-|gainsboro||bgcolor="#DBDBDB"|&nbsp;|ghostwhite||bgcolor="#F7F7FF"|&nbsp;|gold||bgcolor="#FFD600"|&nbsp;|goldenrod||bgcolor="#D8A521"|&nbsp;|-|green||bgcolor="#00FF00"|&nbsp;|greenyellow||bgcolor="#ADFF2D"|&nbsp;|honeydew||bgcolor="#EFFFEF"|&nbsp;|hotpink||bgcolor="#FF68B5"|&nbsp;|-|indianred||bgcolor="#CC5B5B"|&nbsp;|ivory||bgcolor="#FFFFEF"|&nbsp;|khaki||bgcolor="#EFE58C"|&nbsp;|lavender||bgcolor="#E5E5F9"|&nbsp;|-|lavenderblush||bgcolor="#FFEFF4"|&nbsp;|lawngreen||bgcolor="#7CFC00"|&nbsp;|lemonchiffon||bgcolor="#FFF9CC"|&nbsp;|lightblue||bgcolor="#ADD8E5"|&nbsp;|-|lightcoral||bgcolor="#EF7F7F"|&nbsp;|lightcyan||bgcolor="#E0FFFF"|&nbsp;|lightgoldenrod||bgcolor="#EDDD82"|&nbsp;|lightgoldenrodyellow||bgcolor="#F9F9D1"|&nbsp;|-|lightpink||bgcolor="#FFB5C1"|&nbsp;|lightsalmon||bgcolor="#FFA07A"|&nbsp;|lightseagreen||bgcolor="#21B2AA"|&nbsp;|lightskyblue||bgcolor="#87CEF9"|&nbsp;|-|lightslateblue||bgcolor="#8470FF"|&nbsp;|lightsteelblue||bgcolor="#AFC4DD"|&nbsp;|lightyellow||bgcolor="#FFFFE0"|&nbsp;|limegreen||bgcolor="#33CC33"|&nbsp;|-|linen||bgcolor="#F9EFE5"|&nbsp;|magenta||bgcolor="#FF00FF"|&nbsp;|maroon||bgcolor="#AF3060"|&nbsp;|mediumaquamarine||bgcolor="#66CCAA"|&nbsp;|-|mediumblue||bgcolor="#0000CC"|&nbsp;|mediumorchid||bgcolor="#BA54D3"|&nbsp;|mediumpurple||bgcolor="#9370DB"|&nbsp;|mediumseagreen||bgcolor="#3DB270"|&nbsp;|-|mediumslateblue||bgcolor="#7A68ED"|&nbsp;|mediumspringgreen||bgcolor="#00F999"|&nbsp;|mediumturquoise||bgcolor="#47D1CC"|&nbsp;|mediumvioletred||bgcolor="#C61484"|&nbsp;|-|midnightblue||bgcolor="#191970"|&nbsp;|mintcream||bgcolor="#F4FFF9"|&nbsp;|mistyrose||bgcolor="#FFE2E0"|&nbsp;|moccasin||bgcolor="#FFE2B5"|&nbsp;|-|navajowhite||bgcolor="#FFDDAD"|&nbsp;|navy||bgcolor="#00007F"|&nbsp;|navyblue||bgcolor="#00007F"|&nbsp;|oldlace||bgcolor="#FCF4E5"|&nbsp;|-|olivedrab||bgcolor="#6B8E23"|&nbsp;|orange||bgcolor="#FFA500"|&nbsp;|orangered||bgcolor="#FF4400"|&nbsp;|orchid||bgcolor="#D870D6"|&nbsp;|-|palegoldenrod||bgcolor="#EDE8AA"|&nbsp;|palegreen||bgcolor="#99F999"|&nbsp;|paleturquoise||bgcolor="#AFEDED"|&nbsp;|palevioletred||bgcolor="#DB7093"|&nbsp;|-|papayawhip||bgcolor="#FFEFD6"|&nbsp;|peachpuff||bgcolor="#FFD8BA"|&nbsp;|peru||bgcolor="#CC843F"|&nbsp;|pink||bgcolor="#FFBFCC"|&nbsp;|-|plum||bgcolor="#DDA0DD"|&nbsp;|powderblue||bgcolor="#AFE0E5"|&nbsp;|purple||bgcolor="#A021EF"|&nbsp;|red ||bgcolor="#FF0000"|&nbsp;|-|rosybrown||bgcolor="#BC8E8E"|&nbsp;|royalblue||bgcolor="#3F68E0"|&nbsp;|saddlebrown||bgcolor="#8C4411"|&nbsp;|salmon||bgcolor="#F97F72"|&nbsp;|-|sandybrown||bgcolor="#F4A360"|&nbsp;|seagreen||bgcolor="#2D8C56"|&nbsp;|seashell||bgcolor="#FFF4ED"|&nbsp;|sienna||bgcolor="#A0512D"|&nbsp;|-|skyblue||bgcolor="#87CEEA"|&nbsp;|slateblue||bgcolor="#6B59CC"|&nbsp;|snow||bgcolor="#FFF9F9"|&nbsp;|springgreen||bgcolor="#00FF7F"|&nbsp;|-|steelblue||bgcolor="#4482B5"|&nbsp;|tan ||bgcolor="#D1B58C"|&nbsp;|thistle||bgcolor="#D8BFD8"|&nbsp;|tomato||bgcolor="#FF6347"|&nbsp;|-|turquoise||bgcolor="#3FE0D1"|&nbsp;|violet||bgcolor="#ED82ED"|&nbsp;|violetred||bgcolor="#D1218E"|&nbsp;|wheat||bgcolor="#F4DDB2"|&nbsp;|-|white||bgcolor="#FFFFFF"|&nbsp;|whitesmoke||bgcolor="#F4F4F4"|&nbsp;|yellow||bgcolor="#FFFF00"|&nbsp;|yellowgreen||bgcolor="#99CC33"|&nbsp;|}
For example, if your original graphic is an EPS file containing the following lines:== Additional pre-defined colors ==
%%DocumentCustomColors: (PANTONE 298 CV) %%+ (PANTONE 308 CV) %%CMYKCustomColor: 0In addition to the above, there are two other sets of pre-defined colors.69 0.07 0 0 (PANTONE 298 CV) %%+ 1 0.05 0 0.47 (PANTONE 308 CV)
and you convert this to a PDF using {| class="wikitable"| x11 || <ttcode>ps2pdf\usecolors[x11]</ttcode> for inclusion | {{src|colo-imp-x11.mkiv}}| 658 extended Xorg color keywords (WWW), defined in your '''ConTeXt''' document your PDF graphic will then contain something like:hex RGB|-| crayola || <code>\usecolors[crayola] </code> | {src|colo-imp-crayola.mkiv} || 235 Crayola (Binney & Smith) colors|-| ema || <code>\usecolors[ema]</code>| {{src|colo-imp-ema.mkiv}} || 549 Emacs colors|-| RAL || <code>\usecolors[ral]</code>| {{src|colo-imp-ral.mkiv}} || 213 RAL color system (Deutsches Institut für Gütesicherung und Kennzeichnung)|}
<code>
8 0 obj
[/Separation
/PANTONE#20308#20CV
/DeviceCMYK
9 0 R]endobj
10 0 obj
[/Separation
/PANTONE#20298#20CV
/DeviceCMYK
11 0 R]endobj
</code>
Note how the space characters in the colour name are now encoded as '#20', but the colour names are essentially identical between the original EPS graphic, the new PDF graphic and your text.= Defining New Colors =
A good way of testing colour separation if you don't have access to expensive pre-flight PDF validation tools is to use New colors may be defined in the following GhostScript command:ways
gs {| class="wikitable"! Name !! Sytanx (and Example) !! Explanation|-| RGB color model| <texcode>\definecolor[...][r=..., g=..., b=...]</texcode> For example,<texcode>\definecolor[lime][r=0.75, g=1, b=0] -dBATCH This is \color[lime]{a new color} that we defined</texcode>| The values for <code>r</code>, <code>g</code>, and <code>b</code> are floating point number between <code>0</code> and <code>1</code>. |-dNOPAUSE | CMYK color model| <texcode>\definecolor[...][c=.., m=.., y=.., k=..]</texcode> -sDEVICEFor example,<texcode>\definecolor[lime][c=0.25, m=0, y=1, k=tiffsep 0] This is \color[lime]{a new color} that we defined</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>. |-dDOINTERPOLATE | HSV color model|<texcode>\definecolor[...][h=.., s=.., v=..]</texcode> -dTextAlphaBitsFor example,<texcode>\definecolor[lime][h=75, s=1, v=4 1] This is \color[lime]{a new color}that we defined</texcode>| The value for <code>h</code> is between <code>0</code> and <code>360</code>; the values for <code>s</code>, <code>v</code> are floating point numbers between <code>0</code> and <code>1</code>. |-dGraphicsAlphaBits| Hex| <texcode>\definecolor[...][h=4 ...]</texcode> For example,<texcode>\definecolor[lime][h=BFFF00] This is \color[lime]{a new color}that we defined</texcode>| The value for <code>x</code> is a three-sOutputFile=outputbyte hexadecimal number where the bytes represent the red, green, and blue values. This follows the HTML and CSS style of defining colors.tif \ |-r120 |Gray scale|<texcode>\definecolor[...][s=...]</texcode> For example, -MaxSeparations<texcode>\definecolor[screen][g=8 0.5] This is \color[screen]{a new color} inputthat 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).pdf|}
This renders a PDF file '''Note''': The key-values are overloaded. For example, <code>h</code> is used for both HSV model and Hex model; <code>s<tt/code>inputis used for both HSV model and grayscale model.pdfThe distinction is made based on the presence or absence of the <code>v</ttcode> as a set of TIFF files:key.
output.tif - Composite including CMYK approximations to spot colours output.tif.Black.tif - K channel output.tif.Cyan.tif - C channel output.tif.Magenta.tif - M channel output.tif.Yellow.tif - Y channel output.tif.s0.tif - Pantone 308 CV output.tif.s1.tif - Pantone 298 CV== Cloning existing colors ==
=Multitones=You can ''clone'' an existing color using<texcode>\definecolor[new-color][old-color]</texcode>
Hans wrote on the mailinglist on 2004-12-27 about handling of multitone colors:For example{| ! width="45%"| ! width="10%"| ! width="45%"||<texcode>\usecolors[xwi]\definecolor[highlight][yellow]\defineframed [important] [location=low, frame=off, background=color, backgroundcolor=highlight]
Currently it's done by pdftoolsThis is a \important{important}word.rb
Once pdfxTeX becomes pdfeTeX out of \definecolor[highlight][lavenderblush]This is a sudden your beta can do it as well\important{important}word.</texcode>||<context mode=mkiv>\usecolors[xwi]\definecolor[highlight][yellow]\defineframed[important][location=low, frame=off, background=color, backgroundcolor=highlight]
I still need to figure out This is a way to automatically reverse the graphic, but one of these days you can start using it\important{important}word.
Actually, multitones for text already work out of the box:\definecolor[highlight][lavenderblush]This is a \important{important}word.<texcode/context>\setupcolors[state=start]|}
\definecolor [blue] [c=1,m=.38,yAdapting existing colors =0,k=.64]\definecolor [yellow] [c=0,m=.28,y=1,k=.06]
\definecolor [blue-100] [blue] [p=1]\definecolor [yellow-100] [yellow] [p=1]{{todo | add details about this}}
\definemultitonecolor [combicolor] [blue=.12,yellowAdvanced Usage =.28] [c=.1,m=.1,y=.3,k=.1]
\starttext== Changing color of entire document ==
\startcolor[blue]\blackrule[width=3cm,height=3cm]\stopcolorTo change the main text color of the document use
<texcode>\startcolorsetupcolors[yellow]\blackrule[widthtextcolor=3cm,height=3cmdefined-color]\stopcolor</texcode>
\startcolor[combicolor]\blackrule[width=3cmFor example,height=3cm]\stopcolor
{|
! width="45%"|
! width="10%"|
! width="45%"|
|-
|<texcode>\setupcolors[textcolor=blue]
\starttext
text
\stoptext
</texcode>
(The CMYK color spec is the fall back color used on screen; one can preview separations in full Acrobat 7.)||<context mode=mkiv>\setupcolors[textcolor=blue]\starttexttext\stoptext</context>|}
== Changing background color of page ==
The background color of the page can be changed using<texcode>\setupbackgrounds[page][background=Transparent Colorscolor,backgroundcolor=defined-color]</texcode>
As mentioned earlier, transparent colors can be produced by setting the <tt>t</tt> value for the color. Hans Hagen posted the following sample code for transparent colors on the mailing list on 2005-07-13; the yellow blocks have been added to demonstrate the order in which the blocks are drawn on the page; the first yellow block is behind the transparent red and blue blocks, while the second is in front of them.
For example,{| ! width="45%"| ! width="10%"| ! width="45%"| |- | <texcode>\setuppapersize[A10]\setupbackgrounds[page][background=color,backgroundcolor=blue] \starttexttext\stoptext</texcode>||<context>\setuppapersize[A10]
\setupcolors[state=start]
\definecolor [transparentred] [r=1,t=.5,a=1]\definecolor setupbackgrounds[transparentbluepage] [b=1,t=.5,a=1]\definecolor [solidyellow] [y=1,tbackground=1color,abackgroundcolor=1blue]
\starttext
text
\stoptext
</context>
|}
 
\startTEXpage
This is some sample text that goes behind the rectangles\hskip-8cm
\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cm
\blackrule[width=2cm,height=2cm,color=transparentred]\hskip-0.67cm
\blackrule[width=2cm,height=1cm,depth=1cm,color=transparentblue]\hskip-0.67cm
\blackrule[width=2cm,height=2cm,color=solidyellow]\hskip2cm.
\stopTEXpage
\stoptext
</texcode>
<context>\setupcolors[state=start]\definecolor [transparentred] [r=1,tUsing colors in MetaPost =.5,a=1] A color defined in TeX is available in MetaPost using `\definecolor [transparentblue] [b=1,t=MPcolor{...}`.5,a=1]\definecolor [solidyellow] [y=1,t=1,a=1]For example:
{|
|-
|<texcode>
\definecolor[highlight][r=0.8,g=0.8,b=0]
\starttext
\color[highlight]{Highlighted text in TeX}
\startTEXpagestartMPcodeThis is some sample label("Highlighted text that goes behind the rectanglesin MetaPost", origin) withcolor \hskip-8cmMPcolor{highlight};\blackrule[widthstopMPcode</texcode>|<context mode=2cm,height=1cm,depth=1cm,color=solidyellow]\hskip-0.67cmmkiv>\blackruledefinecolor[highlight][widthr=2cm,height=2cm0.8,colorg=transparentred]\hskip-0.67cm\blackrule[width=2cm8,heightb=1cm,depth=1cm,color=transparentblue0]\hskip-0.67cmstarttext\blackrulecolor[width=2cm,height=2cm,color=solidyellowhighlight]\hskip2cm.\stopTEXpage{Highlighted text in TeX}
\stoptextstartMPcodelabel("Highlighted text in MetaPost", origin) withcolor \MPcolor{highlight};\stopMPcode
</context>
|}
 
Note that `\MPcolor{...}` behaves similar to a `color` primitive in MetaPost. For example, the following is valid MetaPost code.
<texcode>color myColor; myColor = 0.5[\MPcolor{highlight}, white];</texcode>
=Colorizing Grayscale Pictures=
Another sample by Hans (mailing list 2005-11-16) demonstrates a lot of different possibilities:== Using colors in TikZ ==
<texcode>\setuplayout[header=0pt,footerViewing pre-defined color =0pt,width=middle,height=middle,backspace=1cm,topspace=1cm]\setupcolors[state=start]
\startbuffer\definecolor [blue] [c=1, m=.38, yView all defined colors =0, k=.64]\definecolor [yellow] [c=0, m=.28, y=1, k=.06]
\definecolor [blueTo view pre-100] [blue] [p=1]\definecolor [yellowdefined colors, you can use {{cmd|showcolor}}. For example, to see all the colors defined in {{src|colo-100] [yellow] [p=1]imp-x11.mkiv}}, use (output truncated for display here ...)
{| |-|<texcode>\definemultitonecolor showcolor[combicolorx11] </texcode>|<context mode=mkiv>\startTEXpage[blueheight=.12, yellow=.285cm] \showcolor[c=.1, m=.1, y=.3, k=.1x11]\stopTEXpage</context>|}
\definemultitonecolor [combicolor-b] [blue=1] [c=1If you use {{cmd|showcolor}} without any argument, m=all currently defined colors are shown.38, y=0, k=.64] % force multitone\definemultitonecolor [combicolor-y] [yellow=1] [c=0, m=.28, y=1, k=.06] % force multitone
\useexternalfigure[demo-a][mill.png] [object=no, width=.2\textwidth]\useexternalfigure[demo-b][hacker-bw.jpg][objectView specific defined colors =no, width=.2\textwidth]
\startbaselinecorrection\startcombination[4*1] {\externalfigure[demo-To view the components of a]} {no defined color} {\externalfigure[demo-a][color=combicolor]} {indexed duotone} {\externalfigure[demo-a][color=combicolor-b]} {spot color} {\externalfigure[demo-a][color=combicolor-y]} {spot color}\stopcombination\stopbaselinecorrection, you can use:
\startbaselinecorrection\startcombination[4*1] {\externalfigure[demo-b]} {no colorcmd|showcolorcomponents} {\externalfigure[demo-b][color=combicolor]} {indexed duotone} {<texcode>\externalfigure[demo-b]showcolorcomponents[color=combicolor-b]} {spot color} {\externalfigure[demo-b][1, color=combicolor-y2]} {spot color}\stopcombination\stopbaselinecorrection</texcode>
\startbaselinecorrection\startcombination[4*1] {\externalfigure[demo-a]} {no color} {\externalfigure[demo-a][color=combicolor]} {indexed duotone} {\externalfigure[demo-a][color=blue-100]} {spot color} {\externalfigure[demo-a][color=yellow-100]} {spot color}\stopcombination\stopbaselinecorrectionFor example,
\startbaselinecorrection{| \startcombination[4*1]|- {|<texcode>\externalfigureshowcolorcomponents[demo-bred,middlered,darkred]} {no color}</texcode> {\externalfigure[demo-b][color|<context mode=combicolor]} {indexed duotone} {mkiv>\externalfigure[demo-b]showcolorcomponents[color=blue-100red,middlered,darkred]} {spot color}</context> {\externalfigure[demo-b][color=yellow-100]} {spot color|}\stopcombination\stopbaselinecorrection\stopbuffer
* {{cmd|colorcomponents}}* {{cmd|transparencycomponents}}* {{cmd|processcolorcomponents}}<texcode>\getbuffer colorcompoents{defined-color}\typebuffertranparencycomponents{defined-color}\processcolorcomponents{defined-color}</texcode>
For example,{||-|<texcode>\stoptextstartlines\colorcomponents{red}\transparencycomponents{red}\processcolorcomponents{red}\stoplines
</texcode>
|
<context mode=mkiv>
\startlines
\colorcomponents{red}
\transparencycomponents{red}
\processcolorcomponents{red}
\stoplines
</context>
|}
= Colors with Hexadecimal Numbers Testing if color is defined To test if a color is defined, use * {{cmd|doifcolor}}* {{cmd|doifcolorelse}} Usage:
You can also use hexadecimal numers to specify colors. You need to load the '''hex''' color module first:
<texcode>
\setupcolor[hex]</texcode>and they you may define colors with<texcode>doifcolor{color-name}{... if branch ... }\definecolor[hexdoifcolorelse{color-red][h=FF0000]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 and graphics.
 
* Tina Sutton, Bride M Whelan: The Complete Color Harmony. Rockport Publishers (2004). ISBN 978-1592530311 (recommanded in the mailing list)
 
 
 
{{Getting started navbox}}
4

edits

Navigation menu