% \iffalse meta-comment
%%
%% ----------------------------------------------------------------
%% Copyright (C) 2003-2007 by Dr. Uwe Kern <xcolor at ukern dot de>
%% ----------------------------------------------------------------
%%
%<*package>
%% Please send error reports and suggestions for
%% improvements to the above email address.
%%
%% This package contains code copied from
%%
%% color.dtx [1999/02/16 v1.0i Standard LaTeX Color (DPC)]
%% Copyright (C) 1994--1999 David Carlisle
%%
%% which is part of the Standard LaTeX `Graphics Bundle'.
%%
%</package>
%<*extract|driver|test1|test2|test3|test4>
\def\XCfileversion{v2.11}%
\def\XCfiledate{2007/01/21}%
%</extract|driver|test1|test2|test3|test4>
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% of this license or (at your option) any later version.
% The latest version of this license is in:
%
%    http://www.latex-project.org/lppl.txt
%
% and version 1.2 or later is part of all distributions of LaTeX
% version 1999/12/01 or later.
%
% \fi
%
% \CheckSum{4864}
%
% \DoNotIndex{\def,\gdef,\edef,\xdef,\long,\let}
% \DoNotIndex{\ifnum,\ifdim,\iftrue,\iffalse,\ifx,\ifcase,\else,\or,\fi}
% \DoNotIndex{\bgroup,\egroup,\begingroup,\endgroup,\begin,\end}
% \DoNotIndex{\relax,\endinput}
% \DoNotIndex{\csname,\endcsname,\string,\the,\noexpand,\expandafter}
% \DoNotIndex{\advance,\count,\dimen}
% \DoNotIndex{\m@ne,\z@,\@ne,\tw@,\p@,\@@tmp}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \iffalse
%<*batchfile>
\IfFileExists{xcolor.ins}{\let\uknext=\relax}{\let\uknext=\stop}
\begin{filecontents*}{xcolor.ins}
%% Package `xcolor' by Dr. Uwe Kern
%%
%% Extract all package files:
%%   `latex xcolor.ins'
%%
%% Put the generated files to their respective locations
%% within the TeX installation:
%%   *.sty -> /tex/latex/xcolor/
%%   *.def -> /tex/latex/xcolor/
%%   *.pro -> /dvips/xcolor/
%%
%% Create the documentation:
%%   `latex xcolor.dtx'
%%   `latex xcolor.dtx'
%%   `makeindex -s gind.ist xcolor.idx'
%%   `latex xcolor.dtx'
%%   `latex xcolor.dtx'
%%
%% Run the test files (N=1,2,...):
%%   `latex xcolorN.tex'
%%   `latex xcolorN.tex'
%%
\def\batchfile{xcolor.ins}
\input docstrip.tex
\askforoverwritefalse
\generate{\file{xcolor.lox}{\from{xcolor.dtx}{extract}}}
\batchinput{xcolor.lox}
\endbatchfile
\end{filecontents*}
%</batchfile>
%
%<*driver>
\listfiles
\ProvidesFile{xcolor.dtx}[\XCfiledate\space\XCfileversion\space
                          `xcolor' source and documentation (UK)]
\documentclass{ltxdoc}
\usepackage[table,showerrors,dvipsnames,hyperref]{xcolor}[2005/06/06]
\usepackage{chngpage,varioref,tabularx,amsmath,amsthm}
\usepackage
 [\GinDriver,hyperindex=false,bookmarks,bookmarksopen,bookmarksopenlevel=1,%
  pdftitle={xcolor \XCfileversion{} (\XCfiledate)},pdfauthor={Dr. Uwe Kern},%
  pdfsubject={Color extensions for LaTeX and pdfLaTeX},%
  pdfkeywords={xcolor,color,colour,model,tint,tone,shade,harmony,spot,latex,pdftex,dvips,%
   conversion,blend,mix,mask,separation,rgb,cmy,cmyk,hsb,gray,html,wave,thsb,wheel}]{hyperref}
\OnlyDescription
\EnableCrossrefs
\CodelineIndex
\makeatletter
\def\Meaning#1{\texttt{\expandafter\expandafter\expandafter\strip@prefix\expandafter\meaning\csname #1\endcsname}}
\makeatother
\pagestyle{myheadings}
\markright{\hskip-2.5cm xcolor \XCfileversion\space(\XCfiledate)}
\begin{document}
 \DocInput{xcolor.dtx}
 \let\Section\section\def\section*#1{\Section*{#1}\addcontentsline{toc}{section}{#1}}
 \begin{adjustwidth}{-2.5cm}{}
 \def\markboth#1#2{}\PrintIndex
 \end{adjustwidth}
\end{document}
%</driver>
%
%<*extract>
\def\ukfile#1#2#3#4%
 {\def\ukhead
   {\ifnum#1>2 \perCent!^^J\fi
    \defaultpreamble^^J\MetaPrefix^^J%
    \ifcase#1
      \string\ProvidesPackage{#2}^^J\or
      \string\ProvidesFile{#2}^^J\or
      \string\ProvidesFile{#2.def}^^J\or
      \MetaPrefix\space #2.pro (PostScript/dvips header file)^^J\MetaPrefix\space
    \fi
    \space[\XCfiledate\space\XCfileversion\space#4\space(UK)]}
  \usepreamble\ukhead
  \file{#2.\ifcase#1sty\or tex\or def\or pro\fi}{\from{xcolor.dtx}{#3}}}
\generate{
\ukfile0{xcolor}{package}{LaTeX color extensions}
\ukfile2{svgnam}{svgnames}{Predefined colors according to SVG 1.1}
\ukfile2{x11nam}{x11names}{Predefined colors according to Unix/X11}
\ukfile1{xcolor1}{test1}{Color conversion test}
\ukfile1{xcolor2}{test2}{Pstricks color test}
\ukfile1{xcolor3}{test3}{Color logging test}
\ukfile1{xcolor4}{test4}{Color driver test}
\def\PStail{\MetaPrefix\space End of file `\outFileName'.}
\usepostamble\PStail
\ukfile3{xcolor}{dvips}{LaTeX color extensions}
}
%</extract>
% \fi
%
%
%
% \iffalse
%-------------------------------------------------------------------------------
% \fi
%
%
% \makeatletter
%
% \def\testclr#1#{\@testclr{#1}}
% \def\@testclr#1#2{{\fboxsep\z@\fbox{\colorbox#1{#2}{\phantom{XX}}}}}
% \def\Testclr#1#{\@Testclr{#1}}
% \def\@Testclr#1#2#3{\testclr#1{#2}~\rlap{\Color[-]{#3}}\\}
% \def\TestClr#1#{\@TestClr{#1}}
% \def\@TestClr#1#2#3{\testclr#1{#2}~\rlap{\Color[+]{#3}}\\}
% \newif\if@Meta
% \DeclareRobustCommand*\Meta{\@ifstar{\@Metatrue\@Meta}{\@Metafalse\@Meta}}
% \newcommand*\@Meta[2][]{\meta{#2}\@ifxempty{#1}{}{\ensuremath{\mskip-1mu\rule[-.4ex]{0pt}{1ex}_{#1}}}\if@Meta\index{arguments\levelchar\meta{#2}\string|usage}\fi}
% \def\DescribeArg#1{\leavevmode\@bsphack\marginpar{\raggedleft\Meta*{#1}}\@esphack\ignorespaces}
% \def\DescribeFunc#1{\leavevmode\@bsphack\marginpar{\raggedleft\Function{#1}\strut}\@esphack\ignorespaces}
%
% \makeatother
%
% \def\Index#1{#1\index{#1\string|usage}}
% \def\Package#1{\textsf{#1}\index{packages\levelchar\textsf{#1}\string|usage}}
% \def\Program#1{\textsf{\itshape#1}\index{programs\levelchar\textsf{\itshape#1}\string|usage}}
% \def\Model#1{\textsf{\bfseries#1}\index{color models\levelchar\textsf{\bfseries#1}\string|usage}}
% \def\nModel#1{`#1'\index{color models\levelchar`#1'\string|usage}}
% \def\pModel#1{\textbf{\itshape #1}}
% \def\People#1#2{#1 #2\index{people\levelchar#2, #1\string|usage}}
% \newcommand*\Color[2][+]{\textsl{#2}\ifx#1+\index{color names\levelchar\textsl{#2}\string|usage}\fi}
% \def\Option#1{\texttt{#1}\index{package options\levelchar\texttt{#1}\string|usage}}
% \def\oOption#1{\texttt{#1}\index{package options (obsolete)\levelchar\texttt{#1}\string|usage}}
% \def\Key#1{\textit{#1}\index{keys\levelchar\textit{#1}\string|usage}}
% \def\File#1{\texttt{#1}\index{files\levelchar\texttt{#1}\string|usage}}
% \def\Function#1{\textit{#1}\index{color functions\levelchar\textit{#1}\string|usage}}
% \def\Op#1#2{#1\nolimits_{\,\Model{#2}}}
% \def\med{\mathop{\textrm{med}}}
% \def\mix{\mathop{\textrm{mix}}}
% \def\rd{\mathop{\textrm{round}}}
% \def\tint{\mathop{\textrm{tint}}}
% \def\shade{\mathop{\textrm{shade}}}
% \def\tone{\mathop{\textrm{tone}}}
% \def\LC{\Package{color}}
% \def\LCP{\Package{color} package}
% \def\XC{\Package{xcolor}}
% \def\XCP{\Package{xcolor} package}
% \def\XCW{\texttt{\href{http://www.ukern.de/tex/xcolor.html}{www.ukern.de/tex/xcolor.html}}}
% \def\URL#1{\texttt{\url{#1}}}
% \def\CTAN#1#2{\texttt{\href{http://www.ctan.org/tex-archive/#1}{CTAN/#1#2}}}
% \newtheorem{lemma}{Lemma}
% \def\RtoI#1{\Gamma_{\!#1}}
% \def\ItoR#1{\Delta_{#1}}
% \def\bbbN{\textrm{I\kern-.333ex N}}
% \def\bbbR{\textrm{I\kern-.333ex R}}
% \def\Circ{\textsuperscript{$\circ$}}
%
% \newdimen\XCdim
%
% \parindent0pt
% \extrarowheight1pt
% \def\textfraction{0.01}
% \def\topfraction{0.99}
% \def\bottomfraction{0.99}
% \def\floatpagefraction{0.70}
% \setlength\abovecaptionskip{12pt}
% \setlength\belowcaptionskip{10pt}
% \colorlet{tableheadcolor}{gray!25}
% \colorlet{tablerowcolor}{gray!12.5}
%
%
%
% \title{Extending \LaTeX's color facilities: the \XCP}
% \author{\href{mailto:xcolor@ukern.de}{\fboxrule0pt\fboxsep2pt\fbox{Dr. Uwe Kern}}}
% \date{\XCfileversion{} (\XCfiledate)
%       \thanks{This package can be downloaded from \CTAN{macros/latex/contrib/xcolor/}{}.
%               There is also an \textsf{xcolor} homepage: \XCW.
%               Please send error reports and suggestions for improvements to the author:
%               \texttt{\href{mailto:xcolor@ukern.de}{xcolor@ukern.de}}.}}
% \maketitle
%
% \begin{abstract}
% \noindent
% \XC{} provides easy driver-independent access to several kinds of colors, tints, shades, tones, and mixes of arbitrary colors by means of color expressions like |\color{red!50!green!20!blue}|.
% It allows to select a document-wide target color model and offers tools for automatic color schemes, conversion between twelve color models, alternating table row colors, color blending and masking, color separation, and color wheel calculations.
% \end{abstract}
%
% \phantomsection\pdfbookmark[1]{\contentsname}{toc}
% \tableofcontents\listoftables\listoffigures\newpage
%
%
%
%
% \clearpage
% \section{Introduction}
%
% \subsection{Purpose of this package}
%
% The \LCP{} provides a powerful and stable tool for handling colors within (pdf)\LaTeX{} in a consistent and driver-independent way, supporting several color models (slightly less driver-independent).
%
% Nevertheless, it is sometimes a bit clumsy to use, especially in cases where slight color variations, color mixes or color conversions are involved:
% this usually implies the usage of another program that calculates the necessary parameters, which are then copied into a |\definecolor| command in \LaTeX.
% Quite often, also a pocket calculator is involved in the treatment of issues like the following:
% \begin{itemize}
% \item My company has defined a corporate color, and the printing office tells me how expensive it is to use more than two colors in our new brochure, whereas all kinds of tints (e.g., a 75\% version) of our color can be used at no extra cost.
% But how to access these color variations in \LaTeX?\\
% (Answer: |\color{CorporateColor!75}| etc.)
% \item My friend uses a nice color which I would like to apply in my own documents; unfortunately, it is defined in the \Model{hsb} model which is not supported in my favorite application pdf\LaTeX.
% What to do now?\\
% (Answer: just use the \Model{hsb} definitions, \XC{} will do the necessary calculations)
% \item How does a mixture of 40\% \Color{green} and 60\% \Color{yellow} look like?\\
% (Answer: 40\% \testclr{green} $+$ 60\% \testclr{yellow} $=$ \testclr{green!40!yellow}, e.g., |\color{green!40!yellow}|)
% \item And how does its complementary color look like?\\
% (Answer: \testclr{-green!40!yellow}, accessible via |\color{-green!40!yellow}|)
% \item Now I want to mix three parts of the last color with two parts of its complement and one part of \Color{red}.
% How does that look?\\
% (Answer: $3\times$ \testclr{-green!40!yellow} $+ 2\times$ \testclr{green!40!yellow} $+ 1\times$ \testclr{red} $=$ \testclr{rgb:-green!40!yellow,3;green!40!yellow,2;red,1}, the last color being accessible via |\color{rgb:-green!40!yellow,3;green!40!yellow,2;red,1}|)
% \item I know that light waves of 485nm are within the visible range. But which color do they represent?\\
% (Answer: approximately \testclr[wave]{485}, via |\color[wave]{485}|)
% \item My printing office wants all color definitions in my document to be transformed into the \Model{cmyk} model.
% How can I do the calculations efficiently?\\
% (Answer: |\usepackage[cmyk]{xcolor}| or |\selectcolormodel{cmyk}|)
% \item I have a table with 50 rows.
% How can I get alternating colors for entire rows without copying 50 |\rowcolor| commands? The alternating scheme should start in the 3rd row.\\
% (Answer: something like |\rowcolors{3}{OddColor}{EvenColor}|)
% \end{itemize}
% These are some of the issues solved by the \XCP.
% Its purpose can be summarized as to maintain the characteristics of \LC, while providing additional features and flexibility with (hopefully) easy-to-use interfaces.
%
%
%
% \subsection{Color tints, shades, tones, and complements}
%
% According to \cite{smith} we define the terms
% \begin{itemize}
% \item \textbf{\Index{tint}}: a color with \Color{white} added,
% \item \textbf{\Index{shade}}: a color with \Color{black} added,
% \item \textbf{\Index{tone}}: a color with \Color{gray} added.
% \end{itemize}
% These are special cases of a general function
% $\mix(C,C',p)$ which constructs a new color, consisting of $p$ parts of color $C$ and $1-p$ parts of color $C'$, where $0\le p\le1$.
% Thus, we set
% \begin{align}
% \tint(C,p) &:= \mix(C,|white|,p)\\
% \shade(C,p) &:= \mix(C,|black|,p)\\
% \tone(C,p) &:= \mix(C,|gray|,p)
% \end{align}
% where |white|, |black|, and |gray| are model-specific constants, see table \vref{tab.const}.
% Further we define the term
% \begin{itemize}
% \item \textbf{complement}: a color $C^*$ that yields \Color{white} if superposed with the original color $C$,
% \end{itemize}
% knowing that there are also different concepts of complementarity in place (e.g., opposite colors on \emph{color wheels}).
% See section \vref{sec.cnv} for calculation details and section \vref{sec.harmony} for some remarks on color wheels.
%
%
%
% \subsection{Color models}
%
% A color model is a tool to describe or represent a certain set of colors in a way that is suitable for the desired target device, e.g., a screen or a printer.
% There are proprietary models (like \Index{Pantone} or \Index{HKS}) that provide finite sets of colors (often called \emph{\Index{spot color}s}), where the user has to choose from without caring about parametrisations; on the other hand, there are parameter-driven models like \Model{gray}, \Model{rgb}, and \Model{cmyk}, that aim to represent large finite or even (theoretically) infinite sets of colors, built on very small subsets of base colors and rules, how to construct other colors from these base colors.
% For example, a large range of colors can be constructed by linear combinations of the base colors \Color{red}, \Color{green}, and \Color{blue}.
% On the other hand, usually \Index{spot color}s can only be \emph{approximated} by parameter values in models like \Model{cmyk} or \Model{rgb}; the original colors are being physically mixed even dependent on the targeted kind of paper.
% Finally, there are certain colors like \Color{gold} and \Color{silver} that are hardly reproducable by any parameter-driven color model on standard ink or laser printers.
%
%
%
% \subsection{Color wheels and color harmony}\label{sec.harmony}
%
% There has been a long history of placing colors (hues) on wheels in order to discuss theoretical or practical color issues (e.g., \People{Isaac}{Newton}, \People{Johann Wolfgang von}{Goethe}).
% One reason may be that the circle itself is a natural tool to demonstrate common relationships as well as opposite properties.
%
% Nowadays, there exists some confusion about notions, since both major areas related to color --- art and graphics design on one hand, scientific color theory on the other hand --- tend to use the same words to describe color properties, however meaning sometimes very different facts!
% Thus, the appearance of color wheels differs as well as the meaning of concepts like `primary' or `complementary' colors.
%
%
% \paragraph{Typical color wheel construction}
% First, three \emph{primary colors} are placed at 0\Circ, 120\Circ, 240\Circ (artists often choose \Color{red}, \Color{yellow}, \Color{blue}, whereas color scientists might prefer \Color{red}, \Color{green}, \Color{blue}).
% Next, three \emph{secondary colors} are put at 60\Circ, 180\Circ, 300\Circ.
% Then, six \emph{tertiary colors} may be placed in between (30\Circ, 90\Circ, \dots).
% This is why color wheels are frequently described to consist of twelve equidistant colors, although the algorithm can be repeated arbitrarily often.
%
%
% \paragraph{Color harmonies derived from a wheel}
% We start with an arbitrary color wheel:
% \begin{itemize}
% \item \textbf{complementary colors} have a distance of 180\Circ{} on the wheel,
% \item \textbf{color triads} consist of three colors in 120\Circ{} steps,
% \item \textbf{color tetrads} consist of four colors in 90\Circ{} steps.
% \end{itemize}
% We assume now that the wheel is partitioned into $2n$ sectors of equal size:
% \begin{itemize}
% \item \textbf{split complementary colors} of a given color are the two immediate neighbours of its complementary color, characterised by the positions $\frac{n\pm1}{2n}\cdot360^\circ$,
% \item \textbf{analogous colors} to a given color are its two or four neighbours, characterised by the positions $\pm\frac{1}{2n}\cdot360^\circ$ and $\pm\frac{2}{2n}\cdot360^\circ$.
% \end{itemize}
% Given these methods to generate `color harmonies', we conclude that the results depend heavily on how we constructed the wheel!
% Moreover, the choice of $n$ will affect the visual results as well.
% Examples are shown in figure \vref{fig.harmony}.
%
%
%
%
% \clearpage
% \section{The User Interface}
%
% \subsection{Preparation}
%
% \subsubsection{Package installation}
%
% First of all, put \File{xcolor.sty} and all the \File{.def} files to some place where (pdf)\LaTeX{} finds them.
% A typical place according to the \emph{\TeX\ Directory Structure} (TDS) would be the directory |texmf/tex/latex/xcolor|, where |texmf| denotes the main directory of your \TeX\ installation.
% Additionally, put \File{xcolor.pro} to a place where \Program{dvips} finds it, typically |texmf/dvips/xcolor|.
% Usually, you will have to run some kind of filename database update in order to make the files known and quickly searchable to the \TeX\ system.
% Then simply use \XC{} (instead of \LC) in your document.
% Thus, the general command is |\usepackage|\oarg{options}|{xcolor}| in the document preamble.
% Table \vref{tab.package} shows what has to be taken into account with respect to the package loading order.
%
%
% \subsubsection{Package options}
%
% In general, there are several types of options:
% \begin{itemize}
% \item options that determine the color driver as explained in \cite{dpc} and \cite{color}, currently: \Option{dvips}, \Option{xdvi}, \Option{dvipdf}, \Option{dvipdfm}, \Option{dvipdfmx}, \Option{pdftex}, \Option{dvipsone}, \Option{dviwindo}, \Option{emtex}, \Option{dviwin}, \Option{oztex}, \Option{textures}, \Option{pctexps}, \Option{pctexwin}, \Option{pctexhp}, \Option{pctex32}, \Option{truetex}, \Option{tcidvi}, \Option{vtex}, \Option{xetex},
% \item options that determine the target color model\footnote{Section \vref{sec.tgt} explains how this setting can be overridden at any point in a document.} (\Option{natural}, \Option{rgb}, \Option{cmy}, \Option{cmyk}, \Option{hsb}, \Option{gray}, \Option{RGB}, \Option{HTML}, \Option{HSB}, \Option{Gray}) or disable colored output (\Option{monochrome}),
% \item options that control whether and how certain sets of predefined colors are being loaded: \Option{dvipsnames}, \Option{dvipsnames*}, \Option{svgnames}, \Option{svgnames*}, \Option{x11names}, \Option{x11names*},
% \item options that determine which other packages are to be loaded or supported: \Option{table}, \Option{fixpdftex},
% \Option{hyperref},
% \item options that influence the behaviour of other commands: \Option{prologue}, \Option{kernelfbox}, \Option{xcdraw}, \Option{noxcdraw}, \Option{fixinclude}, \Option{showerrors}, \Option{hideerrors},
% \item obsolete options:
% \oOption{pst},
% \oOption{override}, \oOption{usenames}, \oOption{nodvipsnames}.
% \end{itemize}
% All available package options (except driver selection and obsolete options) are listed in table \vref{tab.opt}.
% \DescribeMacro\GetGinDriver
% \DescribeMacro\GinDriver
% In order to facilitate the co-operation with the \Package{hyperref} package, there is a command |\GetGinDriver|\footnote{This command is executed automatically if the package option \Option{hyperref} is used.} that grabs the driver actually used and puts it into the command |\GinDriver|.
% The latter can then be used within \Package{hyperref} (or other packages), see the code example on page \pageref{ex.range}.
% If there is no corresponding \Package{hyperref} option, \Option{hypertex} will be taken as default.
%
% Warning: there is a substantial difference between \XC{} and \LC{} regarding how the \Option{dvips} option is being handled.
% The \LCP{} implicitly invokes the \Option{dvipsnames} option, whenever one of the |dvips|, |oztex|, |xdvi| drivers is selected.
% This makes documents less portable, since whenever one of these colors is used without explicit \Option{dvipsnames} option, other drivers like |pdftex| will issue error messages because of unknown colors.
% Therefore, \XC{} always requires an explicit \Option{dvipsnames} option to use these names --- which then works for all drivers.
%
%
% \begin{table}[p]\caption{Package options}\label{tab.opt}
% \extrarowheight2pt
% \begin{adjustwidth}{-2.5cm}{}
% \advance\textwidth2.5cm
% \rowcolors{3}{tablerowcolor}{}
% \begin{tabularx}{\linewidth}{lX}
% \hline
% \rowcolor{tableheadcolor}
% \em Option & \em Description\\
% \Option{natural}& (Default.) Keep all colors in their model, except \Model{RGB} (converted to \Model{rgb}), \Model{HSB} (converted to \Model{hsb}), and \Model{Gray} (converted to \Model{gray}).\\
% \Option{rgb}& Convert all colors to the \Model{rgb} model.\\
% \Option{cmy}& Convert all colors to the \Model{cmy} model.\\
% \Option{cmyk}& Convert all colors to the \Model{cmyk} model.\\
% \Option{hsb}& Convert all colors to the \Model{hsb} model.\\
% \Option{gray}& Convert all colors to the \Model{gray} model. Especially useful to simulate how a black \& white printer will output the document.\\
% \Option{RGB}& Convert all colors to the \Model{RGB} model (and afterwards to \Model{rgb}).\\
% \Option{HTML}& Convert all colors to the \Model{HTML} model (and afterwards to \Model{rgb}).\\
% \Option{HSB}& Convert all colors to the \Model{HSB} model (and afterwards to \Model{hsb}).\\
% \Option{Gray}& Convert all colors to the \Model{Gray} model (and afterwards to \Model{gray}).\\
% \hline
% \Option{dvipsnames}, \Option{dvipsnames*}& Load a set of predefined colors.\footnotemark[1]\\
% \Option{svgnames}, \Option{svgnames*}& Load a set of predefined colors according to \Index{SVG} 1.1.\footnotemark[1]\\
% \Option{x11names}, \Option{x11names*}& Load a set of predefined colors according to \Index{Unix}/\Index{X11}.\footnotemark[1]\\
% \hline
% \Option{table}& Load the \Package{colortbl} package, in order to use the tools for coloring rows, columns, and cells within tables.\\
% \Option{fixpdftex}& Load the \Package{pdfcolmk} package, in order to improve |pdftex|'s color behaviour (see section \vref{sec.fixpdftex}).\\
% \Option{hyperref}& Support the \Package{hyperref} package in terms of color expressions by defining additional keys (see section \vref{sec.hyperref}).\\
% \hline
% \Option{prologue}& Write prologue information to \File{.xcp} file for every color definition (as described in section \vref{sec.prologue}).\\
% \hline
% \Option{kernelfbox}& Use \LaTeX{} kernel method to draw \texttt{\string\f(rame)box} frames\footnotemark[2].\\
% \Option{xcdraw}& Use driver-specific commands to draw frames and color boxes.\footnotemark[2]\\
% \Option{noxcdraw}& (Default.) Use generic code to draw frames and color boxes.\footnotemark[2]\\
% \Option{fixinclude}& Prevent |dvips| color reset before \File{.eps} file inclusion (see section \vref{sec.fixinclude}).\\
% \hline
% \Option{showerrors}& (Default.) Display an error message if an undefined color is being used (same behaviour as in the original \LCP).\\
% \Option{hideerrors}& Display only a warning if an undefined color is being used, and replace this color by \Color{black}.\\
% \hline\hline
% \multicolumn2{c}{\footnotemark[1]\,See section \vref{sec.additionalcolors}.\quad \footnotemark[2]\,See section \vref{sec.fbox}.}\\
% \hline
% \end{tabularx}
% \end{adjustwidth}
% \end{table}
%
%
% \begin{table}[htbp]\caption{Package loading order}\label{tab.package}
% \begin{adjustwidth}{-2.5cm}{}
% \raggedleft
% \extrarowheight2pt
% \rowcolors{3}{tablerowcolor}{}
% \begin{tabular}{l*{6}{c}}
% \hline
% \rowcolor{tableheadcolor}
% \em Action/Package    & \Package{colortbl}& \Package{pdfcolmk}& \Package{hyperref}& \Package{pstricks}& \LC& \Package{pstcol}\\
% load before \XC       & no & no & allowed & allowed\rlap{\footnotemark[1]} & no & no  \\
% load with \XC{} option& \Option{table} & \Option{fixpdftex} & --- & --- & --- & --- \\
% load after \XC        & no & allowed & allowed & allowed & no & no \\
% \hline\hline
% \multicolumn6{c}{\footnotemark[1]\,recent \Package{pstricks} versions do load \XC\ by default}\\
% \hline
% \end{tabular}
% \end{adjustwidth}
% \end{table}
%
%
% \begin{table}[htbp]\caption{Supported color models}\label{tab.mod}
% \raggedleft
% \extrarowheight2pt
% \rowcolors{3}{tablerowcolor}{}
% \begin{tabular}{l>{\em}l>{$}l<{$}rl}
% \hline
% \rowcolor{tableheadcolor}
% \emph{Name}  & Base colors/notions & \emph{Parameter range}& \multicolumn2{>{\columncolor{tableheadcolor}}l}{\emph{Default}}\\
% \Model{rgb} & red, green, blue & \left[0,1\right]^3&& \\
% \Model{cmy} & cyan, magenta, yellow & \left[0,1\right]^3&& \\
% \Model{cmyk} & cyan, magenta, yellow, black & \left[0,1\right]^4&& \\
% \Model{hsb} & hue, saturation, brightness & \left[0,1\right]^3&& \\
% \Model{Hsb} & hue\Circ\!, saturation, brightness & \left[0,H\right]\times\left[0,1\right]^2&$H=$& $\mkern-15mu\rangeHsb$\\
% \Model{tHsb} & hue\Circ\!, saturation, brightness & \left[0,H\right]\times\left[0,1\right]^2&$H=$& $\mkern-15mu\rangeHsb$\\
% \Model{gray} & gray & \left[0,1\right]&& \\
% \Model{RGB} & Red, Green, Blue & \{0,1,\dots,L\}^3& $L\,=$& $\mkern-15mu\rangeRGB$\\
% \Model{HTML} & RRGGBB & \{\texttt{000000},\dots,\texttt{FFFFFF}\}&& \\
% \Model{HSB} & Hue, Saturation, Brightness & \{0,1,\dots,M\}^3& $M=$& $\mkern-15mu\rangeHSB$\\
% \Model{Gray} & Gray & \{0,1,\dots,N\}& $N\,=$& $\mkern-15mu\rangeGray$\\
% \Model{wave} & lambda \emph{(nm)}& \left[363,814\right]&& \\
% \hline\hline
% \multicolumn5{c}{$L,M,N$ are positive integers; $H$ is a positive real number}\\
% \hline
% \end{tabular}
% \end{table}
%
%
% \subsubsection{Executing additional initialisation commands}
%
% \DescribeMacro\xcolorcmd
% Here is a simple interface to pass commands that should be executed at the end of the \XCP{} (immediately before the initialising |\color{black}| is executed).
% Just say |\def\xcolorcmd|\marg{commands} at some point before \XC{} is loaded.
%
% Example: assuming that |a.tex| is a complete \LaTeX{} document, a command like
% `|latex \def\xcolorcmd{\colorlet{black}{red}}\input{a}|'
% at the console generates a file |a.dvi| with all occurences of \Color{black} being replaced by \Color{red}, without the necessity to change the source file itself.
% (The exact spelling of the console command might vary across operating systems and \TeX{} distributions.)
%
%
%
% \subsection{Color models}
%
% \subsubsection{Supported color models}
%
% The list of supported color models and their parameter ranges is given in table \vref{tab.mod}.
% We emphasize that this color support is independent of the chosen driver.
%
% `Color model support' also means that it is possible to specify colors directly with their parameters, e.g., by saying |\textcolor[cmy]{0.7,0.5,0.3}{foo}| (\textcolor[cmy]{0.7,0.5,0.3}{foo}) or |\textcolor[HTML]{AFFE90}{foo}| (\textcolor[HTML]{AFFE90}{foo}).
%
% \paragraph{\Model{rgb}, \Model{cmyk}, \Model{hsb}, \Model{gray}}
% These are the models supported by \Index{PostScript} directly.
% We therefore refer to \cite{plrm} for a description of their properties and relations.
% There is a special command
% \DescribeMacro\adjustUCRBG
% to fine-tune the mechanisms of \emph{undercolor-removal} and \emph{black-generation} during conversion to the \Model{cmyk} model, see section \vref{sec.cmy2cmyk} for details.
%
% \paragraph{\Model{cmy}}
% This is mainly a model for intermediary calculation steps.
% With respect to that, it is a simple complement of \Model{rgb}.
% As far as visualisation is concerned, \Model{cmy} is treated as \Model{cmyk} with $k=0$.
%
% \paragraph{\Model{HTML}}
% This is a model derived from \Model{rgb} in order to enable input of color parameters from web pages or CSS files.
% Therefore, it is not really a color model of its own right, but rather a user interface for convenience.
% It is worth mentioning that \Model{HTML} accepts any combination of the characters |0|--|9|, |A|--|F|, |a|--|f|, as long as the string has a length of exactly 6~characters.
% However, outputs of conversions to \Model{HTML} will always consist of numbers and \emph{uppercase} letters.
%
% \paragraph{\Model{Hsb}, \Model{tHsb}}
% Firstly, \Model{Hsb} is a `user interface' model, mapping $\emph{hue}\in[0,1]$ onto $\emph{hue\Circ}\in[0,H]$, where $H$ is given by |\def\rangeHsb|\marg{H}.
% \DescribeMacro\rangeHsb
% Thus, if $H=360$, we can think of a circle or wheel to specify the \emph{hue\Circ} parameter.
% Secondly, \Model{Hsb} is the basis for \Model{tHsb}, also named \pModel{tuned} \Model{Hsb}, which enables the user to apply a piecewise linear transformation on \emph{hue\Circ} by shifting selected \emph{hue\Circ} values forward or backward on the circle.
% This transformation is defined by |\def\rangetHsb{|$x_1,y_1;x_2,y_2;\dots$|}|
% \DescribeMacro\rangetHsb
% which specifies that $\emph{hue\Circ}=x_1$ in \Model{tHsb} means $\emph{hue\Circ}=y_1$ in \Model{Hsb}, etc.
% For example, \Color{yellow} is at 60\Circ{} in the \Model{Hsb} circle (\Color{red} being at 0\Circ), however, in most color wheels used by artists, \Color{yellow} is at 120\Circ.
% Therefore, a `|120,60|' entry would make sense if we planned to replicate an artist's color wheel via \Model{tHsb}.
% See section \vref{sec.tHsb2Hsb} for the exact transformation formula and further restrictions, and section \vref{sec.harmony} for color wheels and color harmonies.
% Figure \vref{fig.tHsb} may serve for comparison purposes.
%
% Example: `|\def\rangetHsb{|\texttt{\rangetHsb}|}|' is in fact \XC's default setting.
%
% \paragraph{\Model{wave}}
% With this model we try to make wavelengths transformable to standard color models, in order to approximate the visual appearance of light waves.
% While the visible spectrum covers a range of approximately 400--750\,nm, the implementation in \XC{} generally allows for all real `wavelengths' $\lambda$ that have an absolute value less than \csname strip@pt\endcsname\maxdimen{} (the biggest number \TeX{} can represent as a dimension).
% However, the probability of getting any non-black color outside the range of $\lambda\in[363,814]$ is exactly zero.
% Therefore, figure \vref{fig.spectrum} illustrates only the mentioned wavelength interval.
% Note that it is not possible to convert other models to \Model{wave} in a sensible way, since the latter covers only a limited range of colors.
%
% \paragraph{\Model{RGB}, \Model{HSB}, \Model{Gray}}
% These are derived models, turning the continuous $[0,1]$ parameter ranges of \Model{rgb}, \Model{hsb}, and \Model{gray} to finite sets of integers; we therefore use the term \emph{integer models}.
% The constants $L, M, N$ of table \ref{tab.mod} are defined via the commands |\def\rangeRGB|\marg{L},
% \DescribeMacro\rangeRGB
% |\def\rangeHSB|\marg{M},
% \DescribeMacro\rangeHSB
% and |\def\rangeGray|\marg{N}.
% \DescribeMacro\rangeGray
% Changes of these constants can be done \emph{before} or \emph{after} the \XCP{} is loaded, e.g.,
% \label{ex.range}\begin{verbatim}
% \documentclass{article}
% ...
% \def\rangeRGB{15}
% \usepackage[dvips]{xcolor}
% ...
% \GetGinDriver
% \usepackage[\GinDriver]{hyperref}
% ...
% \begin{document}
% ...
% \def\rangeRGB{63}
% ...
% \end{verbatim}
%
%
% \subsubsection{Substituting individual color models}\label{sec.subst}
%
% \DescribeMacro\substitutecolormodel
%   \marg{source model}\marg{target model-list}\\
% Substitute \Meta{source model} by the first actually present model that occurs in \Meta{target model-list}.
% Only color models of type \Meta{num model} are allowed;
% all changes are local to the current group, but a prepended |\xglobal| is obeyed.
%
% Example: assume the actual driver has an incorrect implementation of \Model{hsb} whereas \Model{rgb} looks well.
% Then |\substitutecolormodel{hsb}{rgb}| could be a good choice, since it converts --- from that point onwards --- all definitions of \Model{hsb} colors by \XC's algorithms into \Model{rgb} specifications, without touching other models.
%
%
% \subsubsection{Changing the target color model within a document}\label{sec.tgt}
%
% \DescribeMacro\selectcolormodel
%   \marg{num model}\\
% Sets the target model to \Meta{num model}, where the latter is one of the model names allowed as package option (i.e., \Option{natural}, \Option{rgb}, \Option{cmy}, \Option{cmyk}, \Option{hsb}, \Option{gray}, \Option{RGB}, \Option{HTML}, \Option{HSB}, \Option{Gray}), see figure \vref{fig.tgt} for an example.
% There are two possible hooks, where the conversion to the target model can take place:
% \begin{itemize}
% \item \DescribeMacro\ifconvertcolorsD at color \emph{definition} time\footnote{This means that all \emph{newly} defined colors will be first converted to the target model, then saved.} (i.e., within |\definecolor| and friends); this is controlled by the switch |\ifconvertcolorsD|;
% \item \DescribeMacro\ifconvertcolorsU at time of color \emph{usage} (immediately before a color is displayed, therefore covering colors that have been defined in other models or that are being specified directly like |\color[rgb]{.1,.2,.3}|); this is controlled by the switch |\ifconvertcolorsU|.
% \end{itemize}
% Both switches are set to `true' by selecting any of the models, except \Option{natural}, which sets them to `false'.
% This applies for selection via a package option as well as via |\selectcolormodel|.
% Why don't we simply convert all colors at time of usage?
% If many colors are involved, it can save some processing time when all conversions are already done during color definitions.
% Best performance can be achieved by |\usepackage[rgb,...]{xcolor}\convertcolorsUfalse|, which is actually the way how \XC{} worked up to version 1.07.
%
%
% \begin{table}[p]\caption{Arguments and terminology}\label{tab.term}
% \def\RS{\ensuremath{\to}\space}
% \footnotesize\raggedleft
% \extrarowheight2pt
% \begin{adjustwidth}{-2.5cm}{}
% \advance\textwidth2.5cm
% \tabcolsep.25em
% \rowcolors{3}{tablerowcolor}{}
% \begin{tabularx}{\textwidth}{lX}
% \hline
% \rowcolor{tableheadcolor}
% \em Element & \em Replacement string\\
% \Meta*{empty}& \RS empty string `'\\
% \Meta*{minus}& \RS non-empty string consisting of one or more minus signs `|-|'\\
% \Meta*{plus}& \RS non-empty string consisting of one or more plus signs `|+|'\\
% \hline
% \Meta*{int}& \RS integer number\hfill(\emph{integer})\\
% \Meta*{num}& \RS non-negative integer number\hfill(\emph{number})\\
% \Meta*{dec}& \RS real number\hfill(\emph{decimal})\\
% \Meta*{div}& \RS non-zero real number\hfill(\emph{divisor})\\
% \Meta*{pct}& \RS real number from the interval $[0,100]$\hfill(\emph{percentage})\\
% \hline
% \Meta*{id}& \RS non-empty string consisting of letters and digits\hfill(\emph{identifier})\\
% \Meta*{ext id}& \RS \Meta{id}\newline
%                 \RS \Meta[1]{id}|=|\Meta[2]{id}\\
% \Meta*{id-list}& \RS \Meta[1]{ext id}|,|\Meta[2]{ext id}|,...,|\Meta[l]{ext id}\\
% \Meta*{name}& \RS \Meta{id}\hfill(\emph{explicit name})\newline
%               \RS `|.|'\hfill(\emph{implicit name})\\
% \Meta*{core model}& \RS `|rgb|', `|cmy|', `|cmyk|', `|hsb|', `|gray|'\hfill(\emph{core models})\\
% \Meta*{num model}& \RS \Meta{core model}\newline
%                    \RS `|RGB|', `|HTML|', `|HSB|', `|Gray|'\hfill(\emph{integer models})\newline
%                    \RS `|Hsb|', `|tHsb|', `|wave|'\hfill(\emph{decimal models})\\
% \Meta*{model}& \RS \Meta{num model}\hfill(\emph{numerical models})\newline
%                \RS `|named|'\hfill(\emph{pseudo model})\\
% \Meta*{model-list}& \RS \Meta[1]{model}|/|\Meta[2]{model}|/.../|\Meta[m]{model} \hfill(\emph{multiple models})\newline
%                     \RS \Meta{core model}|:|\Meta[1]{model}|/|\Meta[2]{model}|/.../|\Meta[m]{model}\\
% \Meta*{spec}& \RS comma-separated list of numerical values\hfill(\emph{explicit specification})\newline
%               \RS space-separated list of numerical values\hfill(\emph{explicit specification})\newline
%               \RS name of a `named' color\hfill(\emph{implicit specification})\\
% \Meta*{spec-list}& \RS \Meta[1]{spec}|/|\Meta[2]{spec}|/.../|\Meta[m]{spec} \hfill(\emph{multiple specifications})\\
% \Meta*{type}& \RS \Meta{empty}\newline
%               \RS `|named|', `|ps|'\\
% \hline
% \Meta*{expr}& \RS \Meta{prefix}\Meta{name}\Meta{mix expr}\Meta{postfix}\hfill(\emph{standard color expression})\\
% \Meta*{prefix}& \RS \Meta{empty}\newline
%                 \RS \Meta{minus}\hfill(\emph{complement indicator})\\
% \Meta*{mix expr}& \RS |!|\Meta[1]{pct}|!|\Meta[1]{name}|!|\Meta[2]{pct}|!|\Meta[2]{name}|!...!|\Meta[n]{pct}|!|\Meta[n]{name} \hfill(\emph{complete mix expr.})\newline
%                   \RS |!|\Meta[1]{pct}|!|\Meta[1]{name}|!|\Meta[2]{pct}|!|\Meta[2]{name}|!...!|\Meta[n]{pct} \hfill(\emph{incomplete mix expr.})\\
% \Meta*{postfix}& \RS \Meta{empty}\newline
%                  \RS |!!|\Meta{plus}\hfill(\emph{series step})\newline
%                  \RS |!![|\Meta{num}|]|\hfill(\emph{series access})\\
% \hline
% \Meta*{ext expr}& \RS \Meta{core model}|,|\Meta{div}|:|\Meta[1]{expr}|,|\Meta[1]{dec}|;|\Meta[2]{expr}|,|\Meta[2]{dec}|;...;|\Meta[k]{expr}|,|\Meta[k]{dec}\newline
%                   \RS \Meta{core model}|:|\Meta[1]{expr}|,|\Meta[1]{dec}|;|\Meta[2]{expr}|,|\Meta[2]{dec}|;...;|\Meta[k]{expr}|,|\Meta[k]{dec}\\
% \hline
% \Meta*{func expr}& \RS |>|\Meta{function}|,|\Meta[1]{arg}|,|\Meta[2]{arg}|,...,|\Meta[j]{arg}\hfill(\emph{color function expression})\\
% \Meta*{function}& \RS `|wheel|', `|twheel|'\hfill(\emph{color functions})\\
% \hline
% \Meta*{color}& \RS \Meta{color expr}\Meta[1]{func expr}\Meta[2]{func expr}|...|\Meta[i]{func expr}\\
% \Meta*{color expr}& \RS \Meta{name}\newline
%                     \RS \Meta{expr}\newline
%                     \RS \Meta{ext expr}\\
% \hline\hline
% \rowcolor{white}
% Remarks:& Each \RS denotes a possible replacement string for the element in the left column;
%           however, further context-dependent restrictions may apply.
%           See main text for details.
%           A string `|foo|' is always to be understood without the quotes.
%           $i,j,k,l,m,n$ denote non-negative integers, $k,l,m,n>0$, $m\le8$.\\
% \hline
% \end{tabularx}
% \end{adjustwidth}
% \end{table}
%
%
%
% \subsection{Arguments and terminology}\label{sec.term}
%
% Before we describe \XC's color-related commands in detail, we define several elements or identifiers that appear repeatedly within arguments of those commands.
% A general syntax overview is given in table \vref{tab.term}.
%
%
% \subsubsection{Additional remarks and restrictions on arguments}
%
% \paragraph{Basic strings and numbers}
% \DescribeArg{empty}
% \DescribeArg{minus}
% \DescribeArg{plus}
% \DescribeArg{int}
% \DescribeArg{num}
% \DescribeArg{dec}
% \DescribeArg{pct}
% \DescribeArg{div}
% These arguments do not need much explanation.
% However, as far as numerical values are concerned, it is noteworthy that real numbers in (La)\TeX{} are --- as long as they are to be used in the context of lengths, dimensions, or skips --- are restricted to a maximum absolute value $<16384$.
% Certainly, in a chain of numerical calculations, this constraint has also to be obeyed for every single interim result, which usually implies further range restrictions.
% Since \XC{} makes extensive use of \TeX's internal dimension registers for most types of calculations, this should be kept in mind whenever \Meta{ext expr} expressions are to be used.
%
%
% \paragraph{Color names}
% \DescribeArg{name}
% A \Meta{name} denotes the declared name (or the name to be declared) of a \emph{color} or a \emph{color series};
% it may be declared \emph{explicitly} by one of the following commands: |\definecolor|, |\providecolor|, |\colorlet|, |\definecolorset|, |\providecolorset|, |\definecolorseries|, |\definecolors|, |\providecolors|.
% On the other hand, the reserved color name `|.|' is declared \emph{implicitly} and denotes the \emph{current color}.
% Actually, besides letters and digits, certain other characters do also work for \Meta{name} declarations, but the given restriction avoids misunderstandings and ensures compatibility with future extensions of \XC.
%
% Examples: `|red|', `|MySpecialGreen1980|', `|.|'.
%
%
% \paragraph{Color models}
% \DescribeArg{core model}
% \DescribeArg{num model}
% \DescribeArg{model}
% The differentiation between \emph{core models} (\Model{rgb}, \Model{cmy}, \Model{cmyk}, \Model{hsb}, \Model{gray}), \emph{integer models} (\Model{RGB}, \Model{HTML}, \Model{HSB}, \Model{Gray}), \emph{decimal models} (\Model{Hsb}, \Model{tHsb}, \Model{wave}) and \emph{pseudo models} (currently \nModel{named}, \nModel{ps}) has a simple reason: core models with their parameter ranges based on the unit interval $[0,1]$ are best suited for all kinds of calculations, whereas the purpose of the integer models is mainly to facilitate the input of parameters, followed by some transformation into one of the core models.
% Finally, the decimal models \Model{Hsb} and \Model{tHsb} are special-purpose versions of \Model{hsb}, whereas \Model{wave} and the pseudo model \nModel{named} have a special status, since they are `calculation-averse': it is usually only possible to convert such a color into one of the other models, but not the other way round.
% Even worse for the pseudo model \nModel{ps}: since such colors contain \Index{PostScript} code, they are absolutely intransparent for \TeX.
%
%
% \paragraph{Color specifications}
% \DescribeArg{spec}
% The \Meta{spec} argument --- which specifies the parameters of a color --- obviously depends on the underlying color model.
% We differentiate between \emph{explicit} and \emph{implicit} specification, the former referring to numerical parameters as explained in table \vref{tab.mod}, the latter --- ideally --- referring to driver-provided names.
%
% Examples: `|.1,.2,.3|', `|.1 .2 .3|', `|0.56789|', `|89ABCD|', `|ForestGreen|'.
%
%
% \paragraph{Multiple models and specifications}
% \DescribeArg{model-list}
% \DescribeArg{spec-list}
% These arguments always appear in (explicit or implicit) pairs within the following color definition commands:
% |\definecolor|, |\providecolor|, |\definecolorset|, |\providecolorset|.
% First, \Meta{model-spec} is being reconciled with the current target model (as set by a package option or the |\selectcolormodel| command); in case there is no exact match, the first model of the list is chosen.
% Then, the corresponding color specification will be selected from \Meta{spec-list}, such that we arrive at a proper $(\Meta{model}, \Meta{spec})$ pair.
% Therefore, in the actual executed color definition there is no ambiguity anymore.
% The extended form \Meta{core model}|:|\Meta[1]{model}|/|\Meta[2]{model}|/.../|\Meta[m]{model} causes an immediate conversion of the relevant \Meta{spec} to \Meta{core model}; an unknown target model will be silently ignored here.
%
% Examples: `|rgb/cmyk/named/gray|', `|0,0,0/0,0,0,1/Black/0|', `|rgb:cmy/hsb|'.
%
%
% \paragraph{The type argument}
% \DescribeArg{type}
% This is used only in the context of color defining commands, see the description of |\definecolor| and friends.
%
%
% \paragraph{Standard color expressions}
% \DescribeArg{expr}
% \DescribeArg{prefix}
% \DescribeArg{mix expr}
% \DescribeArg{postfix}
% These expressions serve as a tool to easily specify a certain form of cascaded color mixing which is described in detail in section~\ref{sec.expr-meaning}.
% The \Meta{prefix} argument controls whether the color following thereafter or its complement will be relevant:
% an odd number of minus signs indicates that the color resulting from the remaining expression has to be converted into its complementary color.
% An \emph{incomplete mix expression} is just an abbreviation for a \emph{complete mix expression} with $\Meta[n]{name} = |white|$, in order to save some keystrokes in the case of tints.
% The \Meta{postfix} string is usually empty, but it offers some additional functionality in the case of a \emph{color series}:
% the non-empty cases require that
% \begin{itemize}
% \item \Meta{name} denotes the name of a \emph{color series},
% \item \Meta{mix expr} is a \emph{complete} mix expression.
% \end{itemize}
% Examples: `|red|', `|-red|', `|--red!50!green!12.345|', `|red!50!green!20!blue|', `|foo!!+|', `|foo!![7]|', `|foo!25!red!!+++|', `|foo!25!red!70!green!![7]|'.
%
%
% \paragraph{Extended color expressions}
% \DescribeArg{ext expr}
% These expressions provide another method of color mixing, see section \vref{sec.extexpr-meaning} for details.
% The shorter form
% \begin{align*}
% \Meta{core model}&|:|\Meta[1]{expr}|,|\Meta[1]{dec}|;|\Meta[2]{expr}|,|\Meta[2]{dec}|;...;|\Meta[k]{expr}|!|\Meta[k]{dec}\\
% \intertext{is an abbreviation for the special (and probably most used) case}
% \Meta{core model}|,|\Meta{div}&|:|\Meta[1]{expr}|,|\Meta[1]{dec}|;|\Meta[2]{expr}|,|\Meta[2]{dec}|;...;|\Meta[k]{expr}|!|\Meta[k]{dec}\\
% \intertext{with the following definition (requiring a non-zero sum of all \Meta[\kappa]{dec} coefficients):}
% \Meta{div} &:= \Meta[1]{dec} + \Meta[2]{dec} + \dots + \Meta[k]{dec} \neq0.
% \end{align*}
% Examples: `|rgb:red,1|', `|cmyk:red,1;-green!25!blue!60,11.25;blue,-2|'.
%
%
% \paragraph{Function expressions}
% \DescribeArg{func expression}
% \DescribeArg{function}
% These expressions extend the functionality of \emph{standard} or \emph{extended} expressions by taking the result of such an expression to perform additional calculations.
% The number of arguments may vary between different functions, see section \vref{sec.functions} for details.
%
% Examples: `|>wheel,30|', `|>wheel,30,|', `|>twheel,1,12|', `|>twheel,-11,12|'.
%
%
%
% \paragraph{Colors}
% \DescribeArg{color}
% \DescribeArg{color expr}
% Finally, \Meta{color} is the `umbrella' argument, covering the different concepts of specifying colors.
% This means, whenever there is a \Meta{color} argument, the full range of names and expressions, as explained above, may be used.
%
%
% \subsubsection{Meaning of standard color expressions}\label{sec.expr-meaning}
%
% We explain now how an expression
% \begin{gather*}
% \Meta{prefix}\Meta{name}|!|\Meta[1]{pct}|!|\Meta[1]{name}|!|\Meta[2]{pct}|!|\dots|!|\Meta[n]{pct}|!|\Meta[n]{name}\Meta{postfix}
% \end{gather*}
% is being interpreted and processed:
% \begin{enumerate}
% \item First of all, the model and color parameters of \Meta{name} are extracted to define a temporary color \Meta{temp}.
% If \Meta{postfix} has the form `|!![|\Meta{num}|]|', then \Meta{temp} will be the corresponding (direct-accessed) color \Meta{num} from the series \Meta{name}.
% \item Then a color mix, consisting of \Meta[1]{pct}\% of color \Meta{temp} and $(100-\Meta[1]{pct})$\% of color \Meta[1]{name} is computed; this is the new temporary color \Meta{temp}.
% \item The previous step is being repeated for all remaining parameter pairs (\Meta[2]{pct},\Meta[2]{name}), \dots, (\Meta[n]{pct},\Meta[n]{name}).
% \item If \Meta{prefix} consists of an odd number of minus signs `-', then \Meta{temp} will be changed into its complementary color.
% \item If \Meta{postfix} has the form `|!!+|', `|!!++|', `|!!+++|', etc., a number of step commands (=~number of `|+|' signs) are performed on the underlying color series \Meta{name}.
% This has no consequences for the color \Meta{temp}.
% \item Now the color \Meta{temp} is being displayed or serves as an input for other operations, depending on the invoking command.
% \end{enumerate}
% Note that in a typical step 2 expression \Meta{temp}|!|\Meta[\nu]{pct}|!|\Meta[\nu]{name}, if \Meta[\nu]{pct}=100 resp.{} \Meta[\nu]{pct}=0, the color \Meta{temp} resp.{} \Meta[\nu]{name} is used without further transformations.
% In the true mix case, $0<$\Meta[\nu]{pct}$<100$, the two involved colors may have been defined in different color models, e.g., |\definecolor{foo}{rgb}{...}| and |\definecolor{bar}{cmyk}{...}|.
% In general, the second color, \Meta[\nu]{name}, is transformed into the model of the first color, \Meta{temp}, then the mix is calculated within that model.\,\footnote{Exception: in order to avoid strange results, this rule is being reversed if \Meta{temp} origins from the \Model{gray} model; in this case it is converted into the underlying model of \Meta[\nu]{name}.}
% Thus, \Meta{temp}|!|\Meta[\nu]{pct}|!|\Meta[\nu]{name} and \Meta[\nu]{name}|!|\Meta[\nu]{$100-$pct}|!|\Meta{temp}, which should be equivalent theoretically, will not necessarily yield identical visual results.
%
% Figures \vrefrange{fig.expr}{fig.ex} show some first applications of colors and expressions.
% More examples are given in figure \vref{fig.progress}.
% Over and above that, a large set of color examples can be found in \cite{chroma}.
%
%
% \subsubsection{Meaning of extended color expressions}\label{sec.extexpr-meaning}
%
% An \emph{extended color expression}
% \begin{gather*}
% \Meta{core model}|:|\Meta[1]{expr}|,|\Meta[1]{dec}|;|\Meta[2]{expr}|,|\Meta[2]{dec}|;...;|\Meta[k]{expr}|,|\Meta[k]{dec}
% \end{gather*}
% mimes color mixing as painters do it: specify a list of colors, each with a \Meta{dec} factor attached to.
% For such an \Meta{ext expr}, each standard color expression \Meta[\kappa]{expr} will be converted to \Meta{core model}, then the resulting vector is multiplied by $\Meta[\kappa]{dec}/\Meta{div}$, where
% \begin{gather*}
% \Meta{div} := \Meta[1]{dec} + \Meta[2]{dec} + \dots + \Meta[k]{dec}.
% \end{gather*}
% Afterwards the sum of all of these vectors is calculated.
%
% Example: mixing 4~parts of \testclr{red} \Color{red}, 2~parts of \testclr{green} \Color{green}, and 1~part of \testclr{yellow} \Color{yellow}, we get \testclr{rgb:red,4;green,2;yellow,1} via |\color{rgb:red,4;green,2;yellow,1}|.
% Trying the same with $-1$ parts of \Color{yellow} instead, we get \testclr{rgb:red,4;green,2;yellow,-1}.
% Note that this mechanism can also be used to display an individual color (expression) in a certain color model: |\color{rgb:yellow,1}| results in such a conversion.
% The general form
% \begin{gather*}
% \Meta{core model}|,|\Meta{div}|:|\Meta[1]{expr}|,|\Meta[1]{dec}|;|\Meta[2]{expr}|,|\Meta[2]{dec}|;...;|\Meta[k]{expr}|,|\Meta[k]{dec}
% \end{gather*}
% does the same operation with the only difference that the divisor \Meta{div} is being specified instead of calculated.
% In the above example, we get a shaded version \testclr{rgb,9:red,4;green,2;yellow,1} via |\color{rgb,9:red,4;green,2;yellow,1}|.
% Note that it is not forbidden to specify a \Meta{div} argument which is smaller than the sum of all \Meta[\kappa]{dec}, such that one or more of the final color specification parameters could be outside the interval $[0,1]$.
% However, the mapping of equation (\ref{eq.U}) takes care of such cases.
%
%
% \subsubsection{Color functions}\label{sec.functions}
%
% Color functions take a comma-separated list of arguments, and they serve to transform the \emph{given color} (i.e., the result of all calculations prior to the function call) into a new color.
%
% \paragraph{Color wheel calculations}
% \DescribeFunc{wheel}
% \DescribeFunc{twheel}
% Arguments: \Meta{angle} or \Meta{angle}|,|\Meta{full circle}, the former being an abbreviataion of \Meta{angle}|,\rangeHsb|.
% These functions allow to calculate related colors by harmonic relations based on color wheels (cf.~section \vref{sec.harmony}).
% The second argument \Meta{full circle} declares how many units a full circle consists of, the first argument states by how many units the given color has to be rotated.
% To this end, the given color is first converted to \Model{Hsb} (in case of \Function{wheel}), yielding \emph{hue\Circ}, \emph{saturation}, and \emph{brightness}, respectively.
% Then
% \begin{gather}
% \displaystyle\emph{hue\Circ} := \emph{hue\Circ} + \frac{\Meta{angle}}{\Meta{full circle}}\cdot H, \qquad \emph{hue} := u\Bigl( \frac{\emph{hue\Circ}}{H} \Bigr)
% \end{gather}
% where $u$ is the range-reduction function of equation~(\ref{eq.U}) and $H = \texttt{\string\rangeHsb}$.
% With \emph{saturation} and \emph{brightness} left untouched, the final model is \Model{hsb}.
% The \Function{twheel} function works similarly, but its arguments refer to \Model{tHsb} instead of \Model{Hsb}.
% Examples are shown in figure \vref{fig.harmony}.
%
%
% \subsection{Predefined colors}
%
% \subsubsection{Colors that are always available}
%
% \def\test#1{\testclr{#1}~\Color{#1}}
% Within \File{xcolor.sty}, the following color names are defined:
% \test{red}, \test{green}, \test{blue}, \test{cyan}, \test{magenta}, \test{yellow}, \test{black}, \test{gray}, \test{white}, \test{darkgray}, \test{lightgray}, \test{brown}, \test{lime}, \test{olive}, \test{orange}, \test{pink}, \test{purple}, \test{teal}, \test{violet}.
%
% This base set of colors can be used without restrictions in all kinds of color expressions, as explained in section \vref{sec.term}.
%
%
% \subsubsection{Additional sets of colors}\label{sec.additionalcolors}
%
% There are also sets of color names that may be loaded by \XC{} via package options, available in two variants:
% a `normal' version (e.g., \Option{dvipsnames}) and a `starred' version (e.g., \Option{dvipsnames*}).
% The first variant simply defines all the colors \emph{immediately}, whereas the second applies the mechanism of \emph{deferred} definition.
% In the latter case, individual color names have to be activated by |\definecolors| or |\providecolors| commands, as described in section \vref{sec.deferred}, before they can be applied in a document.
% \begin{itemize}
% \item \Option{dvipsnames}/\Option{dvipsnames*} loads a set of 68 \Model{cmyk} colors as defined in the |dvips| driver. However, these colors may be used in all supported drivers.
% \item \Option{svgnames}/\Option{svgnames*} loads a set of 151 \Model{rgb} color names\footnote{In fact, these names represent 141 different colors.} according to the \Index{SVG}~1.1 specification \cite{svg}\footnote{Actually, the cited specification lists only lowercase names, and the original definitions are given in \Model{RGB} parameters, converted to \Model{rgb} by the author.}, enhanced by~4 names taken from the file \File{rgb.txt} which is part of \Index{Unix}/\Index{X11} distributions. Note that \Index{HTML4} accepts a subset of 16~color keywords (using identical specifications), see \cite{HTML4} and section \vref{sec.names}.
% \item \Option{x11names}/\Option{x11names*} loads a set of 317 \Model{rgb} color names\footnote{These names represent 315 different colors.} that are basically variations of a subset of the \Index{SVG} set mentioned before, according to the file \File{rgb.txt} which is part of \Index{Unix}/\Index{X11} distributions\footnote{Again, the original definitions are given in \Model{RGB} parameters, converted to \Model{rgb} by the author.}.
% We describe now how to access all 752 color names of \File{rgb.txt} without much effort:
% \begin{itemize}
% \item Load \Option{x11namees} as well as \Option{svgnames}.
% \item Capitalise initials and skip blanks: \Color[-]{DarkSlateGray} instead of \Color[-]{dark slate gray}.
% \item \Index{X11} names without numbers are identical to the corresponding \Index{SVG} colors, except in 5~cases:
% use \Color{Gray0}, \Color{Grey0}, \Color{Green0}, \Color{Maroon0}, \Color{Purple0} instead of \Color[-]{Gray}, \Color[-]{Grey}, \Color[-]{Green}, \Color[-]{Maroon}, \Color[-]{Purple} to obtain the original \Index{X11} colors.
% \item For $N=0,1,\dots,100$ use `|[gray]{|$N/100$|}|' or `|black!|$100-N$' instead of \Color[-]{grayN} or \Color[-]{greyN}.
% \end{itemize}
% \end{itemize}
% The color names and corresponding displays are listed in section \vref{sec.names}.
% Section \vref{sec.clash} describes how to deal with name clashs while using both \Option{svgnames} and \Option{dvipsnames} in the same document.
% See also \cite{chroma} for a systematic set of color and mix examples.
%
%
% \subsection{Color definition}\label{sec.def}
%
% \subsubsection{Ordinary and named colors}\label{sec.prologue}
%
% In the \LCP{} there is a distinction between `colors' (defined by the command |\definecolor|) and `named colors' (defined by |\DefineNamedColor|, which is allowed only in the preamble).
% Whenever an ordinary color is being used in a document, it will be translated into a |\special| command that contains a --- driver-specific --- numerical description of the color which is written to the \File{.dvi} file.
% On the other hand, named colors offer the opportunity to store numerical values at a central place whereas during usage, colors may be identified by their names, thus enabling post-processing if required by the output device.
%
% All drivers delivered with the standard \Package{graphics} package support the \emph{formalism} of defining and invoking `named colors'.
% However, real support for the \emph{concept} behind that, i.e.~employing names instead of parameters, ranges from `none' to `complete'.
% We demonstrate the current situation for three different drivers:
% \begin{itemize}
% \item \Option{dvips} has very good support for the `named' concept; the \Index{PostScript} equivalents to the color names defined by \Option{dvipsnames} are being loaded -- unless switched off -- by \Program{dvips} automatically.
% However, additional names have to be made known to the \Index{PostScript} interpreter by some kind of header file.
% Since version 2.01, \XC{} offers an integrated solution for this task: by invoking the package option \Option{prologue}, a \Index{PostScript} header file \File{xcolor.pro} is loaded by \Program{dvips}.
% Additionally, under this option every color definition command\footnote{This is not only true for the document preamble, but for the document body as well.} (|\definecolor|, |\colorlet|, etc.) will generate some \Index{PostScript} code that is written to an auxiliary file with the extension \File{.xcp} (shortcut for \textbf{xc}olor \textbf prologue).
% This file is as well loaded by \Program{dvips} as a prologue, thus making all color names available to the \Index{PostScript} interpreter.
% Of course, the \File{.xcp} file may be edited before \Program{dvips} is applied, making it easy to change device-specific color parameters at a central place.
% Note that the \Index{PostScript} code is designed similar to \File{color.pro}: only \emph{new} names are defined.
% This allows to preload other prologue files with color definitions that are not being destroyed by \XC.
% On the other hand, it requires the user to take care about redefining color names.\\
% Example: |\colorlet{foo}{red}\colorlet{foo}{blue}\color{foo}| will switch to \Color{blue} in the usual \XC{} logic, however the \File{.ps} file would display \Color{red} (unless \Color{foo} had been defined differently before).\\
% It should be stressed that this mechanism is only employed by the \Option{prologue} option.
% Without that, the predefined `named' colors activated by the \Option{dvipsnames} option (without employing any tints, shades, color expressions, etc.) may be used in this way, all other `named' colors are unknown to \Index{PostScript}.
% \item \Option{dvipdfm} supports only the standard \Option{dvipsnames} colors since these are hard-coded in the \Program{dvipdfm} program itself; there seems to be no way to load any user-defined prologue files.
% \item \Option{pdftex} does not offer conceptual support, all `named' colors are converted immediately to their numerical representation. It therefore allows unrestricted definition and usage of named colors (although offering no added value through this).
% \end{itemize}
%
% Typically, a \File{.dvi} viewer will have difficulties to display user-defined `named' colors.
% For example, \Index{MiK\TeX}'s viewer \Program{Yap} currently displays only `named' colors from the \Option{dvipsnames} set.
% Thus, whenever the \Option{prologue} option is invoked together with \Option{dvips}, \emph{all} other colors will appear black.
% However, after employing \Program{dvips}, a \Index{PostScript} viewer should display the correct colors.
%
%
% \subsubsection{Color definition in \XC}
%
% \DescribeMacro\definecolor
%   \oarg{type}\marg{name}\marg{model-list}\marg{spec-list}\footnote{Prior to version 2.00, this command was called \cs{xdefinecolor}, the latter name still being available for compatibility reasons.}\\
% This is one of the commands that may be used to assign a \Meta{name} to a specific color.
% Afterwards, this color is known to the system (in the current group) and may be used in \emph{\Index{color expression}s}, as explained in section \vref{sec.term}.
% It replaces both \LC's |\DefineNamedColor| and |\definecolor|.
% Note that an already existing color \Meta{name} will be overwritten.
% The variable |\tracingcolors| controls whether such an overwriting will be logged or not (see section \vref{sec.info} for details).
% The arguments are described in section \vref{sec.term}.
% Hence, valid expressions for color definitions are
% \begin{itemize}
% \item |\definecolor{red}{rgb}{1,0,0}|,
% \item |\definecolor{red}{rgb/cmyk}{1,0,0/0,1,1,0}|,
% \item |\definecolor{red}{hsb:rgb/cmyk}{1,0,0/0,1,1,0}|,
% \item |\definecolor[named]{Black}{cmyk}{0,0,0,1}|,
% \item |\definecolor{myblack}{named}{Black}|,
% \end{itemize}
% where the last command is equivalent to |\colorlet{myblack}{Black}| (see below); the second command defines \Color{red} in the \Model{rgb} or \Model{cmyk} model, depending on the current setting of the \emph{target model}, whereas the third will additionally transform the color to \Model{hsb} prior to saving.
% Note that there is a special \Package{pstricks}-related version as described in section \vref{sec.pstricks}.
%
% \medskip
%
% \DescribeMacro\providecolor
%   \oarg{type}\marg{name}\marg{model-list}\marg{spec-list}\\
% Similar to |\definecolor|, but the color \Meta{name} is only defined if it does not exist already.
%
% \medskip
%
% \DescribeMacro\colorlet
%   \oarg{type}\marg{name}\oarg{num model}\marg{color}\\
% Copies the actual color which results from \Meta{color} to \Meta{name}.
% If \Meta{num model} is non-empty, \Meta{color} is first transformed to the specified model, before \Meta{name} is being defined.
% The pseudo model \nModel{named} is \emph{not} allowed here, it may, however, be specified in the \Meta{type} argument.
% Note that an already existing color \Meta{name} will be overwritten.
%
% Example: we said |\colorlet{tableheadcolor}{gray!25}| in the preamble of this document.
% In most of the tables we then formatted the first row by using the command |\rowcolor{tableheadcolor}|.
%
%
% \subsubsection{Defining sets of colors}
%
% \DescribeMacro\definecolorset
%   \oarg{type}\marg{model-list}\marg{head}\marg{tail}\marg{set spec}\\
% This command facilitates the construction of \emph{\Index{color set}s}, i.e.~(possibly large) sets of individual colors with common underlying \Meta{model-list} and \Meta{type}.
% Here, \Meta{set spec} = \Meta[1]{name},\Meta[1]{spec-list};\dots;\Meta[l]{name},\Meta[l]{spec-list} ($l\ge1$ name/specification-list pairs).
% Individual colors are being constructed by single
% \begin{center}
% |\definecolor|\oarg{type}|{|\Meta{head}\Meta[\lambda]{name}\Meta{tail}|}|\marg{model-list}|{|\Meta[\lambda]{spec-list}|}|
% \end{center}
% commands, $\lambda=1,\dots,l$.
% For example,
% \begin{itemize}
% \item |\definecolorset{rgb}{}{}{red,1,0,0;green,0,1,0;blue,0,0,1}|\\
% could be used to define the basic colors \Color{red}, \Color{green}, and \Color{blue};\footnote{Actually, \XC{} uses a more complicated variant to provide the basic colors for different underlying models (see the source code for the full command):\\
% \cs{definecolorset\string{rgb/hsb/cmyk/gray\string}\string{\string}\string{\string}\string{red,1,0,0/0,1,1/0,1,1,0/.3;green,...\string}}.}
% \item |\definecolorset{rgb}{x}{10}{red,1,0,0;green,0,1,0;blue,0,0,1}|\\
% would define the colors \Color[-]{xred10}, \Color[-]{xgreen10}, and \Color[-]{xblue10}.
% \end{itemize}
%
% \DescribeMacro\providecolorset
%   \oarg{type}\marg{model-list}\marg{head}\marg{tail}\marg{set spec}\\
% Similar to |\definecolorset|, but based on |\providecolor|, thus the individual colors are defined only if they do not exist already.
%
%
% \subsubsection{Immediate and deferred definitions}\label{sec.deferred}
%
% Traditionally, the definition of a color as described above leads to the immediate construction of a command that holds at least the information needed by the driver to display the desired color.
% Thus, defining 300 colors, e.g., by loading a huge set of predefined colors, will result in 300 new commands, although most of them --- except for the purpose of displaying lists of colors --- will hardly ever be used within a document.
% Along the development of computer memory --- increasing in size, decreasing in price --- recent \TeX{} implementations have increased their provisions for internal memory stacks that are available for strings, control sequences, etc.
% However, as memory continues to be finite, it may still be useful (or occasionally necessary) to have a method at hand that allows to reduce memory requirements a bit.
% This is the point where \emph{deferred color definition} comes into play.
% Its principle is simple: for every definition of this type (e.g., via |\preparecolor|), all necessary information is saved on a specific global \emph{\Index{definition stack}}, where it can be taken from later (e.g., via |\definecolors|) in order to construct the actual color command.
%
% Note that the following commands are only to be used in the document preamble, since the definition stack of colors for deferred definitions is deleted at the begin of the document body --- in order to save memory.
%
% \medskip
%
% \DescribeMacro\preparecolor
%   \oarg{type}\marg{name}\marg{model-list}\marg{spec-list}\\
% Similar to |\definecolor|, but the color \Meta{name} is not yet being defined: the arguments \Meta{model-list} and \Meta{spec-list} are evaluated immediately, then all necessary parameters (i.e.~\Meta{type}, \Meta{name}, \Meta{model}, \Meta{spec}) are put onto the \emph{\Index{definition stack}} for later usage.
%
% \medskip
%
% \DescribeMacro\preparecolorset
%   \oarg{type}\marg{model-list}\marg{head}\marg{tail}\marg{set spec}
% \DescribeMacro\ifdefinecolors\\
% Similar to |\definecolorset|, but depending on the |\ifdefinecolors| switch: if set to `true', to each element of the set the command |\definecolor| (i.e.~immediate definition) is applied; if set to `false', |\preparecolor| (i.e.~deferred definition) is applied.
% For example, the package option \Option{svgnames} performs something like |\definecolorstrue\preparecolorset|, whereas \Option{svgnames*} acts like |\definecolorsfalse\preparecolorset|.
% Both options set |\definecolorstrue| at the end, in order to have a proper starting point for other color sets.
%
% \medskip
%
% \DescribeMacro\DefineNamedColor
%   \marg{type}\marg{name}\marg{model-list}\marg{spec-list}
% is provided mainly for compatibility reasons, especially to support the predefined colors in \File{dvipsnam.def}.
% It is the same as \Meta{cmd}\oarg{type}\marg{name}\marg{model}\marg{spec}, where \Meta{cmd} is either |\definecolor| or |\preparecolor|, depending on the state of |\ifdefinecolors|.
% Note that \LC's restriction to allow |\DefineNamedColor| only in the document preamble has been abolished in \XC.
%
% \medskip
%
% \DescribeMacro\definecolors
%   \marg{id-list}\\
% Recall that \Meta{id-list} has the form \Meta[1]{ext id}|,...,|\Meta[l]{ext id} where each \Meta[\lambda]{ext id} is either an identifier \Meta[\lambda]{id} or an assignment \Meta[\lambda']{id}|=|\Meta[\lambda]{id}.
% We consider the first case to be an abbreviation for \Meta[\lambda]{id}|=|\Meta[\lambda]{id} and describe the general case:
% the \Index{definition stack} is searched for the name \Meta[\lambda]{id} and its corresponding color parameters; if there is no match, nothing happens; if the name \Meta[\lambda]{id} is on the stack and its color parameters are \Meta[\lambda]{type}, \Meta[\lambda]{model}, and \Meta[\lambda]{spec}, then the command |\definecolor[|\Meta[\lambda]{type}|]{|\Meta[\lambda']{id}|}{|\Meta[\lambda]{model}|}{|\Meta[\lambda]{spec}|}| is executed.
% Thus, the user may control by which names the \emph{prepared} colors are to be used in the document.
% Note that the entry \Meta[\lambda]{id} is not removed from the stack, such that it can be used several times (even within the same |\definecolors| command).
%
% \medskip
%
% \DescribeMacro\providecolors
%   \marg{id-list}\\
% Similar to |\definecolors|, but based on |\providecolor|, thus the individual colors are defined only if they do not exist already.
%
%
% \subsubsection{Global color definitions}
%
% \DescribeMacro\ifglobalcolors
% By default, definitions via |\definecolor|, |\providecolor|, \dots{} are available only within the current group.
% By setting |\globalcolorstrue|, all such definitions are being made globally available --- until the current group ends.\footnote{The switch may also be set in the preamble in order to control the whole document.}
% \DescribeMacro\xglobal
% Another method to specify that an individual color definition is to be made global is to prefix it by |\xglobal|, e.g., |\xglobal\definecolor{foo}...|.
%
%
%
% \subsection{Color application}
%
% \subsubsection{Standard color commands}
%
% Here is the list of user-level color commands, as known from the \LCP, but with an extended syntax for the colors, allowing for expressions etc.:\\
% \DescribeMacro\color\marg{color}\\
% \oarg{model-list}\marg{spec-list}\\
% Switches to the color given either by name/expression or by model/specification.
% This color will stay in effect until the end of the current \TeX\ group.\\
% \DescribeMacro\textcolor\marg{color}\marg{text}\\
% \oarg{model-list}\marg{spec-list}\marg{text}\\
% are just alternative syntax for |\color|, in which the groups are added implicitly.
% Thus \meta{text} appears in the specified color, but then the color reverts to its previous value.
% Additionally, it calls |\leavevmode| to ensure the start of horizontal mode.\\
% \DescribeMacro\pagecolor\marg{color}\\
% \oarg{model-list}\marg{spec-list}\\
% Specifies the background color for the current, and all following, pages.
% It is a global declaration which does not respect \TeX\ groups.
%
% Remark: all of these commands except |\color| require that the \Meta{color} resp.\ \Meta{spec} arguments are put into curly braces |{}|, even if they are buried in macros.
%
% For example, after |\def\foo{red}|, one may say |\color\foo|, but one should always write |\textcolor{\foo}{bar}| instead of |\textcolor\foo{bar}| in order to avoid strange results.
%
% Note that color-specific commands from other packages may give unexpected results if directly confronted with color expressions (e.g., \Package{soul}'s |\sethlcolor| and friends).
% However, one can turn the expression into a name via |\colorlet| and try to use that name instead.
%
%
% \subsubsection{Colored boxes}\label{sec.fbox}
%
% \DescribeMacro\colorbox\marg{color}\marg{text}\\
% \oarg{model-list}\marg{spec-list}\marg{text}\\
% Takes the same argument forms as |\textcolor|, but the color specifies the \emph{background} color of the box.\\
% \DescribeMacro\fcolorbox\marg{frame color}\marg{background color}\marg{text}\\
% \oarg{model-list}\marg{frame spec-list}\marg{background spec-list}\marg{text}\\
% \oarg{fr.~model-list}\marg{fr.~spec-list}\oarg{backgr.~model-list}\marg{backgr.~spec-list}\marg{text}\\
% \marg{frame color}\oarg{background model-list}\marg{background spec-list}\marg{text}\\
% Puts a frame of the first color around a box with a background specified by the second color.
% If only the first optional argument is given, it specifies the color model for both colors.
% Besides the possibility to specify color \emph{expressions} as arguments, |\fcolorbox| now offers more flexibility for its arguments than the \LC{} version:
% \begin{itemize}
% \item \fcolorbox{gray}{yellow}{test} |\fcolorbox{gray}{yellow}{test}|,
% \item \fcolorbox[cmyk]{0,0,0,0.5}{0,0,1,0}{test} |\fcolorbox[cmyk]{0,0,0,0.5}{0,0,1,0}{test}|,
% \item \fcolorbox[gray]{0.5}[wave]{580}{test} |\fcolorbox[gray]{0.5}[wave]{580}{test}|,
% \item \fcolorbox{gray}[wave]{580}{test} |\fcolorbox{gray}[wave]{580}{test}|.
% \end{itemize}
% Additionally, |\fcolorbox| uses a new approach to frame drawing, which is an extension of \People{Donald}{Arseneau}'s suggestion in bug report latex/3655 \cite{fbox}.
% The main difference to \LaTeX's implementation is that box construction and frame drawing are split into separate operations, such that the frame is drawn \emph{after} the box contents has been constructed.
% This ensures that the frame is always on top of the box.
% \People{Donald}{Arseneau} improved speed as well as memory requirements of this approach.
% Furthermore, a new macro is introduced:
%
% \DescribeMacro\boxframe\marg{width}\marg{height}\marg{depth}\\
% Draws a frame with a linewidth of |\fboxrule|.
% Returns a |\hbox| with outer dimensions \meta{width}, \meta{height}, \meta{depth}.
% By this approach, a frame-primitive may also be provided by a driver file, in order to exploit driver-specific drawing facilities (see below).
% Again, this macro was optimised by \People{Donald}{Arseneau}.
%
% The new frame approach is used for |\fcolorbox| as well as \LaTeX's |\fbox| and |\framebox| commands, unless the \Option{kernelfbox} option is specified, which returns to \LaTeX's original definitions of |\f(rame)box|.
%
% Option \Option{xcdraw} uses \Index{PostScript} commands to draw frames and color boxes in case of the \Option{dvips} driver and \Index{PDF} code to draw frames in case of the \Option{pdftex} and \Option{dvipdfm} drivers.
% This is still experimental code that may confuse \File{.dvi} viewers.
% The opposite option \Option{noxcdraw} forces usage of the generic (driver-independent) code.
%
%
% \subsubsection{Using the current color}
%
% Within a color expression, `.' serves as a placeholder for the current color.
% See figure \vref{fig.cc} for an example.
%
% It is also possible to save the current color for later use, e.g., via the command |\colorlet{foo}{.}|.
%
% Note that in some cases the current color is of rather limited use, e.g., the construction of an |\fcolorbox| implies that at the time when the \Meta{background color} is evaluated, the current color equals the \Meta{frame color}; in this case `|.|' does not refer to the current color \emph{outside} the box.
%
%
% \subsubsection{Color testing}
%
% \DescribeEnv{testcolors}
%   \oarg{num models}\\
% This is a simple tabular environment in order to test (display) colors in different models, showing both the visual result and the model-specific parameters.
% The optional \Meta{num models} argument is a comma-separated list of \emph{numerical} color models (as usual without spaces) which form the table columns; the default list is
% {\makeatletter\ttfamily\let\@protected@testopt\@gobbletwo\edef\tmp{\testcolors}\expandafter\@firstofone\tmp}.
%
% \DescribeMacro\testcolor
%   \marg{color}\\
%   \oarg{model-list}\marg{spec-list}\\
% Each |\testcolor| command generates a table row, containing a display sample plus the respective parameters for each of the models.
% If the column-model matches the model of the color in question, its parameters are underlined.
% Note that this command is only available within the |testcolors| environment.
%
% For applications see figure \vref{fig.testcolors} and figures \ref{fig.tHsb}, \ref{fig.harmony}.
%
%
%
% \subsection{Color blending}
%
% The purpose of \emph{color blending} is to add some mixing color (expression) to all subsequent explicit color commands.
% Thus, it is possible to perform such a mix (or blend) operation for many colors without touching the individual commands.
%
% \medskip
%
% \DescribeMacro\blendcolors
%   \marg{mix expr}\\
% \DescribeMacro{\blendcolors*}
%   \marg{mix expr}\\
% Initialises all necessary parameters for color blending.
% The actual (completed) color blend expression is stored in |\colorblend|.
% In the starred version, the argument will be appended to a previously defined blend expression.
% An empty \Meta{mix expr} argument will switch blending off.
%
% Example: after |\blendcolors{!50!yellow}|, the colors \testclr{red} \testclr{green} \testclr{blue} are transformed into {\blendcolors{!50!yellow}\testclr{red} \testclr{green} \testclr{blue}, an additional |\blendcolors*{!50}| yields \blendcolors*{!50}\testclr{red} \testclr{green} \testclr{blue}}.
% \DescribeMacro\xglobal
% In order to achieve global scope, |\blendcolors| may be prefixed by |\xglobal|.
%
% Remark: color blending is applied only to \emph{explicit} color commands, i.e.~|\color|, |\fcolorbox| and the like.
% In the previous example the frames are not being blended because their color is set by an driver-internal command (switching back to the `current color').
% Thus, to influence these \emph{implicit} colors as well, we have to set the current color \emph{after} the blending:
% |\blendcolors{!50!yellow}\color{black}| results in {\blendcolors{!50!yellow}\color{black}\testclr{red} \testclr{green} \testclr{blue}, an additional |\blendcolors*{!50}\color{black}| yields \blendcolors*{!50}\color{black}\testclr{red} \testclr{green} \testclr{blue}}.
%
%
%
% \subsection{Color masks and separation}
%
% The purpose of \emph{color separation} is to represent all colors that appear in the document as a combination of a finite subset of base colors and their tints.
% Most prominent is \Model{cmyk} separation, where the base colors are \Color{cyan}, \Color{magenta}, \Color{yellow}, and \Color{black}, as required by the printers.
% This can be done by choosing the package option \Option{cmyk}, such that all colors will be converted in this model, and post-processing the output file.
% We describe now another --- and more general --- solution: \emph{color masking}.
% How does it work?
% Color masking is based on a specified color model \Meta{m-model} and a parameter vector \Meta{m-spec}.
% Whenever a color is to be displayed in the document, it will first be converted to \Meta{m-model}, afterwards each component of the resulting color vector will be multiplied by the corresponding component of \Meta{m-spec}.
% For example, let's assume that \Meta{m-model} equals |cmyk|, and \Meta{m-spec} equals $(\mu_c,\mu_m,\mu_y,\mu_k)$.
% Then an arbitrary color \Color{foo} will be transformed according to
% \begin{gather}
% \Color{foo} \mapsto (c,m,y,k) \mapsto (\mu_c\cdot c,\mu_m\cdot m,\mu_y\cdot y,\mu_k\cdot k)
% \end{gather}
% Obviously, color separation is a special case of masking by the vectors $(1,0,0,0)$, $(0,1,0,0)$, etc.
% An interesting application is to shade or tint all colors by masking them with $(x,x,x)$ in the \Model{rgb} or \Model{cmy} model, see the last two rows in figure \vref{fig.mask}.
%
% \medskip
%
% \DescribeMacro\maskcolors
%   \oarg{num model}\marg{color}\\
% Initialises all necessary parameters for color masking:
% if \Meta{num model} is not specified (or empty), \Meta{m-model} will be set to the natural model of \Meta{color}, otherwise to \Meta{num model};
% the color specification of \Meta{color} is extracted to define \Meta{m-spec}.
% Additionally, |\maskcolorstrue| is performed.
% \DescribeMacro\ifmaskcolors
% Color masking can be switched off temporarily by |\maskcolorsfalse|, or --- in a more radical way --- by |\maskcolors{}|, which in addition clears the initialisation parameters.
% \DescribeMacro\xglobal
% In general, the scope of |\maskcolors| is the current group (unless it is prefixed by the |\xglobal| command), but it may be used in the document preamble as well.
% The final remark of the color blending section applies here similarly.
%
% Now it is easy to separate a complete document without touching the source code:
% |latex| |\def\xcolorcmd{\maskcolors[cmyk]{cyan}}\input{a}| will do the \Color{cyan} part of the job for |a.tex|.
%
% \DescribeMacro\colormask
% Caution: \XC{} has no idea about colors in files that are included via the command |\includegraphics|, e.g., images of type \File{.eps}, \File{.pdf}, \File{.jpg}, or \File{.png}.
% Such files have to be separated separately.
% Nevertheless, \XC{} offers some basic support by storing the mask color in |\colormask|, which can be used to decide which file is to be included:
% \begin{verbatim}
% \def\temp{cyan}\ifx\colormask\temp \includegraphics{foo_c}\else
% \def\temp{magenta}\ifx\colormask\temp \includegraphics{foo_m}\else
% ...
% \fi\fi
% \end{verbatim}
%
%
%
% \subsection{Color series}\label{sec.series}
%
% Automatic coloring may be useful in graphics or chart applications, where a --- potentially large and unspecified --- number of colors are needed, and the user does not want or is not able to specify each individual color.
% Therefore, we introduce the term \emph{color series}, which consists of a base color and a scheme, how the next color is being constructed from the current color.
%
% The practical application consists of three parts:
% definition of a color series (usually once in the document), initialisation of the series (potentially several times), and application --- with or without stepping --- of the current color of the series (potentially many times).
%
%
% \subsubsection{Definition of a color series}
%
% \DescribeMacro\definecolorseries
%   \marg{name}\marg{core model}\marg{method}\oarg{b-model}\marg{b-spec}\oarg{s-model}\marg{s-spec}\\
% Defines a color series called \Meta{name}, whose calculations are performed within the color model \Meta{core model}, where \Meta{method} selects the algorithm (one of |step|, |grad|, |last|, see below).
% The method details are determined by the remaining arguments:
% \begin{itemize}
% \item \oarg{b-model}\marg{b-spec} specifies the \emph{base} (= first) color in the algorithm, either directly, e.g., |[rgb]{1,0.5,0.5}|, or as a \Meta{color}, e.g., |{-yellow!50}|, if the optional argument is missing.
% \item \oarg{s-model}\marg{s-spec} specifies how the \emph{step} vector is calculated in the algorithm, according to the chosen \Meta{method}:
%   \begin{itemize}
%   \item |step|,\ |grad|:\ the optional argument is meaningless, and \Meta{s-spec} is a parameter vector whose dimension is determined by \Meta{core model}, e.g., |{0.1,-0.2,0.3}| in case of |rgb|, |cmy|, or |hsb|.
%   \item |last|:\ the last color is specified either directly, e.g., |[rgb]{1,0.5,0.5}|, or as a \Meta{color}, e.g., |{-yellow!50}|, if the optional argument is missing.
%   \end{itemize}
% \end{itemize}
% This is the general scheme:
% \begin{gather}
% \emph{color}_1 := \emph{base},\qquad
% \emph{color}_{n+1} := U\bigl(\emph{color}_{n} + \emph{step}\bigr)
% \end{gather}
% for $n=1,2,\dots$, where $U$ maps arbitrary real $m$-vectors into the unit $m$-cube:
% \begin{gather}
% U(x_1,\dots,x_m) = (u(x_1),\dots,u(x_m)),\qquad
% u(x) =
% \begin{cases}
%  1 & \text{if $x=1$}\\
%  x-[x]& \text{if $x\neq1$}\\
% \end{cases}\label{eq.U}
% \end{gather}
% Thus, every step of the algorithm yields a valid color with parameters from the interval $[0,1]$.
%
% \medskip
% Now, the different methods use different schemes to calculate the \emph{step} vector:
% \begin{itemize}
% \item |step|,\ |grad|:\ the last argument, \marg{s-spec}, defines the directional vector \emph{grad}.
% \item |last|:\ \marg{s-spec} resp.\ \oarg{s-model}\marg{s-spec} defines the color parameter vector \emph{last}.
% \end{itemize}
% Then, during |\resetcolorseries|, the actual \emph{step} vector is calculated:
% \begin{gather}
% \emph{step} :=
% \begin{cases}
% \emph{grad} & \text{if $\Meta{method} = |step|$}\\
% \frac1{\Meta{div}}\cdot\emph{grad} & \text{if $\Meta{method} = |grad|$}\\
% \frac1{\Meta{div}}\cdot(\emph{last}-\emph{base}) & \text{if $\Meta{method} = |last|$}\\
% \end{cases}\label{eq.cs}
% \end{gather}
% Please note that it is also possible to use the current color placeholder `.' within the definition of color series.
% Thus, |\definecolorseries{foo}{rgb}{last}{.}{-.}| will set up a series that starts with the current color and ends with its complement.
% Of course, similar to \TeX's |\let| primitive, the \emph{current} definition of the current color at the time of execution is used, there is no relation to current colors in any later stage of the document.
%
%
% \subsubsection{Initialisation of a color series}
%
% \DescribeMacro\resetcolorseries
%   \oarg{div}\marg{name}\\
% This command has to be applied at least once, in order to make use of the color series \Meta{name}.
% It resets the current color of the series to the base color and calculates the actual step vector according to the chosen \Meta{div}, a non-zero real number, for the methods |grad| and |last|, see equation (\ref{eq.cs}).
% \DescribeMacro\colorseriescycle
% If the optional argument is empty, the value stored in the macro |\colorseriescycle| is applied.
% Its default value is \colorseriescycle, which can be changed by |\def\colorseriescycle|\marg{div}, applied \emph{before} the \XCP{} is loaded (similar to |\rangeRGB| and friends).
% The optional argument is ignored in case of the |step| method.
%
%
% \subsubsection{Application of a color series}
%
% There are two ways to display the current color of a color series:
% any of the \emph{color expressions} in section \vref{sec.term} used within a |\color|, |\textcolor|, \dots{} command will display this color according to the usual syntax of such expressions.
% However, in the cases when \Meta{postfix} equals `|!!+|', |\color{|\Meta{name}|!!+}| etc., will not only display the color, but it will also perform a step operation.
% Thus, the current color of the series will be changed in that case.
% An expression |\color{|\Meta{name}|!![|\Meta{num}|]}| enables direct access to an element of a series, where \Meta{num} = $0,1,2,\dots$, starting with~0 for the base color.
% See figure \vref{fig.csx} for a demonstration of different methods.
%
%
% \subsubsection{Differences between colors and color series}
%
% Although they behave similar if applied within color expressions, the objects defined by |\definecolor| and |\definecolorseries| are fundamentally different with respect to their scope/availability:
% like \LC's original |\definecolor| command, |\definecolor| generates \emph{local} colors, whereas |\definecolorseries| generates \emph{global} objects (otherwise it would not be possible to use the stepping mechanism within tables or graphics conveniently).
% E.g., if we assume that |bar| is an undefined color, then after saying
% \begin{verbatim}
% \begingroup
% \definecolorseries{foo}{rgb}{last}{red}{blue}
% \resetcolorseries[10]{foo}
% \definecolor{bar}{rgb}{.6,.5,.4}
% \endgroup
% \end{verbatim}
% commands like |\color{foo}| or |\color{foo!!+}| may be used without restrictions, whereas |\color{bar}| will give an error message.
% However, it is possible to say |\colorlet{bar}{foo}| or |\colorlet{bar}{foo!!+}| in order to save the current color of a series locally --- with or without stepping.
%
%
%
%
% \subsection{Border colors for hyperlinks}\label{sec.hyperref}
%
% The \Package{hyperref} package offers all kinds of support for hyperlinks, pdfmarks etc.
% There are two standard ways to make hyperlinks visible (see the package documentation \cite{hyperref} for additional information on how to set up these features):
% \begin{itemize}
% \item print hyperlinks in a different color than normal text, using the keys \Key{citecolor}, \Key{filecolor}, \Key{linkcolor}, \Key{menucolor}, \Key{pagecolor}, \Key{runcolor}, \Key{urlcolor} with color expressions, e.g., |\hypersetup{urlcolor=-green!50}|;
% \item display a colored border around hyperlinks, using the keys \Key{citebordercolor}, \Key{filebordercolor}, \Key{linkbordercolor}, \Key{menubordercolor}, \Key{pagebordercolor}, \Key{runbordercolor}, \Key{urlbordercolor} with explicit numerical \Model{rgb} parameter specification, e.g., |\hypersetup{urlbordercolor={1 0.5 0.25}}|.
% \end{itemize}
% Obviously, the second method is somewhat inconvenient since it does not allow for color names or even color expressions.
% Therefore, \XC{} provides --- via the package option \Option{hyperref} --- a set of extended keys \Key{xcitebordercolor}, \Key{xfilebordercolor}, \Key{xlinkbordercolor}, \Key{xmenubordercolor}, \Key{xpagebordercolor}, \Key{xrunbordercolor}, \Key{xurlbordercolor} which are being used in conjunction with color expressions, e.g., |\hypersetup{xurlbordercolor=-green!50}|.
%
% Another new key, \Key{xpdfborder}, provides a way to deal with a \Program{dvips}-related problem:
% for most of the drivers, a setting like |pdfborder={0 0 1}| will determine the width of the border that is drawn around hyperlinks in points.
% However, in the \Program{dvips} case, the numerical parameters are interpreted in relation to the chosen output resolution for processing the \File{.dvi} file into a \File{.ps} file.
% Unfortunately, at the time when the \File{.dvi} is constructed, nobody knows if and at which resolution a transformation into \File{.ps} will take place afterwards.
% Consequently, any default value for \Key{pdfborder} may be useful or not.
% Within \Package{hyperref}, the default for \Program{dvips} is |pdfborder={0 0 12}|, which works fine for a resolution of 600 or 1200 dpi, but which produces an invisible border for a resolution of 8000 dpi, as determined by the command-line switch |-Ppdf|.
% On the other hand, setting |pdfborder={0 0 80}| works fine for \Program{dvips} at 8000 dpi, but makes a document unportable, since other drivers (or even |dvips| in a low resolution) will draw very thick boxes in that case.
% This is were the \Key{xpdfborder} key comes in handy: it rescales its arguments for the |dvips| case by a factor 80 (ready for 8000 dpi) and leaves everything unchanged for other drivers.
% Thus one can say |xpdfborder={0 0 1}| in a driver-independent way.
%
%
%
% \subsection{Additional color specification in the \Package{pstricks} world}\label{sec.pstricks}
%
% For \Package{pstricks} users, there are different ways of invoking colors within command option keys:
% \begin{itemize}
% \item |\psset{linecolor=green!50}|
% \item |\psset{linecolor=[rgb]{0.5,1,0.5}}|
% \item |\psframebox[linecolor={[rgb]{0.5,1,0.5}}]{foo}|
% \end{itemize}
% Note the additional curly braces in the last case; without them, the optional argument of |\psframebox| would be terminated too early.
%
% \DescribeMacro\definecolor
%   |[ps]|\marg{name}\marg{core model-list}\marg{code}\\
% Stores \Index{PostScript} \Meta{code} --- that should not contain slash~`|/|' characters --- within a color.
% Example:
% after |\definecolor[ps]{foo}{rgb}{bar}|, the \Package{pstricks} command |\psline[linecolor=foo]...| inserts `|bar setrgbcolor|' where the linecolor information is required --- at least in case of the \Option{dvips} driver.
% See also \href{xcolor2.pdf}{\File{xcolor2.tex}} for an illustrative application.
%
%
%
% \subsection{Color in tables}
%
% \DescribeMacro\rowcolors
%   \oarg{commands}\marg{row}\marg{odd-row color}\marg{even-row color}\\
% \DescribeMacro{\rowcolors*}
%   \oarg{commands}\marg{row}\marg{odd-row color}\marg{even-row color}\\
% One of these commands has to be executed \emph{before} a table starts.
% \Meta{row} tells the number of the first row which should be colored according to the \Meta{odd-row color} and \Meta{even-row color} scheme.
% Each of the color arguments may also be left empty (= no color).
% In the starred version, \Meta{commands} are ignored in rows with inactive \emph{rowcolors status} (see below), whereas in the non-starred version, \Meta{commands} are applied to every row of the table.
% Such optional commands may be |\hline| or |\noalign|\marg{stuff}.
%
% \DescribeMacro\showrowcolors
% \DescribeMacro\hiderowcolors
% The \emph{rowcolors status} is activated (i.e., use coloring scheme) by default and/or |\showrowcolors|, it is inactivated (i.e., ignore coloring scheme) by the command |\hiderowcolors|.
% \DescribeMacro\rownum
% The counter |\rownum| may be used within such a table to access the current row number.
% An example is given in figure \vref{fig.row}.
% These commands require the \Option{table} option (which loads the \Package{colortbl} package).
%
% Note that table coloring may be combined with color series.
% This method was used to construct the examples in figure \vref{fig.csx}.
%
%
%
% \subsection{Color information}\label{sec.info}
%
% \DescribeMacro\extractcolorspec
%   \marg{color}\marg{cmd}\\
% Extracts the color specification of \Meta{color} and puts it into \Meta{cmd}; equivalent to |\def\cmd{|\marg{model}\marg{spec}|}|.
%
% \DescribeMacro\extractcolorspecs
%   \marg{color}\marg{model-cmd}\marg{color-cmd}\\
% Extracts the color specification of \Meta{color} and puts it into \Meta{model-cmd} and \Meta{color-cmd}, respectively.
%
% \medskip
% \DescribeMacro\tracingcolors
%   |=|\Meta{int}\\
% Controls the amount of information that is written into the |log| file:
% \begin{itemize}
% \item \mbox{$\Meta{int}\le0$:}~no specific color logging.
% \item \mbox{$\Meta{int}\ge1$:}~ignored color definitions due to |\providecolor| are logged.
% \item \mbox{$\Meta{int}\ge2$:}~multiple (i.e.~overwritten) color definitions are logged.
% \item \mbox{$\Meta{int}\ge3$:}~every command that defines a color will be logged.
% \item \mbox{$\Meta{int}\ge4$:}~every command that sets a color will be logged.
% \end{itemize}
% Like \TeX's |\tracing...| commands, this command may be used globally (in the document preamble) or locally/block-wise.
% The package sets |\tracingcolors=0| as default.
% Remark: since registers are limited and valuable, no counter is wasted for this issue.
%
% Note that whenever a color is used that has been defined via \LC's |\definecolor| command rather than \XC's new |\definecolor| and friends, a warning message `Incompatible color definition' will be issued.\footnote{This should not happen since usually there is no reason to load \LC{} in parallel to \XC{}.}
%
%
%
% \subsection{Color conversion}
%
% \DescribeMacro\convertcolorspec
%   \marg{model}\marg{spec}\marg{target model}\marg{cmd}\\
% Converts a color, given by the \Meta{spec} in model \Meta{model}, into \Meta{target model} and stores the new color specification in |\cmd|.
% \Meta{target model} must be of type \Meta{num model}, whereas \Meta{model} may also be `named', in which case \Meta{spec} is simply the name of the color.
%
% Example: |\convertcolorspec{cmyk}{0.81,1,0,0.07}{HTML}\tmp| acts like |\def| |\tmp{1F00ED}|.
%
%
%
% \subsection{Problems and solutions}
%
% \subsubsection{Name clashs between \Option{dvipsnames} and \Option{svgnames}}\label{sec.clash}
%
% Due to the fixed option processing order (which does not depend on the order how the options were specified in the |\usepackage| command), the \Option{svgnames} colors will always overrule \Option{dvipsnames} colors with identical names.
% This can lead to undesired results if both options are used together.
% For instance, \Color{Fuchsia} yields \testclr[cmyk]{0.47,0.91,0,0.08} under the regime of \Option{dvipsnames} and \testclr[rgb]{1,0,1} with respect to \Option{svgnames}.
% However, there is a simple trick --- based on \emph{deferred color definition} --- that allows us to use colors from both sets in the desired way:
% \begin{verbatim}
% \usepackage[dvipsnames*,svgnames]{xcolor}
% \definecolors{Fuchsia}
% \end{verbatim}
% Now all colors from the \Index{SVG} set are available (except \Color{Fuchsia}) plus \Color{Fuchsia} from the other set.
%
% \subsubsection{Page breaks and pdf\TeX}\label{sec.fixpdftex}
%
% Since pdf\TeX{} does not maintain a \emph{\Index{color stack}} --- in contrast to \Program{dvips} --- a typical problem is the behaviour of colors in the case of page breaks, as illustrated by the following example:
% \begin{verbatim}
% \documentclass{minimal}
% \usepackage{xcolor}
% \begin{document}
% black\color{red}red1\newpage red2\color{black}black
% \end{document}
% \end{verbatim}
% This works as expected with |dvips|, i.e., `red1' and `red2' being \Color{red}, however, with |pdftex|, `red2' is displayed in \Color{black}.
% The problem may be solved by using the \Option{fixpdftex} option which simply loads Heiko Oberdiek's \Package{pdfcolmk} package \cite{pdfcolmk}.
% However, its author also lists some limitations:
% \begin{itemize}
% \item Mark limitations: page breaks in math.
% \item LaTeX's output routine is redefinded.
% \begin{itemize}
% \item Changes in the output routine of newer versions of LaTeX are not detected.
% \item Packages that change the output routine are not supported.
% \end{itemize}
% \item It does not support several independent text streams like footnotes.
% \end{itemize}
%
% \subsubsection{Change color of included \File{.eps} file}\label{sec.fixinclude}
%
% In general, \XC{} cannot change colors of an image that is being included via the |\includegraphics| command from the \Package{graphics} or \Package{graphicx} package.
% There is, however, a limited opportunity to influence the current color of included \Index{PostScript} files.
% Consider the following file |foo.eps| which draws a framed gray box:
% \begin{verbatim}
% %!PS-Adobe-3.0 EPSF-3.0
% %%BoundingBox: 0 0 60 12
% 0 0 60 12 rectfill
% 0.75 setgray
% 2 2 56 8 rectfill
% \end{verbatim}
% Now run the following code through \LaTeX{} and \Program{dvips}:
% \begin{verbatim}
% \documentclass{minimal}
% \usepackage[fixinclude]{xcolor}
% \usepackage{graphics}
% \begin{document}
% \includegraphics{foo} \textcolor{red}{\includegraphics{foo}}
% \end{document}
% \end{verbatim}
% The resulting \File{.ps} file will display two gray boxes: the first with a black frame, the second with a red frame.
% If we had omitted the \Option{fixinclude} option, the second box would also display a black frame.
% This is because \Program{dvips} usually resets the current color to black immediately before including an \File{.eps} file.
%
%
%
%
% \clearpage
% \begin{adjustwidth}{-2.5cm}{}
% \section{Examples}
%
%
% \begin{figure}[htbp]\caption{Color spectrum}\label{fig.spectrum}
% \small
% \newcount\WL \unitlength.75pt
% \begin{picture}(460,60)(355,-10)
% \sffamily \tiny \linethickness{1.25\unitlength} \WL=360
% \multiput(360,0)(1,0){456}%
%  {{\color[wave]{\the\WL}\line(0,1){50}}\global\advance\WL1}
% \linethickness{0.25\unitlength}\WL=360
% \multiput(360,0)(20,0){23}%
%  {\picture(0,0)
%   \line(0,-1){5} \multiput(5,0)(5,0){3}{\line(0,-1){2.5}}
%   \put(0,-10){\makebox(0,0){\the\WL}}\global\advance\WL20
%   \endpicture}
% \end{picture}
% \vspace*{3ex}
% \begin{verbatim}
% \newcount\WL \unitlength.75pt
% \begin{picture}(460,60)(355,-10)
% \sffamily \tiny \linethickness{1.25\unitlength} \WL=360
% \multiput(360,0)(1,0){456}%
%  {{\color[wave]{\the\WL}\line(0,1){50}}\global\advance\WL1}
% \linethickness{0.25\unitlength}\WL=360
% \multiput(360,0)(20,0){23}%
%  {\picture(0,0)
%   \line(0,-1){5} \multiput(5,0)(5,0){3}{\line(0,-1){2.5}}
%   \put(0,-10){\makebox(0,0){\the\WL}}\global\advance\WL20
%   \endpicture}
% \end{picture}
% \end{verbatim}
% \end{figure}
%
%
% \begin{figure}[htbp]\caption{Color testing}\label{fig.testcolors}
% \small
% \begin{adjustwidth}{-2.5cm}{}
% \raggedleft
% \sffamily
% \begin{testcolors}[rgb,cmyk,hsb,HTML,gray]
% \testcolor{olive}
% \testcolor{red!50!green}
% \testcolor{-cyan!50!magenta}
% \testcolor[cmyk]{0,0,1,0.5}
% \testcolor[cmyk]{0,0,.5,.5}
% \testcolor[rgb:cmyk]{0,0,.5,.5}
% \end{testcolors}
% \end{adjustwidth}
% \vspace*{3ex}
% \begin{adjustwidth}{2.5cm}{}
% \begin{verbatim}
% \sffamily
% \begin{testcolors}[rgb,cmyk,hsb,HTML,gray]
% \testcolor{olive}
% \testcolor{red!50!green}
% \testcolor{-cyan!50!magenta}
% \testcolor[cmyk]{0,0,1,0.5}
% \testcolor[cmyk]{0,0,.5,.5}
% \testcolor[rgb:cmyk]{0,0,.5,.5}
% \end{testcolors}
% \end{verbatim}
% \end{adjustwidth}
% \end{figure}
%
%
% \def\ukColor{MyGreen}
% \definecolor{\ukColor}{cmyk}{0.92,0,0.87,0.09}
% \colorlet{\ukColor-rgb}[rgb]{\ukColor}
% \colorlet{\ukColor-cmy}[cmy]{\ukColor}
% \colorlet{\ukColor-hsb}[hsb]{\ukColor}
% \colorlet{\ukColor-gray}[gray]{\ukColor}
%
% \begin{figure}[htbp]\caption{Progressing from one to another color}\label{fig.progress}
% \small
% \begin{adjustwidth}{-2.5cm}{}
% \makeatletter
% \def\ColorLoop#1#2{\@tfor\@@tmp:={}{-rgb}{-cmy}{-hsb}{-gray}\do
%   {\ifcase#1
%    \expandafter\Colorloop\expandafter{\expandafter\ukColor\@@tmp}{#2}\or
%    \expandafter\Colorshow\expandafter{\expandafter\ukColor\@@tmp}\fi}\\[-2ex]\ignorespaces}
% \def\Colorloop#1#2{\@ifxempty{#1}{}{\texttt{#1!}}&
%   \count@105 \@whilenum\count@>\z@\do
%    {\advance\count@-5
%     \@ifxempty{#1}{\hb@xt@\XCdim{\hss\textsf{\the\count@}\hss}}{\testclr{#1!\the\count@!#2}}\hskip-\fboxrule}\hskip\fboxrule&
%   \@ifxempty{#1}{}{\texttt{!#2}}\\}
% \def\Colorshow#1{\texttt{#1}&
%   \multicolumn2{l@{}}{\expandafter\let\expandafter\@@tmp\csname\string\color@#1\endcsname
%   \edef\@@tmp{\expandafter\@gobbletwo\@@tmp}\Meaning{@@tmp}}\\}
% \makeatother
% \sbox0{\testclr{red}}\XCdim\wd0
% \begin{tabular}{@{}lll@{}}
% \Colorloop{}{}\\[-2ex]
% \ColorLoop0{white}
% \ColorLoop0{gray}
% \ColorLoop0{black}
% \ColorLoop0{red}
% \ColorLoop0{blue}
% \ColorLoop0{yellow}
% \\\noalign{\vspace*{-2.5ex}}\hline\noalign{\vspace*{1.5ex}}
% \itshape Color&\itshape Definition/representation (\textup{\Option{\csname XC@@drv\endcsname}} driver)\\
% \ColorLoop1{}
% \end{tabular}
% \end{adjustwidth}
% \end{figure}
%
%
% \begin{figure}[htbp]\caption{Target color model}\label{fig.tgt}
% \small
% \begin{adjustwidth}{-2.5cm}{}
% \raggedleft
% \extrarowheight2pt
% \makeatletter
% \def\X#1%
%  {\def\tmp{{#1}}\dots\Meaning{tmp}&
%   \selectcolormodel{#1}\testclr{red} \testclr{green} \testclr{blue} \testclr{cyan} \testclr{magenta} \testclr{yellow} \testclr{brown} \testclr{lime} \testclr{olive} \testclr{orange} \testclr{pink} \testclr{purple} \testclr{teal} \testclr{violet} \testclr{black} \testclr{darkgray} \testclr{gray} \testclr{lightgray} \testclr{white}\\}
% \makeatother
% \begin{tabular}{@{}>{\ttfamily}l@{ }l@{}}
% \string\selectcolormodel&\\
% \X{natural}
% \X{rgb}
% \X{cmy}
% \X{cmyk}
% \X{hsb}
% \X{gray}
% \end{tabular}
% \end{adjustwidth}
% \end{figure}
%
%
% \begin{figure}[htbp]\caption{Standard color expressions}\label{fig.expr}
% \centering\small
% \def\test#1{\testclr{#1}& \texttt{#1}}
% \def\X#1{\test{#1}& \test{-#1}}
% \begin{tabular}{@{}l@{ \ }ll@{ \ }l@{}}
% \X{red}\\
% \X{red!75}\\
% \X{red!75!green}\\
% \X{red!75!green!50}\\
% \X{red!75!green!50!blue}\\
% \X{red!75!green!50!blue!25}\\
% \X{red!75!green!50!blue!25!gray}\\
% \end{tabular}
% \end{figure}
%
%
% \begin{figure}[htbp]\caption{Standard color expressions}\label{fig.ex}
% \begin{minipage}{\textwidth}\small
% \begin{verbatim}
% \fboxrule6pt
% \fcolorbox
%  {red!70!green}% outer frame
%  {yellow!30!blue}% outer background
%  {\fcolorbox
%    {-yellow!30!blue}% inner frame
%    {-red!70!green}% inner background
%    {Test\textcolor{red!72.75}{Test}\color{-green}Test}}
% \end{verbatim}
% \end{minipage}\relax
% \llap{\fboxrule6pt \fcolorbox
%   {red!70!green}{yellow!30!blue}{\fcolorbox
%     {-yellow!30!blue}{-red!70!green}{Test\textcolor{red!72.75}{Test}\color{-green}Test}}}
% \end{figure}
%
%
% \begin{figure}[htbp]\caption{Current color}\label{fig.cc}
% \begin{minipage}{\textwidth}\small
% \begin{verbatim}
% \def\test{current, \textcolor{.!50}{50\%},
%           \textcolor{-.}{complement},
%           \textcolor{yellow!50!.}{mix}}
% \textcolor{blue}{\test}\\
%  and \textcolor{red}{\test}\\
% \def\Test{\color{.!80}Test}
% \textcolor{blue}{\Test\Test\Test\Test\Test}\\
% and \textcolor{red}{\Test\Test\Test\Test\Test}
% \end{verbatim}
% \end{minipage}\relax
% \llap{\begin{minipage}{.5\textwidth}\small\raggedleft
% \def\test{current, \textcolor{.!50}{50\%},
%           \textcolor{-.}{complement},
%           \textcolor{yellow!50!.}{mix}}
% \textcolor{blue}{\test}\\
%  and \textcolor{red}{\test}\\
% \def\Test{\color{.!80}Test}
% \textcolor{blue}{\Test\Test\Test\Test\Test}\\
% and \textcolor{red}{\Test\Test\Test\Test\Test}
% \end{minipage}}
% \end{figure}
%
%
% \begin{figure}[htbp]\caption{Color series}\label{fig.csx}
% \centering
% \def\tabulartest#1{\definecolorseries{test}#1\resetcolorseries[12]{test}%
%  \rowcolors[\hline]{1}{test!!+}{test!!+}%
%  \begin{tabular}{c}
%  \number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\
%  \number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\
%  \number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\
%  \number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\
%  \end{tabular}}
%
% \begin{tabular}{@{}*{9}{c}@{}}
% $S_1$ & $S_2$ & $G_1$ & $G_2$ & $L_1$ & $L_2$ & $L_3$ & $L_4$ & $L_5$ \\[3pt]
% \tabulartest{{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}}&
% \tabulartest{{hsb}{step}[hsb]{.575,1,1}{.11,-.05,0}}&
% \tabulartest{{rgb}{grad}[rgb]{.95,.85,.55}{3,11,17}}&
% \tabulartest{{hsb}{grad}[hsb]{.575,1,1}{.987,-.234,0}}&
% \tabulartest{{rgb}{last}[rgb]{.95,.85,.55}[rgb]{.05,.15,.55}}&
% \tabulartest{{hsb}{last}[hsb]{.575,1,1}[hsb]{-.425,.15,1}}&
% \tabulartest{{rgb}{last}{yellow!50}{blue}}&
% \tabulartest{{hsb}{last}{yellow!50}{blue}}&
% \tabulartest{{cmy}{last}{yellow!50}{blue}}\\
% \end{tabular}
%
% \bigskip
%
% \footnotesize
% \rowcolors{3}{tablerowcolor}{}
% \begin{tabular}{>{$}l<{$}l}
% \hline
% \multicolumn2{>{\columncolor{tableheadcolor}}c}{\em Individual definitions}\\
% S_1& |\definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}|\\
% S_2& |\definecolorseries{test}{hsb}{step}[hsb]{.575,1,1}{.11,-.05,0}|\\
% G_1& |\definecolorseries{test}{rgb}{grad}[rgb]{.95,.85,.55}{3,11,17}|\\
% G_2& |\definecolorseries{test}{hsb}{grad}[hsb]{.575,1,1}{.987,-.234,0}|\\
% L_1& |\definecolorseries{test}{rgb}{last}[rgb]{.95,.85,.55}[rgb]{.05,.15,.55}|\\
% L_2& |\definecolorseries{test}{hsb}{last}[hsb]{.575,1,1}[hsb]{-.425,.15,1}|\\
% L_3& |\definecolorseries{test}{rgb}{last}{yellow!50}{blue}|\\
% L_4& |\definecolorseries{test}{hsb}{last}{yellow!50}{blue}|\\
% L_5& |\definecolorseries{test}{cmy}{last}{yellow!50}{blue}|\\
% \hline
% \multicolumn2{>{\columncolor{tableheadcolor}}c}{\em Common definitions}\\
% \hiderowcolors
% &|\resetcolorseries[12]{test}|\\
% &|\rowcolors[\hline]{1}{test!!+}{test!!+}|\\
% &|\begin{tabular}{c}|\\
% &|\number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\|\\
% &|\number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\|\\
% &|\number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\|\\
% &|\number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\|\\
% &|\end{tabular}|\\
% \hline
% \end{tabular}
% \end{figure}
%
%
% \begin{figure}[htbp]\caption{Color masking}\label{fig.mask}
% \begin{adjustwidth}{-2.5cm}{}
% \small\raggedleft
% \extrarowheight2pt
% \makeatletter
% \def\X#1#2{\edef\tmp{\@ifxempty{#1}{}{[#1]}{#2}}\dots\Meaning{tmp}&
%   \maskcolors[#1]{#2}\testclr{red} \testclr{green} \testclr{blue} \testclr{cyan} \testclr{magenta} \testclr{yellow} \testclr{brown} \testclr{lime} \testclr{olive} \testclr{orange} \testclr{pink} \testclr{purple} \testclr{teal} \testclr{violet} \testclr{black} \testclr{darkgray} \testclr{gray} \testclr{lightgray} \testclr{white}\\}\relax
% \makeatother
% \begin{tabular}{@{}>{\ttfamily}l@{ }l@{}}
% \string\maskcolors&\\
% \hline
% \X{}{}
% \hline
% \X{cmyk}{cyan}
% \X{cmyk}{magenta}
% \X{cmyk}{yellow}
% \X{cmyk}{black}
% \hline
% \X{cmyk}{red}
% \X{cmyk}{green}
% \X{cmyk}{blue}
% \hline
% \X{rgb}{red}
% \X{rgb}{green}
% \X{rgb}{blue}
% \hline
% \X{hsb}{red}
% \X{hsb}{green}
% \X{hsb}{blue}
% \hline
% \X{rgb}{gray}
% \X{cmy}{gray}
% \end{tabular}
% \end{adjustwidth}
% \end{figure}
%
%
% \begin{figure}[htbp]\caption{Alternating row colors in tables: \cmd\rowcolors{} vs. \cmd\rowcolors\texttt*}\label{fig.row}
% \centering
% \begin{minipage}{\textwidth}
% \begin{verbatim}
% \rowcolors[\hline]{3}{green!25}{yellow!50} \arrayrulecolor{red!75!gray}
% \begin{tabular}{ll}
% test & row \number\rownum\\
% test & row \number\rownum\\
% test & row \number\rownum\\
% test & row \number\rownum\\
% \arrayrulecolor{black}
% test & row \number\rownum\\
% test & row \number\rownum\\
% \rowcolor{blue!25}
% test & row \number\rownum\\
% test & row \number\rownum\\
% \hiderowcolors
% test & row \number\rownum\\
% test & row \number\rownum\\
% \showrowcolors
% test & row \number\rownum\\
% test & row \number\rownum\\
% \multicolumn{1}%
%  {>{\columncolor{red!12}}l}{test} & row \number\rownum\\
% \end{tabular}
% \end{verbatim}
% \end{minipage}
% \hskip-.5\textwidth
% \rowcolors[\hline]{3}{green!25}{yellow!50} \arrayrulecolor{red!75!gray}
% \begin{tabular}{ll}
% test & row \number\rownum\\
% test & row \number\rownum\\
% test & row \number\rownum\\
% test & row \number\rownum\\
% \arrayrulecolor{black}
% test & row \number\rownum\\
% test & row \number\rownum\\
% \rowcolor{blue!25}
% test & row \number\rownum\\
% test & row \number\rownum\\
% \hiderowcolors
% test & row \number\rownum\\
% test & row \number\rownum\\
% \showrowcolors
% test & row \number\rownum\\
% test & row \number\rownum\\
% \multicolumn{1}%
%  {>{\columncolor{red!12}}l}{test} & row \number\rownum\\
% \end{tabular}
% \qquad
% \rowcolors*[\hline]{3}{green!25}{yellow!50}\arrayrulecolor{red!75!gray}
% \begin{tabular}{ll}
% test & row \number\rownum\\
% test & row \number\rownum\\
% test & row \number\rownum\\
% test & row \number\rownum\\
% \arrayrulecolor{black}
% test & row \number\rownum\\
% test & row \number\rownum\\
% \rowcolor{blue!25}
% test & row \number\rownum\\
% test & row \number\rownum\\
% \hiderowcolors
% test & row \number\rownum\\
% test & row \number\rownum\\
% \showrowcolors
% test & row \number\rownum\\
% test & row \number\rownum\\
% \multicolumn{1}%
%  {>{\columncolor{red!12}}l}{test} & row \number\rownum\\
% \end{tabular}
% \arrayrulecolor{black}
% \end{figure}
%
%
% \begin{figure}[htbp]\caption{\Model{Hsb} and \Model{tHsb}: \emph{hue\Circ} in $15^\circ$ steps}\label{fig.tHsb}
% \begin{adjustwidth}{-2.5cm}{}
% \footnotesize\sffamily\raggedleft
% \extrarowheight.5pt
% \begin{testcolors}[rgb,cmyk,hsb,Hsb,tHsb]
% \testcolor[Hsb]{0,1,1}
% \testcolor[Hsb]{15,1,1}
% \testcolor[Hsb]{30,1,1}
% \testcolor[Hsb]{45,1,1}
% \testcolor[Hsb]{60,1,1}
% \testcolor[Hsb]{75,1,1}
% \testcolor[Hsb]{90,1,1}
% \testcolor[Hsb]{105,1,1}
% \testcolor[Hsb]{120,1,1}
% \testcolor[Hsb]{135,1,1}
% \testcolor[Hsb]{150,1,1}
% \testcolor[Hsb]{165,1,1}
% \testcolor[Hsb]{180,1,1}
% \testcolor[Hsb]{195,1,1}
% \testcolor[Hsb]{210,1,1}
% \testcolor[Hsb]{225,1,1}
% \testcolor[Hsb]{240,1,1}
% \testcolor[Hsb]{255,1,1}
% \testcolor[Hsb]{270,1,1}
% \testcolor[Hsb]{285,1,1}
% \testcolor[Hsb]{300,1,1}
% \testcolor[Hsb]{315,1,1}
% \testcolor[Hsb]{330,1,1}
% \testcolor[Hsb]{345,1,1}
% \testcolor[Hsb]{360,1,1}
% \noalign{\medskip}
% \testcolor[tHsb]{0,1,1}
% \testcolor[tHsb]{15,1,1}
% \testcolor[tHsb]{30,1,1}
% \testcolor[tHsb]{45,1,1}
% \testcolor[tHsb]{60,1,1}
% \testcolor[tHsb]{75,1,1}
% \testcolor[tHsb]{90,1,1}
% \testcolor[tHsb]{105,1,1}
% \testcolor[tHsb]{120,1,1}
% \testcolor[tHsb]{135,1,1}
% \testcolor[tHsb]{150,1,1}
% \testcolor[tHsb]{165,1,1}
% \testcolor[tHsb]{180,1,1}
% \testcolor[tHsb]{195,1,1}
% \testcolor[tHsb]{210,1,1}
% \testcolor[tHsb]{225,1,1}
% \testcolor[tHsb]{240,1,1}
% \testcolor[tHsb]{255,1,1}
% \testcolor[tHsb]{270,1,1}
% \testcolor[tHsb]{285,1,1}
% \testcolor[tHsb]{300,1,1}
% \testcolor[tHsb]{315,1,1}
% \testcolor[tHsb]{330,1,1}
% \testcolor[tHsb]{345,1,1}
% \testcolor[tHsb]{360,1,1}
% \end{testcolors}
% \end{adjustwidth}
% \end{figure}
%
%
% \begin{figure}[htbp]\caption{Color harmony}\label{fig.harmony}
% \begin{adjustwidth}{-2.5cm}{}
% \small\sffamily\raggedleft
% \extrarowheight1.5pt
% \begin{testcolors}[rgb,cmyk,Hsb,tHsb]
% \noalign{\smallskip}
% \rlap{\em complementary colors (two-color harmony):}\\
% \testcolor{yellow>wheel,1,2}
% \testcolor{yellow}
% \testcolor{yellow>twheel,1,2}
% \noalign{\medskip}
% \rlap{\em color triad (three-color harmony):}\\
% \testcolor{yellow>wheel,2,3}
% \testcolor{yellow>wheel,1,3}
% \testcolor{yellow}
% \testcolor{yellow>twheel,1,3}
% \testcolor{yellow>twheel,2,3}
% \noalign{\medskip}
% \rlap{\em color tetrad (four-color harmony):}\\
% \testcolor{yellow>wheel,3,4}
% \testcolor{yellow>wheel,2,4}
% \testcolor{yellow>wheel,1,4}
% \testcolor{yellow}
% \testcolor{yellow>twheel,1,4}
% \testcolor{yellow>twheel,2,4}
% \testcolor{yellow>twheel,3,4}
% \noalign{\medskip}
% \rlap{\em split complementary colors:}\\
% \testcolor{yellow>wheel,7,12}
% \testcolor{yellow>wheel,5,12}
% \testcolor{yellow}
% \testcolor{yellow>twheel,5,12}
% \testcolor{yellow>twheel,7,12}
% \noalign{\medskip}
% \rlap{\em analogous (adjacent) colors:}\\
% \testcolor{yellow>wheel,11,12}
% \testcolor{yellow>wheel,10,12}
% \testcolor{yellow>wheel,2,12}
% \testcolor{yellow>wheel,1,12}
% \testcolor{yellow}
% \testcolor{yellow>twheel,1,12}
% \testcolor{yellow>twheel,2,12}
% \testcolor{yellow>twheel,10,12}
% \testcolor{yellow>twheel,11,12}
% \end{testcolors}
% \end{adjustwidth}
% \end{figure}
%
% \end{adjustwidth}
%
%
% \clearpage
%
% \begin{adjustwidth}{-2.5cm}{}
% \raggedcolumns\columnsep2.5em
%
% \section{Colors by Name}\label{sec.names}
%
% \begin{multicols}{5}[\subsection{Base colors (always available)}\label{sec.basenam}]
% \footnotesize\def\0#1{\Testclr{#1}{#1}}
% \0{black}
% \0{blue}
% \0{brown}
% \0{cyan}
% \0{darkgray}
% \0{gray}
% \0{green}
% \0{lightgray}
% \0{lime}
% \0{magenta}
% \0{olive}
% \0{orange}
% \0{pink}
% \0{purple}
% \0{red}
% \0{teal}
% \0{violet}
% \0{white}
% \0{yellow}
% \end{multicols}
%
%
% \begin{multicols}{5}[\subsection{Colors via \Option{dvipsnames} option}\label{sec.dvipsnam}]
% \footnotesize\def\0#1{\Testclr{#1}{#1}}
% \0{Apricot}
% \0{Aquamarine}
% \0{Bittersweet}
% \0{Black}
% \0{Blue}
% \0{BlueGreen}
% \0{BlueViolet}
% \0{BrickRed}
% \0{Brown}
% \0{BurntOrange}
% \0{CadetBlue}
% \0{CarnationPink}
% \0{Cerulean}
% \0{CornflowerBlue}
% \0{Cyan}
% \0{Dandelion}
% \0{DarkOrchid}
% \0{Emerald}
% \0{ForestGreen}
% \0{Fuchsia}
% \0{Goldenrod}
% \0{Gray}
% \0{Green}
% \0{GreenYellow}
% \0{JungleGreen}
% \0{Lavender}
% \0{LimeGreen}
% \0{Magenta}
% \0{Mahogany}
% \0{Maroon}
% \0{Melon}
% \0{MidnightBlue}
% \0{Mulberry}
% \0{NavyBlue}
% \0{OliveGreen}
% \0{Orange}
% \0{OrangeRed}
% \0{Orchid}
% \0{Peach}
% \0{Periwinkle}
% \0{PineGreen}
% \0{Plum}
% \0{ProcessBlue}
% \0{Purple}
% \0{RawSienna}
% \0{Red}
% \0{RedOrange}
% \0{RedViolet}
% \0{Rhodamine}
% \0{RoyalBlue}
% \0{RoyalPurple}
% \0{RubineRed}
% \0{Salmon}
% \0{SeaGreen}
% \0{Sepia}
% \0{SkyBlue}
% \0{SpringGreen}
% \0{Tan}
% \0{TealBlue}
% \0{Thistle}
% \0{Turquoise}
% \0{Violet}
% \0{VioletRed}
% \0{White}
% \0{WildStrawberry}
% \0{Yellow}
% \0{YellowGreen}
% \0{YellowOrange}
% \end{multicols}
%
%
% \makeatletter
% \def\ColorList#1#2#3#4{\begin{multicols}{#1}[\subsection{Colors via \Option{#2names} option}\label{sec.#2nam}]
%   \footnotesize
%   \def\preparecolorset
%    {\def\XC@@cmd[####1]####2####3####4{\definecolor[####1]{@test}{####3}{####4}#4{@test}{####2}}\@testopt{\XC@definecolorset}{}}
%   \edef\restore{\catcode`\noexpand\%\the\catcode`\%\relax}
%   \catcode`\%14\relax\input{#3nam.def}\restore
%   \end{multicols}}
% \makeatother
%
% \ColorList4{svg}{svg}\Testclr
% \medskip
% \begin{adjustwidth}{1cm}{1cm}
% \footnotesize\raggedright Duplicate colors:
% \Color[-]{Aqua} = \Color[-]{Cyan},
% \Color[-]{Fuchsia} = \Color[-]{Magenta};
% \Color[-]{Navy} = \Color[-]{NavyBlue};
% \Color[-]{Gray} = \Color[-]{Grey},
% \Color[-]{DarkGray} = \Color[-]{DarkGrey},
% \Color[-]{LightGray} = \Color[-]{LightGrey},
% \Color[-]{SlateGray} = \Color[-]{SlateGrey},
% \Color[-]{DarkSlateGray} = \Color[-]{DarkSlateGrey},
% \Color[-]{LightSlateGray} = \Color[-]{LightSlateGrey},
% \Color[-]{DimGray} = \Color[-]{DimGrey}.
% \par\smallskip
% \Index{HTML4} color keyword subset:
% \Color[-]{Aqua}, \Color[-]{Black}, \Color[-]{Blue}, \Color[-]{Fuchsia},
% \Color[-]{Gray}, \Color[-]{Green}, \Color[-]{Lime}, \Color[-]{Maroon},
% \Color[-]{Navy}, \Color[-]{Olive}, \Color[-]{Purple}, \Color[-]{Red},
% \Color[-]{Silver}, \Color[-]{Teal}, \Color[-]{White}, \Color[-]{Yellow}.
% \par\smallskip
% Colors taken from \Index{Unix}/\Index{X11}:
% \Color[-]{LightGoldenrod},
% \Color[-]{LightSlateBlue},
% \Color[-]{NavyBlue},
% \Color[-]{VioletRed}.
% \end{adjustwidth}
%
% \ColorList4{x11}{x11}\Testclr
% \medskip
% \begin{adjustwidth}{1cm}{1cm}
% \footnotesize\raggedright Duplicate colors:
% \Color[-]{Gray0} = \Color[-]{Grey0},
% \Color[-]{Green0} = \Color[-]{Green1}.
% \end{adjustwidth}
%
% \end{adjustwidth}
%
%
%
%
% \clearpage
% \section{Technical Supplement}
%
% \subsection{Color models supported by drivers}
%
% Since some of the drivers only pretend to support the \Model{hsb} model, we included some code to bypass this behaviour.
% The models actually added by \XC{} are shown in the log file.
% Table \vref{tab.drv} lists mainly the drivers that are part of current MiK\TeX{} \cite{mik} distributions and their color model support.
% Probably, other distributions behave similarly.
%
% \begin{table}[htbp]\caption{Drivers and color models}\label{tab.drv}
% \centering\small
% \extrarowheight1pt
% \tabcolsep3pt
% \rowcolors{3}{tablerowcolor}{}
% \begin{tabular}{ll*{9}{c}}
% \rowcolor{tableheadcolor}
% \hline
% \em Driver&\em Version&\Model{rgb}&\Model{cmy}&\Model{cmyk}&\Model{hsb}&\Model{gray}&\Model{RGB}&\Model{HTML}&\Model{HSB}&\Model{Gray}\\
% \Option{dvipdf}&1999/02/16 v3.0i&d&n&d&n&d&i&n&n&n\\
% \Option{dvips}&1999/02/16 v3.0i&d&n&d&d&d&i&n&n&n\\
% \Option{dvipsone}&1999/02/16 v3.0i&d&n&d&d&d&i&n&n&n\\
% \Option{pctex32}&1999/02/16 v3.0i&d&n&d&d&d&i&n&n&n\\
% \Option{pctexps}&1999/02/16 v3.0i&d&n&d&d&d&i&n&n&n\\
% \hline
% \Option{pdftex}&2006/03/02 v0.03p&d&n&d&n&d&i&n&n&n\\
% \hline
% \Option{dvipdfm}&1998/11/24 vx.x\,\footnotemark[1]&d&n&d&a&d&i&n&n&n\\
% \Option{dvipdfm}&1999/9/6 vx.x\,\footnotemark[2]&d&n&d&a&d&i&n&n&n\\
% \hline
% \Option{dvipdfmx}&?&d&n&d&f&d&i&n&n&n\\
% \hline
% \Option{textures}&1997/5/28 v0.3&d&n&d&a&i&n&n&n&n\\
% \hline
% \Option{vtex}&1999/01/14 v6.3&d&n&d&n&i&i&n&n&n\\
% \hline
% \Option{xetex}&2004/05/09 v0.7&i&n&i&i&i&i&d&n&n\\
% \hline
% \Option{tcidvi}&1999/02/16 v3.0i&i&n&i&n&i&d&n&n&n\\
% \Option{truetex}&1999/02/16 v3.0i&i&n&i&n&i&d&n&n&n\\
% \hline
% \Option{dviwin}&1999/02/16 v3.0i&n&n&n&n&n&n&n&n&n\\
% \Option{emtex}&1999/02/16 v3.0i&n&n&n&n&n&n&n&n&n\\
% \Option{pctexhp}&1999/02/16 v3.0i&n&n&n&n&n&n&n&n&n\\
% \Option{pctexwin}&1999/02/16 v3.0i&n&n&n&n&n&n&n&n&n\\
% \hline\hline
% \multicolumn{11}c{\Option{dviwindo} = \Option{dvipsone}; \Option{oztex} = \Option{dvips}; \Option{xdvi} = \Option{dvips} + \Option{monochrome}}\\
% \multicolumn{11}c{\footnotemark[1]\,part of \Package{graphics} package\quad \footnotemark[2]\,additionally distributed with MiK\TeX}\\
% \hline
% \multicolumn{11}c{Driver's color model support: d\,=\,direct, i\,=\,indirect, a\,=\,alleged, n\,=\,none, f\,=\,faulty}\\
% \hline
% \end{tabular}
% \end{table}
%
%
%
% \subsection{How \XC{} handles driver-specific color models}
%
% Although there is a variety of drivers that implement different approaches to color visualisation, they all have some features in common, as defined by the original \LCP.
% One of these features is that any color model `foo' requires a |\color@foo|\marg{cmd}\marg{spec} command in order to translate the `foo'-dependent color \Meta{spec} into some driver-specific code that is stored in \Meta{cmd}.
% Therefore, \XC{} in general detects driver-support for the `foo' model via the existence of |\color@foo|.
%
% By this mechanism, \XC{} can also change the behaviour of certain models without touching the driver file itself.
% A good example is the |\substitutecolormodel| command which is used during the package initialisation process to provide support for models that are not covered by the actual driver (like \Model{hsb} for \Option{pdftex}) or that have incorrect implementations (like \Model{hsb} for \Option{dvipdfm}).
%
%
% \subsection{Behind the scenes: internal color representation}
%
% Every definition of a color in order to access it by its name requires an internal representation of the color, i.e.~a macro that contains some bits of information required by the driver to display the color properly.
%
% \LC's |\definecolor{foo}{...}{...}| generates a command |\\color@foo|\footnote{The double backslash is intentional.} which contains the color definition in a driver-dependent way; therefore it is possible but non-trivial to access the color model and parameters afterwards (see the \Package{colorinfo} package \cite{colorinfo} for a solution).
%
% \LC's |\DefineNamedColor{named}{foo}{...}{...}| generates |\col@foo|\footnote{The single backslash is intentional.} which again contains some driver-dependent information.
% In this case, an additional |\\color@foo| will only be defined if the package option \Option{usecolors} is active.
%
% \XC's |\definecolor{foo}{...}{...}| generates\footnote{This was introduced in version 1.10; prior to that, a command \cs{\string\xcolor@foo} with a different syntax was generated.} a command |\\color@foo| as well, which combines the features of the former commands and contains both the driver-dependent and driver-independent information, thus making it possible to access the relevant parameters in a standardised way.
% Although it has now a different syntax, |\\color@foo| expands to the same expression as the original command.
% On the other hand, |\col@foo| commands are no longer needed and therefore not generated in the `named' case: \XC{} works with a single color data structure (as described).
%
% Table \vref{tab.internal} shows some examples for the two most prominent drivers.
% See also figure \vref{fig.progress} which displays the definitions with respect to the driver that was used to process this document.
%
%
% \begin{table}[htb]\caption{Driver-dependent internal color representation}\label{tab.internal}
% \centering\small
% \def\X{\hspace*{-.845\textwidth}\\}
% \extrarowheight1pt
% \tabcolsep8pt
% \begin{tabular}{l>{\color{blue}(}r<{)}l}
% \hline
% \multicolumn3{>{\columncolor{tableheadcolor}}l}{\Option{dvips} driver}\\
% \hline
% |\\color@Plum=macro:| & |\definecolor{Plum}{rgb}{.5,0,1}| & \LC\\
% |->rgb .5 0 1.|\X
% \hline
% |\\color@Plum=macro:| & |\definecolor{Plum}{rgb}{.5,0,1}|& \XC\\
% |->\xcolor@ {}{rgb 0.5 0 1}{rgb}{0.5,0,1}.|\X
% \hline
% |\col@Plum=macro:| & |\DefineNamedColor{Plum}{rgb}{.5,0,1}|& \LC\\
% |->\@nil .|\X
% |\\color@Plum=macro:| & with option \oOption{usenames}\\
% |-> Plum.|\X
% \hline
% |\\color@Plum=macro:| & |\definecolor[named]{Plum}{rgb}{.5,0,1}|& \XC\\
% |->\xcolor@ {named}{ Plum}{rgb}{0.5,0,1}.|\X
% \hline
% \multicolumn3{>{\columncolor{tableheadcolor}}l}{\Option{pdftex} driver}\\
% \hline
% |\\color@Plum=macro:| & |\definecolor{Plum}{rgb}{.5,0,1}|& \LC\\
% |->.5 0 1 rg .5 0 1 RG.|\X
% \hline
% |\\color@Plum=macro:| & |\definecolor{Plum}{rgb}{.5,0,1}|& \XC\\
% |->\xcolor@ {}{0.5 0 1 rg 0.5 0 1 RG}{rgb}{0.5,0,1}.|\X
% \hline
% |\col@Plum=macro:| & |\DefineNamedColor{Plum}{rgb}{.5,0,1}|& \LC\\
% |->.5 0 1 rg .5 0 1 RG.|\X
% |\\color@Plum=macro:| & with option \oOption{usenames}\\
% |->.5 0 1 rg .5 0 1 RG.|\X
% \hline
% |\\color@Plum=macro:| & |\definecolor[named]{Plum}{rgb}{.5,0,1}|& \XC\\
% |->\xcolor@ {}{0.5 0 1 rg 0.5 0 1 RG}{rgb}{0.5,0,1}.|\X
% \hline
% \end{tabular}
% \end{table}
%
%
%
% \subsection{A remark on accuracy}
%
% Since the macros presented here require some computation, special efforts were made to ensure a maximum of accuracy for conversion and mixing formulas --- all within \TeX's limited numerical capabilities.\footnote{For example, applying the `transformation' \cs{dimen0=0.}\Meta{int}\texttt{pt} \cs{the\string\dimen0} to all 5-digit numbers \Meta{int} of the range 00000\dots 99999, exactly 34464 of these 100000 numbers don't survive unchanged. We are not talking about gobbled final zeros here \dots}
% We decided to develop and include a small set of commands to improve the quality of division and multiplication results, instead of loading one of the packages that provide multi-digit arithmetic and a lot more, like \Package{realcalc} or \Package{fp}.
% The marginal contribution of the latter packages seems not to justify their usage for our purposes.
% Thus, we stay within a sort of fixed-point arithmetic framework, providing at most 5~decimal digits via \TeX's dimension registers.
%
%
%
%
% \clearpage
% \section{The Formulas}
%
% \subsection{Color mixing}
%
% In general, we use linear interpolation for color mixing:
% \begin{align}
% \mix(C, C', p) = p \cdot C + (1-p) \cdot C'\label{eq.mix}
% \end{align}
% Note that there is a special situation in the \Model{hsb} case:
% if $\emph{saturation}=0$ then the color equals a gray color of level \emph{brightness}, independently of the \emph{hue} value.
% Therefore, to achieve smooth transitions of an arbitrary color to a specific gray (like white or black), we actually use the formulas
% \begin{align}
% \Op\tint{hsb}(C, p) &= p \cdot C + (1-p) \cdot \bigl(\emph{hue},0,1\bigr)\\
% \Op\shade{hsb}(C, p) &= p \cdot C + (1-p) \cdot \bigl(\emph{hue},0,0\bigr)\\
% \Op\tone{hsb}(C, p) &\textstyle= p \cdot C + (1-p) \cdot \bigl(\emph{hue},0,\frac12\bigr)
% \end{align}
% where $C=(\emph{hue},\emph{saturation},\emph{brightness})$.
%
% From equation (\ref{eq.mix}) and the way how color expressions are being interpreted, as described in section \vref{sec.term}, it is an easy proof by induction to verify that a color expression
% \begin{gather}
% C_0!P_1!C_1!P_2!\dots!P_n!C_n
% \end{gather}
% with $n\in\{0,1,2,\dots\}$, colors $C_0,C_1,\dots,C_n$, and percentages $P_1,\dots,P_n\in [0,100]$ will result in a parameter vector
% \begin{equation}
% \begin{split}
% C &= \sum_{\nu=0}^n \Biggl(\prod_{\mu=\nu+1}^n p_\mu \Biggr) (1-p_\nu)\cdot C_\nu\\
%   &= p_n\cdots p_1\cdot C_0\\
%   &\quad + p_n\cdots p_2(1-p_1)\cdot C_1\\
%   &\quad + p_n\cdots p_3(1-p_2)\cdot C_2\\
%   &\quad + \dots\\
%   &\quad + p_n(1-p_{n-1})\cdot C_{n-1}\\
%   &\quad + (1-p_n)\cdot C_n
% \end{split}
% \end{equation}
% where $p_0 := 0$ and $p_\nu := P_\nu/100$ for $\nu=1,\dots,n$.
% We note also a split formula:
% \begin{equation}
% \begin{split}
% C_0!P_1!C_1!\dots!P_{n+k}!C_{n+k}
%  &= p_{n+k}\cdots p_{n+1}\cdot C_0!P_1!C_1!\dots!P_n!C_n\\
%  &\quad - p_{n+k}\cdots p_{n+1}\cdot C_n\\
%  &\quad + C_n!P_{n+1}!C_{n+1}!\dots!P_{n+k}!C_{n+k}
% \end{split}
% \end{equation}
%
%
% \begin{table}[p]\caption{Color constants}\label{tab.const}
% \centering
% \extrarowheight2pt
% \rowcolors{3}{tablerowcolor}{}
% \begin{tabular}{*4{c}}
% \hline
% \rowcolor{tableheadcolor}
% \emph{model/constant} &
%       \ttfamily white  &  \ttfamily black & \ttfamily gray\\[2pt]
% \Model{rgb}&  $(1,1,1)$   & $(0,0,0)$   & $(\frac12,\frac12,\frac12)$ \\[2pt]
% \Model{cmy}&  $(0,0,0)$   & $(1,1,1)$   & $(\frac12,\frac12,\frac12)$ \\[2pt]
% \Model{cmyk}& $(0,0,0,0)$ & $(0,0,0,1)$ & $(0,0,0,\frac12)$ \\[2pt]
% \Model{hsb}&  $(h,0,1)$   & $(h,0,0)$   & $(h,0,\frac12)$ \\[2pt]
% \Model{Hsb}&  $(h^\circ,0,1)$ & $(h^\circ,0,0)$ & $(h^\circ,0,\frac12)$ \\[2pt]
% \Model{tHsb}& $(h^\circ,0,1)$ & $(h^\circ,0,0)$ & $(h^\circ,0,\frac12)$ \\[2pt]
% \Model{gray}& $1$ & $0$ & $\frac12$ \\[2pt]
% \Model{RGB}&  $(L,L,L)$ & $(0,0,0)$ & $(\lfloor\frac {L+1}2\rfloor,\lfloor\frac {L+1}2\rfloor,\lfloor\frac {L+1}2\rfloor)$ \\[2pt]
% \Model{HTML}& \texttt{FFFFFF}& \texttt{000000}& \texttt{808080}\\[2pt]
% \Model{HSB}&  $(H,0,M)$ & $(H,0,0)$ & $(H,0,\lfloor\frac {M+1}2\rfloor)$ \\[2pt]
% \Model{Gray}& $N$ & $0$ & $\lfloor\frac {N+1}2\rfloor$ \\[2pt]
% \hline
% \end{tabular}
% \end{table}
%
%
% \begin{table}[p]\caption{Color conversion pairs}\label{tab.cnv}
% \begin{adjustwidth}{-2.5cm}{}
% \small\raggedleft
% \def\Em#1{\Model{#1}}
% \def\sp{\hbox to3em{\hfil$\ast$\hfil}}
% \def\id{\textrm{id}}
% \extrarowheight1pt
% \tabcolsep3pt
% \rowcolors{3}{tablerowcolor}{}
% \begin{tabular}{c*{11}{>{\sffamily}c}}
% \rowcolor{tableheadcolor}
% \hline
% \emph{from/to}&
%            \Em{rgb}& \Em{cmy}& \Em{cmyk}& \Em{hsb}& \Em{Hsb} & \Em{tHsb} & \Em{gray}& \Em{RGB}& \Em{HTML}& \Em{HSB}& \Em{Gray}\\
% \Em{rgb}&  \id     & \sp     & (cmy)    & \sp     & (hsb)    & (hsb)     & \sp      & \sp     & \sp      & (hsb)   & (gray)\\
% \Em{cmy}&  \sp     & \id     & \sp      & (rgb)   & (rgb)    & (rgb)     & \sp      & (rgb)   & (rgb)    & (rgb)   & (gray)\\
% \Em{cmyk}& (cmy)   & \sp     & \id      & (cmy)   & (cmy)    & (cmy)     & \sp      & (cmy)   & (cmy)    & (cmy)   & (gray)\\
% \Em{hsb}&  \sp     & (rgb)   & (rgb)    & \id     & \sp      & (Hsb)     & (rgb)    & (rgb)   & (rgb)    & \sp     & (rgb)\\
% \Em{Hsb}&  (hsb)   & (hsb)   & (hsb)    & \sp     & \id      & \sp       & (hsb)    & (hsb)   & (hsb)    & (hsb)   & (hsb)\\
% \Em{tHsb}& (Hsb)   & (Hsb)   & (Hsb)    & (Hsb)   & \sp      & \id       & (Hsb)    & (Hsb)   & (Hsb)    & (Hsb)   & (Hsb)\\
% \Em{gray}& \sp     & \sp     & \sp      & \sp     & \sp      & \sp       & \id      & \sp     & \sp      & \sp     & \sp\\
% \Em{RGB}&  \sp     & (rgb)   & (rgb)    & (rgb)   & (rgb)    & (rgb)     & (rgb)    & \id     & (rgb)    & (rgb)   & (rgb)\\
% \Em{HTML}& \sp     & (rgb)   & (rgb)    & (rgb)   & (rgb)    & (rgb)     & (rgb)    & (rgb)   & \id      & (rgb)   & (rgb)\\
% \Em{HSB}&  (hsb)   & (hsb)   & (hsb)    & \sp     & (hsb)    & (hsb)     & (hsb)    & (hsb)   & (hsb)    & \id     & (hsb)\\
% \Em{Gray}& (gray)  & (gray)  & (gray)   & (gray)  & (gray)   & (gray)    & \sp      & (gray)  & (gray)   & (gray)  & \id\\
% \Em{wave}& (hsb)   & (hsb)   & (hsb)    & \sp     & (hsb)    & (hsb)     & (hsb)    & (hsb)   & (hsb)    & (hsb)   & (hsb)\\
% \hline\hline
% \multicolumn{12}{c}{\id{} = identity function; $\ast$ = specific conversion function;}\\
% \multicolumn{12}{c}{\textsf{(model)} = conversion via specified model}\\
% \hline
% \end{tabular}
% \end{adjustwidth}
% \end{table}
%
%
%
% \subsection{Conversion between integer and real models}
%
% We fix a positive integer $n$ and define the sets $\mathcal I_n:=\{0,1,\dots,n\}$ and $\mathcal R:= [0,1]$.
% The complement of $\nu\in\mathcal I_n$ is $n-\nu$, the complement of $x\in\mathcal R$ is $1-x$.
%
% \subsubsection{Real to integer conversion}\label{sec.real2int}
%
% The straightforward mapping for this case is
% \begin{gather}
% \textstyle\RtoI n : \mathcal R \to \mathcal I_n,\ x \mapsto \rd(n\cdot x,0) = \left\lfloor \frac12+n\cdot x\right\rfloor
% \end{gather}
% where $\rd(r,d)$ rounds the real number $r$ to $d\ge0$ decimal digits.
% This mapping nearly always preserves complements, as shown in the next lemma.
% \begin{lemma}[Preservation of complements]
% For $x\in\mathcal R$,
% \begin{gather}
% \textstyle\RtoI n(x) + \RtoI n(1-x) = n \iff x \notin \mathcal R_n^\circ := \left\{ \frac1n\bigl(\nu - \frac12\bigr) \bigm\vert \nu=1,2,\dots,n\right\}.
% \end{gather}
% \end{lemma}
% \begin{proof}
% Let $\nu:=\RtoI n(x)$, then from $-\frac12 \le \eta := n\cdot x - \nu < \frac12$ we conclude
% \begin{gather*}
% \textstyle \RtoI n(1-x) = \rd(n(1-x),0) = \rd(n-\nu-\eta,0) =
% \begin{cases}
%  n-\nu   & \text{if $\eta\neq-\frac12$}\\
%  n-\nu+1 & \text{if $\eta=-\frac12$}
% \end{cases}
% \end{gather*}
% Now, $\eta = -\frac12 \iff x = \frac1n\bigl(\nu-\frac12\bigr) \iff x\in\mathcal I_n'$.
% \end{proof}
% Remark: the set $\mathcal R_n^\circ$ is obviously identical to the set of points where $\RtoI n$ is not continuous.
%
%
% \subsubsection{Integer to real conversion}\label{sec.int2real}
%
% The straightforward way in this case is the function
% \begin{gather}
% \ItoR n^*: \mathcal I_n \to \mathcal R,\ \nu \mapsto \frac \nu n.
% \end{gather}
% This is, however, only one out of a variety of solutions: every function $\ItoR n:\mathcal I_n\to\mathcal R$ that obeys the condition
% \begin{gather}
% \nu\in\mathcal I_n \Rightarrow \Gamma_n\bigl(\ItoR n(\nu)\bigr) = \nu
% \end{gather}
% which is equivalent to
% \begin{gather}
% \nu\in\mathcal I_n \Rightarrow \nu + \frac12 > n\cdot\ItoR n(\nu) \ge \nu - \frac12\label{eq.round}
% \end{gather}
% does at least guarantee that all integers $\nu$ may be reconstructed from $\ItoR n(\nu)$ via multiplication by $n$ and rounding to the nearest integer.
% Preservation of complements means now
% \begin{gather}
% \nu\in\mathcal I_n \Rightarrow \ItoR n(\nu) + \ItoR n(n-\nu) = 1
% \end{gather}
% which is obviously the case for $\ItoR n = \ItoR n^*$.
% If we consider, more generally, a transformation
% \begin{gather}
% \ItoR n(\nu) = \frac{\nu + \alpha}{n + \beta}
% \end{gather}
% with $\beta\neq-n$, then the magic inequality (\ref{eq.round}) is equivalent to
% \begin{gather}
% \frac12 > \frac{\alpha n - \beta\nu}{n + \beta} \ge -\frac12
% \end{gather}
% which is obeyed by the function
% \begin{gather}
% \ItoR n':\mathcal I_n\to\mathcal R,\ \nu \mapsto
% \begin{cases}
% \frac\nu{n+1}& \text{if $\nu\le\frac{n+1}2$}\\[0.25ex]
% \frac{\nu+1}{n+1}& \text{if $\nu>\frac{n+1}2$}
% \end{cases}
% \end{gather}
% that has the nice feature $\ItoR n'\bigl(\frac{n+1}2\bigr) = \frac12$ for odd $n$.
% \begin{lemma}[Preservation of complements]
% For odd $n$ and each $\nu\in\mathcal I_n$,
% \begin{gather}
% \textstyle\ItoR n'(\nu) + \ItoR n'(n-\nu) = 1 \iff \nu \notin \mathcal I_n^\circ := \left\{ \frac{n-1}2, \frac{n+1}2 \right\}.
% \end{gather}
% \end{lemma}
% \begin{proof}
% The assertion is a consequence of the following arguments:
% \begin{itemize}
% \item $\nu<\frac{n-1}2 \iff n-\nu>\frac{n+1}2$ \ and \ $\frac{n-1}2 + \frac{n+1}2 = n$;
% \item $\nu<\frac{n-1}2 \,\Rightarrow\, \ItoR n'(\nu) + \ItoR n'(n-\nu) = \frac\nu{n+1} + \frac{n-\nu+1}{n+1} = 1$;
% \item $\nu=\frac{n-1}2 \,\Rightarrow\, \ItoR n'(\nu) + \ItoR n'(n-\nu) = \frac{n-1}{2(n+1)} + \frac12 = \frac n{n+1} \neq1$.\qedhere
% \end{itemize}
% \end{proof}
%
% For the time being, we choose \fbox{$\ItoR n := \ItoR n^*$} as default transformation function.
%
% \medskip
% Another variant --- which is probably too slow for large-scale on-the-fly calculations --- may be used for constructing sets of predefined colors.
% The basic idea is to minimize the number of decimal digits in the representation while keeping some invariance with respect to the original resolution:
% \begin{gather}
% \textstyle\ItoR n'':\mathcal I_n\to\mathcal R,\ \nu \mapsto \rd\bigl(\frac\nu n, d_n(\frac\nu n)\bigr)
% \end{gather}
% where
% \begin{gather}
% d_n:[0,1]\to\bbbN,\ x \mapsto \min\bigl\{ d\in\bbbN \bigm\vert \RtoI n\bigl(\rd(\ItoR n^*(\RtoI n(x)),d)\bigr) = \RtoI n(x)\bigr\}
% \end{gather}
% In the most common case $n=255$ it turns out that we end up with at most 3 decimal digits; preservation of complements is only violated for $\nu\in\{25,26,76,77,127,128,178,179,229,230\}$ where the corresponding set of decimal numbers is $\{0.098,0.1,0.298,0.3,0.498,0.5,0.698,0.7,0.898,0.9\}$.
%
%
%
% \subsection{Color conversion and complements}\label{sec.cnv}
%
% We collect here the specific conversion formulas between the supported color models.
% Table \vref{tab.cnv} gives an overwiew of how each conversion pair is handled.
% In general, \Index{PostScript} (as described in \cite{plrm}) is used as a basis for most of the calculations, since it supports the color models \Model{rgb}, \Model{cmyk}, \Model{hsb}, and \Model{gray} natively.
% Furthermore, \People{Alvy Ray}{Smith}'s paper \cite{smith} is cited in \cite{plrm} as reference for \Model{hsb}-related formulas.
%
% First, we define a constant which is being used throughout the conversion formulas:
% \begin{gather}
% E := (1,1,1)
% \end{gather}
%
%
% \subsubsection{The \Model{rgb} model}
%
% \paragraph{Conversion \Model{rgb} to \Model{cmy}}\label{sec.rgb2cmy}
% Source: \cite{plrm}, p. 475.
% \begin{gather}
% (\emph{cyan}, \emph{magenta}, \emph{yellow}) := E-(\emph{red}, \emph{green}, \emph{blue})
% \end{gather}
%
%
% \paragraph{Conversion \Model{rgb} to \Model{hsb} (1)}
% We set
% \begin{align}
% x & := \max\{\emph{red}, \emph{green}, \emph{blue}\}\\
% y & := \med\{\emph{red}, \emph{green}, \emph{blue}\}\\
% z & := \min\{\emph{red}, \emph{green}, \emph{blue}\}%\\
% \end{align}
% where `$\med$' denotes the median of the values.
% Then,
% \begin{align}
% \emph{brightness} & := x\\
% \intertext{Case $x=z$:}
% \emph{saturation} & := 0\\
% \emph{hue} & := 0\\
% \intertext{Case $x\neq z$:}
% \emph{saturation} & := \frac{x - z}x\\
% f & := \frac{x - y}{x - z}
% \end{align}
% \begin{gather}
% \emph{hue} := \frac 16\cdot
%  \begin{cases}
%  1-f & \text{if $x=\emph{red}\ge\emph{green}\ge\emph{blue}=z$}\\
%  1+f & \text{if $x=\emph{green}\ge\emph{red}\ge\emph{blue}=z$}\\
%  3-f & \text{if $x=\emph{green}\ge\emph{blue}\ge\emph{red}=z$}\\
%  3+f & \text{if $x=\emph{blue}\ge\emph{green}\ge\emph{red}=z$}\\
%  5-f & \text{if $x=\emph{blue}\ge\emph{red}\ge\emph{green}=z$}\\
%  5+f & \text{if $x=\emph{red}\ge\emph{blue}>\emph{green}=z$}
%  \end{cases}\label{eq.rgb2hsb1}
% \end{gather}
%
% \medskip
%
% This is based on \cite{smith}, \emph{RGB to HSV Algorithm (Hexcone Model)}, which reads (slightly reformulated):
% \begin{gather}
% r := \frac{x - \emph{red}}{x - z},\qquad
% g := \frac{x - \emph{green}}{x - z},\qquad
% b := \frac{x - \emph{blue}}{x - z}\\
% \emph{hue} := \frac 16\cdot
%  \begin{cases}
%  5+b & \text{if $\emph{red}=x$ and $\emph{green}=z$}\\
%  1-g & \text{if $\emph{red}=x$ and $\emph{green}>z$}\\
%  1+r & \text{if $\emph{green}=x$ and $\emph{blue}=z$}\\
%  3-b & \text{if $\emph{green}=x$ and $\emph{blue}>z$}\\
%  3+g & \text{if $\emph{blue}=x$ and $\emph{red}=z$}\\
%  5-r & \text{if $\emph{blue}=x$ and $\emph{red}>z$}
%  \end{cases}
% \end{gather}
% Note that the singular case $x=z$ is not covered completely in Smith's original algorithm; we stick here to \Index{PostScript}'s behaviour in real life.
%
% Because we need to sort three numbers in order to calculate $x,y,z$, several comparisons are involved in the algorithm.
% We present now a second method which is more suited for \TeX.
%
%
% \paragraph{Conversion \Model{rgb} to \Model{hsb} (2)}
% Let $\beta$ be a function that takes a Boolean expression as argument and returns 1 if the expression is true, 0 otherwise; set
% \begin{gather}
% i := 4\cdot\beta(\emph{red}\ge\emph{green}) + 2\cdot\beta(\emph{green}\ge\emph{blue}) + \beta(\emph{blue}\ge\emph{red}),
% \intertext{and}
% (\emph{hue},\emph{saturation},\emph{brightness}) :=
% \begin{cases}
% \Phi(\emph{blue},\emph{green},\emph{red},3,1) & \text{if $i=1$}\\
% \Phi(\emph{green},\emph{red},\emph{blue},1,1) & \text{if $i=2$}\\
% \Phi(\emph{green},\emph{blue},\emph{red},3,-1) & \text{if $i=3$}\\
% \Phi(\emph{red},\emph{blue},\emph{green},5,1) & \text{if $i=4$}\\
% \Phi(\emph{blue},\emph{red},\emph{green},5,-1) & \text{if $i=5$}\\
% \Phi(\emph{red},\emph{green},\emph{blue},1,-1) & \text{if $i=6$}\\
% (0,0,\emph{blue}) &  \text{if $i=7$}
% \end{cases}\label{eq.rgb2hsb2}
% \intertext{where}
% \Phi(x,y,z,u,v) := \Bigl( \frac{u\cdot(x-z)+v\cdot(x-y)}{6(x-z)}, \frac{x-z}x, x\Bigr)
% \end{gather}
%
% The singular case $x=z$, which is equivalent to $\emph{red}=\emph{green}=\emph{blue}$, is covered here by $i=7$.
%
% \medskip
%
% It is not difficult to see that this algorithm is a reformulation of the previous method.
% The following table explains how the transition from equation (\ref{eq.rgb2hsb1}) to equation (\ref{eq.rgb2hsb2}) works:
%
% \medskip
%
% \begin{tabular*}{\textwidth}{@{\extracolsep\fill}*5{>{$}c<{$}}l@{}}
% 6\cdot\emph{hue}& \emph{Condition}& \emph{red}\ge\emph{green}& \emph{green}\ge\emph{blue}& \emph{blue}\ge\emph{red}& $i$\\\hline
%  1-f & \emph{red}\ge\emph{green}\ge\emph{blue}& 1& 1& *& \textbf6/7\\
%  1+f & \emph{green}\ge\emph{red}\ge\emph{blue}& *& 1& *& \textbf2/3/6/7\\
%  3-f & \emph{green}\ge\emph{blue}\ge\emph{red}& *& 1& 1& \textbf3/7\\
%  3+f & \emph{blue}\ge\emph{green}\ge\emph{red}& *& *& 1& \textbf1/3/5/7\\
%  5-f & \emph{blue}\ge\emph{red}\ge\emph{green}& 1& *& 1& \textbf5/7\\
%  5+f & \emph{red}\ge\emph{blue}\ge\emph{green}& 1& *& *& \textbf4/5/6/7\\
% \end{tabular*}
%
% \medskip
%
% Here, $*$ denotes possible 0 or 1 values.
% Bold $i$~values mark the main cases where all $*$~values of a row are zero.
% The slight difference to equation (\ref{eq.rgb2hsb1}) in the last inequality is intentional and does no harm.
%
%
% \paragraph{Conversion \Model{rgb} to \Model{gray}}
% Source: \cite{plrm}, p. 474.
% \begin{align}
% \emph{gray} & := 0.3\cdot\emph{red} + 0.59\cdot\emph{green} + 0.11\cdot\emph{blue}
% \end{align}
%
%
% \paragraph{Conversion \Model{rgb} to \Model{RGB}}
% As described in section \vref{sec.real2int}.
% \begin{gather}
% (\emph{Red},\emph{Green},\emph{Blue}) := \bigl(\RtoI L(\emph{red}), \RtoI L(\emph{green}), \RtoI L(\emph{blue})\bigr)
% \end{gather}
%
%
% \paragraph{Conversion \Model{rgb} to \Model{HTML}}
% As described in section \vref{sec.real2int}.
% Convert to 6-digit hexadecimal afterwards.
% Certainly, multiplication and summation can be replaced by simple text concatenation of 2-digit hexadecimals.
% \begin{gather}
% \emph{RRGGBB} := \bigl( 65536\cdot\RtoI L(\emph{red}) + 256\cdot \RtoI L(\emph{green}) + \RtoI L(\emph{blue}) \bigr)_{\emph{hex}}
% \end{gather}
%
%
% \paragraph{Complement of \Model{rgb} color}
% We simply take the complementary vector:
% \begin{gather}
% (\emph{red}^*, \emph{green}^*, \emph{blue}^*) := E - (\emph{red}, \emph{green}, \emph{blue})
% \end{gather}
%
%
% \subsubsection{The \Model{cmy} model}
%
% \paragraph{Conversion \Model{cmy} to \Model{rgb}}
% This is simply a reversion of the $\Model{rgb}\to\Model{cmy}$ case, cf. section \vref{sec.rgb2cmy}.
% \begin{gather}
% (\emph{red}, \emph{green}, \emph{blue}) := E - (\emph{cyan}, \emph{magenta}, \emph{yellow})
% \end{gather}
%
%
% \paragraph{Conversion \Model{cmy} to \Model{cmyk}}\label{sec.cmy2cmyk}
% This is probably the hardest of our conversion tasks: many sources emphasize that there does not exist any universal conversion algorithm for this case because of device-dependence.
% The following algorithm is an extended version of the one given in \cite{plrm}, p. 476.
% \begin{align}
% k & := \min\{\emph{cyan},\emph{magenta},\emph{yellow}\}\\
% \emph{cyan} & := \min\{1,\max\{0,\emph{cyan} - \emph{UCR}_c(k)\}\}\\
% \emph{magenta} & := \min\{1,\max\{0,\emph{magenta} - \emph{UCR}_m(k)\}\}\\
% \emph{yellow} & := \min\{1,\max\{0,\emph{yellow} - \emph{UCR}_y(k)\}\}\\
% \emph{black} & := \emph{BG}(k)
% \end{align}
% Here, four additional functions are required:
% \begin{align}
% \emph{UCR}_c, \emph{UCR}_m, \emph{UCR}_y & : [0,1] \to [-1,1]\tag*{\em undercolor-removal}\\
% \emph{BG} & : [0,1] \to [0,1]\tag*{\em black-generation}
% \end{align}
% These functions are device-dependent, see the remarks in \cite{plrm}.
% Although there are some indications that they should be chosen as nonlinear functions, as long as we have no further knowledge about the target device we define them linearly:
% \begin{align}
% \emph{UCR}_c(k) &:= \beta_c\cdot k\\
% \emph{UCR}_m(k) &:= \beta_m\cdot k\\
% \emph{UCR}_y(k) &:= \beta_y\cdot k\\
% \emph{BG}(k) &:= \beta_k\cdot k
% \end{align}
% \DescribeMacro\adjustUCRBG
% where the parameters are given by |\def\adjustUCRBG{|\Meta{$\beta_c$},\Meta{$\beta_m$},\Meta{$\beta_y$},\Meta{$\beta_k$}|}| at any point in a document, defaulting to |{|$\adjustUCRBG$|}|.
%
%
% \paragraph{Conversion \Model{cmy} to \Model{gray}}
% This is derived from the conversion chain $\Model{cmy}\to\Model{rgb}\to\Model{gray}$.
% \begin{align}
% \emph{gray} & := 1 - (0.3\cdot\emph{cyan} + 0.59\cdot\emph{magenta} + 0.11\cdot\emph{yellow})
% \end{align}
%
%
% \paragraph{Complement of \Model{cmy} color}
% We simply take the complementary vector:
% \begin{gather}
% (\emph{cyan}^*, \emph{magenta}^*, \emph{yellow}^*) := E - (\emph{cyan}, \emph{magenta}, \emph{yellow})
% \end{gather}
%
%
% \subsubsection{The \Model{cmyk} model}
%
% \paragraph{Conversion \Model{cmyk} to \Model{cmy}}\label{sec.cmyk2cmy}
% Based on \cite{plrm}, p. 477, in connection with $\Model{rgb}\to\Model{cmy}$ conversion.
% \begin{align}
% \emph{cyan} & := \min\{1,\emph{cyan} + \emph{black}\}\\
% \emph{magenta} & := \min\{1,\emph{magenta} + \emph{black}\}\\
% \emph{yellow} & := \min\{1,\emph{yellow} + \emph{black}\}
% \end{align}
%
%
% \paragraph{Conversion \Model{cmyk} to \Model{gray}}
% Source: \cite{plrm}, p. 475.
% \begin{align}
% \emph{gray} & := 1 - \min\{1,0.3\cdot\emph{cyan} + 0.59\cdot\emph{magenta} + 0.11\cdot\emph{yellow} + black\}
% \end{align}
%
%
% \paragraph{Complement of \Model{cmyk} color}
% The simple vector complement does not yield useful results.
% Therefore, we first convert %$C=(\emph{cyan}, \emph{magenta}, \emph{yellow}, \emph{black})$
% to the \Model{cmy} model, calculate the complement there, and convert back to \Model{cmyk}.
%
%
% \subsubsection{The \Model{hsb} model}
%
% \paragraph{Conversion \Model{hsb} to \Model{rgb}}
% \begin{gather}
% (\emph{red},\emph{green},\emph{blue}) :=
%  \emph{brightness}\cdot( E - \emph{saturation}\cdot F)\\
% \intertext{with}
% i := \left\lfloor 6\cdot\emph{hue}\right\rfloor,\qquad f := 6\cdot\emph{hue} - i\\
% \intertext{and}
% F :=
%  \begin{cases}
%   (0,1-f,1) & \text{if $i=0$}\\
%   (f,0,1) & \text{if $i=1$}\\
%   (1,0,1-f) & \text{if $i=2$}\\
%   (1,f,0) & \text{if $i=3$}\\
%   (1-f,1,0) & \text{if $i=4$}\\
%   (0,1,f) & \text{if $i=5$}\\
%   (0,1,1) & \text{if $i=6$}
%  \end{cases}\label{eq.hsb2rgb2}
% \end{gather}
%
% \medskip
%
% This is based on \cite{smith}, \emph{HSV to RGB Algorithm (Hexcone Model)}, which reads (slightly reformulated):
% \begin{align}
% m & := 1-\emph{saturation}\\
% n & := 1-f\cdot\emph{saturation}\\
% k & := 1-(1-f)\cdot\emph{saturation}\\
% (\emph{red},\emph{green},\emph{blue}) & := \emph{brightness}\cdot
%  \begin{cases}
%   (1,k,m) & \text{if $i=0,6$}\\
%   (n,1,m) & \text{if $i=1$}\\
%   (m,1,k) & \text{if $i=2$}\\
%   (m,n,1) & \text{if $i=3$}\\
%   (k,m,1) & \text{if $i=4$}\\
%   (1,m,n) & \text{if $i=5$}
%  \end{cases}\label{eq.hsb2rgb1}
% \end{align}
% Note that the case $i=6$ (which results from $\emph{hue}=1$) is missing in Smith's algorithm.
% Because of
% \begin{align}
% \lim_{f\to1} (0,1,f) = (0,1,1) = \lim_{f\to0} (0,1-f,1)
% \end{align}
% it is clear that there is only one way to define $F$ for $i=6$ in order to get a continuous function, as shown in equation (\ref{eq.hsb2rgb2}).
% This has been transformed back to equation (\ref{eq.hsb2rgb1}).
% A similar argument shows that $F$ indeed is a continuous function of \emph{hue} over the whole range $[0,1]$.
%
%
% \paragraph{Conversion \Model{hsb} to \Model{Hsb}}
% Only the first component has to be changed.
% \begin{gather}
% (\emph{hue\Circ}, \emph{saturation}, \emph{brightness}) := (H\cdot\emph{hue}, \emph{saturation}, \emph{brightness})
% \end{gather}
%
%
% \paragraph{Conversion \Model{hsb} to \Model{HSB}}
% As described in section \vref{sec.real2int}.
% \begin{gather}
% (\emph{Hue}, \emph{Saturation}, \emph{Brightness}) := \bigl(\RtoI M(\emph{hue}), \RtoI M(\emph{saturation}), \RtoI M(\emph{brightness})\bigr)
% \end{gather}
%
%
% \paragraph{Complement of \Model{hsb} color}
% We have not found a formula in the literature, therefore we give a short proof afterwards.
% \begin{lemma}
% The \textup{\Model{hsb}}-complement can be calculated by the following formulas:\em
% \begin{align}
% \emph{hue}^* & :=
% \begin{cases}
% \emph{hue} + \frac12 & \text{if $\emph{hue}<\frac12$}\\[1ex]
% \emph{hue} - \frac12 & \text{if $\emph{hue}\ge\frac12$}\\
% \end{cases}\\[1ex]
% \emph{brightness}^* & := 1 - \emph{brightness}\cdot(1-\emph{saturation})\\[1ex]
% \emph{saturation}^* & :=
% \begin{cases}
% 0 & \text{if $\emph{brightness}^*=0$}\\[1ex]
% \displaystyle\frac{\emph{brightness}\cdot\emph{saturation}}{\emph{brightness}^*} & \text{if $\emph{brightness}^*\ne0$}
% \end{cases}
% \end{align}
% \end{lemma}
%
% \begin{proof}
% Starting with the original color $C=(h,s,b)$, we define color $C^*=(h^*,s^*,b^*)$ by the given formulas, convert both $C$ and $C^*$ to the \Model{rgb} model and show that
% \begin{gather}
% C_{\Model{rgb}} + C_{\Model{rgb}}^* = b\cdot(E - s\cdot F) + b^*\cdot(E - s'\cdot F^*) \stackrel!= E,\label{eq.hsbcompl1}
% \end{gather}
% which means that $C_{\Model{rgb}}$ is the complement of $C_{\Model{rgb}}^*$.
% First we note that the parameters of $C^*$ are in the legal range $[0,1]$.
% This is obvious for $h^*,b^*$.
% From
% $b^* = 1-b\cdot(1-s) = 1 - b + b\cdot s$
% we derive $b\cdot s = b^* - (1-b) \le b^*$, therefore $s^*\in[0,1]$, and
% \begin{gather*}
% b^* = 0 \Leftrightarrow s=0 \text{ and } b=1.
% \end{gather*}
% Thus, equation (\ref{eq.hsbcompl1}) holds in the case $b^*=0$.
% Now we assume $b^*\ne0$, hence
% \begin{align*}
% C_{\Model{rgb}} + C_{\Model{rgb}}^*
% &= b\cdot(E - s\cdot F) + b^*\cdot\Bigl(E - \frac{b\cdot s}{b^*}\cdot F^*\Bigr) \\
% &= b\cdot E - b\cdot s\cdot F + b^*\cdot E - b\cdot s\cdot F^*\\[1ex]
% &= E - b\cdot s\cdot(F+F^*-E)
% \end{align*}
% since $b^*=1-b+bs$.
% Therefore, it is sufficient to show that
% \begin{gather}
% F+F^*=E.\label{eq.hsbcompl2}
% \end{gather}
% From
% \begin{gather*}\textstyle
% h<\frac12 \Rightarrow h^*=h+\frac12 \Rightarrow 6h^* = 6h+3 \Rightarrow i^*=i+3 \text{ and } f^*=f
% \end{gather*}
% it is easy to see from (\ref{eq.hsb2rgb2}) that equation (\ref{eq.hsbcompl2}) holds for the cases $i=0,1,2$.
% Similarly,
% \begin{gather*}\textstyle
% h\ge\frac12 \Rightarrow h^*=h-\frac12 \Rightarrow 6h^* = 6h-3 \Rightarrow i^*=i-3 \text{ and } f^*=f
% \end{gather*}
% and again from (\ref{eq.hsb2rgb2}) we derive (\ref{eq.hsbcompl2}) for the cases $i=3,4,5$.
% Finally, if $i=6$ then $f=0$ and $F+F^* = (0,1,1) + (1,0,0) = E$.
% \end{proof}
%
%
% \subsubsection{The \Model{Hsb} model}
%
% \paragraph{Conversion \Model{Hsb} to \Model{hsb}}
% Only the first component has to be changed.
% \begin{gather}
% (\emph{hue}, \emph{saturation}, \emph{brightness}) := (\emph{hue\Circ}/H, \emph{saturation}, \emph{brightness})
% \end{gather}
%
%
% \paragraph{Conversion \Model{Hsb} to \Model{tHsb}}
% Under the settings of (\ref{eq.tHsb1})--(\ref{eq.tHsb3}) we simply have to exchange the letters $x$ and $y$ in equation (\ref{eq.tHsb4}) to get the inverse transformation:
% \begin{gather}
% \displaystyle \emph{hue\Circ}\in\left[y_{\eta-1},y_\eta\right] \Rightarrow
% \emph{hue\Circ} := x_{\eta-1} + \frac{x_\eta - x_{\eta-1}}{y_\eta - y_{\eta-1}}\cdot(\emph{hue\Circ} - y_{\eta-1})
% \end{gather}
% while \emph{saturation} and \emph{brightness} are left unchanged.
%
%
% \subsubsection{The \Model{tHsb} model}
%
% \paragraph{Conversion \Model{tHsb} to \Model{Hsb}}\label{sec.tHsb2Hsb}
% \DescribeMacro\rangeHsb
% \DescribeMacro\rangetHsb
% We assume that $\texttt{\string\rangeHsb}=H$ and |\rangetHsb| expands to
% \begin{gather}
% x_1,y_1;x_2,y_2;\dots;x_{h-1},y_{h-1}\label{eq.tHsb1}
% \intertext{where}
% x_0:=0<x_1<x_2<\dots<x_{h-1}<x_h:=H\label{eq.tHsb2}\\
% y_0:=0<y_1<y_2<\dots<y_{h-1}<y_h:=H\label{eq.tHsb3}
% \end{gather}
% with an integer $h>0$.
% Now the $x$ and $y$ values determine a piecewise linear transformation:
% \begin{gather}
% \displaystyle \emph{hue\Circ}\in\left[x_{\eta-1},x_\eta\right] \Rightarrow
% \emph{hue\Circ} := y_{\eta-1} + \frac{y_\eta - y_{\eta-1}}{x_\eta - x_{\eta-1}}\cdot(\emph{hue\Circ} - x_{\eta-1})
% \label{eq.tHsb4}
% \end{gather}
% while \emph{saturation} and \emph{brightness} are left unchanged.
%
%
% \subsubsection{The \Model{gray} model}
%
% \paragraph{Conversion \Model{gray} to \Model{rgb}}
% Source: \cite{plrm}, p. 474.
% \begin{gather}
% (\emph{red}, \emph{green}, \emph{blue}) := \emph{gray}\cdot E
% \end{gather}
%
%
% \paragraph{Conversion \Model{gray} to \Model{cmy}}
% This is derived from the conversion chain $\Model{gray}\to\Model{rgb}\to\Model{cmy}$.
% \begin{gather}
% (\emph{cyan}, \emph{magenta}, \emph{yellow}) := (1-\emph{gray})\cdot E
% \end{gather}
%
%
% \paragraph{Conversion \Model{gray} to \Model{cmyk}}
% Source: \cite{plrm}, p. 475.
% \begin{gather}
% (\emph{cyan}, \emph{magenta}, \emph{yellow}, \emph{black}) := (0,0,0,1-\emph{gray})
% \end{gather}
%
%
% \paragraph{Conversion \Model{gray} to \Model{hsb}}
% This is derived from the conversion chain $\Model{gray}\to\Model{rgb}\to\Model{hsb}$.
% \begin{gather}
% (\emph{hue}, \emph{saturation}, \emph{brightness}) := (0,0,\emph{gray})
% \end{gather}
%
%
% \paragraph{Conversion \Model{gray} to \Model{Hsb}/\Model{tHsb}}
% This is derived from the conversion chain $\Model{gray}\to\Model{hsb}\to\Model{Hsb}$, followed by $\Model{Hsb}\to\Model{tHsb}$ if applicable.
% \begin{gather}
% (\emph{hue\Circ}, \emph{saturation}, \emph{brightness}) := (0,0,\emph{gray})
% \end{gather}
%
%
% \paragraph{Conversion \Model{gray} to \Model{Gray}}
% As described in section \vref{sec.real2int}.
% \begin{gather}
% \emph{Gray} := \RtoI N(\emph{gray})
% \end{gather}
%
%
% \paragraph{Complement of \Model{gray} color}
% This is similar to the \Model{rgb} case:
% \begin{gather}
% \emph{gray}^* := 1 - \emph{gray}
% \end{gather}
%
%
% \subsubsection{The \Model{RGB} model}
%
% \paragraph{Conversion \Model{RGB} to \Model{rgb}}
% As described in section \vref{sec.int2real}.
% \begin{gather}
% (\emph{red}, \emph{green}, \emph{blue}) := \bigl(\ItoR L(\emph{Red}), \ItoR L(\emph{Green}), \ItoR L(\emph{Blue})\bigr)
% \end{gather}
%
%
% \subsubsection{The \Model{HTML} model}
%
% \paragraph{Conversion \Model{HTML} to \Model{rgb}}
% As described in section \vref{sec.int2real}: starting with \emph{RRGGBB} set
% \begin{gather}
% (\emph{red}, \emph{green}, \emph{blue}) := \bigl(\ItoR{255}(\emph{RR}_{\emph{dec}}), \ItoR{255}(\emph{GG}_{\emph{dec}}), \ItoR{255}(\emph{BB}_{\emph{dec}})\bigr)
% \end{gather}
%
%
% \subsubsection{The \Model{HSB} model}
%
% \paragraph{Conversion \Model{HSB} to \Model{hsb}}
% As described in section \vref{sec.int2real}.
% \begin{gather}
% (\emph{hue}, \emph{saturation}, \emph{brightness}) := \bigl(\ItoR M(\emph{Hue}), \ItoR M(\emph{Saturation}), \ItoR M(\emph{Brightness})\bigr)
% \end{gather}
%
%
% \subsubsection{The \Model{Gray} model}
%
% \paragraph{Conversion \Model{Gray} to \Model{gray}}
% As described in section \vref{sec.int2real}.
% \begin{gather}
% \emph{gray} := \ItoR N(\emph{Gray})
% \end{gather}
%
%
% \subsubsection{The \Model{wave} model}
%
% \paragraph{Conversion \Model{wave} to \Model{rgb}}
% Source: based on \People{Dan}{Bruton}'s algorithm \cite{Bruton}.
% Let $\lambda$ be a visible wavelength, given in nanometers (nm), i.e., $\lambda\in\left[380,780\right]$.
% We assume further that $\gamma>0$ is a fixed number ($\gamma=0.8$ in \cite{Bruton}).
% First set
% \begin{align}
% (r,g,b) & :=
%  \begin{cases}
%   \displaystyle \Bigl(\frac{440-\lambda}{440-380},0,1\Bigr) & \text{if $\lambda\in[380,440[$}\\[1.75ex]
%   \displaystyle \Bigl(0,\frac{\lambda-440}{490-440},1\Bigr) & \text{if $\lambda\in[440,490[$}\\[1.75ex]
%   \displaystyle \Bigl(0,1,\frac{510-\lambda}{510-490}\Bigr) & \text{if $\lambda\in[490,510[$}\\[1.75ex]
%   \displaystyle \Bigl(\frac{\lambda-510}{580-510},1,0\Bigr) & \text{if $\lambda\in[510,580[$}\\[1.75ex]
%   \displaystyle \Bigl(1,\frac{645-\lambda}{645-580},0\Bigr) & \text{if $\lambda\in[580,645[$}\\[2.5ex]
%   \displaystyle (1,0,0) & \text{if $\lambda\in[645,780]$}\\
%  \end{cases}\label{eq.gamma2rgb1}\\
% \intertext{then, in order to let the intensity fall off near the vision limits,}
% f & :=
%  \begin{cases}
%   \displaystyle 0.3 + 0.7\cdot\frac{\lambda-380}{420-380} & \text{if $\lambda\in\left[380,420\right[$}\\[1.25ex]
%   \displaystyle 1 & \text{if $\lambda\in[420,700]$}\\[1ex]
%   \displaystyle 0.3 + 0.7\cdot\frac{780-\lambda}{780-700} & \text{if $\lambda\in\left]700,780\right]$}\\
%  \end{cases}\label{eq.gamma2rgb2}\\
% \intertext{and finally}
% (\emph{red},\emph{green},\emph{blue}) & := \bigl((f\cdot r)^\gamma, (f\cdot g)^\gamma, (f\cdot b)^\gamma\bigr)
% \end{align}
% The intermediate colors $(r,g,b)$ at the interval borders of equation (\ref{eq.gamma2rgb1}) are well-known:
% for $\lambda=380,440,490,510,580,645$ we get \Color{magenta}, \Color{blue}, \Color{cyan}, \Color{green}, \Color{yellow}, \Color{red}, respectively.
% These turn out to be represented in the \Model{hsb} model by $\emph{hue}=\frac56,\frac46,\frac36,\frac26,\frac16,\frac06$, whereas $\emph{saturation}=\emph{brightness}=1$ throughout the 6~colors.
% Furthermore, these \Model{hsb} representations are independent of the actual $\gamma$ value.
% Staying within this model framework, we observe that the intensity fall off near the vision limits --- as represented by equation (\ref{eq.gamma2rgb2}) --- translates into decreasing \emph{brightness} parameters towards the margins.
% A simple calculation shows that the edges $\lambda=380,780$ of the algorithm yield the colors |magenta!|$0.3^\gamma$|!black|, |red!|$0.3^\gamma$|!black|, respectively.
% We see no reason why we should not extend these edges in a similar fashion to end-up with true \Color{black} on either side.
% Now we are prepared to translate everything into another, more natural algorithm.
%
%
% \paragraph{Conversion \Model{wave} to \Model{hsb}}
% Let $\lambda>0$ be a wavelength, given in nanometers (nm), and let
% \begin{gather}
% \varrho : \bbbR \to \left[0,1\right],\ x \mapsto \bigl( \min\{ 1, \max\{ 0,x\} \} )^\gamma
% \end{gather}
% with a fixed correction number $\gamma>0$.
% Then
% \begin{align}
% \emph{hue} & := \displaystyle \frac16\cdot
%  \begin{cases}
%   \displaystyle 4 + \varrho\Bigl(\frac{\lambda-440}{380-440}\Bigr) & \text{if $\lambda<440$}\\[1.75ex]
%   \displaystyle 4 - \varrho\Bigl(\frac{\lambda-440}{490-440}\Bigr) & \text{if $\lambda\in[440,490[$}\\[1.75ex]
%   \displaystyle 2 + \varrho\Bigl(\frac{\lambda-510}{490-510}\Bigr) & \text{if $\lambda\in[490,510[$}\\[1.75ex]
%   \displaystyle 2 - \varrho\Bigl(\frac{\lambda-510}{580-510}\Bigr) & \text{if $\lambda\in[510,580[$}\\[1.75ex]
%   \displaystyle 0 + \varrho\Bigl(\frac{\lambda-645}{580-645}\Bigr) & \text{if $\lambda\in[580,645[$}\\[2.5ex]
%   \displaystyle 0 & \text{if $\lambda\ge645$}\\
%  \end{cases}\label{eq.gamma2hsb1}\\[1ex]
% \emph{saturation} & := 1\\[1ex]
% \emph{brightness} & :=
%  \begin{cases}
%   \displaystyle \varrho\Bigl(0.3 + 0.7\cdot\frac{\lambda-380}{420-380}\Bigr) & \text{if $\lambda<420$}\\[1.5ex]
%   \displaystyle 1 & \text{if $\lambda\in[420,700]$}\\[1ex]
%   \displaystyle \varrho\Bigl(0.3 + 0.7\cdot\frac{\lambda-780}{700-780}\Bigr) & \text{if $\lambda>700$}\\
%  \end{cases}\label{eq.gamma2hsb2}
% \end{align}
% For the sake of completeness we note that, independent of $\gamma$,
% \begin{gather*}
% (\emph{hue},\emph{saturation},\emph{brightness}) =
%  \begin{cases}
%   \bigl(\frac56,1,0\bigr) & \text{if $\lambda\le 380 - \frac{3\cdot(420-380)}7 = 362.857\dots$}\\[1.5ex]
%   \bigl(0,1,0\bigr) & \text{if $\lambda\ge 780 + \frac{3\cdot(780-700)}7 = 814.285\dots$}\\
%  \end{cases}\label{eq.gamma2hsb3}
% \end{gather*}
% What is the best (or, at least, a good) value for $\gamma$?
% In the original algorithm \cite{Bruton}, $\gamma=0.8$ is chosen.
% However, we could not detect significant visible difference between the cases $\gamma=0.8$ and $\gamma=1$.
% Thus, for the time being, \XC's implementation uses the latter value which implies a pure linear approach.
% In the \Package{pstricks} examples file \href{xcolor2.pdf}{\File{xcolor2.tex}}, there is a demonstration of different $\gamma$ values.
%
% \clearpage
%
%
%
% \begin{adjustwidth}{-2.5cm}{}
% \begingroup\raggedright
% \begin{thebibliography}{00}
% \addcontentsline{toc}{section}{References}
%
% \bibitem{plrm}%
%  {Adobe Systems Incorporated: ``PostScript Language Reference Manual''. Addison-Wesley, third edition, 1999.
%   \URL{http://www.adobe.com/products/postscript/pdfs/PLRM.pdf}}
%
% \bibitem{fbox}%
%  {\People{Donald}{Arseneau}: ``Patch so \cmd\fbox{} draws frame on top of text''. \LaTeX{} bug report, latex/3655, 2004/03/18.
%   \URL{http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=latex/3655}}
%
% \bibitem{url}%
%  {\People{Donald}{Arseneau}: \Package{url} package, ``2005/06/27  ver 3.2  Verb mode for urls, etc.''.
%   \CTAN{macros/latex/contrib/misc/}{url.sty}}
%
% \bibitem{Bruton}%
%  {\People{Dan}{Bruton}: ``Approximate RGB values for Visible Wavelengths'', 1996.
%   \URL{http://www.physics.sfasu.edu/astro/color/spectra.html}}
%
% \bibitem{dpc}%
%  {\People{David P.}{Carlisle}: ``Packages in the `graphics' bundle'', 2005.
%   \CTAN{macros/latex/required/graphics/}{grfguide.*}}
%
% \bibitem{color}%
%  {\People{David P.}{Carlisle}: \LCP, ``2005/11/14 v1.0j Standard \LaTeX{} Color''.
%   \CTAN{macros/latex/required/graphics/}{color.dtx}}
%
% \bibitem{colortbl}%
%  {\People{David P.}{Carlisle}: \Package{colortbl} package, ``2001/02/13 v0.1j Color table columns''.
%   \CTAN{macros/latex/contrib/colortbl/}{}}
%
% \bibitem{pstcol}%
%  {\People{David P.}{Carlisle}, \People{Herbert}{Vo\ss}, \People{Rolf}{Niepraschk}: \Package{pstcol} package, ``2005/11/16 v1.2 LaTeX wrapper for `PSTricks'{}''.
%   \CTAN{macros/graphics/pstricks/latex/}{pstcol.sty}}
%
% \bibitem{chroma}%
%  {\People{Uwe}{Kern}: ``Chroma: a reference book of \LaTeX{} colors''.
%   \CTAN{info/colour/chroma/}{} and
%   \URL{http://www.ukern.de/tex/chroma.html}}
%
% \bibitem{xcolor}%
%  {\People{Uwe}{Kern}: \Package{xcolor} package, ``\LaTeX{} color extensions''.
%   \CTAN{macros/latex/contrib/xcolor/}{} and
%   \URL{http://www.ukern.de/tex/xcolor.html}}
%
% \bibitem{mik}%
%  {MiK\TeX{} Project:
%   \URL{http://www.miktex.org/}}
%
% \bibitem{colorinfo}%
%  {\People{Rolf}{Niepraschk}: \Package{colorinfo} package, ``2003/05/04 v0.3c Info from defined colors''.
%   \CTAN{macros/latex/contrib/colorinfo/}{}}
%
% \bibitem{pdfcolmk}%
%  {\People{Heiko}{Oberdiek}: \Package{pdfcolmk} package, ``2006/02/20 v0.8 PDFtex COLor MarK''.
%   \CTAN{macros/latex/contrib/oberdiek/}{pdfcolmk.*}}
%
% \bibitem{hyperref}%
%  {\People{Sebastian}{Rahtz}, \People{Heiko}{Oberdiek}: \Package{hyperref} package, ``2006/09/06 v6.75e Hypertext links for \LaTeX''.
%   \CTAN{macros/latex/contrib/hyperref/}{}}
%
% \bibitem{smith}%
%  {\People{Alvy Ray}{Smith}: ``Color Gamut Transform Pairs''. \emph{Computer Graphics} (ACM SIGGRAPH), Volume 12, Number 3, August 1978.
%   \URL{http://alvyray.com/Papers/PapersCG.htm}}
%
% \bibitem{HTML4}%
%  {World Wide Web Consortium: ``HTML4 color keywords''.
%   \URL{http://www.w3.org/TR/css3-color/\#html4}}
%
% \bibitem{svg}%
%  {World Wide Web Consortium: ``Scalable Vector Graphics (\Index{SVG}) 1.1 Specification --- Basic Data Types and Interfaces''.
%   \URL{http://www.w3.org/TR/SVG11/types.html\#ColorKeywords}}
%
% \end{thebibliography}
% \endgroup
% \clearpage
%
% \columnsep2.25em
% \begin{multicols}{2}[\section*{Appendix}%
% \addcontentsline{toc}{section}{Appendix}]
%
% \subsection*{Acknowledgement}
% \addcontentsline{toc}{subsection}{Acknowledgement}
% This package is based on and contains code copied from \cite{color} (Copyright (C) 1994--1999 \People{David P.}{Carlisle}), which is part of the Standard \LaTeX{} `Graphics Bundle'.
% Although many commands and features have been added and most of the original \LC{} commands have been rewritten or adapted within \XC, the latter package would not exist without \LC.
% Thus, the author is grateful to \People{David P.}{Carlisle} for having created \LC{} and its accompanying files.
%
% \subsection*{Trademarks}
% \addcontentsline{toc}{subsection}{Trademarks}
% Trademarks appear throughout this documentation without any trademark symbol; they are the property of their respective trademark owner.
% There is no intention of infringement; the usage is to the benefit of the trademark owner.
%
% \raggedright
% \leftmargini1em
% \leftmarginii1em
% \leftmarginiii1em
%
% \subsection*{Known Issues}
% \addcontentsline{toc}{subsection}{Known Issues}
% \begin{itemize}
% \item |\rowcolors[\hline]...| does not work with \Package{longtable}.
% \end{itemize}
%
% \subsection*{History}
% \addcontentsline{toc}{subsection}{History}
%
% \subsubsection*{2007/01/21 v2.11}
% \begin{itemize}
% \item New features:
%   \begin{itemize}
%   \item color names \Color{lime} and \Color{teal} added to the set of predefined colors.
%   \end{itemize}
% \item Bugfix:
%   \begin{itemize}
%   \item incorrect |\XC@strip@comma| call within \Package{hyperref}-related options.
%   \end{itemize}
% \end{itemize}
%
% \subsubsection*{2006/11/28 v2.10}
% \begin{itemize}
% \item New features:
%   \begin{itemize}
%   \item \Option{fixinclude} option prevents \Program{dvips} from explicitly resetting current color to \Color{black} before actually inserting an \File{.eps} file via |\color{red}\includegraphics{foo}|.
%   \end{itemize}
% \item Changes:
%   \begin{itemize}
%   \item |\colorbox| and |\fcolorbox| made robust;
%   \item obsolete package option \oOption{pst} removed;
%   \item several changes to internal macros.
%   \end{itemize}
% \item Bugfixes:
%   \begin{itemize}
%   \item incorrect processing of \Model{cmyk}-type current color `.'.
%   \end{itemize}
% \end{itemize}
%
% \subsubsection*{2005/12/21 v2.09}
% \begin{itemize}
% \item New features:
%   \begin{itemize}
%   \item |\definecolor| and |\color| now accept space-separated color specifications, e.g., |\color| |[rgb]{1 .5 0}|;
%   \item experimental \Option{xcdraw} option extended to \Option{pdftex} and \Option{dvipdfm} drivers.
%   \end{itemize}
% \item Changes:
%   \begin{itemize}
%   \item test file \File{xcolor2.tex} made compatible with recent changes in \Package{pstricks};
%   \item test file \File{xcolor3.tex} extended;
%   \item driver test file \File{xcolor4.tex} extended to demonstrate the different frame drawing approaches;
%   \item more efficient implementation of driver-specific code.
%   \end{itemize}
% \end{itemize}
%
% \subsubsection*{2005/11/25 v2.08}
% \begin{itemize}
% \item New features:
%   \begin{itemize}
%   \item more flexibility for |\fcolorbox| arguments, e.g., |\fcolorbox| |[gray]{0.5}[wave]{580}{test}|;
%   \item |\boxframe| returns a frame of given dimensions;
%   \item new implementation of |\f(rame)box| and |\fcolorbox| as an extension of bug report latex/3655 to reduce pixel positioning errors in output devices;
%   \item \Option{kernelfbox} option for those who prefer the previous |\f(rame)box| approach;
%   \item experimental \Option{xcdraw} option uses \Index{PostScript} commands to draw frames and color boxes in case of \Option{dvips}.
%   \end{itemize}
% \item Bugfixes:
%   \begin{itemize}
%   \item insufficient expression type detection within |\colorlet|;
%   \item wrong calculation in the unit interval reduction for negative integers (affecting color series and extended color expressions).
%   \end{itemize}
% \end{itemize}
%
% \subsubsection*{2005/11/12 v2.07}
% \begin{itemize}
% \item New features:
%   \begin{itemize}
%   \item color model \Model{Hsb} allows to specify \emph{hue} in degrees;
%   \item color model \Model{tHsb} (\pModel{tuned} \Model{Hsb}) for user-defined \emph{hue} configuration on color wheels;
%   \item easy generation of color harmonies derived from \Model{Hsb} or \Model{tHsb} color wheels, e.g., |\color{red>wheel,1,12}| yields an `analogous' color to \Color{red} on a 12-spoke wheel;
%   \item additional 317 predefined color names according to \File{rgb.txt}, which is part of \Index{Unix}/\Index{X11} distributions;
%   \item \Option{svgnames} option extended by~4~colors taken from \File{rgb.txt};
%   \item enhanced syntax for immediate conversion, e.g., |\definecolor| |{foo}{rgb:gray}{0.3}| or |\color| |[rgb:wave]{478}|;
%   \item |\@ifundefinedcolor| and |\@ifundefinedmodel| commands;
%   \end{itemize}
% \item Changes:
%   \begin{itemize}
%   \item enhanced documentation;
%   \item several changes to internal macros.
%   \end{itemize}
% \item Bugfixes:
%   \begin{itemize}
%   \item wrong calculation of color series components in some cases of negative step parameters.
%   \end{itemize}
% \end{itemize}
%
% \subsubsection*{2005/10/15 v2.06}
% \begin{itemize}
% \item New features:
%   \begin{itemize}
%   \item color model \Model{wave} for (approximate) visualisation of light wavelengths, still somewhat experimental;
%   \item pseudo-model \nModel{ps} for colors defined by literal \Index{PostScript} code in conjunction with \Package{pstricks} and \Option{dvips}; an illustrative example for a $\gamma$-correction approach is given in \href{xcolor2.pdf}{\File{xcolor2.tex}};
%   \item |\substitutecolormodel| command for replacement of missing or faulty driver-specific color models;
%   \item improved detection and handling of driver-specific color models;
%   \item \Option{dvipdfmx} and \Option{xetex} options to support these drivers;
%   \item generic driver test file \File{xcolor4.tex}.
%   \end{itemize}
% \item Changes:
%   \begin{itemize}
%   \item |\XC@strip@comma| doesn't generate a trailing space anymore, which improves also the output of the |testcolors| environment.
%   \end{itemize}
% \end{itemize}
%
% \subsubsection*{2005/09/30 v2.05}
% \begin{itemize}
% \item New features:
%   \begin{itemize}
%   \item |testcolors| environment helps to test colors in different models, showing both the visual result and the model-specific parameters;
%   \item |\extractcolorspecs| puts model/color specification into two separate commands, as opposed to |\extractcolorspec|;
%   \item color names \Color{pink} and \Color{olive} added to the set of predefined colors.
%   \end{itemize}
% \item Bugfixes:
%   \begin{itemize}
%   \item |\definecolor{foo}{named}{bar}| did not work in v2.04.
%   \end{itemize}
% \end{itemize}
%
% \subsubsection*{2005/09/23 v2.04}
% \begin{itemize}
% \item New features:
%   \begin{itemize}
%   \item preparation for usage of additional -- driver-provided -- color models;
%   \item \Package{pstricks} users may now specify explicit color parameters within |\psset| and related commands, e.g., |\psset{linecolor=[rgb]{1,0,0}}|; an illustrative example is given in \href{xcolor2.pdf}{\File{xcolor2.tex}}.
%   \end{itemize}
% \item Changes:
%   \begin{itemize}
%   \item color model names sanitized (i.e., turned to catcode~12) throughout the package;
%   \item |\@namelet| command deprecated because of name clash with \Package{memoir} --- please use |\XC@let@cc| instead (more |\XC@let@..| commands are available as well);
%   \item simplified color conversion code by using the new |\XC@ifxcase| command;
%   \item some minor changes to internal macros.
%   \end{itemize}
% \end{itemize}
%
% \subsubsection*{2005/06/06 v2.03}
% \begin{itemize}
% \item New features:
%   \begin{itemize}
%   \item \Option{fixpdftex} option loads \Package{pdfcolmk} package in order to improve pdf\TeX's color behaviour during page breaks.
%   \end{itemize}
% \item Changes:
%   \begin{itemize}
%   \item some minor changes to internal macros.
%   \end{itemize}
% \item Bugfixes:
%   \begin{itemize}
%   \item due to an incorrect |\if| statement within |\XC@info|, |\colorlet| caused trouble whenever its second argument started with two identical letters, e.g., |\colorlet{rab}{oof}|;
%   \item argument processing of |\XC@getcolor| caused incompatibility with \Package{msc} package;
%   \item \Option{prologue} option caused incompatibility with \Package{preview} package.
%   \end{itemize}
% \end{itemize}
%
% \subsubsection*{2005/03/24 v2.02}
% \begin{itemize}
% \item New features:
%   \begin{itemize}
%   \item |\aftergroupedef| command to reproduce |\aftergroupdef|'s behaviour prior to v2.01;
%   \item \XC's homepage \XCW{} now provides also a ready-to-run TDS-compliant archive containing all required files.
%   \end{itemize}
% \item Changes:
%   \begin{itemize}
%   \item |\rowcolors| and friends are solely enabled by the \Option{table} option;
%   \item |\@ifxempty| changed back to more robust variant of v2.00.
%   \end{itemize}
% \item Bugfixes:
%   \begin{itemize}
%   \item |\psset{linecolor=\ifcase\foo| |red\or green\or blue\fi}| did not work with \Package{pstricks} (error introduced in v2.01).
%   \end{itemize}
% \end{itemize}
%
% \subsubsection*{2005/03/15 v2.01}
% \begin{itemize}
% \item New features:
%   \begin{itemize}
%   \item \Option{prologue} option for comprehensive `named' color support in conjunction with \Option{dvips}: on-the-fly generation of \Index{PostScript} prologue files with all color definitions, ready for \Program{dvips} inclusion and/or post-processing with device-specific parameters (e.g., spot colors);
%   \item \Program{dvips} prologue file \File{xcolor.pro} to support additional `named' colors;
%   \item |\colorlet| may now also be used to create named colors from arbitrary color expressions;
%   \item enhanced color definition syntax to allow for target-model specific color parameters, e.g., |\definecolor| |{red}{rgb/cmyk}{1,0,0/0,1,1,0}|, facilitating the usage of tailor-made colors both for displays and printers;
%   \item `deferred definition' of colors: |\preparecolor| and |\definecolors| enable decoupling of color specification and control sequence generation, especially useful (= memory saving) for large lists of colors, of which only a few names are actually used;
%   \item \Option{dvipsnames*} and \Option{svgnames*} options to support deferred definition.
%   \end{itemize}
% \item Changes:
%   \begin{itemize}
%   \item higher accuracy: most complement calculations are now exact for all 5-digit decimals;
%   \item |\rangeRGB| and similar variables may now be changed at any point in a document;
%   \item |\aftergroupdef| now performs only a first-level expansion of its code argument;
%   \item |\XCfileversion| and similar internal constants removed from \File{.sty} and \File{.def} files;
%   \item improved memory management (reduced generation of `multiletter control sequences' by |\@ifundefined| tests);
%   \item several internal macros improved and/or renamed.
%   \end{itemize}
% \item Bugfixes:
%   \begin{itemize}
%   \item |\XC@getcolor| could cause unwanted spaces when |\psset| was used inside |pspicture| environments (\Package{pstricks});
%   \item arithmetic overflow could happen when too many decimal digits were used within color parameters, e.g., as a result of \Package{fp} calculations.
%   \end{itemize}
% \end{itemize}
%
% \subsubsection*{2004/07/04 v2.00}
% \begin{itemize}
% \item New features:
%   \begin{itemize}
%   \item extended functionality for color expressions: mix colors like a painter;
%   \item support for color blending: specify color mix expressions that are being blended with every displayed color;
%   \item |\xglobal| command for selective control of globality for color definitions, blends, and masks;
%   \item multiple step operations (e.g., |\color{foo!!+++}|) and access to individual members (e.g., |\color{foo!![7]}|) in color series;
%   \item |\providecolor| command to define only non-existent colors;
%   \item |\definecolorset| and |\providecolorset| commands to facilitate the construction of color sets with common underlying color model;
%   \item additional 147 predefined color names according to \Index{SVG}~1.1 specification;
%   \item \Key{xpdfborder} key for setting the width of hyperlink borders in a more driver-independent way if \Program{dvips} is used.
%   \end{itemize}
% \item Changes:
%   \begin{itemize}
%   \item \LCP{} now completely integrated within \XC;
%   \item \oOption{override}, \oOption{usenames}, \oOption{nodvipsnames} options and |\xdefinecolor| command no longer needed;
%   \item \Option{dvips} and \Option{dvipsnames} options now independent of each other;
%   \item |\tracingcolors|'s behaviour changed to make it more versatile and reduce log file size in standard cases;
%   \item |\rdivide|'s syntax made more flexible (divide by numbers and/or dimensions);
%   \item code restructured, some internal commands renamed;
%   \item documentation rearranged and enhanced.
%   \end{itemize}
% \item Bugfixes:
%   \begin{itemize}
%   \item |\definecolor{foo}{named}{bar}| did not work (error introduced in v1.11);
%   \item more robust behaviour of conditionals within \Package{pstricks} key-values.
%   \end{itemize}
% \end{itemize}
%
% \subsubsection*{2004/05/09 v1.11}
% \begin{itemize}
% \item New features:
%   \begin{itemize}
%   \item switch |\ifglobalcolors| to control whether color definitions are global or local;
%   \item option \Option{hyperref} provides color expression support for the border colors of hyperlinks, e.g., |\hypersetup| |{xurlbordercolor=red!50!yellow}|;
%   \item internal hooks |\XC@bcolor|, |\XC@mcolor|, and |\XC@ecolor| for additional code that has to be executed immediately before/after the current color is being displayed.
%   \end{itemize}
% \item Changes:
%   \begin{itemize}
%   \item |\XC@logcolor| renamed to |\XC@display|, which is now the core color display command;
%   \item improved interface to \Package{pstricks}.
%   \end{itemize}
% \end{itemize}
%
% \subsubsection*{2004/03/27 v1.10}
% \begin{itemize}
% \item New features:
%   \begin{itemize}
%   \item support for \nModel{named} model;
%   \item support for \Program{dvips} colors (may now be used within color expressions);
%   \item internal representation of `ordinary' and `named' colors merged into unified data structure;
%   \item allow multiple `-' signs at the beginning of color expressions.
%   \end{itemize}
% \item Bugfixes:
%   \begin{itemize}
%   \item commands like |\color[named]{foo}| caused errors when color masking or target model conversion were active;
%   \item incompatibility with \Package{soul} package: commands |\hl|, |\ul|, etc. could yield unexpected results.
%   \end{itemize}
% \item Documentation:
%   \begin{itemize}
%   \item added formula for general color expressions;
%   \item enhanced text and index;
%   \item removed dependence of index generation on local configuration file.
%   \end{itemize}
% \end{itemize}
%
% \subsubsection*{2004/02/16 v1.09}
% \begin{itemize}
% \item New features:
%   \begin{itemize}
%   \item color model \Model{HTML}, a 24-bit hexadecimal \Model{RGB} variant; allows to specify colors like |\color[HTML]{AFFE90}|;
%   \item color names \Color{orange}, \Color{violet}, \Color{purple}, and \Color{brown} added to the set of predefined colors.
%   \end{itemize}
% \item New \XC{} homepage: \XCW
% \item Bugfix: |\xdefinecolor| sometimes did not normalise its parameters.
% \item Changes:
%   \begin{itemize}
%   \item slight improvements of the documentation;
%   \item example file |xcolor1.tex| reorganised and abridged.
%   \end{itemize}
% \end{itemize}
%
% \subsubsection*{2004/02/04 v1.08}
% \begin{itemize}
% \item New commands:
%   \begin{itemize}
%   \item |\selectcolormodel| to change the target model within a document;
%   \item |\adjustUCRBG| to fine-tune undercolor-removal and black-generation during conversion to \Model{cmyk}.
%   \end{itemize}
% \item Bugfix: color expressions did not work correctly in connection with active `!' character, e.g., in case of |\usepackage[frenchb]babel}|.
% \item Code re-organisation:
%   \begin{itemize}
%   \item |\XC@xdefinecolor| merged into |\xdefinecolor|, making the first command obsolete;
%   \item several internal commands improved/streamlined.
%   \end{itemize}
% \end{itemize}
%
% \subsubsection*{2004/01/20 v1.07}
% \begin{itemize}
% \item New feature: support for color masking and color separation.
% \item New commands:
%   \begin{itemize}
%   \item |\rmultiply| to multiply a dimension register by a real number;
%   \item |\xcolorcmd| to pass commands that are to be executed at the end of the package.
%   \end{itemize}
% \item Changes:
%   \begin{itemize}
%   \item more consistent color handling: extended colors now always take precedence over standard colors;
%   \item several commands improved by using code from the \LaTeX{} kernel.
%   \end{itemize}
% \item Documentation: some minor changes.
% \item Example files: additional \Package{pstricks} examples (file \href{xcolor2.pdf}{\File{xcolor2.tex}}).
% \end{itemize}
%
% \subsubsection*{2003/12/15 v1.06}
% \begin{itemize}
% \item New feature: extended color expressions, allowing for cascaded mix operations, e.g., |\color{red!30!green!40!blue}|.
% \item Documentation: new section on color expressions.
% \item Bugfix:~color series stepping did not work correctly within non-displaying commands like |\extractcolorspec{foo!!+}| (this bug was introduced in v1.05).
% \item Renamed~commands:~|\ukfileversion| and similar internal constants renamed to |\XCfileversion| etc.
% \item Removed~commands:~|\ifXCpst| and |\ifXCtable| made obsolete by a simple trick.
% \end{itemize}
%
% \subsubsection*{2003/11/21 v1.05}
% \begin{itemize}
% \item Bugfixes:
%   \begin{itemize}
%   \item package option \Option{hideerrors} should now work as expected;
%   \item usage of `.' in the first color expression in a document caused an error due to incorrect initialisation.
%   \end{itemize}
% \item Code re-organisation: |\extractcolorspec| now uses |\XC@splitcolor|, making |\XC@extract| obsolete.
% \end{itemize}
%
% \subsubsection*{2003/11/09 v1.04}
% \begin{itemize}
% \item New feature: easy access to current color within color expressions.
% \item New option: \oOption{override} to replace |\definecolor| by |\xdefinecolor|.
% \item New command: |\tracingcolors| for logging color-specific information.
% \end{itemize}
%
% \subsubsection*{2003/09/21 v1.03}
% \begin{itemize}
% \item Change: bypass strange behaviour of some drivers.
% \item New feature: driver-sharing with \Package{hyperref}.
% \end{itemize}
%
% \subsubsection*{2003/09/19 v1.02}
% \begin{itemize}
% \item Change: |\extractcolorspec| and |\colorlet| now also accept color series as arguments.
% \end{itemize}
%
% \subsubsection*{2003/09/15 v1.01}
% \begin{itemize}
% \item New feature: |\definecolorseries| and friends.
% \item Documentation: removed some \Package{doc}-related side-effects.
% \item Code re-organisation: all calculation-related tools put to one place.
% \item Bugfixes:
%   \begin{itemize}
%   \item |\@rdivide|: added |\relax| to fix problem with negative numerators;
%   \item |\rowc@l@rs|: replaced |\@ifempty| by |\@ifxempty|.
%   \end{itemize}
% \end{itemize}
%
% \subsubsection*{2003/09/09 v1.00}
% \begin{itemize}
% \item First published release.
% \end{itemize}
%
% \end{multicols}
% \end{adjustwidth}
%
% \StopEventually{}
% \clearpage
%
% \section{The Implementation}
%
% Some commands have been copied unchanged from \cite{color} (Copyright (C) 1994--1999 \People{David P.}{Carlisle}), which is part of the Standard \LaTeX{} `Graphics Bundle'.
% Additionally, also some parts of the code documentation were copied from \cite{color}.
%
%
%
% \subsection{Preparation}
%
% \subsubsection{File identification}
%
% \renewcommand*\MacroFont{\footnotesize\ttfamily}
% \renewcommand*\AltMacroFont{\footnotesize\ttfamily\slshape}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
% \fbox{\MacroFont\string\ProvidesPackage\string{xcolor\string}[\XCfiledate\space\XCfileversion\space LaTeX color extensions (UK)]}
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
%    \end{macrocode}
%
%
% \subsubsection{Safety first}
%
% \begin{macro}{\XC@catcodes}
% Save catcodes for later restore:
%    \begin{macrocode}
\expandafter\edef\csname XC@catcodes\endcsname
 {\catcode33 \the\catcode33 % !
  \catcode34 \the\catcode34 % "
  \catcode39 \the\catcode39 % '
  \catcode42 \the\catcode42 % *
  \catcode44 \the\catcode44 % ,
  \catcode45 \the\catcode45 % -
  \catcode46 \the\catcode46 % .
  \catcode47 \the\catcode47 % /
  \catcode58 \the\catcode58 % :
  \catcode59 \the\catcode59 % ;
  \catcode60 \the\catcode60 % <
  \catcode61 \the\catcode61 % =
  \catcode62 \the\catcode62 % >
  \catcode63 \the\catcode63 % ?
  \catcode64 \the\catcode64 % @
  \catcode94 \the\catcode94 % ^
  \catcode96 \the\catcode96 % `
  \catcode`\noexpand\^^A\the\catcode`\^^A\relax}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\catcode64 11 %
\@makeother\! \@makeother\" \@makeother\' \@makeother\* \@makeother\,
\@makeother\- \@makeother\. \@makeother\/ \@makeother\: \@makeother\;
\@makeother\< \@makeother\= \@makeother\> \@makeother\? \@makeother\`
\catcode94 7 %
\catcode`\^^A=14 %
%    \end{macrocode}
%
%
% \subsubsection{Constants}
%
%  \begin{macro}{\XC@@}
% Macro consisting of the macro |\\XC@@|, serves as a delimiter.
%    \begin{macrocode}
\edef\XC@@{\expandafter\noexpand\csname\string\XC@@\endcsname}
%    \end{macrocode}
%  \end{macro}
%
%
% \subsubsection{Switches}
%
%  \begin{macro}{\ifcolors@}
% This boolean can be tested by higher level macros that may want to alter their behaviour if a monochrome driver is being used.
%    \begin{macrocode}
\newif\ifcolors@ \colors@true
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\ifcolorerrors@}
% Controls whether missing color models/names result in error or warning messages.
%    \begin{macrocode}
\newif\ifcolorerrors@
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\ifglobalcolors}
% Controls whether |\definecolor| and |\colorlet| generate global or local color definitions.
%    \begin{macrocode}
\newif\ifglobalcolors \globalcolorsfalse
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifdefinecolors}
% Controls whether |\definecolorset| should \emph{define} or \emph{prepare} colors.
%    \begin{macrocode}
\newif\ifdefinecolors \definecolorstrue
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifconvertcolorsD}
% \begin{macro}{\ifconvertcolorsU}
% Control whether conversion to target models take place at \emph{definition} time (|\ifconvertcolorsD|) and/or \emph{usage} (|\ifconvertcolorsU|).
%    \begin{macrocode}
\newif\ifconvertcolorsD
\newif\ifconvertcolorsU
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifblendcolors}
% \begin{macro}{\ifmaskcolors}
% Control whether colors are to be blended and/or masked at display time.
%    \begin{macrocode}
\newif\ifblendcolors
\newif\ifmaskcolors
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifXC@@fbox}
% \begin{macro}{\ifXC@@tst}
% Auxiliary test variables.
%    \begin{macrocode}
\newif\ifXC@@fbox \XC@@fboxtrue
\newif\ifXC@@tst
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Error handling}
%
% \begin{macro}{\c@lor@error}
% Multi-purpose error handler (issues warnings instead of errors if the \Option{hideerrors} option is used).
% This command is used already in the options section.
%    \begin{macrocode}
\def\c@lor@error#1%
 {\ifcolorerrors@\PackageError{xcolor}{Undefined color #1}\@ehc
  \else\PackageWarning{xcolor}{Undefined color #1}\fi}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Macro concatenation}
%
% \begin{macro}{\XC@append}
%   \marg{cmd}\marg{token list}\\
% Append \Meta{token list} to the definition of \Meta{cmd}.
% This command is used already in the options section.
%    \begin{macrocode}
\def\XC@append#1#2%
 {\ifx#1\@undefined\def#1{#2}\else\ifx#1\relax\def#1{#2}\else
  \toks@\expandafter{#1#2}\edef#1{\the\toks@}\fi\fi}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Macro definition}
%
% The following |\XC@let@..| commands mimic \LaTeX3's coding syntax for the type of arguments used:
% the `c' type is for brace delimited arguments which turn into a control sequence inside |\csname ... \endcsname|, whereas `N' is just a single token.
% Thanks to \People{Morten}{H\o gholm} for pointing me to that.
%
% \begin{macro}{\XC@let@cc}
%   \marg{target character string}\marg{source character string}\\
% Performs |\let\|\Meta{target character string}|=\|\Meta{source character string}.
%    \begin{macrocode}
\def\XC@let@cc#1{\expandafter\XC@let@Nc\csname#1\endcsname}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@namelet}
% This is provided for compatibility reasons only, although deprecated because of a name clash with \Package{memoir}.
%    \begin{macrocode}
\providecommand*\@namelet[1]{\expandafter\XC@let@Nc\csname#1\endcsname}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@let@Nc}
%   \marg{target name}\marg{source character string}\\
% Performs |\let|\Meta{target name}|=\|\Meta{source character string}.
% Formerly called |\@@namelet|.
%    \begin{macrocode}
\def\XC@let@Nc#1#2{\expandafter\let\expandafter#1\csname#2\endcsname}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@let@cN}
%   \marg{target character string}\marg{source name}\\
% Performs |\let\|\Meta{target character string}|=|\Meta{source name}.
%    \begin{macrocode}
\def\XC@let@cN#1{\expandafter\let\csname#1\endcsname}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@namexdef}
%   \marg{character string}\marg{code}\\
% Performs |\xdef\|\Meta{character string}|{|\Meta{code}|}|.
% Similar to the \LaTeX{} internal |\@namedef| command.
%    \begin{macrocode}
\def\@namexdef#1{\expandafter\xdef\csname #1\endcsname}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\aftergroupdef}
% \begin{macro}{\aftergroupedef}
%   \marg{cmd}\marg{code}\\
% Defines \meta{cmd} with the first-level or complete expansion of \meta{code} after the end of the current group.
%    \begin{macrocode}
\def\aftergroupdef#1#2%
 {\expandafter\endgroup\expandafter\def\expandafter#1\expandafter{#2}}
\def\aftergroupedef#1#2%
 {\edef\@@tmp{\def\noexpand#1{#2}}\expandafter\endgroup\@@tmp}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\XC@edef}
% \begin{macro}{\XC@mdef}
% \begin{macro}{\XC@sdef}
%   \marg{cmd}\marg{code}\\
% Defines \Meta{cmd} as a safe expansion of \Meta{code}; needed for color expressions in certain languages.
% The second form is a streamlined version that takes only care of active `|/|' and `|:|' characters that may occur in \Meta{model-list} and \Meta{spec-list} arguments.
% The third form defines a sanitized expansion without considering active characters.
% It is faster since it needs no grouping operation.
%    \begin{macrocode}
\begingroup
\catcode`\!=13 \catcode`\:=13 \catcode`\-=13 \catcode`\+=13
\catcode`\;=13 \catcode`\/=13 \catcode`\"=13 \catcode`\>=13
\gdef\XC@edef#1#2%
 {\begingroup
  \ifnum\catcode`\!=13 \edef!{\string!}\fi
  \ifnum\catcode`\:=13 \edef:{\string:}\fi
  \ifnum\catcode`\-=13 \edef-{\string-}\fi
  \ifnum\catcode`\+=13 \edef+{\string+}\fi
  \ifnum\catcode`\;=13 \edef;{\string;}\fi
  \ifnum\catcode`\"=13 \edef"{\string"}\fi
  \ifnum\catcode`\>=13 \edef>{\string>}\fi
  \edef#1{#2}\@onelevel@sanitize#1\aftergroupdef#1#1}
\gdef\XC@mdef#1#2%
 {\begingroup
  \ifnum\catcode`\/=13 \edef/{\string/}\fi
  \ifnum\catcode`\:=13 \edef:{\string:}\fi
  \edef#1{#2}\@onelevel@sanitize#1\aftergroupdef#1#1}
\endgroup
\def\XC@sdef#1#2{\edef#1{#2}\@onelevel@sanitize#1}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Conditional processing}
%
% \begin{macro}{\@ifxempty}
%   \marg{arg}\marg{empty}\marg{non-empty}\\
% Tests without expanding, whether the argument \Meta{arg} is empty and executes the following code accordingly; \Meta{arg} must not start with the token |\XC@@|.
% Can also be used within |\edef|.
%    \begin{macrocode}
\def\@ifxempty#1{\@@ifxempty#1\@@ifxempty\XC@@}
\def\@@ifxempty#1#2\XC@@
 {\ifx#1\@@ifxempty
  \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@ifxcase}
%   \marg{cmd}|{{|\Meta[1]{cmd}|}{|\Meta[1]{code}|}...{|\Meta[n]{cmd}|}{|\Meta[n]{code}|}}|\marg{default code}\\
% Performs the test |\ifx|\Meta{cmd}\Meta[k]{cmd} for $k=1,\dots,n$.
% If for some $k$ the test is `true', then the attached code \Meta[k]{code} is executed.
% If all tests are `false', then \Meta{default code} is executed.
%    \begin{macrocode}
\long\def\XC@ifxcase#1#2#3%
 {\long\def\@@tmp##1##2%
   {\ifx#1##1%
      \toks@{##2}\expandafter\remove@to@nnil\else\expandafter\@@tmp\fi}%
  \@@tmp#2#1{#3}\@nnil\the\toks@}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@ifcase}
%   \marg{str}|{{|\Meta[1]{str-list}|}{|\Meta[1]{code}|}...{|\Meta[n]{str-list}|}{|\Meta[n]{code}|}}|\marg{default code}\\
% Tests whether \Meta{str} appears in one of the comma-separated lists \Meta[k]{str-list}.
% Performs the test |\if|\Meta{str}\Meta[kl]{str} for $k=1,\dots,n$ and $l=1,\ldots,m_n$.
% If for some $k,l$ the test is `true', then the attached code \Meta[k]{code} is executed.
% If all tests are `false', then \Meta{default code} is executed.
%    \begin{macrocode}
\long\def\XC@ifcase#1#2#3%
 {\long\def\@@tmp##1##2%
   {\@expandtwoargs\in@{,#1,}{,##1,}\ifin@
      \toks@{##2}\expandafter\remove@to@nnil\else\expandafter\@@tmp\fi}%
  \@@tmp#2{#1}{#3}\@nnil\the\toks@}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Package options}
%
% \begin{macro}{\XC@@opt}
% Initialise the macro to hold the names of \emph{executed} \XCP{} options.
%    \begin{macrocode}
\def\XC@@opt{,}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ifXCopt}
%   \marg{option}\marg{executed}\marg{not executed}\\
% Performs action dependent on whether a specific \XCP{} option has been executed or not.
%    \begin{macrocode}
\def\@ifXCopt#1%
 {\@expandtwoargs\in@{,#1,}{\XC@@opt}%
  \ifin@\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@@pkg}
% Initialise the macro to hold the names of packages that are to be loaded by \XC.
%    \begin{macrocode}
\let\XC@@pkg\relax
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DeclareOption}
% |\DeclareOption| has to be redefined in order to collect every executed package option in |\XC@@opt|.
% This is being restored immediately before |\ProcessOptions|; thus, other packages use the original definition.
%    \begin{macrocode}
\let\XC@declareoption\@declareoption
\long\def\@declareoption#1#2%
 {\XC@declareoption{#1}{\edef\XC@@opt{\XC@@opt#1,}#2}}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Color model selection}
%
% \begin{macro}{\selectcolormodel}
%   \marg{num model}\\
% Determines the target model for color definitions with |\definecolor| and friends.
%    \begin{macrocode}
\def\selectcolormodel#1%
 {\@ifundefined{XC@mod@#1}%
   {\c@lor@error{target model `#1'}}%
   {\expandafter\ifx\csname XC@mod@#1\endcsname\XC@mod@natural
      \def\XC@tgt@mod##1{##1}\convertcolorsDfalse\convertcolorsUfalse
    \else\expandafter\ifx\csname XC@mod@#1\endcsname\XC@mod@named
      \c@lor@error{target model `#1'}
    \else
      \edef\XC@tgt@mod##1{#1}\convertcolorsDtrue\convertcolorsUtrue
    \fi\fi}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@mod@Hsb}
% \begin{macro}{\XC@mod@tHsb}
% \begin{macro}{\XC@mod@ignore}
% \begin{macro}{\XC@mod@named}
% \begin{macro}{\XC@mod@ps}
% \begin{macro}{\XC@mod@wave}
% \begin{macro}{\XC@mod@natural}
% \begin{macro}{\XC@mod@rgb}
% \begin{macro}{\XC@mod@cmy}
% \begin{macro}{\XC@mod@cmyk}
% \begin{macro}{\XC@mod@hsb}
% \begin{macro}{\XC@mod@gray}
% \begin{macro}{\XC@mod@RGB}
% \begin{macro}{\XC@mod@HTML}
% \begin{macro}{\XC@mod@HSB}
% \begin{macro}{\XC@mod@Gray}
% Put model names into commands and define package options
% \Option{natural}, \Option{rgb}, \Option{cmy}, \Option{cmyk}, \Option{hsb}, \Option{gray}, \Option{RGB}, \Option{HTML}, \Option{HSB}, \Option{Gray}.
%    \begin{macrocode}
\@tfor\@@tmp:={Hsb}{tHsb}{ignore}{named}{ps}{wave}\do
 {\expandafter\XC@sdef\csname XC@mod@\@@tmp\endcsname{\@@tmp}}
%    \end{macrocode}
%
%    \begin{macrocode}
\@tfor\@@tmp:={natural}{rgb}{cmy}{cmyk}{hsb}{gray}{RGB}{HTML}{HSB}{Gray}\do
 {\expandafter\XC@sdef\csname XC@mod@\@@tmp\endcsname{\@@tmp}%
  \edef\@@tmp
   {\noexpand\DeclareOption{\@@tmp}{\noexpand\selectcolormodel{\@@tmp}}}%
  \@@tmp}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% The \Option{monochrome} option should be used \emph{in addition} to one of the standard driver options.
%    \begin{macrocode}
\DeclareOption{monochrome}
 {\ExecuteOptions{hideerrors}%
  \AtEndOfPackage
   {\colors@false
    \def\set@color{\c@lor@special\m@ne
      {color push \current@color}\aftergroup\reset@color}%
    \def\reset@color{\c@lor@special\m@ne{color pop}}%
    \def\set@page@color{\c@lor@special\m@ne{background \current@color}}}}
%    \end{macrocode}
%
%
% \subsubsection{Sets of predefined colors}
%
% \begin{macro}{\XC@@names}
% Initialise the macro to hold the names of files that contain predefined colors; these files are loaded near to the end of this package.
%    \begin{macrocode}
\let\XC@@names\relax
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\colornameprefix}
% \begin{macro}{\XC@@nameprefix}
% Initialise the macro to hold the string that is prefixed to driver-specific color names.
% Save the value for later restore.
%    \begin{macrocode}
\providecommand*\colornameprefix{XC@}
\let\XC@@nameprefix\colornameprefix
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\XC@declarenames}
%   \marg{base name}\marg{file name}\marg{initial commands}\\
% Construct package options for color names.
%    \begin{macrocode}
\def\XC@declarenames#1#2#3%
 {\DeclareOption{#1}{\XC@append\XC@@names
   {#3\definecolorstrue\input{#2.def}\definecolorstrue
    \let\colornameprefix\XC@@nameprefix}}
  \DeclareOption{#1*}{\XC@append\XC@@names
   {#3\definecolorsfalse\input{#2.def}\definecolorstrue
    \let\colornameprefix\XC@@nameprefix}}}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\XC@declarenames{dvipsnames}{dvipsnam}{\let\colornameprefix\@empty}
\XC@declarenames{svgnames}{svgnam}{}
\XC@declarenames{x11names}{x11nam}{}
\XC@declarenames{hksnames}%
 {hks\ifcase\paperquality k\or n\or k\or z\else n\fi nam}{}
\XC@declarenames{pmsnames}{pmsnam}{}
\XC@declarenames{ralnames}{ralnam}{}
%    \end{macrocode}
%
%
% \subsubsection{Support for other packages}
%
% Use this option to load \People{David P.}{Carlisle}'s \Package{colortbl} package:
%    \begin{macrocode}
\DeclareOption{table}{\XC@append\XC@@pkg{\RequirePackage{colortbl}}}
%    \end{macrocode}
%
% Use this option to load \People{Heiko}{Oberdiek}'s \Package{pdfcolmk} package:
%    \begin{macrocode}
\DeclareOption{fixpdftex}{\XC@append\XC@@pkg{\RequirePackage{pdfcolmk}}}
%    \end{macrocode}
%
% \begin{macro}{\KV@Hyp@xcitebordercolor}
% \begin{macro}{\KV@Hyp@xfilebordercolor}
% \begin{macro}{\KV@Hyp@xlinkbordercolor}
% \begin{macro}{\KV@Hyp@xmenubordercolor}
% \begin{macro}{\KV@Hyp@xpagebordercolor}
% \begin{macro}{\KV@Hyp@xrunbordercolor}
% \begin{macro}{\KV@Hyp@xurlbordercolor}
% \begin{macro}{\KV@Hyp@xpdfborder}
% Use this option to define the extended keys for the \Package{hyperref} package.
%    \begin{macrocode}
\DeclareOption{hyperref}
 {\@tfor\@@tmp:={cite}{file}{link}{menu}{page}{run}{url}\do
   {\expandafter\edef\csname KV@Hyp@x\@@tmp bordercolor\endcsname #1%
     {\noexpand\XC@bordercolor{\@@tmp}{#1}}}%
  \AtEndOfPackage
   {\GetGinDriver\def\KV@Hyp@xpdfborder#1{\edef\@pdfborder{#1}}%
    \@tfor\@@tmp:={dvips}\do
     {\ifx\GinDriver\@@tmp
       \def\KV@Hyp@xpdfborder#1%
        {\edef\@pdfborder{#1}\expandafter\XC@pdfborder\@pdfborder\relax}%
      \@break@tfor\fi}}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Driver options}
%
% \begin{macro}{\Gin@driver}
% Initialise the macro to hold the driver file name.
%    \begin{macrocode}
\providecommand*\Gin@driver{}
%    \end{macrocode}
%
% Drivers that come with their individual definition files:
%    \begin{macrocode}
\@tfor\@@tmp:={dvipdf}{dvipdfm}{dvipdfmx}{dvips}{dvipsone}{dviwin}%
              {emtex}{pctex32}{pctexhp}{pctexps}{pctexwin}{pdftex}%
              {tcidvi}{textures}{truetex}{vtex}{xetex}\do
 {\edef\@@tmp{\noexpand\DeclareOption{\@@tmp}%
    {\def\noexpand\Gin@driver{\@@tmp.def}}}%
  \@@tmp}
%    \end{macrocode}
%
% Drivers that are derivatives of others:
%    \begin{macrocode}
\DeclareOption{dviwindo}{\ExecuteOptions{dvipsone}}
\DeclareOption{oztex}{\ExecuteOptions{dvips}}
\DeclareOption{xdvi}{\ExecuteOptions{dvips,monochrome}}
%    \end{macrocode}
%
% Options used by (some) drivers.
%    \begin{macrocode}
\DeclareOption{xcdraw}{\def\XC@@xcd@{1}}
\DeclareOption{noxcdraw}{\def\XC@@xcd@{-1}}
\DeclareOption{fixinclude}{\def\XC@@xcf@{1}}
\DeclareOption{prologue}{\def\XC@@xcp@{1}}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Other options}
%
% Switch to original kernel |\fbox| command instead of new \XC{} version.
%    \begin{macrocode}
\DeclareOption{kernelfbox}{\XC@@fboxfalse}
%    \end{macrocode}
%
% These options control how non-existing colors are treated:
%    \begin{macrocode}
\DeclareOption{showerrors}{\colorerrors@true}
\DeclareOption{hideerrors}{\colorerrors@false}
%    \end{macrocode}
%
% The \Option{debugshow} option turns on debugging info (perhaps).
%    \begin{macrocode}
\DeclareOption{debugshow}{\catcode`\^^A=9 \let\GDebug\typeout}
%    \end{macrocode}
%
% All other options (including \LC's \oOption{usenames}, \oOption{nodvipsnames}) are being ignored.
%    \begin{macrocode}
\DeclareOption*%
 {\PackageInfo{xcolor}{Package option `\CurrentOption' ignored}}
%    \end{macrocode}
%
% Choose default options:
%    \begin{macrocode}
\def\XC@@xcd@{-1}
\def\XC@@xcf@{-1}
\def\XC@@xcp@{-1}
\ExecuteOptions{natural,showerrors}
%    \end{macrocode}
%
%
% \subsubsection{Processing options}
%
% A local configuration file may declare more options.
% It should also make one driver option the default, by calling |\ExecuteOptions| with the appropriate option.
%    \begin{macrocode}
\InputIfFileExists{color.cfg}{}{}
%    \end{macrocode}
%
% After the options are processed, load the appropriate driver file.
% If a site wants a default driver (e.g., \Option{dvips}) it just needs to put |\ExecuteOptions{dvips}| in a \File{color.cfg} file.
%    \begin{macrocode}
\let\@declareoption\XC@declareoption
\ProcessOptions\relax
%    \end{macrocode}
%
% \begin{macro}{\XC@@drv}
% Holds the name of the loaded driver (without \File{.def} extension).
%    \begin{macrocode}
\edef\Gin@driver{\Gin@driver}
\if!\Gin@driver!
  \PackageError{xcolor}
    {No driver specified}
    {You should make a default driver option in a file \MessageBreak
     color.cfg\MessageBreak
     eg: \protect\ExecuteOptions{dvips}}
\else
  \PackageInfo{xcolor}{Driver file: \Gin@driver}
  \@ifundefined{ver@\Gin@driver}{\input{\Gin@driver}}{}
  \def\@@tmp#1.def{\def\XC@@drv{#1}}
  \expandafter\@@tmp\Gin@driver
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@@xcd@}
% \begin{macro}{\XC@@xcf@}
% \begin{macro}{\XC@@xcp@}
% These are used firstly by the \Option{xcdraw} and \Option{prologue} options, indicating whether either option is switched on or off.
% Secondly, the macros serve as test variables for |\ifcase| expressions, storing the intended type of output: $-1=\text{dvi}, 0=\text{ps}, 1=\text{pdf}$.
%    \begin{macrocode}
\count@\XC@@xcd@ \advance\count@\XC@@xcf@ \advance\count@\XC@@xcp@\relax
\ifnum\count@>-3
%    \end{macrocode}
%
% \begin{macro}{\XC@special}
%   \meta{code}\\
% Driver-specific variant of |\special|.
% Even if the intended type of output is the same (e.g., pdf), the |\special| commands may differ.
%    \begin{macrocode}
  \XC@ifcase\XC@@drv
   {{dvips,pctex32}%
    {\def\@tempa{0}
     \def\XC@special#1{\special{ps:XC!b}\special{"#1}\special{ps:XC!e}}}%
    {pdftex}%
    {\def\@tempa{1}
     \def\XC@special#1{\pdfliteral{ q #1 Q }}}%
    {dvipdfm}%
    {\def\@tempa{1}
     \def\XC@special#1{\special{pdf: content #1}}}%
   }{\def\@tempa{-1}}
%    \end{macrocode}
% \end{macro}
%
% Since the options are independent of each other, we have to adjust the affiliated test variables independently as well.
%    \begin{macrocode}
  \ifnum\XC@@xcd@>\m@ne\let\XC@@xcd@\@tempa\fi
  \ifnum\XC@@xcf@>\m@ne\let\XC@@xcf@\@tempa\fi
  \ifnum\XC@@xcp@>\m@ne\let\XC@@xcp@\@tempa\fi
%    \end{macrocode}
%
%    \begin{macrocode}
  \ifnum\@tempa=0 \AtBeginDvi{\special{header=xcolor.pro}}\fi
  \ifcase\XC@@xcf@
    \AtBeginDvi{\special{! XCfixnormalscale}}
  \fi
  \ifcase\XC@@xcp@
    \AtBeginDvi{\special{header=\jobname.xcp}}
    \newwrite\XC@@xcp\immediate\openout\XC@@xcp=\jobname.xcp
    \immediate\write\XC@@xcp{\@percentchar!}
    \immediate\write\XC@@xcp{TeXDict begin}
    \AtEndDocument
     {\immediate\write\XC@@xcp{end}\immediate\closeout\XC@@xcp}
  \fi
%    \end{macrocode}
%
% End of driver-specific part.
%    \begin{macrocode}
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Required packages}
%
% All packages within the list |\XC@pkg|
% receive a pretended \LC.
%    \begin{macrocode}
\@namedef{ver@color.sty}{1999/02/16}
\XC@@pkg
%    \end{macrocode}
%
%
% \subsection{Macro tools}
%
% \subsubsection{General tools}
%
% \begin{macro}{\@secondoffive}
% \begin{macro}{\@thirdoffive}
% Argument grabbing, similar to \LaTeX{} kernel.
%    \begin{macrocode}
\long\def\@secondoffive#1#2#3#4#5{#2}
\long\def\@thirdoffive#1#2#3#4#5{#3}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\xglobal}
% \begin{macro}{\xglobal@test}
% If |\foo| occurs in the token list |\xglobal@@|, then the command |\xglobal\foo| will set the switch |\xglobal@true| which can be used inside |\foo| to determine whether certain definitions are to be made explicitely global.
% |\foo| is responsible for resetting |\xglobal@false| in order to avoid side effects.
% To include |\foo| in the magic list, simply say |\XC@append\xglobal@list{\foo}|.
% If |\foo| is not in the list, |\xglobal\foo| will behave like |\global\foo|, thus |\xglobal\let| will be like |\global\let| etc.
%    \begin{macrocode}
\def\xglobal{\xglobal@stop\begingroup\futurelet\@@tok\xglobal@test}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\xglobal@test
 {\expandafter\@tfor\expandafter\@@tmp
   \expandafter:\expandafter=\xglobal@list\do
    {\expandafter\ifx\@@tmp\@@tok
       \aftergroup\let\aftergroup\xglobal@\@break@tfor\fi}%
  \endgroup\global}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\xglobal@stop}
% Resetting |\xglobal@|.
%    \begin{macrocode}
\def\xglobal@stop{\let\xglobal@\@empty}
\xglobal@stop
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\xglobal@list}
% Initial list of commands that may be prefixed by |\xglobal|.
%    \begin{macrocode}
\def\xglobal@list
 {\definecolor\definecolors\definecolorset\colorlet\providecolor
  \providecolors\providecolorset\blendcolors\maskcolors
  \substitutecolormodel}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\xglobalize@}
% Globalisation command: makes a local definition global.
%    \begin{macrocode}
\def\xglobalize@#1{\ifx\xglobal@\global\global\let#1#1\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\GetGinDriver}
% Transforms the chosen driver option ready for \Package{hyperref}.
%    \begin{macrocode}
\def\GetGinDriver
 {\@tempswafalse
  \@tfor\@@tmp:={dvips}{pdftex}{dvipdf}{dvipdfm}{dvipsone}{vtex}{textures}%
  \do{\ifx\XC@@drv\@@tmp\@tempswatrue\@break@tfor\fi}%
  \edef\GinDriver{\if@tempswa\XC@@drv\else hypertex\fi}}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{String manipulation}
%
% \begin{macro}{\@hex@Hex}
%   \Meta{hex-string}|\relax|\\
% Converts \Meta{hex-string} to a string where all letters a--f are changed into their uppercase variants.
% All other letters are left unchanged.
% May be used inside |\edef|.
%    \begin{macrocode}
\def\@hex@Hex#1{\ifx#1\relax\else\expandafter\@hex@@Hex\expandafter#1\fi}
\def\@hex@@Hex#1%
 {\if a#1A\else \if b#1B\else \if c#1C\else \if d#1D\else
  \if e#1E\else \if f#1f\else #1\fi\fi\fi\fi\fi\fi \@hex@Hex}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@strip@comma}
%   \Meta[1]{string}|,|\Meta[2]{string}|,...,|\Meta[n]{string}|,,\@nnil|\\
% Converts a comma-separated list into a space-separated list.
% The evaluation stops at the first empty argument, skipping all remaining tokens until (and including) |\@nnil|.
% Thus, the list to be converted should always contain at least one `|,,|' sequence.
% May be used inside |\edef|.
%    \begin{macrocode}
\def\XC@strip@comma#1,#2%
 {\ifx,#2%
    #1\expandafter\remove@to@nnil\else#1 \expandafter\XC@strip@comma\fi
  #2}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@replace}
%   \marg{cmd}\marg{search}\marg{replace}\\
% Replace all occurences of \meta{search} within the first-level expansion of \meta{cmd} by \meta{replace} and save the result in \meta{cmd}.
% The replacement is recursive, so don't put the search pattern into the replacement text!
% Note that this macro is incapable of seeing `into' braces.
% The code and its explanation is taken from \People{Donald}{Arseneau}'s \Package{url} package \cite{url}, with only minor changes and renamings applied.
% The original name of the game is |\Url@Edit|.
% Thanks to \People{Donald}{Arseneau} for giving me valuable hints.
%    \begin{macrocode}
{\catcode`Q=3
 \gdef\XC@replace#1#2#3%
  {\begingroup
%    \end{macrocode}
%
% If finished, then remove |\@empty|'s and redefine macro else, re-iterate.
%    \begin{macrocode}
   \def\XC@repl@ce##1#2##2Q##3%
    {\@ifxempty{##2}{\XC@r@pl@ce##1Q}{\XC@repl@ce##1##3##2Q{##3}}}%
   \def\XC@r@pl@ce##1\@empty Q%
    {\expandafter\endgroup\expandafter\def\expandafter#1\expandafter{##1}}%
%    \end{macrocode}
%
% The leading |\@empty| preserves braces, as does the trailing pattern.
%    \begin{macrocode}
   \expandafter\XC@repl@ce\expandafter\@empty #1\@empty#2Q{#3}}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@clean}
%   \marg{cmd}\\
% Makes a proper comma-separated list from \meta{cmd}'s contents and stores it again in \meta{cmd}.
% Firstly, all commas are changed into spaces, secondly, `|. |' strings are changed to spaces.
% Thirdly, non-trailing spaces are turned into commas (using a technique similar to \LaTeX's |\zap@space|).
% Finally, the two leading commas are gobbled.
% For example, `| 1 2. ,  3 |' is mapped to `|1,2,3|'.
%    \begin{macrocode}
\def\XC@clean#1%
 {\edef#1{ #1 }%
  \XC@cle@n#1,{ }\XC@cle@n#1{. }{ }\XC@cle@n#1{ },%
  \edef#1{\expandafter\@gobbletwo#1}}
\def\XC@cle@n#1#2#3%
 {\def\XC@cl@@n##1#2##2{#3##1\ifx##2\@empty\else\expandafter\XC@cl@@n\fi##2}%
  \edef#1{\expandafter\XC@cl@@n#1#2\@empty}}%
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Scalar arithmetic}
%
% \begin{macro}{\rdivide}
%   \marg{dimension register}\marg{div}\\
% Divides \Meta{dimension register} by a real number \Meta{div}, which may also be buried in a dimension (register), and stores the resulting rounded dimension in \Meta{dimension register}.
% The denominator \Meta{div} is assumed to be non-zero.
%    \begin{macrocode}
\def\rdivide#1#2%
 {\begingroup\toks@{#1}\edef\@@tmp{\noexpand\@tempdima\the#1}%
  \@defaultunits\@tempdimb=#2pt\relax\@nnil \@@tmp\relax
  \ifdim\@tempdima<\z@ \@tempdima-\@tempdima\def\@sign{-}\else
    \def\@sign{}\fi
  \ifdim\@tempdimb<\z@ \@tempdimb-\@tempdimb\edef\@sign{\@sign-}\fi
  \ifdim\@tempdima<.1\maxdimen \ifdim\@tempdimb<.01\maxdimen
    \lshift\@tempdima \lshift\@tempdimb \fi\fi
  \@tempcnta=\@tempdima \@tempcntb=\@tempdimb
  \count@=\@tempcnta \divide\count@\@tempcntb
  \edef\@@tmp{\number\count@.}%
  \@tempswatrue  \@rdivide \@rdivide \@rdivide \@rdivide \@rdivide
  \@tempswafalse \@rdivide
  \dimen@\@@tmp\p@ \ifnum\count@>4\advance\dimen@1sp\fi
  \dimen@\@sign\dimen@
  \edef\@@tmp{\the\toks@\the\dimen@}%
  \expandafter\endgroup\@@tmp}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@rdivide
 {\multiply\count@\@tempcntb \advance\@tempcnta-\count@
  \multiply\@tempcnta10 \count@=\@tempcnta \divide\count@\@tempcntb
  \if@tempswa\edef\@@tmp{\@@tmp\number\count@}\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rmultiply}
%   \marg{dimension register}\marg{dec}\\
% Multiplies \Meta{dimension register} by \Meta{dec} and stores the resulting dimension in \Meta{dimension register}.
%    \begin{macrocode}
\def\rmultiply#1#2%
 {\begingroup
  \edef\@@mul{#2}\@tempdima\the#1\relax
  \afterassignment\@tempdimb\@tempcntb=\@@mul\p@
  \ifdim\@tempdima<\z@ \@tempdima-\@tempdima\def\@sign{-}\else
    \def\@sign{}\fi
  \ifnum\@tempcntb<\z@ \@tempcntb-\@tempcntb\edef\@sign{\@sign-}\fi
  \lshift\@tempdima \dimen@\z@
  \expandafter\@rmultiply\@@mul.0.\@nil
  \advance\dimen@\@tempcntb\@tempdima \rshift\dimen@
  \dimen@\@sign\dimen@
  \edef\@@tmp{#1\the\dimen@}%
  \expandafter\endgroup\@@tmp}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@rmultiply#1.#2.#3\@nil
 {\def\@@tmp{}%
  \@tfor\@@mul:=#2\do
   {\edef\@@tmp
     {\advance\dimen@\@@mul\@tempdima \divide\dimen@10 \@@tmp}}%
  \@@tmp}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lshift}
% \begin{macro}{\llshift}
%   \marg{dimension register}\\
% Multiplies \Meta{dimension register} safely by 10 resp. 100.
%    \begin{macrocode}
\def\lshift#1{#1\expandafter\lshift@\the#1}
\def\llshift#1{\lshift#1\lshift#1}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\lshiftnum}
% \begin{macro}{\llshiftnum}
%   \marg{decimal number}\\
% Multiplies \Meta{decimal number} by 10 resp. 100.
%    \begin{macrocode}
\def\lshiftnum#1{\expandafter\lshiftnum@#1.00.:}
\def\lshiftnum@#1.#2#3.#4:{#1#2\ifnum0#3>\z@.#3\fi}
\def\llshiftnum#1{\expandafter\llshiftnum@#1\@empty.00.:}
\def\llshiftnum@#1.#2#3#4.#5:%
 {#1#2\ifnum0#3>\z@#3\else0\fi\ifnum0#4>\z@.#4\fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\lshiftset}
% \begin{macro}{\llshiftset}
%   \marg{dimension register}\marg{decimal number}\\
% Multiplies \Meta{decimal number} by 10 resp. 100 and puts it into \Meta{dimension register}.
%    \begin{macrocode}
\def\lshiftset#1#2{\edef\@@XC{\noexpand\lshiftnum{#2}}#1\@@XC\p@}
\def\llshiftset#1#2{\edef\@@XC{\noexpand\llshiftnum{#2}}#1\@@XC\p@}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\rshift}
% \begin{macro}{\rrshift}
%   \marg{dimension register}\\
% Divides \Meta{dimension register} safely by 10 resp. 100.
%    \begin{macrocode}
\def\rshift#1{#1\expandafter\rshift@\the#1}
\def\rrshift#1{\rshift#1\rshift#1}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\lshift}
% \begin{macro}{\llshift}
%   \marg{dec}\\
% Multiplies \Meta{dec}, which may be either a number or something like |\the\dimen@|, safely by 10 resp. 100.
% The following definitions are similar to the way how |\strip@pt| is defined in the \LaTeX{} kernel.
%    \begin{macrocode}
\begingroup
\catcode`P=12
\catcode`T=12
\lowercase
 {\def\@@tmp{\def\lshift@##1.##2##3PT{##1##2\ifnum0##3>\z@.##3\fi\p@}
             \def\rshift@##1.##2PT{\rshift@@##1\relax##2\p@}}}
\expandafter\endgroup\@@tmp
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%    \begin{macrocode}
\def\rshift@@#1#2%
 {\ifx#2\relax.#1\else#1\expandafter\rshift@@\expandafter#2\fi}
%    \end{macrocode}
%
%
% \subsubsection{Vector arithmetic}
%
% \begin{macro}{\XC@inflate}
%   \marg{core model}\marg{first}\marg{second}\marg{cmd}\\
% Constructs an 8-dimensional vector based on two vectors \Meta{first}, \Meta{second} (of common dimension $1,3,4$) and an underlying color model (stored in the macro \Meta{core model}).
% The resulting vector is stored in \Meta{cmd}.
%    \begin{macrocode}
\def\XC@inflate#1#2#3#4%
 {\edef#4{#2,\ifx#1\XC@mod@cmyk #3\else
             \ifx#1\XC@mod@gray ,,,#3,,,\else ,#3,\fi\fi}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@vec}
%   \Meta{a}|,|\Meta{b}|,|\Meta{c}|,|\Meta{d}|,|\Meta{a'}|,|\Meta{b'}|,|\Meta{c'}|,|\Meta{d'}|,|\marg{cmd}\\
% Generic vector calculation for two vectors (of common dimension $1,3,4$), puts the result into \Meta{cmd}.
%    \begin{macrocode}
\def\XC@vec#1,#2,#3,#4,#5,#6,#7,#8,#9%
 {\def\@@tmp{}%
  \XC@vec@{#1}{#5}%
  \ifx,#2,\else
  \XC@vec@{#2}{#6}\XC@vec@{#3}{#7}\ifx,#4,\else\XC@vec@{#4}{#8}\fi\fi
  \aftergroupdef#9\@@tmp}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@vec@@{\edef\@@tmp{\ifx\@@tmp\@empty\else\@@tmp,\fi\strip@pt\dimen@}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@add}
%   \Meta{a}|,|\Meta{b}|,|\Meta{c}|,|\Meta{d}|,|\Meta{a'}|,|\Meta{b'}|,|\Meta{c'}|,|\Meta{d'}|,|\marg{cmd}\\
% Calculates the sum of two vectors (of common dimension $1,3,4$) and puts it into \Meta{cmd}.
%    \begin{macrocode}
\def\XC@add{\begingroup \let\XC@vec@\XC@add@ \XC@vec}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@add@#1#2%
 {\llshiftset\dimen@{#1}\llshiftset\@tempdima{#2}%
  \advance\dimen@\@tempdima \rrshift\dimen@ \XC@vec@@}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@sub}
%   \Meta{a}|,|\Meta{b}|,|\Meta{c}|,|\Meta{d}|,|\Meta{a'}|,|\Meta{b'}|,|\Meta{c'}|,|\Meta{d'}|,|\marg{cmd}\\
% Calculates the difference of two vectors (of common dimension $1,3,4$) and puts it into \Meta{cmd}.
%    \begin{macrocode}
\def\XC@sub{\begingroup \let\XC@vec@\XC@sub@ \XC@vec}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@sub@#1#2{\XC@add@{#1}{-#2}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@mul}
%   \Meta{a}|,|\Meta{b}|,|\Meta{c}|,|\Meta{d}|,|\Meta{a'}|,|\Meta{b'}|,|\Meta{c'}|,|\Meta{d'}|,|\marg{cmd}\\
% Calculates the (component-wise) product of two vectors (of common dimension $1,3,4$) and puts it into \Meta{cmd}.
%    \begin{macrocode}
\def\XC@mul{\begingroup \let\XC@vec@\XC@mul@ \XC@vec}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@mul@#1#2%
 {\llshiftset\dimen@{#1}\rmultiply\dimen@{#2}\rrshift\dimen@ \XC@vec@@}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@mix}
%   \Meta{a}|,|\Meta{b}|,|\Meta{c}|,|\Meta{d}|,|\Meta{a'}|,|\Meta{b'}|,|\Meta{c'}|,|\Meta{d'}|,|\marg{cmd}\\
% Calculates the linear interpolation of two color parameter vectors and puts it into \Meta{cmd}.
% The percentage parameter $p$ is input via register |\dimen@|.
%    \begin{macrocode}
\def\XC@mix%
 {\begingroup
  \@tempdima\dimen@ \@tempdimb100\p@ \advance\@tempdimb-\@tempdima
  \let\XC@vec@\XC@mix@ \XC@vec}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@mix@#1#2%
 {\dimen@#1\@tempdima \advance\dimen@#2\@tempdimb \rrshift\dimen@ \XC@vec@@}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@calc@}
%   \Meta{x}|,|\Meta{y}|,|\Meta{z}|,|\Meta{w}|,|\Meta{dummy}|:|\marg{function}\\
% Performs, dependent on the number of non-empty parameters, |\edef\@@tmp{|$f(x)$|}| or |\edef\@@tmp{|$f(x),f(y),f(z)$|}| or |\edef\@@tmp{|$f(x),f(y),f(z),f(w)$|}|, where the function $f$ is determined by the parameter \Meta{function}.
%    \begin{macrocode}
\def\XC@calc@#1,#2,#3,#4,#5:#6%
 {\XC@let@Nc\@@cmd{XC@calc#6}\@@cmd{#1}\@@tmp
  \ifx,#2,\else
    \@@cmd{#2}\@tempa\@@cmd{#3}\@tempb
    \ifx,#4,%
      \edef\@@tmp{\@@tmp,\@tempa,\@tempb}\else
      \@@cmd{#4}\@tempc\edef\@@tmp{\@@tmp,\@tempa,\@tempb,\@tempc}\fi\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcC}
%   \marg{x}\marg{cmd}\\
% \textbf Complement of $x$: performs |\def|\Meta{cmd}|{|$1-x$|}|.
% Yields exact results for all numbers within $[0,1]$ with 5 decimal digits.
%    \begin{macrocode}
\def\XC@calcC#1#2%
 {\llshiftset\dimen@{-#1}\advance\dimen@100\p@
  \rrshift\dimen@ \XC@calcN{\strip@pt\dimen@}#2}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcD}
%   \marg{x}\marg{cmd}\\
% \textbf Division of $x$ by $s$: performs |\def|\Meta{cmd}|{|$x/s$|}|.
% The parameter $s$ is input via |\@@scl|.
%    \begin{macrocode}
\def\XC@calcD{\XC@c@lcD\@@scl{}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@c@lcD}
%   \marg{s}\marg{string}\marg{x}\marg{cmd}\\
% \textbf Division of $x$ by $s$, appending \Meta{string}: performs |\def|\Meta{cmd}|{|$x/s$\Meta{string}|}|.
%    \begin{macrocode}
\def\XC@c@lcD#1#2#3#4%
 {\dimen@#3\p@ \rdivide\dimen@{#1}\edef#4{\strip@pt\dimen@#2}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcF}
%   \marg{x}\marg{cmd}\\
% \textbf Format $x$ with 5 decimals, no range checks.
%    \begin{macrocode}
\def\XC@calcF#1#2%
 {\edef#2{#1}\expandafter\XC@c@lcF#2.0.:#2}
%    \end{macrocode}
%
% Special treatment of integer part because of so many possible variations ($---.0$, $7$, \dots).
%    \begin{macrocode}
\def\XC@c@lcF#1.#2.#3:#4%
 {\edef#4{\XC@c@@cR#200000:}%
  \dimen@#1.5\p@ \afterassignment\dimen@\count@=\the\dimen@
  \edef#4%
   {\ifnum#4>0 \ifnum\count@=0 \ifdim#1.5\p@<\z@ -\fi\fi\fi
    \number\count@.#4}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcH}
%   \marg{x}\marg{cmd}\\
% \textbf Hexadecimal transformation of $x\in\{0,1,\dots,255\}$: performs |\def|\Meta{cmd}|{|$x_{16}$|}|.
%    \begin{macrocode}
\def\XC@calcH#1#2%
 {\count@#1 \divide\count@\sixt@@n \edef\XC@@tmp{\hexnumber@\count@}%
  \multiply\count@-\sixt@@n \advance\count@#1
  \edef#2{\XC@@tmp\hexnumber@\count@}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcM}
%   \marg{x}\marg{cmd}\\
% \textbf Multiplication of $x$ by $s$ plus rounding: performs |\def|\Meta{cmd}|{|$[s\cdot x+0.5]$|}|.
% The parameter $s$ is input via |\@@scl|.
%    \begin{macrocode}
\def\XC@calcM#1#2%
 {\dimen@#1\p@ \dimen@\@@scl\dimen@ \advance\dimen@.5\p@
  \afterassignment\dimen@\count@=\the\dimen@ \edef#2{\number\count@}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcN}
%   \marg{x}\marg{cmd}\\
% \textbf Normalisation of $x$: similar to |\XC@calcR|, but trailing zeros are eliminated.
%    \begin{macrocode}
\def\XC@calcN#1#2%
 {\XC@calcR{#1}#2\edef#2{\expandafter\XC@c@lcN#200000:}}
%    \end{macrocode}
%
% Gobble trailing zeros.
%    \begin{macrocode}
\def\XC@c@lcN#1.#200000#3:{#1\ifnum0#2=0 \else.#2\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcR}
%   \marg{x}\marg{cmd}\\
% \textbf Reduction of $x$ to the unit interval: performs |\def|\Meta{cmd}|{|$\min\{1,\max\{0,x\}\}$|}|.
% Numbers are output with 5 decimals.
% This could also be done using |\XC@calcF|, followed by a range check, but perhaps less efficiently.
%    \begin{macrocode}
\def\XC@calcR#1#2{\edef#2{#1}\edef#2{\expandafter\XC@c@lcR#2.0.:}}
%    \end{macrocode}
%
% Check interval.
%    \begin{macrocode}
\def\XC@c@lcR#1.#2.#3:%
 {\ifnum#10>0 1.00000\else 0.\ifnum#11<0 00000\else
  \XC@c@@cR#200000:\fi\fi}
%    \end{macrocode}
%
% Normalize to 5 digits.
%    \begin{macrocode}
\def\XC@c@@cR#1#2#3#4#5#6:{#1#2#3#4#5}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcS}
%   \marg{x}\marg{cmd}\\
% \textbf Scaling of $x$ by $s$: performs |\def|\Meta{cmd}|{|$s\cdot x$|}|.
% The parameter $s$ is input via |\@@scl|.
%    \begin{macrocode}
\def\XC@calcS{\XC@c@lcS\@@scl{}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@c@lcS}
%   \marg{s}\marg{string}\marg{x}\marg{cmd}\\
% \textbf Scaling of $x$ by $s$, appending \Meta{string}: performs |\def|\Meta{cmd}|{|$s\cdot x$\Meta{string}|}|.
%    \begin{macrocode}
\def\XC@c@lcS#1#2#3#4%
 {\lshiftset\dimen@{#3}%
  \ifdim#1\p@<100\p@
    \dimen@\lshiftnum#1\dimen@ \rrshift\dimen@ \else
    \dimen@#1\dimen@ \rshift\dimen@ \fi
  \edef#4{\strip@pt\dimen@#2}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcT}
%   \marg{x}\marg{cmd}\\
% \textbf Translate $x$ by $a$ and cut to unit interval: performs |\def|\Meta{cmd}|{|$\min\{1,\max\{0,x+a\}\}$|}|.
% The parameter $a$ is input via |\@@arg|.
%    \begin{macrocode}
\def\XC@calcT#1#2%
 {\lshiftset\dimen@{#1}\advance\dimen@\lshiftnum\@@arg\p@ \rshift\dimen@
  \edef#2%
   {\ifdim\dimen@>\p@1\else\ifdim\dimen@<\z@0\else\strip@pt\dimen@\fi\fi}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@calcU}
%   \marg{x}\marg{cmd}\\
% \textbf Unit interval mapping of $x$: performs |\def|\Meta{cmd}|{|$x-[x]$|}| if $x\neq1$, $1$ otherwise.
%    \begin{macrocode}
\def\XC@calcU#1#2%
 {\dimen@#1\p@
  \ifdim\dimen@=\p@\else
    \afterassignment\dimen@\count@=\the\dimen@
    \relax\ifdim\dimen@=\z@\else
      \ifdim#1\p@<\z@ \dimen@-\dimen@ \advance\dimen@\p@ \fi
    \fi
  \fi
  \edef#2{\strip@pt\dimen@}}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Color definition}
%
% \subsubsection{Constants}
%
% \begin{macro}{\rangeRGB}
% \begin{macro}{\rangeHSB}
% \begin{macro}{\rangeHsb}
% \begin{macro}{\rangetHsb}
% \begin{macro}{\rangeGray}
% Scaling ranges for `integer' and other special models:
%    \begin{macrocode}
\providecommand*\rangeRGB{255}
\providecommand*\rangeHSB{240}
\providecommand*\rangeHsb{360}
\providecommand*\rangetHsb{60,30;120,60;180,120;210,180;240,240}
\providecommand*\rangeGray{15}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\adjustUCRBG}
% Parameters for undercolor-removal (UCR) and black-generation (BG) during \Model{cmy} to \Model{cmyk} conversion:
%    \begin{macrocode}
\providecommand*\adjustUCRBG{1,1,1,1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\paperquality}
% Parameter for choosing different color sets according to the paper quality; yet supported only for the HKS colors.
%    \begin{macrocode}
\providecommand*\paperquality{1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\colorseriescycle}
% Default cycle length for color series:
%    \begin{macrocode}
\providecommand*\colorseriescycle{16}
%    \end{macrocode}
% \end{macro}
%
% Model-dependent base colors:
%    \begin{macrocode}
\def\XC@clr@rgb@white{1,1,1}
\def\XC@clr@cmy@white{0,0,0}
\def\XC@clr@cmyk@white{0,0,0,0}
\def\XC@clr@hsb@white{\@@hue,0,1}
\def\XC@clr@hsb@gray{\@@hue,0,0.5}
\def\XC@clr@hsb@black{\@@hue,0,0}
\def\XC@clr@gray@white{1}
%    \end{macrocode}
%
% \begin{macro}{\XC@met@grad}
% \begin{macro}{\XC@met@last}
% \begin{macro}{\XC@met@step}
% Methods for color series:
%    \begin{macrocode}
\@tfor\@@tmp:={grad}{last}{step}\do
 {\XC@let@cN{XC@met@\@@tmp}\@@tmp}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Colors}\label{sec.definition}
%
% \begin{macro}{\definecolor}
%   \oarg{type}\marg{name}\oarg{prefix}\marg{model-list}\marg{spec-list}\\
% Extends the facilities of \LC's |\definecolor|.
% The optional argument \Meta{type} has currently to be either empty (= normal color definition) or `named' or `ps'.
% \Meta{prefix} is an argument used for the internal driver-dependent representation.
% |\definecolor| creates a new command |\\color@|\Meta{name} that contains the \emph{internal representation}
% |\xcolor@|\marg{type-spec}\marg{driver-spec}\marg{n-model}\marg{n-color-spec} of the color, where
% \begin{itemize}
% \item \Meta{type-spec} is either empty (if \Meta{type} was empty), or a driver-dependent macro or expression (if \Meta{type} was `named', `ps');
% \item \Meta{driver-spec} is a driver-dependent representation of the color, which also depends on \Meta{type};
% \item \Meta{n-model} is either \Meta{model} or the name of another color model, dependent on the desired transformation(s) at definition time;
% \item \Meta{n-color-spec} are the comma-separated normalised parameter values of the color with respect to \Meta{n-model}.
% \end{itemize}
% See table \vref{tab.internal} for some examples.
%    \begin{macrocode}
\def\definecolor{\@testopt{\XC@definecolor}{}}
\def\XC@definecolor[#1]#2%
 {\@testopt{\XC@definec@lor[#1]{#2}}\colornameprefix}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@definec@lor[#1]#2[#3]#4#5%
 {\begingroup
  \XC@sdef\@@cls{#1}\XC@edef\@@nam{#2}\edef\colornameprefix{#3}%
  \XC@logdef\@@nam
  \XC@getmodclr02{#4}{#5}{\let\@@tmp\relax}%
   {\ifx\@@mod\XC@mod@named
      \XC@c@l@rlet\@@nam\@@clr
    \else
      \ifx\@@cls\XC@mod@ps
        \edef\@@drv{\@@mod\space\@@clr}\def\@@hue{0}%
        \edef\@@clr{\@nameuse{XC@clr@\@@mod @white}}%
      \else
        \ifconvertcolorsD
          \let\@@tmp\@@mod\XC@sdef\@@mod{\XC@tgt@mod\@@tmp}%
          \convertcolorspec\@@tmp\@@clr\@@mod\@@clr
        \fi
        \XC@coremodel\@@mod\@@clr
%    \end{macrocode}
%
% Determine driver-dependent color definition:
%    \begin{macrocode}
        \csname color@\@@mod\expandafter\endcsname
          \expandafter\@@drv\expandafter{\@@clr}%
%    \end{macrocode}
%
% Handle prologue and `named' colors:
%    \begin{macrocode}
        \ifcase\XC@@xcp@
          \immediate\write\XC@@xcp{/\colornameprefix\@@nam{\expandafter
            \XC@strip@comma\@@clr,,\@nnil}XC\@@mod}%
          \let\@@cls\XC@mod@named
        \fi
        \ifx\@@cls\@empty\else
          \let\@@tmp\@@cls
          \@nameuse{define@color@\@@cls}\@@nam\@@drv
          \csname color@\@@tmp\expandafter\endcsname
            \expandafter\@@drv\expandafter{\@@nam}%
        \fi
      \fi
%    \end{macrocode}
%
% Finally write all information into macro |\\color@|\Meta{name}:
%    \begin{macrocode}
      \toks@\expandafter{\@@drv}%
      \edef\@@tmp
       {\ifglobalcolors\global\else\xglobal@\fi
        \noexpand\@namedef{\string\color@\@@nam}%
         {\noexpand\xcolor@{\@@cls}{\the\toks@}{\@@mod}{\@@clr}}}%
    \fi}%
  \expandafter\endgroup\@@tmp\xglobal@stop}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@getmodclr}
%   \marg{mod-opt}\marg{clr-opt}\marg{model-list}\marg{spec-list}\marg{undefined}\marg{defined}\\
% Depending on \Meta{mod-opt}, different tasks are performed:
% \begin{itemize}
% \item[0:] Retrieve color model and target model from \Meta{model-list} if |\XC@@getmod| is `true'.
% \item[1:] Retrieve color model and target model from \Meta{model-list} always.
% \end{itemize}
% The color model is stored in |\@@mod|, its position in |\XC@@pos|, a possible target model in |\@@Mod|.
% Depending on \Meta{clr-opt}, different tasks are performed:
% \begin{itemize}
% \item[0:] Don't pick color specification from \Meta{spec-list}.
% \item[1:] Pick color specification from \Meta{spec-list}, convert it from model |\@@mod| to |\@@Mod|, unless the latter is `ignore' or |\@@cls| is `ps'.
% \item[2:] Like the former case, additionally |\let\@@mod\@@Mod|.
% \end{itemize}
% The color specification is stored in |\@@clr|.
% Color specification picking relies on the position |\XC@@pos|, conversion relies on the model |\@@mod|, and the target model |\@@Mod|.
% If |\@@mod| represents an undefined color model, then \Meta{undefined} is executed at the end of the macro, else \Meta{defined}.
%    \begin{macrocode}
\def\XC@getmodclr#1#2#3#4%
 {\ifnum\ifcase#1 \ifXC@@getmod1\else0 \fi \or1 \fi>0
    \XC@mdef\@@mod{#3}\expandafter\XC@getmod\@@mod////////\XC@@
    \@ifundefinedmodel\@@Mod{\let\@@Mod\XC@mod@ignore}{}\fi
  \@ifundefined{XC@mod@\@@mod}%
   {\c@lor@error{model `\@@mod'}\@firstoftwo}%
   {\ifcase#2\else
      \XC@mdef\@@clr{#4}%
      \edef\@@clr{\expandafter\XC@getclr\@@clr////////\XC@@}%
      \ifx\@@cls\XC@mod@ps\else\XC@clean\@@clr\fi
      \ifx\@@Mod\XC@mod@ignore\else
        \convertcolorspec\@@mod\@@clr\@@Mod\@@clr
        \ifnum#2>1 \let\@@mod\@@Mod\fi
      \fi
    \fi \@secondoftwo}}
%    \end{macrocode}
%
% \begin{macro}{\XC@getmod}
% Retrieve model position |\XC@@pos|, model |\@@mod|, and target model |\@@Mod| from multiple definitions (up to~8), separated by `|/|'.
%    \begin{macrocode}
\def\XC@getmod#1/#2/#3/#4/#5/#6/#7/#8/#9\XC@@
 {\XC@g@tm@d0#1::\XC@@ \XC@getm@d1{#2}\XC@getm@d2{#3}%
  \XC@getm@d3{#4}\XC@getm@d4{#5}\XC@getm@d5{#6}\XC@getm@d6{#7}%
  \XC@getm@d7{#8}\def\XC@@pos{0}\def\@@mod{#1}\@gobble\@nnil}%
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@getm@d#1#2%
 {\edef\XC@@pos{#2}\XC@sdef\@@mod{\XC@tgt@mod\XC@@pos}%
  \ifx\XC@@pos\@@mod\def\XC@@pos{#1}\expandafter\remove@to@nnil\fi}%
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@g@tm@d#1#2:#3:#4\XC@@
 {\@ifxempty{#3}{\let\@@Mod\XC@mod@ignore\XC@getm@d0{#2}}%
    {\def\@@Mod{#2}\XC@getm@d0{#3}}}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@getclr}
% Pick color specification on position |\XC@@pos| from multiple definitions (up to~8), separated by `|/|'.
% Expandable.
%    \begin{macrocode}
\def\XC@getclr#1/#2/#3/#4/#5/#6/#7/#8/#9\XC@@
 {\ifcase\XC@@pos\space #1\or#2\or#3\or#4\or#5\or#6\or#7\or#8\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifXC@@getmod}
% Switch used to determine whether the model has to be retrieved (e.g., ordinary |\definecolor|) or not (e.g., |\definecolor| acting as subroutine to |\definecolorset|).
%    \begin{macrocode}
\newif\ifXC@@getmod \XC@@getmodtrue
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\xdefinecolor}
% This command is identical with |\definecolor|, it is kept only for compatibility reasons.
%    \begin{macrocode}
\let\xdefinecolor\definecolor
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\providecolor}
%   \oarg{type}\marg{name}\marg{model-list}\marg{spec-list}\\
% Similar to |\definecolor|, but the color \Meta{name} is only defined if it does not exist already.
%    \begin{macrocode}
\def\providecolor{\@testopt{\XC@providecolor}{}}
\def\XC@providecolor[#1]#2%
 {\@testopt{\XC@providec@lor[#1]{#2}}\colornameprefix}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@providec@lor[#1]#2[#3]%
 {\XC@edef\XC@@tmp{#2}%
  \@ifundefinedcolor\XC@@tmp{\XC@definecolor[#1]{#2}[#3]}%
   {\ifnum\XC@tracing>0
      \PackageInfo{xcolor}{Ignoring color definition `\XC@@tmp'}\fi
    \@gobbletwo}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\xcolor@}
%   \marg{type-spec}\marg{driver-spec}\marg{model}\marg{spec}\\
% Simply grabs the driver-specific part of the color definition.
% Therefore, the command |\\color@|\Meta{name} behaves like in the original case, when first-level expanded.
%    \begin{macrocode}
\def\xcolor@#1#2#3#4{#2}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\colorlet}
%   \oarg{type}\marg{name}\oarg{num model}\marg{color}\\
% Create a color `name' consisting of \Meta{color}, converted to \Meta{num model} if non-empty.
%    \begin{macrocode}
\def\colorlet{\@testopt{\XC@colorlet}{}}
\def\XC@colorlet[#1]#2{\@testopt{\XC@col@rlet[#1]{#2}}{}}
\def\XC@col@rlet[#1]#2[#3]#4%
 {\begingroup
  \edef\@@cls{#1}\XC@edef\@@nam{#2}\XC@sdef\@@mod{#3}\XC@edef\@@clr{#4}%
%    \end{macrocode}
%
% Check whether |#4| is an explicit name, |#3| is empty and |#1| is either empty or equal to the corresponding parameter of |#4|: in this case, a simple |\let| command will do the job.
%    \begin{macrocode}
  \XC@info\@@clr\@@tmp\XC@@tstfalse
  \ifnum\@@tmp=\@ne\ifx\@@mod\@empty
    \ifx\@@cls\@empty
      \XC@@tsttrue
    \else
      \edef\@@tmp
       {\expandafter\expandafter\expandafter\@secondoffive
         \csname\string\color@\@@clr\endcsname}%
      \ifx\@@cls\@@tmp\XC@@tsttrue\fi
    \fi
  \fi\fi
  \ifXC@@tst
    \XC@logdef\@@nam\XC@c@l@rlet\@@nam\@@clr
  \else
    \extractcolorspec\@@clr\@@clr
    \ifx\@@mod\@empty\else
      \expandafter\convertcolorspec\@@clr\@@mod\@@clr
      \edef\@@clr{{\@@mod}{\@@clr}}\fi
    \edef\@@tmp{\noexpand\XC@definecolor[\@@cls]{\@@nam}\@@clr}%
  \fi
  \expandafter\endgroup\@@tmp\xglobal@stop}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@c@l@rlet#1#2%
 {\@ifundefinedcolor{#2}%
   {\c@lor@error{`#2'}\let\@@tmp\@empty}%
   {\edef\@@tmp
     {\ifglobalcolors\global\else\xglobal@\fi
      \noexpand\XC@let@cc{\string\color@#1}{\string\color@#2}}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DefineNamedColor}
%   \marg{type}\marg{name}\marg{model-list}\marg{spec-list}
%    \begin{macrocode}
\def\DefineNamedColor#1%
 {\@nameuse{XC@\ifdefinecolors defin\else prepar\fi ecolor}[#1]}
%    \end{macrocode}
%  \end{macro}
%
%
% \subsubsection{Deferred definition}
%
% \begin{macro}{\preparecolor}
%   \oarg{type}\marg{name}\oarg{prefix}\marg{model-list}\marg{spec-list}\\
%    \begin{macrocode}
\def\preparecolor{\@testopt{\XC@preparecolor}{}}
\def\XC@preparecolor[#1]#2%
 {\@testopt{\XC@preparec@lor[#1]{#2}}\colornameprefix}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@preparec@lor[#1]#2[#3]#4#5%
 {\XC@sdef\@@cls{#1}\XC@edef\@@nam{#2}%
  \XC@getmodclr01{#4}{#5}{}%
   {\xdef\XC@@stack
     {\ifx\XC@@stack\@empty\else\XC@@stack,\fi{#1}{\@@nam}{#3}%
      {\ifx\@@Mod\XC@mod@ignore\@@mod\else\@@Mod\fi}{\@@clr}}}}
%    \end{macrocode}
%
%    \begin{macrocode}
\let\XC@@stack\@empty
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\definecolors}
%   \marg{id-list}
%    \begin{macrocode}
\def\definecolors#1%
 {\let\XC@@cmd\definecolor\let\XC@@glb\xglobal@
  \expandafter\XC@definecolors#1,,}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@definecolors#1,%
 {\@ifxempty{#1}{}{\expandafter\XC@definec@lors#1=#1=:\XC@definecolors}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@definec@lors#1=#2=#3:%
 {\XC@edef\@@nam{#1}\XC@edef\@@arg{#2}%
  \let\next\XC@definec@l@rs\expandafter\next\XC@@stack,,\@nnil}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@definec@l@rs#1,%
 {\ifx,#1,\let\next\remove@to@nnil\else\XC@defin@c@l@rs#1\fi\next}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@defin@c@l@rs#1#2#3#4#5%
 {\def\@@tmp{#2}%
  \ifx\@@tmp\@@arg
    \let\xglobal@\XC@@glb\XC@@cmd[#1]{\@@nam}[#3]{#4}{#5}%
    \let\next\remove@to@nnil
  \fi}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\providecolors}
%   \marg{id-list}\\
% Similar to |\definecolor|, but based on |\providecolor|, thus the individual colors are defined only if they do not exist already.
%    \begin{macrocode}
\def\providecolors#1%
 {\let\XC@@cmd\providecolor\let\XC@@glb\xglobal@
  \expandafter\XC@definecolors#1,,}
%    \end{macrocode}
%  \end{macro}
%
%
% \subsubsection{Sets of colors}
%
% \begin{macro}{\definecolorset}
%   \oarg{type}\marg{model-list}\marg{head}\marg{tail}\marg{set spec}\\
% This command facilitates the construction of \emph{color sets} with common underlying \Meta{model-list} and \Meta{type}.
% Here, \Meta{set spec} = \Meta[1]{name},\Meta[1]{spec-list};\dots;\Meta[k]{name},\Meta[k]{spec-list} ($k\ge1$ name/specification-list pairs).
% Individual colors are being constructed by |\definecolor|\oarg{type}|{|\Meta{head}\Meta[1]{name}\Meta{tail}|}|\marg{model-list}|{|\Meta[1]{spec-list}|}| etc.
%    \begin{macrocode}
\def\definecolorset
 {\let\XC@@cmd\definecolor\@testopt{\XC@definecolorset}{}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@definecolorset[#1]#2#3#4#5%
 {\XC@getmodclr10{#2}{}{}%
   {\XC@@getmodfalse\XC@edef\XC@@tmp{#5}\let\XC@@glb\xglobal@
    \def\XC@definec@lorset##1,##2;%
     {\@ifxempty{##1}{}%
       {\let\xglobal@\XC@@glb
        \XC@@cmd[#1]{#3##1#4}{\@@mod}{##2}\XC@definec@lorset}}%
    \expandafter\XC@definec@lorset\XC@@tmp;,;\XC@@getmodtrue}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\providecolorset}
%   \oarg{type}\marg{model-list}\marg{name-prefix}\marg{name-postfix}\marg{set spec}\\
% Similar to |\definecolorset|, but based on |\providecolor|, thus the individual colors are defined only if they do not exist already.
%    \begin{macrocode}
\def\providecolorset
 {\let\XC@@cmd\providecolor\@testopt{\XC@definecolorset}{}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\preparecolorset}
%   \oarg{type}\marg{model-list}\marg{name-prefix}\marg{name-postfix}\marg{set spec}\\
% Similar to |\definecolorset|, but dependent on |\ifdefinecolors|, either a |\definecolor| or a |\preparecolor| command will be executed for each single set member.
%    \begin{macrocode}
\def\preparecolorset
 {\ifdefinecolors\let\XC@@cmd\definecolor\else\let\XC@@cmd\preparecolor\fi
  \@testopt{\XC@definecolorset}{}}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Color series}
%
% \begin{macro}{\definecolorseries}
%   \marg{name}\marg{core model}\marg{method}\oarg{b-model}\marg{base color}\oarg{l-model}\marg{delta}
%    \begin{macrocode}
\def\definecolorseries#1#2#3%
 {\@testopt{\XC@definecolorseries{#1}{#2}{#3}}{}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@definecolorseries#1#2#3[#4]#5%
 {\@testopt{\XC@definec@lorseries{#1}{#2}{#3}[#4]{#5}}{}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@definec@lorseries#1#2#3[#4]#5[#6]#7%
 {\begingroup
  \XC@sdef\@@mod{#2}%
  \@ifxempty{#4}{\extractcolorspec{#5}\@@clr}{\edef\@@clr{{#4}{#5}}}%
  \expandafter\convertcolorspec\@@clr\@@mod\@@clr
  \@namexdef{\string\colorB@#1}{{\@@mod}{\@@clr}}%
  \edef\@@met{#3}%
  \ifx\@@met\XC@met@last
    \@ifxempty{#6}{\extractcolorspec{#7}\@@tmp}{\edef\@@tmp{{#6}{#7}}}%
    \expandafter\convertcolorspec\@@tmp\@@mod\@@tmp
    \XC@inflate\@@mod\@@tmp\@@clr\@@tmp
    \expandafter\XC@sub\@@tmp,\@@tmp
  \else
    \edef\@@tmp{#7}%
  \fi
  \@namexdef{\string\colorD@#1}{{\@@met}{\@@tmp}}%
  \endgroup}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\resetcolorseries}
%   \oarg{div}\marg{name}
%    \begin{macrocode}
\def\resetcolorseries{\@testopt{\XC@resetcolorseries}{}}
\def\XC@resetcolorseries[#1]#2%
 {\begingroup
  \@namexdef
   {\string\color@#2}{\noexpand\xcolor@{}{}\@nameuse{\string\colorB@#2}}%
  \XC@let@Nc\@@tmp{\string\colorD@#2}%
  \edef\@@met{\expandafter\@firstoftwo\@@tmp}%
  \edef\@@tmp{\expandafter\@secondoftwo\@@tmp}%
  \ifx\@@met\XC@met@step\else
    \edef\@@scl{\@ifxempty{#1}\colorseriescycle{#1}}%
    \expandafter\XC@calc@\@@tmp,,,,:D%
  \fi
  \@namexdef{\string\colorS@#2}{\@@tmp}%
  \endgroup}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@step}
% \begin{macro}{\XC@stepabs}
%   \marg{name}\\
% Perform a relative or absolute (= direct access) step within a color series \Meta{name}.
% In the relative case, the (non-negative) number of single steps is supposed to be stored in |\@tempcnta|.
%    \begin{macrocode}
\def\XC@step#1%
 {\let\xcolor@\@gobbletwo\edef\@@tmp{\@nameuse{\string\color@#1}}%
  \expandafter\XC@st@p\@@tmp{#1}%
  \@namexdef{\string\color@#1}{\noexpand\xcolor@{}{}{\@@mod}{\@@tmp}}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@st@p#1#2#3%
 {\def\@@mod{#1}\def\@@tmp{#2}\edef\@@vec{\@nameuse{\string\colorS@#3}}%
  \@whilenum\@tempcnta>\z@\do
   {\XC@inflate\@@mod\@@tmp\@@vec\@@tmp
    \expandafter\XC@add\@@tmp,\@@tmp \expandafter\XC@calc@\@@tmp,,,,:U%
    \advance\@tempcnta\m@ne}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@stepabs#1%
 {\edef\@@tmp{\@nameuse{\string\colorB@#1}}%
  \expandafter\XC@st@p\@@tmp{#1}%
  \edef\@@tmp
   {\def\noexpand\@@mod{\@@mod}\def\noexpand\@@clr{\@@tmp}}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Color blending}
%
% \begin{macro}{\blendcolors}
% \begin{macro}{\blendcolors*}
%   \marg{mix expr}\\
% Initialises all necessary parameters for color blending.
% The actual (completed) color blend expression is stored in |\colorblend|.
% In the starred version, the argument will be appended to a previously defined blend expression.
% An empty \Meta{mix expr} argument will switch blending off.
%    \begin{macrocode}
\def\blendcolors{\@ifstar{\XC@blendcolors\colorblend}{\XC@blendcolors{}}}
\def\XC@blendcolors#1#2%
 {\edef\colorblend{#1}\XC@edef\XC@@tmp{#2}%
  \ifx\XC@@tmp\@empty
    \xglobal@\blendcolorsfalse
  \else
    \xglobal@\blendcolorstrue
    \expandafter\XC@blendc@lors\XC@@tmp!!\@nil
  \fi
  \xglobalize@\colorblend \xglobal@stop}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@blendc@lors!#1!#2!#3\@nil
 {\@ifxempty{#1}{}%
   {\@ifxempty{#2}%
    {\edef\colorblend{\colorblend!#1!white}}%
    {\edef\colorblend{\colorblend!#1!#2}\XC@blendc@lors!#3!\@nil}}}
%    \end{macrocode}
%
%    \begin{macrocode}
\blendcolors{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Color masks and separation}
%
% \begin{macro}{\maskcolors}
%   \oarg{core model}\marg{color}\\
% Initialises all necessary parameters for color masking.
% The actual color mask expression is stored in |\colormask|.
% An empty \Meta{color} argument will switch masking off.
% The optional \Meta{core model} argument may be used to determine the underlying color model.
%    \begin{macrocode}
\def\maskcolors{\@testopt{\XC@maskcolors}{}}
\def\XC@maskcolors[#1]#2%
 {\XC@edef\colormask{#2}%
  \ifx\colormask\@empty
    \xglobal@\maskcolorsfalse \def\XC@mmod{}\def\XC@mclr{}%
  \else
    \xglobal@\maskcolorstrue \extractcolorspecs\colormask\XC@mmod\XC@mclr
    \@ifxempty{#1}{}%
     {\convertcolorspec\XC@mmod\XC@mclr{#1}\XC@mclr \XC@sdef\XC@mmod{#1}}%
    \XC@coremodel\XC@mmod\XC@mclr
  \fi
  \xglobalize@\colormask \xglobalize@\XC@mmod \xglobalize@\XC@mclr
  \xglobal@stop}
%    \end{macrocode}
%
%    \begin{macrocode}
\maskcolors{}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Color application}
%
% \subsubsection{Standard color commands}
%
%  \begin{macro}{\color}
%   \marg{color}\\
%   \oarg{model-list}\marg{spec-list}\\
% Switches to the color given either by name/expression or by model/specification.
% This color will stay in effect until the end of the current \TeX\ group.
%    \begin{macrocode}
\DeclareRobustCommand\color
 {\@ifnextchar[\@undeclaredcolor\@declaredcolor}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\@undeclaredcolor}
%   \oarg{model-list}\marg{spec-list}\\
% Display a color that is given by \Meta{model} name and numerical \Meta{spec}.
%    \begin{macrocode}
\def\@undeclaredcolor[#1]#2%
 {\begingroup
  \let\@@cls\@empty
  \XC@getmodclr12{#1}{#2}{}%
   {\ifblendcolors
      \ifx\colorblend\@empty\else
        \edef\@@mix{\expandafter\@gobble\colorblend}\@tempswafalse
        \XC@coremodel\@@mod\@@clr\@xcolor@{}{}\@@mod\@@clr
      \fi
    \fi
    \ifconvertcolorsU
      \edef\@@tmp{\XC@tgt@mod{\@@mod}}%
      \convertcolorspec\@@mod\@@clr\@@tmp\@@clr \let\@@mod\@@tmp
    \fi
    \ifmaskcolors
      \convertcolorspec\@@mod\@@clr\XC@mmod\@@clr
      \let\@@mod\XC@mmod
      \XC@inflate\@@mod\XC@mclr\@@clr\@@tmp
      \expandafter\XC@mul\@@tmp,\@@clr
    \fi
    \edef\@@tmp{\noexpand\XC@undeclaredcolor{\@@mod}{\@@clr}}%
    \expandafter\endgroup\@@tmp}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@undeclaredcolor#1#2%
 {\@ifundefinedmodel{#1}%
   {\c@lor@error{model `#1'}}%
   {\@nameuse{color@#1}\current@color{#2}%
    \edef\XC@current@color{\noexpand\xcolor@{}{\current@color}{#1}{#2}}%
    \XC@display}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@declaredcolor}
%   \marg{color}\\
% Display a color that is given by an arbitrary \Meta{color}.
%    \begin{macrocode}
\def\@declaredcolor#1%
 {\XC@edef\XC@@tmp{#1}\XC@@tstfalse
  \ifcase\XC@type\XC@@tmp\relax \XC@@tsttrue\or \relax\else
    \ifblendcolors\XC@@tsttrue\fi \ifmaskcolors\XC@@tsttrue\fi
    \ifconvertcolorsU\XC@@tsttrue\fi
  \fi
  \ifXC@@tst
    \expandafter\XC@declaredcolor\else
    \expandafter\XC@declaredc@lor\fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@declaredcolor
 {\XC@split\XC@@tmp
  \edef\@@tmp{\noexpand\@undeclaredcolor[\@@mod]{\@@clr}}%
  \expandafter\endgroup\@@tmp}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@declaredc@lor
 {\XC@let@Nc\XC@current@color{\string\color@\XC@@tmp}%
  \edef\current@color{\XC@current@color}%
  \XC@display}
%    \end{macrocode}
% \end{macro}
%
%  \begin{macro}{\textcolor}
%   \marg{color}\marg{text}\\
%   \oarg{model-list}\marg{spec-list}\marg{text}\\
% are just alternative syntax for |\color|, in which the groups are added implicitly.
% Thus \emph{text} appears in the specified color, but then the color reverts to its previous value.
% The naming is by analogy with |\textrm| (as opposed to |\rm| and |\rmfamily|) although it is slightly a misnomer as the command also works in math-mode.
% Additionally, it calls |\leavevmode| to ensure the start of horizontal mode.
%    \begin{macrocode}
\def\textcolor#1#{\@textcolor{#1}}
\def\@textcolor#1#2#3{\protect\leavevmode{\color#1{#2}#3}}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\pagecolor}
%   \marg{color}\\
%   \oarg{model-list}\marg{spec-list}\\
% Specifies the background color for the current, and all following, pages.
% It is a global declaration which does not respect \TeX\ groups.
%    \begin{macrocode}
\def\pagecolor
 {\begingroup
  \let\ignorespaces\endgroup \let\set@color\set@page@color
  \color}
%    \end{macrocode}
%  \end{macro}
%
%
% \subsubsection{Colored boxes}
%
% \begin{macro}{\colorbox}
%   \marg{color}\marg{text}\\
%   \oarg{model}\marg{spec}\marg{text}\\
% Takes the same argument forms as |\textcolor|, but the color specifies the \emph{background} color of the box.
%    \begin{macrocode}
\def\colorbox#1#{\protect\color@box{#1}}
\def\color@box#1#2{\color@b@x\relax{\color#1{#2}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fcolorbox}
%   \marg{frame color}\marg{background color}\marg{text}\\
%   \oarg{model}\marg{frame spec}\marg{background spec}\marg{text}\\
%   \oarg{frame model}\marg{frame spec}\oarg{background model}\marg{background spec}\marg{text}\\
%   \marg{frame color}\oarg{background model}\marg{background spec}\marg{text}\\
% Puts a frame of the first color around a box with a background specified by the second color.
% If only the first optional argument is given, it specifies the color model for both colors.
%    \begin{macrocode}
\def\fcolorbox#1#{\color@fbox{#1}}
\def\color@fbox#1#2#3#{\protect\color@fb@x{#1}{#2}{#3}}
\def\color@fb@x#1#2#3#4%
 {\color@b@x{\fboxsep\z@\color#1{#2}\XC@fbox}%
   {\@ifxempty{#3}{\color#1}{\color#3}{#4}}}
%    \end{macrocode}
% \end{macro}
%
%  \begin{macro}{\color@b@x}
% Internal macro for |\colorbox| and |\fcolorbox|.
%    \begin{macrocode}
\long\def\color@b@x#1#2#3%
 {\leavevmode
  \setbox\z@\hbox{\kern\fboxsep{\set@color#3}\kern\fboxsep}%
  \dimen@\ht\z@\advance\dimen@\fboxsep\ht\z@\dimen@
  \dimen@\dp\z@\advance\dimen@\fboxsep\dp\z@\dimen@
  {#1{#2\color@block{\wd\z@}{\ht\z@}{\dp\z@}\box\z@}}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\XC@frameb@x}
% Common part of |\framebox| and |\fbox|.
% |#1| is a negative kern in the |\framebox| case so that the vertical rules do not add to the width of the box.
% Optimised by \People{Donald}{Arseneau}.
%    \begin{macrocode}
\def\XC@frameb@x#1%
 {\hbox
   {\@tempdima\fboxrule \advance\@tempdima\fboxsep
    \advance\@tempdima\dp\@tempboxa
    \setbox\@tempboxa\hbox
     {\lower\@tempdima\hbox
       {\vbox
         {\kern\fboxrule
          \hbox{\kern\fboxrule#1%
                \vbox{\kern\fboxsep\box\@tempboxa\kern\fboxsep}%
                #1\kern\fboxrule}%
          \kern\fboxrule}}}%
    \@tempdima\wd\@tempboxa
    \edef\@tempa{{\the\@tempdima}{\the\ht\@tempboxa}{\the\dp\@tempboxa}}%
    \box\@tempboxa\kern-\@tempdima\expandafter\boxframe\@tempa}}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\XC@fbox}
% \begin{macro}{\@frameb@x}
% If no \Option{kernelfbox} option was specified, switch to the new method in general, else only for |\fcolorbox|.
%    \begin{macrocode}
\ifXC@@fbox
  \let\@frameb@x\XC@frameb@x \let\XC@fbox\fbox
\else
  \def\XC@fbox{\let\@frameb@x\XC@frameb@x\fbox}
\fi
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%
% \subsubsection{Driver-specific and generic drawing}
%
% \begin{macro}{\color@block}
%   \marg{width}\marg{height}\marg{depth}\\
% Should take up no space for \TeX, but produce a block in the current color of the specified size.
% It is mainly used for producing box backgrounds.
%  \begin{macro}{\boxframe}
%   \marg{width}\marg{height}\marg{depth}\\
% Draw a frame with a linewidth of |\fboxrule|.
% Return a |\hbox| with outer dimensions \meta{width}, \meta{height}, \meta{depth}.

%  \begin{macro}{\XC@boxframe}
%   \marg{width}\marg{height}\marg{depth}\marg{frame construction}\\
% Wrapper for |\boxframe| commands that return zero-dimension frames.
%    \begin{macrocode}
\ifnum\XC@@xcd@>\m@ne
\def\XC@boxframe#1#2#3#4%
 {\hbox{\sbox\z@{\ifdim\fboxrule>\z@ #4\fi}%
    \wd\z@#1\relax\ht\z@#2\relax\dp\z@#3\relax\box\z@}}
\fi
%    \end{macrocode}
% \end{macro}
%
% \textbf{\Option{dvips}-optimised code}
%    \begin{macrocode}
\ifcase\XC@@xcd@
%    \end{macrocode}
%
%    \begin{macrocode}
\providecommand*\color@block[3]%
 {{\set@color\hbox
    {\dimen@#3\edef\@tempa{ \number\dimen@\space}%
     \dimen@#2\edef\@tempa{ \number\dimen@\@tempa}%
     \dimen@#1\relax
     \XC@special{\number\dimen@\@tempa XCcolorblock}}}}
%    \end{macrocode}
%
%    \begin{macrocode}
\providecommand*\boxframe[3]%
 {\XC@boxframe{#1}{#2}{#3}%
   {\dimen@#3\edef\@tempa{ \number\dimen@\space}%
    \dimen@#2\edef\@tempa{ \number\dimen@\@tempa}%
    \dimen@#1\relax
    \XC@special{\number\fboxrule\space\number\dimen@\@tempa XCboxframe}}}
%    \end{macrocode}
%
% \textbf{\Option{pdftex}-optimised code }
% There seems to be no improvement by adding a specific |\color@block| command, since the PDF format doesn't offer higher accuracy than \TeX.
% For |\boxframe| we want to achieve this PDF pseudo-code (besides initial scaling):\\[1ex]
% \centerline{\ttfamily $l$ w [] $0$ d $2$ J $0$ j $4$ M
% $1$ $0$ $0$ $1$ $\frac12\,l$ $\frac12\,l$ cm
% $0$ $-d$ $(w-l)$ $(h+d-l)$ re s}
%    \begin{macrocode}
\or
%    \end{macrocode}
%
%    \begin{macrocode}
\providecommand*\boxframe[3]%
 {\XC@boxframe{#1}{#2}{#3}%
   {\dimen@#3\edef\@tempa{ 0 -\strip@pt\dimen@\space}%
    \edef\@tempb{\advance\dimen@\the\dimen@}%
    \dimen@#2\advance\dimen@-\fboxrule\@tempb
    \edef\@tempb{ \strip@pt\dimen@\space re s}%
    \dimen@#1\advance\dimen@-\fboxrule
    \edef\@tempb{ cm\@tempa\strip@pt\dimen@\@tempb}%
    \dimen@.5\fboxrule\edef\@tempa{ \strip@pt\dimen@}%
    \XC@special
     {0.996264 0 0 0.996264 0 0 cm
      \strip@pt\fboxrule\space w [] 0 d 2 J 0 j 4 M
      1 0 0 1\@tempa\@tempa\@tempb}}}
%    \end{macrocode}
%
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
% \textbf{Generic code }
% The definition here works by selecting a color, and then drawing a \TeX\ rule (unless |\ifcolors@false|).
%    \begin{macrocode}
\providecommand*\color@block[3]%
 {{\set@color\rlap{\ifcolors@\vrule\@width#1\@height#2\@depth#3\fi}}}
%    \end{macrocode}
%
% The following definition was optimised by \People{Donald}{Arseneau}.
%    \begin{macrocode}
\providecommand*\boxframe[3]%
 {\hbox
   {\dimen@#2\advance\dimen@#3\relax
    \lower#3\vbox
     {\hrule\@height\fboxrule
      \@tempdima-0.5\fboxrule \ifodd\fboxrule\advance\@tempdima\m@ne sp\fi
      \kern\@tempdima
      \hbox
       {\advance\dimen@-\fboxrule
        \vrule\@width\fboxrule\@height\dimen@\@depth\z@
        \@tempdima#1\advance\@tempdima-\tw@\fboxrule \kern\@tempdima
        \vrule\@width\fboxrule\@height\dimen@\@depth\z@}%
      \kern-0.5\fboxrule
      \hrule\@height\fboxrule}}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Color argument processing}
%
% \begin{macro}{\@xcolor@}
%   \marg{type-spec}\marg{driver-spec}\marg{model}\marg{spec}\\
% This is the `work-horse' that does all necessary conversions and calculations if a color (expression) has to be displayed.
% \Meta{type-spec}  and \Meta{driver-spec} are ignored.
% |\@@mix| may contain a mix expression without leading `!'.
%    \begin{macrocode}
\def\@xcolor@#1#2#3#4%
 {\XC@sdef\@@mod{#3}\edef\@@clr{#4}%
  \ifx\@@mix\@empty\else\expandafter\@xcolor@@\@@mix!!!!\@nil\fi
  \if@tempswa
    \XC@let@Nc\@@tmp{XC@cnv@\@@mod @compl}%
    \ifx\@@tmp\relax \expandafter\XC@calc@\@@clr,,,,:C\else
                     \expandafter\@@tmp\@@clr,\fi
    \let\@@clr\@@tmp
  \fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@xcolor@@#1!#2!#3!#4!#5\@nil
 {\dimen@\@ifxempty{#1}{100}{#1}\p@
  \edef\@@mix{\@ifxempty{#2}{white}{#2}}%
  \ifdim\dimen@=100\p@
    \expandafter\XC@postfix\@@mix]\relax
  \else\ifdim\dimen@=\z@
    \extractcolorspecs\@@mix\@@mod\@@clr
  \else
    \XC@let@Nc\@@tmp{XC@clr@\@@mod @\@@mix}%
    \ifx\@@tmp\relax
      \extractcolorspec\@@mix\@@tmp
      \ifx\@@mod\XC@mod@gray
        \edef\@@mod{\expandafter\@firstoftwo\@@tmp}%
        \edef\@@tmp{\expandafter\@secondoftwo\@@tmp}%
        \convertcolorspec\XC@mod@gray\@@clr\@@mod\@@clr
      \else
        \expandafter\convertcolorspec\@@tmp\@@mod\@@tmp
      \fi
    \else
      \ifx\@@mod\XC@mod@hsb\expandafter\XC@extract@hue\@@clr:\@@hue\fi
    \fi
    \XC@inflate\@@mod\@@clr\@@tmp\@@tmp
    \expandafter\XC@mix\@@tmp,\@@clr
  \fi\fi
  \@ifxempty{#3}%
   {\@ifxempty{#4}{}{\@xcolor@@!#4!#5\@nil}}%
   {\@xcolor@@#3!#4!#5\@nil}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@split}
%   \marg{ext expr}\\
% Split \Meta{ext expr} into all of its components, do the necessary calculations, and save the model of the resulting color in |\@@mod| and the parameters in |\@@clr|.
% Note: |\XC@split| opens a group which has to be closed afterwards by |\endgroup|.
%    \begin{macrocode}
\def\XC@split#1%
 {\begingroup\XC@edef\@@tmp{#1}\expandafter\XC@split@i\@@tmp>>\@nnil}
%    \end{macrocode}
%
% \begin{macro}{\XC@split@i}
% Separate first part of expression chain and apply function(s) afterwards as requested.
%    \begin{macrocode}
\def\XC@split@i#1>%
 {\def\@@tmp{#1}\XC@split@ii#1:\@nil \XC@func}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@split@ii}
% Check whether it is an \emph{extended} or \emph{standard} color expression.
%    \begin{macrocode}
\def\XC@split@ii#1:#2\@nil
 {\@ifxempty{#2}{\XC@split@vi}{\XC@split@iii#1,,:#2}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@split@iii}
% Initialisation for extended color expressions.
% The magic \Meta{div} is either given as second argument, or calculated as the sum of all weights.
%    \begin{macrocode}
\def\XC@split@iii#1,#2,#3:#4:%
 {\edef\XC@@mod{#1}\let\@tempa\@empty
  \ifx,#2,\XC@@tsttrue\@tempdima\z@\else\XC@@tstfalse\@tempdima#2\p@\fi
  \XC@split@iv#4;,;}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@split@iv}
%   \marg{expr}\marg{dec}\\
% Step through the list of \Meta{expr},\Meta{dec} pairs.
% Add \Meta{dec} to the sum of weights (in order to calculate the ultimate \Meta{div}) and append pair information to |\@tempa| command.
% At the end of the list, execute |\@tempa| and map resulting parameter vector into unit cube.
% Finally, |\@@mod| and |\@@clr| contain the desired information about color model and parameters.
%    \begin{macrocode}
\def\XC@split@iv#1,#2;%
 {\@ifxempty{#1}%
   {\let\XC@@clr\@empty \@tempa \expandafter\XC@calc@\XC@@clr,,,,:U%
    \let\@@mod\XC@@mod \let\@@clr\@@tmp}
   {\XC@append\@tempa{\XC@split@v{#1}{#2}}%
    \ifXC@@tst\advance\@tempdima#2\p@\fi
    \XC@split@iv}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@split@v}
%   \marg{expr}\marg{dec}\\
% Extract color specification from \Meta{expr}, convert to target model, multiply the resulting vector by the quotient of \Meta{dec} and \Meta{div}, add that vector to the overall parameter vector.
%    \begin{macrocode}
\def\XC@split@v#1#2%
 {\def\@@tmp{#1}\XC@split@vi
  \ifx\@@mod\XC@@mod\else
    \convertcolorspec\@@mod\@@clr\XC@@mod\@@clr
  \fi
  \dimen@#2\p@ \rdivide\dimen@\@tempdima
  \edef\@@scl{\strip@pt\dimen@}%
  \expandafter\XC@calc@\@@clr,,,,:S%
  \ifx\XC@@clr\@empty\let\XC@@clr\@@tmp\else
    \XC@inflate\XC@@mod\XC@@clr\@@tmp\@@tmp
    \expandafter\XC@add\@@tmp,\XC@@clr
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@split@vi}
% Start splitting process for standard color expression.
%    \begin{macrocode}
\def\XC@split@vi{\count@\z@ \expandafter\XC@split@vii\@@tmp!\@nil}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@split@vii}
% Count number of `-' signs at the beginning of the string.
%    \begin{macrocode}
\def\XC@split@vii#1%
 {\ifx#1-\advance\count@\@ne\expandafter\XC@split@vii
  \else\expandafter\XC@split@viii\expandafter#1\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@split@viii}
% Extract \Meta{name} and \Meta{mix expr} part of color expression.
% Delegate control to |\@xcolor@|.
%    \begin{macrocode}
\def\XC@split@viii#1!#2\@nil
 {\edef\@@nam{#1}\edef\@@mix{#2}%
  \ifodd\count@\@tempswatrue\else\@tempswafalse\fi
  \@ifundefinedcolor\@@nam
   {\c@lor@error{`\@@nam'}\def\@@nam{black}}{}%
  \let\xcolor@\@xcolor@\@nameuse{\string\color@\@@nam}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\XC@postfix}
% Examine the postfix of a color expression and derive the actions to be taken for color series.
%    \begin{macrocode}
\def\XC@postfix#1#2]#3\relax
 {\begingroup
  \if[#1\@tempcnta#2\relax\XC@stepabs\@@nam
  \else\@tempcnta\z@
    \@tfor\@@tok:=#1#2\do
     {\if+\@@tok\advance\@tempcnta\@ne
      \else\if-\@@tok\advance\@tempcnta\m@ne
      \else\@tempcnta\z@\expandafter\@break@tfor\fi\fi}%
    \ifnum\@tempcnta=\z@\relax\else\XC@step\@@nam\fi
    \let\@@tmp\@empty
  \fi\expandafter\endgroup\@@tmp}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@func}
%   \marg{function}|,{|\Meta[1]{arg}|,...,{|\Meta[n]{arg}|}>...\@nnil>|\\
% General macro to handle color functions.
% The number of arguments depends on the function.
% Multiple consecutive functions may be applied.
% Color model and specifications are input and output via |\@@mod| and |\@@clr|.
%    \begin{macrocode}
\def\XC@func#1>{\@ifxempty{#1}{\remove@to@nnil}{\XC@fun@#1,>\XC@func}}
\def\XC@fun@#1,#2>{\@nameuse{XC@func@#1}#2,,>}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@func@wheel}
% \begin{macro}{\XC@func@twheel}
%   \marg{angle}|,|\marg{full circle}|,>|\\
% Calculate color wheel position according to \Model{Hsb} or \Model{tHsb} model: \emph{hue} is rotated by \meta{angle} relative to \meta{full circle}.
% The latter value is taken from |\rangeHsb| if left empty.
% Finally, |\@@mod| is changed to \Model{hsb}.
%    \begin{macrocode}
\def\XC@func@wheel#1,#2,#3>{\XC@func@wh@el{#1}{#2}0}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@func@twheel#1,#2,#3>{\XC@func@wh@el{#1}{#2}1}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@func@wh@el#1#2#3%
 {\convertcolorspec\@@mod\@@clr
   {\ifcase#3 \XC@mod@Hsb\or\XC@mod@tHsb\fi}\@@clr
  \expandafter\XC@extract@hue\@@clr:\@@hue \dimen@#1\p@
  \@ifxempty{#2}{}%
   {\rdivide\dimen@{#2}\lshift\dimen@
    \dimen@\rangeHsb\dimen@\rshift\dimen@}%
  \advance\dimen@\@@hue\p@ \rdivide\dimen@\rangeHsb
  \edef\@@hue{\strip@pt\dimen@}\XC@calcU\@@hue\@@hue
  \ifcase#3
    \expandafter\XC@replace@hue\@@clr:\@@hue,\@@clr
  \or
    \XC@c@lcS\rangeHsb{}\@@hue\@@hue
    \expandafter\XC@replace@hue\@@clr:\@@hue,\@@clr
    \convertcolorspec\XC@mod@tHsb\@@clr\XC@mod@hsb\@@clr
  \fi
  \let\@@mod\XC@mod@hsb}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\XC@display}
% Write information to log file and display the current color.
%    \begin{macrocode}
\def\XC@display
 {\XC@bcolor\XC@let@cN{\string\color@.}\XC@current@color
  \ifnum\XC@type{.}=1
    \PackageWarning{xcolor}{Incompatible color definition}\else
  \ifnum\XC@tracing>2
    \begingroup \let\xcolor@\@empty \def\@nil{\string\@nil}%
    \PackageInfo{xcolor}{Setting color `\XC@current@color'}%
    \endgroup
  \fi\fi
  \XC@mcolor\set@color\XC@ecolor\ignorespaces}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@bcolor}
% \begin{macro}{\XC@mcolor}
% \begin{macro}{\XC@ecolor}
% Hooks that may be used to execute additional code within |\XC@display| immediately before/after a color is being displayed.
% Note that |\XC@bcolor| can use the current color information given by |\current@color| and |\XC@current@color| if further manipulation of the color is necessary.
% These hooks are intended for class/package writers and not used by \XC{} itself.
% In order to prevent unwanted side effects, please make sure that all internal \XC{} variables are restored properly at the end of |\XC@display|.
%    \begin{macrocode}
\let\XC@bcolor\relax
\let\XC@mcolor\relax
\let\XC@ecolor\relax
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Border colors for hyperlinks}
%
% \begin{macro}{\XC@bordercolor}
%   \marg{type}\marg{color}\\
% Basic macro to transform \Meta{color} into the format required by \Package{hyperref}.
% Here, \Meta{type} corresponds to the key `x\Meta{type}bordercolor'.
%    \begin{macrocode}
\def\XC@bordercolor#1#2%
 {\extractcolorspec{#2}\XC@@tmp
  \expandafter\convertcolorspec\XC@@tmp\XC@mod@rgb\XC@@tmp
  \expandafter\edef\csname @#1bordercolor\endcsname
   {\expandafter\XC@strip@comma\XC@@tmp,,\@nnil}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@pdfborder}
%   \Meta[1]{number}| |\Meta[2]{number}| |\Meta[3]{number}|\relax|\\
% Basic macro to transform a pdfborder expression into a suitable format for \Program{dvips} with a resolution of 8000~dpi.
%    \begin{macrocode}
\def\XC@pdfborder#1 #2 #3\relax
 {\def\@@scl{80}\XC@calc@#1,#2,#3,,:S%
  \edef\@pdfborder{\expandafter\XC@strip@comma\@@tmp,,\@nnil}}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Colored rows in tables}
%
% The following definitions make only sense if the \Package{colortbl} package has been loaded by the \Option{table} option.
%    \begin{macrocode}
\@ifXCopt{table}{%
%    \end{macrocode}
%
% \begin{macro}{\rowcolors}
% \begin{macro}{\rowcolors*}
%   \oarg{commands}\marg{row}\marg{odd-row color}\marg{even-row color}\\
% Defines alternating colors for the next tabular environment.
% Starting with row \Meta{row}, odd and even rows get their respective colors.
% The color arguments may also be left empty (= no color).
% Optional commands may be |\hline| or |\noalign|\marg{stuff}.
%    \begin{macrocode}
 \def\rowcolors
  {\@ifstar{\@rowcmdfalse\rowc@lors}{\@rowcmdtrue\rowc@lors}}
%    \end{macrocode}
%
%    \begin{macrocode}
 \def\rowc@lors{\@testopt{\rowc@l@rs}{}}
%    \end{macrocode}
%
%    \begin{macrocode}
 \def\rowc@l@rs[#1]#2#3#4%
  {\global\rownum=\z@
   \global\@rowcolorstrue
   \@ifxempty{#3}%
     {\def\@oddrowcolor{\@norowcolor}}%
     {\def\@oddrowcolor{\gdef\CT@row@color{\CT@color{#3}}}}%
   \@ifxempty{#4}%
     {\def\@evenrowcolor{\@norowcolor}}%
     {\def\@evenrowcolor{\gdef\CT@row@color{\CT@color{#4}}}}%
   \if@rowcmd
     \def\@rowcolors
      {#1\if@rowcolors
         \noalign{\relax\ifnum\rownum<#2\@norowcolor\else
                  \ifodd\rownum\@oddrowcolor\else\@evenrowcolor\fi\fi}%
       \fi}%
   \else
     \def\@rowcolors
      {\if@rowcolors
         \ifnum\rownum<#2\noalign{\@norowcolor}\else
         #1\noalign{\ifodd\rownum\@oddrowcolor\else\@evenrowcolor\fi}\fi
       \fi}%
   \fi
   \CT@everycr{\@rowc@lors\the\everycr}%
   \ignorespaces}
%    \end{macrocode}
%
%    \begin{macrocode}
 \def\@rowc@lors{\noalign{\global\advance\rownum\@ne}\@rowcolors}
 \let\@rowcolors\@empty
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\showrowcolors}
% \begin{macro}{\hiderowcolors}
% Switch coloring mode on/off.
%    \begin{macrocode}
 \def\showrowcolors{\noalign{\global\@rowcolorstrue}\@rowcolors}
 \def\hiderowcolors{\noalign{\global\@rowcolorsfalse\@norowcolor}}
 \def\@norowcolor{\global\let\CT@row@color\relax}
 \@norowcolor
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\if@rowcolors}
% \begin{macro}{\if@rowcmd}
%    \begin{macrocode}
 \newif\if@rowcolors
 \newif\if@rowcmd
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\rownum}
% Reserve a counter register.
%    \begin{macrocode}
 \@ifundefined{rownum}{\newcount\rownum}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\CT@extract}
% This is a fix for active `!' character to enable color expressions; it is apparently only necessary for |\columncolor| commands within |\multicolumn|.
%    \begin{macrocode}
 \def\CT@extract#1\columncolor#2#3\@nil
  {\if!#2%
     \let\CT@column@color\@empty
   \else
     \if[#2%
       \expandafter\CT@extractb
     \else
       \XC@edef\XC@@tmp{#2}%
       \edef\CT@column@color{\noexpand\CT@color{\XC@@tmp}}%
       \expandafter\CT@extractd
     \fi
     {#1}#3\@nil
   \fi}
%    \end{macrocode}
% \end{macro}
%
% End of conditional code for colored tables.
%    \begin{macrocode}
}{}
%    \end{macrocode}
%
%
% \subsubsection{Color information}
%
% \begin{macro}{\extractcolorspec}
%   \marg{color}\marg{cmd}\\
% Extracts the color specification of \Meta{color} and puts it into \Meta{cmd}; equivalent to
% |\def|\Meta{cmd}|{|\marg{model}\marg{spec}|}|.
%    \begin{macrocode}
\def\extractcolorspec#1#2%
 {\XC@split{#1}\edef\@@tmp{{\@@mod}{\@@clr}}\aftergroupdef#2\@@tmp}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\extractcolorspecs}
%   \marg{color}\marg{model-cmd}\marg{color-cmd}\\
% Extracts the color specification of \Meta{color} and puts it into \Meta{model-cmd} and \Meta{color-cmd}, respectively.
%    \begin{macrocode}
\def\extractcolorspecs#1#2#3%
 {\extractcolorspec{#1}#3%
  \edef#2{\expandafter\@firstoftwo#3}%
  \edef#3{\expandafter\@secondoftwo#3}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@extract@hue}
% Extract first entry of comma-separated value list.
%    \begin{macrocode}
\def\XC@extract@hue#1,#2:#3{\edef#3{#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@extract@hue}
% Change first entry of comma-separated value list.
%    \begin{macrocode}
\def\XC@replace@hue#1,#2:#3,#4{\edef#4{#3,#2}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ifundefinedcolor}
%   \marg{name}\marg{undefined}\marg{defined}\\
% Checks whether \Meta{name} is a defined color name and executes the respective code.
%    \begin{macrocode}
\def\@ifundefinedcolor#1{\@ifundefined{\string\color@#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ifundefinedmodel}
%   \marg{model}\marg{undefined}\marg{defined}\\
% Checks whether \Meta{model} is a defined color model and executes the respective code.
%    \begin{macrocode}
\def\@ifundefinedmodel#1{\@ifundefined{color@#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@type}
%   \marg{name}\\
% Determines the \emph{type} of color \Meta{name}, expressed as a natural number (here, $t_1,t_2,\dots$ denote the tokens of |\\color@|\Meta{name}):
% \begin{center}
% \begin{tabular}{cll}
% \em type& \em description& \em conditions\\
% 0 & undefined\\
% 1 & unidentified& $t_1\neq|\xcolor@|$\\
% 2 & named & $t_1=|\xcolor@|\quad t_2\neq\emptyset$\\
% 3 & declared & $t_1=|\xcolor@|\quad t_2=\emptyset\quad t_3\neq\emptyset$\\
% 4 & undeclared & $t_1=|\xcolor@|\quad t_2=\emptyset\quad t_3=\emptyset$\\
% \end{tabular}
% \end{center}
%    \begin{macrocode}
\def\XC@type#1%
 {\expandafter\expandafter\expandafter\XC@typ@
  \csname\string\color@#1\endcsname\@empty\@empty\@empty\XC@@}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@typ@#1#2#3#4\XC@@
 {\ifx#1\relax 0\else
    \ifx#1\xcolor@
      \ifx$#2$%
        \ifx$#3$4\else3\fi\@gobbletwo
      \else2\fi\@gobbletwo
    \else1\fi
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@info}
%   \marg{color}\marg{cmd}\\
% Determines the \emph{type} of color \Meta{color}, expressed as a natural number; the result is stored in \Meta{cmd}.
% \begin{center}
% \begin{tabular}{cll}
% \em type& \em description& \em examples\\
% 0 & implicit name& `|.|'\\
% 1 & explicit name& `|red|', `|green|'\\
% 2 & standard color expression& `|-red|', `|green!50|'\\
% 3 & extended color expression& `|rgb:-red,1;green!50,2|'\\
% 4 & color function expression& `|rgb:-red,1;green!50,2>wheel,30|'\\
% \end{tabular}
% \end{center}
%    \begin{macrocode}
\def\XC@info#1#2%
 {\XC@edef#2{#1}%
  \if.#2\def#2{0}\else\expandafter\in@\expandafter>\expandafter{#2}%
  \ifin@\def#2{4}\else\expandafter\in@\expandafter:\expandafter{#2}%
  \ifin@\def#2{3}\else\expandafter\in@\expandafter!\expandafter{#2}%
  \ifin@\def#2{2}\else\edef#2{\noexpand\in@{/-}{/#2}}#2%
  \edef#2{\ifin@2\else1\fi}\fi\fi\fi\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tracingcolors}
% Put the integer following |\tracingcolors| into the macro |\XC@tracing|.
%    \begin{macrocode}
\def\tracingcolors{\begingroup\afterassignment\XC@tracingcolors\count@}
\def\XC@tracingcolors{\aftergroupdef\XC@tracing{\the\count@}}
%    \end{macrocode}
%
%    \begin{macrocode}
\tracingcolors=0
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@logdef}
%   \marg{name}\\
% Issue a log file information if color \Meta{name} is being (re)defined.
%    \begin{macrocode}
\def\XC@logdef#1%
 {\ifnum\XC@tracing>1
    \@ifundefinedcolor{#1}%
     {\ifnum\XC@tracing>2
        \PackageInfo{xcolor}{Defining color `#1'}%
      \fi}%
     {\PackageInfo{xcolor}{Redefining color `#1'}}%
  \fi}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Color testing}
%
% \begin{environment}{testcolors}
%   \oarg{num models}\\
% This is a simple tabular environment in order to test (display) colors in different models, showing both the visual result and the model-specific parameters.
% The optional \Meta{num models} argument is a comma-separated list of \emph{numerical} color models.
%    \begin{macrocode}
\newenvironment*{testcolors}[1][rgb,cmyk,hsb,HTML]%
 {\let\@@nam\@empty\count@\z@
  \@for\@@tmp:=#1\do
    {\advance\count@\@ne
     \XC@sdef\@@tmp{\@@tmp}\edef\@@nam{\@@nam{\@@tmp}}}%
  \edef\@@num{\the\count@}%
%    \end{macrocode}
%
% Check whether the actual font belongs to a set of OT1-encoded monospaced fonts in order to display |>| instead of |\textgreater|.
% \begin{macro}{\XC@@gt}
%    \begin{macrocode}
  \def\XC@@gt{\textgreater}\def\@@tmp{OT1}%
  \ifx\f@encoding\@@tmp
    \@expandtwoargs\in@{,\f@family,}{,cmtt,pcr,}%
    \ifin@\def\XC@@gt{>}\fi
  \fi
%    \end{macrocode}
%  \end{macro}
%
% Disable prologue and tracing commands for temporary color definitions.
%    \begin{macrocode}
  \def\XC@@xcp@{-1}\ifnum\XC@tracing>1 \def\XC@tracing{1}\fi
%    \end{macrocode}
%
% \begin{macro}{\testcolor}
%   \marg{color}\\
%   \oarg{model-list}\marg{spec-list}\\
% Each |\testcolor| command generates a table row.
% If the column-model matches the model of the color in question, its parameters are underlined.
%    \begin{macrocode}
  \def\testcolor{\@testopt{\@testcolor}{}}%
  \def\@testcolor[##1]##2%
   {\XC@mdef\@@mod{##1}\XC@edef\@@clr{##2}%
    \ifx\@@mod\@empty
      \let\@@arg\@@clr\XC@replace\@@arg>\XC@@gt\else
      \edef\@@arg{[\@@mod]{\@@clr}}\XC@definecolor[]{*}\@@mod\@@clr
      \def\@@clr{*}\fi
    \XC@append\@@arg{&}\extractcolorspecs\@@clr\@@mod\@@clr
    \@testc@lor}%
%    \end{macrocode}
%  \end{macro}
%
% Common loop macro for table head and |\testcolor| rows.
% Note that this command is only available within the |testcolors| environment.
%    \begin{macrocode}
  \def\@testc@lor
   {\count@\z@
    \expandafter\@tfor\expandafter\@@tmp\expandafter:\expandafter=\@@nam\do
     {\ifx\@@clr\@empty
        \edef\@@cmd{\noexpand\textbf{\@@tmp}}%
      \else
        \convertcolorspec\@@mod\@@clr\@@tmp\@@cmd
        \edef\@@cmd
         {\noexpand\@testc@l@r{\@@tmp}{\@@cmd}%
          \ifx\@@mod\@@tmp\noexpand\underline\fi
          {\expandafter\XC@strip@comma\@@cmd,,\@nnil}}%
      \fi
      \expandafter\XC@append\expandafter\@@arg\expandafter{\@@cmd}%
      \advance\count@\@ne
      \ifnum\count@=\@@num\XC@append\@@arg{\\}\else\XC@append\@@arg{&}\fi}%
    \@@arg}%
%    \end{macrocode}
%
% Display color sample box:
%    \begin{macrocode}
  \def\@testc@l@r##1##2%
   {\fboxsep\z@\fbox{\colorbox[##1]{##2}{\phantom{XX}}} }%
%    \end{macrocode}
%
% Now start the table:
%    \begin{macrocode}
  \tabular{@{}l*{\@@num}{l}@{}}%
  \def\@@arg{\textbf{color}& }\let\@@clr\@empty\@testc@lor}%
%    \end{macrocode}
%
% End of environment:
%    \begin{macrocode}
 {\endtabular\ignorespacesafterend}
%    \end{macrocode}
%  \end{environment}
%
%
% \subsubsection{Extra groups}
% Turning on extra groups in the standard \LaTeX\ commands, so that color commands are scoped corectly.
%
% Like |\normalcolor|, the following five commands are defined in the kernel, with empty definitions (|\relax|).
% This means that they can be used to make macros in packages `color safe'.
% The commands will not have any effect unless a user also uses a color package, when the `active definitions' here will take effect and keep color commands correctly scoped.
%
% \begin{macro}{\color@setgroup}
% This is to be used in contexts (e.g., `lrbox') where text is to be saved and used after some other, unknown, text that may contain color commands.
% A matching |\color@endgroup| should be used at the end of the text.
%    \begin{macrocode}
\def\color@setgroup{\begingroup\set@color}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\color@begingroup}
% This is to be used at the start of contexts that may contain color commands, but where it is not necessary to save the current color.
% Examples of this are in the box commands of \File{ltboxes.dtx} where user-supplied text is saved internally in a box between |\color@begingroup|, |\color@endgroup|, but the box is used before any other color commands could intervene.
% A matching |\color@endgroup| should be used at the end of the text.
%    \begin{macrocode}
\let\color@begingroup\begingroup
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\color@endgroup}
% To be used to close the `group' started by one of the above two commands.
% The |\endgraf| in its definition is required in the case of groups of text in vertical `par' mode, but doesn't do any harm in horizontal `LR' contexts.
%    \begin{macrocode}
\def\color@endgroup{\endgraf\endgroup}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\color@hbox}
% To be used to open a `colored hbox'
%    \begin{macrocode}
\def\color@hbox{\hbox\bgroup\color@begingroup}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\color@vbox}
% To be used to open a `colored hbox'
%    \begin{macrocode}
\def\color@vbox{\vbox\bgroup\color@begingroup}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\color@endbox}
% To be used to close a `colored (h/v)box'
%    \begin{macrocode}
\def\color@endbox{\color@endgroup\egroup}
%    \end{macrocode}
%  \end{macro}
%
%
%
% \subsection{Color calculation}
%
% \subsubsection{Color conversion}
%
% \begin{macro}{\convertcolorspec}
%   \marg{source model}\marg{spec}\marg{target model}\marg{cmd}\\
% General color conversion command.
%    \begin{macrocode}
\def\convertcolorspec#1#2#3#4%
 {\begingroup
  \XC@sdef\sm{#1}\XC@sdef\tm{#3}\edef\@@tmp{#2}%
  \ifx\sm\XC@mod@named\extractcolorspecs\@@tmp\sm\@@tmp\fi
  \ifx\sm\tm\else\csname XC@cnv@\sm\expandafter\endcsname\@@tmp,\fi
  \aftergroupdef#4\@@tmp}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@coremodel}
%   \marg{model-cmd}\marg{color-cmd}\\
% Convert color, given by \marg{model-cmd} and \marg{color-cmd}, into parametrisation in one of the \emph{core} models.
% The result is again saved in \marg{model-cmd} and \marg{color-cmd}.
%    \begin{macrocode}
\def\XC@coremodel#1#2%
 {\XC@ifxcase#1%
   {\XC@mod@RGB {\convertcolorspec#1#2\XC@mod@rgb#2\let#1\XC@mod@rgb}%
    \XC@mod@HTML{\convertcolorspec#1#2\XC@mod@rgb#2\let#1\XC@mod@rgb}%
    \XC@mod@Hsb {\convertcolorspec#1#2\XC@mod@hsb#2\let#1\XC@mod@hsb}%
    \XC@mod@tHsb{\convertcolorspec#1#2\XC@mod@hsb#2\let#1\XC@mod@hsb}%
    \XC@mod@HSB {\convertcolorspec#1#2\XC@mod@hsb#2\let#1\XC@mod@hsb}%
    \XC@mod@Gray{\convertcolorspec#1#2\XC@mod@gray#2\let#1\XC@mod@gray}%
    \XC@mod@wave{\convertcolorspec#1#2\XC@mod@hsb#2\let#1\XC@mod@hsb}%
    \XC@mod@named{}%
    \XC@mod@ps{}}%
   {\expandafter\XC@calc@#2,,,,:N\let#2\@@tmp}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@rgb}
%   \Meta{red}|,|\Meta{green}|,|\Meta{blue}|,|
%    \begin{macrocode}
\def\XC@cnv@rgb#1,#2,#3,%
 {\XC@ifxcase\tm
   {\XC@mod@cmy {\XC@calc@#1,#2,#3,,:C}%
    \XC@mod@cmyk
     {\XC@calc@#1,#2,#3,,:C\expandafter\XC@cnv@cmy@cmyk\@@tmp,}%
    \XC@mod@RGB {\edef\@@scl{\rangeRGB}\XC@calc@#1,#2,#3,,:M}%
    \XC@mod@HTML{\edef\@@scl{\@cclv}\XC@calc@#1,#2,#3,,:M%
      \expandafter\XC@calc@\@@tmp,,:H%
      \expandafter\XC@cnv@rgb@HTML\@@tmp,}%
    \XC@mod@gray{\XC@cnv@rgb@gray#1,#2,#3,}%
    \XC@mod@Gray{\XC@cnv@rgb@gray#1,#2,#3,\XC@cnv@gray\@@tmp,}}%
   {\XC@cnv@rgb@hsb#1,#2,#3,\XC@cnv@hsb@}}
%    \end{macrocode}
%
% \begin{macro}{\XC@cnv@rgb@}
%    \begin{macrocode}
\def\XC@cnv@rgb@
 {\ifx\tm\XC@mod@rgb\else\expandafter\XC@cnv@rgb\@@tmp,\fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\XC@cnv@rgb@hsb}
%   \Meta{red}|,|\Meta{green}|,|\Meta{blue}|,|
%    \begin{macrocode}
\def\XC@cnv@rgb@hsb#1,#2,#3,%
 {\count@\z@
  \ifdim#2\p@>#1\p@ \else\advance\count@4 \fi
  \ifdim#3\p@>#2\p@ \else\advance\count@2 \fi
  \ifdim#1\p@>#3\p@ \else\advance\count@1 \fi
  \ifcase\count@\or
  \XC@c@v@rgb@hsb{#3}{#2}{#1}3{}\or
  \XC@c@v@rgb@hsb{#2}{#1}{#3}1{}\or
  \XC@c@v@rgb@hsb{#2}{#3}{#1}3-\or
  \XC@c@v@rgb@hsb{#1}{#3}{#2}5{}\or
  \XC@c@v@rgb@hsb{#3}{#1}{#2}5-\or
  \XC@c@v@rgb@hsb{#1}{#2}{#3}1-\or
  \def\@tempa{0}\def\@tempb{0}\XC@calcN{#3}\@tempc
  \fi
  \edef\@@tmp{\@tempa,\@tempb,\@tempc}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@c@v@rgb@hsb}
%   \marg{max}\marg{med}\marg{min}\marg{const}\marg{sign}
%    \begin{macrocode}
\def\XC@c@v@rgb@hsb#1#2#3#4#5%
 {\XC@calcN{#1}\@tempc \llshiftset\dimen@{#1}%
  \llshiftset\@tempdimb{-#3}\advance\@tempdimb\dimen@
  \llshiftset\@tempdima{-#5#2}\advance\@tempdima#5\dimen@
  \advance\@tempdima#4\@tempdimb \rdivide\@tempdima{6\@tempdimb}%
  \edef\@tempa{\ifdim\@tempdima>\p@1\else\strip@pt\@tempdima\fi}%
  \rdivide\@tempdimb\dimen@
  \edef\@tempb{\strip@pt\@tempdimb}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@rgb@gray}
%   \Meta{red}|,|\Meta{green}|,|\Meta{blue}|,|
%    \begin{macrocode}
\def\XC@cnv@rgb@gray#1,#2,#3,%
 {\llshiftset\dimen@{#1}\@tempdima30\dimen@
  \llshiftset\dimen@{#2}\advance\@tempdima59\dimen@
  \llshiftset\dimen@{#3}\advance\@tempdima11\dimen@
  \rrshift\@tempdima \rdivide\@tempdima{100}%
  \edef\@@tmp{\strip@pt\@tempdima}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@rgb@HTML}
%   \Meta{red}|,|\Meta{green}|,|\Meta{blue}|,|
%    \begin{macrocode}
\def\XC@cnv@rgb@HTML#1,#2,#3,%
 {\edef\@@tmp{#1#2#3}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@cnv@cmy}
%   \Meta{cyan}|,|\Meta{magenta}|,|\Meta{yellow}|,|
%    \begin{macrocode}
\def\XC@cnv@cmy#1,#2,#3,%
 {\XC@ifxcase\tm
   {\XC@mod@cmyk{\XC@cnv@cmy@cmyk#1,#2,#3,}%
    \XC@mod@gray{\XC@cnv@rgb@gray#1,#2,#3,\XC@calcC\@@tmp\@@tmp}%
    \XC@mod@Gray{\XC@cnv@rgb@gray#1,#2,#3,\XC@calcC\@@tmp\@@tmp
      \XC@cnv@gray\@@tmp,}}%
   {\XC@calc@#1,#2,#3,,:C\XC@cnv@rgb@}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@cmy@cmyk}
%   \Meta{cyan}|,|\Meta{magenta}|,|\Meta{yellow}|,|\\
% This transformation includes linear \emph{undercolor-removal} and \emph{black-generation}, as specified by the 4-dimensional parameter vector |\adjustUCRBG|.
%    \begin{macrocode}
\def\XC@cnv@cmy@cmyk#1,#2,#3,%
 {\edef\@@scl
   {\ifdim#1\p@<#2\p@
    \ifdim#1\p@<#3\p@ #1\else #3\fi \else
    \ifdim#2\p@<#3\p@ #2\else #3\fi \fi}%
  \expandafter\XC@calc@\adjustUCRBG,:S%
  \expandafter\XC@c@v@cmy@cmyk\@@tmp,#1,#2,#3,}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@c@v@cmy@cmyk#1,#2,#3,#4,#5,#6,#7,%
 {\XC@add#5,#6,#7,,-#1,-#2,-#3,,\@@tmp \edef\@@tmp{\@@tmp,#4}%
  \expandafter\XC@calc@\@@tmp,:N}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@cnv@cmyk}
%   \Meta{cyan}|,|\Meta{magenta}|,|\Meta{yellow}|,|\Meta{black}|,|
%    \begin{macrocode}
\def\XC@cnv@cmyk#1,#2,#3,#4,%
 {\XC@ifxcase\tm
   {\XC@mod@gray{\XC@cnv@rgb@gray#1,#2,#3,\edef\@@arg{#4}%
      \XC@calcT\@@tmp\@@tmp \XC@calcC\@@tmp\@@tmp}%
    \XC@mod@Gray{\XC@cnv@rgb@gray#1,#2,#3,\edef\@@arg{#4}%
      \XC@calcT\@@tmp\@@tmp \XC@calcC\@@tmp\@@tmp \XC@cnv@gray\@@tmp,}}%
   {\XC@cnv@cmyk@cmy#1,#2,#3,#4,%
    \ifx\tm\XC@mod@cmy\else\expandafter\XC@cnv@cmy\@@tmp,\fi}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@cmyk@cmy}
%   \Meta{cyan}|,|\Meta{magenta}|,|\Meta{yellow}|,|\Meta{black}|,|
%    \begin{macrocode}
\def\XC@cnv@cmyk@cmy#1,#2,#3,#4,%
 {\edef\@@arg{#4}\XC@calc@#1,#2,#3,,:T}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@cnv@hsb}
%   \Meta{hue}|,|\Meta{saturation}|,|\Meta{brightness}|,|
%    \begin{macrocode}
\def\XC@cnv@hsb#1,#2,#3,%
 {\XC@ifxcase\tm
   {\XC@mod@Hsb {\XC@cnv@hsb@Hsb#1,#2,#3,}%
    \XC@mod@tHsb{\XC@cnv@hsb@Hsb#1,#2,#3,\expandafter\XC@cnv@Hsb\@@tmp,}%
    \XC@mod@HSB {\edef\@@scl{\rangeHSB}\XC@calc@#1,#2,#3,,:M}}%
   {\XC@cnv@hsb@rgb#1,#2,#3,\XC@cnv@rgb@}}
%    \end{macrocode}
%
% \begin{macro}{\XC@cnv@hsb@}
%    \begin{macrocode}
\def\XC@cnv@hsb@
 {\ifx\tm\XC@mod@hsb\else\expandafter\XC@cnv@hsb\@@tmp,\fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\XC@cnv@hsb@rgb}
%   \Meta{hue}|,|\Meta{saturation}|,|\Meta{brightness}|,|
%    \begin{macrocode}
\def\XC@cnv@hsb@rgb#1,#2,#3,%
 {\llshiftset\dimen@{#1}\dimen@6\dimen@ \rrshift\dimen@
  \afterassignment\dimen@\count@=\the\dimen@
  \edef\@@tmp{\strip@pt\dimen@}%
  \ifodd\count@\else\XC@calcC\@@tmp\@@tmp\fi
  \edef\@@tmp
   {\ifcase\count@ 0,\@@tmp,1\or \@@tmp,0,1\or 1,0,\@@tmp\or
    1,\@@tmp,0\or \@@tmp,1,0\or 0,1,\@@tmp\or 0,\@@tmp,1\fi}%
  \edef\@@scl{#2}\expandafter\XC@calc@\@@tmp,,:S%
  \expandafter\XC@calc@\@@tmp,,:C%
  \edef\@@scl{#3}\expandafter\XC@calc@\@@tmp,,:S%
  \expandafter\XC@calc@\@@tmp,,:N}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@hsb@Hsb}
%   \Meta{hue}|,|\Meta{saturation}|,|\Meta{brightness}|,|
%    \begin{macrocode}
\def\XC@cnv@hsb@Hsb#1,#2,#3,%
 {\XC@c@lcS\rangeHsb{,#2,#3}{#1}\@@tmp}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@gray}
%   \Meta{gray}|,|
%    \begin{macrocode}
\def\XC@cnv@gray#1,%
 {\XC@ifxcase\tm
   {\XC@mod@rgb {\XC@calcN{#1}\@@tmp \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}}%
    \XC@mod@cmy {\XC@calcC{#1}\@@tmp \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}}%
    \XC@mod@cmyk{\XC@calcC{#1}\@@tmp \edef\@@tmp{0,0,0,\@@tmp}}%
    \XC@mod@RGB {\edef\@@scl{\rangeRGB}\XC@calcM{#1}\@@tmp
      \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}}%
    \XC@mod@HTML{\edef\@@scl{\@cclv}\XC@calcM{#1}\@@tmp
      \XC@calcH\@@tmp\@@tmp \edef\@@tmp{\@@tmp\@@tmp\@@tmp}}%
    \XC@mod@HSB {\edef\@@scl{\rangeHSB}\XC@calcM{#1}\@@tmp
      \edef\@@tmp{0,0,\@@tmp}}%
    \XC@mod@Gray{\edef\@@scl{\rangeGray}\XC@calcM{#1}\@@tmp}}%
   {\XC@calcN{#1}\@@tmp \edef\@@tmp{0,0,\@@tmp}}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@cnv@RGB}
%   \Meta{Red}|,|\Meta{Green}|,|\Meta{Blue}|,|
%    \begin{macrocode}
\def\XC@cnv@RGB#1,#2,#3,%
 {\edef\@@scl{\rangeRGB}\XC@calc@#1,#2,#3,,:D\XC@cnv@rgb@}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@cnv@HTML}
%   \Meta{RRGGBB}|,|
%    \begin{macrocode}
\def\XC@cnv@HTML#1,%
 {\edef\@@tmp{\expandafter\@hex@Hex#1\relax}\expandafter\XC@cnv@HTML@\@@tmp
  \edef\@@scl{\@cclv}\expandafter\XC@calc@\@@tmp,,:D\XC@cnv@rgb@}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@cnv@HTML@#1#2#3#4#5#6%
 {\edef\@@tmp{\number"#1#2,\number"#3#4,\number"#5#6}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@cnv@Hsb}
%   \Meta{hue\Circ}|,|\Meta{saturation}|,|\Meta{brightness}|,|
%    \begin{macrocode}
\def\XC@cnv@Hsb#1,#2,#3,%
 {\ifx\tm\XC@mod@tHsb\XC@cnv@@Hsb#1,#2,#3,\XC@cnv@Hsb@
  \else\XC@cnv@Hsb@hsb#1,#2,#3,\XC@cnv@hsb@\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@Hsb@hsb}
%   \Meta{hue\Circ}|,|\Meta{saturation}|,|\Meta{brightness}|,|
%    \begin{macrocode}
\def\XC@cnv@Hsb@hsb#1,#2,#3,%
 {\XC@c@lcD\rangeHsb{,#2,#3}{#1}\@@tmp}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@@Hsb}
%   \Meta{hue\Circ}|,|\Meta{saturation}|,|\Meta{brightness}|,|\marg{cmd}
%    \begin{macrocode}
\def\XC@cnv@@Hsb#1,#2,#3,#4%
 {\dimen@\rangeHsb\p@ \advance\dimen@\p@ \edef\@@tmp{\strip@pt\dimen@}%
  \edef\@@tmp{0,0;\rangetHsb;\rangeHsb,\rangeHsb;\@@tmp,\@@tmp;}%
  \dimen@#1\p@ \expandafter#4\@@tmp\@nnil
  \edef\@@tmp{\strip@pt\dimen@,#2,#3}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@Hsb@}
%   \Meta{x}|,|\Meta{y}|;|\Meta{x'}|,|\Meta{y'}|;|
%    \begin{macrocode}
\def\XC@cnv@Hsb@#1,#2;#3,#4;%
 {\ifdim\dimen@<#4\p@
    \@tempdima#3\p@ \advance\@tempdima-#1\p@
    \@tempdimb#4\p@ \advance\@tempdimb-#2\p@
    \rdivide\@tempdima\@tempdimb
    \advance\dimen@-#2\p@ \rmultiply\dimen@{\strip@pt\@tempdima}%
    \advance\dimen@#1\p@ \expandafter\remove@to@nnil
  \else
    \def\@@tmp{\XC@cnv@Hsb@#3,#4;}\expandafter\@@tmp
  \fi}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@cnv@tHsb}
%   \Meta{hue\Circ}|,|\Meta{saturation}|,|\Meta{brightness}|,|
%    \begin{macrocode}
\def\XC@cnv@tHsb#1,#2,#3,%
 {\XC@cnv@@Hsb#1,#2,#3,\XC@cnv@tHsb@
  \ifx\tm\XC@mod@Hsb\else\expandafter\XC@cnv@Hsb\@@tmp,\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@tHsb@}
%   \Meta{x}|,|\Meta{y}|;|\Meta{x'}|,|\Meta{y'}|;|
%    \begin{macrocode}
\def\XC@cnv@tHsb@#1,#2;#3,#4;%
 {\ifdim\dimen@<#3\p@
    \@tempdima#4\p@ \advance\@tempdima-#2\p@
    \@tempdimb#3\p@ \advance\@tempdimb-#1\p@
    \rdivide\@tempdima\@tempdimb
    \advance\dimen@-#1\p@ \rmultiply\dimen@{\strip@pt\@tempdima}%
    \advance\dimen@#2\p@ \expandafter\remove@to@nnil
  \else
    \def\@@tmp{\XC@cnv@tHsb@#3,#4;}\expandafter\@@tmp
  \fi}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@cnv@HSB}
%   \Meta{Hue}|,|\Meta{Saturation}|,|\Meta{Brightness}|,|
%    \begin{macrocode}
\def\XC@cnv@HSB#1,#2,#3,%
 {\edef\@@scl{\rangeHSB}\XC@calc@#1,#2,#3,,:D\XC@cnv@hsb@}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@cnv@Gray}
%   \Meta{Gray}|,|
%    \begin{macrocode}
\def\XC@cnv@Gray#1,%
 {\XC@c@lcD\rangeGray{}{#1}\@@tmp \XC@cnv@gray\@@tmp,}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\XC@cnv@wave}
%   \Meta{lambda}|,|
%    \begin{macrocode}
\def\XC@cnv@wave#1,%
 {\XC@cnv@wave@hsb#1,\XC@cnv@hsb@}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@wave@hsb}
%   \Meta{lambda}|,|
%    \begin{macrocode}
\def\XC@cnv@wave@hsb#1,%
 {\@tempdima#1\p@
%    \end{macrocode}
%
% Calculate hue:
%    \begin{macrocode}
  \ifdim\@tempdima<440\p@
    \XC@c@v@wave@hsb{-.0166667}{7.33333}4{}\else
  \ifdim\@tempdima<490\p@
    \XC@c@v@wave@hsb{.02}{-8.8}4-\else
  \ifdim\@tempdima<510\p@
    \XC@c@v@wave@hsb{-.05}{25.5}2{}\else
  \ifdim\@tempdima<580\p@
    \XC@c@v@wave@hsb{.0142857}{-7.28571}2-\else
  \ifdim\@tempdima<645\p@
    \XC@c@v@wave@hsb{-.0153846}{9.92308}0{}\else
  \dimen@\z@ \fi\fi\fi\fi\fi
  \divide\dimen@6\relax
  \edef\@@tmp{\strip@pt\dimen@,1,}%
%    \end{macrocode}
%
% Calculate brightness:
%    \begin{macrocode}
  \ifdim\@tempdima<420\p@
    \XC@c@v@wave@hsb{.0175}{-6.35}0{}\else
  \ifdim\@tempdima>700\p@
    \XC@c@v@wave@hsb{-.00875}{7.125}0{}\else
  \dimen@\p@ \fi\fi
  \edef\@@tmp{\@@tmp\strip@pt\dimen@}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@c@v@wave@hsb}
%   \marg{factor}\marg{const}\marg{offset}\marg{sign}\\
% Calculates $\Meta{offset} + \Meta{sign}\cdot\varrho\bigl(\Meta{const} + \Meta{factor}\cdot\lambda\bigr)$, where $\varrho$ is the reduction function.
% The result is stored in |\dimen@|.
%    \begin{macrocode}
\def\XC@c@v@wave@hsb#1#2#3#4%
 {\dimen@#1\@tempdima \advance\dimen@#2\p@
  \XC@calcR{\strip@pt\dimen@}\@tempa
  \dimen@#4\@tempa\p@ \advance\dimen@#3\p@}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Color complement}
%
% \begin{macro}{\XC@cnv@cmyk@compl}
%   \Meta{cyan}|,|\Meta{magenta}|,|\Meta{yellow}|,|\Meta{black}|,|
%    \begin{macrocode}
\def\XC@cnv@cmyk@compl#1,#2,#3,#4,%
 {\XC@cnv@cmyk@cmy#1,#2,#3,#4,%
  \expandafter\XC@calc@\@@tmp,,:C\expandafter\XC@cnv@cmy@cmyk\@@tmp,}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@cnv@hsb@compl}
%   \Meta{hue}|,|\Meta{saturation}|,|\Meta{brightness}|,|
%    \begin{macrocode}
\def\XC@cnv@hsb@compl#1,#2,#3,%
 {\lshiftset\dimen@{#1}\advance\dimen@\ifdim\dimen@<5\p@-\fi-5\p@
  \rshift\dimen@ \edef\@@tmp{\strip@pt\dimen@}%
  \lshiftset\dimen@{#3}\@tempdima#2\dimen@
  \@tempdimb\@tempdima \advance\@tempdimb10\p@ \advance\@tempdimb-\dimen@
  \ifdim\@tempdimb=\z@
    \edef\@@tmp{\@@tmp,0,0}%
  \else
    \rdivide\@tempdima\@tempdimb \rshift\@tempdimb
    \edef\@@tmp{\@@tmp,\strip@pt\@tempdima,\strip@pt\@tempdimb}%
  \fi}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Color initialisation}
%
% \subsubsection{Support for missing color models}
%
% These macros provide generic support for missing color models in specific drivers.
% For example, \File{pdftex.def} does not support the \Model{hsb} model.
% It is assumed that at least one of the models \Model{rgb}, \Model{RGB}, \Model{HTML}, \Model{hsb}, \Model{Hsb}, \Model{HSB}, \Model{cmy}, \Model{cmyk}, \Model{gray}, \Model{Gray} exists.
%
% \begin{macro}{\substitutecolormodel}
%   \marg{source model}\marg{target model-list}\\
% Substitute \Meta{source model} by the first actually present model from \Meta{target model-list}:
% each reference to the driver-specific command |\color@|\Meta{source model} is replaced by a color model conversion, followed by the driver-specific command |\color@|\Meta{target model}.
%    \begin{macrocode}
\def\substitutecolormodel#1#2%
 {\XC@sdef\XC@@tmp{\expandafter\XC@substitutecolormodel#2/ignore/\@nnil}%
  \ifx\XC@@tmp\XC@mod@ignore
    \XC@let@cN{color@#1}\color@ignore
  \else
    \expandafter\edef\csname color@#1\endcsname##1##2%
     {\noexpand\convertcolorspec
      \expandafter\noexpand\csname XC@mod@#1\endcsname{##2}%
      \expandafter\noexpand\csname XC@mod@\XC@@tmp\endcsname
      \noexpand\XC@@tmp\noexpand\expandafter
      \expandafter\noexpand\csname color@\XC@@tmp\endcsname
      \noexpand\expandafter##1\noexpand\expandafter{\noexpand\XC@@tmp}}%
  \fi
  \expandafter\xglobalize@\csname color@#1\endcsname \xglobal@stop
  \PackageInfo{xcolor}{Model `#1' substituted by `\XC@@tmp'}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\XC@substitutecolormodel#1/%
 {\@ifundefinedmodel{#1}{\XC@substitutecolormodel}{#1\remove@to@nnil}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\color@ignore}
%   \marg{cmd}\marg{spec}\\
% Empty color model: no driver-specific representation at all.
%    \begin{macrocode}
\def\color@ignore#1#2{\def#1{}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\color@rgb}
%   \marg{cmd}\marg{spec}\\
% Takes the color specification \Meta{spec}, turns it into a driver-specific representation and puts the result into the macro \Meta{cmd}.
% For example, if \File{dvips.def} is loaded, then |\color@rgb\foo{1,0,0}| will be equivalent to |\def\foo{rgb 1 0 0}|.
% In the case of \File{pdftex.def}, it will act like |\def\foo{1 0 0 rg 1 0 0 RG}| instead.
%    \begin{macrocode}
\@ifundefinedmodel{rgb}%
 {\substitutecolormodel{rgb}{RGB/HTML/hsb/Hsb/HSB/cmy/cmyk/gray/Gray}}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\color@cmyk}
%   \marg{cmd}\marg{spec}
%    \begin{macrocode}
\@ifundefinedmodel{cmyk}{\substitutecolormodel{cmyk}{cmy/rgb}}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\color@cmy}
%   \marg{cmd}\marg{spec}
%    \begin{macrocode}
\@ifundefinedmodel{cmy}%
 {\PackageInfo{xcolor}{Model `cmy' substituted by `cmy0'}
  \def\color@cmy#1#2{\color@cmyk#1{#2,0}}}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\color@hsb}
%   \marg{cmd}\marg{spec}\\
% Since the \Option{dvipdfm} and \Option{textures} drivers only pretend to support \Model{hsb}, we have to check for these drivers.
%    \begin{macrocode}
\@ifundefinedmodel{hsb}{\@tempswatrue}%
 {\XC@ifcase\XC@@drv{{dvipdfm,textures}\@tempswatrue}\@tempswafalse}
\if@tempswa
  \substitutecolormodel{hsb}{Hsb/HSB/rgb}
\fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\color@RGB}
%   \marg{cmd}\marg{spec}\\
% If the model is supported and |\rangeRGB| equals 255, we stick to the algorithm provided by the driver.
%    \begin{macrocode}
\@ifundefinedmodel{RGB}%
 {\substitutecolormodel{RGB}{HTML/rgb}}
 {\PackageInfo{xcolor}{Model `RGB' extended}
  \let\XC@color@RGB\color@RGB
  \def\color@RGB#1#2%
   {\relax\ifnum\rangeRGB=255
      \XC@color@RGB#1{#2}%
    \else
      \convertcolorspec\XC@mod@RGB{#2}\XC@mod@rgb\XC@@tmp
      \expandafter\color@rgb\expandafter#1\expandafter{\XC@@tmp}%
    \fi}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\color@gray}
% \begin{macro}{\color@HTML}
% \begin{macro}{\color@Hsb}
% \begin{macro}{\color@tHsb}
% \begin{macro}{\color@HSB}
% \begin{macro}{\color@Gray}
% \begin{macro}{\color@wave}
%   \marg{cmd}\marg{spec}
%    \begin{macrocode}
\@ifundefinedmodel{gray}{\substitutecolormodel{gray}{Gray/rgb}}{}
\@ifundefinedmodel{HTML}{\substitutecolormodel{HTML}{rgb}}{}
\@ifundefinedmodel{Hsb}{\substitutecolormodel{Hsb}{hsb}}{}
\@ifundefinedmodel{tHsb}{\substitutecolormodel{tHsb}{hsb}}{}
\@ifundefinedmodel{HSB}{\substitutecolormodel{HSB}{hsb}}{}
\@ifundefinedmodel{Gray}{\substitutecolormodel{Gray}{gray}}{}
\@ifundefinedmodel{wave}{\substitutecolormodel{wave}{hsb}}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{\Index{PostScript}-related stuff}
%
% \begin{macro}{\XC@getcolor}
%   \marg{color}\marg{cmd}\\
%   \marg{color command}\marg{cmd}\\
%   |{|\oarg{model}\marg{spec}|}|\marg{cmd}\\
% Transformation of a color, given by the first argument, especially needed for \Package{pstricks}.
% The result will always be an internal color representation (as described in section \vref{sec.definition}) and is stored in \Meta{cmd}.
% There are different ways of specifying the color:
% \begin{itemize}
% \item \Meta{color} is a color name, expression, etc., e.g., |\XC@getcolor{green!50}\foo|;
% \item \Meta{color command} is a macro whose \emph{first level} expansion is an internal color representation, e.g., |\XC@getcolor\pslinecolor\foo|;
% \item \Meta{model} and \Meta{spec} provide, as usual, explicit parameter specifications.
% \end{itemize}
%    \begin{macrocode}
\def\XC@getcolor#1#2%
 {\begingroup\toks@{#1}\XC@getc@lor#1\XC@@\aftergroupdef#2{\@@tmp}}
%    \end{macrocode}
%
% Check whether the argument consists of one or more tokens.
% In the first case, expand by one level and go to next check.
% In the second case, assume it's a \Meta{color} and simulate its display, but without performing the real |\set@color| command (which would insert |\special|s, possibly causing trouble with blank spaces).
% This simulation ensures that we get exactly the same color --- including all blending, masking --- as if we had executed an explicit |\color| command at that point.
%    \begin{macrocode}
\def\XC@getc@lor#1#2\XC@@
 {\@ifxempty{#2}%
   {\expandafter\XC@getc@l@r#1\XC@@}%
   {\let\set@color\relax
    \ifx#1[%
      \expandafter\@undeclaredcolor\the\toks@\else
      \expandafter\@declaredcolor\expandafter{\the\toks@}\fi
    \let\@@tmp\XC@current@color}}
%    \end{macrocode}
%
% Check whether the first token is |\xcolor@|.
% In that case, |#1#2| is assumed to be a complete internal color representation.
% Otherwise, perform a simulation as described before.
%    \begin{macrocode}
\def\XC@getc@l@r#1#2\XC@@
 {\ifx#1\xcolor@
    \def\@@tmp{\xcolor@#2}%
  \else
    \let\set@color\relax
    \expandafter\@declaredcolor\expandafter{\the\toks@}%
    \let\@@tmp\XC@current@color
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\XC@usecolor}
%   \marg{name}\\
%   \marg{color command}\\
% Transformation of a color into \Index{PostScript} code.
% The argument may be either a command whose \emph{first-level} expansion is an internal color representation (e.g., the outcome of an |\XC@getcolor| command: |\XC@usecolor\pslinecolor|), or a \Meta{name} (e.g., |\XC@usecolor{green}|).
% Note that non-trivial color expressions like |green!50| are forbidden and that |\XC@usecolor| is fully expandable, for example, |\edef\foo{\XC@usecolor{green}}| is valid.
%    \begin{macrocode}
\def\XC@usecolor#1{\expandafter\XC@usec@lor#1\XC@@}
\def\XC@usec@lor#1#2\XC@@
 {\ifx#1\xcolor@
    \expandafter\expandafter\expandafter\c@lor@to@ps#1#2\@@
  \else
    \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
    \expandafter\c@lor@to@ps\csname\string\color@#1#2\endcsname\@@
  \fi
  \space}
%    \end{macrocode}
%
% For compatibility reasons, we need the following command temporarily; however, |\XC@c@lor@to@ps| will disappear!
%    \begin{macrocode}
\let\XC@c@lor@to@ps\XC@usecolor
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\let\pst@getcolor\XC@getcolor
\let\pst@usecolor\XC@usecolor
%    \end{macrocode}
%
%
% \subsubsection{Whatsit \ldots}
%
% \begin{macro}{\c@lor@special}
% Some drivers do not support all the features of this package.
% They should always put a \Meta{whatsit} in the current list though.
% The following macro has most of the features of |\special|, but does not put anything into the \File{.dvi} file.
% It does write to the |log| file or the terminal (depending on the value of |#1|).
%    \begin{macrocode}
\def\c@lor@special#1#2{\edef\@tempa{\write#1{#2}}\@tempa}
%    \end{macrocode}
%  \end{macro}
%
%
% \subsubsection{Default color}
%
% \begin{macro}{\normalcolor}
% |\normalcolor| is defined (to |\relax|) in the \LaTeX\ kernel, so it is safe to use this in macros that may possibly be used in conjunction with color.
% It will have no effect until the \XCP{} is also loaded.
%    \begin{macrocode}
\def\normalcolor{\let\current@color\default@color\set@color}
%    \end{macrocode}
% \end{macro}
%
%  \begin{macro}{\default@color}
% Internal macro to store the `default' color used by |\normalcolor|.
%    \begin{macrocode}
\AtBeginDocument{\let\default@color\current@color}
%    \end{macrocode}
% \end{macro}
% |\current@color| (which is the expansion of |\XC@current@color|) contains an internal representation of the color at this point in the document.
% This can only be an approximation to the truth as the `macro layer' of \TeX\ does not know where the output routine is going to re-insert floats.
% This is why drivers must maintain their own stack of colors in order to fully support these commands.
%
%
% \subsubsection{Driver-specific definitions for named colors}
%
% \begin{macro}{\c@lor@@named}
% \begin{macro}{\define@color@named}
% We have to modify a few driver-specific commands in order to avoid generation of superfluous macros.
%    \begin{macrocode}
\XC@ifcase\XC@@drv
 {{dvipdf,dvipdfm,dvipdfmx,dvips,pctex32}%
  {\def\c@lor@@named#1,#2,#3\@@#4%
    {\edef#4{\expandafter\expandafter\expandafter\@thirdoffive
             \csname\string\color@#1\endcsname}}
   \def\define@color@named#1#2%
    {\@namedef{\string\color@#1}{{}{}{ \colornameprefix#1}{}{}}}}%
%    \end{macrocode}
%
%    \begin{macrocode}
  {dvipsone,pctexps,pdftex,tcidvi,truetex,vtex,xetex}%
  {\def\c@lor@@named#1,#2,#3\@@#4%
    {\edef#4{\expandafter\expandafter\expandafter\@thirdoffive
             \csname\string\color@#1\endcsname}}
   \def\define@color@named#1#2%
    {\let\@@cls\@empty\@namedef{\string\color@#1}{{}{}{#2}{}{}}}}%
%    \end{macrocode}
%
%    \begin{macrocode}
  {textures}%
  {\def\c@lor@@named#1,#2,#3\@@#4%
    {\edef\@tempa{\color@P@custom{#1}{\if!#2!1\else#2\fi}}%
     \expandafter\def\expandafter#4\@tempa}
   \def\define@color@named#1#2%
    {\edef\@tempa{{#1}{#2}}\expandafter\AddCustomColor\@tempa}
   \def\c@lor@ps@#1 #2\@@
    {\expandafter\expandafter\expandafter\expandafter\expandafter
     \expandafter\expandafter\c@lor@to@ps@
     \csname\string\color@#1\expandafter\endcsname\space
     #2. \@@{#1}}}%
%    \end{macrocode}
%
%    \begin{macrocode}
 }{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsubsection{Basic color definitions}
%
% \Model{rgb}-minded colors.\footnote{Generic definitions:
% \Color{brown} = \Color{violet}|!|50|!|\Color{yellow},
% \Color{lime} = \Color{green}|!|25|!|\Color{yellow},
% \Color{orange} = \Color{red}|!|50|!|\Color{yellow},
% \Color{pink} = \Color{red}|!|25,
% \Color{purple} = \Color{violet}|!|50|!|\Color{red},
% \Color{teal} = \Color{green}|!|50|!|\Color{blue},
% \Color{violet} = \Color{blue}|!|50|!|\Color{red}.}
%    \begin{macrocode}
\definecolorset{rgb/hsb/cmyk/gray}{}{}%
 {red,1,0,0/0,1,1/0,1,1,0/.3;%
  green,0,1,0/.33333,1,1/1,0,1,0/.59;%
  blue,0,0,1/.66667,1,1/1,1,0,0/.11;%
  brown,.75,.5,.25/.083333,.66667,.75/0,.25,.5,.25/.5475;%
  lime,.75,1,0/.20833,1,1/.25,0,1,0/.815;%
  orange,1,.5,0/.083333,1,1/0,.5,1,0/.595;%
  pink,1,.75,.75/0,.25,1/0,.25,.25,0/.825;%
  purple,.75,0,.25/.94444,1,.75/0,.75,.5,.25/.2525;%
  teal,0,.5,.5/.5,1,.5/.5,0,0,.5/.35;%
  violet,.5,0,.5/.83333,1,.5/0,.5,0,.5/.205}%
%    \end{macrocode}
%
% \Model{cmyk}-minded colors.\footnote{Generic definitions:
% \Color{olive} = \Color{red}|!|50|!|\Color{green}.}
%    \begin{macrocode}
\definecolorset{cmyk/rgb/hsb/gray}{}{}%
 {cyan,1,0,0,0/0,1,1/.5,1,1/.7;%
  magenta,0,1,0,0/1,0,1/.83333,1,1/.41;%
  yellow,0,0,1,0/1,1,0/.16667,1,1/.89;%
  olive,0,0,1,.5/.5,.5,0/.16667,1,.5/.39}
%    \end{macrocode}
%
% \Model{gray}-minded colors.
%    \begin{macrocode}
\definecolorset{gray/rgb/hsb/cmyk}{}{}%
 {black,0/0,0,0/0,0,0/0,0,0,1;%
  darkgray,.25/.25,.25,.25/0,0,.25/0,0,0,.75;%
  gray,.5/.5,.5,.5/0,0,.5/0,0,0,.5;%
  lightgray,.75/.75,.75,.75/0,0,.75/0,0,0,.25;%
  white,1/1,1,1/0,0,1/0,0,0,0}
%    \end{macrocode}
%
% Load predefined sets of colors (e.g., \File{dvipsnam.def}).
%    \begin{macrocode}
\XC@@names
%    \end{macrocode}
%
%
% \subsubsection{Finale}
%
% Clear color stack and restore catcodes.
%    \begin{macrocode}
\AtBeginDocument{\let\XC@@stack\@empty}
\let\colornameprefix\XC@@nameprefix
\XC@catcodes
%    \end{macrocode}
%
%    \begin{macrocode}
\csname xcolorcmd\endcsname
\color{black}
%</package>
%    \end{macrocode}
%
%
% \iffalse
%-------------------------------------------------------------------------------
% \fi
%
% \subsection{Auxiliary definitions}
%
% \subsubsection{\Index{PostScript} prologue file \File{xcolor.pro}}
%
%    \begin{macrocode}
%<*dvips>
userdict begin
/setcmycolor{0 setcmykcolor}def
/XCbd{bind def}bind def
/XCed{exch def}XCbd
%    \end{macrocode}
%
% \Index{PostScript} version of |\providecommand|.
%    \begin{macrocode}
/XCdef{exch dup TeXDict exch known{pop pop}{XCed}ifelse}XCbd
%    \end{macrocode}
%
% \Index{PostScript} version of |\providecolor|.
%    \begin{macrocode}
/XCsetcolor{cvx counttomark array astore cvx exch pop XCdef}XCbd
%    \end{macrocode}
%
% Now define model-dependent color definition commands.
%    \begin{macrocode}
/XCcmy{mark exch exec/setcmycolor XCsetcolor}XCbd
/XCcmyk{mark exch exec/setcmykcolor XCsetcolor}XCbd
/XCgray{mark exch exec/setgray XCsetcolor}XCbd
/XChsb{mark exch exec/sethsbcolor XCsetcolor}XCbd
/XCrgb{mark exch exec/setrgbcolor XCsetcolor}XCbd
%    \end{macrocode}
%
% This is a fix for \File{special.pro}'s behaviour to perform a |0 setgray| during |normalscale|.
%    \begin{macrocode}
/XCfixnormalscale{/normalscale{Resolution 72 div VResolution 72 div neg
  scale magscale{DVImag dup scale}if}def}def
%    \end{macrocode}
%
% Grouping operators.
% We have to call |XCfixnormalscale| since |normalscale| is invoked by |@beginspecial| as defined by \File{special.pro}.
%    \begin{macrocode}
/XC!b{save XCfixnormalscale}XCbd
/XC!e{restore}XCbd
%    \end{macrocode}
%
% Scale `sp' coordinates back to `bp' units.
%    \begin{macrocode}
/XCsp2bp{1 65781.76 div dup scale}XCbd
%    \end{macrocode}
%
% \begin{macro}{XCsetline}
%   \meta{linewidth} |XCsetline|\\
% Common line definition.
%    \begin{macrocode}
/XCsetline
 {setlinewidth [] 0 setdash 2 setlinecap 0 setlinejoin 4 setmiterlimit}XCbd
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{XCboxframe}
%   \meta{linewidth} \meta{width} \meta{height} \meta{depth} |XCboxframe|\\
% Draw a frame in `sp' coordinates using LanguageLevel~2.
%    \begin{macrocode}
/XCboxframe{/d XCed/h XCed/w XCed/l XCed w 0 gt{h d neg gt{l 0 gt
 {XCsp2bp l XCsetline
  l 2 div dup translate
  0 d neg w l sub h l sub d add rectstroke}if}if}if}XCbd
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{XCcolorblock}
%   \meta{width} \meta{height} \meta{depth} |XCcolorblock|\\
% Draw a colored box in `sp' coordinates using LanguageLevel~2.
%    \begin{macrocode}
/XCcolorblock{/d XCed/h XCed/w XCed w 0 gt{h d neg gt
 {XCsp2bp 0 XCsetline
  0 d neg w h d add rectfill}if}if}XCbd
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
end
%</dvips>
%    \end{macrocode}
%
%
% \clearpage
% \Finale
% \endinput
%
%
% \iffalse
%-------------------------------------------------------------------------------
%<*svgnames|x11names|hksknames|hksnnames|hksznames|pmsnames|ralnames>
\def\colornameprefix{XC@}
%</svgnames|x11names|hksknames|hksnnames|hksznames|pmsnames|ralnames>
%
%<*svgnames>
\preparecolorset{rgb}{}{}{%
AliceBlue,.94,.972,1;%
AntiqueWhite,.98,.92,.844;%
Aqua,0,1,1;%
Aquamarine,.498,1,.83;%
Azure,.94,1,1;%
Beige,.96,.96,.864;%
Bisque,1,.894,.77;%
Black,0,0,0;%
BlanchedAlmond,1,.92,.804;%
Blue,0,0,1;%
BlueViolet,.54,.17,.888;%
Brown,.648,.165,.165;%
BurlyWood,.87,.72,.53;%
CadetBlue,.372,.62,.628;%
Chartreuse,.498,1,0;%
Chocolate,.824,.41,.116;%
Coral,1,.498,.312;%
CornflowerBlue,.392,.585,.93;%
Cornsilk,1,.972,.864;%
Crimson,.864,.08,.235;%
Cyan,0,1,1;%
DarkBlue,0,0,.545;%
DarkCyan,0,.545,.545;%
DarkGoldenrod,.72,.525,.044;%
DarkGray,.664,.664,.664;%
DarkGreen,0,.392,0;%
DarkGrey,.664,.664,.664;%
DarkKhaki,.74,.716,.42;%
DarkMagenta,.545,0,.545;%
DarkOliveGreen,.332,.42,.185;%
DarkOrange,1,.55,0;%
DarkOrchid,.6,.196,.8;%
DarkRed,.545,0,0;%
DarkSalmon,.912,.59,.48;%
DarkSeaGreen,.56,.736,.56;%
DarkSlateBlue,.284,.24,.545;%
DarkSlateGray,.185,.31,.31;%
DarkSlateGrey,.185,.31,.31;%
DarkTurquoise,0,.808,.82;%
DarkViolet,.58,0,.828;%
DeepPink,1,.08,.576;%
DeepSkyBlue,0,.75,1;%
DimGray,.41,.41,.41;%
DimGrey,.41,.41,.41;%
DodgerBlue,.116,.565,1;%
FireBrick,.698,.132,.132;%
FloralWhite,1,.98,.94;%
ForestGreen,.132,.545,.132;%
Fuchsia,1,0,1;%
Gainsboro,.864,.864,.864;%
GhostWhite,.972,.972,1;%
Gold,1,.844,0;%
Goldenrod,.855,.648,.125;%
Gray,.5,.5,.5;%
Green,0,.5,0;%
GreenYellow,.68,1,.185;%
Grey,.5,.5,.5;%
Honeydew,.94,1,.94;%
HotPink,1,.41,.705;%
IndianRed,.804,.36,.36;%
Indigo,.294,0,.51;%
Ivory,1,1,.94;%
Khaki,.94,.9,.55;%
Lavender,.9,.9,.98;%
LavenderBlush,1,.94,.96;%
LawnGreen,.488,.99,0;%
LemonChiffon,1,.98,.804;%
LightBlue,.68,.848,.9;%
LightCoral,.94,.5,.5;%
LightCyan,.88,1,1;%
LightGoldenrod,.933,.867,.51;%
LightGoldenrodYellow,.98,.98,.824;%
LightGray,.828,.828,.828;%
LightGreen,.565,.932,.565;%
LightGrey,.828,.828,.828;%
LightPink,1,.712,.756;%
LightSalmon,1,.628,.48;%
LightSeaGreen,.125,.698,.668;%
LightSkyBlue,.53,.808,.98;%
LightSlateBlue,.518,.44,1;%
LightSlateGray,.468,.532,.6;%
LightSlateGrey,.468,.532,.6;%
LightSteelBlue,.69,.77,.87;%
LightYellow,1,1,.88;%
Lime,0,1,0;%
LimeGreen,.196,.804,.196;%
Linen,.98,.94,.9;%
Magenta,1,0,1;%
Maroon,.5,0,0;%
MediumAquamarine,.4,.804,.668;%
MediumBlue,0,0,.804;%
MediumOrchid,.73,.332,.828;%
MediumPurple,.576,.44,.86;%
MediumSeaGreen,.235,.7,.444;%
MediumSlateBlue,.484,.408,.932;%
MediumSpringGreen,0,.98,.604;%
MediumTurquoise,.284,.82,.8;%
MediumVioletRed,.78,.084,.52;%
MidnightBlue,.098,.098,.44;%
MintCream,.96,1,.98;%
MistyRose,1,.894,.884;%
Moccasin,1,.894,.71;%
NavajoWhite,1,.87,.68;%
Navy,0,0,.5;%
NavyBlue,0,0,.5;%
OldLace,.992,.96,.9;%
Olive,.5,.5,0;%
OliveDrab,.42,.556,.136;%
Orange,1,.648,0;%
OrangeRed,1,.27,0;%
Orchid,.855,.44,.84;%
PaleGoldenrod,.932,.91,.668;%
PaleGreen,.596,.985,.596;%
PaleTurquoise,.688,.932,.932;%
PaleVioletRed,.86,.44,.576;%
PapayaWhip,1,.936,.835;%
PeachPuff,1,.855,.725;%
Peru,.804,.52,.248;%
Pink,1,.752,.796;%
Plum,.868,.628,.868;%
PowderBlue,.69,.88,.9;%
Purple,.5,0,.5;%
Red,1,0,0;%
RosyBrown,.736,.56,.56;%
RoyalBlue,.255,.41,.884;%
SaddleBrown,.545,.27,.075;%
Salmon,.98,.5,.448;%
SandyBrown,.956,.644,.376;%
SeaGreen,.18,.545,.34;%
Seashell,1,.96,.932;%
Sienna,.628,.32,.176;%
Silver,.752,.752,.752;%
SkyBlue,.53,.808,.92;%
SlateBlue,.415,.352,.804;%
SlateGray,.44,.5,.565;%
SlateGrey,.44,.5,.565;%
Snow,1,.98,.98;%
SpringGreen,0,1,.498;%
SteelBlue,.275,.51,.705;%
Tan,.824,.705,.55;%
Teal,0,.5,.5;%
Thistle,.848,.75,.848;%
Tomato,1,.39,.28;%
Turquoise,.25,.88,.815;%
Violet,.932,.51,.932;%
VioletRed,.816,.125,.565;%
Wheat,.96,.87,.7;%
White,1,1,1;%
WhiteSmoke,.96,.96,.96;%
Yellow,1,1,0;%
YellowGreen,.604,.804,.196}
%</svgnames>
%
%<*x11names>
\preparecolorset{rgb}{}{}{%
AntiqueWhite1,1,.936,.86;%
AntiqueWhite2,.932,.875,.8;%
AntiqueWhite3,.804,.752,.69;%
AntiqueWhite4,.545,.512,.47;%
Aquamarine1,.498,1,.83;%
Aquamarine2,.464,.932,.776;%
Aquamarine3,.4,.804,.668;%
Aquamarine4,.27,.545,.455;%
Azure1,.94,1,1;%
Azure2,.88,.932,.932;%
Azure3,.756,.804,.804;%
Azure4,.512,.545,.545;%
Bisque1,1,.894,.77;%
Bisque2,.932,.835,.716;%
Bisque3,.804,.716,.62;%
Bisque4,.545,.49,.42;%
Blue1,0,0,1;%
Blue2,0,0,.932;%
Blue3,0,0,.804;%
Blue4,0,0,.545;%
Brown1,1,.25,.25;%
Brown2,.932,.23,.23;%
Brown3,.804,.2,.2;%
Brown4,.545,.136,.136;%
Burlywood1,1,.828,.608;%
Burlywood2,.932,.772,.57;%
Burlywood3,.804,.668,.49;%
Burlywood4,.545,.45,.332;%
CadetBlue1,.596,.96,1;%
CadetBlue2,.556,.898,.932;%
CadetBlue3,.48,.772,.804;%
CadetBlue4,.325,.525,.545;%
Chartreuse1,.498,1,0;%
Chartreuse2,.464,.932,0;%
Chartreuse3,.4,.804,0;%
Chartreuse4,.27,.545,0;%
Chocolate1,1,.498,.14;%
Chocolate2,.932,.464,.13;%
Chocolate3,.804,.4,.112;%
Chocolate4,.545,.27,.075;%
Coral1,1,.448,.336;%
Coral2,.932,.415,.312;%
Coral3,.804,.356,.27;%
Coral4,.545,.244,.185;%
Cornsilk1,1,.972,.864;%
Cornsilk2,.932,.91,.804;%
Cornsilk3,.804,.785,.694;%
Cornsilk4,.545,.532,.47;%
Cyan1,0,1,1;%
Cyan2,0,.932,.932;%
Cyan3,0,.804,.804;%
Cyan4,0,.545,.545;%
DarkGoldenrod1,1,.725,.06;%
DarkGoldenrod2,.932,.68,.055;%
DarkGoldenrod3,.804,.585,.048;%
DarkGoldenrod4,.545,.396,.03;%
DarkOliveGreen1,.792,1,.44;%
DarkOliveGreen2,.736,.932,.408;%
DarkOliveGreen3,.635,.804,.352;%
DarkOliveGreen4,.43,.545,.24;%
DarkOrange1,1,.498,0;%
DarkOrange2,.932,.464,0;%
DarkOrange3,.804,.4,0;%
DarkOrange4,.545,.27,0;%
DarkOrchid1,.75,.244,1;%
DarkOrchid2,.698,.228,.932;%
DarkOrchid3,.604,.196,.804;%
DarkOrchid4,.408,.132,.545;%
DarkSeaGreen1,.756,1,.756;%
DarkSeaGreen2,.705,.932,.705;%
DarkSeaGreen3,.608,.804,.608;%
DarkSeaGreen4,.41,.545,.41;%
DarkSlateGray1,.592,1,1;%
DarkSlateGray2,.552,.932,.932;%
DarkSlateGray3,.475,.804,.804;%
DarkSlateGray4,.32,.545,.545;%
DeepPink1,1,.08,.576;%
DeepPink2,.932,.07,.536;%
DeepPink3,.804,.064,.464;%
DeepPink4,.545,.04,.312;%
DeepSkyBlue1,0,.75,1;%
DeepSkyBlue2,0,.698,.932;%
DeepSkyBlue3,0,.604,.804;%
DeepSkyBlue4,0,.408,.545;%
DodgerBlue1,.116,.565,1;%
DodgerBlue2,.11,.525,.932;%
DodgerBlue3,.094,.455,.804;%
DodgerBlue4,.064,.305,.545;%
Firebrick1,1,.19,.19;%
Firebrick2,.932,.172,.172;%
Firebrick3,.804,.15,.15;%
Firebrick4,.545,.1,.1;%
Gold1,1,.844,0;%
Gold2,.932,.79,0;%
Gold3,.804,.68,0;%
Gold4,.545,.46,0;%
Goldenrod1,1,.756,.145;%
Goldenrod2,.932,.705,.132;%
Goldenrod3,.804,.608,.112;%
Goldenrod4,.545,.41,.08;%
Green1,0,1,0;%
Green2,0,.932,0;%
Green3,0,.804,0;%
Green4,0,.545,0;%
Honeydew1,.94,1,.94;%
Honeydew2,.88,.932,.88;%
Honeydew3,.756,.804,.756;%
Honeydew4,.512,.545,.512;%
HotPink1,1,.43,.705;%
HotPink2,.932,.415,.655;%
HotPink3,.804,.376,.565;%
HotPink4,.545,.228,.385;%
IndianRed1,1,.415,.415;%
IndianRed2,.932,.39,.39;%
IndianRed3,.804,.332,.332;%
IndianRed4,.545,.228,.228;%
Ivory1,1,1,.94;%
Ivory2,.932,.932,.88;%
Ivory3,.804,.804,.756;%
Ivory4,.545,.545,.512;%
Khaki1,1,.965,.56;%
Khaki2,.932,.9,.52;%
Khaki3,.804,.776,.45;%
Khaki4,.545,.525,.305;%
LavenderBlush1,1,.94,.96;%
LavenderBlush2,.932,.88,.898;%
LavenderBlush3,.804,.756,.772;%
LavenderBlush4,.545,.512,.525;%
LemonChiffon1,1,.98,.804;%
LemonChiffon2,.932,.912,.75;%
LemonChiffon3,.804,.79,.648;%
LemonChiffon4,.545,.536,.44;%
LightBlue1,.75,.936,1;%
LightBlue2,.698,.875,.932;%
LightBlue3,.604,.752,.804;%
LightBlue4,.408,.512,.545;%
LightCyan1,.88,1,1;%
LightCyan2,.82,.932,.932;%
LightCyan3,.705,.804,.804;%
LightCyan4,.48,.545,.545;%
LightGoldenrod1,1,.925,.545;%
LightGoldenrod2,.932,.864,.51;%
LightGoldenrod3,.804,.745,.44;%
LightGoldenrod4,.545,.505,.298;%
LightPink1,1,.684,.725;%
LightPink2,.932,.635,.68;%
LightPink3,.804,.55,.585;%
LightPink4,.545,.372,.396;%
LightSalmon1,1,.628,.48;%
LightSalmon2,.932,.585,.448;%
LightSalmon3,.804,.505,.385;%
LightSalmon4,.545,.34,.26;%
LightSkyBlue1,.69,.888,1;%
LightSkyBlue2,.644,.828,.932;%
LightSkyBlue3,.552,.712,.804;%
LightSkyBlue4,.376,.484,.545;%
LightSteelBlue1,.792,.884,1;%
LightSteelBlue2,.736,.824,.932;%
LightSteelBlue3,.635,.71,.804;%
LightSteelBlue4,.43,.484,.545;%
LightYellow1,1,1,.88;%
LightYellow2,.932,.932,.82;%
LightYellow3,.804,.804,.705;%
LightYellow4,.545,.545,.48;%
Magenta1,1,0,1;%
Magenta2,.932,0,.932;%
Magenta3,.804,0,.804;%
Magenta4,.545,0,.545;%
Maroon1,1,.204,.7;%
Maroon2,.932,.19,.655;%
Maroon3,.804,.16,.565;%
Maroon4,.545,.11,.385;%
MediumOrchid1,.88,.4,1;%
MediumOrchid2,.82,.372,.932;%
MediumOrchid3,.705,.32,.804;%
MediumOrchid4,.48,.215,.545;%
MediumPurple1,.67,.51,1;%
MediumPurple2,.624,.475,.932;%
MediumPurple3,.536,.408,.804;%
MediumPurple4,.365,.28,.545;%
MistyRose1,1,.894,.884;%
MistyRose2,.932,.835,.824;%
MistyRose3,.804,.716,.71;%
MistyRose4,.545,.49,.484;%
NavajoWhite1,1,.87,.68;%
NavajoWhite2,.932,.81,.63;%
NavajoWhite3,.804,.7,.545;%
NavajoWhite4,.545,.475,.37;%
OliveDrab1,.752,1,.244;%
OliveDrab2,.7,.932,.228;%
OliveDrab3,.604,.804,.196;%
OliveDrab4,.41,.545,.132;%
Orange1,1,.648,0;%
Orange2,.932,.604,0;%
Orange3,.804,.52,0;%
Orange4,.545,.352,0;%
OrangeRed1,1,.27,0;%
OrangeRed2,.932,.25,0;%
OrangeRed3,.804,.215,0;%
OrangeRed4,.545,.145,0;%
Orchid1,1,.512,.98;%
Orchid2,.932,.48,.912;%
Orchid3,.804,.41,.79;%
Orchid4,.545,.28,.536;%
PaleGreen1,.604,1,.604;%
PaleGreen2,.565,.932,.565;%
PaleGreen3,.488,.804,.488;%
PaleGreen4,.33,.545,.33;%
PaleTurquoise1,.732,1,1;%
PaleTurquoise2,.684,.932,.932;%
PaleTurquoise3,.59,.804,.804;%
PaleTurquoise4,.4,.545,.545;%
PaleVioletRed1,1,.51,.67;%
PaleVioletRed2,.932,.475,.624;%
PaleVioletRed3,.804,.408,.536;%
PaleVioletRed4,.545,.28,.365;%
PeachPuff1,1,.855,.725;%
PeachPuff2,.932,.796,.68;%
PeachPuff3,.804,.688,.585;%
PeachPuff4,.545,.468,.396;%
Pink1,1,.71,.772;%
Pink2,.932,.664,.72;%
Pink3,.804,.57,.62;%
Pink4,.545,.39,.424;%
Plum1,1,.732,1;%
Plum2,.932,.684,.932;%
Plum3,.804,.59,.804;%
Plum4,.545,.4,.545;%
Purple1,.608,.19,1;%
Purple2,.57,.172,.932;%
Purple3,.49,.15,.804;%
Purple4,.332,.1,.545;%
Red1,1,0,0;%
Red2,.932,0,0;%
Red3,.804,0,0;%
Red4,.545,0,0;%
RosyBrown1,1,.756,.756;%
RosyBrown2,.932,.705,.705;%
RosyBrown3,.804,.608,.608;%
RosyBrown4,.545,.41,.41;%
RoyalBlue1,.284,.464,1;%
RoyalBlue2,.264,.43,.932;%
RoyalBlue3,.228,.372,.804;%
RoyalBlue4,.152,.25,.545;%
Salmon1,1,.55,.41;%
Salmon2,.932,.51,.385;%
Salmon3,.804,.44,.33;%
Salmon4,.545,.298,.224;%
SeaGreen1,.33,1,.624;%
SeaGreen2,.305,.932,.58;%
SeaGreen3,.264,.804,.5;%
SeaGreen4,.18,.545,.34;%
Seashell1,1,.96,.932;%
Seashell2,.932,.898,.87;%
Seashell3,.804,.772,.75;%
Seashell4,.545,.525,.51;%
Sienna1,1,.51,.28;%
Sienna2,.932,.475,.26;%
Sienna3,.804,.408,.224;%
Sienna4,.545,.28,.15;%
SkyBlue1,.53,.808,1;%
SkyBlue2,.494,.752,.932;%
SkyBlue3,.424,.65,.804;%
SkyBlue4,.29,.44,.545;%
SlateBlue1,.512,.435,1;%
SlateBlue2,.48,.404,.932;%
SlateBlue3,.41,.35,.804;%
SlateBlue4,.28,.235,.545;%
SlateGray1,.776,.888,1;%
SlateGray2,.725,.828,.932;%
SlateGray3,.624,.712,.804;%
SlateGray4,.424,.484,.545;%
Snow1,1,.98,.98;%
Snow2,.932,.912,.912;%
Snow3,.804,.79,.79;%
Snow4,.545,.536,.536;%
SpringGreen1,0,1,.498;%
SpringGreen2,0,.932,.464;%
SpringGreen3,0,.804,.4;%
SpringGreen4,0,.545,.27;%
SteelBlue1,.39,.72,1;%
SteelBlue2,.36,.675,.932;%
SteelBlue3,.31,.58,.804;%
SteelBlue4,.21,.392,.545;%
Tan1,1,.648,.31;%
Tan2,.932,.604,.288;%
Tan3,.804,.52,.248;%
Tan4,.545,.352,.17;%
Thistle1,1,.884,1;%
Thistle2,.932,.824,.932;%
Thistle3,.804,.71,.804;%
Thistle4,.545,.484,.545;%
Tomato1,1,.39,.28;%
Tomato2,.932,.36,.26;%
Tomato3,.804,.31,.224;%
Tomato4,.545,.21,.15;%
Turquoise1,0,.96,1;%
Turquoise2,0,.898,.932;%
Turquoise3,0,.772,.804;%
Turquoise4,0,.525,.545;%
VioletRed1,1,.244,.59;%
VioletRed2,.932,.228,.55;%
VioletRed3,.804,.196,.47;%
VioletRed4,.545,.132,.32;%
Wheat1,1,.905,.73;%
Wheat2,.932,.848,.684;%
Wheat3,.804,.73,.59;%
Wheat4,.545,.494,.4;%
Yellow1,1,1,0;%
Yellow2,.932,.932,0;%
Yellow3,.804,.804,0;%
Yellow4,.545,.545,0;%
Gray0,.745,.745,.745;%
Green0,0,1,0;%
Grey0,.745,.745,.745;%
Maroon0,.69,.19,.376;%
Purple0,.628,.125,.94}
%</x11names>
%
%<*test1>
\documentclass[a4paper]{article}

\usepackage{array,multicol,multido,textcomp}
\usepackage{xcolor}[2005/03/24]
\usepackage[hmargin={1.25cm,.75cm},vmargin=1.25cm,footskip=.5cm,nohead]{geometry}

\newdimen\Argwd
\newdimen\Errsum
\newdimen\Errmax
\newcount\Colors
\newcount\Errors
\newcount\Loops
\newif\ifColor

\makeatletter

\def\DisplayColor#1#2#3%
 {\global\advance\Loops\@ne
  \@tempdima=#1\p@ \edef\@tempa{\the\@tempdima}%
  \edef\Colori{\strip@pt\@tempdima}%
  \ifColor
    \@tempdimb=#2\p@ \edef\@tempb{\the\@tempdimb}%
    \@tempdimc=#3\p@ \edef\@tempc{\the\@tempdimc}%
    \edef\Colori{\Colori,\strip@pt\@tempdimb,\strip@pt\@tempdimc}%
  \fi
  \Make12\Make23\Make34\Make45\Make56\Make67%
  \begin{tabular}{@{}ll*4{@{ }p{\Argwd}}@{}}
  \Row1\Row2\Row3\Row4\Row5\Row6\noalign{\medskip}
  \end{tabular}
  \global\advance\Colors1 \relax\ifnum\Colors=30 \newpage\global\Colors=0 \fi}

\def\Make#1#2%
 {\edef\@@tmp
   {\noexpand\definecolor{Color\romannumeral#1}%
     {\@nameuse{Model\romannumeral#1}}{\@nameuse{Color\romannumeral#1}}%
   }\@@tmp
  \relax\ifnum#1<6
    \convertcolorspec
     {\@nameuse{Model\romannumeral#1}}{\@nameuse{Color\romannumeral#1}}%
     {\@nameuse{Model\romannumeral#2}}\@@tmp
    \XC@let@cN{Color\romannumeral#2}\@@tmp
  \fi}
\def\Row#1%
 {\edef\@@tmp{\@nameuse{Color\romannumeral#1}\@nameuse{Row\romannumeral#1}}%
  \expandafter\@Row\@@tmp}

\def\@Row#1,#2,#3,#4,#5#6%
 {\fcolorbox{black}{Color\romannumeral#5}{\phantom{000}}&
  \csname Model\romannumeral#5\endcsname &
  \ifodd#6 \@Error{#1}\@tempa \else #1\fi &
  \ifColor\ifodd#6 \@Error{#2}\@tempb \else #2\fi\else #2\fi &
  \ifColor\ifodd#6 \@Error{#3}\@tempc \else #3\fi\else #3\fi &
  #4\\}

\def\defModel#1#2#3#4% number, name, commas, check
 {\@namedef{Model\romannumeral#1}{#2}\@namedef{Row\romannumeral#1}{#3#1#4}}

\def\@Error#1#2%
 {\ifdim#1\p@=#2\relax #1\else
    \textcolor{red}{#1}\global\advance\Errors\@ne
    \dimen@#2\advance\dimen@-#1\p@ \ifdim\dimen@<\z@\dimen@-\dimen@\fi
    \global\advance\Errsum\dimen@
    \ifdim\dimen@>\Errmax \global\Errmax\dimen@
      \dimen@\@tempa \edef\@@tempa{\strip@pt\dimen@}%
      \ifColor
        \dimen@\@tempb \edef\@@tempb{\strip@pt\dimen@}%
        \dimen@\@tempc \edef\@@tempc{\strip@pt\dimen@}%
        \xdef\Errcase{\@@tempa\noexpand~\@@tempb\noexpand~\@@tempc}%
      \else
        \xdef\Errcase{\@@tempa}%
      \fi
    \fi
  \fi}

\newenvironment{ColorTest}[1]%
 {\addcontentsline{toc}{section}{Color conversion chain: #1}
  \Colors\z@ \Errors\z@ \Loops\z@ \Errsum\z@ \Errmax\z@
  \begin{multicols}{3}\centering}%
 {\end{multicols}\bigskip
  \begin{tabular}{@{}l@{ = }l@{}}
  \multicolumn2{@{}l@{}}{Rounding error statistics of color conversion test}\\
  \multicolumn2{@{}l@{}}%
   {$\textbf\Modeli\rightarrow \textbf\Modelii\rightarrow \textbf\Modeliii\rightarrow
     \textbf\Modeliv\rightarrow \textbf\Modelv\rightarrow \textbf\Modelvi$:}\\[1ex]
  number of examples& \number\Loops\\
  number of errors& \number\Errors\\
  sum of absolute errors& \strip@pt\Errsum\\
  \ifnum\Errors>\z@
    average error& \Errsum100\Errsum \dimen@\Errors\p@ \divide\dimen@\@m
    \rdivide\Errsum\dimen@ \strip@pt\Errsum\textperiodcentered10\textsuperscript{-5}\\
    maximum error& \strip@pt\Errmax{} @ \Modeli~\Errcase\\
  \fi
  \end{tabular}\newpage}

\def\thepage{\sffamily\footnotesize\@nameuse{@arabic}\c@page}

\makeatother

\parindent0pt
\setcounter{secnumdepth}{-1}

\begin{document}

\title{Color conversion with the \textsf{xcolor} package --- Examples}
\author{Dr. Uwe Kern\thanks{This file is part of the \textsf{xcolor} distribution which can be downloaded from the CTAN mirrors (\texttt{macros/latex/contrib/xcolor/}) or the homepage \texttt{www.ukern.de/tex/xcolor.html}. Please send error reports and suggestions for improvements to \texttt{xcolor@ukern.de}.}}
\date{\XCfileversion{} (\XCfiledate)}
\maketitle

\begin{center}
\begin{minipage}{.75\textwidth}
\tableofcontents
\end{minipage}
\end{center}
\newpage

\sffamily\footnotesize
\fboxrule.25pt
\settowidth\Argwd{0.00000}

\defModel1{rgb}{,,}0
\defModel2{cmy}{,,}0
\defModel3{cmyk}{,}0
\defModel4{hsb}{,,}0
\defModel5{rgb}{,,}1
\defModel6{gray}{,,,,}0
\Colortrue

\begin{ColorTest}{rgb, cmy, cmyk, hsb, rgb, gray}
\multido{\nR=1+-.1}{11}%
 {\multido{\nG=1+-.1}{11}%
  {\multido{\nB=1+-.1}{11}%
   {\DisplayColor{\nR}{\nG}{\nB}}}}%
\end{ColorTest}

\defModel1{gray}{,,,,}0
\defModel2{rgb}{,,}0
\defModel3{cmy}{,,}0
\defModel4{cmyk}{,}0
\defModel5{hsb}{,,}0
\defModel6{gray}{,,,,}1
\Colorfalse

\begin{ColorTest}{gray, rgb, cmy, cmyk, hsb, gray}
\multido{\nG=1+-.01}{101}{\DisplayColor{\nG}{}{}}%
\end{ColorTest}

\end{document}
%</test1>
%
%<*test2>
\listfiles
\documentclass{article}

\usepackage{pstricks,pst-tree,pst-slpe,multido}
\makeatletter
\makeatother
\usepackage{fvrb-ex}

\def\textfraction{0.01}
\def\topfraction{0.99}
\def\bottomfraction{0.99}
\def\floatpagefraction{0.70}
\setlength\abovecaptionskip{12pt}
\setlength\belowcaptionskip{10pt}
\parindent0pt

\begin{document}
\title{Color extensions with the \textsf{xcolor} package --- \textsf{pstricks} examples}
\author{Dr. Uwe Kern\thanks{This file is part of the \textsf{xcolor} distribution which can be downloaded from the CTAN mirrors (\texttt{macros/latex/contrib/xcolor/}) or the homepage \texttt{www.ukern.de/tex/xcolor.html}. Please send error reports and suggestions for improvements to \texttt{xcolor@ukern.de}.}}
\date{\XCfileversion{} (\XCfiledate)}
\maketitle

\centerline{\fcolorbox{red}{yellow!50}{This document is not suitable for pdf\LaTeX! Please use \LaTeX{} + \texttt{dvips} etc.}}

\begin{figure}[htb]\caption{Modified version of an example from the \textsf{pstricks} manual; requires \textsf{pst-tree}}
\begin{SideBySideExample}[fontsize=\footnotesize,xrightmargin=.45\textwidth]
  \begin{pspicture}(-0.5,-2)(3,2)
  \cnode(0,0){.5cm}{root}
  \cnode*[linecolor=red](3,1.5){4pt}{A}
  \cnode*[linecolor=red!72.5375!blue](3,0){4pt}{B}
  \cnode*[linecolor=-red](3,-1.5){4pt}{C}
  \psset{nodesep=3pt}
  \ncline[linecolor=green!50!red]{root}{A}
  \ncline[linecolor=blue]{root}{B}
  \ncline[linecolor=-green!50!red]{root}{C}
  \end{pspicture}
\end{SideBySideExample}
\end{figure}

\begin{figure}[htb]\caption{Moving from one color to its complement; requires \textsf{pst-slpe}}
\begin{SideBySideExample}[fontsize=\footnotesize,xrightmargin=.45\textwidth]
  \begin{pspicture}(4,1)
  \psframe[fillstyle=slope,
           slopeangle=30,
           slopebegin=red!72.5375!blue,
           slopeend=-red!72.5375!blue](4,1)
  \end{pspicture}
\end{SideBySideExample}
\end{figure}

\begin{figure}[htb]\caption{Explicit color specification via a loop command; requires \textsf{multido}}
\begin{SideBySideExample}[fontsize=\footnotesize,xrightmargin=.45\textwidth]
  \psset{unit=1.75}%
  \begin{pspicture}(0,-1)(2,1)
  \multido{\rHue=0.00+0.01}{100}%
   {\pscircle[linewidth=0.01,
              linecolor={[hsb]{\rHue,1,1}}](1,0){\rHue}}
  \end{pspicture}
\end{SideBySideExample}
\end{figure}

\begin{figure}[htb]\caption{Color series --- modified version of an example from the \textsf{pst-fill} manual; note that the \texttt{\string\multirput} command does not give the desired result here}
\begin{SideBySideExample}[fontsize=\footnotesize,xrightmargin=.45\textwidth]
  \newcommand*\Sheep
   {\begin{pspicture}(3,1.5)
    \pscustom[liftpen=2,fillstyle=solid,fillcolor=sheep!!+]%
     {\pscurve(0.5,-0.2)(0.6,0.5)(0.2,1.3)(0,1.5)(0,1.5)
       (0.4,1.3)(0.8,1.5)(2.2,1.9)(3,1.5)(3,1.5)(3.2,1.3)
       (3.6,0.5)(3.4,-0.3)(3,0)(2.2,0.4)(0.5,-0.2)}
    \pscircle*(2.65,1.25){0.12\psunit}% Eye
    \psccurve*(3.5,0.3)(3.35,0.45)(3.5,0.6)(3.6,0.4)% Muzzle
    \pscurve(3,0.35)(3.3,0.1)(3.6,0.05)% Mouth
    \pscurve(2.3,1.3)(2.1,1.5)(2.15,1.7)
    \pscurve(2.1,1.7)(2.35,1.6)(2.45,1.4)% Ear
    \end{pspicture}}
  \definecolorseries
   {sheep}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
  \resetcolorseries{sheep}
  \psset{unit=0.4}
  \begin{pspicture}(-3,-6)(0,7.5)
  \Multido{\ry=6.0+-1.5}{5}%
   {\rput(0,\ry){\Multido{}{5}{\Sheep}}}
  \resetcolorseries{sheep}%
  \multirput(-6,-6)(3,0)5{\Sheep}
  \end{pspicture}
\end{SideBySideExample}
\end{figure}

\begin{figure}[htb]\caption{Interaction with native PostScript code --- $\gamma$-corrected wavelengths}
\begin{Example}[fontsize=\footnotesize,xrightmargin=.45\textwidth]
  \newcount\WL \unitlength.75pt
  \def\WaveToPS#1%
   {\definecolor{tmp}{rgb:wave}{#1}\extractcolorspecs{tmp}\tmpm\tmpc
    \expandafter\WaveToPSi\tmpc,}
  \def\WaveToPSi#1,#2,#3,{\pstVerb{/Red{#1}def /Green{#2}def /Blue{#3}def}}
  \def\DisplayBar#1#2%
   {\linethickness{1.25\unitlength}\WL=360
    \pstVerb{/Gamma{#1}def}%
    \multiput(360,#2)(1,0){456}%
     {\WaveToPS{\the\WL}{\color{lambda}\line(0,1){50}}\global\advance\WL1}%
    \linethickness{0.25\unitlength}\WL=360
    \multiput(360,#2)(20,0){23}%
     {\picture(0,0)
      \line(0,-1){5}\multiput(5,0)(5,0){3}{\line(0,-1){2.5}}%
      \put(0,-10){\makebox(0,0){\the\WL}}\global\advance\WL20
      \endpicture}%
    \put(350,#2){\makebox(0,50)[r]{\small$\gamma$\,=\,#1}}}
  \pstVerb{/Corr{dup 0 gt {Gamma exp}if}def}
  \definecolor[ps]{lambda}{rgb}{Red Corr Green Corr Blue Corr}%
  \begin{picture}(510,345)(310,-10)
  \sffamily\tiny
  \DisplayBar{0.4}{0}%
  \DisplayBar{0.6}{70}%
  \DisplayBar{0.8}{140}%
  \DisplayBar{1.0}{210}%
  \DisplayBar{1.2}{280}%
  \end{picture}
\end{Example}
\end{figure}

\end{document}
%</test2>
%
%<*test3>
\listfiles
\documentclass[a4paper]{article}
\usepackage[showerrors,table,dvipsnames*,hyperref]{xcolor}[2005/12/21]
\usepackage[margin=2.25cm]{geometry}
\usepackage
 [\GinDriver,hyperindex=false,bookmarks,bookmarksopen,bookmarksopenlevel=1,%
  pdftitle={xcolor3 \XCfileversion{} (\XCfiledate)},pdfauthor={Dr. Uwe Kern},%
  pdfsubject={Color extensions for LaTeX and pdfLaTeX},%
  pdfkeywords={xcolor,color,colour,model,tint,tone,shade,harmony,spot,latex,pdftex,dvips,%
   conversion,blend,mix,mask,separation,rgb,cmy,cmyk,hsb,gray,html,wave,thsb,wheel}]{hyperref}

\tracingcolors=4
%%\tracingcolors=3
%%\tracingcolors=2
%%\tracingcolors=1
%%\tracingcolors=0

\parindent0pt
\pagecolor{gray!25}

\definecolors{JungleGreen,DarkOrchid}

\begin{document}
\title{Color extensions with the \textsf{xcolor} package --- various examples}
\author{\href{mailto:xcolor@ukern.de}{\fboxrule0pt\fboxsep2pt\fbox{Dr. Uwe Kern}}}
\date{\XCfileversion{} (\XCfiledate)
\thanks{This file (\texttt{\jobname.tex}) is part of the \textsf{xcolor} distribution which can be downloaded from the CTAN mirrors \texttt{\href{http://www.ctan.org/tex-archive/macros/latex/contrib/xcolor/}{CTAN/macros/latex/contrib/xcolor/}} or the homepage \texttt{\href{http://www.ukern.de/tex/xcolor.html}{www.ukern.de/tex/xcolor.html}}. Please send error reports and suggestions for improvements to \texttt{\href{mailto:xcolor@ukern.de}{xcolor@ukern.de}}.}}
\maketitle

The purpose of this file is to demonstrate a variety of capabilities including the logging facilities of the \textsf{xcolor} package.
By playing around with different values of \texttt{\string\tracingcolors}, one can observe the different behavior in the \texttt{log} file.

\section{Predefined colors}

\begingroup
\small\sffamily
\rowcolors1{}{}
\begin{testcolors}[rgb,cmyk,hsb,HTML,gray]
\testcolor{red}
\testcolor{green}
\testcolor{blue}
\testcolor{cyan}
\testcolor{magenta}
\testcolor{yellow}
\testcolor{orange}
\testcolor{violet}
\testcolor{purple}
\testcolor{brown}
\testcolor{pink}
\testcolor{olive}
\testcolor{black}
\testcolor{darkgray}
\testcolor{gray}
\testcolor{lightgray}
\testcolor{white}
\noalign{\medskip}\hline\noalign{\medskip}
\testcolor{-red}
\testcolor{-green}
\testcolor{-blue}
\testcolor{-cyan}
\testcolor{-magenta}
\testcolor{-yellow}
\testcolor{-orange}
\testcolor{-violet}
\testcolor{-purple}
\testcolor{-brown}
\testcolor{-pink}
\testcolor{-olive}
\testcolor{-black}
\testcolor{-darkgray}
\testcolor{-gray}
\testcolor{-lightgray}
\testcolor{-white}
\noalign{\medskip}\hline\noalign{\medskip}
\testcolor{JungleGreen}
\testcolor{DarkOrchid}
\noalign{\medskip}\hline\noalign{\medskip}
\testcolor{-JungleGreen}
\testcolor{-DarkOrchid}
\end{testcolors}
\endgroup

\vfill

\clearpage
\pagecolor{white}

\section{Color definition and application}

\providecolor{dummy}{rgb}{.6,.5,.4}
\definecolor{dummy}{rgb}{.6,.5,.4}
\providecolor{dummy}{rgb}{.6,.5,.4}
\hbox{\textcolor{dummy}{Test with \texttt{\string\definecolor}}}

\bigskip

Comma-separated and space-separated definitions:

\definecolor{c1}{rgb}{.7,.6,.5}
\definecolor{c2}{rgb}{.7 .6 .5}
\colorlet{c1a}{c1}
\colorlet{c2a}{c2}

\textcolor{c1}{identical} =
\textcolor{c2}{identical} =
\textcolor{c1a}{identical} =
\textcolor{c2a}{identical} =
\textcolor[rgb]{.7,.6,.5}{identical} =
\textcolor[rgb]{.7 .6 .5}{identical} =
\textcolor{rgb,10:red,7;green,6;blue,5}{identical}
\textcolor{rgb,15:red,10.5;green,9;blue,7.5}{identical}

\medskip

\begingroup
\sffamily
\begin{testcolors}
\testcolor{c1}
\testcolor{c2}
\testcolor{c1a}
\testcolor{c2a}
\testcolor[rgb]{.7,.6,.5}
\testcolor[rgb]{.7 .6 .5}
\testcolor{rgb,10:red,7;green,6;blue,5}
\testcolor{rgb,15:red,10.5;green,9;blue,7.5}
\end{testcolors}
\endgroup

\bigskip

\textcolor{rgb:red!50,4;green!25,2}{Another extended color expression (rgb:red!50,4;green!25,2)}.

\bigskip

\begingroup
\color{black}
Test with named colors:\par
\color{blue}
Test: \textcolor[named]{JungleGreen}{JungleGreen};
Test: \textcolor{JungleGreen}{JungleGreen};
Test: \textcolor{JungleGreen!50!DarkOrchid}{JungleGreen!50!DarkOrchid};
Test: \textcolor{green!50!red}{green!50!red}.
\endgroup

\bigskip

{\color[rgb]{.4,.5,.6}Test with \texttt{\string\color}}

\bigskip
Current color application:\par
\def\test{current, \textcolor{.!50}{50\%}, \textcolor{-.}{complement},
          \textcolor{yellow!50!.}{mix}}
\textcolor{blue}{\test} and \textcolor{red}{\test},\par
\def\Test{\color{.!80}Test}
\textcolor{blue}{\Test\Test\Test\Test\Test} and
\textcolor{red}{\Test\Test\Test\Test\Test}.

\bigskip
Current color test with \texttt{\string\definecolorseries}:\par
\begingroup
\color{blue}
\definecolorseries{foo}{rgb}{last}{.}{-.}
\resetcolorseries[5]{foo}
\def\test{\hbox to 1em{{\color{foo!!+}\vrule width 1em height 1.5ex}}}
Test\test\test\test\test\test\test Test

\resetcolorseries[5]{foo}
\def\test{\hbox to 1em{{\color{foo!!++}\vrule width 1em height 1.5ex}}}
Test\test\test\test\test\test\test Test

\resetcolorseries[5]{foo}
\def\test{\hbox to 1em{{\color{foo!![2]}\vrule width 1em height 1.5ex}}}
Test\test\test\test\test\test\test Test

\endgroup

\section{Color in tables}

\rowcolors[\hline]{1}{green!25}{yellow!50}
\begin{tabular}{ll}
test & row \number\rownum\\
test & row \number\rownum\\
\rowcolor{blue!25}
test & row \number\rownum\\
test & row \number\rownum\\
\hiderowcolors
test & row \number\rownum\\
test & row \number\rownum\\
\showrowcolors
test & row \number\rownum\\
test & row \number\rownum\\
\multicolumn{1}%
 {>{\columncolor{red!12}}l}{test} & row \number\rownum\\
\end{tabular}

\section{Color information}

Type test:
\makeatletter
\@namedef{\string\color@foo1}{foo1{}{}{}{}}\edef\tempa{\XC@type{foo1}}\tempa
\@namedef{\string\color@foo2}{\xcolor@{foo2}{}{}{}}\edef\tempb{\XC@type{foo2}}\tempb
\@namedef{\string\color@foo3}{\xcolor@{}{foo3}{}{}}\edef\tempc{\XC@type{foo3}}\tempc
\@namedef{\string\color@foo4}{\xcolor@{}{}{foo4}{}}\edef\tempd{\XC@type{foo4}}\tempd
\makeatother

\end{document}
%</test3>
%
%<*test4>
\listfiles
\documentclass[a4paper]{article}
%%\PassOptionsToPackage{dvipdf}{xcolor}
%%\PassOptionsToPackage{dvipdfm}{xcolor}
%%\PassOptionsToPackage{dvipdfmx}{xcolor}
%%\PassOptionsToPackage{dvips}{xcolor}
%%\PassOptionsToPackage{dvipsone}{xcolor}
%%\PassOptionsToPackage{dviwin}{xcolor}
%%\PassOptionsToPackage{dviwindo}{xcolor}
%%\PassOptionsToPackage{emtex}{xcolor}
%%\PassOptionsToPackage{oztex}{xcolor}
%%\PassOptionsToPackage{pctex32}{xcolor}
%%\PassOptionsToPackage{pctexhp}{xcolor}
%%\PassOptionsToPackage{pctexps}{xcolor}
%%\PassOptionsToPackage{pctexwin}{xcolor}
%%\PassOptionsToPackage{pdftex}{xcolor}
%%\PassOptionsToPackage{tcidvi}{xcolor}
%%\PassOptionsToPackage{textures}{xcolor}
%%\PassOptionsToPackage{truetex}{xcolor}
%%\PassOptionsToPackage{vtex}{xcolor}
%%\PassOptionsToPackage{xdvi}{xcolor}
%%\PassOptionsToPackage{xetex}{xcolor}
%%\PassOptionsToPackage{prologue}{xcolor}
%%\PassOptionsToPackage{kernelfbox}{xcolor}
%%\PassOptionsToPackage{xcdraw}{xcolor}
\usepackage[emtex]{graphics}
\usepackage{xcolor}
\usepackage[margin=1.25cm,noheadfoot]{geometry}
\pagestyle{empty}
\parindent0pt
\nofiles
\let\familydefault\sfdefault
\makeatletter
%% special code for driver list construction via
%%   latex \def\xcdriverlist{1}\input{xcolor4}
%% writes list in file xcolor4.tmp
\@ifundefined{xcdriverlist}{}{%
%% optional * (skips test whether #1.def exists)
%% #1 = driver
%% #2 = additional options (stored in \options@#2)
%% #3 = processor 1
%% #4 = output format 1
%% #5 = processor 2
%% #6 = output format 2
%% #7 = processor 3
%% #8 = output format 3
\def\0{\@ifstar
  {\def\@@tmp####1{\@firstoftwo}\1}{\def\@@tmp####1{\IfFileExists{####1.def}}\1}}
\def\1#1#2#3#4#5#6#7#8{\@@tmp{#1}%
  {\XC@let@Nc\@@tmp{options@#2}
   \ifx\@@tmp\@empty\else
     \edef\@@tmp{,\@@tmp}\XC@replace\@@tmp,{;#1-}\XC@replace\@@tmp;,
   \fi
   \edef\@@tmp{:=#1\@@tmp}
   \expandafter\@for\expandafter\@tempa\@@tmp\do
    {\let\@@tmp\@tempa\XC@replace\@@tmp-,
     \edef\@@tmp{\@tempa\space\string\PassOptionsToPackage{\@@tmp}{xcolor}}
     \@namexdef{list@#4}{\@nameuse{list@#4},#3 \@@tmp}
     \@namexdef{list@#6}{\@nameuse{list@#6},#5 \@@tmp}
     \@namexdef{list@#8}{\@nameuse{list@#8},#7 \@@tmp}}}%
  {\typeout{No file `#1.def' found.}}}
\def\list@{}
\def\list@dvi{}
\def\list@ps{}
\def\list@pdf{}
\@namedef{options@0}{}
\@namedef{options@1}{kernelfbox,prologue,xcdraw,kernelfbox-xcdraw,prologue-xcdraw}
\0{dvips}1{latex}{dvi}{dvips}{ps}{ps2pdf}{pdf}
\0{pctex32}0{latex}{dvi}{dvips}{ps}{ps2pdf}{pdf}
\0{dvipdf}0{latex}{dvi}{dvipdf}{pdf}{}{}
\0{dvipdfm}1{latex}{dvi}{dvipdfm}{pdf}{}{}
\0{dvipdfmx}0{latex}{dvi}{dvipdfmx}{pdf}{}{}
\0{dvipsone}0{latex}{dvi}{}{}{}{}
\0{dviwin}0{latex}{dvi}{}{}{}{}
\0*{dviwindo}0{latex}{dvi}{}{}{}{}
\0{emtex}0{latex}{dvi}{}{}{}{}
\0*{oztex}0{latex}{dvi}{}{}{}{}
\0{pctexhp}0{latex}{dvi}{}{}{}{}
\0{pctexps}0{latex}{dvi}{}{}{}{}
\0{pctexwin}0{latex}{dvi}{}{}{}{}
\0{tcidvi}0{latex}{dvi}{}{}{}{}
\0{textures}0{latex}{dvi}{}{}{}{}
\0{truetex}0{latex}{dvi}{}{}{}{}
\0*{xdvi}0{latex}{dvi}{}{}{}{}
\0{pdftex}1{pdflatex}{pdf}{}{}{}{}
\0{vtex}0{vlatex}{pdf}{}{}{}{}
\0{xetex}0{xelatex}{pdf}{}{}{}{}
\newwrite\@tempa\immediate\openout\@tempa=\jobname.tmp
\@tfor\@tempb:={dvi}{ps}{pdf}\do
 {\edef\@@tmp{\@nameuse{list@\@tempb}}\edef\@@tmp{:=\expandafter\@gobble\@@tmp}
  \expandafter\@for\expandafter\@@tmp\@@tmp\do
   {\immediate\write\@tempa{\@@tmp}}}
\immediate\closeout\@tempa
\@@end}% end of driver list construction code
\edef\Options{\expandafter\@gobble\XC@@opt}
\@tfor\@@tmp:={dvipdf}{dvipdfm}{dvipdfmx}{dvips}{dvipsone}{dviwin}{dviwindo}%
              {emtex}{oztex}{pctex32}{pctexhp}{pctexps}{pctexwin}{pdftex}%
              {tcidvi}{textures}{truetex}{vtex}{xdvi}{xetex}%
              {natural}{table}{fixpdftex}{hyperref}{showerrors}{hideerrors}%
              {override}{usenames}{nodvipsnames}{debugshow}\do
 {\expandafter\XC@replace\expandafter\Options\expandafter{\@@tmp,}{}}
\edef\Options{\XC@@drv,\Options}
\def\@@tmp#1,#2%
 {\ifx,#2#1\expandafter\remove@to@nnil\else#1', `\expandafter\@@tmp\fi#2}
\edef\Options{`\expandafter\@@tmp\Options,,\@nnil'}
\makeatother
\begin{document}
\vbox to\textheight{\vss\centering
{\Large\textbf{xcolor} driver test: \Options}
\vskip0.5cm
\begin{testcolors}[rgb,hsb,cmyk,gray,HTML]
\testcolor{magenta}
\testcolor[rgb]{1,0,1}
\testcolor[hsb]{0.83333,1,1}
\testcolor[cmyk]{0,1,0,0}
\testcolor[gray]{0.41}
\noalign{\medskip}
\testcolor{blue}
\testcolor[rgb]{0,0,1}
\testcolor[hsb]{0.66667,1,1}
\testcolor[cmyk]{1,1,0,0}
\testcolor[gray]{0.11}
\noalign{\medskip}
\testcolor{cyan}
\testcolor[rgb]{0,1,1}
\testcolor[hsb]{0.5,1,1}
\testcolor[cmyk]{1,0,0,0}
\testcolor[gray]{0.7}
\noalign{\medskip}
\testcolor{green}
\testcolor[rgb]{0,1,0}
\testcolor[hsb]{0.33333,1,1}
\testcolor[cmyk]{1,0,1,0}
\testcolor[gray]{0.59}
\noalign{\medskip}
\testcolor{yellow}
\testcolor[rgb]{1,1,0}
\testcolor[hsb]{0.16667,1,1}
\testcolor[cmyk]{0,0,1,0}
\testcolor[gray]{0.89}
\noalign{\medskip}
\testcolor{red}
\testcolor[rgb]{1,0,0}
\testcolor[hsb]{0,1,1}
\testcolor[cmyk]{0,1,1,0}
\testcolor[gray]{0.3}
\noalign{\medskip}
\testcolor{black}
\testcolor[rgb]{0,0,0}
\testcolor[hsb]{0,0,0}
\testcolor[cmyk]{0,0,0,1}
\testcolor[gray]{0}
\noalign{\medskip}
\testcolor{gray}
\testcolor[rgb]{0.5,0.5,0.5}
\testcolor[hsb]{0,0,0.5}
\testcolor[cmyk]{0,0,0,0.5}
\testcolor[gray]{0.5}
\noalign{\medskip}
\testcolor{white}
\testcolor[rgb]{1,1,1}
\testcolor[hsb]{0,0,1}
\testcolor[cmyk]{0,0,0,0}
\testcolor[gray]{1}
\noalign{\medskip\smallskip}
f(color)box &
\multicolumn5{c}{\def\i{\fbox{\a}}\def\ii{\fcolorbox{red}{yellow}{\a}}\def\iii{\scalebox{3}}%
\def\a{{\setbox0=\hbox to3ex{\hss\textcolor{blue}{\vrule width .75ex height1.5ex depth1.5ex}\hss}\ht0=0pt\dp0=0pt\box0}}%
\fboxsep0.333ex \i\quad\ii\quad\iii\i\quad\iii\ii\quad\fboxrule.75ex \iii\i\quad\iii\ii}
\end{testcolors}
\vskip0.5cm
{\footnotesize This table was generated with \textbf{xcolor4.tex} which is part of the \textbf{xcolor} package \XCfileversion{} (\XCfiledate) by Uwe Kern.}
\vss}
\end{document}
%</test4>
%
% \fi
\endinput
%%
%% End of file `xcolor.dtx'.
