Difference between revisions of "Color"

From Wiki
Jump to navigation Jump to search
m (Moved to a separate page)
m (Moved to a separate page)
Line 15: Line 15:
 
* 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.
 
* 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.
 
* 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.
 
 
 
  
  
Line 163: Line 151:
 
|}
 
|}
  
===Transparent Colors===
 
 
You can define '''transparent''' colors through setting t, e.g. <tt>t=0.5</tt>. Beware, some PDF viewers and printshops can't handle PDF transparences!
 
 
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.
 
 
{|
 
! width="45%"|
 
! width="10%"|
 
! width="45%"|
 
|-
 
| <texcode>
 
\definecolor [transparentred]  [r=1,t=.5,a=1]
 
\definecolor [transparentblue] [b=1,t=.5,a=1]
 
\definecolor [solidyellow]  [y=1,t=1,a=1]
 
 
\starttext
 
 
\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,t=.5,a=1]
 
\definecolor [transparentblue] [b=1,t=.5,a=1]
 
\definecolor [solidyellow]  [y=1,t=1,a=1]
 
 
\starttext
 
 
\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
 
</context>
 
|}
 
 
== Defining color schemes: {{cmd|definecolorgroup}} and {{cmd|definepalet}}==
 
{{cmd|definecolorgroup}}<tt>[name][system][values]</tt>
 
 
{{cmd|definepalet}}<tt>[palettename][colorname1=groupcolor:1, colorname2=groupcolor:2, ...]</tt>
 
  
Very interesting feature, see also the manual and here on the wiki [[Command/definecolor]]
 
  
 
=Choosing a color scheme=
 
=Choosing a color scheme=

Revision as of 20:45, 15 June 2015

< 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

   \setupcolors[state=start]

Defining Colors

Choosing a color model

  • RGB and CMYK are enabled by default. If you want only RGB or only CMYK color, use cmyk=no or rgb=no. 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.


Using predefined colors: \setupcolor

Colors have identifiers, some of which are grouped in more or less widely known sets. The primary example of these possibly are the 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: there are two sets representing the web colors: xwi and x11. The main difference between them is that the latter defines variations for many keywords. For instance, instead of having only one color deepskyblue with xwi, you get another four colors deepskyblue1, deepskyblue2 deepskyblue3 and deepskyblue4 with the x11 set. (Another technical aspect is that the latter are specified using hexadecimal RGB values whereas the former rely on decimal values.)

To use them and any of the others listed below, pass the respective definition identifier to \setupcolor:

\setupcolor[x11]

The macro \showcolor pretty prints a the list of all named colors in a definition set.

\showcolor[rgb]

yields several pages of this:

MkIV

The definitions reside in the files prefixed colo-imp-, to separate them from the color functionality that is implemented in colo-xxx.mkiv.

id source description
rgb colo-imp-rgb.mkiv some simple colors, loaded by default (with translations for the different interface languages!)
xwi colo-imp-xwi.mkiv Xorg color keywords (WWW), defined in decimal RGB
x11 colo-imp-x11.mkiv extended Xorg color keywords (WWW), defined in hex RGB
ema colo-imp-ema.mkiv Emacs colors
dem colo-imp-dem.mkiv color groups and palets for different language interfaces

MkII

You will find lists of predefined colors in the files colo-xxx.mkii, load them with \setupcolor[xxx].

id source description
rgb colo-rgb.mkii some simple colors, loaded by default (with translations for the different interface languages!)
x11 colo-x11.mkii Xorg-colors (hex)
xwi colo-xwi.mkii Xorg-colors (decimal)
pra colo-???.mkii PRAGMA ADE corporate design (not included in the distribution?)
ema colo-ema.mkii Emacs colors

Alternatives

You can generate an alternative definition set based on the results of the xkcd color survey with the xcs-colors.lua script.

Defining colors: \definecolor

\definecolor[blablue][r=.1, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2] (definition for RGB, CMYK and Grey!). See also Command/definecolor.


\definecolor[blablue][r=.25, g=.1, b=1, c=1, m=.1, y=0, k=0, s=.2]

Here's some \color[blablue]{blue text} inbetween!

Colors with Hexadecimal Numbers

You can also use hexadecimal numers to specify colors. You need to load the hex color module first:

\setupcolor[hex]
\definecolor[salmon][h=AB5757]

Hey, \color[salmon]{look at that!}


Choosing a color scheme

There are three basic strategies to select color combinations for a particular design

  1. Create a color scheme by picking several colors found within the objects to be used (photographs, pictures, etc)
  2. Create colors derived from those found in the objects to be used
  3. Create a color scheme based on the message to convey / the psychological effects of color

See for additional help & reference:

  • colorschemedesigner.com - Useful site to help choose a color scheme in rgb color space
  • Tina Sutton, Bride M Whelan: The Complete Color Harmony. Rockport Publishers (2004). ISBN 978-1592530311 (recommanded in the mailing list)


Using Colors

  • Use the color name like [color=blablue] in some \setup... command.

With text

Typeset single text elements with \color[colorname]{nice blue text}:

Three \color[red]{cool} cats

Alternatively, typeset text elements with \colored[rgb values]{colored text} (suggested on NTG-ConTeXt: [1]):

Three \colored[r=.4, g=.4, b=.9]{colorful} kittens.


Typeset longer sections with \startcolor[colorname] ... \stopcolor:

\setuppapersize[A6]
\starttext
\startcolor[orange]
\input tufte
\stopcolor
\stoptext

In titles

See Titles#Using_colors_in_chapters_and_sections

With frames

\framed[background=color, backgroundcolor=green]{bla}
\framed[background=color, backgroundcolor=yellow, corner=00]{bla}

Background of the page

\setuppapersize[A10]
\setupbackgrounds[page][background=color,backgroundcolor=blue]

\starttext
text
\stoptext

Background of cells in tables

See

In Metapost

Metapost in MkIV is different from MkII and all labels are typeset and colored in TeX, if you want a label use

 label(textext("\blue RED"),origin) ;

In TikZ

\usemodule[tikz]
\starttext
\tikz\shade[ball color=red!40!yellow] (0,0) circle (.15cm);
\stoptext
internal error: convert failed


References


Template:Getting started navbox