From af8b0693bda73b20f4907cd05973e646a988dd85 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 11 Jan 2006 23:59:04 +0000 Subject: trunk/Master/texmf-dist/source/latex/xcolor git-svn-id: svn://tug.org/texlive/trunk@591 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/source/latex/xcolor/xcolor.dtx | 6789 ++++++++++++++++++++++ Master/texmf-dist/source/latex/xcolor/xcolor.ins | 28 + 2 files changed, 6817 insertions(+) create mode 100644 Master/texmf-dist/source/latex/xcolor/xcolor.dtx create mode 100644 Master/texmf-dist/source/latex/xcolor/xcolor.ins (limited to 'Master/texmf-dist/source/latex/xcolor') diff --git a/Master/texmf-dist/source/latex/xcolor/xcolor.dtx b/Master/texmf-dist/source/latex/xcolor/xcolor.dtx new file mode 100644 index 00000000000..04fc084392c --- /dev/null +++ b/Master/texmf-dist/source/latex/xcolor/xcolor.dtx @@ -0,0 +1,6789 @@ +% \iffalse meta-comment +%% +%% ---------------------------------------------------------------- +%% Copyright (C) 2003-2005 by Dr. Uwe Kern +%% ---------------------------------------------------------------- +%% +%<*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'. +%% +% +%<*extract|driver|test1|test2|test3|test4> +\def\XCfileversion{v2.06}% +\def\XCfiledate{2005/10/15}% +% +% +% 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{4242} +% +% \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*} +% +% +%<*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,spot,latex,pdftex,dvips,% + conversion,blend,mix,mask,separation,rgb,cmy,cmyk,hsb,gray,html,wave}]{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} +% +% +%<*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} +\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} +} +% +% \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} +% +% \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\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\Key#1{\textit{#1}\index{keys\levelchar\textit{#1}\string|usage}} +% \def\File#1{\texttt{#1}\index{files\levelchar\texttt{#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}} +% +% \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 nine color models, alternating table row colors, color blending and masking, and color separation. +% \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} +% See section \vref{sec.cnv} for details. +% +% +% +% \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. +% +% +% +% +% \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*}, +% \item options that determine which other packages are to be loaded (\Option{table}, \Option{fixpdftex}, \Option{pst}\footnote{\label{fnt.pst}This option will soon become obsolete, since recent \File{pstricks.sty} versions do load \XC, whereas \Package{pstcol} is no longer needed.}) or supported (\Option{hyperref}), +% \item options that determine the behaviour of other commands: \Option{prologue}, \Option{showerrors}, \Option{hideerrors}, +% \item obsolete options: \Option{override}, \Option{usenames}, \Option{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]\\ +% \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{pst}& Load the \Package{pstcol} package, in order to use `normal' color definitions within \Package{pstricks} macros (see footnote \vref{fnt.pst}).\\ +% \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}).\\ +% \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]\,these options are explained in section \vref{sec.additionalcolors}}\\ +% \hline +% \end{tabularx} +% \end{adjustwidth} +% \end{table} +% +% +% \begin{table}[htbp]\caption{Package loading order}\label{tab.package} +% \centering +% \extrarowheight2pt +% \rowcolors{3}{tablerowcolor}{} +% \begin{tabular}{lccccc} +% \hline +% \rowcolor{tableheadcolor} +% \em Action/Package & \LC & \Package{colortbl}& \Package{pdfcolmk}& \Package{pstcol}& \Package{hyperref}\\ +% load before \XC & no & no & no & no & allowed \\ +% load with \XC{} option& --- & \Option{table} & \Option{fixpdftex} & \Option{pst}\footnotemark[1] & ---\\ +% load after \XC & no & no & allowed & no & allowed \\ +% \hline\hline +% \multicolumn5{c}{\footnotemark[1]\,not recommended, better use recent \File{pstricks.sty}}\\ +% \hline +% \end{tabular} +% \end{table} +% +% +% \begin{table}[htbp]\caption{Supported color models}\label{tab.mod} +% \centering +% \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{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}\\ +% \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, the command +% |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. +% +% +% +% \subsection{Color models} +% +% \subsubsection{Supported color models} +% +% The list of supported color models 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}). +% It is noteworthy that the \Model{HTML} model accepts any combination of the characters \texttt0--\texttt9, \texttt A--\texttt F, \texttt a--\texttt 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. +% +% \DescribeMacro\adjustUCRBG +% There is a special command 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. +% +% \DescribeMacro\rangeRGB +% \DescribeMacro\rangeHSB +% \DescribeMacro\rangeGray +% For the \emph{integer models} \Model{RGB}, \Model{HSB}, and \Model{Gray}, the constants $L, M, N$ of table \ref{tab.mod} are defined via the commands |\def\rangeRGB|\marg{L}, |\def\rangeHSB|\marg{M}, and |\def\rangeGray|\marg{N}. +% 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 saying |\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} +% \small\raggedleft +% \extrarowheight2pt +% \begin{adjustwidth}{-2.5cm}{} +% \advance\textwidth2.5cm +% \rowcolors{3}{tablerowcolor}{} +% \begin{tabularx}{\textwidth}{l@{ }X} +% \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 `|wave|'\hfill(\emph{real model})\\ +% \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})\\ +% \Meta*{spec}& \RS comma-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*{color}& \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 restrictions may apply --- depending on the context. +% See main text for details. +% A string `|foo|' is always to be understood without the quotes.\newline +% $k,l,m,n$ denote positive integers, $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}), 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 real model \Model{wave} (which approximates the visual appearance of light waves) 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|', `|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. +% +% Examples: `|rgb/cmyk/named/gray|', `|0,0,0/0,0,0,1/Black/0|'. +% +% +% \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 \vref{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{Colors} +% \DescribeArg{color} +% 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} by saying |\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} by saying |\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. +% +% +% +% \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{orange}, \test{violet}, \test{purple}, \test{brown}, \test{pink}, \test{olive}, \test{black}, \test{darkgray}, \test{gray}, \test{lightgray}, \test{white}. +% +% 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 147 \Model{rgb} color names\footnote{In fact, these names represent 138 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.}. +% \end{itemize} +% The color names and corresponding displays are listed in section \vref{sec.names}. +% Note that --- due to some overlap in the names --- the option order is important, if you plan to use more than one of these sets. +% 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[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}. +% Note that there is a special \Package{pstricks} 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:\\ +% \DescribeMacro\color\marg{color}\\ +% \oarg{model}\marg{spec}\\ +% \DescribeMacro\textcolor\marg{color}\marg{text}\\ +% \oarg{model}\marg{spec}\marg{text}\\ +% \DescribeMacro\colorbox\marg{color}\marg{text}\\ +% \oarg{model}\marg{spec}\marg{text}\\ +% \DescribeMacro\fcolorbox\marg{frame color}\marg{background color}\marg{text}\\ +% \oarg{model}\marg{frame spec}\marg{background spec}\marg{text}\\ +% \DescribeMacro\pagecolor\marg{color}\\ +% \oarg{model}\marg{spec}\\ +% Hence, the formal difference to the \LCP{} is that color \emph{expressions} may be used instead of pure color \emph{names}. +% A previous section explains how color expressions are constructed. +% +% 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{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}\marg{spec}\\ +% 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. +% See figure \vref{fig.testcolors} for an example. +% +% +% +% \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. +% +% +% +% \subsection{Problems and solutions} +% +% \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} +% +% +% +% +% \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} +% \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} +% \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{orange} \testclr{violet} \testclr{purple} \testclr{brown} \testclr{pink} \testclr{olive} \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{orange} \testclr{violet} \testclr{purple} \testclr{brown} \testclr{pink} +% \testclr{olive} \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} +% +% \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}&2002/06/19 v0.03k&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 \Option{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 \Option{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{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} +% \centering\small +% \def\Em#1{\Model{#1}} +% \def\sp{\hbox to3em{\hfil$\ast$\hfil}} +% \def\id{\textrm{id}} +% \extrarowheight1pt +% \tabcolsep3pt +% \rowcolors{3}{tablerowcolor}{} +% \begin{tabular}{c*9{>{\sffamily}c}} +% \rowcolor{tableheadcolor} +% \hline +% \emph{from/to}& +% \Em{rgb}& \Em{cmy}& \Em{cmyk}& \Em{hsb}& \Em{gray}& \Em{RGB}& \Em{HTML}& \Em{HSB}& \Em{Gray}\\ +% \Em{rgb}& \id & \sp & (cmy) & \sp & \sp & \sp & \sp & (hsb) & (gray)\\ +% \Em{cmy}& \sp & \id & \sp & (rgb) & \sp & (rgb) & (rgb) & (rgb) & (gray)\\ +% \Em{cmyk}& (cmy) & \sp & \id & (cmy) & \sp & (cmy) & (cmy) & (cmy) & (gray)\\ +% \Em{hsb}& \sp & (rgb) & (rgb) & \id & (rgb) & (rgb) & {rgb} & \sp & (rgb)\\ +% \Em{gray}& \sp & \sp & \sp & \sp & \id & \sp & \sp & \sp & \sp\\ +% \Em{RGB}& \sp & (rgb) & (rgb) & (rgb) & (rgb) & \id & (rgb) & (rgb) & (rgb)\\ +% \Em{HTML}& \sp & (rgb) & (rgb) & (rgb) & (rgb) & (rgb) & \id & (rgb) & (rgb)\\ +% \Em{HSB}& (hsb) & (hsb) & (hsb) & \sp & (hsb) & (hsb) & (hsb) & \id & (hsb)\\ +% \Em{Gray}& (gray) & (gray) & (gray) & (gray) & \sp & (gray) & (gray) & (gray) & \id\\ +% \Em{wave}& (hsb) & (hsb) & (hsb) & \sp & (hsb) & (hsb) & (hsb) & (hsb) & (hsb)\\ +% \hline\hline +% \multicolumn{10}{c}{\id{} = identity function; $\ast$ = specific conversion function;}\\ +% \multicolumn{10}{c}{\textsf{(model)} = conversion via specified model}\\ +% \hline +% \end{tabular} +% \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, 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 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{align} +% \emph{Red} & := \RtoI L(\emph{red})\\ +% \emph{Green} & := \RtoI L(\emph{green})\\ +% \emph{Blue} & := \RtoI L(\emph{blue}) +% \end{align} +% +% \paragraph{Conversion \Model{rgb} to \Model{HTML}} +% As described in section \vref{sec.real2int}. Convert to hexadecimal afterwards. +% \begin{align} +% \emph{RR} & := \RtoI L(\emph{red})_{\emph{hex}}\\ +% \emph{GG} & := \RtoI L(\emph{green})_{\emph{hex}}\\ +% \emph{BB} & := \RtoI L(\emph{blue})_{\emph{hex}} +% \end{align} +% +% \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}} +% As described in section \vref{sec.real2int}. Convert to hexadecimal afterwards. +% \begin{align} +% \emph{Hue} & := \RtoI M(\emph{hue})\\ +% \emph{Saturation} & := \RtoI M(\emph{saturation})\\ +% \emph{Brightness} & := \RtoI M(\emph{brightness}) +% \end{align} +% +% +% \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{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{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}{} +% \raggedcolumns\columnsep2.5em +% +% \section{Colors by Name}\label{sec.names} +% +% \begin{multicols}{5}[\subsection{Base Colors}\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{magenta} +% \0{olive} +% \0{orange} +% \0{pink} +% \0{purple} +% \0{red} +% \0{violet} +% \0{white} +% \0{yellow} +% \end{multicols} +% +% +% \begin{multicols}{5}[\subsection{Colors via \Option{dvipsnames}}\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}}\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{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}. +% \end{adjustwidth} +% +% \end{adjustwidth} +% \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{Bruton}% +% {Dan~Bruton:~``Approximate RGB values for Visible Wavelengths'', 1996. +% \URL{http://www.physics.sfasu.edu/astro/color/spectra.html}} +% +% \bibitem{dpc}% +% {David~P.~Carlisle:~``Packages in the `graphics' bundle'', 1999. +% \CTAN{macros/latex/required/graphics/}{grfguide.*}} +% +% \bibitem{color}% +% {David~P.~Carlisle:~\LCP, ``1999/02/16 v1.0i Standard \LaTeX{} Color''. +% \CTAN{macros/latex/required/graphics/}{color.*}} +% +% \bibitem{colortbl}% +% {David~P.~Carlisle:~\Package{colortbl} package, ``2001/02/13 v0.1j Color table columns''. +% \CTAN{macros/latex/contrib/carlisle/}{colortbl.*}} +% +% \bibitem{pstcol}% +% {David~P.~Carlisle:~\Package{pstcol} package, ``2001/06/20 v1.1 PSTricks color compatibility''. +% \CTAN{macros/latex/required/graphics/}{pstcol.*}} +% +% \bibitem{chroma}% +% {Uwe~Kern:~``Chroma: a reference book of \LaTeX{} colors''. +% \CTAN{info/colour/chroma/}{} and +% \URL{http://www.ukern.de/tex/chroma.html}} +% +% \bibitem{xcolor}% +% {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}% +% {Rolf~Niepraschk:~\Package{colorinfo} package, ``2003/05/04 v0.3c Info from defined colors''. +% \CTAN{macros/latex/contrib/colorinfo/}{}} +% +% \bibitem{pdfcolmk}% +% {Heiko~Oberdiek:~\Package{pdfcolmk} package, ``2005/07/09 v0.7''. +% \CTAN{macros/latex/contrib/oberdiek/pdfcolmk.sty}{}} +% +% \bibitem{hyperref}% +% {Sebastian~Rahtz:~\Package{hyperref} package, ``2003/11/30 v6.74m Hypertext links for \LaTeX''. +% \CTAN{macros/latex/contrib/hyperref/}{}} +% +% \bibitem{smith}% +% {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{svg}% +% {World Wide Web Consortium: ``Scalable Vector Graphics (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}{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}{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*{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 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 \Option{override}, \Option{usenames}, \Option{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: \Option{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}{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 + {\catcode`\noexpand\@\the\catcode`\@\relax + \catcode`\noexpand\!\the\catcode`\!\relax + \catcode`\noexpand\:\the\catcode`\:\relax + \catcode`\noexpand\-\the\catcode`\-\relax + \catcode`\noexpand\+\the\catcode`\+\relax + \catcode`\noexpand\;\the\catcode`\;\relax + \catcode`\noexpand\/\the\catcode`\/\relax + \catcode`\noexpand\"\the\catcode`\"\relax + \catcode`\noexpand\^^A\the\catcode`\^^A\relax} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\catcode`\@=11 +\catcode`\!=12 +\catcode`\:=12 +\catcode`\-=12 +\catcode`\+=12 +\catcode`\;=12 +\catcode`\/=12 +\catcode`\"=12 +\catcode`\^^A=\catcode`\% +% \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@@xcp} +% \begin{macro}{\ifXC@@tst} +% Auxiliary test variables. +% \begin{macrocode} +\newif\ifXC@@xcp +\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{\noexpand\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 `|/|' 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 +\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 + \edef#1{#2}\@onelevel@sanitize#1\aftergroupdef#1#1} +\gdef\XC@mdef#1#2% + {\begingroup + \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} +% +% +% +% \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@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:={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} +% +% 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{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}{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} +% +% Use this option to load \People{David}{Carlisle}'s \Package{pstcol} package in order to make standard color definitions available within \Package{pstricks}. +% Warning: this option is neither needed nor useful with recent \Package{pstricks} versions. +% \begin{macrocode} +\DeclareOption{pst}{\def\XC@pst{\RequirePackage{pstcol}}} +% \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}% + {\noexpand\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} +% +% \Option{prologue} option, used by (some) drivers. +% \begin{macrocode} +\DeclareOption{prologue}{\XC@@xcptrue} +% \end{macrocode} +% \end{macro} +% +% +% \subsubsection{Other options} +% +% 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 \Option{usenames}, \Option{nodvipsnames}) are being ignored. +% \begin{macrocode} +\DeclareOption*% + {\PackageInfo{xcolor}{Package option `\CurrentOption' ignored}} +% \end{macrocode} +% +% Choose default options: +% \begin{macrocode} +\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@@drv@} +% Test variable for |\ifcase| expressions. +% \begin{macrocode} +\def\XC@@drv@{-1} +\@tfor\@@tmp:={dvips}{pctex32}\do + {\ifx\@@tmp\XC@@drv\def\XC@@drv@{0}\@break@tfor\fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\XC@@xcp} +% File variabe for prologue output. +% \begin{macrocode} +\ifXC@@xcp\ifcase\XC@@drv@ + \AtBeginDvi{\special{header=xcolor.pro}\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\fi +% \end{macrocode} +% \end{macro} +% +% +% \subsubsection{Required packages} +% +% The --- obsolete --- package \Package{pstcol} needs the real \LCP; all other packages receive a pretended \LC. +% \begin{macrocode} +\@nameuse{XC@pst} +\@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}{\@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@@} +% \end{macrocode} +% +% \begin{macrocode} +\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\XC@ifxc@se##1##2% + {\ifx#1##1% + \toks@{##2}\expandafter\remove@to@nnil\else + \expandafter\XC@ifxc@se\fi}% + \XC@ifxc@se#2#1{#3}\@nnil\the\toks@} +% \end{macrocode} +% \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} +% \end{macrocode} +% +% \begin{macrocode} +\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} +% +% +% \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#1#2% + {\dimen@#1\p@ \rdivide\dimen@\@@scl \edef#2{\strip@pt\dimen@}} +% \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#1#2% + {\lshiftset\dimen@{#1}\dimen@\lshiftnum\@@scl\dimen@ \rrshift\dimen@ + \edef#2{\strip@pt\dimen@}} +% \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@ + \ifnum\count@<\z@ + \lshift\dimen@ \dimen@-\dimen@ \advance\dimen@10\p@ \rshift\dimen@ + \fi + \fi + \edef#2{\strip@pt\dimen@}} +% \end{macrocode} +% \end{macro} +% +% +% \subsection{Color definition} +% +% \subsubsection{Constants} +% +% \begin{macro}{\rangeRGB} +% \begin{macro}{\rangeHSB} +% \begin{macro}{\rangeGray} +% Scaling ranges for `integer models': +% \begin{macrocode} +\providecommand*\rangeRGB{255} +\providecommand*\rangeHSB{240} +\providecommand*\rangeGray{15} +% \end{macrocode} +% \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'. +% \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'); +% \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}{}} +% \end{macrocode} +% +% \begin{macrocode} +\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 + \ifXC@@getmod\XC@getmod{#4}\XC@@pos\@@mod\fi + \XC@getclr{#5}\XC@@pos\@@clr + \@ifundefined{color@\@@mod}% + {\c@lor@error{model `\@@mod'}\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} + \ifXC@@xcp\ifcase\XC@@drv@ + \immediate\write\XC@@xcp{/\colornameprefix\@@nam{\expandafter + \XC@strip@comma\@@clr,,\@nnil}XC\@@mod}% + \let\@@cls\XC@mod@named + \fi\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@getmod} +% \marg{model-list}\marg{position-cmd}\marg{model-cmd}\\ +% Retrieve color model from multiple definitions, separated by `|/|'. +% This is being done by searching \Meta{model-list} for the current target model; if there is no match, the first listed model will be taken. +% The position is saved in \Meta{position-cmd}, the resulting model is saved in \Meta{model-cmd}. +% \begin{macrocode} +\def\XC@getmod#1#2#3% + {\def\XC@getm@d##1/##2/##3/##4/##5/##6/##7/##8/##9:% + {\XC@g@tm@d0{##1}\XC@g@tm@d1{##2}\XC@g@tm@d2{##3}\XC@g@tm@d3{##4}% + \XC@g@tm@d4{##5}\XC@g@tm@d5{##6}\XC@g@tm@d6{##7}\XC@g@tm@d7{##8}% + \def#2{0}\def#3{##1}\@gobble\@nnil}% + \def\XC@g@tm@d##1##2% + {\edef#2{##2}\XC@sdef#3{\XC@tgt@mod#2}% + \ifx#2#3\def#2{##1}\expandafter\remove@to@nnil\fi}% + \XC@mdef#3{#1}\expandafter\XC@getm@d#3////////:} +% \end{macrocode} +% +% \begin{macrocode} +\newif\ifXC@@getmod \XC@@getmodtrue +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\XC@getclr} +% \marg{spec-list}\marg{position}\marg{clr-cmd}\\ +% Pick color specification on position \Meta{position} from multiple definitions, separated by `|/|'. +% The associated specification from \Meta{spec-list} is put into \Meta{clr-cmd}. +% It is assumed that \Meta{position} contains a valid number, no checks are performed. +% \begin{macrocode} +\def\XC@getclr#1#2#3% + {\def\XC@getc@r##1/##2/##3/##4/##5/##6/##7/##8/##9:% + {\ifcase#2 ##1\or##2\or##3\or##4\or##5\or##6\or##7\or##8\fi}% + \XC@mdef#3{#1}\edef#3{\expandafter\XC@getc@r#3////////:}} +% \end{macrocode} +% \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}{}} +% \end{macrocode} +% +% \begin{macrocode} +\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}% + \@ifundefined{\string\color@\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}{}} +% \end{macrocode} +% +% \begin{macrocode} +\def\XC@colorlet[#1]#2{\@testopt{\XC@col@rlet[#1]{#2}}{}} +% \end{macrocode} +% +% \begin{macrocode} +\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% + {\@ifundefined{\string\color@#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}\marg{model-list}\marg{spec-list}\\ +% \begin{macrocode} +\def\preparecolor{\@testopt{\XC@preparecolor}{}} +% \end{macrocode} +% +% \begin{macrocode} +\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@edef\@@nam{#2}% + \ifXC@@getmod\XC@getmod{#4}\XC@@pos\@@mod\fi + \XC@getclr{#5}\XC@@pos\@@clr + \@ifundefined{XC@mod@\@@mod}% + {\c@lor@error{model `\@@mod'}}% + {\xdef\XC@@stack + {\ifx\XC@@stack\@empty\else\XC@@stack,\fi + {#1}{\@@nam}{#3}{\@@mod}{\@@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@getmod{#2}\XC@@pos\@@mod\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}{}} +% \end{macrocode} +% +% \begin{macrocode} +\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 + {\noexpand\def\noexpand\@@mod{\@@mod}% + \noexpand\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{}}} +% \end{macrocode} +% +% \begin{macrocode} +\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}{}} +% \end{macrocode} +% +% \begin{macrocode} +\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{The core command} +% +% \begin{macro}{\color} +% \marg{color}\\ +% \oarg{model}\marg{spec}\\ +% 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}\marg{spec}\\ +% Display a color that is given by \Meta{model} name and numerical \Meta{spec}. +% \begin{macrocode} +\def\@undeclaredcolor[#1]#2% + {\begingroup + \XC@sdef\@@mod{#1}\XC@edef\@@clr{#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% + {\@ifundefined{color@#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} +% +% +% \subsubsection{Internal commands} +% +% \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% + {\edef\@@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:\@nil} +% \end{macrocode} +% +% \begin{macro}{\XC@split@i} +% Check whether it is an \emph{extended} or \emph{standard} color expression. +% \begin{macrocode} +\def\XC@split@i#1:#2\@nil + {\@ifxempty{#2}{\XC@split@v}{\XC@split@ii#1,,:#2}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\XC@split@ii} +% 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@ii#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@iii#4;,;} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\XC@split@iii} +% \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@iii#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@iv{#1}{#2}}% + \ifXC@@tst\advance\@tempdima#2\p@\fi + \XC@split@iii}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\XC@split@iv} +% \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@iv#1#2% + {\def\@@tmp{#1}\XC@split@v + \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@v} +% Start splitting process for standard color expression. +% \begin{macrocode} +\def\XC@split@v{\count@\z@ \expandafter\XC@split@vi\@@tmp!\@nil} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\XC@split@vi} +% Count number of `-' signs at the beginning of the string. +% \begin{macrocode} +\def\XC@split@vi#1% + {\ifx#1-\advance\count@\@ne\expandafter\XC@split@vi + \else\expandafter\XC@split@vii\expandafter#1\fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\XC@split@vii} +% Extract \Meta{name} and \Meta{mix expr} part of color expression. +% Delegate control to |\@xcolor@|. +% \begin{macrocode} +\def\XC@split@vii#1!#2\@nil + {\edef\@@nam{#1}\edef\@@mix{#2}% + \ifodd\count@\@tempswatrue\else\@tempswafalse\fi + \@ifundefined{\string\color@\@@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@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{Additional user-level commands} +% +% \begin{macro}{\textcolor} +% \marg{color}\marg{text}\\ +% \oarg{model}\marg{spec}\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}{\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. +% +% The definition here works by selecting a color, and then drawing a \TeX\ rule (unless |\ifcolors@false|). +% This allows the `driver independent' color specials to be used. +% A graphics package may want to define it using a |\special| to produce (for example) a \Index{PostScript} line. +% Producing the line in the |\special| has the advantage that on a preview that does not understand |\special|s, the line is automatically omited, without needing to modify the source of the document (for instance by adding the \Option{monochrome} option). +% \begin{macrocode} +\def\color@block#1#2#3{% + {\set@color\rlap{\ifcolors@\vrule\@width#1\@height#2\@depth#3\fi}}} +% \end{macrocode} +% \end{macro} +% +% \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#{\color@box{#1}} +% \end{macrocode} +% +% \begin{macrocode} +\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}\\ +% Puts a frame of the first color around a box with a background specified by the second color. +% If an optional argument is given, it specifies the color model for both colors. +% \begin{macrocode} +\def\fcolorbox#1#{\color@fbox{#1}} +% \end{macrocode} +% +% \begin{macrocode} +\def\color@fbox#1#2#3{% + \color@b@x{\fboxsep\z@\color#1{#2}\fbox}{\color#1{#3}}} +% \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} +% +% +% \subsubsection{Background (page) color} +% +% \begin{macro}{\pagecolor} +% \marg{color}\\ +% \oarg{model}\marg{spec}\\ +% 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{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} + \ifx\rownum\@undefined\newcount\rownum\fi +% \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{macrocode} +\def\XC@extract@hue#1,#2:#3{\edef#3{#1}} +% \end{macrocode} +% +% \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|'\\ +% \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{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} +% \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 + \@ifundefined{\string\color@#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} +% +% \begin{macro}{\testcolor} +% \marg{color}\\ +% \oarg{model}\marg{spec}\\ +% 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% + {\@ifxempty{##1}% + {\def\@@arg{##2&}\def\@@clr{##2}}% + {\def\@@arg{[##1]{##2}&}\definecolor{*}{##1}{##2}\def\@@clr{*}}% + \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@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@hsb {\XC@cnv@rgb@hsb#1,#2,#3,}% + \XC@mod@gray{\XC@cnv@rgb@gray#1,#2,#3,}% + \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@HSB {\XC@cnv@rgb@hsb#1,#2,#3,% + \edef\@@scl{\rangeHSB}\expandafter\XC@calc@\@@tmp,,:M}% + \XC@mod@Gray{\XC@cnv@rgb@gray#1,#2,#3,% + \edef\@@scl{\rangeGray}\XC@calcM\@@tmp\@@tmp}}% + {\XC@calc@#1,#2,#3,,:N}} +% \end{macrocode} +% \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@rgb {\XC@calc@#1,#2,#3,,:C}% + \XC@mod@cmyk{\XC@cnv@cmy@cmyk#1,#2,#3,}% + \XC@mod@hsb {\XC@calc@#1,#2,#3,,:C\expandafter\XC@cnv@rgb@hsb\@@tmp,}% + \XC@mod@gray{\XC@cnv@rgb@gray#1,#2,#3,\XC@calcC\@@tmp\@@tmp}% + \XC@mod@RGB {\XC@calc@#1,#2,#3,,:C% + \edef\@@scl{\rangeRGB}\expandafter\XC@calc@\@@tmp,,:M}% + \XC@mod@HTML{\XC@calc@#1,#2,#3,,:C\expandafter\XC@cnv@rgb\@@tmp,}% + \XC@mod@HSB {\XC@calc@#1,#2,#3,,:C\expandafter\XC@cnv@rgb@hsb\@@tmp,% + \edef\@@scl{\rangeHSB}\expandafter\XC@calc@\@@tmp,,:M}% + \XC@mod@Gray{\XC@cnv@rgb@gray#1,#2,#3,\XC@calcC\@@tmp\@@tmp + \edef\@@scl{\rangeGray}\XC@calcM\@@tmp\@@tmp}}% + {\XC@calc@#1,#2,#3,,:N}} +% \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@rgb + {\XC@cnv@cmyk@cmy#1,#2,#3,#4,\expandafter\XC@calc@\@@tmp,,:C}% + \XC@mod@cmy{\XC@cnv@cmyk@cmy#1,#2,#3,#4,}% + \XC@mod@hsb + {\XC@cnv@cmyk@cmy#1,#2,#3,#4,\expandafter\XC@calc@\@@tmp,,:C% + \expandafter\XC@cnv@rgb@hsb\@@tmp,}% + \XC@mod@gray{\XC@cnv@rgb@gray#1,#2,#3,% + \edef\@@arg{#4}\XC@calcT\@@tmp\@@tmp \XC@calcC\@@tmp\@@tmp}% + \XC@mod@RGB + {\XC@cnv@cmyk@cmy#1,#2,#3,#4,\expandafter\XC@calc@\@@tmp,,:C% + \edef\@@scl{\rangeRGB}\expandafter\XC@calc@\@@tmp,,:M}% + \XC@mod@HTML + {\XC@cnv@cmyk@cmy#1,#2,#3,#4,\expandafter\XC@cnv@cmy\@@tmp,}% + \XC@mod@HSB + {\XC@cnv@cmyk@cmy#1,#2,#3,#4,\expandafter\XC@calc@\@@tmp,,:C% + \expandafter\XC@cnv@rgb@hsb\@@tmp,% + \edef\@@scl{\rangeHSB}\expandafter\XC@calc@\@@tmp,,:M}% + \XC@mod@Gray{\XC@cnv@rgb@gray#1,#2,#3,% + \edef\@@arg{#4}\XC@calcT\@@tmp\@@tmp \XC@calcC\@@tmp\@@tmp + \edef\@@scl{\rangeGray}\XC@calcM\@@tmp\@@tmp}}% + {\XC@calc@#1,#2,#3,#4,:N}} +% \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,% + {\ifx\tm\XC@mod@HSB + \edef\@@scl{\rangeHSB}\XC@calc@#1,#2,#3,,:M% + \else + \XC@cnv@hsb@rgb#1,#2,#3,% + \ifx\tm\XC@mod@rgb\else\expandafter\XC@cnv@rgb\@@tmp,\fi + \fi} +% \end{macrocode} +% \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@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@hsb {\XC@calcN{#1}\@@tmp \edef\@@tmp{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}} +% \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\expandafter\XC@cnv@rgb\@@tmp,} +% \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% + \expandafter\XC@cnv@rgb\@@tmp,} +% \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}|,|\Meta{Saturation}|,|\Meta{Brightness}|,| +% \begin{macrocode} +\def\XC@cnv@HSB#1,#2,#3,% + {\edef\@@scl{\rangeHSB}\XC@calc@#1,#2,#3,,:D\expandafter\XC@cnv@hsb\@@tmp,} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\XC@cnv@Gray} +% \Meta{Gray}|,| +% \begin{macrocode} +\def\XC@cnv@Gray#1,% + {\edef\@@scl{\rangeGray}\XC@calcD{#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,% + \ifx\tm\XC@mod@hsb\else\expandafter\XC@cnv@hsb\@@tmp,\fi} +% \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@ + \edef\@tempa{\strip@pt\dimen@}% + \XC@calcR\@tempa\@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{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% + {\edef\XC@@tmp{\expandafter\XC@substitutecolormodel#2/ignore/\@nnil}% + \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}}% + \expandafter\xglobalize@\csname color@#1\endcsname \xglobal@stop + \PackageInfo{xcolor}{Model `#1' substituted by `\XC@@tmp'}} +% \end{macrocode} +% +% \begin{macrocode} +\def\XC@substitutecolormodel#1/% + {\@ifundefined{color@#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} +\@ifundefined{color@rgb}% + {\substitutecolormodel{rgb}{RGB/HTML/hsb/HSB/cmy/cmyk/gray/Gray}}{} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\color@cmyk} +% \marg{cmd}\marg{spec} +% \begin{macrocode} +\@ifundefined{color@cmyk}{\substitutecolormodel{cmyk}{cmy/rgb}}{} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\color@cmy} +% \marg{cmd}\marg{spec} +% \begin{macrocode} +\@ifundefined{color@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} +\@ifundefined{color@hsb}{\@tempswatrue}% + {\@tempswafalse + \@tfor\@@tmp:={dvipdfm}{textures}\do + {\ifx\@@tmp\XC@@drv\@tempswatrue\@break@tfor\fi}} +\if@tempswa + \substitutecolormodel{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} +\@ifundefined{color@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@Gray} +% \begin{macro}{\color@wave} +% \marg{cmd}\marg{spec} +% \begin{macrocode} +\@ifundefined{color@gray}{\substitutecolormodel{gray}{Gray/rgb}}{} +\@ifundefined{color@HTML}{\substitutecolormodel{HTML}{rgb}}{} +\@ifundefined{color@HSB}{\substitutecolormodel{HSB}{hsb}}{} +\@ifundefined{color@Gray}{\substitutecolormodel{Gray}{gray}}{} +\@ifundefined{color@wave}{\substitutecolormodel{wave}{hsb}}{} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \subsubsection{PostScript-related stuff} +% +% \begin{macrocode} +\@ifundefined{XC@pst}{% +% \end{macrocode} +% +% \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} +% +% This alternative code is temporarily needed for compatibility reasons if \Package{pstricks} is loaded via the \Option{pst} option: +% \begin{macrocode} +}{% compatibility code begin +\def\XC@getcolor#1#2% + {\@ifundefined{\string\color@#1}% + {\begingroup\color{#1}% + \edef\@@tmp + {\noexpand\edef\noexpand#2{\noexpand\expandafter\noexpand\c@lor@to@ps + \current@color\noexpand\@@}}% + \expandafter\endgroup\@@tmp}% + {\edef#2{\XC@usecolor{#1}}}} +}% compatibility code end +% \end{macrocode} +% +% \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@@} +% \end{macrocode} +% +% \begin{macrocode} +\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 soon! +% \begin{macrocode} +\let\XC@c@lor@to@ps\XC@usecolor +% \end{macrocode} +% \end{macro} +% +% If \Package{pstcol} has been loaded, we have to redefine two macros from this package. +% The conditional code is needed temporarily, until a new version of \Package{pstricks} is released. +% \begin{macrocode} +\let\pst@getcolor\XC@getcolor +\@ifundefined{XC@pst}{% + \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 first-level 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} +\@tfor\@@tmp:={dvipdf}{dvipdfm}{dvipdfmx}{dvips}{pctex32}\do + {\ifx\@@tmp\XC@@drv + \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}{}{}}} + \@break@tfor\fi} +% \end{macrocode} +% +% \begin{macrocode} +\@tfor\@@tmp:={dvipsone}{pctexps}{pdftex}{tcidvi}{truetex}{vtex}{xetex}\do + {\ifx\@@tmp\XC@@drv + \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}{}{}}} + \@break@tfor\fi} +% \end{macrocode} +% +% \begin{macrocode} +\@tfor\@@tmp:={textures}\do + {\ifx\@@tmp\XC@@drv + \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}} + \@break@tfor\fi} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \subsubsection{Basic color definitions} +% +% \Model{rgb}-minded colors.\footnote{Generic definitions: +% \Color{orange} = \Color{red}|!|50|!|\Color{yellow}, +% \Color{violet} = \Color{blue}|!|50|!|\Color{red}, +% \Color{purple} = \Color{violet}|!|50|!|\Color{red}, +% \Color{brown} = \Color{violet}|!|50|!|\Color{yellow}, +% \Color{pink} = \Color{red}|!|25.} +% \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;% + orange,1,.5,0/.083333,1,1/0,.5,1,0/.595;% + violet,.5,0,.5/.83333,1,.5/0,.5,0,.5/.205;% + purple,.75,0,.25/.94444,1,.75/0,.75,.5,.25/.2525;% + brown,.75,.5,.25/.083333,.66667,.75/0,.25,.5,.25/.5475;% + pink,1,.75,.75/0,.25,1/0,.25,.25,0/.825}% +% \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} +% \end{macrocode} +% +% \begin{macrocode} +% +% \end{macrocode} +% +% +% \iffalse +%------------------------------------------------------------------------------- +% \fi +% +% \subsection{Auxiliary definitions} +% +% \subsubsection{PostScript prologue} +% +% \begin{macrocode} +%<*dvips> +userdict begin +/setcmycolor{0 setcmykcolor}def +/XCdef{exch dup TeXDict exch known{pop pop}{exch def}ifelse}bind def +/XCbdef{bind XCdef}bind def +/XCsetcolor{cvx counttomark array astore cvx exch pop XCdef}XCbdef +/XCcmy{mark exch exec /setcmycolor XCsetcolor}XCbdef +/XCcmyk{mark exch exec /setcmykcolor XCsetcolor}XCbdef +/XCgray{mark exch exec /setgray XCsetcolor}XCbdef +/XChsb{mark exch exec /sethsbcolor XCsetcolor}XCbdef +/XCrgb{mark exch exec /setrgbcolor XCsetcolor}XCbdef +end +% +% \end{macrocode} +% +% +% \clearpage +% \Finale +% \endinput +% +% +% \iffalse +%------------------------------------------------------------------------------- +%<*svgnames|hksknames|hksnnames|hksznames|pmsnames|ralnames> +\def\colornameprefix{XC@} +% +% +%<*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;% +Grey,.5,.5,.5;% +Green,0,.5,0;% +GreenYellow,.68,1,.185;% +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;% +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;% +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;% +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;% +Wheat,.96,.87,.7;% +White,1,1,1;% +WhiteSmoke,.96,.96,.96;% +Yellow,1,1,0;% +YellowGreen,.604,.804,.196} +% +% +%<*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} +% +% +%<*test2> +\listfiles +\documentclass{article} + +\usepackage{pstricks,pst-tree,pst-slpe,multido} +\makeatletter +\@ifpackagelater{pstricks}{2004/05/12}{}{\usepackage[pst]{xcolor}} +\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}[.5](-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}{wave}{#1}\extractcolorspec{tmp}\tmp + \expandafter\convertcolorspec\tmp{rgb}\tmp \expandafter\WaveToPSi\tmp,} + \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} +% +% +%<*test3> +\listfiles +\documentclass{article} +\usepackage[table,dvipsnames]{xcolor}[2005/03/24] + +\tracingcolors=4 +%%\tracingcolors=3 +%%\tracingcolors=2 +%%\tracingcolors=1 +%%\tracingcolors=0 + +\parindent0pt +\pagecolor{gray!25} + +\begin{document} +\title{Color extensions with the \textsf{xcolor} package --- log file example} +\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 + +The purpose of this file is to demonstrate 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. + +\bigskip +Table example: +\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} + +\bigskip +\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}}} + +{\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 + +\bigskip +\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 + +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 + +\textcolor{rgb:red!50,4;green!25,2}{Extended color expression (rgb:red!50,4;green!25,2)}. + +\end{document} +% +% +%<*test4> +\listfiles +\documentclass[a4paper]{article} +\usepackage{xcolor} +%%\usepackage[dvipdf]{xcolor} +%%\usepackage[dvipdfm]{xcolor} +%%\usepackage[dvipdfmx]{xcolor} +%%\usepackage[dvips]{xcolor} +%%\usepackage[dvipsone]{xcolor} +%%\usepackage[dviwin]{xcolor} +%%\usepackage[emtex]{xcolor} +%%\usepackage[pctex32]{xcolor} +%%\usepackage[pctexhp]{xcolor} +%%\usepackage[pctexps]{xcolor} +%%\usepackage[pctexwin]{xcolor} +%%\usepackage[pdftex]{xcolor} +%%\usepackage[tcidvi]{xcolor} +%%\usepackage[textures]{xcolor} +%%\usepackage[truetex]{xcolor} +%%\usepackage[vtex]{xcolor} +%%\usepackage[xetex]{xcolor} +%%\usepackage[dviwindo]{xcolor} +%%\usepackage[oztex]{xcolor} +%%\usepackage[xdvi]{xcolor} +\usepackage[margin=1.25cm,noheadfoot]{geometry} +\pagestyle{empty} +\parindent0pt +\nofiles +\let\familydefault\sfdefault +\begin{document} +\vbox to\textheight{\vss\centering +{\Large\textbf{xcolor} driver test: `\csname XC@@drv\endcsname'} +\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} +\testcolor[wave]{440} +\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} +\testcolor[wave]{490} +\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} +\testcolor[wave]{510} +\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} +\testcolor[wave]{580} +\noalign{\medskip} +\testcolor{red} +\testcolor[rgb]{1,0,0} +\testcolor[hsb]{0,1,1} +\testcolor[cmyk]{0,1,1,0} +\testcolor[gray]{0.3} +\testcolor[wave]{645} +\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} +\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} +% +% +% \fi +\endinput +%% +%% End of file `xcolor.dtx'. diff --git a/Master/texmf-dist/source/latex/xcolor/xcolor.ins b/Master/texmf-dist/source/latex/xcolor/xcolor.ins new file mode 100644 index 00000000000..9941813512e --- /dev/null +++ b/Master/texmf-dist/source/latex/xcolor/xcolor.ins @@ -0,0 +1,28 @@ +%% 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 -- cgit v1.2.3