Changes

Jump to navigation Jump to search
1,224 bytes removed ,  15:04, 7 October 2019
m
→‎Defining New Colors: bit of visual cleanup
< [[Visuals]] | [[Graphics]] > = Enabling colors = In current versions (newer than 11.05.2009) of ConTeXt mkiv, colors are enabled by default. In older versions, colors must be enabled using {{cmd|setupcolorsColor navbox}}<tt>[state=start]</tt> = Defining Colors = == Choosing a color model == * RGB and CMYK are enabled by default. If you want only RGB or only CMYK color, use <tt>cmyk=no</tt> or <tt>rgb=no</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 ''and'' CMYK and get converted if needed. == Transparency == Acrobat Reader might not render transparency using RGB in a PDF that is displayed on a monitor. If the colours do not appear correctly, add the following code: <code>\setupcolors[pagecolormodel=auto]</code> In Acrobat, when transparency is used, a different route is followed (at least in the past) when rendering. Rendering colorspaces might be adapted to the output medium so it's a combination of colorspace, monitor/paper, calibration, knockout/overprint, transparency groups, assumptions, and so forth.    == Using predefined colors: {{cmd|setupcolor}} ==
Colors have identifiers, some of which are grouped in more or less
widely known sets. The primary example of these possibly are the
[http://www.w3.org/TR/2002/WD-css3-color-20020219/#x11-color named colors of the X Windowing System],
a set of RGB vectors.
With the growth of the WWW this list of definitions eventually achieved
the rank of the default ''Web colors''.
For convenience the X11 colors, along with a couple others, are
pre-defined in Context in the form of a loadable module.
''NB''ConTeXt supports two color models: there are two sets representing the web colors[http:<code>xwi</code> and <code>x11</code>en. The main difference between themis that the latter defines variations for many keywordswikipedia.For instance, instead of having only one color ''deepskyblue'' with<code>xwi<org/wiki/code>, you get another four colors ''deepskyblue1'',''deepskyblue2'' ''deepskyblue3'' RGB_color_model RGB] (typically used for screen display) and ''deepskyblue4'' with the<code>x11<[http://code> seten.wikipedia.org/wiki/CMYK_color_model CMYK] (Another technical aspect typically used for printing). There is that the latter are specified usinghexadecimal RGB values whereas the former rely on decimal valuesalso support for [http://en.wikipedia.org/wiki/Spot_color spot colors] (typically used for offset printing)and transparencies.
To use them and any of the others listed below, pass the respectivedefinition identifier to {{cmd|setupcolor}}:= Before you start ... =
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>
\setupcolordefinehighlight[x11important][color=red]
</texcode>
and then use <code>\important{important text}</code> in the text.
The macro {{cmd|showcolor}} pretty prints a the list of all named2. Colors are not enabled by default in MkII. To enabled colors in a definition set.MkII, use<context mode="mkiv" source="yes" text="yields several pages of this:"texcode>\showcolorsetupcolors[rgbstate=start]</contexttexcode=== MkIV ===
The definitions reside 3. To disable colors in the files prefixed <code>colo-imp-</code>a document, toseparate them from the color functionality that is implemented inuse<codetexcode>colo-xxx.mkiv\setupcolors[state=stop]</codetexcode>.
{|! id !! source !! description|-| rgb || {{src|colo-imp-rgb.mkiv}} || some simple colors, loaded by default (with translations for the different interface languages!)|-| xwi || {{src|colo-imp-xwi.mkiv}}| Xorg color keywords (WWW), defined in decimal RGB|-| x11 || {{src|colo-imp-x11.mkiv}}| extended Xorg color keywords (WWW), defined in hex RGB|-| ema || {{src|colo-imp-ema.mkiv}} || Emacs colors|-| dem || {{src|colo-imp-dem.mkiv}}| color groups and palets for different language interfaces|}= Basic Usage =
=== MkII ===
You will find lists of predefined colors in the files<tt>colo-xxx.mkii</tt>To color text, load them with{{cmd|setupcolor}}<tt>[xxx]</tt>.{|! id !! source !! description|-| rgb || {{src|colo-rgb.mkii}} || some simple colors, loaded by default (with translations for the different interface languages!)|-| x11 || {{src|colo-x11.mkii}} || Xorg-colors (hex)|-| xwi || {{src|colo-xwi.mkii}} || Xorg-colors (decimal)|-| pra || {{src|colo-???.mkii|link=no}}| PRAGMA ADE corporate design (not included in the distribution?)|-| ema || {{src|colo-ema.mkii}} || Emacs colors|}use
=== Alternatives ===<texcode>\color[defined-color]{ ... text ... }</texcode>
You can generate an alternative definition set based on the results ofthe [http://blog.xkcd.com/2010/05/03/color-survey-results/ xkcd color survey]with the[https://bitbucket.org/phg/xcs-colors <code>xcs-colors.lua</code> script].or
== Defining colors: {{cmd|definecolor}} == {{cmd|definecolor}}<tttexcode>\startcolor[blabluedefined-color][r= ...1, g=text .1, b=1, c=1, m=.1, y=0, k=0, s=.2]\stopcolor</tttexcode> (definition for RGB, CMYK and Grey!).See also [[Command/definecolor]].
where <code>defined-color</code> is a color defined using {{cmd|definecolor}}. For example, <code>red</code> is one of the predefined colors. So, we can use:
{|
|-
| <texcode>
\definecolor[blablue][r=.25, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2] Here's some Three \color[blabluered]{blue textcool} inbetween!cats
</texcode>
|
| <contextmode=mkiv>\setupcolors[state=start]starttext\definecolor[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2] Here's some Three \color[blabluered]{blue textcool} inbetween!cats\stoptext
</context>
|}
=== Colors with Hexadecimal Numbers ===or
You can also use hexadecimal numers to specify colors. You need to load the '''hex''' color module first:
{|
! width="45%"|
|-
| <texcode>
\setupcolorstarttext\startcolor[hexred]\definecolor[salmon][h=AB5757]input tufte\stopcolorHey, \color[salmon]{look at that!}stoptext
</texcode>
|
|<contextmode=mkiv>\setupcolorssetuppapersize[state=startA5]\setupcolorstarttext\startcolor[hexred]\definecolor[salmon][h=AB5757]input tufte\stopcolorHey, \color[salmon]{look at that!}stoptext
</context>
|}
===Transparent Colors===It is also possible to use RGB or CMYK or hex values to color text. The syntax for these is You can define '''transparent''' colors through setting t, e<texcode>\colored[settings]{... text ..g. }</texcode>where <ttcode>t=0.5settings</ttcode>are the same settings as used by {{cmd|definecolor}}. Beware, some PDF viewers and printshops can't handle PDF transparences!For example:
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.
{|
|-
| <texcode>
Three \definecolor [transparentred] colored[r=0.1,tg=0.58,ab=10.8]{colorful} cats</texcode>||<context mode=mkiv>\definecolor starttextThree \colored[transparentblue] [br=0.1,tg=0.58,b=0.8]{colorful} cats\stoptext</context>|}  '''Note'''. There is no need to use the color commands directly. Almost all ConTeXt commands accept a<code>color</code> key, and you can use <code>color=1]defined-color</code>. For example,  * To color the section titles red, use<texcode>\definecolor setuphead[solidyellowcolor=red] </texcode> * To color the footnotes red, use<texcode>\setupfootnotes[ycolor=1,tred]</texcode> etc.  =1,aPre-defined colors =1]
\starttext
\startTEXpageThis is some sample text that goes behind the rectangles\hskip-8cm\blackrule[width=2cm,height=1cm,depth=1cm,color=solidyellow]\hskipDefault pre-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,heightdefined colors =2cm,color=solidyellow]\hskip2cm.\stopTEXpage
\stoptext</texcode>The following colors are pre-defined in ConTeXt (see {{src||<context>\setupcolors[state=start]\definecolor [transparentred] [r=1,t=colo-imp-rgb.5,a=1]\definecolor [transparentblue] [b=1,t=mkiv}}).5,a=1]\definecolor [solidyellow] [y=1,t=1,a=1]
\starttext
\startTEXpageThis is some sample {| style="text that goes behind the rectangles\hskip-8cmalign: right; padding-right: 20px;"\blackrule[!| Name !! Color !style="width: 80px;"| Name !! Color !style=2cm,height"width: 100px;"| Name !! Color !style=1cm,depth"width: 100px;"| Name !! Color|-|black||bgcolor=1cm,color"#000"| &nbsp;|white||bgcolor=solidyellow]\hskip"#FFF"| &nbsp; |-0.67cm\blackrule[width|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=2cm,height"#00FFFF" | &nbsp;| &nbsp; ||bgcolor=2cm,color| &nbsp; |middlecyan||bgcolor=transparentred]\hskip"#00CCCC" | &nbsp;|darkcyan||bgcolor="#006666" | &nbsp;|-0.67cm\blackrule[width|magenta||bgcolor=2cm,height"#FF00FF" | &nbsp;| &nbsp; ||bgcolor=1cm,depth| &nbsp; |middlemagenta||bgcolor=1cm,color"CC00CC" | &nbsp;|darkmagenta||bgcolor=transparentblue]\hskip"660066" | &nbsp;|-0.67cm\blackrule[width|yellow||bgcolor=2cm,height"#FFFF00" | &nbsp;| &nbsp; ||bgcolor=2cm,color| &nbsp; |middleyellow||bgcolor=solidyellow]\hskip2cm."CCCC00" | &nbsp;\stopTEXpage|darkyellow||bgcolor="666600" | &nbsp;
\stoptext
</context>
|}
== Defining color schemes: {{cmd|definecolorgroup}} and {{cmd|definepalet}}X11 Colors =={{cmd|definecolorgroup}}<tt>[name][system][values]</tt>
In addition to the above basic color, ConTeXt also includes a definition of the [http://www.w3.org/TR/2002/WD-css3-color-20020219/#x11-color X11 colors]. To load this list ({{cmdsrc|definepaletcolo-imp-xwi.mkiv}}<tt>[palettename][colorname1=groupcolor:1, colorname2=groupcolor:2), ...]</tt>use
Very interesting feature, see also the manual and here on the wiki <texcode>\usecolors[[Commandxwi]</definecolor]]texcode>
=Choosing a color scheme=This loads the following additional colors:
There are three basic strategies to select color combinations for a particular design{| style="text-align: right; padding-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;|}
# Create a color scheme by picking several == Additional pre-defined colors found within the objects to be used (photographs, pictures, etc)# Create colors derived from those found in the objects to be used# Create a color scheme based on the message to convey / the psychological effects of color==
See for additional help & reference:* [http://colorschemedesigner.com/ colorschemedesigner.com] - Useful site In addition to help choose a color scheme in rgb color space* Tina Suttonthe above, Bride M Whelan: The Complete Color Harmony. Rockport Publishers (2004)there are two other sets of pre-defined colors. ISBN 978-1592530311 (recommanded in the mailing list)
{| class="wikitable"
| x11 || <code>\usecolors[x11]</code>
| {{src|colo-imp-x11.mkiv}}
| 658 extended Xorg color keywords (WWW), defined in 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)
|-
| Solarized || <code>\usecolors[solarized]</code>
| {{src|colo-imp-solarized.mkiv}} || 16 solarized colors
|}
=Using Defining New Colors=
* Use New colors may be defined in the color name like <tt>[color=blablue]</tt> in some <tt>\setup...</tt> command.following ways
{| class="wikitable"! Name !! Syntax (and Example) !! Explanation|-| style= With text "width:20%;" | RGB color model| style="width:40%;" | <texcode>\definecolor[...][r=..., g=..., b=...]</texcode> For example,<texcode>\definecolor[lime][r=0.75, g=1, b=0] 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>. |-| CMYK color model| <texcode>\definecolor[...][c=.., m=.., y=.., k=..]</texcode> For example,<texcode>\definecolor[lime][c=0.25, m=0, y=1, k=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>. |-| HSV color model|<texcode>\definecolor[...][h=.., s=.., v=..]</texcode> For example,<texcode>\definecolor[lime][h=75, s=1, v=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>. |-| Hex| <texcode>\definecolor[...][h=...]</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-byte hexadecimal number where the bytes represent the red, green, and blue values. This follows the HTML and CSS style of defining colors.|-|Gray scale|<texcode>\definecolor[...][s=...]</texcode> For example,<texcode>\definecolor[screen][g=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 ==
Typeset single text elements with {{cmd|You can ''clone'' an existing color}}using<tttexcode>\definecolor[colornamenew-color][old-color]{nice blue text}</tttexcode>:
For example
{|
! | width="45%"|<texcode>\usecolors[xwi]\definecolor[highlight][yellow]\defineframed [important] ! width [location=low, frame="10%"|off, ! width background=color, backgroundcolor="45%"|highlight]  |-This is a \important{important}word. | <texcode>Three \colordefinecolor[highlight][redlavenderblush]This is a \important{coolimportant} catsword.
</texcode>
| width="10%"|| width="45%"|<contextmode=mkiv>\usecolors[xwi]\definecolor[highlight][yellow]\setupcolorsdefineframed[important][statelocation=low, frame=off, background=color, backgroundcolor=starthighlightThis is a \starttextimportant{important}word. Three \colordefinecolor[highlight][redlavenderblush]This is a \important{coolimportant} cats\stoptextword.
</context>
|}
Alternatively, typeset text elements with == Adapting existing colors == {{cmdtodo |coloredadd details about this}}<tt>[rgb values]{colored text}</tt> (suggested on NTG-ConTeXt: [http://www.ntg.nl/pipermail/ntg-context/2010/046563.html]): = Advanced Usage = == Changing color of entire document ==
{| ! width="45%"| ! width="10%"| ! width="45%"| |- | <texcode>Three \colored[r=.4, g=.4, b=.9]{colorful} kittens.</texcode>||<context>\setupcolors[state=start]\starttextThree \colored[r=.4, g=.4, b=.9]{colorful} kittens.\stoptext</context>|}To change the main text color of the document use
<texcode>\setupcolors[textcolor=defined-color]</texcode>
Typeset longer sections with {{cmd|startcolor}}<tt>[colorname] ...</tt> {{cmd|stopcolor}}:For example,
{|
! width="10%"|
! width="45%"|
|- | <texcode>\setuppapersizesetupcolors[A6textcolor=blue]
\starttext
\startcolor[orange]\input tufte\stopcolortext
\stoptext
</texcode>
|
|<contextmode=mkiv>\setuppapersize[A6]\setupcolors[statetextcolor=startblue]
\starttext
\startcolor[orange]\input tufte\stopcolortext
\stoptext
</context>
|}
== In titles Changing background color of page ==
See The background color of the page can be changed using<texcode>\setupbackgrounds[page][Titles#Using_colors_in_chapters_and_sections]background=color,backgroundcolor=defined-color]</texcode>
== With frames ==
 
{|
! width="45%"|
! width="10%"|
! width="45%"|
|-
| <texcode>
\framed[background=color, backgroundcolor=green]{bla}
\framed[background=color, backgroundcolor=yellow, corner=00]{bla}
</texcode>
|
|<context>
\setupcolors[state=start]
 
\starttext
\framed[background=color, backgroundcolor=green]{bla}
\framed[background=color, backgroundcolor=yellow, corner=00]{bla}
</context>
|}
 
== Background of the page ==
For example,
{|
! width="45%"|
|}
== Background of cells in tables ==
See
* [[Table#Background Colors]]
* [[TABLE#Round_corners]]
== In Metapost ==
Metapost == Using colors in MkIV is different from MkII and all labels are typesetand colored in TeX, if you want a label use label(textext("\blue RED"),origin) ;MetaPost ==
== In TikZ ==A color defined in TeX is available in MetaPost using `\MPcolor{...}`. For example:
{|
! width="45%"| ! width="10%"| ! width="45%"| |- | <texcode>\usemoduledefinecolor[highlight][tikzr=0.8,g=0.8,b=0]
\starttext
\tikz\shadecolor[ball color=red!40!yellowhighlight] {Highlighted text in TeX} \startMPcodelabel(0"Highlighted text in MetaPost",0) circle (.15cmorigin) withcolor \MPcolor{highlight};\stoptextstopMPcode
</texcode>
||<contextmode=mkiv>\setupcolorsdefinecolor[state=starthighlight]\usemodule[tikzr=0.8,g=0.8,b=0]
\starttext
\tikz\shadecolor[ball color=red!40!yellowhighlight] {Highlighted text in TeX} \startMPcodelabel(0"Highlighted text in MetaPost",0) circle (.15cmorigin) withcolor \MPcolor{highlight};\stoptextstopMPcode
</context>
|}
Note that `\MPcolor{...}` behaves similar to a `color` primitive in MetaPost. For example, the following is valid MetaPost code.<texcode>color myColor; myColor =Spot colours=0.5[\MPcolor{highlight}, white];</texcode>
To produce a file ready for a clean PDF separation process at your print house, start with:
{{cmd|setupcolors}}<tt>[rgb=no,cmyk=yes,spotUsing colors in TikZ =yes,state=start,overprint=yes]</tt>
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 = Viewing pre- this is important for some types of commercial printing.defined color =
Then define your basic spot colour. Note that the name cannot contain spaces or numbers (but we come to that later):== View all defined colors ==
To view pre-defined colors, you can use {{cmd|definecolorshowcolor}}<tt>[PantoneTwoNineFour][c=1. For example,m=to see all the colors defined in {{src|colo-imp-x11.56mkiv}},y=0,k=use (output truncated for display here ...18]</tt>)
Now you can define the tints of this ink that you are actually going to use in your document. Let's say you'll have a 100% for headings:{| |-|<texcode>\showcolor[x11]</texcode>|<context mode=mkiv>\startTEXpage[height=5cm]\showcolor[x11]\stopTEXpage</context>|}
If you use {{cmd|definespotcolorshowcolor}}<tt>[MyBlue][PantoneTwoNineFour][p=1]</tt>without any argument, all currently defined colors are shown.
And then a 20% tint for nice display boxes:== View specific defined colors ==
{{cmd|definespotcolor}}<tt>[MyBlueTint][PantoneTwoNineFour][p=.2]</tt>To view the components of a defined color, you can use:
And now you can happily use these named colours:* {{cmd|showcolorcomponents}}<texcode>\showcolorcomponents[color-1, color-2]</texcode>
<texcode>\starttext \color[MyBlue]{Interesting}\stoptext</texcode>For example,
If you are including graphics made by an external program{| |-|<texcode>\showcolorcomponents[red,middlered,darkred]</texcode>|<context mode=mkiv>\showcolorcomponents[red, 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 themmiddlered, so you need to do some extra work.darkred]</context>|}
==Using the 'e' key to * {{cmd|colorcomponents}}* {{cmd|transparencycomponents}}* {{cmd|processcolorcomponents}}<texcode>\definespotcolor to specify a spot colour name with spaces==colorcompoents{defined-color}\tranparencycomponents{defined-color}\processcolorcomponents{defined-color}</texcode>
You can use the 'e' key when defining your spot colours in order to specify the precise colour names to be used by your ConTeXt set-up in the output file. For example:,{||-|<texcode>% set up the cmyk fallbacks\startlines\definecolor [PantoneThreeZeroEight] [c=1,m=.05,y=0,k=.47]colorcomponents{red}\definecolor [PantoneTwoNineEight] [c=.69,m=.07,y=0,k=0] % Define tints of spot colours to be used in document for colouring texttransparencycomponents{red}\definespotcolor [DarkBlue] [PantoneThreeZeroEight] [p=1,e=PANTONE 308 CV]processcolorcomponents{red}\definespotcolor [LightBlue] [PantoneTwoNineEight] [p=1,e=PANTONE 298 CV]stoplines
</texcode>
|
<context mode=mkiv>
\startlines
\colorcomponents{red}
\transparencycomponents{red}
\processcolorcomponents{red}
\stoplines
</context>
|}
(Tested only on minimal Linux distribution dated 8 May 2010 - can others confirm thisto be true across the board now?) Any text between a {{cmd|startcolor[DarkBlue]}} and {{cmd|stopcolor}} should now be assigned to the correct spot colour channel - Pantone 308 CV - 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.  For example, if your original graphic is an EPS file containing the following lines:  %%DocumentCustomColors: (PANTONE 298 CV) %%+ (PANTONE 308 CV) %%CMYKCustomColor: 0.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 <tt>ps2pdf</tt> for inclusion in your '''ConTeXt''' document your PDF graphic will then contain something like:  <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. A good way of testing colour separation = Testing if you don't have access to expensive pre-flight PDF validation tools color is to use the following GhostScript command:  gs \ -dBATCH \ -dNOPAUSE \ -sDEVICE=tiffsep \ -dDOINTERPOLATE \ -dTextAlphaBits=4 \ -dGraphicsAlphaBits=4 \ -sOutputFile=output.tif \ -r120 \ -MaxSeparationsdefined =8 \ input.pdf This renders a PDF file <tt>input.pdf</tt> as a set of TIFF files:
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 CVTo test if a color is defined, use
=Multitones=* {{cmd|doifcolor}}* {{cmd|doifcolorelse}}
Hans posted this example about spot and multitone colors on the mailinglist (2012-05-07).The interface has slightly changed in comparison to older versions. It is important to define the colorants as spot colors first (\definespotcolor).Usage:
<texcode>
\definecolor [xcyan] [c=1]\definecolor [xmagenta][m=1]\definecolor [xyellow] [y=1] \definespotcolor [scyan] [xcyan] [p=1]\definespotcolor [smagenta][xmagenta][p=1]\definespotcolor [syellow] [xyellow] [p=1] \definemultitonecolor[scombi] [xcyan=doifcolor{color-name}{.2,xmagenta=.4,xyellow=.6][c=if branch .2,m=.4,y=.6]}\startTEXpage \hbox \bgroup \blackrule[doifcolorelse{color=scyan, width=1cm,height=1cm,depth=0cm]% \blackrule[color=smagenta,width=1cm,height=1cm,depth=0cm]% \blackrule[color=syellow, width=1cm,height=1cm,depth=0cm]% \blackrule[color=scombi, width=1cm,height=1cm,depth=0cm]% \egroup\stopTEXpage-name}{... if branch ...}{... else branch ...}
</texcode>
(The CMYK color spec is the fall back color used on screen; one can preview separations in full Acrobat 7.)
=Colorizing Grayscale PicturesSpecialized topics =
Another sample by Hans (mailing list 2005-11-16) demonstrates a lot of different possibilities:* [[Color/Palet|Color Palettes]]* [[Color/Transparency|Transparency]] * [[Color/Spot_Colors|Spot Colors]]
<texcode>\setuplayout[header=0pt,footerReferences =0pt,width=middle,height=middle,backspace=1cm,topspace=1cm]\setupcolors[state=start]
\startbuffer\definecolor [blue] * [c=1, m=.38, y=0, k=http://paletton.64com Paletton]- Website to choose color palettes\definecolor * [yellowhttp://colorbrewer2.org/ ColorBrewer] [c=0, m=.28, y=1, k=- website to choose colors for maps and graphics.06]
\definespotcolor [blue-100] [blue] [p=1]\definespotcolor [yellow-100] [yellow] [p=1] \definemultitonecolor [combicolor] [blue=.12, yellow=.28] [c=.1, m=.1, y=.3, k=.1] \definemultitonecolor [combicolor-b] [blue=1] [c=1* Tina Sutton, m=Bride M Whelan: The Complete Color Harmony.38, y=0, k=Rockport Publishers (2004).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][object=no, width=.2\textwidth] \startbaselinecorrection\startcombination[4*1] {\externalfigure[demo-a]} {no 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 \startbaselinecorrection\startcombination[4*1] {\externalfigure[demo-b]} {no color} {\externalfigure[demo-b][color=combicolor]} {indexed duotone} {\externalfigure[demo-b][color=combicolor-b]} {spot color} {\externalfigure[demo-b][color=combicolor-y]} {spot color}\stopcombination\stopbaselinecorrection \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=yellowISBN 978-100]} {spot color}\stopcombination\stopbaselinecorrection1592530311 (recommanded in the mailing list)
\startbaselinecorrection
\startcombination[4*1]
{\externalfigure[demo-b]} {no color}
{\externalfigure[demo-b][color=combicolor]} {indexed duotone}
{\externalfigure[demo-b][color=blue-100]} {spot color}
{\externalfigure[demo-b][color=yellow-100]} {spot color}
\stopcombination
\stopbaselinecorrection
\stopbuffer
\getbuffer \typebuffer
 
\stoptext
</texcode>
 
= References =
 
{{Color navbox}}
{{Getting started navbox}}
 
[[Category:Graphics]]

Navigation menu