1% \iffalse meta-comment 2%% 3%% ---------------------------------------------------------------- 4%% Copyright (C) 2003-2005 by Dr. Uwe Kern <xcolor at ukern dot de> 5%% ---------------------------------------------------------------- 6%% 7%<*package> 8%% Please send error reports and suggestions for 9%% improvements to the above email address. 10%% 11%% This package contains code copied from 12%% 13%% color.dtx [1999/02/16 v1.0i Standard LaTeX Color (DPC)] 14%% Copyright (C) 1994--1999 David Carlisle 15%% 16%% which is part of the Standard LaTeX `Graphics Bundle'. 17%% 18%</package> 19%<*extract|driver|test1|test2|test3|test4> 20\def\XCfileversion{v2.09}% 21\def\XCfiledate{2005/12/21}% 22%</extract|driver|test1|test2|test3|test4> 23% 24% This file may be distributed and/or modified under the 25% conditions of the LaTeX Project Public License, either version 1.2 26% of this license or (at your option) any later version. 27% The latest version of this license is in: 28% 29% http://www.latex-project.org/lppl.txt 30% 31% and version 1.2 or later is part of all distributions of LaTeX 32% version 1999/12/01 or later. 33% 34% \fi 35% 36% \CheckSum{4875} 37% 38% \DoNotIndex{\def,\gdef,\edef,\xdef,\long,\let} 39% \DoNotIndex{\ifnum,\ifdim,\iftrue,\iffalse,\ifx,\ifcase,\else,\or,\fi} 40% \DoNotIndex{\bgroup,\egroup,\begingroup,\endgroup,\begin,\end} 41% \DoNotIndex{\relax,\endinput} 42% \DoNotIndex{\csname,\endcsname,\string,\the,\noexpand,\expandafter} 43% \DoNotIndex{\advance,\count,\dimen} 44% \DoNotIndex{\m@ne,\z@,\@ne,\tw@,\p@,\@@tmp} 45% 46% \CharacterTable 47% {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 48% 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 49% Digits \0\1\2\3\4\5\6\7\8\9 50% Exclamation \! Double quote \" Hash (number) \# 51% Dollar \$ Percent \% Ampersand \& 52% Acute accent \' Left paren \( Right paren \) 53% Asterisk \* Plus \+ Comma \, 54% Minus \- Point \. Solidus \/ 55% Colon \: Semicolon \; Less than \< 56% Equals \= Greater than \> Question mark \? 57% Commercial at \@ Left bracket \[ Backslash \\ 58% Right bracket \] Circumflex \^ Underscore \_ 59% Grave accent \` Left brace \{ Vertical bar \| 60% Right brace \} Tilde \~} 61% 62% 63% \iffalse 64%<*batchfile> 65\IfFileExists{xcolor.ins}{\let\uknext=\relax}{\let\uknext=\stop} 66\begin{filecontents*}{xcolor.ins} 67%% Package `xcolor' by Dr. Uwe Kern 68%% 69%% Extract all package files: 70%% `latex xcolor.ins' 71%% 72%% Put the generated files to their respective locations 73%% within the TeX installation: 74%% *.sty -> /tex/latex/xcolor/ 75%% *.def -> /tex/latex/xcolor/ 76%% *.pro -> /dvips/xcolor/ 77%% 78%% Create the documentation: 79%% `latex xcolor.dtx' 80%% `latex xcolor.dtx' 81%% `makeindex -s gind.ist xcolor.idx' 82%% `latex xcolor.dtx' 83%% `latex xcolor.dtx' 84%% 85%% Run the test files (N=1,2,...): 86%% `latex xcolorN.tex' 87%% `latex xcolorN.tex' 88%% 89\def\batchfile{xcolor.ins} 90\input docstrip.tex 91\askforoverwritefalse 92\generate{\file{xcolor.lox}{\from{xcolor.dtx}{extract}}} 93\batchinput{xcolor.lox} 94\endbatchfile 95\end{filecontents*} 96%</batchfile> 97% 98%<*driver> 99\listfiles 100\ProvidesFile{xcolor.dtx}[\XCfiledate\space\XCfileversion\space 101 `xcolor' source and documentation (UK)] 102\documentclass{ltxdoc} 103\usepackage[table,showerrors,dvipsnames,hyperref]{xcolor}[2005/06/06] 104\usepackage{chngpage,varioref,tabularx,amsmath,amsthm} 105\usepackage 106 [\GinDriver,hyperindex=false,bookmarks,bookmarksopen,bookmarksopenlevel=1,% 107 pdftitle={xcolor \XCfileversion{} (\XCfiledate)},pdfauthor={Dr. Uwe Kern},% 108 pdfsubject={Color extensions for LaTeX and pdfLaTeX},% 109 pdfkeywords={xcolor,color,colour,model,tint,tone,shade,harmony,spot,latex,pdftex,dvips,% 110 conversion,blend,mix,mask,separation,rgb,cmy,cmyk,hsb,gray,html,wave,thsb,wheel}]{hyperref} 111\OnlyDescription 112\EnableCrossrefs 113\CodelineIndex 114\makeatletter 115\def\Meaning#1{\texttt{\expandafter\expandafter\expandafter\strip@prefix\expandafter\meaning\csname #1\endcsname}} 116\makeatother 117\pagestyle{myheadings} 118\markright{\hskip-2.5cm xcolor \XCfileversion\space(\XCfiledate)} 119\begin{document} 120 \DocInput{xcolor.dtx} 121 \let\Section\section\def\section*#1{\Section*{#1}\addcontentsline{toc}{section}{#1}} 122 \begin{adjustwidth}{-2.5cm}{} 123 \def\markboth#1#2{}\PrintIndex 124 \end{adjustwidth} 125\end{document} 126%</driver> 127% 128%<*extract> 129\def\ukfile#1#2#3#4% 130 {\def\ukhead 131 {\ifnum#1>2 \perCent!^^J\fi 132 \defaultpreamble^^J\MetaPrefix^^J% 133 \ifcase#1 134 \string\ProvidesPackage{#2}^^J\or 135 \string\ProvidesFile{#2}^^J\or 136 \string\ProvidesFile{#2.def}^^J\or 137 \MetaPrefix\space #2.pro (PostScript/dvips header file)^^J\MetaPrefix\space 138 \fi 139 \space[\XCfiledate\space\XCfileversion\space#4\space(UK)]} 140 \usepreamble\ukhead 141 \file{#2.\ifcase#1sty\or tex\or def\or pro\fi}{\from{xcolor.dtx}{#3}}} 142\generate{ 143\ukfile0{xcolor}{package}{LaTeX color extensions} 144\ukfile2{svgnam}{svgnames}{Predefined colors according to SVG 1.1} 145\ukfile2{x11nam}{x11names}{Predefined colors according to Unix/X11} 146\ukfile1{xcolor1}{test1}{Color conversion test} 147\ukfile1{xcolor2}{test2}{Pstricks color test} 148\ukfile1{xcolor3}{test3}{Color logging test} 149\ukfile1{xcolor4}{test4}{Color driver test} 150\def\PStail{\MetaPrefix\space End of file `\outFileName'.} 151\usepostamble\PStail 152\ukfile3{xcolor}{dvips}{LaTeX color extensions} 153} 154%</extract> 155% \fi 156% 157% 158% 159% \iffalse 160%------------------------------------------------------------------------------- 161% \fi 162% 163% 164% \makeatletter 165% 166% \def\testclr#1#{\@testclr{#1}} 167% \def\@testclr#1#2{{\fboxsep\z@\fbox{\colorbox#1{#2}{\phantom{XX}}}}} 168% \def\Testclr#1#{\@Testclr{#1}} 169% \def\@Testclr#1#2#3{\testclr#1{#2}~\rlap{\Color[-]{#3}}\\} 170% \def\TestClr#1#{\@TestClr{#1}} 171% \def\@TestClr#1#2#3{\testclr#1{#2}~\rlap{\Color[+]{#3}}\\} 172% \newif\if@Meta 173% \DeclareRobustCommand*\Meta{\@ifstar{\@Metatrue\@Meta}{\@Metafalse\@Meta}} 174% \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} 175% \def\DescribeArg#1{\leavevmode\@bsphack\marginpar{\raggedleft\Meta*{#1}}\@esphack\ignorespaces} 176% \def\DescribeFunc#1{\leavevmode\@bsphack\marginpar{\raggedleft\Function{#1}\strut}\@esphack\ignorespaces} 177% 178% \makeatother 179% 180% \def\Index#1{#1\index{#1\string|usage}} 181% \def\Package#1{\textsf{#1}\index{packages\levelchar\textsf{#1}\string|usage}} 182% \def\Program#1{\textsf{\itshape#1}\index{programs\levelchar\textsf{\itshape#1}\string|usage}} 183% \def\Model#1{\textsf{\bfseries#1}\index{color models\levelchar\textsf{\bfseries#1}\string|usage}} 184% \def\nModel#1{`#1'\index{color models\levelchar`#1'\string|usage}} 185% \def\pModel#1{\textbf{\itshape #1}} 186% \def\People#1#2{#1 #2\index{people\levelchar#2, #1\string|usage}} 187% \newcommand*\Color[2][+]{\textsl{#2}\ifx#1+\index{color names\levelchar\textsl{#2}\string|usage}\fi} 188% \def\Option#1{\texttt{#1}\index{package options\levelchar\texttt{#1}\string|usage}} 189% \def\Key#1{\textit{#1}\index{keys\levelchar\textit{#1}\string|usage}} 190% \def\File#1{\texttt{#1}\index{files\levelchar\texttt{#1}\string|usage}} 191% \def\Function#1{\textit{#1}\index{color functions\levelchar\textit{#1}\string|usage}} 192% \def\Op#1#2{#1\nolimits_{\,\Model{#2}}} 193% \def\med{\mathop{\textrm{med}}} 194% \def\mix{\mathop{\textrm{mix}}} 195% \def\rd{\mathop{\textrm{round}}} 196% \def\tint{\mathop{\textrm{tint}}} 197% \def\shade{\mathop{\textrm{shade}}} 198% \def\tone{\mathop{\textrm{tone}}} 199% \def\LC{\Package{color}} 200% \def\LCP{\Package{color} package} 201% \def\XC{\Package{xcolor}} 202% \def\XCP{\Package{xcolor} package} 203% \def\XCW{\texttt{\href{http://www.ukern.de/tex/xcolor.html}{www.ukern.de/tex/xcolor.html}}} 204% \def\URL#1{\texttt{\url{#1}}} 205% \def\CTAN#1#2{\texttt{\href{http://www.ctan.org/tex-archive/#1}{CTAN/#1#2}}} 206% \newtheorem{lemma}{Lemma} 207% \def\RtoI#1{\Gamma_{\!#1}} 208% \def\ItoR#1{\Delta_{#1}} 209% \def\bbbN{\textrm{I\kern-.333ex N}} 210% \def\bbbR{\textrm{I\kern-.333ex R}} 211% \def\Circ{\textsuperscript{$\circ$}} 212% 213% \newdimen\XCdim 214% 215% \parindent0pt 216% \extrarowheight1pt 217% \def\textfraction{0.01} 218% \def\topfraction{0.99} 219% \def\bottomfraction{0.99} 220% \def\floatpagefraction{0.70} 221% \setlength\abovecaptionskip{12pt} 222% \setlength\belowcaptionskip{10pt} 223% \colorlet{tableheadcolor}{gray!25} 224% \colorlet{tablerowcolor}{gray!12.5} 225% 226% 227% 228% \title{Extending \LaTeX's color facilities: the \XCP} 229% \author{\href{mailto:xcolor@ukern.de}{\fboxrule0pt\fboxsep2pt\fbox{Dr. Uwe Kern}}} 230% \date{\XCfileversion{} (\XCfiledate) 231% \thanks{This package can be downloaded from \CTAN{macros/latex/contrib/xcolor/}{}. 232% There is also an \textsf{xcolor} homepage: \XCW. 233% Please send error reports and suggestions for improvements to the author: 234% \texttt{\href{mailto:xcolor@ukern.de}{xcolor@ukern.de}}.}} 235% \maketitle 236% 237% \begin{abstract} 238% \noindent 239% \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}|. 240% It allows to select a document-wide target color model and offers tools for automatic color schemes, conversion between twelve color models, alternating table row colors, color blending and masking, color separation, and color wheel calculations. 241% \end{abstract} 242% 243% \phantomsection\pdfbookmark[1]{\contentsname}{toc} 244% \tableofcontents\listoftables\listoffigures\newpage 245% 246% 247% 248% 249% \clearpage 250% \section{Introduction} 251% 252% \subsection{Purpose of this package} 253% 254% 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). 255% 256% Nevertheless, it is sometimes a bit clumsy to use, especially in cases where slight color variations, color mixes or color conversions are involved: 257% this usually implies the usage of another program that calculates the necessary parameters, which are then copied into a |\definecolor| command in \LaTeX. 258% Quite often, also a pocket calculator is involved in the treatment of issues like the following: 259% \begin{itemize} 260% \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. 261% But how to access these color variations in \LaTeX?\\ 262% (Answer: |\color{CorporateColor!75}| etc.) 263% \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. 264% What to do now?\\ 265% (Answer: just use the \Model{hsb} definitions, \XC{} will do the necessary calculations) 266% \item How does a mixture of 40\% \Color{green} and 60\% \Color{yellow} look like?\\ 267% (Answer: 40\% \testclr{green} $+$ 60\% \testclr{yellow} $=$ \testclr{green!40!yellow}, e.g., |\color{green!40!yellow}|) 268% \item And how does its complementary color look like?\\ 269% (Answer: \testclr{-green!40!yellow}, accessible via |\color{-green!40!yellow}|) 270% \item Now I want to mix three parts of the last color with two parts of its complement and one part of \Color{red}. 271% How does that look?\\ 272% (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}|) 273% \item I know that light waves of 485nm are within the visible range. But which color do they represent?\\ 274% (Answer: approximately \testclr[wave]{485}, via |\color[wave]{485}|) 275% \item My printing office wants all color definitions in my document to be transformed into the \Model{cmyk} model. 276% How can I do the calculations efficiently?\\ 277% (Answer: |\usepackage[cmyk]{xcolor}| or |\selectcolormodel{cmyk}|) 278% \item I have a table with 50 rows. 279% How can I get alternating colors for entire rows without copying 50 |\rowcolor| commands? The alternating scheme should start in the 3rd row.\\ 280% (Answer: something like |\rowcolors{3}{OddColor}{EvenColor}|) 281% \end{itemize} 282% These are some of the issues solved by the \XCP. 283% Its purpose can be summarized as to maintain the characteristics of \LC, while providing additional features and flexibility with (hopefully) easy-to-use interfaces. 284% 285% 286% 287% \subsection{Color tints, shades, tones, and complements} 288% 289% According to \cite{smith} we define the terms 290% \begin{itemize} 291% \item \textbf{\Index{tint}}: a color with \Color{white} added, 292% \item \textbf{\Index{shade}}: a color with \Color{black} added, 293% \item \textbf{\Index{tone}}: a color with \Color{gray} added. 294% \end{itemize} 295% These are special cases of a general function 296% $\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$. 297% Thus, we set 298% \begin{align} 299% \tint(C,p) &:= \mix(C,|white|,p)\\ 300% \shade(C,p) &:= \mix(C,|black|,p)\\ 301% \tone(C,p) &:= \mix(C,|gray|,p) 302% \end{align} 303% where |white|, |black|, and |gray| are model-specific constants, see table \vref{tab.const}. 304% Further we define the term 305% \begin{itemize} 306% \item \textbf{complement}: a color $C^*$ that yields \Color{white} if superposed with the original color $C$, 307% \end{itemize} 308% knowing that there are also different concepts of complementarity in place (e.g., opposite colors on \emph{color wheels}). 309% See section \vref{sec.cnv} for calculation details and section \vref{sec.harmony} for some remarks on color wheels. 310% 311% 312% 313% \subsection{Color models} 314% 315% 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. 316% 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. 317% For example, a large range of colors can be constructed by linear combinations of the base colors \Color{red}, \Color{green}, and \Color{blue}. 318% 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. 319% 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. 320% 321% 322% 323% \subsection{Color wheels and color harmony}\label{sec.harmony} 324% 325% There has been a long history of placing colors (hues) on wheels in order to discuss theoretical or practical color issues (e.g., \People{Isaac}{Newton}, \People{Johann Wolfgang von}{Goethe}). 326% One reason may be that the circle itself is a natural tool to demonstrate common relationships as well as opposite properties. 327% 328% Nowadays, there exists some confusion about notions, since both major areas related to color --- art and graphics design on one hand, scientific color theory on the other hand --- tend to use the same words to describe color properties, however meaning sometimes very different facts! 329% Thus, the appearance of color wheels differs as well as the meaning of concepts like `primary' or `complementary' colors. 330% 331% 332% \paragraph{Typical color wheel construction} 333% First, three \emph{primary colors} are placed at 0\Circ, 120\Circ, 240\Circ (artists often choose \Color{red}, \Color{yellow}, \Color{blue}, whereas color scientists might prefer \Color{red}, \Color{green}, \Color{blue}). 334% Next, three \emph{secondary colors} are put at 60\Circ, 180\Circ, 300\Circ. 335% Then, six \emph{tertiary colors} may be placed in between (30\Circ, 90\Circ, \dots). 336% This is why color wheels are frequently described to consist of twelve equidistant colors, although the algorithm can be repeated arbitrarily often. 337% 338% 339% \paragraph{Color harmonies derived from a wheel} 340% We start with an arbitrary color wheel: 341% \begin{itemize} 342% \item \textbf{complementary colors} have a distance of 180\Circ{} on the wheel, 343% \item \textbf{color triads} consist of three colors in 120\Circ{} steps, 344% \item \textbf{color tetrads} consist of four colors in 90\Circ{} steps. 345% \end{itemize} 346% We assume now that the wheel is partitioned into $2n$ sectors of equal size: 347% \begin{itemize} 348% \item \textbf{split complementary colors} of a given color are the two immediate neighbours of its complementary color, characterised by the positions $\frac{n\pm1}{2n}\cdot360^\circ$, 349% \item \textbf{analogous colors} to a given color are its two or four neighbours, characterised by the positions $\pm\frac{1}{2n}\cdot360^\circ$ and $\pm\frac{2}{2n}\cdot360^\circ$. 350% \end{itemize} 351% Given these methods to generate `color harmonies', we conclude that the results depend heavily on how we constructed the wheel! 352% Moreover, the choice of $n$ will affect the visual results as well. 353% Examples are shown in figure \vref{fig.harmony}. 354% 355% 356% 357% 358% \clearpage 359% \section{The User Interface} 360% 361% \subsection{Preparation} 362% 363% \subsubsection{Package installation} 364% 365% First of all, put \File{xcolor.sty} and all the \File{.def} files to some place where (pdf)\LaTeX{} finds them. 366% 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. 367% Additionally, put \File{xcolor.pro} to a place where \Program{dvips} finds it, typically |texmf/dvips/xcolor|. 368% 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. 369% Then simply use \XC{} (instead of \LC) in your document. 370% Thus, the general command is |\usepackage|\oarg{options}|{xcolor}| in the document preamble. 371% Table \vref{tab.package} shows what has to be taken into account with respect to the package loading order. 372% 373% 374% \subsubsection{Package options} 375% 376% In general, there are several types of options: 377% \begin{itemize} 378% \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}, 379% \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}), 380% \item options that control whether and how certain sets of predefined colors are being loaded: \Option{dvipsnames}, \Option{dvipsnames*}, \Option{svgnames}, \Option{svgnames*}, \Option{x11names}, \Option{x11names*}, 381% \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}), 382% \item options that determine the behaviour of other commands: \Option{prologue}, \Option{kernelfbox}, \Option{xcdraw}, \Option{noxcdraw}, \Option{showerrors}, \Option{hideerrors}, 383% \item obsolete options: \Option{override}, \Option{usenames}, \Option{nodvipsnames}. 384% \end{itemize} 385% All available package options (except driver selection and obsolete options) are listed in table \vref{tab.opt}. 386% \DescribeMacro\GetGinDriver 387% \DescribeMacro\GinDriver 388% 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|. 389% The latter can then be used within \Package{hyperref} (or other packages), see the code example on page \pageref{ex.range}. 390% If there is no corresponding \Package{hyperref} option, \Option{hypertex} will be taken as default. 391% 392% Warning: there is a substantial difference between \XC{} and \LC{} regarding how the \Option{dvips} option is being handled. 393% The \LCP{} implicitly invokes the \Option{dvipsnames} option, whenever one of the |dvips|, |oztex|, |xdvi| drivers is selected. 394% 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. 395% Therefore, \XC{} always requires an explicit \Option{dvipsnames} option to use these names --- which then works for all drivers. 396% 397% 398% \begin{table}[p]\caption{Package options}\label{tab.opt} 399% \extrarowheight2pt 400% \begin{adjustwidth}{-2.5cm}{} 401% \advance\textwidth2.5cm 402% \rowcolors{3}{tablerowcolor}{} 403% \begin{tabularx}{\linewidth}{lX} 404% \hline 405% \rowcolor{tableheadcolor} 406% \em Option & \em Description\\ 407% \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}).\\ 408% \Option{rgb}& Convert all colors to the \Model{rgb} model.\\ 409% \Option{cmy}& Convert all colors to the \Model{cmy} model.\\ 410% \Option{cmyk}& Convert all colors to the \Model{cmyk} model.\\ 411% \Option{hsb}& Convert all colors to the \Model{hsb} model.\\ 412% \Option{gray}& Convert all colors to the \Model{gray} model. Especially useful to simulate how a black \& white printer will output the document.\\ 413% \Option{RGB}& Convert all colors to the \Model{RGB} model (and afterwards to \Model{rgb}).\\ 414% \Option{HTML}& Convert all colors to the \Model{HTML} model (and afterwards to \Model{rgb}).\\ 415% \Option{HSB}& Convert all colors to the \Model{HSB} model (and afterwards to \Model{hsb}).\\ 416% \Option{Gray}& Convert all colors to the \Model{Gray} model (and afterwards to \Model{gray}).\\ 417% \hline 418% \Option{dvipsnames}, \Option{dvipsnames*}& Load a set of predefined colors.\footnotemark[1]\\ 419% \Option{svgnames}, \Option{svgnames*}& Load a set of predefined colors according to \Index{SVG} 1.1.\footnotemark[1]\\ 420% \Option{x11names}, \Option{x11names*}& Load a set of predefined colors according to \Index{Unix}/\Index{X11}.\footnotemark[1]\\ 421% \hline 422% \Option{table}& Load the \Package{colortbl} package, in order to use the tools for coloring rows, columns, and cells within tables.\\ 423% \Option{fixpdftex}& Load the \Package{pdfcolmk} package, in order to improve |pdftex|'s color behaviour (see section \vref{sec.fixpdftex}).\\ 424% \Option{pst}& Load the \Package{pstcol} package, in order to use `normal' color definitions within \Package{pstricks} macros (see footnote \vref{fnt.pst}).\\ 425% \Option{hyperref}& Support the \Package{hyperref} package in terms of color expressions by defining additional keys (see section \vref{sec.hyperref}).\\ 426% \hline 427% \Option{prologue}& Write prologue information to \File{.xcp} file for every color definition (as described in section \vref{sec.prologue}).\\ 428% \hline 429% \Option{kernelfbox}& Use \LaTeX{} kernel method to draw \texttt{\string\f(rame)box} frames\footnotemark[2].\\ 430% \Option{xcdraw}& Use driver-specific commands to draw frames and color boxes.\footnotemark[2]\\ 431% \Option{noxcdraw}& (Default.) Use generic code to draw frames and color boxes.\footnotemark[2]\\ 432% \hline 433% \Option{showerrors}& (Default.) Display an error message if an undefined color is being used (same behaviour as in the original \LCP).\\ 434% \Option{hideerrors}& Display only a warning if an undefined color is being used, and replace this color by \Color{black}.\\ 435% \hline\hline 436% \multicolumn2{c}{\footnotemark[1]\,See section \vref{sec.additionalcolors}.\quad \footnotemark[2]\,See section \vref{sec.fbox}.}\\ 437% \hline 438% \end{tabularx} 439% \end{adjustwidth} 440% \end{table} 441% 442% 443% \begin{table}[htbp]\caption{Package loading order}\label{tab.package} 444% \centering 445% \extrarowheight2pt 446% \rowcolors{3}{tablerowcolor}{} 447% \begin{tabular}{lccccc} 448% \hline 449% \rowcolor{tableheadcolor} 450% \em Action/Package & \LC & \Package{colortbl}& \Package{pdfcolmk}& \Package{pstcol}& \Package{hyperref}\\ 451% load before \XC & no & no & no & no & allowed \\ 452% load with \XC{} option& --- & \Option{table} & \Option{fixpdftex} & \Option{pst}\footnotemark[1] & ---\\ 453% load after \XC & no & no & allowed & no & allowed \\ 454% \hline\hline 455% \multicolumn5{c}{\footnotemark[1]\,not recommended, better use recent \File{pstricks.sty}}\\ 456% \hline 457% \end{tabular} 458% \end{table} 459% 460% 461% \begin{table}[htbp]\caption{Supported color models}\label{tab.mod} 462% \centering 463% \extrarowheight2pt 464% \rowcolors{3}{tablerowcolor}{} 465% \begin{tabular}{l>{\em}l>{$}l<{$}rl} 466% \hline 467% \rowcolor{tableheadcolor} 468% \emph{Name} & Base colors/notions & \emph{Parameter range}& \multicolumn2{>{\columncolor{tableheadcolor}}l}{\emph{Default}}\\ 469% \Model{rgb} & red, green, blue & \left[0,1\right]^3&& \\ 470% \Model{cmy} & cyan, magenta, yellow & \left[0,1\right]^3&& \\ 471% \Model{cmyk} & cyan, magenta, yellow, black & \left[0,1\right]^4&& \\ 472% \Model{hsb} & hue, saturation, brightness & \left[0,1\right]^3&& \\ 473% \Model{Hsb} & hue\Circ\!, saturation, brightness & \left[0,H\right]\times\left[0,1\right]^2&$H=$& $\mkern-15mu\rangeHsb$\\ 474% \Model{tHsb} & hue\Circ\!, saturation, brightness & \left[0,H\right]\times\left[0,1\right]^2&$H=$& $\mkern-15mu\rangeHsb$\\ 475% \Model{gray} & gray & \left[0,1\right]&& \\ 476% \Model{RGB} & Red, Green, Blue & \{0,1,\dots,L\}^3& $L\,=$& $\mkern-15mu\rangeRGB$\\ 477% \Model{HTML} & RRGGBB & \{\texttt{000000},\dots,\texttt{FFFFFF}\}&& \\ 478% \Model{HSB} & Hue, Saturation, Brightness & \{0,1,\dots,M\}^3& $M=$& $\mkern-15mu\rangeHSB$\\ 479% \Model{Gray} & Gray & \{0,1,\dots,N\}& $N\,=$& $\mkern-15mu\rangeGray$\\ 480% \Model{wave} & lambda \emph{(nm)}& \left[363,814\right]&& \\ 481% \hline\hline 482% \multicolumn5{c}{$L,M,N$ are positive integers; $H$ is a positive real number}\\ 483% \hline 484% \end{tabular} 485% \end{table} 486% 487% 488% \subsubsection{Executing additional initialisation commands} 489% 490% \DescribeMacro\xcolorcmd 491% 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). 492% Just say |\def\xcolorcmd|\marg{commands} at some point before \XC{} is loaded. 493% 494% Example: assuming that |a.tex| is a complete \LaTeX{} document, a command like 495% `|latex \def\xcolorcmd{\colorlet{black}{red}}\input{a}|' 496% 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. 497% (The exact spelling of the console command might vary across operating systems and \TeX{} distributions.) 498% 499% 500% 501% \subsection{Color models} 502% 503% \subsubsection{Supported color models} 504% 505% The list of supported color models and their parameter ranges is given in table \vref{tab.mod}. 506% We emphasize that this color support is independent of the chosen driver. 507% 508% `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}). 509% 510% \paragraph{\Model{rgb}, \Model{cmyk}, \Model{hsb}, \Model{gray}} 511% These are the models supported by \Index{PostScript} directly. 512% We therefore refer to \cite{plrm} for a description of their properties and relations. 513% There is a special command 514% \DescribeMacro\adjustUCRBG 515% 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. 516% 517% \paragraph{\Model{cmy}} 518% This is mainly a model for intermediary calculation steps. 519% With respect to that, it is a simple complement of \Model{rgb}. 520% As far as visualisation is concerned, \Model{cmy} is treated as \Model{cmyk} with $k=0$. 521% 522% \paragraph{\Model{HTML}} 523% This is a model derived from \Model{rgb} in order to enable input of color parameters from web pages or CSS files. 524% Therefore, it is not really a color model of its own right, but rather a user interface for convenience. 525% It is worth mentioning that \Model{HTML} accepts any combination of the characters |0|--|9|, |A|--|F|, |a|--|f|, as long as the string has a length of exactly 6~characters. 526% However, outputs of conversions to \Model{HTML} will always consist of numbers and \emph{uppercase} letters. 527% 528% \paragraph{\Model{Hsb}, \Model{tHsb}} 529% Firstly, \Model{Hsb} is a `user interface' model, mapping $\emph{hue}\in[0,1]$ onto $\emph{hue\Circ}\in[0,H]$, where $H$ is given by |\def\rangeHsb|\marg{H}. 530% \DescribeMacro\rangeHsb 531% Thus, if $H=360$, we can think of a circle or wheel to specify the \emph{hue\Circ} parameter. 532% Secondly, \Model{Hsb} is the basis for \Model{tHsb}, also named \pModel{tuned} \Model{Hsb}, which enables the user to apply a piecewise linear transformation on \emph{hue\Circ} by shifting selected \emph{hue\Circ} values forward or backward on the circle. 533% This transformation is defined by |\def\rangetHsb{|$x_1,y_1;x_2,y_2;\dots$|}| 534% \DescribeMacro\rangetHsb 535% which specifies that $\emph{hue\Circ}=x_1$ in \Model{tHsb} means $\emph{hue\Circ}=y_1$ in \Model{Hsb}, etc. 536% For example, \Color{yellow} is at 60\Circ{} in the \Model{Hsb} circle (\Color{red} being at 0\Circ), however, in most color wheels used by artists, \Color{yellow} is at 120\Circ. 537% Therefore, a `|120,60|' entry would make sense if we planned to replicate an artist's color wheel via \Model{tHsb}. 538% See section \vref{sec.tHsb2Hsb} for the exact transformation formula and further restrictions, and section \vref{sec.harmony} for color wheels and color harmonies. 539% Figure \vref{fig.tHsb} may serve for comparison purposes. 540% 541% Example: `|\def\rangetHsb{|\texttt{\rangetHsb}|}|' is in fact \XC's default setting. 542% 543% \paragraph{\Model{wave}} 544% With this model we try to make wavelengths transformable to standard color models, in order to approximate the visual appearance of light waves. 545% While the visible spectrum covers a range of approximately 400--750\,nm, the implementation in \XC{} generally allows for all real `wavelengths' $\lambda$ that have an absolute value less than \csname strip@pt\endcsname\maxdimen{} (the biggest number \TeX{} can represent as a dimension). 546% However, the probability of getting any non-black color outside the range of $\lambda\in[363,814]$ is exactly zero. 547% Therefore, figure \vref{fig.spectrum} illustrates only the mentioned wavelength interval. 548% Note that it is not possible to convert other models to \Model{wave} in a sensible way, since the latter covers only a limited range of colors. 549% 550% \paragraph{\Model{RGB}, \Model{HSB}, \Model{Gray}} 551% These are derived models, turning the continuous $[0,1]$ parameter ranges of \Model{rgb}, \Model{hsb}, and \Model{gray} to finite sets of integers; we therefore use the term \emph{integer models}. 552% The constants $L, M, N$ of table \ref{tab.mod} are defined via the commands |\def\rangeRGB|\marg{L}, 553% \DescribeMacro\rangeRGB 554% |\def\rangeHSB|\marg{M}, 555% \DescribeMacro\rangeHSB 556% and |\def\rangeGray|\marg{N}. 557% \DescribeMacro\rangeGray 558% Changes of these constants can be done \emph{before} or \emph{after} the \XCP{} is loaded, e.g., 559% \label{ex.range}\begin{verbatim} 560% \documentclass{article} 561% ... 562% \def\rangeRGB{15} 563% \usepackage[dvips]{xcolor} 564% ... 565% \GetGinDriver 566% \usepackage[\GinDriver]{hyperref} 567% ... 568% \begin{document} 569% ... 570% \def\rangeRGB{63} 571% ... 572% \end{verbatim} 573% 574% 575% \subsubsection{Substituting individual color models}\label{sec.subst} 576% 577% \DescribeMacro\substitutecolormodel 578% \marg{source model}\marg{target model-list}\\ 579% Substitute \Meta{source model} by the first actually present model that occurs in \Meta{target model-list}. 580% Only color models of type \Meta{num model} are allowed; 581% all changes are local to the current group, but a prepended |\xglobal| is obeyed. 582% 583% Example: assume the actual driver has an incorrect implementation of \Model{hsb} whereas \Model{rgb} looks well. 584% 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. 585% 586% 587% \subsubsection{Changing the target color model within a document}\label{sec.tgt} 588% 589% \DescribeMacro\selectcolormodel 590% \marg{num model}\\ 591% 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. 592% There are two possible hooks, where the conversion to the target model can take place: 593% \begin{itemize} 594% \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|; 595% \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|. 596% \end{itemize} 597% Both switches are set to `true' by selecting any of the models, except \Option{natural}, which sets them to `false'. 598% This applies for selection via a package option as well as via |\selectcolormodel|. 599% Why don't we simply convert all colors at time of usage? 600% If many colors are involved, it can save some processing time when all conversions are already done during color definitions. 601% Best performance can be achieved by saying |\usepackage[rgb,...]{xcolor}\convertcolorsUfalse|, which is actually the way how \XC{} worked up to version 1.07. 602% 603% 604% \begin{table}[p]\caption{Arguments and terminology}\label{tab.term} 605% \def\RS{\ensuremath{\to}\space} 606% \footnotesize\raggedleft 607% \extrarowheight2pt 608% \begin{adjustwidth}{-2.5cm}{} 609% \advance\textwidth2.5cm 610% \tabcolsep.25em 611% \rowcolors{3}{tablerowcolor}{} 612% \begin{tabularx}{\textwidth}{lX} 613% \hline 614% \rowcolor{tableheadcolor} 615% \em Element & \em Replacement string\\ 616% \Meta*{empty}& \RS empty string `'\\ 617% \Meta*{minus}& \RS non-empty string consisting of one or more minus signs `|-|'\\ 618% \Meta*{plus}& \RS non-empty string consisting of one or more plus signs `|+|'\\ 619% \hline 620% \Meta*{int}& \RS integer number\hfill(\emph{integer})\\ 621% \Meta*{num}& \RS non-negative integer number\hfill(\emph{number})\\ 622% \Meta*{dec}& \RS real number\hfill(\emph{decimal})\\ 623% \Meta*{div}& \RS non-zero real number\hfill(\emph{divisor})\\ 624% \Meta*{pct}& \RS real number from the interval $[0,100]$\hfill(\emph{percentage})\\ 625% \hline 626% \Meta*{id}& \RS non-empty string consisting of letters and digits\hfill(\emph{identifier})\\ 627% \Meta*{ext id}& \RS \Meta{id}\newline 628% \RS \Meta[1]{id}|=|\Meta[2]{id}\\ 629% \Meta*{id-list}& \RS \Meta[1]{ext id}|,|\Meta[2]{ext id}|,...,|\Meta[l]{ext id}\\ 630% \Meta*{name}& \RS \Meta{id}\hfill(\emph{explicit name})\newline 631% \RS `|.|'\hfill(\emph{implicit name})\\ 632% \Meta*{core model}& \RS `|rgb|', `|cmy|', `|cmyk|', `|hsb|', `|gray|'\hfill(\emph{core models})\\ 633% \Meta*{num model}& \RS \Meta{core model}\newline 634% \RS `|RGB|', `|HTML|', `|HSB|', `|Gray|'\hfill(\emph{integer models})\newline 635% \RS `|Hsb|', `|tHsb|', `|wave|'\hfill(\emph{decimal models})\\ 636% \Meta*{model}& \RS \Meta{num model}\hfill(\emph{numerical models})\newline 637% \RS `|named|'\hfill(\emph{pseudo model})\\ 638% \Meta*{model-list}& \RS \Meta[1]{model}|/|\Meta[2]{model}|/.../|\Meta[m]{model} \hfill(\emph{multiple models})\newline 639% \RS \Meta{core model}|:|\Meta[1]{model}|/|\Meta[2]{model}|/.../|\Meta[m]{model}\\ 640% \Meta*{spec}& \RS comma-separated list of numerical values\hfill(\emph{explicit specification})\newline 641% \RS space-separated list of numerical values\hfill(\emph{explicit specification})\newline 642% \RS name of a `named' color\hfill(\emph{implicit specification})\\ 643% \Meta*{spec-list}& \RS \Meta[1]{spec}|/|\Meta[2]{spec}|/.../|\Meta[m]{spec} \hfill(\emph{multiple specifications})\\ 644% \Meta*{type}& \RS \Meta{empty}\newline 645% \RS `|named|', `|ps|'\\ 646% \hline 647% \Meta*{expr}& \RS \Meta{prefix}\Meta{name}\Meta{mix expr}\Meta{postfix}\hfill(\emph{standard color expression})\\ 648% \Meta*{prefix}& \RS \Meta{empty}\newline 649% \RS \Meta{minus}\hfill(\emph{complement indicator})\\ 650% \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 651% \RS |!|\Meta[1]{pct}|!|\Meta[1]{name}|!|\Meta[2]{pct}|!|\Meta[2]{name}|!...!|\Meta[n]{pct} \hfill(\emph{incomplete mix expr.})\\ 652% \Meta*{postfix}& \RS \Meta{empty}\newline 653% \RS |!!|\Meta{plus}\hfill(\emph{series step})\newline 654% \RS |!![|\Meta{num}|]|\hfill(\emph{series access})\\ 655% \hline 656% \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 657% \RS \Meta{core model}|:|\Meta[1]{expr}|,|\Meta[1]{dec}|;|\Meta[2]{expr}|,|\Meta[2]{dec}|;...;|\Meta[k]{expr}|,|\Meta[k]{dec}\\ 658% \hline 659% \Meta*{func expr}& \RS |>|\Meta{function}|,|\Meta[1]{arg}|,|\Meta[2]{arg}|,...,|\Meta[j]{arg}\hfill(\emph{color function expression})\\ 660% \Meta*{function}& \RS `|wheel|', `|twheel|'\hfill(\emph{color functions})\\ 661% \hline 662% \Meta*{color}& \RS \Meta{color expr}\Meta[1]{func expr}\Meta[2]{func expr}|...|\Meta[i]{func expr}\\ 663% \Meta*{color expr}& \RS \Meta{name}\newline 664% \RS \Meta{expr}\newline 665% \RS \Meta{ext expr}\\ 666% \hline\hline 667% \rowcolor{white} 668% Remarks:& Each \RS denotes a possible replacement string for the element in the left column; 669% however, further context-dependent restrictions may apply. 670% See main text for details. 671% A string `|foo|' is always to be understood without the quotes. 672% $i,j,k,l,m,n$ denote non-negative integers, $k,l,m,n>0$, $m\le8$.\\ 673% \hline 674% \end{tabularx} 675% \end{adjustwidth} 676% \end{table} 677% 678% 679% 680% \subsection{Arguments and terminology}\label{sec.term} 681% 682% Before we describe \XC's color-related commands in detail, we define several elements or identifiers that appear repeatedly within arguments of those commands. 683% A general syntax overview is given in table \vref{tab.term}. 684% 685% 686% \subsubsection{Additional remarks and restrictions on arguments} 687% 688% \paragraph{Basic strings and numbers} 689% \DescribeArg{empty} 690% \DescribeArg{minus} 691% \DescribeArg{plus} 692% \DescribeArg{int} 693% \DescribeArg{num} 694% \DescribeArg{dec} 695% \DescribeArg{pct} 696% \DescribeArg{div} 697% These arguments do not need much explanation. 698% 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$. 699% 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. 700% 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. 701% 702% 703% \paragraph{Color names} 704% \DescribeArg{name} 705% A \Meta{name} denotes the declared name (or the name to be declared) of a \emph{color} or a \emph{color series}; 706% it may be declared \emph{explicitly} by one of the following commands: |\definecolor|, |\providecolor|, |\colorlet|, |\definecolorset|, |\providecolorset|, |\definecolorseries|, |\definecolors|, |\providecolors|. 707% On the other hand, the reserved color name `|.|' is declared \emph{implicitly} and denotes the \emph{current color}. 708% 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. 709% 710% Examples: `|red|', `|MySpecialGreen1980|', `|.|'. 711% 712% 713% \paragraph{Color models} 714% \DescribeArg{core model} 715% \DescribeArg{num model} 716% \DescribeArg{model} 717% The differentiation between \emph{core models} (\Model{rgb}, \Model{cmy}, \Model{cmyk}, \Model{hsb}, \Model{gray}), \emph{integer models} (\Model{RGB}, \Model{HTML}, \Model{HSB}, \Model{Gray}), \emph{decimal models} (\Model{Hsb}, \Model{tHsb}, \Model{wave}) and \emph{pseudo models} (currently \nModel{named}, \nModel{ps}) has a simple reason: core models with their parameter ranges based on the unit interval $[0,1]$ are best suited for all kinds of calculations, whereas the purpose of the integer models is mainly to facilitate the input of parameters, followed by some transformation into one of the core models. 718% Finally, the decimal models \Model{Hsb} and \Model{tHsb} are special-purpose versions of \Model{hsb}, whereas \Model{wave} and the pseudo model \nModel{named} have a special status, since they are `calculation-averse': it is usually only possible to convert such a color into one of the other models, but not the other way round. 719% Even worse for the pseudo model \nModel{ps}: since such colors contain \Index{PostScript} code, they are absolutely intransparent for \TeX. 720% 721% 722% \paragraph{Color specifications} 723% \DescribeArg{spec} 724% The \Meta{spec} argument --- which specifies the parameters of a color --- obviously depends on the underlying color model. 725% 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. 726% 727% Examples: `|.1,.2,.3|', `|.1 .2 .3|', `|0.56789|', `|89ABCD|', `|ForestGreen|'. 728% 729% 730% \paragraph{Multiple models and specifications} 731% \DescribeArg{model-list} 732% \DescribeArg{spec-list} 733% These arguments always appear in (explicit or implicit) pairs within the following color definition commands: 734% |\definecolor|, |\providecolor|, |\definecolorset|, |\providecolorset|. 735% 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. 736% Then, the corresponding color specification will be selected from \Meta{spec-list}, such that we arrive at a proper $(\Meta{model}, \Meta{spec})$ pair. 737% Therefore, in the actual executed color definition there is no ambiguity anymore. 738% The extended form \Meta{core model}|:|\Meta[1]{model}|/|\Meta[2]{model}|/.../|\Meta[m]{model} causes an immediate conversion of the relevant \Meta{spec} to \Meta{core model}; an unknown target model will be silently ignored here. 739% 740% Examples: `|rgb/cmyk/named/gray|', `|0,0,0/0,0,0,1/Black/0|', `|rgb:cmy/hsb|'. 741% 742% 743% \paragraph{The type argument} 744% \DescribeArg{type} 745% This is used only in the context of color defining commands, see the description of |\definecolor| and friends. 746% 747% 748% \paragraph{Standard color expressions} 749% \DescribeArg{expr} 750% \DescribeArg{prefix} 751% \DescribeArg{mix expr} 752% \DescribeArg{postfix} 753% These expressions serve as a tool to easily specify a certain form of cascaded color mixing which is described in detail in section~\ref{sec.expr-meaning}. 754% The \Meta{prefix} argument controls whether the color following thereafter or its complement will be relevant: 755% an odd number of minus signs indicates that the color resulting from the remaining expression has to be converted into its complementary color. 756% 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. 757% The \Meta{postfix} string is usually empty, but it offers some additional functionality in the case of a \emph{color series}: 758% the non-empty cases require that 759% \begin{itemize} 760% \item \Meta{name} denotes the name of a \emph{color series}, 761% \item \Meta{mix expr} is a \emph{complete} mix expression. 762% \end{itemize} 763% 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]|'. 764% 765% 766% \paragraph{Extended color expressions} 767% \DescribeArg{ext expr} 768% These expressions provide another method of color mixing, see section \vref{sec.extexpr-meaning} for details. 769% The shorter form 770% \begin{align*} 771% \Meta{core model}&|:|\Meta[1]{expr}|,|\Meta[1]{dec}|;|\Meta[2]{expr}|,|\Meta[2]{dec}|;...;|\Meta[k]{expr}|!|\Meta[k]{dec}\\ 772% \intertext{is an abbreviation for the special (and probably most used) case} 773% \Meta{core model}|,|\Meta{div}&|:|\Meta[1]{expr}|,|\Meta[1]{dec}|;|\Meta[2]{expr}|,|\Meta[2]{dec}|;...;|\Meta[k]{expr}|!|\Meta[k]{dec}\\ 774% \intertext{with the following definition (requiring a non-zero sum of all \Meta[\kappa]{dec} coefficients):} 775% \Meta{div} &:= \Meta[1]{dec} + \Meta[2]{dec} + \dots + \Meta[k]{dec} \neq0. 776% \end{align*} 777% Examples: `|rgb:red,1|', `|cmyk:red,1;-green!25!blue!60,11.25;blue,-2|'. 778% 779% 780% \paragraph{Function expressions} 781% \DescribeArg{func expression} 782% \DescribeArg{function} 783% These expressions extend the functionality of \emph{standard} or \emph{extended} expressions by taking the result of such an expression to perform additional calculations. 784% The number of arguments may vary between different functions, see section \vref{sec.functions} for details. 785% 786% Examples: `|>wheel,30|', `|>wheel,30,|', `|>twheel,1,12|', `|>twheel,-11,12|'. 787% 788% 789% 790% \paragraph{Colors} 791% \DescribeArg{color} 792% \DescribeArg{color expr} 793% Finally, \Meta{color} is the `umbrella' argument, covering the different concepts of specifying colors. 794% This means, whenever there is a \Meta{color} argument, the full range of names and expressions, as explained above, may be used. 795% 796% 797% \subsubsection{Meaning of standard color expressions}\label{sec.expr-meaning} 798% 799% We explain now how an expression 800% \begin{gather*} 801% \Meta{prefix}\Meta{name}|!|\Meta[1]{pct}|!|\Meta[1]{name}|!|\Meta[2]{pct}|!|\dots|!|\Meta[n]{pct}|!|\Meta[n]{name}\Meta{postfix} 802% \end{gather*} 803% is being interpreted and processed: 804% \begin{enumerate} 805% \item First of all, the model and color parameters of \Meta{name} are extracted to define a temporary color \Meta{temp}. 806% 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}. 807% \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}. 808% \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}). 809% \item If \Meta{prefix} consists of an odd number of minus signs `-', then \Meta{temp} will be changed into its complementary color. 810% \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}. 811% This has no consequences for the color \Meta{temp}. 812% \item Now the color \Meta{temp} is being displayed or serves as an input for other operations, depending on the invoking command. 813% \end{enumerate} 814% 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. 815% 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}{...}|. 816% 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}.} 817% 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. 818% 819% Figures \vrefrange{fig.expr}{fig.ex} show some first applications of colors and expressions. 820% More examples are given in figure \vref{fig.progress}. 821% Over and above that, a large set of color examples can be found in \cite{chroma}. 822% 823% 824% \subsubsection{Meaning of extended color expressions}\label{sec.extexpr-meaning} 825% 826% An \emph{extended color expression} 827% \begin{gather*} 828% \Meta{core model}|:|\Meta[1]{expr}|,|\Meta[1]{dec}|;|\Meta[2]{expr}|,|\Meta[2]{dec}|;...;|\Meta[k]{expr}|,|\Meta[k]{dec} 829% \end{gather*} 830% mimes color mixing as painters do it: specify a list of colors, each with a \Meta{dec} factor attached to. 831% 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 832% \begin{gather*} 833% \Meta{div} := \Meta[1]{dec} + \Meta[2]{dec} + \dots + \Meta[k]{dec}. 834% \end{gather*} 835% Afterwards the sum of all of these vectors is calculated. 836% 837% 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}|. 838% Trying the same with $-1$ parts of \Color{yellow} instead, we get \testclr{rgb:red,4;green,2;yellow,-1}. 839% 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. 840% The general form 841% \begin{gather*} 842% \Meta{core model}|,|\Meta{div}|:|\Meta[1]{expr}|,|\Meta[1]{dec}|;|\Meta[2]{expr}|,|\Meta[2]{dec}|;...;|\Meta[k]{expr}|,|\Meta[k]{dec} 843% \end{gather*} 844% does the same operation with the only difference that the divisor \Meta{div} is being specified instead of calculated. 845% 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}|. 846% 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]$. 847% However, the mapping of equation (\ref{eq.U}) takes care of such cases. 848% 849% 850% \subsubsection{Color functions}\label{sec.functions} 851% 852% Color functions take a comma-separated list of arguments, and they serve to transform the \emph{given color} (i.e., the result of all calculations prior to the function call) into a new color. 853% 854% \paragraph{Color wheel calculations} 855% \DescribeFunc{wheel} 856% \DescribeFunc{twheel} 857% Arguments: \Meta{angle} or \Meta{angle}|,|\Meta{full circle}, the former being an abbreviataion of \Meta{angle}|,\rangeHsb|. 858% These functions allow to calculate related colors by harmonic relations based on color wheels (cf.~section \vref{sec.harmony}). 859% The second argument \Meta{full circle} declares how many units a full circle consists of, the first argument states by how many units the given color has to be rotated. 860% To this end, the given color is first converted to \Model{Hsb} (in case of \Function{wheel}), yielding \emph{hue\Circ}, \emph{saturation}, and \emph{brightness}, respectively. 861% Then 862% \begin{gather} 863% \displaystyle\emph{hue\Circ} := \emph{hue\Circ} + \frac{\Meta{angle}}{\Meta{full circle}}\cdot H, \qquad \emph{hue} := u\Bigl( \frac{\emph{hue\Circ}}{H} \Bigr) 864% \end{gather} 865% where $u$ is the range-reduction function of equation~(\ref{eq.U}) and $H = \texttt{\string\rangeHsb}$. 866% With \emph{saturation} and \emph{brightness} left untouched, the final model is \Model{hsb}. 867% The \Function{twheel} function works similarly, but its arguments refer to \Model{tHsb} instead of \Model{Hsb}. 868% Examples are shown in figure \vref{fig.harmony}. 869% 870% 871% \subsection{Predefined colors} 872% 873% \subsubsection{Colors that are always available} 874% 875% \def\test#1{\testclr{#1}~\Color{#1}} 876% Within \File{xcolor.sty}, the following color names are defined: 877% \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}. 878% 879% This base set of colors can be used without restrictions in all kinds of color expressions, as explained in section \vref{sec.term}. 880% 881% 882% \subsubsection{Additional sets of colors}\label{sec.additionalcolors} 883% 884% There are also sets of color names that may be loaded by \XC{} via package options, available in two variants: 885% a `normal' version (e.g., \Option{dvipsnames}) and a `starred' version (e.g., \Option{dvipsnames*}). 886% The first variant simply defines all the colors \emph{immediately}, whereas the second applies the mechanism of \emph{deferred} definition. 887% 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. 888% \begin{itemize} 889% \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. 890% \item \Option{svgnames}/\Option{svgnames*} loads a set of 151 \Model{rgb} color names\footnote{In fact, these names represent 141 different colors.} according to the \Index{SVG}~1.1 specification \cite{svg}\footnote{Actually, the cited specification lists only lowercase names, and the original definitions are given in \Model{RGB} parameters, converted to \Model{rgb} by the author.}, enhanced by~4 names taken from the file \File{rgb.txt} which is part of \Index{Unix}/\Index{X11} distributions. 891% \item \Option{x11names}/\Option{x11names*} loads a set of 317 \Model{rgb} color names\footnote{These names represent 315 different colors.} that are basically variations of a subset of the \Index{SVG} set mentioned before, according to the file \File{rgb.txt} which is part of \Index{Unix}/\Index{X11} distributions\footnote{Again, the original definitions are given in \Model{RGB} parameters, converted to \Model{rgb} by the author.}. 892% We describe now how to access all 752 color names of \File{rgb.txt} without much effort: 893% \begin{itemize} 894% \item Load \Option{x11namees} as well as \Option{svgnames}. 895% \item Capitalise initials and skip blanks: \Color[-]{DarkSlateGray} instead of \Color[-]{dark slate gray}. 896% \item \Index{X11} names without numbers are identical to the corresponding \Index{SVG} colors, except in 5~cases: 897% use \Color{Gray0}, \Color{Grey0}, \Color{Green0}, \Color{Maroon0}, \Color{Purple0} instead of \Color[-]{Gray}, \Color[-]{Grey}, \Color[-]{Green}, \Color[-]{Maroon}, \Color[-]{Purple} to obtain the original \Index{X11} colors. 898% \item For $N=0,1,\dots,100$ use `|[gray]{|$N/100$|}|' or `|black!|$100-N$' instead of \Color[-]{grayN} or \Color[-]{greyN}. 899% \end{itemize} 900% \end{itemize} 901% The color names and corresponding displays are listed in section \vref{sec.names}. 902% Section \vref{sec.clash} describes how to deal with name clashs while using both \Option{svgnames} and \Option{dvipsnames} in the same document. 903% See also \cite{chroma} for a systematic set of color and mix examples. 904% 905% 906% \subsection{Color definition}\label{sec.def} 907% 908% \subsubsection{Ordinary and named colors}\label{sec.prologue} 909% 910% 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). 911% 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. 912% 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. 913% 914% All drivers delivered with the standard \Package{graphics} package support the \emph{formalism} of defining and invoking `named colors'. 915% However, real support for the \emph{concept} behind that, i.e.~employing names instead of parameters, ranges from `none' to `complete'. 916% We demonstrate the current situation for three different drivers: 917% \begin{itemize} 918% \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. 919% However, additional names have to be made known to the \Index{PostScript} interpreter by some kind of header file. 920% 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}. 921% 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). 922% This file is as well loaded by \Program{dvips} as a prologue, thus making all color names available to the \Index{PostScript} interpreter. 923% 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. 924% Note that the \Index{PostScript} code is designed similar to \File{color.pro}: only \emph{new} names are defined. 925% This allows to preload other prologue files with color definitions that are not being destroyed by \XC. 926% On the other hand, it requires the user to take care about redefining color names.\\ 927% 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).\\ 928% It should be stressed that this mechanism is only employed by the \Option{prologue} option. 929% 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}. 930% \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. 931% \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). 932% \end{itemize} 933% 934% Typically, a \File{.dvi} viewer will have difficulties to display user-defined `named' colors. 935% For example, \Index{MiK\TeX}'s viewer \Program{Yap} currently displays only `named' colors from the \Option{dvipsnames} set. 936% Thus, whenever the \Option{prologue} option is invoked together with \Option{dvips}, \emph{all} other colors will appear black. 937% However, after employing \Program{dvips}, a \Index{PostScript} viewer should display the correct colors. 938% 939% 940% \subsubsection{Color definition in \XC} 941% 942% \DescribeMacro\definecolor 943% \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.}\\ 944% This is one of the commands that may be used to assign a \Meta{name} to a specific color. 945% 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}. 946% It replaces both \LC's |\DefineNamedColor| and |\definecolor|. 947% Note that an already existing color \Meta{name} will be overwritten. 948% The variable |\tracingcolors| controls whether such an overwriting will be logged or not (see section \vref{sec.info} for details). 949% The arguments are described in section \vref{sec.term}. 950% Hence, valid expressions for color definitions are 951% \begin{itemize} 952% \item |\definecolor{red}{rgb}{1,0,0}|, 953% \item |\definecolor{red}{rgb/cmyk}{1,0,0/0,1,1,0}|, 954% \item |\definecolor{red}{hsb:rgb/cmyk}{1,0,0/0,1,1,0}|, 955% \item |\definecolor[named]{Black}{cmyk}{0,0,0,1}|, 956% \item |\definecolor{myblack}{named}{Black}|, 957% \end{itemize} 958% where the last command is equivalent to |\colorlet{myblack}{Black}| (see below); the second command defines \Color{red} in the \Model{rgb} or \Model{cmyk} model, depending on the current setting of the \emph{target model}, whereas the third will additionally transform the color to \Model{hsb} prior to saving. 959% Note that there is a special \Package{pstricks} version as described in section \vref{sec.pstricks}. 960% 961% \medskip 962% 963% \DescribeMacro\providecolor 964% \oarg{type}\marg{name}\marg{model-list}\marg{spec-list}\\ 965% Similar to |\definecolor|, but the color \Meta{name} is only defined if it does not exist already. 966% 967% \medskip 968% 969% \DescribeMacro\colorlet 970% \oarg{type}\marg{name}\oarg{num model}\marg{color}\\ 971% Copies the actual color which results from \Meta{color} to \Meta{name}. 972% If \Meta{num model} is non-empty, \Meta{color} is first transformed to the specified model, before \Meta{name} is being defined. 973% The pseudo model \nModel{named} is \emph{not} allowed here, it may, however, be specified in the \Meta{type} argument. 974% Note that an already existing color \Meta{name} will be overwritten. 975% 976% Example: we said |\colorlet{tableheadcolor}{gray!25}| in the preamble of this document. 977% In most of the tables we then formatted the first row by using the command |\rowcolor{tableheadcolor}|. 978% 979% 980% \subsubsection{Defining sets of colors} 981% 982% \DescribeMacro\definecolorset 983% \oarg{type}\marg{model-list}\marg{head}\marg{tail}\marg{set spec}\\ 984% 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}. 985% 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). 986% Individual colors are being constructed by single 987% \begin{center} 988% |\definecolor|\oarg{type}|{|\Meta{head}\Meta[\lambda]{name}\Meta{tail}|}|\marg{model-list}|{|\Meta[\lambda]{spec-list}|}| 989% \end{center} 990% commands, $\lambda=1,\dots,l$. 991% For example, 992% \begin{itemize} 993% \item |\definecolorset{rgb}{}{}{red,1,0,0;green,0,1,0;blue,0,0,1}|\\ 994% 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):\\ 995% \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}}.} 996% \item |\definecolorset{rgb}{x}{10}{red,1,0,0;green,0,1,0;blue,0,0,1}|\\ 997% would define the colors \Color[-]{xred10}, \Color[-]{xgreen10}, and \Color[-]{xblue10}. 998% \end{itemize} 999% 1000% \DescribeMacro\providecolorset 1001% \oarg{type}\marg{model-list}\marg{head}\marg{tail}\marg{set spec}\\ 1002% Similar to |\definecolorset|, but based on |\providecolor|, thus the individual colors are defined only if they do not exist already. 1003% 1004% 1005% \subsubsection{Immediate and deferred definitions}\label{sec.deferred} 1006% 1007% 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. 1008% 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. 1009% 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. 1010% 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. 1011% This is the point where \emph{deferred color definition} comes into play. 1012% 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. 1013% 1014% 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. 1015% 1016% \medskip 1017% 1018% \DescribeMacro\preparecolor 1019% \oarg{type}\marg{name}\marg{model-list}\marg{spec-list}\\ 1020% 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. 1021% 1022% \medskip 1023% 1024% \DescribeMacro\preparecolorset 1025% \oarg{type}\marg{model-list}\marg{head}\marg{tail}\marg{set spec} 1026% \DescribeMacro\ifdefinecolors\\ 1027% 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. 1028% For example, the package option \Option{svgnames} performs something like |\definecolorstrue\preparecolorset|, whereas \Option{svgnames*} acts like |\definecolorsfalse\preparecolorset|. 1029% Both options set |\definecolorstrue| at the end, in order to have a proper starting point for other color sets. 1030% 1031% \medskip 1032% 1033% \DescribeMacro\DefineNamedColor 1034% \marg{type}\marg{name}\marg{model-list}\marg{spec-list} 1035% is provided mainly for compatibility reasons, especially to support the predefined colors in \File{dvipsnam.def}. 1036% 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|. 1037% Note that \LC's restriction to allow |\DefineNamedColor| only in the document preamble has been abolished in \XC. 1038% 1039% \medskip 1040% 1041% \DescribeMacro\definecolors 1042% \marg{id-list}\\ 1043% 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}. 1044% We consider the first case to be an abbreviation for \Meta[\lambda]{id}|=|\Meta[\lambda]{id} and describe the general case: 1045% 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. 1046% Thus, the user may control by which names the \emph{prepared} colors are to be used in the document. 1047% 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). 1048% 1049% \medskip 1050% 1051% \DescribeMacro\providecolors 1052% \marg{id-list}\\ 1053% Similar to |\definecolors|, but based on |\providecolor|, thus the individual colors are defined only if they do not exist already. 1054% 1055% 1056% \subsubsection{Global color definitions} 1057% 1058% \DescribeMacro\ifglobalcolors 1059% By default, definitions via |\definecolor|, |\providecolor|, \dots{} are available only within the current group. 1060% 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.} 1061% \DescribeMacro\xglobal 1062% 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}...|. 1063% 1064% 1065% 1066% \subsection{Color application} 1067% 1068% \subsubsection{Standard color commands} 1069% 1070% Here is the list of user-level color commands, as known from the \LCP, but with an extended syntax for the colors, allowing for expressions etc.:\\ 1071% \DescribeMacro\color\marg{color}\\ 1072% \oarg{model-list}\marg{spec-list}\\ 1073% Switches to the color given either by name/expression or by model/specification. 1074% This color will stay in effect until the end of the current \TeX\ group.\\ 1075% \DescribeMacro\textcolor\marg{color}\marg{text}\\ 1076% \oarg{model-list}\marg{spec-list}\marg{text}\\ 1077% are just alternative syntax for |\color|, in which the groups are added implicitly. 1078% Thus \meta{text} appears in the specified color, but then the color reverts to its previous value. 1079% Additionally, it calls |\leavevmode| to ensure the start of horizontal mode.\\ 1080% \DescribeMacro\pagecolor\marg{color}\\ 1081% \oarg{model-list}\marg{spec-list}\\ 1082% Specifies the background color for the current, and all following, pages. 1083% It is a global declaration which does not respect \TeX\ groups. 1084% 1085% 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. 1086% 1087% 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. 1088% 1089% 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). 1090% However, one can turn the expression into a name via |\colorlet| and try to use that name instead. 1091% 1092% 1093% \subsubsection{Colored boxes}\label{sec.fbox} 1094% 1095% \DescribeMacro\colorbox\marg{color}\marg{text}\\ 1096% \oarg{model-list}\marg{spec-list}\marg{text}\\ 1097% Takes the same argument forms as |\textcolor|, but the color specifies the \emph{background} color of the box.\\ 1098% \DescribeMacro\fcolorbox\marg{frame color}\marg{background color}\marg{text}\\ 1099% \oarg{model-list}\marg{frame spec-list}\marg{background spec-list}\marg{text}\\ 1100% \oarg{fr.~model-list}\marg{fr.~spec-list}\oarg{backgr.~model-list}\marg{backgr.~spec-list}\marg{text}\\ 1101% \marg{frame color}\oarg{background model-list}\marg{background spec-list}\marg{text}\\ 1102% Puts a frame of the first color around a box with a background specified by the second color. 1103% If only the first optional argument is given, it specifies the color model for both colors. 1104% Besides the possibility to specify color \emph{expressions} as arguments, |\fcolorbox| now offers more flexibility for its arguments than the \LC{} version: 1105% \begin{itemize} 1106% \item \fcolorbox{gray}{yellow}{test} |\fcolorbox{gray}{yellow}{test}|, 1107% \item \fcolorbox[cmyk]{0,0,0,0.5}{0,0,1,0}{test} |\fcolorbox[cmyk]{0,0,0,0.5}{0,0,1,0}{test}|, 1108% \item \fcolorbox[gray]{0.5}[wave]{580}{test} |\fcolorbox[gray]{0.5}[wave]{580}{test}|, 1109% \item \fcolorbox{gray}[wave]{580}{test} |\fcolorbox{gray}[wave]{580}{test}|. 1110% \end{itemize} 1111% Additionally, |\fcolorbox| uses a new approach to frame drawing, which is an extension of \People{Donald}{Arseneau}'s suggestion in bug report latex/3655 \cite{fbox}. 1112% The main difference to \LaTeX's implementation is that box construction and frame drawing are split into separate operations, such that the frame is drawn \emph{after} the box contents has been constructed. 1113% This ensures that the frame is always on top of the box. 1114% \People{Donald}{Arseneau} improved speed as well as memory requirements of this approach. 1115% Furthermore, a new macro is introduced: 1116% 1117% \DescribeMacro\boxframe\marg{width}\marg{height}\marg{depth}\\ 1118% Draws a frame with a linewidth of |\fboxrule|. 1119% Returns a |\hbox| with outer dimensions \meta{width}, \meta{height}, \meta{depth}. 1120% By this approach, a frame-primitive may also be provided by a driver file, in order to exploit driver-specific drawing facilities (see below). 1121% Again, this macro was optimised by \People{Donald}{Arseneau}. 1122% 1123% The new frame approach is used for |\fcolorbox| as well as \LaTeX's |\fbox| and |\framebox| commands, unless the \Option{kernelfbox} option is specified, which returns to \LaTeX's original definitions of |\f(rame)box|. 1124% 1125% Option \Option{xcdraw} uses \Index{PostScript} commands to draw frames and color boxes in case of the \Option{dvips} driver and \Index{PDF} code to draw frames in case of the \Option{pdftex} and \Option{dvipdfm} drivers. 1126% This is still experimental code that may confuse \File{.dvi} viewers. 1127% The opposite option \Option{noxcdraw} forces usage of the generic (driver-independent) code. 1128% 1129% 1130% \subsubsection{Using the current color} 1131% 1132% Within a color expression, `.' serves as a placeholder for the current color. 1133% See figure \vref{fig.cc} for an example. 1134% 1135% It is also possible to save the current color for later use, e.g., via the command |\colorlet{foo}{.}|. 1136% 1137% 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. 1138% 1139% 1140% \subsubsection{Color testing} 1141% 1142% \DescribeEnv{testcolors} 1143% \oarg{num models}\\ 1144% 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. 1145% 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 1146% {\makeatletter\ttfamily\let\@protected@testopt\@gobbletwo\edef\tmp{\testcolors}\expandafter\@firstofone\tmp}. 1147% 1148% \DescribeMacro\testcolor 1149% \marg{color}\\ 1150% \oarg{model-list}\marg{spec-list}\\ 1151% Each |\testcolor| command generates a table row, containing a display sample plus the respective parameters for each of the models. 1152% If the column-model matches the model of the color in question, its parameters are underlined. 1153% Note that this command is only available within the |testcolors| environment. 1154% 1155% For applications see figure \vref{fig.testcolors} and figures \ref{fig.tHsb}, \ref{fig.harmony}. 1156% 1157% 1158% 1159% \subsection{Color blending} 1160% 1161% The purpose of \emph{color blending} is to add some mixing color (expression) to all subsequent explicit color commands. 1162% Thus, it is possible to perform such a mix (or blend) operation for many colors without touching the individual commands. 1163% 1164% \medskip 1165% 1166% \DescribeMacro\blendcolors 1167% \marg{mix expr}\\ 1168% \DescribeMacro{\blendcolors*} 1169% \marg{mix expr}\\ 1170% Initialises all necessary parameters for color blending. 1171% The actual (completed) color blend expression is stored in |\colorblend|. 1172% In the starred version, the argument will be appended to a previously defined blend expression. 1173% An empty \Meta{mix expr} argument will switch blending off. 1174% 1175% 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}}. 1176% \DescribeMacro\xglobal 1177% In order to achieve global scope, |\blendcolors| may be prefixed by |\xglobal|. 1178% 1179% Remark: color blending is applied only to \emph{explicit} color commands, i.e.~|\color|, |\fcolorbox| and the like. 1180% 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'). 1181% Thus, to influence these \emph{implicit} colors as well, we have to set the current color \emph{after} the blending: 1182% |\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}}. 1183% 1184% 1185% 1186% \subsection{Color masks and separation} 1187% 1188% 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. 1189% 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. 1190% 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. 1191% We describe now another --- and more general --- solution: \emph{color masking}. 1192% How does it work? 1193% Color masking is based on a specified color model \Meta{m-model} and a parameter vector \Meta{m-spec}. 1194% 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}. 1195% For example, let's assume that \Meta{m-model} equals |cmyk|, and \Meta{m-spec} equals $(\mu_c,\mu_m,\mu_y,\mu_k)$. 1196% Then an arbitrary color \Color{foo} will be transformed according to 1197% \begin{gather} 1198% \Color{foo} \mapsto (c,m,y,k) \mapsto (\mu_c\cdot c,\mu_m\cdot m,\mu_y\cdot y,\mu_k\cdot k) 1199% \end{gather} 1200% Obviously, color separation is a special case of masking by the vectors $(1,0,0,0)$, $(0,1,0,0)$, etc. 1201% 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}. 1202% 1203% \medskip 1204% 1205% \DescribeMacro\maskcolors 1206% \oarg{num model}\marg{color}\\ 1207% Initialises all necessary parameters for color masking: 1208% 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}; 1209% the color specification of \Meta{color} is extracted to define \Meta{m-spec}. 1210% Additionally, |\maskcolorstrue| is performed. 1211% \DescribeMacro\ifmaskcolors 1212% Color masking can be switched off temporarily by |\maskcolorsfalse|, or --- in a more radical way --- by |\maskcolors{}|, which in addition clears the initialisation parameters. 1213% \DescribeMacro\xglobal 1214% 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. 1215% The final remark of the color blending section applies here similarly. 1216% 1217% Now it is easy to separate a complete document without touching the source code: 1218% |latex| |\def\xcolorcmd{\maskcolors[cmyk]{cyan}}\input{a}| will do the \Color{cyan} part of the job for |a.tex|. 1219% 1220% \DescribeMacro\colormask 1221% 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}. 1222% Such files have to be separated separately. 1223% 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: 1224% \begin{verbatim} 1225% \def\temp{cyan}\ifx\colormask\temp \includegraphics{foo_c}\else 1226% \def\temp{magenta}\ifx\colormask\temp \includegraphics{foo_m}\else 1227% ... 1228% \fi\fi 1229% \end{verbatim} 1230% 1231% 1232% 1233% \subsection{Color series}\label{sec.series} 1234% 1235% 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. 1236% 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. 1237% 1238% The practical application consists of three parts: 1239% 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). 1240% 1241% 1242% \subsubsection{Definition of a color series} 1243% 1244% \DescribeMacro\definecolorseries 1245% \marg{name}\marg{core model}\marg{method}\oarg{b-model}\marg{b-spec}\oarg{s-model}\marg{s-spec}\\ 1246% 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). 1247% The method details are determined by the remaining arguments: 1248% \begin{itemize} 1249% \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. 1250% \item \oarg{s-model}\marg{s-spec} specifies how the \emph{step} vector is calculated in the algorithm, according to the chosen \Meta{method}: 1251% \begin{itemize} 1252% \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|. 1253% \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. 1254% \end{itemize} 1255% \end{itemize} 1256% This is the general scheme: 1257% \begin{gather} 1258% \emph{color}_1 := \emph{base},\qquad 1259% \emph{color}_{n+1} := U\bigl(\emph{color}_{n} + \emph{step}\bigr) 1260% \end{gather} 1261% for $n=1,2,\dots$, where $U$ maps arbitrary real $m$-vectors into the unit $m$-cube: 1262% \begin{gather} 1263% U(x_1,\dots,x_m) = (u(x_1),\dots,u(x_m)),\qquad 1264% u(x) = 1265% \begin{cases} 1266% 1 & \text{if $x=1$}\\ 1267% x-[x]& \text{if $x\neq1$}\\ 1268% \end{cases}\label{eq.U} 1269% \end{gather} 1270% Thus, every step of the algorithm yields a valid color with parameters from the interval $[0,1]$. 1271% 1272% \medskip 1273% Now, the different methods use different schemes to calculate the \emph{step} vector: 1274% \begin{itemize} 1275% \item |step|,\ |grad|:\ the last argument, \marg{s-spec}, defines the directional vector \emph{grad}. 1276% \item |last|:\ \marg{s-spec} resp.\ \oarg{s-model}\marg{s-spec} defines the color parameter vector \emph{last}. 1277% \end{itemize} 1278% Then, during |\resetcolorseries|, the actual \emph{step} vector is calculated: 1279% \begin{gather} 1280% \emph{step} := 1281% \begin{cases} 1282% \emph{grad} & \text{if $\Meta{method} = |step|$}\\ 1283% \frac1{\Meta{div}}\cdot\emph{grad} & \text{if $\Meta{method} = |grad|$}\\ 1284% \frac1{\Meta{div}}\cdot(\emph{last}-\emph{base}) & \text{if $\Meta{method} = |last|$}\\ 1285% \end{cases}\label{eq.cs} 1286% \end{gather} 1287% Please note that it is also possible to use the current color placeholder `.' within the definition of color series. 1288% Thus, |\definecolorseries{foo}{rgb}{last}{.}{-.}| will set up a series that starts with the current color and ends with its complement. 1289% 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. 1290% 1291% 1292% \subsubsection{Initialisation of a color series} 1293% 1294% \DescribeMacro\resetcolorseries 1295% \oarg{div}\marg{name}\\ 1296% This command has to be applied at least once, in order to make use of the color series \Meta{name}. 1297% 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}). 1298% \DescribeMacro\colorseriescycle 1299% If the optional argument is empty, the value stored in the macro |\colorseriescycle| is applied. 1300% 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). 1301% The optional argument is ignored in case of the |step| method. 1302% 1303% 1304% \subsubsection{Application of a color series} 1305% 1306% There are two ways to display the current color of a color series: 1307% 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. 1308% 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. 1309% Thus, the current color of the series will be changed in that case. 1310% 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. 1311% See figure \vref{fig.csx} for a demonstration of different methods. 1312% 1313% 1314% \subsubsection{Differences between colors and color series} 1315% 1316% 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: 1317% 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). 1318% E.g., if we assume that |bar| is an undefined color, then after saying 1319% \begin{verbatim} 1320% \begingroup 1321% \definecolorseries{foo}{rgb}{last}{red}{blue} 1322% \resetcolorseries[10]{foo} 1323% \definecolor{bar}{rgb}{.6,.5,.4} 1324% \endgroup 1325% \end{verbatim} 1326% commands like |\color{foo}| or |\color{foo!!+}| may be used without restrictions, whereas |\color{bar}| will give an error message. 1327% 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. 1328% 1329% 1330% 1331% 1332% \subsection{Border colors for hyperlinks}\label{sec.hyperref} 1333% 1334% The \Package{hyperref} package offers all kinds of support for hyperlinks, pdfmarks etc. 1335% 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): 1336% \begin{itemize} 1337% \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}|; 1338% \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}}|. 1339% \end{itemize} 1340% Obviously, the second method is somewhat inconvenient since it does not allow for color names or even color expressions. 1341% 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}|. 1342% 1343% Another new key, \Key{xpdfborder}, provides a way to deal with a \Program{dvips}-related problem: 1344% 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. 1345% 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. 1346% 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. 1347% Consequently, any default value for \Key{pdfborder} may be useful or not. 1348% 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|. 1349% 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. 1350% 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. 1351% Thus one can say |xpdfborder={0 0 1}| in a driver-independent way. 1352% 1353% 1354% 1355% \subsection{Additional color specification in the \Package{pstricks} world}\label{sec.pstricks} 1356% 1357% For \Package{pstricks} users, there are different ways of invoking colors within command option keys: 1358% \begin{itemize} 1359% \item |\psset{linecolor=green!50}| 1360% \item |\psset{linecolor=[rgb]{0.5,1,0.5}}| 1361% \item |\psframebox[linecolor={[rgb]{0.5,1,0.5}}]{foo}| 1362% \end{itemize} 1363% Note the additional curly braces in the last case; without them, the optional argument of |\psframebox| would be terminated too early. 1364% 1365% \DescribeMacro\definecolor 1366% |[ps]|\marg{name}\marg{core model-list}\marg{code}\\ 1367% Stores \Index{PostScript} \Meta{code} --- that should not contain slash~`|/|' characters --- within a color. 1368% Example: 1369% 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. 1370% See also \href{xcolor2.pdf}{\File{xcolor2.tex}} for an illustrative application. 1371% 1372% 1373% 1374% \subsection{Color in tables} 1375% 1376% \DescribeMacro\rowcolors 1377% \oarg{commands}\marg{row}\marg{odd-row color}\marg{even-row color}\\ 1378% \DescribeMacro{\rowcolors*} 1379% \oarg{commands}\marg{row}\marg{odd-row color}\marg{even-row color}\\ 1380% One of these commands has to be executed \emph{before} a table starts. 1381% \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. 1382% Each of the color arguments may also be left empty (= no color). 1383% 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. 1384% Such optional commands may be |\hline| or |\noalign|\marg{stuff}. 1385% 1386% \DescribeMacro\showrowcolors 1387% \DescribeMacro\hiderowcolors 1388% 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|. 1389% \DescribeMacro\rownum 1390% The counter |\rownum| may be used within such a table to access the current row number. 1391% An example is given in figure \vref{fig.row}. 1392% These commands require the \Option{table} option (which loads the \Package{colortbl} package). 1393% 1394% Note that table coloring may be combined with color series. 1395% This method was used to construct the examples in figure \vref{fig.csx}. 1396% 1397% 1398% 1399% \subsection{Color information}\label{sec.info} 1400% 1401% \DescribeMacro\extractcolorspec 1402% \marg{color}\marg{cmd}\\ 1403% Extracts the color specification of \Meta{color} and puts it into \Meta{cmd}; equivalent to |\def\cmd{|\marg{model}\marg{spec}|}|. 1404% 1405% \DescribeMacro\extractcolorspecs 1406% \marg{color}\marg{model-cmd}\marg{color-cmd}\\ 1407% Extracts the color specification of \Meta{color} and puts it into \Meta{model-cmd} and \Meta{color-cmd}, respectively. 1408% 1409% \medskip 1410% \DescribeMacro\tracingcolors 1411% |=|\Meta{int}\\ 1412% Controls the amount of information that is written into the |log| file: 1413% \begin{itemize} 1414% \item \mbox{$\Meta{int}\le0$:}~no specific color logging. 1415% \item \mbox{$\Meta{int}\ge1$:}~ignored color definitions due to |\providecolor| are logged. 1416% \item \mbox{$\Meta{int}\ge2$:}~multiple (i.e.~overwritten) color definitions are logged. 1417% \item \mbox{$\Meta{int}\ge3$:}~every command that defines a color will be logged. 1418% \item \mbox{$\Meta{int}\ge4$:}~every command that sets a color will be logged. 1419% \end{itemize} 1420% Like \TeX's |\tracing...| commands, this command may be used globally (in the document preamble) or locally/block-wise. 1421% The package sets |\tracingcolors=0| as default. 1422% Remark: since registers are limited and valuable, no counter is wasted for this issue. 1423% 1424% 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{}.} 1425% 1426% 1427% 1428% \subsection{Color conversion} 1429% 1430% \DescribeMacro\convertcolorspec 1431% \marg{model}\marg{spec}\marg{target model}\marg{cmd}\\ 1432% Converts a color, given by the \Meta{spec} in model \Meta{model}, into \Meta{target model} and stores the new color specification in |\cmd|. 1433% \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. 1434% 1435% Example: |\convertcolorspec{cmyk}{0.81,1,0,0.07}{HTML}\tmp| acts like |\def| |\tmp{1F00ED}|. 1436% 1437% 1438% 1439% \subsection{Problems and solutions} 1440% 1441% \subsubsection{Name clashs between \Option{dvipsnames} and \Option{svgnames}}\label{sec.clash} 1442% 1443% Due to the fixed option processing order (which does not depend on the order how the options were specified in the |\usepackage| command), the \Option{svgnames} colors will always overrule \Option{dvipsnames} colors with identical names. 1444% This can lead to undesired results if both options are used together. 1445% For instance, \Color{Fuchsia} yields \testclr[cmyk]{0.47,0.91,0,0.08} under the regime of \Option{dvipsnames} and \testclr[rgb]{1,0,1} with respect to \Option{svgnames}. 1446% However, there is a simple trick --- based on \emph{deferred color definition} --- that allows us to use colors from both sets in the desired way: 1447% \begin{verbatim} 1448% \usepackage[dvipsnames*,svgnames]{xcolor} 1449% \definecolors{Fuchsia} 1450% \end{verbatim} 1451% Now all colors from the \Index{SVG} set are available (except \Color{Fuchsia}) plus \Color{Fuchsia} from the other set. 1452% 1453% \subsubsection{Page breaks and pdf\TeX}\label{sec.fixpdftex} 1454% 1455% 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: 1456% \begin{verbatim} 1457% \documentclass{minimal} 1458% \usepackage{xcolor} 1459% \begin{document} 1460% black\color{red}red1\newpage red2\color{black}black 1461% \end{document} 1462% \end{verbatim} 1463% This works as expected with |dvips|, i.e., `red1' and `red2' being \Color{red}, however, with |pdftex|, `red2' is displayed in \Color{black}. 1464% The problem may be solved by using the \Option{fixpdftex} option which simply loads Heiko Oberdiek's \Package{pdfcolmk} package \cite{pdfcolmk}. 1465% However, its author also lists some limitations: 1466% \begin{itemize} 1467% \item Mark limitations: page breaks in math. 1468% \item LaTeX's output routine is redefinded. 1469% \begin{itemize} 1470% \item Changes in the output routine of newer versions of LaTeX are not detected. 1471% \item Packages that change the output routine are not supported. 1472% \end{itemize} 1473% \item It does not support several independent text streams like footnotes. 1474% \end{itemize} 1475% 1476% 1477% 1478% 1479% \clearpage 1480% \begin{adjustwidth}{-2.5cm}{} 1481% \section{Examples} 1482% 1483% 1484% \begin{figure}[htbp]\caption{Color spectrum}\label{fig.spectrum} 1485% \small 1486% \newcount\WL \unitlength.75pt 1487% \begin{picture}(460,60)(355,-10) 1488% \sffamily \tiny \linethickness{1.25\unitlength} \WL=360 1489% \multiput(360,0)(1,0){456}% 1490% {{\color[wave]{\the\WL}\line(0,1){50}}\global\advance\WL1} 1491% \linethickness{0.25\unitlength}\WL=360 1492% \multiput(360,0)(20,0){23}% 1493% {\picture(0,0) 1494% \line(0,-1){5} \multiput(5,0)(5,0){3}{\line(0,-1){2.5}} 1495% \put(0,-10){\makebox(0,0){\the\WL}}\global\advance\WL20 1496% \endpicture} 1497% \end{picture} 1498% \vspace*{3ex} 1499% \begin{verbatim} 1500% \newcount\WL \unitlength.75pt 1501% \begin{picture}(460,60)(355,-10) 1502% \sffamily \tiny \linethickness{1.25\unitlength} \WL=360 1503% \multiput(360,0)(1,0){456}% 1504% {{\color[wave]{\the\WL}\line(0,1){50}}\global\advance\WL1} 1505% \linethickness{0.25\unitlength}\WL=360 1506% \multiput(360,0)(20,0){23}% 1507% {\picture(0,0) 1508% \line(0,-1){5} \multiput(5,0)(5,0){3}{\line(0,-1){2.5}} 1509% \put(0,-10){\makebox(0,0){\the\WL}}\global\advance\WL20 1510% \endpicture} 1511% \end{picture} 1512% \end{verbatim} 1513% \end{figure} 1514% 1515% 1516% \begin{figure}[htbp]\caption{Color testing}\label{fig.testcolors} 1517% \small 1518% \begin{adjustwidth}{-2.5cm}{} 1519% \raggedleft 1520% \sffamily 1521% \begin{testcolors}[rgb,cmyk,hsb,HTML,gray] 1522% \testcolor{olive} 1523% \testcolor{red!50!green} 1524% \testcolor{-cyan!50!magenta} 1525% \testcolor[cmyk]{0,0,1,0.5} 1526% \testcolor[cmyk]{0,0,.5,.5} 1527% \testcolor[rgb:cmyk]{0,0,.5,.5} 1528% \end{testcolors} 1529% \end{adjustwidth} 1530% \vspace*{3ex} 1531% \begin{adjustwidth}{2.5cm}{} 1532% \begin{verbatim} 1533% \sffamily 1534% \begin{testcolors}[rgb,cmyk,hsb,HTML,gray] 1535% \testcolor{olive} 1536% \testcolor{red!50!green} 1537% \testcolor{-cyan!50!magenta} 1538% \testcolor[cmyk]{0,0,1,0.5} 1539% \testcolor[cmyk]{0,0,.5,.5} 1540% \testcolor[rgb:cmyk]{0,0,.5,.5} 1541% \end{testcolors} 1542% \end{verbatim} 1543% \end{adjustwidth} 1544% \end{figure} 1545% 1546% 1547% \def\ukColor{MyGreen} 1548% \definecolor{\ukColor}{cmyk}{0.92,0,0.87,0.09} 1549% \colorlet{\ukColor-rgb}[rgb]{\ukColor} 1550% \colorlet{\ukColor-cmy}[cmy]{\ukColor} 1551% \colorlet{\ukColor-hsb}[hsb]{\ukColor} 1552% \colorlet{\ukColor-gray}[gray]{\ukColor} 1553% 1554% \begin{figure}[htbp]\caption{Progressing from one to another color}\label{fig.progress} 1555% \small 1556% \begin{adjustwidth}{-2.5cm}{} 1557% \makeatletter 1558% \def\ColorLoop#1#2{\@tfor\@@tmp:={}{-rgb}{-cmy}{-hsb}{-gray}\do 1559% {\ifcase#1 1560% \expandafter\Colorloop\expandafter{\expandafter\ukColor\@@tmp}{#2}\or 1561% \expandafter\Colorshow\expandafter{\expandafter\ukColor\@@tmp}\fi}\\[-2ex]\ignorespaces} 1562% \def\Colorloop#1#2{\@ifxempty{#1}{}{\texttt{#1!}}& 1563% \count@105 \@whilenum\count@>\z@\do 1564% {\advance\count@-5 1565% \@ifxempty{#1}{\hb@xt@\XCdim{\hss\textsf{\the\count@}\hss}}{\testclr{#1!\the\count@!#2}}\hskip-\fboxrule}\hskip\fboxrule& 1566% \@ifxempty{#1}{}{\texttt{!#2}}\\} 1567% \def\Colorshow#1{\texttt{#1}& 1568% \multicolumn2{l@{}}{\expandafter\let\expandafter\@@tmp\csname\string\color@#1\endcsname 1569% \edef\@@tmp{\expandafter\@gobbletwo\@@tmp}\Meaning{@@tmp}}\\} 1570% \makeatother 1571% \sbox0{\testclr{red}}\XCdim\wd0 1572% \begin{tabular}{@{}lll@{}} 1573% \Colorloop{}{}\\[-2ex] 1574% \ColorLoop0{white} 1575% \ColorLoop0{gray} 1576% \ColorLoop0{black} 1577% \ColorLoop0{red} 1578% \ColorLoop0{blue} 1579% \ColorLoop0{yellow} 1580% \\\noalign{\vspace*{-2.5ex}}\hline\noalign{\vspace*{1.5ex}} 1581% \itshape Color&\itshape Definition/representation (\textup{\Option{\csname XC@@drv\endcsname}} driver)\\ 1582% \ColorLoop1{} 1583% \end{tabular} 1584% \end{adjustwidth} 1585% \end{figure} 1586% 1587% 1588% \begin{figure}[htbp]\caption{Target color model}\label{fig.tgt} 1589% \small 1590% \begin{adjustwidth}{-2.5cm}{} 1591% \raggedleft 1592% \extrarowheight2pt 1593% \makeatletter 1594% \def\X#1% 1595% {\def\tmp{{#1}}\dots\Meaning{tmp}& 1596% \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}\\} 1597% \makeatother 1598% \begin{tabular}{@{}>{\ttfamily}l@{ }l@{}} 1599% \string\selectcolormodel&\\ 1600% \X{natural} 1601% \X{rgb} 1602% \X{cmy} 1603% \X{cmyk} 1604% \X{hsb} 1605% \X{gray} 1606% \end{tabular} 1607% \end{adjustwidth} 1608% \end{figure} 1609% 1610% 1611% \begin{figure}[htbp]\caption{Standard color expressions}\label{fig.expr} 1612% \centering\small 1613% \def\test#1{\testclr{#1}& \texttt{#1}} 1614% \def\X#1{\test{#1}& \test{-#1}} 1615% \begin{tabular}{@{}l@{ \ }ll@{ \ }l@{}} 1616% \X{red}\\ 1617% \X{red!75}\\ 1618% \X{red!75!green}\\ 1619% \X{red!75!green!50}\\ 1620% \X{red!75!green!50!blue}\\ 1621% \X{red!75!green!50!blue!25}\\ 1622% \X{red!75!green!50!blue!25!gray}\\ 1623% \end{tabular} 1624% \end{figure} 1625% 1626% 1627% \begin{figure}[htbp]\caption{Standard color expressions}\label{fig.ex} 1628% \begin{minipage}{\textwidth}\small 1629% \begin{verbatim} 1630% \fboxrule6pt 1631% \fcolorbox 1632% {red!70!green}% outer frame 1633% {yellow!30!blue}% outer background 1634% {\fcolorbox 1635% {-yellow!30!blue}% inner frame 1636% {-red!70!green}% inner background 1637% {Test\textcolor{red!72.75}{Test}\color{-green}Test}} 1638% \end{verbatim} 1639% \end{minipage}\relax 1640% \llap{\fboxrule6pt \fcolorbox 1641% {red!70!green}{yellow!30!blue}{\fcolorbox 1642% {-yellow!30!blue}{-red!70!green}{Test\textcolor{red!72.75}{Test}\color{-green}Test}}} 1643% \end{figure} 1644% 1645% 1646% \begin{figure}[htbp]\caption{Current color}\label{fig.cc} 1647% \begin{minipage}{\textwidth}\small 1648% \begin{verbatim} 1649% \def\test{current, \textcolor{.!50}{50\%}, 1650% \textcolor{-.}{complement}, 1651% \textcolor{yellow!50!.}{mix}} 1652% \textcolor{blue}{\test}\\ 1653% and \textcolor{red}{\test}\\ 1654% \def\Test{\color{.!80}Test} 1655% \textcolor{blue}{\Test\Test\Test\Test\Test}\\ 1656% and \textcolor{red}{\Test\Test\Test\Test\Test} 1657% \end{verbatim} 1658% \end{minipage}\relax 1659% \llap{\begin{minipage}{.5\textwidth}\small\raggedleft 1660% \def\test{current, \textcolor{.!50}{50\%}, 1661% \textcolor{-.}{complement}, 1662% \textcolor{yellow!50!.}{mix}} 1663% \textcolor{blue}{\test}\\ 1664% and \textcolor{red}{\test}\\ 1665% \def\Test{\color{.!80}Test} 1666% \textcolor{blue}{\Test\Test\Test\Test\Test}\\ 1667% and \textcolor{red}{\Test\Test\Test\Test\Test} 1668% \end{minipage}} 1669% \end{figure} 1670% 1671% 1672% \begin{figure}[htbp]\caption{Color series}\label{fig.csx} 1673% \centering 1674% \def\tabulartest#1{\definecolorseries{test}#1\resetcolorseries[12]{test}% 1675% \rowcolors[\hline]{1}{test!!+}{test!!+}% 1676% \begin{tabular}{c} 1677% \number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\ 1678% \number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\ 1679% \number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\ 1680% \number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\ 1681% \end{tabular}} 1682% 1683% \begin{tabular}{@{}*{9}{c}@{}} 1684% $S_1$ & $S_2$ & $G_1$ & $G_2$ & $L_1$ & $L_2$ & $L_3$ & $L_4$ & $L_5$ \\[3pt] 1685% \tabulartest{{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}}& 1686% \tabulartest{{hsb}{step}[hsb]{.575,1,1}{.11,-.05,0}}& 1687% \tabulartest{{rgb}{grad}[rgb]{.95,.85,.55}{3,11,17}}& 1688% \tabulartest{{hsb}{grad}[hsb]{.575,1,1}{.987,-.234,0}}& 1689% \tabulartest{{rgb}{last}[rgb]{.95,.85,.55}[rgb]{.05,.15,.55}}& 1690% \tabulartest{{hsb}{last}[hsb]{.575,1,1}[hsb]{-.425,.15,1}}& 1691% \tabulartest{{rgb}{last}{yellow!50}{blue}}& 1692% \tabulartest{{hsb}{last}{yellow!50}{blue}}& 1693% \tabulartest{{cmy}{last}{yellow!50}{blue}}\\ 1694% \end{tabular} 1695% 1696% \bigskip 1697% 1698% \footnotesize 1699% \rowcolors{3}{tablerowcolor}{} 1700% \begin{tabular}{>{$}l<{$}l} 1701% \hline 1702% \multicolumn2{>{\columncolor{tableheadcolor}}c}{\em Individual definitions}\\ 1703% S_1& |\definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}|\\ 1704% S_2& |\definecolorseries{test}{hsb}{step}[hsb]{.575,1,1}{.11,-.05,0}|\\ 1705% G_1& |\definecolorseries{test}{rgb}{grad}[rgb]{.95,.85,.55}{3,11,17}|\\ 1706% G_2& |\definecolorseries{test}{hsb}{grad}[hsb]{.575,1,1}{.987,-.234,0}|\\ 1707% L_1& |\definecolorseries{test}{rgb}{last}[rgb]{.95,.85,.55}[rgb]{.05,.15,.55}|\\ 1708% L_2& |\definecolorseries{test}{hsb}{last}[hsb]{.575,1,1}[hsb]{-.425,.15,1}|\\ 1709% L_3& |\definecolorseries{test}{rgb}{last}{yellow!50}{blue}|\\ 1710% L_4& |\definecolorseries{test}{hsb}{last}{yellow!50}{blue}|\\ 1711% L_5& |\definecolorseries{test}{cmy}{last}{yellow!50}{blue}|\\ 1712% \hline 1713% \multicolumn2{>{\columncolor{tableheadcolor}}c}{\em Common definitions}\\ 1714% \hiderowcolors 1715% &|\resetcolorseries[12]{test}|\\ 1716% &|\rowcolors[\hline]{1}{test!!+}{test!!+}|\\ 1717% &|\begin{tabular}{c}|\\ 1718% &|\number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\|\\ 1719% &|\number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\|\\ 1720% &|\number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\|\\ 1721% &|\number\rownum\\ \number\rownum\\ \number\rownum\\ \number\rownum\\|\\ 1722% &|\end{tabular}|\\ 1723% \hline 1724% \end{tabular} 1725% \end{figure} 1726% 1727% 1728% \begin{figure}[htbp]\caption{Color masking}\label{fig.mask} 1729% \begin{adjustwidth}{-2.5cm}{} 1730% \small\raggedleft 1731% \extrarowheight2pt 1732% \makeatletter 1733% \def\X#1#2{\edef\tmp{\@ifxempty{#1}{}{[#1]}{#2}}\dots\Meaning{tmp}& 1734% \maskcolors[#1]{#2}\testclr{red} \testclr{green} \testclr{blue} \testclr{cyan} \testclr{magenta} 1735% \testclr{yellow} \testclr{orange} \testclr{violet} \testclr{purple} \testclr{brown} \testclr{pink} 1736% \testclr{olive} \testclr{black} \testclr{darkgray} \testclr{gray} \testclr{lightgray} \testclr{white}\\}\relax 1737% \makeatother 1738% \begin{tabular}{@{}>{\ttfamily}l@{ }l@{}} 1739% \string\maskcolors&\\ 1740% \hline 1741% \X{}{} 1742% \hline 1743% \X{cmyk}{cyan} 1744% \X{cmyk}{magenta} 1745% \X{cmyk}{yellow} 1746% \X{cmyk}{black} 1747% \hline 1748% \X{cmyk}{red} 1749% \X{cmyk}{green} 1750% \X{cmyk}{blue} 1751% \hline 1752% \X{rgb}{red} 1753% \X{rgb}{green} 1754% \X{rgb}{blue} 1755% \hline 1756% \X{hsb}{red} 1757% \X{hsb}{green} 1758% \X{hsb}{blue} 1759% \hline 1760% \X{rgb}{gray} 1761% \X{cmy}{gray} 1762% \end{tabular} 1763% \end{adjustwidth} 1764% \end{figure} 1765% 1766% 1767% \begin{figure}[htbp]\caption{Alternating row colors in tables: \cmd\rowcolors{} vs. \cmd\rowcolors\texttt*}\label{fig.row} 1768% \centering 1769% \begin{minipage}{\textwidth} 1770% \begin{verbatim} 1771% \rowcolors[\hline]{3}{green!25}{yellow!50} \arrayrulecolor{red!75!gray} 1772% \begin{tabular}{ll} 1773% test & row \number\rownum\\ 1774% test & row \number\rownum\\ 1775% test & row \number\rownum\\ 1776% test & row \number\rownum\\ 1777% \arrayrulecolor{black} 1778% test & row \number\rownum\\ 1779% test & row \number\rownum\\ 1780% \rowcolor{blue!25} 1781% test & row \number\rownum\\ 1782% test & row \number\rownum\\ 1783% \hiderowcolors 1784% test & row \number\rownum\\ 1785% test & row \number\rownum\\ 1786% \showrowcolors 1787% test & row \number\rownum\\ 1788% test & row \number\rownum\\ 1789% \multicolumn{1}% 1790% {>{\columncolor{red!12}}l}{test} & row \number\rownum\\ 1791% \end{tabular} 1792% \end{verbatim} 1793% \end{minipage} 1794% \hskip-.5\textwidth 1795% \rowcolors[\hline]{3}{green!25}{yellow!50} \arrayrulecolor{red!75!gray} 1796% \begin{tabular}{ll} 1797% test & row \number\rownum\\ 1798% test & row \number\rownum\\ 1799% test & row \number\rownum\\ 1800% test & row \number\rownum\\ 1801% \arrayrulecolor{black} 1802% test & row \number\rownum\\ 1803% test & row \number\rownum\\ 1804% \rowcolor{blue!25} 1805% test & row \number\rownum\\ 1806% test & row \number\rownum\\ 1807% \hiderowcolors 1808% test & row \number\rownum\\ 1809% test & row \number\rownum\\ 1810% \showrowcolors 1811% test & row \number\rownum\\ 1812% test & row \number\rownum\\ 1813% \multicolumn{1}% 1814% {>{\columncolor{red!12}}l}{test} & row \number\rownum\\ 1815% \end{tabular} 1816% \qquad 1817% \rowcolors*[\hline]{3}{green!25}{yellow!50}\arrayrulecolor{red!75!gray} 1818% \begin{tabular}{ll} 1819% test & row \number\rownum\\ 1820% test & row \number\rownum\\ 1821% test & row \number\rownum\\ 1822% test & row \number\rownum\\ 1823% \arrayrulecolor{black} 1824% test & row \number\rownum\\ 1825% test & row \number\rownum\\ 1826% \rowcolor{blue!25} 1827% test & row \number\rownum\\ 1828% test & row \number\rownum\\ 1829% \hiderowcolors 1830% test & row \number\rownum\\ 1831% test & row \number\rownum\\ 1832% \showrowcolors 1833% test & row \number\rownum\\ 1834% test & row \number\rownum\\ 1835% \multicolumn{1}% 1836% {>{\columncolor{red!12}}l}{test} & row \number\rownum\\ 1837% \end{tabular} 1838% \arrayrulecolor{black} 1839% \end{figure} 1840% 1841% 1842% \begin{figure}[htbp]\caption{\Model{Hsb} and \Model{tHsb}: \emph{hue\Circ} in $15^\circ$ steps}\label{fig.tHsb} 1843% \begin{adjustwidth}{-2.5cm}{} 1844% \footnotesize\sffamily\raggedleft 1845% \extrarowheight.5pt 1846% \begin{testcolors}[rgb,cmyk,hsb,Hsb,tHsb] 1847% \testcolor[Hsb]{0,1,1} 1848% \testcolor[Hsb]{15,1,1} 1849% \testcolor[Hsb]{30,1,1} 1850% \testcolor[Hsb]{45,1,1} 1851% \testcolor[Hsb]{60,1,1} 1852% \testcolor[Hsb]{75,1,1} 1853% \testcolor[Hsb]{90,1,1} 1854% \testcolor[Hsb]{105,1,1} 1855% \testcolor[Hsb]{120,1,1} 1856% \testcolor[Hsb]{135,1,1} 1857% \testcolor[Hsb]{150,1,1} 1858% \testcolor[Hsb]{165,1,1} 1859% \testcolor[Hsb]{180,1,1} 1860% \testcolor[Hsb]{195,1,1} 1861% \testcolor[Hsb]{210,1,1} 1862% \testcolor[Hsb]{225,1,1} 1863% \testcolor[Hsb]{240,1,1} 1864% \testcolor[Hsb]{255,1,1} 1865% \testcolor[Hsb]{270,1,1} 1866% \testcolor[Hsb]{285,1,1} 1867% \testcolor[Hsb]{300,1,1} 1868% \testcolor[Hsb]{315,1,1} 1869% \testcolor[Hsb]{330,1,1} 1870% \testcolor[Hsb]{345,1,1} 1871% \testcolor[Hsb]{360,1,1} 1872% \noalign{\medskip} 1873% \testcolor[tHsb]{0,1,1} 1874% \testcolor[tHsb]{15,1,1} 1875% \testcolor[tHsb]{30,1,1} 1876% \testcolor[tHsb]{45,1,1} 1877% \testcolor[tHsb]{60,1,1} 1878% \testcolor[tHsb]{75,1,1} 1879% \testcolor[tHsb]{90,1,1} 1880% \testcolor[tHsb]{105,1,1} 1881% \testcolor[tHsb]{120,1,1} 1882% \testcolor[tHsb]{135,1,1} 1883% \testcolor[tHsb]{150,1,1} 1884% \testcolor[tHsb]{165,1,1} 1885% \testcolor[tHsb]{180,1,1} 1886% \testcolor[tHsb]{195,1,1} 1887% \testcolor[tHsb]{210,1,1} 1888% \testcolor[tHsb]{225,1,1} 1889% \testcolor[tHsb]{240,1,1} 1890% \testcolor[tHsb]{255,1,1} 1891% \testcolor[tHsb]{270,1,1} 1892% \testcolor[tHsb]{285,1,1} 1893% \testcolor[tHsb]{300,1,1} 1894% \testcolor[tHsb]{315,1,1} 1895% \testcolor[tHsb]{330,1,1} 1896% \testcolor[tHsb]{345,1,1} 1897% \testcolor[tHsb]{360,1,1} 1898% \end{testcolors} 1899% \end{adjustwidth} 1900% \end{figure} 1901% 1902% 1903% \begin{figure}[htbp]\caption{Color harmony}\label{fig.harmony} 1904% \begin{adjustwidth}{-2.5cm}{} 1905% \small\sffamily\raggedleft 1906% \extrarowheight1.5pt 1907% \begin{testcolors}[rgb,cmyk,Hsb,tHsb] 1908% \noalign{\smallskip} 1909% \rlap{\em complementary colors (two-color harmony):}\\ 1910% \testcolor{yellow>wheel,1,2} 1911% \testcolor{yellow} 1912% \testcolor{yellow>twheel,1,2} 1913% \noalign{\medskip} 1914% \rlap{\em color triad (three-color harmony):}\\ 1915% \testcolor{yellow>wheel,2,3} 1916% \testcolor{yellow>wheel,1,3} 1917% \testcolor{yellow} 1918% \testcolor{yellow>twheel,1,3} 1919% \testcolor{yellow>twheel,2,3} 1920% \noalign{\medskip} 1921% \rlap{\em color tetrad (four-color harmony):}\\ 1922% \testcolor{yellow>wheel,3,4} 1923% \testcolor{yellow>wheel,2,4} 1924% \testcolor{yellow>wheel,1,4} 1925% \testcolor{yellow} 1926% \testcolor{yellow>twheel,1,4} 1927% \testcolor{yellow>twheel,2,4} 1928% \testcolor{yellow>twheel,3,4} 1929% \noalign{\medskip} 1930% \rlap{\em split complementary colors:}\\ 1931% \testcolor{yellow>wheel,7,12} 1932% \testcolor{yellow>wheel,5,12} 1933% \testcolor{yellow} 1934% \testcolor{yellow>twheel,5,12} 1935% \testcolor{yellow>twheel,7,12} 1936% \noalign{\medskip} 1937% \rlap{\em analogous (adjacent) colors:}\\ 1938% \testcolor{yellow>wheel,11,12} 1939% \testcolor{yellow>wheel,10,12} 1940% \testcolor{yellow>wheel,2,12} 1941% \testcolor{yellow>wheel,1,12} 1942% \testcolor{yellow} 1943% \testcolor{yellow>twheel,1,12} 1944% \testcolor{yellow>twheel,2,12} 1945% \testcolor{yellow>twheel,10,12} 1946% \testcolor{yellow>twheel,11,12} 1947% \end{testcolors} 1948% \end{adjustwidth} 1949% \end{figure} 1950% 1951% \end{adjustwidth} 1952% 1953% 1954% \clearpage 1955% 1956% \begin{adjustwidth}{-2.5cm}{} 1957% \raggedcolumns\columnsep2.5em 1958% 1959% \section{Colors by Name}\label{sec.names} 1960% 1961% \begin{multicols}{5}[\subsection{Base Colors}\label{sec.basenam}] 1962% \footnotesize\def\0#1{\Testclr{#1}{#1}} 1963% \0{black} 1964% \0{blue} 1965% \0{brown} 1966% \0{cyan} 1967% \0{darkgray} 1968% \0{gray} 1969% \0{green} 1970% \0{lightgray} 1971% \0{magenta} 1972% \0{olive} 1973% \0{orange} 1974% \0{pink} 1975% \0{purple} 1976% \0{red} 1977% \0{violet} 1978% \0{white} 1979% \0{yellow} 1980% \end{multicols} 1981% 1982% 1983% \begin{multicols}{5}[\subsection{Colors via \Option{dvipsnames}}\label{sec.dvipsnam}] 1984% \footnotesize\def\0#1{\Testclr{#1}{#1}} 1985% \0{Apricot} 1986% \0{Aquamarine} 1987% \0{Bittersweet} 1988% \0{Black} 1989% \0{Blue} 1990% \0{BlueGreen} 1991% \0{BlueViolet} 1992% \0{BrickRed} 1993% \0{Brown} 1994% \0{BurntOrange} 1995% \0{CadetBlue} 1996% \0{CarnationPink} 1997% \0{Cerulean} 1998% \0{CornflowerBlue} 1999% \0{Cyan} 2000% \0{Dandelion} 2001% \0{DarkOrchid} 2002% \0{Emerald} 2003% \0{ForestGreen} 2004% \0{Fuchsia} 2005% \0{Goldenrod} 2006% \0{Gray} 2007% \0{Green} 2008% \0{GreenYellow} 2009% \0{JungleGreen} 2010% \0{Lavender} 2011% \0{LimeGreen} 2012% \0{Magenta} 2013% \0{Mahogany} 2014% \0{Maroon} 2015% \0{Melon} 2016% \0{MidnightBlue} 2017% \0{Mulberry} 2018% \0{NavyBlue} 2019% \0{OliveGreen} 2020% \0{Orange} 2021% \0{OrangeRed} 2022% \0{Orchid} 2023% \0{Peach} 2024% \0{Periwinkle} 2025% \0{PineGreen} 2026% \0{Plum} 2027% \0{ProcessBlue} 2028% \0{Purple} 2029% \0{RawSienna} 2030% \0{Red} 2031% \0{RedOrange} 2032% \0{RedViolet} 2033% \0{Rhodamine} 2034% \0{RoyalBlue} 2035% \0{RoyalPurple} 2036% \0{RubineRed} 2037% \0{Salmon} 2038% \0{SeaGreen} 2039% \0{Sepia} 2040% \0{SkyBlue} 2041% \0{SpringGreen} 2042% \0{Tan} 2043% \0{TealBlue} 2044% \0{Thistle} 2045% \0{Turquoise} 2046% \0{Violet} 2047% \0{VioletRed} 2048% \0{White} 2049% \0{WildStrawberry} 2050% \0{Yellow} 2051% \0{YellowGreen} 2052% \0{YellowOrange} 2053% \end{multicols} 2054% 2055% 2056% \makeatletter 2057% \def\ColorList#1#2#3#4{\begin{multicols}{#1}[\subsection{Colors via \Option{#2names}}\label{sec.#2nam}] 2058% \footnotesize 2059% \def\preparecolorset 2060% {\def\XC@@cmd[####1]####2####3####4{\definecolor[####1]{@test}{####3}{####4}#4{@test}{####2}}\@testopt{\XC@definecolorset}{}} 2061% \edef\restore{\catcode`\noexpand\%\the\catcode`\%\relax} 2062% \catcode`\%14\relax\input{#3nam.def}\restore 2063% \end{multicols}} 2064% \makeatother 2065% 2066% \ColorList4{svg}{svg}\Testclr 2067% \medskip 2068% \begin{adjustwidth}{1cm}{1cm} 2069% \footnotesize\raggedright Duplicate colors: 2070% \Color[-]{Aqua} = \Color[-]{Cyan}, 2071% \Color[-]{Fuchsia} = \Color[-]{Magenta}; 2072% \Color[-]{Navy} = \Color[-]{NavyBlue}; 2073% \Color[-]{Gray} = \Color[-]{Grey}, 2074% \Color[-]{DarkGray} = \Color[-]{DarkGrey}, 2075% \Color[-]{LightGray} = \Color[-]{LightGrey}, 2076% \Color[-]{SlateGray} = \Color[-]{SlateGrey}, 2077% \Color[-]{DarkSlateGray} = \Color[-]{DarkSlateGrey}, 2078% \Color[-]{LightSlateGray} = \Color[-]{LightSlateGrey}, 2079% \Color[-]{DimGray} = \Color[-]{DimGrey}. 2080% \par 2081% Colors taken from \Index{Unix}/\Index{X11}: 2082% \Color[-]{LightGoldenrod}, 2083% \Color[-]{LightSlateBlue}, 2084% \Color[-]{NavyBlue}, 2085% \Color[-]{VioletRed}. 2086% \end{adjustwidth} 2087% 2088% \ColorList4{x11}{x11}\Testclr 2089% \medskip 2090% \begin{adjustwidth}{1cm}{1cm} 2091% \footnotesize\raggedright Duplicate colors: 2092% \Color[-]{Gray0} = \Color[-]{Grey0}, 2093% \Color[-]{Green0} = \Color[-]{Green1}. 2094% \end{adjustwidth} 2095% 2096% \end{adjustwidth} 2097% 2098% 2099% 2100% 2101% \clearpage 2102% \section{Technical Supplement} 2103% 2104% \subsection{Color models supported by drivers} 2105% 2106% Since some of the drivers only pretend to support the \Model{hsb} model, we included some code to bypass this behaviour. 2107% The models actually added by \XC{} are shown in the log file. 2108% Table \vref{tab.drv} lists mainly the drivers that are part of current MiK\TeX{} \cite{mik} distributions and their color model support. 2109% Probably, other distributions behave similarly. 2110% 2111% \begin{table}[htbp]\caption{Drivers and color models}\label{tab.drv} 2112% \centering\small 2113% \extrarowheight1pt 2114% \tabcolsep3pt 2115% \rowcolors{3}{tablerowcolor}{} 2116% \begin{tabular}{ll*{9}{c}} 2117% \rowcolor{tableheadcolor} 2118% \hline 2119% \em Driver&\em Version&\Model{rgb}&\Model{cmy}&\Model{cmyk}&\Model{hsb}&\Model{gray}&\Model{RGB}&\Model{HTML}&\Model{HSB}&\Model{Gray}\\ 2120% \Option{dvipdf}&1999/02/16 v3.0i&d&n&d&n&d&i&n&n&n\\ 2121% \Option{dvips}&1999/02/16 v3.0i&d&n&d&d&d&i&n&n&n\\ 2122% \Option{dvipsone}&1999/02/16 v3.0i&d&n&d&d&d&i&n&n&n\\ 2123% \Option{pctex32}&1999/02/16 v3.0i&d&n&d&d&d&i&n&n&n\\ 2124% \Option{pctexps}&1999/02/16 v3.0i&d&n&d&d&d&i&n&n&n\\ 2125% \hline 2126% \Option{pdftex}&2002/06/19 v0.03k&d&n&d&n&d&i&n&n&n\\ 2127% \hline 2128% \Option{dvipdfm}&1998/11/24 vx.x\,\footnotemark[1]&d&n&d&a&d&i&n&n&n\\ 2129% \Option{dvipdfm}&1999/9/6 vx.x\,\footnotemark[2]&d&n&d&a&d&i&n&n&n\\ 2130% \hline 2131% \Option{dvipdfmx}&?&d&n&d&f&d&i&n&n&n\\ 2132% \hline 2133% \Option{textures}&1997/5/28 v0.3&d&n&d&a&i&n&n&n&n\\ 2134% \hline 2135% \Option{vtex}&1999/01/14 v6.3&d&n&d&n&i&i&n&n&n\\ 2136% \hline 2137% \Option{xetex}&2004/05/09 v0.7&i&n&i&i&i&i&d&n&n\\ 2138% \hline 2139% \Option{tcidvi}&1999/02/16 v3.0i&i&n&i&n&i&d&n&n&n\\ 2140% \Option{truetex}&1999/02/16 v3.0i&i&n&i&n&i&d&n&n&n\\ 2141% \hline 2142% \Option{dviwin}&1999/02/16 v3.0i&n&n&n&n&n&n&n&n&n\\ 2143% \Option{emtex}&1999/02/16 v3.0i&n&n&n&n&n&n&n&n&n\\ 2144% \Option{pctexhp}&1999/02/16 v3.0i&n&n&n&n&n&n&n&n&n\\ 2145% \Option{pctexwin}&1999/02/16 v3.0i&n&n&n&n&n&n&n&n&n\\ 2146% \hline\hline 2147% \multicolumn{11}c{\Option{dviwindo} = \Option{dvipsone}; \Option{oztex} = \Option{dvips}; \Option{xdvi} = \Option{dvips} + \Option{monochrome}}\\ 2148% \multicolumn{11}c{\footnotemark[1]\,part of \Package{graphics} package\quad \footnotemark[2]\,additionally distributed with MiK\TeX}\\ 2149% \hline 2150% \multicolumn{11}c{Driver's color model support: d\,=\,direct, i\,=\,indirect, a\,=\,alleged, n\,=\,none, f\,=\,faulty}\\ 2151% \hline 2152% \end{tabular} 2153% \end{table} 2154% 2155% 2156% 2157% \subsection{How \XC{} handles driver-specific color models} 2158% 2159% 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. 2160% 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}. 2161% Therefore, \XC{} in general detects driver-support for the `foo' model via the existence of |\color@foo|. 2162% 2163% By this mechanism, \XC{} can also change the behaviour of certain models without touching the driver file itself. 2164% 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}). 2165% 2166% 2167% \subsection{Behind the scenes: internal color representation} 2168% 2169% 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. 2170% 2171% \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). 2172% 2173% \LC's |\DefineNamedColor{named}{foo}{...}{...}| generates |\col@foo|\footnote{The single backslash is intentional.} which again contains some driver-dependent information. 2174% In this case, an additional |\\color@foo| will only be defined if the package option \Option{usecolors} is active. 2175% 2176% \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. 2177% Although it has now a different syntax, |\\color@foo| expands to the same expression as the original command. 2178% 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). 2179% 2180% Table \vref{tab.internal} shows some examples for the two most prominent drivers. 2181% See also figure \vref{fig.progress} which displays the definitions with respect to the driver that was used to process this document. 2182% 2183% 2184% \begin{table}[htb]\caption{Driver-dependent internal color representation}\label{tab.internal} 2185% \centering\small 2186% \def\X{\hspace*{-.845\textwidth}\\} 2187% \extrarowheight1pt 2188% \tabcolsep8pt 2189% \begin{tabular}{l>{\color{blue}(}r<{)}l} 2190% \hline 2191% \multicolumn3{>{\columncolor{tableheadcolor}}l}{\Option{dvips} driver}\\ 2192% \hline 2193% |\\color@Plum=macro:| & |\definecolor{Plum}{rgb}{.5,0,1}| & \LC\\ 2194% |->rgb .5 0 1.|\X 2195% \hline 2196% |\\color@Plum=macro:| & |\definecolor{Plum}{rgb}{.5,0,1}|& \XC\\ 2197% |->\xcolor@ {}{rgb 0.5 0 1}{rgb}{0.5,0,1}.|\X 2198% \hline 2199% |\col@Plum=macro:| & |\DefineNamedColor{Plum}{rgb}{.5,0,1}|& \LC\\ 2200% |->\@nil .|\X 2201% |\\color@Plum=macro:| & with option \Option{usenames}\\ 2202% |-> Plum.|\X 2203% \hline 2204% |\\color@Plum=macro:| & |\definecolor[named]{Plum}{rgb}{.5,0,1}|& \XC\\ 2205% |->\xcolor@ {named}{ Plum}{rgb}{0.5,0,1}.|\X 2206% \hline 2207% \multicolumn3{>{\columncolor{tableheadcolor}}l}{\Option{pdftex} driver}\\ 2208% \hline 2209% |\\color@Plum=macro:| & |\definecolor{Plum}{rgb}{.5,0,1}|& \LC\\ 2210% |->.5 0 1 rg .5 0 1 RG.|\X 2211% \hline 2212% |\\color@Plum=macro:| & |\definecolor{Plum}{rgb}{.5,0,1}|& \XC\\ 2213% |->\xcolor@ {}{0.5 0 1 rg 0.5 0 1 RG}{rgb}{0.5,0,1}.|\X 2214% \hline 2215% |\col@Plum=macro:| & |\DefineNamedColor{Plum}{rgb}{.5,0,1}|& \LC\\ 2216% |->.5 0 1 rg .5 0 1 RG.|\X 2217% |\\color@Plum=macro:| & with option \Option{usenames}\\ 2218% |->.5 0 1 rg .5 0 1 RG.|\X 2219% \hline 2220% |\\color@Plum=macro:| & |\definecolor[named]{Plum}{rgb}{.5,0,1}|& \XC\\ 2221% |->\xcolor@ {}{0.5 0 1 rg 0.5 0 1 RG}{rgb}{0.5,0,1}.|\X 2222% \hline 2223% \end{tabular} 2224% \end{table} 2225% 2226% 2227% 2228% \subsection{A remark on accuracy} 2229% 2230% 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} 2231% 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}. 2232% The marginal contribution of the latter packages seems not to justify their usage for our purposes. 2233% Thus, we stay within a sort of fixed-point arithmetic framework, providing at most 5~decimal digits via \TeX's dimension registers. 2234% 2235% 2236% 2237% 2238% \clearpage 2239% \section{The Formulas} 2240% 2241% \subsection{Color mixing} 2242% 2243% In general, we use linear interpolation for color mixing: 2244% \begin{align} 2245% \mix(C, C', p) = p \cdot C + (1-p) \cdot C'\label{eq.mix} 2246% \end{align} 2247% Note that there is a special situation in the \Model{hsb} case: 2248% if $\emph{saturation}=0$ then the color equals a gray color of level \emph{brightness}, independently of the \emph{hue} value. 2249% Therefore, to achieve smooth transitions of an arbitrary color to a specific gray (like white or black), we actually use the formulas 2250% \begin{align} 2251% \Op\tint{hsb}(C, p) &= p \cdot C + (1-p) \cdot \bigl(\emph{hue},0,1\bigr)\\ 2252% \Op\shade{hsb}(C, p) &= p \cdot C + (1-p) \cdot \bigl(\emph{hue},0,0\bigr)\\ 2253% \Op\tone{hsb}(C, p) &\textstyle= p \cdot C + (1-p) \cdot \bigl(\emph{hue},0,\frac12\bigr) 2254% \end{align} 2255% where $C=(\emph{hue},\emph{saturation},\emph{brightness})$. 2256% 2257% 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 2258% \begin{gather} 2259% C_0!P_1!C_1!P_2!\dots!P_n!C_n 2260% \end{gather} 2261% 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 2262% \begin{equation} 2263% \begin{split} 2264% C &= \sum_{\nu=0}^n \Biggl(\prod_{\mu=\nu+1}^n p_\mu \Biggr) (1-p_\nu)\cdot C_\nu\\ 2265% &= p_n\cdots p_1\cdot C_0\\ 2266% &\quad + p_n\cdots p_2(1-p_1)\cdot C_1\\ 2267% &\quad + p_n\cdots p_3(1-p_2)\cdot C_2\\ 2268% &\quad + \dots\\ 2269% &\quad + p_n(1-p_{n-1})\cdot C_{n-1}\\ 2270% &\quad + (1-p_n)\cdot C_n 2271% \end{split} 2272% \end{equation} 2273% where $p_0 := 0$ and $p_\nu := P_\nu/100$ for $\nu=1,\dots,n$. 2274% We note also a split formula: 2275% \begin{equation} 2276% \begin{split} 2277% C_0!P_1!C_1!\dots!P_{n+k}!C_{n+k} 2278% &= p_{n+k}\cdots p_{n+1}\cdot C_0!P_1!C_1!\dots!P_n!C_n\\ 2279% &\quad - p_{n+k}\cdots p_{n+1}\cdot C_n\\ 2280% &\quad + C_n!P_{n+1}!C_{n+1}!\dots!P_{n+k}!C_{n+k} 2281% \end{split} 2282% \end{equation} 2283% 2284% 2285% \begin{table}[p]\caption{Color constants}\label{tab.const} 2286% \centering 2287% \extrarowheight2pt 2288% \rowcolors{3}{tablerowcolor}{} 2289% \begin{tabular}{*4{c}} 2290% \hline 2291% \rowcolor{tableheadcolor} 2292% \emph{model/constant} & 2293% \ttfamily white & \ttfamily black & \ttfamily gray\\[2pt] 2294% \Model{rgb}& $(1,1,1)$ & $(0,0,0)$ & $(\frac12,\frac12,\frac12)$ \\[2pt] 2295% \Model{cmy}& $(0,0,0)$ & $(1,1,1)$ & $(\frac12,\frac12,\frac12)$ \\[2pt] 2296% \Model{cmyk}& $(0,0,0,0)$ & $(0,0,0,1)$ & $(0,0,0,\frac12)$ \\[2pt] 2297% \Model{hsb}& $(h,0,1)$ & $(h,0,0)$ & $(h,0,\frac12)$ \\[2pt] 2298% \Model{Hsb}& $(h^\circ,0,1)$ & $(h^\circ,0,0)$ & $(h^\circ,0,\frac12)$ \\[2pt] 2299% \Model{tHsb}& $(h^\circ,0,1)$ & $(h^\circ,0,0)$ & $(h^\circ,0,\frac12)$ \\[2pt] 2300% \Model{gray}& $1$ & $0$ & $\frac12$ \\[2pt] 2301% \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] 2302% \Model{HTML}& \texttt{FFFFFF}& \texttt{000000}& \texttt{808080}\\[2pt] 2303% \Model{HSB}& $(H,0,M)$ & $(H,0,0)$ & $(H,0,\lfloor\frac {M+1}2\rfloor)$ \\[2pt] 2304% \Model{Gray}& $N$ & $0$ & $\lfloor\frac {N+1}2\rfloor$ \\[2pt] 2305% \hline 2306% \end{tabular} 2307% \end{table} 2308% 2309% 2310% \begin{table}[p]\caption{Color conversion pairs}\label{tab.cnv} 2311% \begin{adjustwidth}{-2.5cm}{} 2312% \small\raggedleft 2313% \def\Em#1{\Model{#1}} 2314% \def\sp{\hbox to3em{\hfil$\ast$\hfil}} 2315% \def\id{\textrm{id}} 2316% \extrarowheight1pt 2317% \tabcolsep3pt 2318% \rowcolors{3}{tablerowcolor}{} 2319% \begin{tabular}{c*{11}{>{\sffamily}c}} 2320% \rowcolor{tableheadcolor} 2321% \hline 2322% \emph{from/to}& 2323% \Em{rgb}& \Em{cmy}& \Em{cmyk}& \Em{hsb}& \Em{Hsb} & \Em{tHsb} & \Em{gray}& \Em{RGB}& \Em{HTML}& \Em{HSB}& \Em{Gray}\\ 2324% \Em{rgb}& \id & \sp & (cmy) & \sp & (hsb) & (hsb) & \sp & \sp & \sp & (hsb) & (gray)\\ 2325% \Em{cmy}& \sp & \id & \sp & (rgb) & (rgb) & (rgb) & \sp & (rgb) & (rgb) & (rgb) & (gray)\\ 2326% \Em{cmyk}& (cmy) & \sp & \id & (cmy) & (cmy) & (cmy) & \sp & (cmy) & (cmy) & (cmy) & (gray)\\ 2327% \Em{hsb}& \sp & (rgb) & (rgb) & \id & \sp & (Hsb) & (rgb) & (rgb) & (rgb) & \sp & (rgb)\\ 2328% \Em{Hsb}& (hsb) & (hsb) & (hsb) & \sp & \id & \sp & (hsb) & (hsb) & (hsb) & (hsb) & (hsb)\\ 2329% \Em{tHsb}& (Hsb) & (Hsb) & (Hsb) & (Hsb) & \sp & \id & (Hsb) & (Hsb) & (Hsb) & (Hsb) & (Hsb)\\ 2330% \Em{gray}& \sp & \sp & \sp & \sp & \sp & \sp & \id & \sp & \sp & \sp & \sp\\ 2331% \Em{RGB}& \sp & (rgb) & (rgb) & (rgb) & (rgb) & (rgb) & (rgb) & \id & (rgb) & (rgb) & (rgb)\\ 2332% \Em{HTML}& \sp & (rgb) & (rgb) & (rgb) & (rgb) & (rgb) & (rgb) & (rgb) & \id & (rgb) & (rgb)\\ 2333% \Em{HSB}& (hsb) & (hsb) & (hsb) & \sp & (hsb) & (hsb) & (hsb) & (hsb) & (hsb) & \id & (hsb)\\ 2334% \Em{Gray}& (gray) & (gray) & (gray) & (gray) & (gray) & (gray) & \sp & (gray) & (gray) & (gray) & \id\\ 2335% \Em{wave}& (hsb) & (hsb) & (hsb) & \sp & (hsb) & (hsb) & (hsb) & (hsb) & (hsb) & (hsb) & (hsb)\\ 2336% \hline\hline 2337% \multicolumn{12}{c}{\id{} = identity function; $\ast$ = specific conversion function;}\\ 2338% \multicolumn{12}{c}{\textsf{(model)} = conversion via specified model}\\ 2339% \hline 2340% \end{tabular} 2341% \end{adjustwidth} 2342% \end{table} 2343% 2344% 2345% 2346% \subsection{Conversion between integer and real models} 2347% 2348% We fix a positive integer $n$ and define the sets $\mathcal I_n:=\{0,1,\dots,n\}$ and $\mathcal R:= [0,1]$. 2349% The complement of $\nu\in\mathcal I_n$ is $n-\nu$, the complement of $x\in\mathcal R$ is $1-x$. 2350% 2351% \subsubsection{Real to integer conversion}\label{sec.real2int} 2352% 2353% The straightforward mapping for this case is 2354% \begin{gather} 2355% \textstyle\RtoI n : \mathcal R \to \mathcal I_n,\ x \mapsto \rd(n\cdot x,0) = \left\lfloor \frac12+n\cdot x\right\rfloor 2356% \end{gather} 2357% where $\rd(r,d)$ rounds the real number $r$ to $d\ge0$ decimal digits. 2358% This mapping nearly always preserves complements, as shown in the next lemma. 2359% \begin{lemma}[Preservation of complements] 2360% For $x\in\mathcal R$, 2361% \begin{gather} 2362% \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\}. 2363% \end{gather} 2364% \end{lemma} 2365% \begin{proof} 2366% Let $\nu:=\RtoI n(x)$, then from $-\frac12 \le \eta := n\cdot x - \nu < \frac12$ we conclude 2367% \begin{gather*} 2368% \textstyle \RtoI n(1-x) = \rd(n(1-x),0) = \rd(n-\nu-\eta,0) = 2369% \begin{cases} 2370% n-\nu & \text{if $\eta\neq-\frac12$}\\ 2371% n-\nu+1 & \text{if $\eta=-\frac12$} 2372% \end{cases} 2373% \end{gather*} 2374% Now, $\eta = -\frac12 \iff x = \frac1n\bigl(\nu-\frac12\bigr) \iff x\in\mathcal I_n'$. 2375% \end{proof} 2376% Remark: the set $\mathcal R_n^\circ$ is obviously identical to the set of points where $\RtoI n$ is not continuous. 2377% 2378% 2379% \subsubsection{Integer to real conversion}\label{sec.int2real} 2380% 2381% The straightforward way in this case is the function 2382% \begin{gather} 2383% \ItoR n^*: \mathcal I_n \to \mathcal R,\ \nu \mapsto \frac \nu n. 2384% \end{gather} 2385% 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 2386% \begin{gather} 2387% \nu\in\mathcal I_n \Rightarrow \Gamma_n\bigl(\ItoR n(\nu)\bigr) = \nu 2388% \end{gather} 2389% which is equivalent to 2390% \begin{gather} 2391% \nu\in\mathcal I_n \Rightarrow \nu + \frac12 > n\cdot\ItoR n(\nu) \ge \nu - \frac12\label{eq.round} 2392% \end{gather} 2393% 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. 2394% Preservation of complements means now 2395% \begin{gather} 2396% \nu\in\mathcal I_n \Rightarrow \ItoR n(\nu) + \ItoR n(n-\nu) = 1 2397% \end{gather} 2398% which is obviously the case for $\ItoR n = \ItoR n^*$. 2399% If we consider, more generally, a transformation 2400% \begin{gather} 2401% \ItoR n(\nu) = \frac{\nu + \alpha}{n + \beta} 2402% \end{gather} 2403% with $\beta\neq-n$, then the magic inequality (\ref{eq.round}) is equivalent to 2404% \begin{gather} 2405% \frac12 > \frac{\alpha n - \beta\nu}{n + \beta} \ge -\frac12 2406% \end{gather} 2407% which is obeyed by the function 2408% \begin{gather} 2409% \ItoR n':\mathcal I_n\to\mathcal R,\ \nu \mapsto 2410% \begin{cases} 2411% \frac\nu{n+1}& \text{if $\nu\le\frac{n+1}2$}\\[0.25ex] 2412% \frac{\nu+1}{n+1}& \text{if $\nu>\frac{n+1}2$} 2413% \end{cases} 2414% \end{gather} 2415% that has the nice feature $\ItoR n'\bigl(\frac{n+1}2\bigr) = \frac12$ for odd $n$. 2416% \begin{lemma}[Preservation of complements] 2417% For odd $n$ and each $\nu\in\mathcal I_n$, 2418% \begin{gather} 2419% \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\}. 2420% \end{gather} 2421% \end{lemma} 2422% \begin{proof} 2423% The assertion is a consequence of the following arguments: 2424% \begin{itemize} 2425% \item $\nu<\frac{n-1}2 \iff n-\nu>\frac{n+1}2$ \ and \ $\frac{n-1}2 + \frac{n+1}2 = n$; 2426% \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$; 2427% \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 2428% \end{itemize} 2429% \end{proof} 2430% 2431% For the time being, we choose \fbox{$\ItoR n := \ItoR n^*$} as default transformation function. 2432% 2433% \medskip 2434% Another variant --- which is probably too slow for large-scale on-the-fly calculations --- may be used for constructing sets of predefined colors. 2435% The basic idea is to minimize the number of decimal digits in the representation while keeping some invariance with respect to the original resolution: 2436% \begin{gather} 2437% \textstyle\ItoR n'':\mathcal I_n\to\mathcal R,\ \nu \mapsto \rd\bigl(\frac\nu n, d_n(\frac\nu n)\bigr) 2438% \end{gather} 2439% where 2440% \begin{gather} 2441% 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\} 2442% \end{gather} 2443% 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\}$. 2444% 2445% 2446% 2447% \subsection{Color conversion and complements}\label{sec.cnv} 2448% 2449% We collect here the specific conversion formulas between the supported color models. 2450% Table \vref{tab.cnv} gives an overwiew of how each conversion pair is handled. 2451% 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. 2452% Furthermore, \People{Alvy Ray}{Smith}'s paper \cite{smith} is cited in \cite{plrm} as reference for \Model{hsb}-related formulas. 2453% 2454% First, we define a constant which is being used throughout the conversion formulas: 2455% \begin{gather} 2456% E := (1,1,1) 2457% \end{gather} 2458% 2459% 2460% \subsubsection{The \Model{rgb} model} 2461% 2462% \paragraph{Conversion \Model{rgb} to \Model{cmy}}\label{sec.rgb2cmy} 2463% Source: \cite{plrm}, p. 475. 2464% \begin{gather} 2465% (\emph{cyan}, \emph{magenta}, \emph{yellow}) := E-(\emph{red}, \emph{green}, \emph{blue}) 2466% \end{gather} 2467% 2468% 2469% \paragraph{Conversion \Model{rgb} to \Model{hsb} (1)} 2470% We set 2471% \begin{align} 2472% x & := \max\{\emph{red}, \emph{green}, \emph{blue}\}\\ 2473% y & := \med\{\emph{red}, \emph{green}, \emph{blue}\}\\ 2474% z & := \min\{\emph{red}, \emph{green}, \emph{blue}\}%\\ 2475% \end{align} 2476% where `$\med$' denotes the median of the values. 2477% Then, 2478% \begin{align} 2479% \emph{brightness} & := x\\ 2480% \intertext{Case $x=z$:} 2481% \emph{saturation} & := 0\\ 2482% \emph{hue} & := 0\\ 2483% \intertext{Case $x\neq z$:} 2484% \emph{saturation} & := \frac{x - z}x\\ 2485% f & := \frac{x - y}{x - z} 2486% \end{align} 2487% \begin{gather} 2488% \emph{hue} := \frac 16\cdot 2489% \begin{cases} 2490% 1-f & \text{if $x=\emph{red}\ge\emph{green}\ge\emph{blue}=z$}\\ 2491% 1+f & \text{if $x=\emph{green}\ge\emph{red}\ge\emph{blue}=z$}\\ 2492% 3-f & \text{if $x=\emph{green}\ge\emph{blue}\ge\emph{red}=z$}\\ 2493% 3+f & \text{if $x=\emph{blue}\ge\emph{green}\ge\emph{red}=z$}\\ 2494% 5-f & \text{if $x=\emph{blue}\ge\emph{red}\ge\emph{green}=z$}\\ 2495% 5+f & \text{if $x=\emph{red}\ge\emph{blue}>\emph{green}=z$} 2496% \end{cases}\label{eq.rgb2hsb1} 2497% \end{gather} 2498% 2499% \medskip 2500% 2501% This is based on \cite{smith}, \emph{RGB to HSV Algorithm (Hexcone Model)}, which reads (slightly reformulated): 2502% \begin{gather} 2503% r := \frac{x - \emph{red}}{x - z},\qquad 2504% g := \frac{x - \emph{green}}{x - z},\qquad 2505% b := \frac{x - \emph{blue}}{x - z}\\ 2506% \emph{hue} := \frac 16\cdot 2507% \begin{cases} 2508% 5+b & \text{if $\emph{red}=x$ and $\emph{green}=z$}\\ 2509% 1-g & \text{if $\emph{red}=x$ and $\emph{green}>z$}\\ 2510% 1+r & \text{if $\emph{green}=x$ and $\emph{blue}=z$}\\ 2511% 3-b & \text{if $\emph{green}=x$ and $\emph{blue}>z$}\\ 2512% 3+g & \text{if $\emph{blue}=x$ and $\emph{red}=z$}\\ 2513% 5-r & \text{if $\emph{blue}=x$ and $\emph{red}>z$} 2514% \end{cases} 2515% \end{gather} 2516% 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. 2517% 2518% Because we need to sort three numbers in order to calculate $x,y,z$, several comparisons are involved in the algorithm. 2519% We present now a second method which is more suited for \TeX. 2520% 2521% 2522% \paragraph{Conversion \Model{rgb} to \Model{hsb} (2)} 2523% Let $\beta$ be a function that takes a Boolean expression as argument and returns 1 if the expression is true, 0 otherwise; set 2524% \begin{gather} 2525% i := 4\cdot\beta(\emph{red}\ge\emph{green}) + 2\cdot\beta(\emph{green}\ge\emph{blue}) + \beta(\emph{blue}\ge\emph{red}), 2526% \intertext{and} 2527% (\emph{hue},\emph{saturation},\emph{brightness}) := 2528% \begin{cases} 2529% \Phi(\emph{blue},\emph{green},\emph{red},3,1) & \text{if $i=1$}\\ 2530% \Phi(\emph{green},\emph{red},\emph{blue},1,1) & \text{if $i=2$}\\ 2531% \Phi(\emph{green},\emph{blue},\emph{red},3,-1) & \text{if $i=3$}\\ 2532% \Phi(\emph{red},\emph{blue},\emph{green},5,1) & \text{if $i=4$}\\ 2533% \Phi(\emph{blue},\emph{red},\emph{green},5,-1) & \text{if $i=5$}\\ 2534% \Phi(\emph{red},\emph{green},\emph{blue},1,-1) & \text{if $i=6$}\\ 2535% (0,0,\emph{blue}) & \text{if $i=7$} 2536% \end{cases}\label{eq.rgb2hsb2} 2537% \intertext{where} 2538% \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) 2539% \end{gather} 2540% 2541% The singular case $x=z$, which is equivalent to $\emph{red}=\emph{green}=\emph{blue}$, is covered here by $i=7$. 2542% 2543% \medskip 2544% 2545% It is not difficult to see that this algorithm is a reformulation of the previous method. 2546% The following table explains how the transition from equation (\ref{eq.rgb2hsb1}) to equation (\ref{eq.rgb2hsb2}) works: 2547% 2548% \medskip 2549% 2550% \begin{tabular*}{\textwidth}{@{\extracolsep\fill}*5{>{$}c<{$}}l@{}} 2551% 6\cdot\emph{hue}& \emph{Condition}& \emph{red}\ge\emph{green}& \emph{green}\ge\emph{blue}& \emph{blue}\ge\emph{red}& $i$\\\hline 2552% 1-f & \emph{red}\ge\emph{green}\ge\emph{blue}& 1& 1& *& \textbf6/7\\ 2553% 1+f & \emph{green}\ge\emph{red}\ge\emph{blue}& *& 1& *& \textbf2/3/6/7\\ 2554% 3-f & \emph{green}\ge\emph{blue}\ge\emph{red}& *& 1& 1& \textbf3/7\\ 2555% 3+f & \emph{blue}\ge\emph{green}\ge\emph{red}& *& *& 1& \textbf1/3/5/7\\ 2556% 5-f & \emph{blue}\ge\emph{red}\ge\emph{green}& 1& *& 1& \textbf5/7\\ 2557% 5+f & \emph{red}\ge\emph{blue}\ge\emph{green}& 1& *& *& \textbf4/5/6/7\\ 2558% \end{tabular*} 2559% 2560% \medskip 2561% 2562% Here, $*$ denotes possible 0 or 1 values. 2563% Bold $i$~values mark the main cases where all $*$~values of a row are zero. 2564% The slight difference to equation (\ref{eq.rgb2hsb1}) in the last inequality is intentional and does no harm. 2565% 2566% 2567% \paragraph{Conversion \Model{rgb} to \Model{gray}} 2568% Source: \cite{plrm}, p. 474. 2569% \begin{align} 2570% \emph{gray} & := 0.3\cdot\emph{red} + 0.59\cdot\emph{green} + 0.11\cdot\emph{blue} 2571% \end{align} 2572% 2573% 2574% \paragraph{Conversion \Model{rgb} to \Model{RGB}} 2575% As described in section \vref{sec.real2int}. 2576% \begin{gather} 2577% (\emph{Red},\emph{Green},\emph{Blue}) := \bigl(\RtoI L(\emph{red}), \RtoI L(\emph{green}), \RtoI L(\emph{blue})\bigr) 2578% \end{gather} 2579% 2580% 2581% \paragraph{Conversion \Model{rgb} to \Model{HTML}} 2582% As described in section \vref{sec.real2int}. 2583% Convert to 6-digit hexadecimal afterwards. 2584% Certainly, multiplication and summation can be replaced by simple text concatenation of 2-digit hexadecimals. 2585% \begin{gather} 2586% \emph{RRGGBB} := \bigl( 65536\cdot\RtoI L(\emph{red}) + 256\cdot \RtoI L(\emph{green}) + \RtoI L(\emph{blue}) \bigr)_{\emph{hex}} 2587% \end{gather} 2588% 2589% 2590% \paragraph{Complement of \Model{rgb} color} 2591% We simply take the complementary vector: 2592% \begin{gather} 2593% (\emph{red}^*, \emph{green}^*, \emph{blue}^*) := E - (\emph{red}, \emph{green}, \emph{blue}) 2594% \end{gather} 2595% 2596% 2597% \subsubsection{The \Model{cmy} model} 2598% 2599% \paragraph{Conversion \Model{cmy} to \Model{rgb}} 2600% This is simply a reversion of the $\Model{rgb}\to\Model{cmy}$ case, cf. section \vref{sec.rgb2cmy}. 2601% \begin{gather} 2602% (\emph{red}, \emph{green}, \emph{blue}) := E - (\emph{cyan}, \emph{magenta}, \emph{yellow}) 2603% \end{gather} 2604% 2605% 2606% \paragraph{Conversion \Model{cmy} to \Model{cmyk}}\label{sec.cmy2cmyk} 2607% 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. 2608% The following algorithm is an extended version of the one given in \cite{plrm}, p. 476. 2609% \begin{align} 2610% k & := \min\{\emph{cyan},\emph{magenta},\emph{yellow}\}\\ 2611% \emph{cyan} & := \min\{1,\max\{0,\emph{cyan} - \emph{UCR}_c(k)\}\}\\ 2612% \emph{magenta} & := \min\{1,\max\{0,\emph{magenta} - \emph{UCR}_m(k)\}\}\\ 2613% \emph{yellow} & := \min\{1,\max\{0,\emph{yellow} - \emph{UCR}_y(k)\}\}\\ 2614% \emph{black} & := \emph{BG}(k) 2615% \end{align} 2616% Here, four additional functions are required: 2617% \begin{align} 2618% \emph{UCR}_c, \emph{UCR}_m, \emph{UCR}_y & : [0,1] \to [-1,1]\tag*{\em undercolor-removal}\\ 2619% \emph{BG} & : [0,1] \to [0,1]\tag*{\em black-generation} 2620% \end{align} 2621% These functions are device-dependent, see the remarks in \cite{plrm}. 2622% 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: 2623% \begin{align} 2624% \emph{UCR}_c(k) &:= \beta_c\cdot k\\ 2625% \emph{UCR}_m(k) &:= \beta_m\cdot k\\ 2626% \emph{UCR}_y(k) &:= \beta_y\cdot k\\ 2627% \emph{BG}(k) &:= \beta_k\cdot k 2628% \end{align} 2629% \DescribeMacro\adjustUCRBG 2630% 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$|}|. 2631% 2632% 2633% \paragraph{Conversion \Model{cmy} to \Model{gray}} 2634% This is derived from the conversion chain $\Model{cmy}\to\Model{rgb}\to\Model{gray}$. 2635% \begin{align} 2636% \emph{gray} & := 1 - (0.3\cdot\emph{cyan} + 0.59\cdot\emph{magenta} + 0.11\cdot\emph{yellow}) 2637% \end{align} 2638% 2639% 2640% \paragraph{Complement of \Model{cmy} color} 2641% We simply take the complementary vector: 2642% \begin{gather} 2643% (\emph{cyan}^*, \emph{magenta}^*, \emph{yellow}^*) := E - (\emph{cyan}, \emph{magenta}, \emph{yellow}) 2644% \end{gather} 2645% 2646% 2647% \subsubsection{The \Model{cmyk} model} 2648% 2649% \paragraph{Conversion \Model{cmyk} to \Model{cmy}}\label{sec.cmyk2cmy} 2650% Based on \cite{plrm}, p. 477, in connection with $\Model{rgb}\to\Model{cmy}$ conversion. 2651% \begin{align} 2652% \emph{cyan} & := \min\{1,\emph{cyan} + \emph{black}\}\\ 2653% \emph{magenta} & := \min\{1,\emph{magenta} + \emph{black}\}\\ 2654% \emph{yellow} & := \min\{1,\emph{yellow} + \emph{black}\} 2655% \end{align} 2656% 2657% 2658% \paragraph{Conversion \Model{cmyk} to \Model{gray}} 2659% Source: \cite{plrm}, p. 475. 2660% \begin{align} 2661% \emph{gray} & := 1 - \min\{1,0.3\cdot\emph{cyan} + 0.59\cdot\emph{magenta} + 0.11\cdot\emph{yellow} + black\} 2662% \end{align} 2663% 2664% 2665% \paragraph{Complement of \Model{cmyk} color} 2666% The simple vector complement does not yield useful results. 2667% Therefore, we first convert %$C=(\emph{cyan}, \emph{magenta}, \emph{yellow}, \emph{black})$ 2668% to the \Model{cmy} model, calculate the complement there, and convert back to \Model{cmyk}. 2669% 2670% 2671% \subsubsection{The \Model{hsb} model} 2672% 2673% \paragraph{Conversion \Model{hsb} to \Model{rgb}} 2674% \begin{gather} 2675% (\emph{red},\emph{green},\emph{blue}) := 2676% \emph{brightness}\cdot( E - \emph{saturation}\cdot F)\\ 2677% \intertext{with} 2678% i := \left\lfloor 6\cdot\emph{hue}\right\rfloor,\qquad f := 6\cdot\emph{hue} - i\\ 2679% \intertext{and} 2680% F := 2681% \begin{cases} 2682% (0,1-f,1) & \text{if $i=0$}\\ 2683% (f,0,1) & \text{if $i=1$}\\ 2684% (1,0,1-f) & \text{if $i=2$}\\ 2685% (1,f,0) & \text{if $i=3$}\\ 2686% (1-f,1,0) & \text{if $i=4$}\\ 2687% (0,1,f) & \text{if $i=5$}\\ 2688% (0,1,1) & \text{if $i=6$} 2689% \end{cases}\label{eq.hsb2rgb2} 2690% \end{gather} 2691% 2692% \medskip 2693% 2694% This is based on \cite{smith}, \emph{HSV to RGB Algorithm (Hexcone Model)}, which reads (slightly reformulated): 2695% \begin{align} 2696% m & := 1-\emph{saturation}\\ 2697% n & := 1-f\cdot\emph{saturation}\\ 2698% k & := 1-(1-f)\cdot\emph{saturation}\\ 2699% (\emph{red},\emph{green},\emph{blue}) & := \emph{brightness}\cdot 2700% \begin{cases} 2701% (1,k,m) & \text{if $i=0,6$}\\ 2702% (n,1,m) & \text{if $i=1$}\\ 2703% (m,1,k) & \text{if $i=2$}\\ 2704% (m,n,1) & \text{if $i=3$}\\ 2705% (k,m,1) & \text{if $i=4$}\\ 2706% (1,m,n) & \text{if $i=5$} 2707% \end{cases}\label{eq.hsb2rgb1} 2708% \end{align} 2709% Note that the case $i=6$ (which results from $\emph{hue}=1$) is missing in Smith's algorithm. 2710% Because of 2711% \begin{align} 2712% \lim_{f\to1} (0,1,f) = (0,1,1) = \lim_{f\to0} (0,1-f,1) 2713% \end{align} 2714% 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}). 2715% This has been transformed back to equation (\ref{eq.hsb2rgb1}). 2716% A similar argument shows that $F$ indeed is a continuous function of \emph{hue} over the whole range $[0,1]$. 2717% 2718% 2719% \paragraph{Conversion \Model{hsb} to \Model{Hsb}} 2720% Only the first component has to be changed. 2721% \begin{gather} 2722% (\emph{hue\Circ}, \emph{saturation}, \emph{brightness}) := (H\cdot\emph{hue}, \emph{saturation}, \emph{brightness}) 2723% \end{gather} 2724% 2725% 2726% \paragraph{Conversion \Model{hsb} to \Model{HSB}} 2727% As described in section \vref{sec.real2int}. 2728% \begin{gather} 2729% (\emph{Hue}, \emph{Saturation}, \emph{Brightness}) := \bigl(\RtoI M(\emph{hue}), \RtoI M(\emph{saturation}), \RtoI M(\emph{brightness})\bigr) 2730% \end{gather} 2731% 2732% 2733% \paragraph{Complement of \Model{hsb} color} 2734% We have not found a formula in the literature, therefore we give a short proof afterwards. 2735% \begin{lemma} 2736% The \textup{\Model{hsb}}-complement can be calculated by the following formulas:\em 2737% \begin{align} 2738% \emph{hue}^* & := 2739% \begin{cases} 2740% \emph{hue} + \frac12 & \text{if $\emph{hue}<\frac12$}\\[1ex] 2741% \emph{hue} - \frac12 & \text{if $\emph{hue}\ge\frac12$}\\ 2742% \end{cases}\\[1ex] 2743% \emph{brightness}^* & := 1 - \emph{brightness}\cdot(1-\emph{saturation})\\[1ex] 2744% \emph{saturation}^* & := 2745% \begin{cases} 2746% 0 & \text{if $\emph{brightness}^*=0$}\\[1ex] 2747% \displaystyle\frac{\emph{brightness}\cdot\emph{saturation}}{\emph{brightness}^*} & \text{if $\emph{brightness}^*\ne0$} 2748% \end{cases} 2749% \end{align} 2750% \end{lemma} 2751% 2752% \begin{proof} 2753% 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 2754% \begin{gather} 2755% C_{\Model{rgb}} + C_{\Model{rgb}}^* = b\cdot(E - s\cdot F) + b^*\cdot(E - s'\cdot F^*) \stackrel!= E,\label{eq.hsbcompl1} 2756% \end{gather} 2757% which means that $C_{\Model{rgb}}$ is the complement of $C_{\Model{rgb}}^*$. 2758% First we note that the parameters of $C^*$ are in the legal range $[0,1]$. 2759% This is obvious for $h^*,b^*$. 2760% From 2761% $b^* = 1-b\cdot(1-s) = 1 - b + b\cdot s$ 2762% we derive $b\cdot s = b^* - (1-b) \le b^*$, therefore $s^*\in[0,1]$, and 2763% \begin{gather*} 2764% b^* = 0 \Leftrightarrow s=0 \text{ and } b=1. 2765% \end{gather*} 2766% Thus, equation (\ref{eq.hsbcompl1}) holds in the case $b^*=0$. 2767% Now we assume $b^*\ne0$, hence 2768% \begin{align*} 2769% C_{\Model{rgb}} + C_{\Model{rgb}}^* 2770% &= b\cdot(E - s\cdot F) + b^*\cdot\Bigl(E - \frac{b\cdot s}{b^*}\cdot F^*\Bigr) \\ 2771% &= b\cdot E - b\cdot s\cdot F + b^*\cdot E - b\cdot s\cdot F^*\\[1ex] 2772% &= E - b\cdot s\cdot(F+F^*-E) 2773% \end{align*} 2774% since $b^*=1-b+bs$. 2775% Therefore, it is sufficient to show that 2776% \begin{gather} 2777% F+F^*=E.\label{eq.hsbcompl2} 2778% \end{gather} 2779% From 2780% \begin{gather*}\textstyle 2781% h<\frac12 \Rightarrow h^*=h+\frac12 \Rightarrow 6h^* = 6h+3 \Rightarrow i^*=i+3 \text{ and } f^*=f 2782% \end{gather*} 2783% it is easy to see from (\ref{eq.hsb2rgb2}) that equation (\ref{eq.hsbcompl2}) holds for the cases $i=0,1,2$. 2784% Similarly, 2785% \begin{gather*}\textstyle 2786% h\ge\frac12 \Rightarrow h^*=h-\frac12 \Rightarrow 6h^* = 6h-3 \Rightarrow i^*=i-3 \text{ and } f^*=f 2787% \end{gather*} 2788% and again from (\ref{eq.hsb2rgb2}) we derive (\ref{eq.hsbcompl2}) for the cases $i=3,4,5$. 2789% Finally, if $i=6$ then $f=0$ and $F+F^* = (0,1,1) + (1,0,0) = E$. 2790% \end{proof} 2791% 2792% 2793% \subsubsection{The \Model{Hsb} model} 2794% 2795% \paragraph{Conversion \Model{Hsb} to \Model{hsb}} 2796% Only the first component has to be changed. 2797% \begin{gather} 2798% (\emph{hue}, \emph{saturation}, \emph{brightness}) := (\emph{hue\Circ}/H, \emph{saturation}, \emph{brightness}) 2799% \end{gather} 2800% 2801% 2802% \paragraph{Conversion \Model{Hsb} to \Model{tHsb}} 2803% Under the settings of (\ref{eq.tHsb1})--(\ref{eq.tHsb3}) we simply have to exchange the letters $x$ and $y$ in equation (\ref{eq.tHsb4}) to get the inverse transformation: 2804% \begin{gather} 2805% \displaystyle \emph{hue\Circ}\in\left[y_{\eta-1},y_\eta\right] \Rightarrow 2806% \emph{hue\Circ} := x_{\eta-1} + \frac{x_\eta - x_{\eta-1}}{y_\eta - y_{\eta-1}}\cdot(\emph{hue\Circ} - y_{\eta-1}) 2807% \end{gather} 2808% while \emph{saturation} and \emph{brightness} are left unchanged. 2809% 2810% 2811% \subsubsection{The \Model{tHsb} model} 2812% 2813% \paragraph{Conversion \Model{tHsb} to \Model{Hsb}}\label{sec.tHsb2Hsb} 2814% \DescribeMacro\rangeHsb 2815% \DescribeMacro\rangetHsb 2816% We assume that $\texttt{\string\rangeHsb}=H$ and |\rangetHsb| expands to 2817% \begin{gather} 2818% x_1,y_1;x_2,y_2;\dots;x_{h-1},y_{h-1}\label{eq.tHsb1} 2819% \intertext{where} 2820% x_0:=0<x_1<x_2<\dots<x_{h-1}<x_h:=H\label{eq.tHsb2}\\ 2821% y_0:=0<y_1<y_2<\dots<y_{h-1}<y_h:=H\label{eq.tHsb3} 2822% \end{gather} 2823% with an integer $h>0$. 2824% Now the $x$ and $y$ values determine a piecewise linear transformation: 2825% \begin{gather} 2826% \displaystyle \emph{hue\Circ}\in\left[x_{\eta-1},x_\eta\right] \Rightarrow 2827% \emph{hue\Circ} := y_{\eta-1} + \frac{y_\eta - y_{\eta-1}}{x_\eta - x_{\eta-1}}\cdot(\emph{hue\Circ} - x_{\eta-1}) 2828% \label{eq.tHsb4} 2829% \end{gather} 2830% while \emph{saturation} and \emph{brightness} are left unchanged. 2831% 2832% 2833% \subsubsection{The \Model{gray} model} 2834% 2835% \paragraph{Conversion \Model{gray} to \Model{rgb}} 2836% Source: \cite{plrm}, p. 474. 2837% \begin{gather} 2838% (\emph{red}, \emph{green}, \emph{blue}) := \emph{gray}\cdot E 2839% \end{gather} 2840% 2841% 2842% \paragraph{Conversion \Model{gray} to \Model{cmy}} 2843% This is derived from the conversion chain $\Model{gray}\to\Model{rgb}\to\Model{cmy}$. 2844% \begin{gather} 2845% (\emph{cyan}, \emph{magenta}, \emph{yellow}) := (1-\emph{gray})\cdot E 2846% \end{gather} 2847% 2848% 2849% \paragraph{Conversion \Model{gray} to \Model{cmyk}} 2850% Source: \cite{plrm}, p. 475. 2851% \begin{gather} 2852% (\emph{cyan}, \emph{magenta}, \emph{yellow}, \emph{black}) := (0,0,0,1-\emph{gray}) 2853% \end{gather} 2854% 2855% 2856% \paragraph{Conversion \Model{gray} to \Model{hsb}} 2857% This is derived from the conversion chain $\Model{gray}\to\Model{rgb}\to\Model{hsb}$. 2858% \begin{gather} 2859% (\emph{hue}, \emph{saturation}, \emph{brightness}) := (0,0,\emph{gray}) 2860% \end{gather} 2861% 2862% 2863% \paragraph{Conversion \Model{gray} to \Model{Hsb}/\Model{tHsb}} 2864% This is derived from the conversion chain $\Model{gray}\to\Model{hsb}\to\Model{Hsb}$, followed by $\Model{Hsb}\to\Model{tHsb}$ if applicable. 2865% \begin{gather} 2866% (\emph{hue\Circ}, \emph{saturation}, \emph{brightness}) := (0,0,\emph{gray}) 2867% \end{gather} 2868% 2869% 2870% \paragraph{Conversion \Model{gray} to \Model{Gray}} 2871% As described in section \vref{sec.real2int}. 2872% \begin{gather} 2873% \emph{Gray} := \RtoI N(\emph{gray}) 2874% \end{gather} 2875% 2876% 2877% \paragraph{Complement of \Model{gray} color} 2878% This is similar to the \Model{rgb} case: 2879% \begin{gather} 2880% \emph{gray}^* := 1 - \emph{gray} 2881% \end{gather} 2882% 2883% 2884% \subsubsection{The \Model{RGB} model} 2885% 2886% \paragraph{Conversion \Model{RGB} to \Model{rgb}} 2887% As described in section \vref{sec.int2real}. 2888% \begin{gather} 2889% (\emph{red}, \emph{green}, \emph{blue}) := \bigl(\ItoR L(\emph{Red}), \ItoR L(\emph{Green}), \ItoR L(\emph{Blue})\bigr) 2890% \end{gather} 2891% 2892% 2893% \subsubsection{The \Model{HTML} model} 2894% 2895% \paragraph{Conversion \Model{HTML} to \Model{rgb}} 2896% As described in section \vref{sec.int2real}: starting with \emph{RRGGBB} set 2897% \begin{gather} 2898% (\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) 2899% \end{gather} 2900% 2901% 2902% \subsubsection{The \Model{HSB} model} 2903% 2904% \paragraph{Conversion \Model{HSB} to \Model{hsb}} 2905% As described in section \vref{sec.int2real}. 2906% \begin{gather} 2907% (\emph{hue}, \emph{saturation}, \emph{brightness}) := \bigl(\ItoR M(\emph{Hue}), \ItoR M(\emph{Saturation}), \ItoR M(\emph{Brightness})\bigr) 2908% \end{gather} 2909% 2910% 2911% \subsubsection{The \Model{Gray} model} 2912% 2913% \paragraph{Conversion \Model{Gray} to \Model{gray}} 2914% As described in section \vref{sec.int2real}. 2915% \begin{gather} 2916% \emph{gray} := \ItoR N(\emph{Gray}) 2917% \end{gather} 2918% 2919% 2920% \subsubsection{The \Model{wave} model} 2921% 2922% \paragraph{Conversion \Model{wave} to \Model{rgb}} 2923% Source: based on \People{Dan}{Bruton}'s algorithm \cite{Bruton}. 2924% Let $\lambda$ be a visible wavelength, given in nanometers (nm), i.e., $\lambda\in\left[380,780\right]$. 2925% We assume further that $\gamma>0$ is a fixed number ($\gamma=0.8$ in \cite{Bruton}). 2926% First set 2927% \begin{align} 2928% (r,g,b) & := 2929% \begin{cases} 2930% \displaystyle \Bigl(\frac{440-\lambda}{440-380},0,1\Bigr) & \text{if $\lambda\in[380,440[$}\\[1.75ex] 2931% \displaystyle \Bigl(0,\frac{\lambda-440}{490-440},1\Bigr) & \text{if $\lambda\in[440,490[$}\\[1.75ex] 2932% \displaystyle \Bigl(0,1,\frac{510-\lambda}{510-490}\Bigr) & \text{if $\lambda\in[490,510[$}\\[1.75ex] 2933% \displaystyle \Bigl(\frac{\lambda-510}{580-510},1,0\Bigr) & \text{if $\lambda\in[510,580[$}\\[1.75ex] 2934% \displaystyle \Bigl(1,\frac{645-\lambda}{645-580},0\Bigr) & \text{if $\lambda\in[580,645[$}\\[2.5ex] 2935% \displaystyle (1,0,0) & \text{if $\lambda\in[645,780]$}\\ 2936% \end{cases}\label{eq.gamma2rgb1}\\ 2937% \intertext{then, in order to let the intensity fall off near the vision limits,} 2938% f & := 2939% \begin{cases} 2940% \displaystyle 0.3 + 0.7\cdot\frac{\lambda-380}{420-380} & \text{if $\lambda\in\left[380,420\right[$}\\[1.25ex] 2941% \displaystyle 1 & \text{if $\lambda\in[420,700]$}\\[1ex] 2942% \displaystyle 0.3 + 0.7\cdot\frac{780-\lambda}{780-700} & \text{if $\lambda\in\left]700,780\right]$}\\ 2943% \end{cases}\label{eq.gamma2rgb2}\\ 2944% \intertext{and finally} 2945% (\emph{red},\emph{green},\emph{blue}) & := \bigl((f\cdot r)^\gamma, (f\cdot g)^\gamma, (f\cdot b)^\gamma\bigr) 2946% \end{align} 2947% The intermediate colors $(r,g,b)$ at the interval borders of equation (\ref{eq.gamma2rgb1}) are well-known: 2948% for $\lambda=380,440,490,510,580,645$ we get \Color{magenta}, \Color{blue}, \Color{cyan}, \Color{green}, \Color{yellow}, \Color{red}, respectively. 2949% 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. 2950% Furthermore, these \Model{hsb} representations are independent of the actual $\gamma$ value. 2951% 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. 2952% 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. 2953% 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. 2954% Now we are prepared to translate everything into another, more natural algorithm. 2955% 2956% 2957% \paragraph{Conversion \Model{wave} to \Model{hsb}} 2958% Let $\lambda>0$ be a wavelength, given in nanometers (nm), and let 2959% \begin{gather} 2960% \varrho : \bbbR \to \left[0,1\right],\ x \mapsto \bigl( \min\{ 1, \max\{ 0,x\} \} )^\gamma 2961% \end{gather} 2962% with a fixed correction number $\gamma>0$. 2963% Then 2964% \begin{align} 2965% \emph{hue} & := \displaystyle \frac16\cdot 2966% \begin{cases} 2967% \displaystyle 4 + \varrho\Bigl(\frac{\lambda-440}{380-440}\Bigr) & \text{if $\lambda<440$}\\[1.75ex] 2968% \displaystyle 4 - \varrho\Bigl(\frac{\lambda-440}{490-440}\Bigr) & \text{if $\lambda\in[440,490[$}\\[1.75ex] 2969% \displaystyle 2 + \varrho\Bigl(\frac{\lambda-510}{490-510}\Bigr) & \text{if $\lambda\in[490,510[$}\\[1.75ex] 2970% \displaystyle 2 - \varrho\Bigl(\frac{\lambda-510}{580-510}\Bigr) & \text{if $\lambda\in[510,580[$}\\[1.75ex] 2971% \displaystyle 0 + \varrho\Bigl(\frac{\lambda-645}{580-645}\Bigr) & \text{if $\lambda\in[580,645[$}\\[2.5ex] 2972% \displaystyle 0 & \text{if $\lambda\ge645$}\\ 2973% \end{cases}\label{eq.gamma2hsb1}\\[1ex] 2974% \emph{saturation} & := 1\\[1ex] 2975% \emph{brightness} & := 2976% \begin{cases} 2977% \displaystyle \varrho\Bigl(0.3 + 0.7\cdot\frac{\lambda-380}{420-380}\Bigr) & \text{if $\lambda<420$}\\[1.5ex] 2978% \displaystyle 1 & \text{if $\lambda\in[420,700]$}\\[1ex] 2979% \displaystyle \varrho\Bigl(0.3 + 0.7\cdot\frac{\lambda-780}{700-780}\Bigr) & \text{if $\lambda>700$}\\ 2980% \end{cases}\label{eq.gamma2hsb2} 2981% \end{align} 2982% For the sake of completeness we note that, independent of $\gamma$, 2983% \begin{gather*} 2984% (\emph{hue},\emph{saturation},\emph{brightness}) = 2985% \begin{cases} 2986% \bigl(\frac56,1,0\bigr) & \text{if $\lambda\le 380 - \frac{3\cdot(420-380)}7 = 362.857\dots$}\\[1.5ex] 2987% \bigl(0,1,0\bigr) & \text{if $\lambda\ge 780 + \frac{3\cdot(780-700)}7 = 814.285\dots$}\\ 2988% \end{cases}\label{eq.gamma2hsb3} 2989% \end{gather*} 2990% What is the best (or, at least, a good) value for $\gamma$? 2991% In the original algorithm \cite{Bruton}, $\gamma=0.8$ is chosen. 2992% However, we could not detect significant visible difference between the cases $\gamma=0.8$ and $\gamma=1$. 2993% Thus, for the time being, \XC's implementation uses the latter value which implies a pure linear approach. 2994% In the \Package{pstricks} examples file \href{xcolor2.pdf}{\File{xcolor2.tex}}, there is a demonstration of different $\gamma$ values. 2995% 2996% \clearpage 2997% 2998% 2999% 3000% \begin{adjustwidth}{-2.5cm}{} 3001% \begingroup\raggedright 3002% \begin{thebibliography}{00} 3003% \addcontentsline{toc}{section}{References} 3004% 3005% \bibitem{plrm}% 3006% {Adobe Systems Incorporated: ``PostScript Language Reference Manual''. Addison-Wesley, third edition, 1999. 3007% \URL{http://www.adobe.com/products/postscript/pdfs/PLRM.pdf}} 3008% 3009% \bibitem{fbox}% 3010% {\People{Donald}{Arseneau}: ``Patch so \cmd\fbox{} draws frame on top of text''. \LaTeX{} bug report, latex/3655, 2004/03/18. 3011% \URL{http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=latex/3655}} 3012% 3013% \bibitem{url}% 3014% {\People{Donald}{Arseneau}: \Package{url} package, ``2005/06/27 ver 3.2 Verb mode for urls, etc.''. 3015% \CTAN{macros/latex/contrib/misc/}{url.sty}} 3016% 3017% \bibitem{Bruton}% 3018% {\People{Dan}{Bruton}: ``Approximate RGB values for Visible Wavelengths'', 1996. 3019% \URL{http://www.physics.sfasu.edu/astro/color/spectra.html}} 3020% 3021% \bibitem{dpc}% 3022% {\People{David P.}{Carlisle}: ``Packages in the `graphics' bundle'', 1999. 3023% \CTAN{macros/latex/required/graphics/}{grfguide.*}} 3024% 3025% \bibitem{color}% 3026% {\People{David P.}{Carlisle}: \LCP, ``1999/02/16 v1.0i Standard \LaTeX{} Color''. 3027% \CTAN{macros/latex/required/graphics/}{color.*}} 3028% 3029% \bibitem{colortbl}% 3030% {\People{David P.}{Carlisle}: \Package{colortbl} package, ``2001/02/13 v0.1j Color table columns''. 3031% \CTAN{macros/latex/contrib/carlisle/}{colortbl.*}} 3032% 3033% \bibitem{pstcol}% 3034% {\People{David P.}{Carlisle}: \Package{pstcol} package, ``2001/06/20 v1.1 PSTricks color compatibility''. 3035% \CTAN{macros/latex/required/graphics/}{pstcol.*}} 3036% 3037% \bibitem{chroma}% 3038% {\People{Uwe}{Kern}: ``Chroma: a reference book of \LaTeX{} colors''. 3039% \CTAN{info/colour/chroma/}{} and 3040% \URL{http://www.ukern.de/tex/chroma.html}} 3041% 3042% \bibitem{xcolor}% 3043% {\People{Uwe}{Kern}: \Package{xcolor} package, ``\LaTeX{} color extensions''. 3044% \CTAN{macros/latex/contrib/xcolor/}{} and 3045% \URL{http://www.ukern.de/tex/xcolor.html}} 3046% 3047% \bibitem{mik}% 3048% {MiK\TeX{} Project: 3049% \URL{http://www.miktex.org/}} 3050% 3051% \bibitem{colorinfo}% 3052% {\People{Rolf}{Niepraschk}: \Package{colorinfo} package, ``2003/05/04 v0.3c Info from defined colors''. 3053% \CTAN{macros/latex/contrib/colorinfo/}{}} 3054% 3055% \bibitem{pdfcolmk}% 3056% {\People{Heiko}{Oberdiek}: \Package{pdfcolmk} package, ``2005/07/09 v0.7''. 3057% \CTAN{macros/latex/contrib/oberdiek/pdfcolmk.sty}{}} 3058% 3059% \bibitem{hyperref}% 3060% {\People{Sebastian}{Rahtz}: \Package{hyperref} package, ``2003/11/30 v6.74m Hypertext links for \LaTeX''. 3061% \CTAN{macros/latex/contrib/hyperref/}{}} 3062% 3063% \bibitem{smith}% 3064% {\People{Alvy Ray}{Smith}: ``Color Gamut Transform Pairs''. \emph{Computer Graphics} (ACM SIGGRAPH), Volume 12, Number 3, August 1978. 3065% \URL{http://alvyray.com/Papers/PapersCG.htm}} 3066% 3067% \bibitem{svg}% 3068% {World Wide Web Consortium: ``Scalable Vector Graphics (\Index{SVG}) 1.1 Specification --- Basic Data Types and Interfaces''. 3069% \URL{http://www.w3.org/TR/SVG11/types.html\#ColorKeywords}} 3070% 3071% \end{thebibliography} 3072% \endgroup 3073% \clearpage 3074% 3075% \columnsep2.25em 3076% \begin{multicols}{2}[\section*{Appendix}% 3077% \addcontentsline{toc}{section}{Appendix}] 3078% 3079% \subsection*{Acknowledgement} 3080% \addcontentsline{toc}{subsection}{Acknowledgement} 3081% This package is based on and contains code copied from \cite{color} (Copyright (C) 1994--1999 \People{David P.}{Carlisle}), which is part of the Standard \LaTeX{} `Graphics Bundle'. 3082% 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. 3083% Thus, the author is grateful to \People{David P.}{Carlisle} for having created \LC{} and its accompanying files. 3084% 3085% \subsection*{Trademarks} 3086% \addcontentsline{toc}{subsection}{Trademarks} 3087% Trademarks appear throughout this documentation without any trademark symbol; they are the property of their respective trademark owner. 3088% There is no intention of infringement; the usage is to the benefit of the trademark owner. 3089% 3090% \raggedright 3091% \leftmargini1em 3092% \leftmarginii1em 3093% \leftmarginiii1em 3094% 3095% \subsection*{Known Issues} 3096% \addcontentsline{toc}{subsection}{Known Issues} 3097% \begin{itemize} 3098% \item |\rowcolors[\hline]...| does not work with \Package{longtable}. 3099% \end{itemize} 3100% 3101% \subsection*{History} 3102% \addcontentsline{toc}{subsection}{History} 3103% 3104% \subsubsection*{2005/12/21 v2.09} 3105% \begin{itemize} 3106% \item New features: 3107% \begin{itemize} 3108% \item |\definecolor| and |\color| now accept space-separated color specifications, e.g., |\color| |[rgb]{1 .5 0}|; 3109% \item experimental \Option{xcdraw} option extended to \Option{pdftex} and \Option{dvipdfm} drivers. 3110% \end{itemize} 3111% \item Changes: 3112% \begin{itemize} 3113% \item test file \File{xcolor2.tex} made compatible with recent changes in \Package{pstricks}; 3114% \item test file \File{xcolor3.tex} extended; 3115% \item driver test file \File{xcolor4.tex} extended to demonstrate the different frame drawing approaches; 3116% \item more efficient implementation of driver-specific code. 3117% \end{itemize} 3118% \end{itemize} 3119% 3120% \subsubsection*{2005/11/25 v2.08} 3121% \begin{itemize} 3122% \item New features: 3123% \begin{itemize} 3124% \item more flexibility for |\fcolorbox| arguments, e.g., |\fcolorbox| |[gray]{0.5}[wave]{580}{test}|; 3125% \item |\boxframe| returns a frame of given dimensions; 3126% \item new implementation of |\f(rame)box| and |\fcolorbox| as an extension of bug report latex/3655 to reduce pixel positioning errors in output devices; 3127% \item \Option{kernelfbox} option for those who prefer the previous |\f(rame)box| approach; 3128% \item experimental \Option{xcdraw} option uses \Index{PostScript} commands to draw frames and color boxes in case of \Option{dvips}. 3129% \end{itemize} 3130% \item Bugfixes: 3131% \begin{itemize} 3132% \item insufficient expression type detection within |\colorlet|; 3133% \item wrong calculation in the unit interval reduction for negative integers (affecting color series and extended color expressions). 3134% \end{itemize} 3135% \end{itemize} 3136% 3137% \subsubsection*{2005/11/12 v2.07} 3138% \begin{itemize} 3139% \item New features: 3140% \begin{itemize} 3141% \item color model \Model{Hsb} allows to specify \emph{hue} in degrees; 3142% \item color model \Model{tHsb} (\pModel{tuned} \Model{Hsb}) for user-defined \emph{hue} configuration on color wheels; 3143% \item easy generation of color harmonies derived from \Model{Hsb} or \Model{tHsb} color wheels, e.g., |\color{red>wheel,1,12}| yields an `analogous' color to \Color{red} on a 12-spoke wheel; 3144% \item additional 317 predefined color names according to \File{rgb.txt}, which is part of \Index{Unix}/\Index{X11} distributions; 3145% \item \Option{svgnames} option extended by~4~colors taken from \File{rgb.txt}; 3146% \item enhanced syntax for immediate conversion, e.g., |\definecolor| |{foo}{rgb:gray}{0.3}| or |\color| |[rgb:wave]{478}|; 3147% \item |\@ifundefinedcolor| and |\@ifundefinedmodel| commands; 3148% \end{itemize} 3149% \item Changes: 3150% \begin{itemize} 3151% \item enhanced documentation; 3152% \item several changes to internal macros. 3153% \end{itemize} 3154% \item Bugfixes: 3155% \begin{itemize} 3156% \item wrong calculation of color series components in some cases of negative step parameters. 3157% \end{itemize} 3158% \end{itemize} 3159% 3160% \subsubsection*{2005/10/15 v2.06} 3161% \begin{itemize} 3162% \item New features: 3163% \begin{itemize} 3164% \item color model \Model{wave} for (approximate) visualisation of light wavelengths, still somewhat experimental; 3165% \item pseudo-model \nModel{ps} for colors defined by literal \Index{PostScript} code in conjunction with \Package{pstricks} and \Option{dvips}; an illustrative example for a $\gamma$-correction approach is given in \href{xcolor2.pdf}{\File{xcolor2.tex}}; 3166% \item |\substitutecolormodel| command for replacement of missing or faulty driver-specific color models; 3167% \item improved detection and handling of driver-specific color models; 3168% \item \Option{dvipdfmx} and \Option{xetex} options to support these drivers; 3169% \item generic driver test file \File{xcolor4.tex}. 3170% \end{itemize} 3171% \item Changes: 3172% \begin{itemize} 3173% \item |\XC@strip@comma| doesn't generate a trailing space anymore, which improves also the output of the |testcolors| environment. 3174% \end{itemize} 3175% \end{itemize} 3176% 3177% \subsubsection*{2005/09/30 v2.05} 3178% \begin{itemize} 3179% \item New features: 3180% \begin{itemize} 3181% \item |testcolors| environment helps to test colors in different models, showing both the visual result and the model-specific parameters; 3182% \item |\extractcolorspecs| puts model/color specification into two separate commands, as opposed to |\extractcolorspec|; 3183% \item color names \Color{pink} and \Color{olive} added to the set of predefined colors. 3184% \end{itemize} 3185% \item Bugfixes: 3186% \begin{itemize} 3187% \item |\definecolor{foo}{named}{bar}| did not work in v2.04. 3188% \end{itemize} 3189% \end{itemize} 3190% 3191% \subsubsection*{2005/09/23 v2.04} 3192% \begin{itemize} 3193% \item New features: 3194% \begin{itemize} 3195% \item preparation for usage of additional -- driver-provided -- color models; 3196% \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}}. 3197% \end{itemize} 3198% \item Changes: 3199% \begin{itemize} 3200% \item color model names sanitized (i.e., turned to catcode~12) throughout the package; 3201% \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); 3202% \item simplified color conversion code by using the new |\XC@ifxcase| command; 3203% \item some minor changes to internal macros. 3204% \end{itemize} 3205% \end{itemize} 3206% 3207% \subsubsection*{2005/06/06 v2.03} 3208% \begin{itemize} 3209% \item New features: 3210% \begin{itemize} 3211% \item \Option{fixpdftex} option loads \Package{pdfcolmk} package in order to improve pdf\TeX's color behaviour during page breaks. 3212% \end{itemize} 3213% \item Changes: 3214% \begin{itemize} 3215% \item some minor changes to internal macros. 3216% \end{itemize} 3217% \item Bugfixes: 3218% \begin{itemize} 3219% \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}|; 3220% \item argument processing of |\XC@getcolor| caused incompatibility with \Package{msc} package; 3221% \item \Option{prologue} option caused incompatibility with \Package{preview} package. 3222% \end{itemize} 3223% \end{itemize} 3224% 3225% \subsubsection*{2005/03/24 v2.02} 3226% \begin{itemize} 3227% \item New features: 3228% \begin{itemize} 3229% \item |\aftergroupedef| command to reproduce |\aftergroupdef|'s behaviour prior to v2.01; 3230% \item \XC's homepage \XCW{} now provides also a ready-to-run TDS-compliant archive containing all required files. 3231% \end{itemize} 3232% \item Changes: 3233% \begin{itemize} 3234% \item |\rowcolors| and friends are solely enabled by the \Option{table} option; 3235% \item |\@ifxempty| changed back to more robust variant of v2.00. 3236% \end{itemize} 3237% \item Bugfixes: 3238% \begin{itemize} 3239% \item |\psset{linecolor=\ifcase\foo| |red\or green\or blue\fi}| did not work with \Package{pstricks} (error introduced in v2.01). 3240% \end{itemize} 3241% \end{itemize} 3242% 3243% \subsubsection*{2005/03/15 v2.01} 3244% \begin{itemize} 3245% \item New features: 3246% \begin{itemize} 3247% \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); 3248% \item \Program{dvips} prologue file \File{xcolor.pro} to support additional `named' colors; 3249% \item |\colorlet| may now also be used to create named colors from arbitrary color expressions; 3250% \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; 3251% \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; 3252% \item \Option{dvipsnames*} and \Option{svgnames*} options to support deferred definition. 3253% \end{itemize} 3254% \item Changes: 3255% \begin{itemize} 3256% \item higher accuracy: most complement calculations are now exact for all 5-digit decimals; 3257% \item |\rangeRGB| and similar variables may now be changed at any point in a document; 3258% \item |\aftergroupdef| now performs only a first-level expansion of its code argument; 3259% \item |\XCfileversion| and similar internal constants removed from \File{.sty} and \File{.def} files; 3260% \item improved memory management (reduced generation of `multiletter control sequences' by |\@ifundefined| tests); 3261% \item several internal macros improved and/or renamed. 3262% \end{itemize} 3263% \item Bugfixes: 3264% \begin{itemize} 3265% \item |\XC@getcolor| could cause unwanted spaces when |\psset| was used inside |pspicture| environments (\Package{pstricks}); 3266% \item arithmetic overflow could happen when too many decimal digits were used within color parameters, e.g., as a result of \Package{fp} calculations. 3267% \end{itemize} 3268% \end{itemize} 3269% 3270% \subsubsection*{2004/07/04 v2.00} 3271% \begin{itemize} 3272% \item New features: 3273% \begin{itemize} 3274% \item extended functionality for color expressions: mix colors like a painter; 3275% \item support for color blending: specify color mix expressions that are being blended with every displayed color; 3276% \item |\xglobal| command for selective control of globality for color definitions, blends, and masks; 3277% \item multiple step operations (e.g., |\color{foo!!+++}|) and access to individual members (e.g., |\color{foo!![7]}|) in color series; 3278% \item |\providecolor| command to define only non-existent colors; 3279% \item |\definecolorset| and |\providecolorset| commands to facilitate the construction of color sets with common underlying color model; 3280% \item additional 147 predefined color names according to \Index{SVG}~1.1 specification; 3281% \item \Key{xpdfborder} key for setting the width of hyperlink borders in a more driver-independent way if \Program{dvips} is used. 3282% \end{itemize} 3283% \item Changes: 3284% \begin{itemize} 3285% \item \LCP{} now completely integrated within \XC; 3286% \item \Option{override}, \Option{usenames}, \Option{nodvipsnames} options and |\xdefinecolor| command no longer needed; 3287% \item \Option{dvips} and \Option{dvipsnames} options now independent of each other; 3288% \item |\tracingcolors|'s behaviour changed to make it more versatile and reduce log file size in standard cases; 3289% \item |\rdivide|'s syntax made more flexible (divide by numbers and/or dimensions); 3290% \item code restructured, some internal commands renamed; 3291% \item documentation rearranged and enhanced. 3292% \end{itemize} 3293% \item Bugfixes: 3294% \begin{itemize} 3295% \item |\definecolor{foo}{named}{bar}| did not work (error introduced in v1.11); 3296% \item more robust behaviour of conditionals within \Package{pstricks} key-values. 3297% \end{itemize} 3298% \end{itemize} 3299% 3300% \subsubsection*{2004/05/09 v1.11} 3301% \begin{itemize} 3302% \item New features: 3303% \begin{itemize} 3304% \item switch |\ifglobalcolors| to control whether color definitions are global or local; 3305% \item option \Option{hyperref} provides color expression support for the border colors of hyperlinks, e.g., |\hypersetup| |{xurlbordercolor=red!50!yellow}|; 3306% \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. 3307% \end{itemize} 3308% \item Changes: 3309% \begin{itemize} 3310% \item |\XC@logcolor| renamed to |\XC@display|, which is now the core color display command; 3311% \item improved interface to \Package{pstricks}. 3312% \end{itemize} 3313% \end{itemize} 3314% 3315% \subsubsection*{2004/03/27 v1.10} 3316% \begin{itemize} 3317% \item New features: 3318% \begin{itemize} 3319% \item support for \nModel{named} model; 3320% \item support for \Program{dvips} colors (may now be used within color expressions); 3321% \item internal representation of `ordinary' and `named' colors merged into unified data structure; 3322% \item allow multiple `-' signs at the beginning of color expressions. 3323% \end{itemize} 3324% \item Bugfixes: 3325% \begin{itemize} 3326% \item commands like |\color[named]{foo}| caused errors when color masking or target model conversion were active; 3327% \item incompatibility with \Package{soul} package: commands |\hl|, |\ul|, etc. could yield unexpected results. 3328% \end{itemize} 3329% \item Documentation: 3330% \begin{itemize} 3331% \item added formula for general color expressions; 3332% \item enhanced text and index; 3333% \item removed dependence of index generation on local configuration file. 3334% \end{itemize} 3335% \end{itemize} 3336% 3337% \subsubsection*{2004/02/16 v1.09} 3338% \begin{itemize} 3339% \item New features: 3340% \begin{itemize} 3341% \item color model \Model{HTML}, a 24-bit hexadecimal \Model{RGB} variant; allows to specify colors like |\color[HTML]{AFFE90}|; 3342% \item color names \Color{orange}, \Color{violet}, \Color{purple}, and \Color{brown} added to the set of predefined colors. 3343% \end{itemize} 3344% \item New \XC{} homepage: \XCW 3345% \item Bugfix: |\xdefinecolor| sometimes did not normalise its parameters. 3346% \item Changes: 3347% \begin{itemize} 3348% \item slight improvements of the documentation; 3349% \item example file |xcolor1.tex| reorganised and abridged. 3350% \end{itemize} 3351% \end{itemize} 3352% 3353% \subsubsection*{2004/02/04 v1.08} 3354% \begin{itemize} 3355% \item New commands: 3356% \begin{itemize} 3357% \item |\selectcolormodel| to change the target model within a document; 3358% \item |\adjustUCRBG| to fine-tune undercolor-removal and black-generation during conversion to \Model{cmyk}. 3359% \end{itemize} 3360% \item Bugfix: color expressions did not work correctly in connection with active `!' character, e.g., in case of |\usepackage[frenchb]babel}|. 3361% \item Code re-organisation: 3362% \begin{itemize} 3363% \item |\XC@xdefinecolor| merged into |\xdefinecolor|, making the first command obsolete; 3364% \item several internal commands improved/streamlined. 3365% \end{itemize} 3366% \end{itemize} 3367% 3368% \subsubsection*{2004/01/20 v1.07} 3369% \begin{itemize} 3370% \item New feature: support for color masking and color separation. 3371% \item New commands: 3372% \begin{itemize} 3373% \item |\rmultiply| to multiply a dimension register by a real number; 3374% \item |\xcolorcmd| to pass commands that are to be executed at the end of the package. 3375% \end{itemize} 3376% \item Changes: 3377% \begin{itemize} 3378% \item more consistent color handling: extended colors now always take precedence over standard colors; 3379% \item several commands improved by using code from the \LaTeX{} kernel. 3380% \end{itemize} 3381% \item Documentation: some minor changes. 3382% \item Example files: additional \Package{pstricks} examples (file \href{xcolor2.pdf}{\File{xcolor2.tex}}). 3383% \end{itemize} 3384% 3385% \subsubsection*{2003/12/15 v1.06} 3386% \begin{itemize} 3387% \item New feature: extended color expressions, allowing for cascaded mix operations, e.g., |\color{red!30!green!40!blue}|. 3388% \item Documentation: new section on color expressions. 3389% \item Bugfix:~color series stepping did not work correctly within non-displaying commands like |\extractcolorspec{foo!!+}| (this bug was introduced in v1.05). 3390% \item Renamed~commands:~|\ukfileversion| and similar internal constants renamed to |\XCfileversion| etc. 3391% \item Removed~commands:~|\ifXCpst| and |\ifXCtable| made obsolete by a simple trick. 3392% \end{itemize} 3393% 3394% \subsubsection*{2003/11/21 v1.05} 3395% \begin{itemize} 3396% \item Bugfixes: 3397% \begin{itemize} 3398% \item package option \Option{hideerrors} should now work as expected; 3399% \item usage of `.' in the first color expression in a document caused an error due to incorrect initialisation. 3400% \end{itemize} 3401% \item Code re-organisation: |\extractcolorspec| now uses |\XC@splitcolor|, making |\XC@extract| obsolete. 3402% \end{itemize} 3403% 3404% \subsubsection*{2003/11/09 v1.04} 3405% \begin{itemize} 3406% \item New feature: easy access to current color within color expressions. 3407% \item New option: \Option{override} to replace |\definecolor| by |\xdefinecolor|. 3408% \item New command: |\tracingcolors| for logging color-specific information. 3409% \end{itemize} 3410% 3411% \subsubsection*{2003/09/21 v1.03} 3412% \begin{itemize} 3413% \item Change: bypass strange behaviour of some drivers. 3414% \item New feature: driver-sharing with \Package{hyperref}. 3415% \end{itemize} 3416% 3417% \subsubsection*{2003/09/19 v1.02} 3418% \begin{itemize} 3419% \item Change: |\extractcolorspec| and |\colorlet| now also accept color series as arguments. 3420% \end{itemize} 3421% 3422% \subsubsection*{2003/09/15 v1.01} 3423% \begin{itemize} 3424% \item New feature: |\definecolorseries| and friends. 3425% \item Documentation: removed some \Package{doc}-related side-effects. 3426% \item Code re-organisation: all calculation-related tools put to one place. 3427% \item Bugfixes: 3428% \begin{itemize} 3429% \item |\@rdivide|: added |\relax| to fix problem with negative numerators; 3430% \item |\rowc@l@rs|: replaced |\@ifempty| by |\@ifxempty|. 3431% \end{itemize} 3432% \end{itemize} 3433% 3434% \subsubsection*{2003/09/09 v1.00} 3435% \begin{itemize} 3436% \item First published release. 3437% \end{itemize} 3438% 3439% \end{multicols} 3440% \end{adjustwidth} 3441% 3442% \StopEventually{} 3443% \clearpage 3444% 3445% \section{The Implementation} 3446% 3447% Some commands have been copied unchanged from \cite{color} (Copyright (C) 1994--1999 \People{David P.}{Carlisle}), which is part of the Standard \LaTeX{} `Graphics Bundle'. 3448% Additionally, also some parts of the code documentation were copied from \cite{color}. 3449% 3450% 3451% 3452% \subsection{Preparation} 3453% 3454% \subsubsection{File identification} 3455% 3456% \renewcommand*\MacroFont{\footnotesize\ttfamily} 3457% \renewcommand*\AltMacroFont{\footnotesize\ttfamily\slshape} 3458% 3459% \begin{macrocode} 3460%<*package> 3461% \end{macrocode} 3462% 3463% \fbox{\MacroFont\string\ProvidesPackage\string{xcolor\string}[\XCfiledate\space\XCfileversion\space LaTeX color extensions (UK)]} 3464% 3465% \begin{macrocode} 3466\NeedsTeXFormat{LaTeX2e} 3467% \end{macrocode} 3468% 3469% 3470% \subsubsection{Safety first} 3471% 3472% \begin{macro}{\XC@catcodes} 3473% Save catcodes for later restore: 3474% \begin{macrocode} 3475\expandafter\edef\csname XC@catcodes\endcsname 3476 {\catcode`\noexpand\@\the\catcode`\@\relax 3477 \catcode`\noexpand\!\the\catcode`\!\relax 3478 \catcode`\noexpand\:\the\catcode`\:\relax 3479 \catcode`\noexpand\-\the\catcode`\-\relax 3480 \catcode`\noexpand\+\the\catcode`\+\relax 3481 \catcode`\noexpand\;\the\catcode`\;\relax 3482 \catcode`\noexpand\/\the\catcode`\/\relax 3483 \catcode`\noexpand\"\the\catcode`\"\relax 3484 \catcode`\noexpand\>\the\catcode`\>\relax 3485 \catcode`\noexpand\^^A\the\catcode`\^^A\relax} 3486% \end{macrocode} 3487% \end{macro} 3488% 3489% \begin{macrocode} 3490\catcode`\@=11 3491\catcode`\!=12 3492\catcode`\:=12 3493\catcode`\-=12 3494\catcode`\+=12 3495\catcode`\;=12 3496\catcode`\/=12 3497\catcode`\"=12 3498\catcode`\>=12 3499\catcode`\^^A=\catcode`\% 3500% \end{macrocode} 3501% 3502% 3503% \subsubsection{Constants} 3504% 3505% \begin{macro}{\XC@@} 3506% Macro consisting of the macro |\\XC@@|, serves as a delimiter. 3507% \begin{macrocode} 3508\edef\XC@@{\expandafter\noexpand\csname\string\XC@@\endcsname} 3509% \end{macrocode} 3510% \end{macro} 3511% 3512% 3513% \subsubsection{Switches} 3514% 3515% \begin{macro}{\ifcolors@} 3516% This boolean can be tested by higher level macros that may want to alter their behaviour if a monochrome driver is being used. 3517% \begin{macrocode} 3518\newif\ifcolors@ \colors@true 3519% \end{macrocode} 3520% \end{macro} 3521% 3522% \begin{macro}{\ifcolorerrors@} 3523% Controls whether missing color models/names result in error or warning messages. 3524% \begin{macrocode} 3525\newif\ifcolorerrors@ 3526% \end{macrocode} 3527% \end{macro} 3528% 3529% \begin{macro}{\ifglobalcolors} 3530% Controls whether |\definecolor| and |\colorlet| generate global or local color definitions. 3531% \begin{macrocode} 3532\newif\ifglobalcolors \globalcolorsfalse 3533% \end{macrocode} 3534% \end{macro} 3535% 3536% \begin{macro}{\ifdefinecolors} 3537% Controls whether |\definecolorset| should \emph{define} or \emph{prepare} colors. 3538% \begin{macrocode} 3539\newif\ifdefinecolors \definecolorstrue 3540% \end{macrocode} 3541% \end{macro} 3542% 3543% \begin{macro}{\ifconvertcolorsD} 3544% \begin{macro}{\ifconvertcolorsU} 3545% Control whether conversion to target models take place at \emph{definition} time (|\ifconvertcolorsD|) and/or \emph{usage} (|\ifconvertcolorsU|). 3546% \begin{macrocode} 3547\newif\ifconvertcolorsD 3548\newif\ifconvertcolorsU 3549% \end{macrocode} 3550% \end{macro} 3551% \end{macro} 3552% 3553% \begin{macro}{\ifblendcolors} 3554% \begin{macro}{\ifmaskcolors} 3555% Control whether colors are to be blended and/or masked at display time. 3556% \begin{macrocode} 3557\newif\ifblendcolors 3558\newif\ifmaskcolors 3559% \end{macrocode} 3560% \end{macro} 3561% \end{macro} 3562% 3563% \begin{macro}{\ifXC@@fbox} 3564% \begin{macro}{\ifXC@@tst} 3565% Auxiliary test variables. 3566% \begin{macrocode} 3567\newif\ifXC@@fbox \XC@@fboxtrue 3568\newif\ifXC@@tst 3569% \end{macrocode} 3570% \end{macro} 3571% \end{macro} 3572% 3573% 3574% \subsubsection{Error handling} 3575% 3576% \begin{macro}{\c@lor@error} 3577% Multi-purpose error handler (issues warnings instead of errors if the \Option{hideerrors} option is used). 3578% This command is used already in the options section. 3579% \begin{macrocode} 3580\def\c@lor@error#1% 3581 {\ifcolorerrors@\PackageError{xcolor}{Undefined color #1}\@ehc 3582 \else\PackageWarning{xcolor}{Undefined color #1}\fi} 3583% \end{macrocode} 3584% \end{macro} 3585% 3586% 3587% \subsubsection{Macro concatenation} 3588% 3589% \begin{macro}{\XC@append} 3590% \marg{cmd}\marg{token list}\\ 3591% Append \Meta{token list} to the definition of \Meta{cmd}. 3592% This command is used already in the options section. 3593% \begin{macrocode} 3594\def\XC@append#1#2% 3595 {\ifx#1\@undefined\def#1{#2}\else\ifx#1\relax\def#1{#2}\else 3596 \toks@\expandafter{#1#2}\edef#1{\the\toks@}\fi\fi} 3597% \end{macrocode} 3598% \end{macro} 3599% 3600% 3601% \subsubsection{Macro definition} 3602% 3603% The following |\XC@let@..| commands mimic \LaTeX3's coding syntax for the type of arguments used: 3604% the `c' type is for brace delimited arguments which turn into a control sequence inside |\csname ... \endcsname|, whereas `N' is just a single token. 3605% Thanks to \People{Morten}{H\o gholm} for pointing me to that. 3606% 3607% \begin{macro}{\XC@let@cc} 3608% \marg{target character string}\marg{source character string}\\ 3609% Performs |\let\|\Meta{target character string}|=\|\Meta{source character string}. 3610% \begin{macrocode} 3611\def\XC@let@cc#1{\expandafter\XC@let@Nc\csname#1\endcsname} 3612% \end{macrocode} 3613% \end{macro} 3614% 3615% \begin{macro}{\@namelet} 3616% This is provided for compatibility reasons only, although deprecated because of a name clash with \Package{memoir}. 3617% \begin{macrocode} 3618\providecommand*\@namelet[1]{\expandafter\XC@let@Nc\csname#1\endcsname} 3619% \end{macrocode} 3620% \end{macro} 3621% 3622% \begin{macro}{\XC@let@Nc} 3623% \marg{target name}\marg{source character string}\\ 3624% Performs |\let|\Meta{target name}|=\|\Meta{source character string}. 3625% Formerly called |\@@namelet|. 3626% \begin{macrocode} 3627\def\XC@let@Nc#1#2{\expandafter\let\expandafter#1\csname#2\endcsname} 3628% \end{macrocode} 3629% \end{macro} 3630% 3631% \begin{macro}{\XC@let@cN} 3632% \marg{target character string}\marg{source name}\\ 3633% Performs |\let\|\Meta{target character string}|=|\Meta{source name}. 3634% \begin{macrocode} 3635\def\XC@let@cN#1{\expandafter\let\csname#1\endcsname} 3636% \end{macrocode} 3637% \end{macro} 3638% 3639% \begin{macro}{\@namexdef} 3640% \marg{character string}\marg{code}\\ 3641% Performs |\xdef\|\Meta{character string}|{|\Meta{code}|}|. 3642% Similar to the \LaTeX{} internal |\@namedef| command. 3643% \begin{macrocode} 3644\def\@namexdef#1{\expandafter\xdef\csname #1\endcsname} 3645% \end{macrocode} 3646% \end{macro} 3647% 3648% \begin{macro}{\aftergroupdef} 3649% \begin{macro}{\aftergroupedef} 3650% \marg{cmd}\marg{code}\\ 3651% Defines \meta{cmd} with the first-level or complete expansion of \meta{code} after the end of the current group. 3652% \begin{macrocode} 3653\def\aftergroupdef#1#2% 3654 {\expandafter\endgroup\expandafter\def\expandafter#1\expandafter{#2}} 3655\def\aftergroupedef#1#2% 3656 {\edef\@@tmp{\def\noexpand#1{#2}}\expandafter\endgroup\@@tmp} 3657% \end{macrocode} 3658% \end{macro} 3659% \end{macro} 3660% 3661% \begin{macro}{\XC@edef} 3662% \begin{macro}{\XC@mdef} 3663% \begin{macro}{\XC@sdef} 3664% \marg{cmd}\marg{code}\\ 3665% Defines \Meta{cmd} as a safe expansion of \Meta{code}; needed for color expressions in certain languages. 3666% The second form is a streamlined version that takes only care of active `|/|' and `|:|' characters that may occur in \Meta{model-list} and \Meta{spec-list} arguments. 3667% The third form defines a sanitized expansion without considering active characters. 3668% It is faster since it needs no grouping operation. 3669% \begin{macrocode} 3670\begingroup 3671\catcode`\!=13 \catcode`\:=13 \catcode`\-=13 \catcode`\+=13 3672\catcode`\;=13 \catcode`\/=13 \catcode`\"=13 \catcode`\>=13 3673\gdef\XC@edef#1#2% 3674 {\begingroup 3675 \ifnum\catcode`\!=13 \edef!{\string!}\fi 3676 \ifnum\catcode`\:=13 \edef:{\string:}\fi 3677 \ifnum\catcode`\-=13 \edef-{\string-}\fi 3678 \ifnum\catcode`\+=13 \edef+{\string+}\fi 3679 \ifnum\catcode`\;=13 \edef;{\string;}\fi 3680 \ifnum\catcode`\"=13 \edef"{\string"}\fi 3681 \ifnum\catcode`\>=13 \edef>{\string>}\fi 3682 \edef#1{#2}\@onelevel@sanitize#1\aftergroupdef#1#1} 3683\gdef\XC@mdef#1#2% 3684 {\begingroup 3685 \ifnum\catcode`\/=13 \edef/{\string/}\fi 3686 \ifnum\catcode`\:=13 \edef:{\string:}\fi 3687 \edef#1{#2}\@onelevel@sanitize#1\aftergroupdef#1#1} 3688\endgroup 3689\def\XC@sdef#1#2{\edef#1{#2}\@onelevel@sanitize#1} 3690% \end{macrocode} 3691% \end{macro} 3692% \end{macro} 3693% \end{macro} 3694% 3695% 3696% \subsubsection{Conditional processing} 3697% 3698% \begin{macro}{\@ifxempty} 3699% \marg{arg}\marg{empty}\marg{non-empty}\\ 3700% 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@@|. 3701% Can also be used within |\edef|. 3702% \begin{macrocode} 3703\def\@ifxempty#1{\@@ifxempty#1\@@ifxempty\XC@@} 3704\def\@@ifxempty#1#2\XC@@ 3705 {\ifx#1\@@ifxempty 3706 \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi} 3707% \end{macrocode} 3708% \end{macro} 3709% 3710% \begin{macro}{\XC@ifxcase} 3711% \marg{cmd}|{{|\Meta[1]{cmd}|}{|\Meta[1]{code}|}...{|\Meta[n]{cmd}|}{|\Meta[n]{code}|}}|\marg{default code}\\ 3712% Performs the test |\ifx|\Meta{cmd}\Meta[k]{cmd} for $k=1,\dots,n$. 3713% If for some $k$ the test is `true', then the attached code \Meta[k]{code} is executed. 3714% If all tests are `false', then \Meta{default code} is executed. 3715% \begin{macrocode} 3716\long\def\XC@ifxcase#1#2#3% 3717 {\long\def\@@tmp##1##2% 3718 {\ifx#1##1% 3719 \toks@{##2}\expandafter\remove@to@nnil\else\expandafter\@@tmp\fi}% 3720 \@@tmp#2#1{#3}\@nnil\the\toks@} 3721% \end{macrocode} 3722% \end{macro} 3723% 3724% \begin{macro}{\XC@ifcase} 3725% \marg{str}|{{|\Meta[1]{str-list}|}{|\Meta[1]{code}|}...{|\Meta[n]{str-list}|}{|\Meta[n]{code}|}}|\marg{default code}\\ 3726% Tests whether \Meta{str} appears in one of the comma-separated lists \Meta[k]{str-list}. 3727% Performs the test |\if|\Meta{str}\Meta[kl]{str} for $k=1,\dots,n$ and $l=1,\ldots,m_n$. 3728% If for some $k,l$ the test is `true', then the attached code \Meta[k]{code} is executed. 3729% If all tests are `false', then \Meta{default code} is executed. 3730% \begin{macrocode} 3731\long\def\XC@ifcase#1#2#3% 3732 {\long\def\@@tmp##1##2% 3733 {\@expandtwoargs\in@{,#1,}{,##1,}\ifin@ 3734 \toks@{##2}\expandafter\remove@to@nnil\else\expandafter\@@tmp\fi}% 3735 \@@tmp#2{#1}{#3}\@nnil\the\toks@} 3736% \end{macrocode} 3737% \end{macro} 3738% 3739% 3740% 3741% \subsection{Package options} 3742% 3743% \begin{macro}{\XC@@opt} 3744% Initialise the macro to hold the names of \emph{executed} \XCP{} options. 3745% \begin{macrocode} 3746\def\XC@@opt{,} 3747% \end{macrocode} 3748% \end{macro} 3749% 3750% \begin{macro}{\@ifXCopt} 3751% \marg{option}\marg{executed}\marg{not executed}\\ 3752% Performs action dependent on whether a specific \XCP{} option has been executed or not. 3753% \begin{macrocode} 3754\def\@ifXCopt#1% 3755 {\@expandtwoargs\in@{,#1,}{\XC@@opt}% 3756 \ifin@\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi} 3757% \end{macrocode} 3758% \end{macro} 3759% 3760% \begin{macro}{\XC@@pkg} 3761% Initialise the macro to hold the names of packages that are to be loaded by \XC. 3762% \begin{macrocode} 3763\let\XC@@pkg\relax 3764% \end{macrocode} 3765% \end{macro} 3766% 3767% \begin{macro}{\DeclareOption} 3768% |\DeclareOption| has to be redefined in order to collect every executed package option in |\XC@@opt|. 3769% This is being restored immediately before |\ProcessOptions|; thus, other packages use the original definition. 3770% \begin{macrocode} 3771\let\XC@declareoption\@declareoption 3772\long\def\@declareoption#1#2% 3773 {\XC@declareoption{#1}{\edef\XC@@opt{\XC@@opt#1,}#2}} 3774% \end{macrocode} 3775% \end{macro} 3776% 3777% 3778% \subsubsection{Color model selection} 3779% 3780% \begin{macro}{\selectcolormodel} 3781% \marg{num model}\\ 3782% Determines the target model for color definitions with |\definecolor| and friends. 3783% \begin{macrocode} 3784\def\selectcolormodel#1% 3785 {\@ifundefined{XC@mod@#1}% 3786 {\c@lor@error{target model `#1'}}% 3787 {\expandafter\ifx\csname XC@mod@#1\endcsname\XC@mod@natural 3788 \def\XC@tgt@mod##1{##1}\convertcolorsDfalse\convertcolorsUfalse 3789 \else\expandafter\ifx\csname XC@mod@#1\endcsname\XC@mod@named 3790 \c@lor@error{target model `#1'} 3791 \else 3792 \edef\XC@tgt@mod##1{#1}\convertcolorsDtrue\convertcolorsUtrue 3793 \fi\fi}} 3794% \end{macrocode} 3795% \end{macro} 3796% 3797% \begin{macro}{\XC@mod@Hsb} 3798% \begin{macro}{\XC@mod@tHsb} 3799% \begin{macro}{\XC@mod@ignore} 3800% \begin{macro}{\XC@mod@named} 3801% \begin{macro}{\XC@mod@ps} 3802% \begin{macro}{\XC@mod@wave} 3803% \begin{macro}{\XC@mod@natural} 3804% \begin{macro}{\XC@mod@rgb} 3805% \begin{macro}{\XC@mod@cmy} 3806% \begin{macro}{\XC@mod@cmyk} 3807% \begin{macro}{\XC@mod@hsb} 3808% \begin{macro}{\XC@mod@gray} 3809% \begin{macro}{\XC@mod@RGB} 3810% \begin{macro}{\XC@mod@HTML} 3811% \begin{macro}{\XC@mod@HSB} 3812% \begin{macro}{\XC@mod@Gray} 3813% Put model names into commands and define package options 3814% \Option{natural}, \Option{rgb}, \Option{cmy}, \Option{cmyk}, \Option{hsb}, \Option{gray}, \Option{RGB}, \Option{HTML}, \Option{HSB}, \Option{Gray}. 3815% \begin{macrocode} 3816\@tfor\@@tmp:={Hsb}{tHsb}{ignore}{named}{ps}{wave}\do 3817 {\expandafter\XC@sdef\csname XC@mod@\@@tmp\endcsname{\@@tmp}} 3818% \end{macrocode} 3819% 3820% \begin{macrocode} 3821\@tfor\@@tmp:={natural}{rgb}{cmy}{cmyk}{hsb}{gray}{RGB}{HTML}{HSB}{Gray}\do 3822 {\expandafter\XC@sdef\csname XC@mod@\@@tmp\endcsname{\@@tmp}% 3823 \edef\@@tmp 3824 {\noexpand\DeclareOption{\@@tmp}{\noexpand\selectcolormodel{\@@tmp}}}% 3825 \@@tmp} 3826% \end{macrocode} 3827% \end{macro} 3828% \end{macro} 3829% \end{macro} 3830% \end{macro} 3831% \end{macro} 3832% \end{macro} 3833% \end{macro} 3834% \end{macro} 3835% \end{macro} 3836% \end{macro} 3837% \end{macro} 3838% \end{macro} 3839% \end{macro} 3840% \end{macro} 3841% \end{macro} 3842% \end{macro} 3843% 3844% The \Option{monochrome} option should be used \emph{in addition} to one of the standard driver options. 3845% \begin{macrocode} 3846\DeclareOption{monochrome} 3847 {\ExecuteOptions{hideerrors}% 3848 \AtEndOfPackage 3849 {\colors@false 3850 \def\set@color{\c@lor@special\m@ne 3851 {color push \current@color}\aftergroup\reset@color}% 3852 \def\reset@color{\c@lor@special\m@ne{color pop}}% 3853 \def\set@page@color{\c@lor@special\m@ne{background \current@color}}}} 3854% \end{macrocode} 3855% 3856% 3857% \subsubsection{Sets of predefined colors} 3858% 3859% \begin{macro}{\XC@@names} 3860% Initialise the macro to hold the names of files that contain predefined colors; these files are loaded near to the end of this package. 3861% \begin{macrocode} 3862\let\XC@@names\relax 3863% \end{macrocode} 3864% \end{macro} 3865% 3866% \begin{macro}{\colornameprefix} 3867% \begin{macro}{\XC@@nameprefix} 3868% Initialise the macro to hold the string that is prefixed to driver-specific color names. 3869% Save the value for later restore. 3870% \begin{macrocode} 3871\providecommand*\colornameprefix{XC@} 3872\let\XC@@nameprefix\colornameprefix 3873% \end{macrocode} 3874% \end{macro} 3875% \end{macro} 3876% 3877% \begin{macro}{\XC@declarenames} 3878% \marg{base name}\marg{file name}\marg{initial commands}\\ 3879% Construct package options for color names. 3880% \begin{macrocode} 3881\def\XC@declarenames#1#2#3% 3882 {\DeclareOption{#1}{\XC@append\XC@@names 3883 {#3\definecolorstrue\input{#2.def}\definecolorstrue 3884 \let\colornameprefix\XC@@nameprefix}} 3885 \DeclareOption{#1*}{\XC@append\XC@@names 3886 {#3\definecolorsfalse\input{#2.def}\definecolorstrue 3887 \let\colornameprefix\XC@@nameprefix}}} 3888% \end{macrocode} 3889% \end{macro} 3890% 3891% \begin{macrocode} 3892\XC@declarenames{dvipsnames}{dvipsnam}{\let\colornameprefix\@empty} 3893\XC@declarenames{svgnames}{svgnam}{} 3894\XC@declarenames{x11names}{x11nam}{} 3895\XC@declarenames{hksnames}% 3896 {hks\ifcase\paperquality k\or n\or k\or z\else n\fi nam}{} 3897\XC@declarenames{pmsnames}{pmsnam}{} 3898\XC@declarenames{ralnames}{ralnam}{} 3899% \end{macrocode} 3900% 3901% 3902% \subsubsection{Support for other packages} 3903% 3904% Use this option to load \People{David P.}{Carlisle}'s \Package{colortbl} package: 3905% \begin{macrocode} 3906\DeclareOption{table}{\XC@append\XC@@pkg{\RequirePackage{colortbl}}} 3907% \end{macrocode} 3908% 3909% Use this option to load \People{Heiko}{Oberdiek}'s \Package{pdfcolmk} package: 3910% \begin{macrocode} 3911\DeclareOption{fixpdftex}{\XC@append\XC@@pkg{\RequirePackage{pdfcolmk}}} 3912% \end{macrocode} 3913% 3914% Use this option to load \People{David P.}{Carlisle}'s \Package{pstcol} package in order to make standard color definitions available within \Package{pstricks}. 3915% Warning: this option is neither needed nor useful with recent \Package{pstricks} versions. 3916% \begin{macrocode} 3917\DeclareOption{pst}{\def\XC@pst{\RequirePackage{pstcol}}} 3918% \end{macrocode} 3919% 3920% \begin{macro}{\KV@Hyp@xcitebordercolor} 3921% \begin{macro}{\KV@Hyp@xfilebordercolor} 3922% \begin{macro}{\KV@Hyp@xlinkbordercolor} 3923% \begin{macro}{\KV@Hyp@xmenubordercolor} 3924% \begin{macro}{\KV@Hyp@xpagebordercolor} 3925% \begin{macro}{\KV@Hyp@xrunbordercolor} 3926% \begin{macro}{\KV@Hyp@xurlbordercolor} 3927% \begin{macro}{\KV@Hyp@xpdfborder} 3928% Use this option to define the extended keys for the \Package{hyperref} package. 3929% \begin{macrocode} 3930\DeclareOption{hyperref} 3931 {\@tfor\@@tmp:={cite}{file}{link}{menu}{page}{run}{url}\do 3932 {\expandafter\edef\csname KV@Hyp@x\@@tmp bordercolor\endcsname #1% 3933 {\noexpand\XC@bordercolor{\@@tmp}{#1}}}% 3934 \AtEndOfPackage 3935 {\GetGinDriver\def\KV@Hyp@xpdfborder#1{\edef\@pdfborder{#1}}% 3936 \@tfor\@@tmp:={dvips}\do 3937 {\ifx\GinDriver\@@tmp 3938 \def\KV@Hyp@xpdfborder#1% 3939 {\edef\@pdfborder{#1}\expandafter\XC@pdfborder\@pdfborder\relax}% 3940 \@break@tfor\fi}}} 3941% \end{macrocode} 3942% \end{macro} 3943% \end{macro} 3944% \end{macro} 3945% \end{macro} 3946% \end{macro} 3947% \end{macro} 3948% \end{macro} 3949% \end{macro} 3950% 3951% 3952% \subsubsection{Driver options} 3953% 3954% \begin{macro}{\Gin@driver} 3955% Initialise the macro to hold the driver file name. 3956% \begin{macrocode} 3957\providecommand*\Gin@driver{} 3958% \end{macrocode} 3959% 3960% Drivers that come with their individual definition files: 3961% \begin{macrocode} 3962\@tfor\@@tmp:={dvipdf}{dvipdfm}{dvipdfmx}{dvips}{dvipsone}{dviwin}% 3963 {emtex}{pctex32}{pctexhp}{pctexps}{pctexwin}{pdftex}% 3964 {tcidvi}{textures}{truetex}{vtex}{xetex}\do 3965 {\edef\@@tmp{\noexpand\DeclareOption{\@@tmp}% 3966 {\def\noexpand\Gin@driver{\@@tmp.def}}}% 3967 \@@tmp} 3968% \end{macrocode} 3969% 3970% Drivers that are derivatives of others: 3971% \begin{macrocode} 3972\DeclareOption{dviwindo}{\ExecuteOptions{dvipsone}} 3973\DeclareOption{oztex}{\ExecuteOptions{dvips}} 3974\DeclareOption{xdvi}{\ExecuteOptions{dvips,monochrome}} 3975% \end{macrocode} 3976% 3977% Options used by (some) drivers. 3978% \begin{macrocode} 3979\DeclareOption{xcdraw}{\def\XC@@xcd@{1}} 3980\DeclareOption{noxcdraw}{\def\XC@@xcd@{-1}} 3981\DeclareOption{prologue}{\def\XC@@xcp@{1}} 3982% \end{macrocode} 3983% \end{macro} 3984% 3985% 3986% \subsubsection{Other options} 3987% 3988% Switch to original kernel |\fbox| command instead of new \XC{} version. 3989% \begin{macrocode} 3990\DeclareOption{kernelfbox}{\XC@@fboxfalse} 3991% \end{macrocode} 3992% 3993% These options control how non-existing colors are treated: 3994% \begin{macrocode} 3995\DeclareOption{showerrors}{\colorerrors@true} 3996\DeclareOption{hideerrors}{\colorerrors@false} 3997% \end{macrocode} 3998% 3999% The \Option{debugshow} option turns on debugging info (perhaps). 4000% \begin{macrocode} 4001\DeclareOption{debugshow}{\catcode`\^^A=9 \let\GDebug\typeout} 4002% \end{macrocode} 4003% 4004% All other options (including \LC's \Option{usenames}, \Option{nodvipsnames}) are being ignored. 4005% \begin{macrocode} 4006\DeclareOption*% 4007 {\PackageInfo{xcolor}{Package option `\CurrentOption' ignored}} 4008% \end{macrocode} 4009% 4010% Choose default options: 4011% \begin{macrocode} 4012\def\XC@@xcd@{-1} 4013\def\XC@@xcp@{-1} 4014\ExecuteOptions{natural,showerrors} 4015% \end{macrocode} 4016% 4017% 4018% \subsubsection{Processing options} 4019% 4020% A local configuration file may declare more options. 4021% It should also make one driver option the default, by calling |\ExecuteOptions| with the appropriate option. 4022% \begin{macrocode} 4023\InputIfFileExists{color.cfg}{}{} 4024% \end{macrocode} 4025% 4026% After the options are processed, load the appropriate driver file. 4027% If a site wants a default driver (e.g., \Option{dvips}) it just needs to put |\ExecuteOptions{dvips}| in a \File{color.cfg} file. 4028% \begin{macrocode} 4029\let\@declareoption\XC@declareoption 4030\ProcessOptions\relax 4031% \end{macrocode} 4032% 4033% \begin{macro}{\XC@@drv} 4034% Holds the name of the loaded driver (without \File{.def} extension). 4035% \begin{macrocode} 4036\edef\Gin@driver{\Gin@driver} 4037\if!\Gin@driver! 4038 \PackageError{xcolor} 4039 {No driver specified} 4040 {You should make a default driver option in a file \MessageBreak 4041 color.cfg\MessageBreak 4042 eg: \protect\ExecuteOptions{dvips}} 4043\else 4044 \PackageInfo{xcolor}{Driver file: \Gin@driver} 4045 \@ifundefined{ver@\Gin@driver}{\input{\Gin@driver}}{} 4046 \def\@@tmp#1.def{\def\XC@@drv{#1}} 4047 \expandafter\@@tmp\Gin@driver 4048\fi 4049% \end{macrocode} 4050% \end{macro} 4051% 4052% \begin{macro}{\XC@@xcd@} 4053% \begin{macro}{\XC@@xcp@} 4054% These are used firstly by the \Option{xcdraw} and \Option{prologue} options, indicating whether either option is swithed on or off. 4055% Secondly, the macros serve as test variables for |\ifcase| expressions, storing the intended type of output: $-1=\text{dvi}, 0=\text{ps}, 1=\text{pdf}$. 4056% \begin{macrocode} 4057\count@\XC@@xcd@ \advance\count@\XC@@xcp@\relax 4058\ifnum\count@>-2 4059% \end{macrocode} 4060% 4061% \begin{macro}{\XC@special} 4062% \meta{code}\\ 4063% Driver-specific variant of |\special|. 4064% Even if the intended type of output is the same (e.g., pdf), the |\special| commands may differ. 4065% \begin{macrocode} 4066 \XC@ifcase\XC@@drv 4067 {{dvips,pctex32}% 4068 {\def\@tempa{0} 4069 \def\XC@special#1{\special{ps:XC!b}\special{"#1}\special{ps:XC!e}}}% 4070 {pdftex}% 4071 {\def\@tempa{1} 4072 \def\XC@special#1{\pdfliteral{ q #1 Q }}}% 4073 {dvipdfm}% 4074 {\def\@tempa{1} 4075 \def\XC@special#1{\special{pdf: content #1}}}% 4076 }{\def\@tempa{-1}} 4077% \end{macrocode} 4078% 4079% Since the options are independent of each other, we have to adjust the affiliated test variables independently as well. 4080% \begin{macrocode} 4081 \ifnum\XC@@xcd@>\m@ne\let\XC@@xcd@\@tempa\fi 4082 \ifnum\XC@@xcp@>\m@ne\let\XC@@xcp@\@tempa\fi 4083% \end{macrocode} 4084% \end{macro} 4085% 4086% File variable for prologue output. 4087% \begin{macrocode} 4088 \ifnum\@tempa=0 \AtBeginDvi{\special{header=xcolor.pro}}\fi 4089 \ifcase\XC@@xcp@ 4090 \AtBeginDvi{\special{header=\jobname.xcp}} 4091 \newwrite\XC@@xcp\immediate\openout\XC@@xcp=\jobname.xcp 4092 \immediate\write\XC@@xcp{\@percentchar!} 4093 \immediate\write\XC@@xcp{TeXDict begin} 4094 \AtEndDocument 4095 {\immediate\write\XC@@xcp{end}\immediate\closeout\XC@@xcp} 4096 \fi 4097% \end{macrocode} 4098% 4099% End of driver-specific part. 4100% \begin{macrocode} 4101\fi 4102% \end{macrocode} 4103% \end{macro} 4104% \end{macro} 4105% 4106% 4107% \subsubsection{Required packages} 4108% 4109% The --- obsolete --- package \Package{pstcol} needs the real \LCP; all other packages receive a pretended \LC. 4110% \begin{macrocode} 4111\@nameuse{XC@pst} 4112\@namedef{ver@color.sty}{1999/02/16} 4113\XC@@pkg 4114% \end{macrocode} 4115% 4116% 4117% \subsection{Macro tools} 4118% 4119% \subsubsection{General tools} 4120% 4121% \begin{macro}{\@secondoffive} 4122% \begin{macro}{\@thirdoffive} 4123% Argument grabbing, similar to \LaTeX{} kernel. 4124% \begin{macrocode} 4125\long\def\@secondoffive#1#2#3#4#5{#2} 4126\long\def\@thirdoffive#1#2#3#4#5{#3} 4127% \end{macrocode} 4128% \end{macro} 4129% \end{macro} 4130% 4131% \begin{macro}{\xglobal} 4132% \begin{macro}{\xglobal@test} 4133% 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. 4134% |\foo| is responsible for resetting |\xglobal@false| in order to avoid side effects. 4135% To include |\foo| in the magic list, simply say |\XC@append\xglobal@list{\foo}|. 4136% If |\foo| is not in the list, |\xglobal\foo| will behave like |\global\foo|, thus |\xglobal\let| will be like |\global\let| etc. 4137% \begin{macrocode} 4138\def\xglobal{\xglobal@stop\begingroup\futurelet\@@tok\xglobal@test} 4139% \end{macrocode} 4140% 4141% \begin{macrocode} 4142\def\xglobal@test 4143 {\expandafter\@tfor\expandafter\@@tmp 4144 \expandafter:\expandafter=\xglobal@list\do 4145 {\expandafter\ifx\@@tmp\@@tok 4146 \aftergroup\let\aftergroup\xglobal@\@break@tfor\fi}% 4147 \endgroup\global} 4148% \end{macrocode} 4149% \end{macro} 4150% \end{macro} 4151% 4152% \begin{macro}{\xglobal@stop} 4153% Resetting |\xglobal@|. 4154% \begin{macrocode} 4155\def\xglobal@stop{\let\xglobal@\@empty} 4156\xglobal@stop 4157% \end{macrocode} 4158% \end{macro} 4159% 4160% \begin{macro}{\xglobal@list} 4161% Initial list of commands that may be prefixed by |\xglobal|. 4162% \begin{macrocode} 4163\def\xglobal@list 4164 {\definecolor\definecolors\definecolorset\colorlet\providecolor 4165 \providecolors\providecolorset\blendcolors\maskcolors 4166 \substitutecolormodel} 4167% \end{macrocode} 4168% \end{macro} 4169% 4170% \begin{macro}{\xglobalize@} 4171% Globalisation command: makes a local definition global. 4172% \begin{macrocode} 4173\def\xglobalize@#1{\ifx\xglobal@\global\global\let#1#1\fi} 4174% \end{macrocode} 4175% \end{macro} 4176% 4177% \begin{macro}{\GetGinDriver} 4178% Transforms the chosen driver option ready for \Package{hyperref}. 4179% \begin{macrocode} 4180\def\GetGinDriver 4181 {\@tempswafalse 4182 \@tfor\@@tmp:={dvips}{pdftex}{dvipdf}{dvipdfm}{dvipsone}{vtex}{textures}% 4183 \do{\ifx\XC@@drv\@@tmp\@tempswatrue\@break@tfor\fi}% 4184 \edef\GinDriver{\if@tempswa\XC@@drv\else hypertex\fi}} 4185% \end{macrocode} 4186% \end{macro} 4187% 4188% 4189% \subsubsection{String manipulation} 4190% 4191% \begin{macro}{\@hex@Hex} 4192% \Meta{hex-string}|\relax|\\ 4193% Converts \Meta{hex-string} to a string where all letters a--f are changed into their uppercase variants. 4194% All other letters are left unchanged. 4195% May be used inside |\edef|. 4196% \begin{macrocode} 4197\def\@hex@Hex#1{\ifx#1\relax\else\expandafter\@hex@@Hex\expandafter#1\fi} 4198\def\@hex@@Hex#1% 4199 {\if a#1A\else \if b#1B\else \if c#1C\else \if d#1D\else 4200 \if e#1E\else \if f#1f\else #1\fi\fi\fi\fi\fi\fi \@hex@Hex} 4201% \end{macrocode} 4202% \end{macro} 4203% 4204% \begin{macro}{\XC@strip@comma} 4205% \Meta[1]{string}|,|\Meta[2]{string}|,...,|\Meta[n]{string}|,,\@nnil|\\ 4206% Converts a comma-separated list into a space-separated list. 4207% The evaluation stops at the first empty argument, skipping all remaining tokens until (and including) |\@nnil|. 4208% Thus, the list to be converted should always contain at least one |,,| sequence. 4209% May be used inside |\edef|. 4210% \begin{macrocode} 4211\def\XC@strip@comma#1,#2% 4212 {\ifx,#2% 4213 #1\expandafter\remove@to@nnil\else#1 \expandafter\XC@strip@comma\fi 4214 #2} 4215% \end{macrocode} 4216% \end{macro} 4217% 4218% \begin{macro}{\XC@replace} 4219% \marg{cmd}\marg{search}\marg{replace}\\ 4220% Replace all occurences of \meta{search} within the first-level expansion of \meta{cmd} by \meta{replace} and save the result in \meta{cmd}. 4221% The replacement is recursive, so don't put the search pattern into the replacement text! 4222% Note that this macro is incapable of seeing `into' braces. 4223% The code and its explanation is taken from \People{Donald}{Arseneau}'s \Package{url} package \cite{url}, with only minor changes and renamings applied. 4224% The original name of the game is |\Url@Edit|. 4225% Thanks to \People{Donald}{Arseneau} for giving me valuable hints. 4226% \begin{macrocode} 4227{\catcode`Q=3 4228 \gdef\XC@replace#1#2#3% 4229 {\begingroup 4230% \end{macrocode} 4231% 4232% If finished, then remove |\@empty|'s and redefine macro else, re-iterate. 4233% \begin{macrocode} 4234 \def\XC@repl@ce##1#2##2Q##3% 4235 {\@ifxempty{##2}{\XC@r@pl@ce##1Q}{\XC@repl@ce##1##3##2Q{##3}}}% 4236 \def\XC@r@pl@ce##1\@empty Q% 4237 {\expandafter\endgroup\expandafter\def\expandafter#1\expandafter{##1}}% 4238% \end{macrocode} 4239% 4240% The leading |\@empty| preserves braces, as does the trailing pattern. 4241% \begin{macrocode} 4242 \expandafter\XC@repl@ce\expandafter\@empty #1\@empty#2Q{#3}} 4243} 4244% \end{macrocode} 4245% \end{macro} 4246% 4247% \begin{macro}{\XC@clean} 4248% \marg{cmd}\\ 4249% Makes a proper comma-separated list from \meta{cmd}'s contents and stores it again in \meta{cmd}. 4250% Firstly, all commas are changed into spaces, secondly, spaces are turned into commas (using a technique similar to \LaTeX's |\zap@space|). 4251% Thirdly, the two leading commas are gobbled. 4252% For example, `| 1 2 , 3 |' is mapped to `|1,2,3|'. 4253% \begin{macrocode} 4254\def\XC@clean#1% 4255 {\edef#1{ #1 }\edef#1{\expandafter\XC@strip@comma#1,,\@nnil}% 4256 \edef#1{\expandafter\XC@cle@n#1\@empty}% 4257 \edef#1{\expandafter\@gobbletwo#1}} 4258\def\XC@cle@n#1 #2{,#1\ifx#2\@empty\else\expandafter\XC@cle@n\fi#2} 4259% \end{macrocode} 4260% \end{macro} 4261% 4262% 4263% \subsubsection{Scalar arithmetic} 4264% 4265% \begin{macro}{\rdivide} 4266% \marg{dimension register}\marg{div}\\ 4267% 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}. 4268% The denominator \Meta{div} is assumed to be non-zero. 4269% \begin{macrocode} 4270\def\rdivide#1#2% 4271 {\begingroup\toks@{#1}\edef\@@tmp{\noexpand\@tempdima\the#1}% 4272 \@defaultunits\@tempdimb=#2pt\relax\@nnil \@@tmp\relax 4273 \ifdim\@tempdima<\z@ \@tempdima-\@tempdima\def\@sign{-}\else 4274 \def\@sign{}\fi 4275 \ifdim\@tempdimb<\z@ \@tempdimb-\@tempdimb\edef\@sign{\@sign-}\fi 4276 \ifdim\@tempdima<.1\maxdimen \ifdim\@tempdimb<.01\maxdimen 4277 \lshift\@tempdima \lshift\@tempdimb \fi\fi 4278 \@tempcnta=\@tempdima \@tempcntb=\@tempdimb 4279 \count@=\@tempcnta \divide\count@\@tempcntb 4280 \edef\@@tmp{\number\count@.}% 4281 \@tempswatrue \@rdivide \@rdivide \@rdivide \@rdivide \@rdivide 4282 \@tempswafalse \@rdivide 4283 \dimen@\@@tmp\p@ \ifnum\count@>4\advance\dimen@1sp\fi 4284 \dimen@\@sign\dimen@ 4285 \edef\@@tmp{\the\toks@\the\dimen@}% 4286 \expandafter\endgroup\@@tmp} 4287% \end{macrocode} 4288% 4289% \begin{macrocode} 4290\def\@rdivide 4291 {\multiply\count@\@tempcntb \advance\@tempcnta-\count@ 4292 \multiply\@tempcnta10 \count@=\@tempcnta \divide\count@\@tempcntb 4293 \if@tempswa\edef\@@tmp{\@@tmp\number\count@}\fi} 4294% \end{macrocode} 4295% \end{macro} 4296% 4297% \begin{macro}{\rmultiply} 4298% \marg{dimension register}\marg{dec}\\ 4299% Multiplies \Meta{dimension register} by \Meta{dec} and stores the resulting dimension in \Meta{dimension register}. 4300% \begin{macrocode} 4301\def\rmultiply#1#2% 4302 {\begingroup 4303 \edef\@@mul{#2}\@tempdima\the#1\relax 4304 \afterassignment\@tempdimb\@tempcntb=\@@mul\p@ 4305 \ifdim\@tempdima<\z@ \@tempdima-\@tempdima\def\@sign{-}\else 4306 \def\@sign{}\fi 4307 \ifnum\@tempcntb<\z@ \@tempcntb-\@tempcntb\edef\@sign{\@sign-}\fi 4308 \lshift\@tempdima \dimen@\z@ 4309 \expandafter\@rmultiply\@@mul.0.\@nil 4310 \advance\dimen@\@tempcntb\@tempdima \rshift\dimen@ 4311 \dimen@\@sign\dimen@ 4312 \edef\@@tmp{#1\the\dimen@}% 4313 \expandafter\endgroup\@@tmp} 4314% \end{macrocode} 4315% 4316% \begin{macrocode} 4317\def\@rmultiply#1.#2.#3\@nil 4318 {\def\@@tmp{}% 4319 \@tfor\@@mul:=#2\do 4320 {\edef\@@tmp 4321 {\advance\dimen@\@@mul\@tempdima \divide\dimen@10 \@@tmp}}% 4322 \@@tmp} 4323% \end{macrocode} 4324% \end{macro} 4325% 4326% \begin{macro}{\lshift} 4327% \begin{macro}{\llshift} 4328% \marg{dimension register}\\ 4329% Multiplies \Meta{dimension register} safely by 10 resp. 100. 4330% \begin{macrocode} 4331\def\lshift#1{#1\expandafter\lshift@\the#1} 4332\def\llshift#1{\lshift#1\lshift#1} 4333% \end{macrocode} 4334% \end{macro} 4335% \end{macro} 4336% 4337% \begin{macro}{\lshiftnum} 4338% \begin{macro}{\llshiftnum} 4339% \marg{decimal number}\\ 4340% Multiplies \Meta{decimal number} by 10 resp. 100. 4341% \begin{macrocode} 4342\def\lshiftnum#1{\expandafter\lshiftnum@#1.00.:} 4343\def\lshiftnum@#1.#2#3.#4:{#1#2\ifnum0#3>\z@.#3\fi} 4344\def\llshiftnum#1{\expandafter\llshiftnum@#1\@empty.00.:} 4345\def\llshiftnum@#1.#2#3#4.#5:% 4346 {#1#2\ifnum0#3>\z@#3\else0\fi\ifnum0#4>\z@.#4\fi} 4347% \end{macrocode} 4348% \end{macro} 4349% \end{macro} 4350% 4351% \begin{macro}{\lshiftset} 4352% \begin{macro}{\llshiftset} 4353% \marg{dimension register}\marg{decimal number}\\ 4354% Multiplies \Meta{decimal number} by 10 resp. 100 and puts it into \Meta{dimension register}. 4355% \begin{macrocode} 4356\def\lshiftset#1#2{\edef\@@XC{\noexpand\lshiftnum{#2}}#1\@@XC\p@} 4357\def\llshiftset#1#2{\edef\@@XC{\noexpand\llshiftnum{#2}}#1\@@XC\p@} 4358% \end{macrocode} 4359% \end{macro} 4360% \end{macro} 4361% 4362% \begin{macro}{\rshift} 4363% \begin{macro}{\rrshift} 4364% \marg{dimension register}\\ 4365% Divides \Meta{dimension register} safely by 10 resp. 100. 4366% \begin{macrocode} 4367\def\rshift#1{#1\expandafter\rshift@\the#1} 4368\def\rrshift#1{\rshift#1\rshift#1} 4369% \end{macrocode} 4370% \end{macro} 4371% \end{macro} 4372% 4373% \begin{macro}{\lshift} 4374% \begin{macro}{\llshift} 4375% \marg{dec}\\ 4376% Multiplies \Meta{dec}, which may be either a number or something like |\the\dimen@|, safely by 10 resp. 100. 4377% The following definitions are similar to the way how |\strip@pt| is defined in the \LaTeX{} kernel. 4378% \begin{macrocode} 4379\begingroup 4380\catcode`P=12 4381\catcode`T=12 4382\lowercase 4383 {\def\@@tmp{\def\lshift@##1.##2##3PT{##1##2\ifnum0##3>\z@.##3\fi\p@} 4384 \def\rshift@##1.##2PT{\rshift@@##1\relax##2\p@}}} 4385\expandafter\endgroup\@@tmp 4386% \end{macrocode} 4387% \end{macro} 4388% \end{macro} 4389% 4390% \begin{macrocode} 4391\def\rshift@@#1#2% 4392 {\ifx#2\relax.#1\else#1\expandafter\rshift@@\expandafter#2\fi} 4393% \end{macrocode} 4394% 4395% 4396% \subsubsection{Vector arithmetic} 4397% 4398% \begin{macro}{\XC@inflate} 4399% \marg{core model}\marg{first}\marg{second}\marg{cmd}\\ 4400% 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}). 4401% The resulting vector is stored in \Meta{cmd}. 4402% \begin{macrocode} 4403\def\XC@inflate#1#2#3#4% 4404 {\edef#4{#2,\ifx#1\XC@mod@cmyk #3\else 4405 \ifx#1\XC@mod@gray ,,,#3,,,\else ,#3,\fi\fi}} 4406% \end{macrocode} 4407% \end{macro} 4408% 4409% \begin{macro}{\XC@vec} 4410% \Meta{a}|,|\Meta{b}|,|\Meta{c}|,|\Meta{d}|,|\Meta{a'}|,|\Meta{b'}|,|\Meta{c'}|,|\Meta{d'}|,|\marg{cmd}\\ 4411% Generic vector calculation for two vectors (of common dimension $1,3,4$), puts the result into \Meta{cmd}. 4412% \begin{macrocode} 4413\def\XC@vec#1,#2,#3,#4,#5,#6,#7,#8,#9% 4414 {\def\@@tmp{}% 4415 \XC@vec@{#1}{#5}% 4416 \ifx,#2,\else 4417 \XC@vec@{#2}{#6}\XC@vec@{#3}{#7}\ifx,#4,\else\XC@vec@{#4}{#8}\fi\fi 4418 \aftergroupdef#9\@@tmp} 4419% \end{macrocode} 4420% 4421% \begin{macrocode} 4422\def\XC@vec@@{\edef\@@tmp{\ifx\@@tmp\@empty\else\@@tmp,\fi\strip@pt\dimen@}} 4423% \end{macrocode} 4424% \end{macro} 4425% 4426% \begin{macro}{\XC@add} 4427% \Meta{a}|,|\Meta{b}|,|\Meta{c}|,|\Meta{d}|,|\Meta{a'}|,|\Meta{b'}|,|\Meta{c'}|,|\Meta{d'}|,|\marg{cmd}\\ 4428% Calculates the sum of two vectors (of common dimension $1,3,4$) and puts it into \Meta{cmd}. 4429% \begin{macrocode} 4430\def\XC@add{\begingroup \let\XC@vec@\XC@add@ \XC@vec} 4431% \end{macrocode} 4432% 4433% \begin{macrocode} 4434\def\XC@add@#1#2% 4435 {\llshiftset\dimen@{#1}\llshiftset\@tempdima{#2}% 4436 \advance\dimen@\@tempdima \rrshift\dimen@ \XC@vec@@} 4437% \end{macrocode} 4438% \end{macro} 4439% 4440% \begin{macro}{\XC@sub} 4441% \Meta{a}|,|\Meta{b}|,|\Meta{c}|,|\Meta{d}|,|\Meta{a'}|,|\Meta{b'}|,|\Meta{c'}|,|\Meta{d'}|,|\marg{cmd}\\ 4442% Calculates the difference of two vectors (of common dimension $1,3,4$) and puts it into \Meta{cmd}. 4443% \begin{macrocode} 4444\def\XC@sub{\begingroup \let\XC@vec@\XC@sub@ \XC@vec} 4445% \end{macrocode} 4446% 4447% \begin{macrocode} 4448\def\XC@sub@#1#2{\XC@add@{#1}{-#2}} 4449% \end{macrocode} 4450% \end{macro} 4451% 4452% \begin{macro}{\XC@mul} 4453% \Meta{a}|,|\Meta{b}|,|\Meta{c}|,|\Meta{d}|,|\Meta{a'}|,|\Meta{b'}|,|\Meta{c'}|,|\Meta{d'}|,|\marg{cmd}\\ 4454% Calculates the (component-wise) product of two vectors (of common dimension $1,3,4$) and puts it into \Meta{cmd}. 4455% \begin{macrocode} 4456\def\XC@mul{\begingroup \let\XC@vec@\XC@mul@ \XC@vec} 4457% \end{macrocode} 4458% 4459% \begin{macrocode} 4460\def\XC@mul@#1#2% 4461 {\llshiftset\dimen@{#1}\rmultiply\dimen@{#2}\rrshift\dimen@ \XC@vec@@} 4462% \end{macrocode} 4463% \end{macro} 4464% 4465% \begin{macro}{\XC@mix} 4466% \Meta{a}|,|\Meta{b}|,|\Meta{c}|,|\Meta{d}|,|\Meta{a'}|,|\Meta{b'}|,|\Meta{c'}|,|\Meta{d'}|,|\marg{cmd}\\ 4467% Calculates the linear interpolation of two color parameter vectors and puts it into \Meta{cmd}. 4468% The percentage parameter $p$ is input via register |\dimen@|. 4469% \begin{macrocode} 4470\def\XC@mix% 4471 {\begingroup 4472 \@tempdima\dimen@ \@tempdimb100\p@ \advance\@tempdimb-\@tempdima 4473 \let\XC@vec@\XC@mix@ \XC@vec} 4474% \end{macrocode} 4475% 4476% \begin{macrocode} 4477\def\XC@mix@#1#2% 4478 {\dimen@#1\@tempdima \advance\dimen@#2\@tempdimb \rrshift\dimen@ \XC@vec@@} 4479% \end{macrocode} 4480% \end{macro} 4481% 4482% 4483% \begin{macro}{\XC@calc@} 4484% \Meta{x}|,|\Meta{y}|,|\Meta{z}|,|\Meta{w}|,|\Meta{dummy}|:|\marg{function}\\ 4485% 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}. 4486% \begin{macrocode} 4487\def\XC@calc@#1,#2,#3,#4,#5:#6% 4488 {\XC@let@Nc\@@cmd{XC@calc#6}\@@cmd{#1}\@@tmp 4489 \ifx,#2,\else 4490 \@@cmd{#2}\@tempa\@@cmd{#3}\@tempb 4491 \ifx,#4,% 4492 \edef\@@tmp{\@@tmp,\@tempa,\@tempb}\else 4493 \@@cmd{#4}\@tempc\edef\@@tmp{\@@tmp,\@tempa,\@tempb,\@tempc}\fi\fi} 4494% \end{macrocode} 4495% \end{macro} 4496% 4497% \begin{macro}{\XC@calcC} 4498% \marg{x}\marg{cmd}\\ 4499% \textbf Complement of $x$: performs |\def|\Meta{cmd}|{|$1-x$|}|. 4500% Yields exact results for all numbers within $[0,1]$ with 5 decimal digits. 4501% \begin{macrocode} 4502\def\XC@calcC#1#2% 4503 {\llshiftset\dimen@{-#1}\advance\dimen@100\p@ 4504 \rrshift\dimen@ \XC@calcN{\strip@pt\dimen@}#2} 4505% \end{macrocode} 4506% \end{macro} 4507% 4508% \begin{macro}{\XC@calcD} 4509% \marg{x}\marg{cmd}\\ 4510% \textbf Division of $x$ by $s$: performs |\def|\Meta{cmd}|{|$x/s$|}|. 4511% The parameter $s$ is input via |\@@scl|. 4512% \begin{macrocode} 4513\def\XC@calcD{\XC@c@lcD\@@scl{}} 4514% \end{macrocode} 4515% \end{macro} 4516% 4517% \begin{macro}{\XC@c@lcD} 4518% \marg{s}\marg{string}\marg{x}\marg{cmd}\\ 4519% \textbf Division of $x$ by $s$, appending \Meta{string}: performs |\def|\Meta{cmd}|{|$x/s$\Meta{string}|}|. 4520% \begin{macrocode} 4521\def\XC@c@lcD#1#2#3#4% 4522 {\dimen@#3\p@ \rdivide\dimen@{#1}\edef#4{\strip@pt\dimen@#2}} 4523% \end{macrocode} 4524% \end{macro} 4525% 4526% \begin{macro}{\XC@calcF} 4527% \marg{x}\marg{cmd}\\ 4528% \textbf Format $x$ with 5 decimals, no range checks. 4529% \begin{macrocode} 4530\def\XC@calcF#1#2% 4531 {\edef#2{#1}\expandafter\XC@c@lcF#2.0.:#2} 4532% \end{macrocode} 4533% 4534% Special treatment of integer part because of so many possible variations ($---.0$, $7$, \dots). 4535% \begin{macrocode} 4536\def\XC@c@lcF#1.#2.#3:#4% 4537 {\edef#4{\XC@c@@cR#200000:}% 4538 \dimen@#1.5\p@ \afterassignment\dimen@\count@=\the\dimen@ 4539 \edef#4% 4540 {\ifnum#4>0 \ifnum\count@=0 \ifdim#1.5\p@<\z@ -\fi\fi\fi 4541 \number\count@.#4}} 4542% \end{macrocode} 4543% \end{macro} 4544% 4545% \begin{macro}{\XC@calcH} 4546% \marg{x}\marg{cmd}\\ 4547% \textbf Hexadecimal transformation of $x\in\{0,1,\dots,255\}$: performs |\def|\Meta{cmd}|{|$x_{16}$|}|. 4548% \begin{macrocode} 4549\def\XC@calcH#1#2% 4550 {\count@#1 \divide\count@\sixt@@n \edef\XC@@tmp{\hexnumber@\count@}% 4551 \multiply\count@-\sixt@@n \advance\count@#1 4552 \edef#2{\XC@@tmp\hexnumber@\count@}} 4553% \end{macrocode} 4554% \end{macro} 4555% 4556% \begin{macro}{\XC@calcM} 4557% \marg{x}\marg{cmd}\\ 4558% \textbf Multiplication of $x$ by $s$ plus rounding: performs |\def|\Meta{cmd}|{|$[s\cdot x+0.5]$|}|. 4559% The parameter $s$ is input via |\@@scl|. 4560% \begin{macrocode} 4561\def\XC@calcM#1#2% 4562 {\dimen@#1\p@ \dimen@\@@scl\dimen@ \advance\dimen@.5\p@ 4563 \afterassignment\dimen@\count@=\the\dimen@ \edef#2{\number\count@}} 4564% \end{macrocode} 4565% \end{macro} 4566% 4567% \begin{macro}{\XC@calcN} 4568% \marg{x}\marg{cmd}\\ 4569% \textbf Normalisation of $x$: similar to |\XC@calcR|, but trailing zeros are eliminated. 4570% \begin{macrocode} 4571\def\XC@calcN#1#2% 4572 {\XC@calcR{#1}#2\edef#2{\expandafter\XC@c@lcN#200000:}} 4573% \end{macrocode} 4574% 4575% Gobble trailing zeros. 4576% \begin{macrocode} 4577\def\XC@c@lcN#1.#200000#3:{#1\ifnum0#2=0 \else.#2\fi} 4578% \end{macrocode} 4579% \end{macro} 4580% 4581% \begin{macro}{\XC@calcR} 4582% \marg{x}\marg{cmd}\\ 4583% \textbf Reduction of $x$ to the unit interval: performs |\def|\Meta{cmd}|{|$\min\{1,\max\{0,x\}\}$|}|. 4584% Numbers are output with 5 decimals. 4585% This could also be done using |\XC@calcF|, followed by a range check, but perhaps less efficiently. 4586% \begin{macrocode} 4587\def\XC@calcR#1#2{\edef#2{#1}\edef#2{\expandafter\XC@c@lcR#2.0.:}} 4588% \end{macrocode} 4589% 4590% Check interval. 4591% \begin{macrocode} 4592\def\XC@c@lcR#1.#2.#3:% 4593 {\ifnum#10>0 1.00000\else 0.\ifnum#11<0 00000\else 4594 \XC@c@@cR#200000:\fi\fi} 4595% \end{macrocode} 4596% 4597% Normalize to 5 digits. 4598% \begin{macrocode} 4599\def\XC@c@@cR#1#2#3#4#5#6:{#1#2#3#4#5} 4600% \end{macrocode} 4601% \end{macro} 4602% 4603% \begin{macro}{\XC@calcS} 4604% \marg{x}\marg{cmd}\\ 4605% \textbf Scaling of $x$ by $s$: performs |\def|\Meta{cmd}|{|$s\cdot x$|}|. 4606% The parameter $s$ is input via |\@@scl|. 4607% \begin{macrocode} 4608\def\XC@calcS{\XC@c@lcS\@@scl{}} 4609% \end{macrocode} 4610% \end{macro} 4611% 4612% \begin{macro}{\XC@c@lcS} 4613% \marg{s}\marg{string}\marg{x}\marg{cmd}\\ 4614% \textbf Scaling of $x$ by $s$, appending \Meta{string}: performs |\def|\Meta{cmd}|{|$s\cdot x$\Meta{string}|}|. 4615% \begin{macrocode} 4616\def\XC@c@lcS#1#2#3#4% 4617 {\lshiftset\dimen@{#3}% 4618 \ifdim#1\p@<100\p@ 4619 \dimen@\lshiftnum#1\dimen@ \rrshift\dimen@ \else 4620 \dimen@#1\dimen@ \rshift\dimen@ \fi 4621 \edef#4{\strip@pt\dimen@#2}} 4622% \end{macrocode} 4623% \end{macro} 4624% 4625% \begin{macro}{\XC@calcT} 4626% \marg{x}\marg{cmd}\\ 4627% \textbf Translate $x$ by $a$ and cut to unit interval: performs |\def|\Meta{cmd}|{|$\min\{1,\max\{0,x+a\}\}$|}|. 4628% The parameter $a$ is input via |\@@arg|. 4629% \begin{macrocode} 4630\def\XC@calcT#1#2% 4631 {\lshiftset\dimen@{#1}\advance\dimen@\lshiftnum\@@arg\p@ \rshift\dimen@ 4632 \edef#2% 4633 {\ifdim\dimen@>\p@1\else\ifdim\dimen@<\z@0\else\strip@pt\dimen@\fi\fi}} 4634% \end{macrocode} 4635% \end{macro} 4636% 4637% \begin{macro}{\XC@calcU} 4638% \marg{x}\marg{cmd}\\ 4639% \textbf Unit interval mapping of $x$: performs |\def|\Meta{cmd}|{|$x-[x]$|}| if $x\neq1$, $1$ otherwise. 4640% \begin{macrocode} 4641\def\XC@calcU#1#2% 4642 {\dimen@#1\p@ 4643 \ifdim\dimen@=\p@\else 4644 \afterassignment\dimen@\count@=\the\dimen@ 4645 \relax\ifdim\dimen@=\z@\else 4646 \ifdim#1\p@<\z@ \dimen@-\dimen@ \advance\dimen@\p@ \fi 4647 \fi 4648 \fi 4649 \edef#2{\strip@pt\dimen@}} 4650% \end{macrocode} 4651% \end{macro} 4652% 4653% 4654% \subsection{Color definition} 4655% 4656% \subsubsection{Constants} 4657% 4658% \begin{macro}{\rangeRGB} 4659% \begin{macro}{\rangeHSB} 4660% \begin{macro}{\rangeHsb} 4661% \begin{macro}{\rangetHsb} 4662% \begin{macro}{\rangeGray} 4663% Scaling ranges for `integer' and other special models: 4664% \begin{macrocode} 4665\providecommand*\rangeRGB{255} 4666\providecommand*\rangeHSB{240} 4667\providecommand*\rangeHsb{360} 4668\providecommand*\rangetHsb{60,30;120,60;180,120;210,180;240,240} 4669\providecommand*\rangeGray{15} 4670% \end{macrocode} 4671% \end{macro} 4672% \end{macro} 4673% \end{macro} 4674% \end{macro} 4675% \end{macro} 4676% 4677% \begin{macro}{\adjustUCRBG} 4678% Parameters for undercolor-removal (UCR) and black-generation (BG) during \Model{cmy} to \Model{cmyk} conversion: 4679% \begin{macrocode} 4680\providecommand*\adjustUCRBG{1,1,1,1} 4681% \end{macrocode} 4682% \end{macro} 4683% 4684% \begin{macro}{\paperquality} 4685% Parameter for choosing different color sets according to the paper quality; yet supported only for the HKS colors. 4686% \begin{macrocode} 4687\providecommand*\paperquality{1} 4688% \end{macrocode} 4689% \end{macro} 4690% 4691% \begin{macro}{\colorseriescycle} 4692% Default cycle length for color series: 4693% \begin{macrocode} 4694\providecommand*\colorseriescycle{16} 4695% \end{macrocode} 4696% \end{macro} 4697% 4698% Model-dependent base colors: 4699% \begin{macrocode} 4700\def\XC@clr@rgb@white{1,1,1} 4701\def\XC@clr@cmy@white{0,0,0} 4702\def\XC@clr@cmyk@white{0,0,0,0} 4703\def\XC@clr@hsb@white{\@@hue,0,1} 4704\def\XC@clr@hsb@gray{\@@hue,0,0.5} 4705\def\XC@clr@hsb@black{\@@hue,0,0} 4706\def\XC@clr@gray@white{1} 4707% \end{macrocode} 4708% 4709% \begin{macro}{\XC@met@grad} 4710% \begin{macro}{\XC@met@last} 4711% \begin{macro}{\XC@met@step} 4712% Methods for color series: 4713% \begin{macrocode} 4714\@tfor\@@tmp:={grad}{last}{step}\do 4715 {\XC@let@cN{XC@met@\@@tmp}\@@tmp} 4716% \end{macrocode} 4717% \end{macro} 4718% \end{macro} 4719% \end{macro} 4720% 4721% 4722% \subsubsection{Colors}\label{sec.definition} 4723% 4724% \begin{macro}{\definecolor} 4725% \oarg{type}\marg{name}\oarg{prefix}\marg{model-list}\marg{spec-list}\\ 4726% Extends the facilities of \LC's |\definecolor|. 4727% The optional argument \Meta{type} has currently to be either empty (= normal color definition) or `named' or `ps'. 4728% \Meta{prefix} is an argument used for the internal driver-dependent representation. 4729% |\definecolor| creates a new command |\\color@|\Meta{name} that contains the \emph{internal representation} 4730% |\xcolor@|\marg{type-spec}\marg{driver-spec}\marg{n-model}\marg{n-color-spec} of the color, where 4731% \begin{itemize} 4732% \item \Meta{type-spec} is either empty (if \Meta{type} was empty), or a driver-dependent macro or expression (if \Meta{type} was `named', `ps'); 4733% \item \Meta{driver-spec} is a driver-dependent representation of the color, which also depends on \Meta{type}; 4734% \item \Meta{n-model} is either \Meta{model} or the name of another color model, dependent on the desired transformation(s) at definition time; 4735% \item \Meta{n-color-spec} are the comma-separated normalised parameter values of the color with respect to \Meta{n-model}. 4736% \end{itemize} 4737% See table \vref{tab.internal} for some examples. 4738% \begin{macrocode} 4739\def\definecolor{\@testopt{\XC@definecolor}{}} 4740\def\XC@definecolor[#1]#2% 4741 {\@testopt{\XC@definec@lor[#1]{#2}}\colornameprefix} 4742% \end{macrocode} 4743% 4744% \begin{macrocode} 4745\def\XC@definec@lor[#1]#2[#3]#4#5% 4746 {\begingroup 4747 \XC@sdef\@@cls{#1}\XC@edef\@@nam{#2}\edef\colornameprefix{#3}% 4748 \XC@logdef\@@nam 4749 \XC@getmodclr02{#4}{#5}{\let\@@tmp\relax}% 4750 {\ifx\@@mod\XC@mod@named 4751 \XC@c@l@rlet\@@nam\@@clr 4752 \else 4753 \ifx\@@cls\XC@mod@ps 4754 \edef\@@drv{\@@mod\space\@@clr}\def\@@hue{0}% 4755 \edef\@@clr{\@nameuse{XC@clr@\@@mod @white}}% 4756 \else 4757 \ifconvertcolorsD 4758 \let\@@tmp\@@mod\XC@sdef\@@mod{\XC@tgt@mod\@@tmp}% 4759 \convertcolorspec\@@tmp\@@clr\@@mod\@@clr 4760 \fi 4761 \XC@coremodel\@@mod\@@clr 4762% \end{macrocode} 4763% 4764% Determine driver-dependent color definition: 4765% \begin{macrocode} 4766 \csname color@\@@mod\expandafter\endcsname 4767 \expandafter\@@drv\expandafter{\@@clr}% 4768% \end{macrocode} 4769% 4770% Handle prologue and `named' colors: 4771% \begin{macrocode} 4772 \ifcase\XC@@xcp@ 4773 \immediate\write\XC@@xcp{/\colornameprefix\@@nam{\expandafter 4774 \XC@strip@comma\@@clr,,\@nnil}XC\@@mod}% 4775 \let\@@cls\XC@mod@named 4776 \fi 4777 \ifx\@@cls\@empty\else 4778 \let\@@tmp\@@cls 4779 \@nameuse{define@color@\@@cls}\@@nam\@@drv 4780 \csname color@\@@tmp\expandafter\endcsname 4781 \expandafter\@@drv\expandafter{\@@nam}% 4782 \fi 4783 \fi 4784% \end{macrocode} 4785% 4786% Finally write all information into macro |\\color@|\Meta{name}: 4787% \begin{macrocode} 4788 \toks@\expandafter{\@@drv}% 4789 \edef\@@tmp 4790 {\ifglobalcolors\global\else\xglobal@\fi 4791 \noexpand\@namedef{\string\color@\@@nam}% 4792 {\noexpand\xcolor@{\@@cls}{\the\toks@}{\@@mod}{\@@clr}}}% 4793 \fi}% 4794 \expandafter\endgroup\@@tmp\xglobal@stop} 4795% \end{macrocode} 4796% \end{macro} 4797% 4798% \begin{macro}{\XC@getmodclr} 4799% \marg{mod-opt}\marg{clr-opt}\marg{model-list}\marg{spec-list}\marg{undefined}\marg{defined}\\ 4800% Depending on \Meta{mod-opt}, different tasks are performed: 4801% \begin{itemize} 4802% \item[0:] Retrieve color model and target model from \Meta{model-list} if |\XC@@getmod| is `true'. 4803% \item[1:] Retrieve color model and target model from \Meta{model-list} always. 4804% \end{itemize} 4805% The color model is stored in |\@@mod|, its position in |\XC@@pos|, a possible target model in |\@@Mod|. 4806% Depending on \Meta{clr-opt}, different tasks are performed: 4807% \begin{itemize} 4808% \item[0:] Don't pick color specification from \Meta{spec-list}. 4809% \item[1:] Pick color specification from \Meta{spec-list}, convert it from model |\@@mod| to |\@@Mod|, unless the latter is `ignore' or |\@@cls| is `ps'. 4810% \item[2:] Like the former case, additionally |\let\@@mod\@@Mod|. 4811% \end{itemize} 4812% The color specification is stored in |\@@clr|. 4813% Color specification picking relies on the position |\XC@@pos|, conversion relies on the model |\@@mod|, and the target model |\@@Mod|. 4814% If |\@@mod| represents an undefined color model, then \Meta{undefined} is executed at the end of the macro, else \Meta{defined}. 4815% \begin{macrocode} 4816\def\XC@getmodclr#1#2#3#4% 4817 {\ifnum\ifcase#1 \ifXC@@getmod1\else0 \fi \or1 \fi>0 4818 \XC@mdef\@@mod{#3}\expandafter\XC@getmod\@@mod////////\XC@@ 4819 \@ifundefinedmodel\@@Mod{\let\@@Mod\XC@mod@ignore}{}\fi 4820 \@ifundefined{XC@mod@\@@mod}% 4821 {\c@lor@error{model `\@@mod'}\@firstoftwo}% 4822 {\ifcase#2\else 4823 \XC@mdef\@@clr{#4}% 4824 \edef\@@clr{\expandafter\XC@getclr\@@clr////////\XC@@}% 4825 \ifx\@@cls\XC@mod@ps\else\XC@clean\@@clr\fi 4826 \ifx\@@Mod\XC@mod@ignore\else 4827 \convertcolorspec\@@mod\@@clr\@@Mod\@@clr 4828 \ifnum#2>1 \let\@@mod\@@Mod\fi 4829 \fi 4830 \fi \@secondoftwo}} 4831% \end{macrocode} 4832% 4833% \begin{macro}{\XC@getmod} 4834% Retrieve model position |\XC@@pos|, model |\@@mod|, and target model |\@@Mod| from multiple definitions (up to~8), separated by `|/|'. 4835% \begin{macrocode} 4836\def\XC@getmod#1/#2/#3/#4/#5/#6/#7/#8/#9\XC@@ 4837 {\XC@g@tm@d0#1::\XC@@ \XC@getm@d1{#2}\XC@getm@d2{#3}% 4838 \XC@getm@d3{#4}\XC@getm@d4{#5}\XC@getm@d5{#6}\XC@getm@d6{#7}% 4839 \XC@getm@d7{#8}\def\XC@@pos{0}\def\@@mod{#1}\@gobble\@nnil}% 4840% \end{macrocode} 4841% 4842% \begin{macrocode} 4843\def\XC@getm@d#1#2% 4844 {\edef\XC@@pos{#2}\XC@sdef\@@mod{\XC@tgt@mod\XC@@pos}% 4845 \ifx\XC@@pos\@@mod\def\XC@@pos{#1}\expandafter\remove@to@nnil\fi}% 4846% \end{macrocode} 4847% 4848% \begin{macrocode} 4849\def\XC@g@tm@d#1#2:#3:#4\XC@@ 4850 {\@ifxempty{#3}{\let\@@Mod\XC@mod@ignore\XC@getm@d0{#2}}% 4851 {\def\@@Mod{#2}\XC@getm@d0{#3}}}% 4852% \end{macrocode} 4853% \end{macro} 4854% 4855% \begin{macro}{\XC@getclr} 4856% Pick color specification on position |\XC@@pos| from multiple definitions (up to~8), separated by `|/|'. 4857% Expandable. 4858% \begin{macrocode} 4859\def\XC@getclr#1/#2/#3/#4/#5/#6/#7/#8/#9\XC@@ 4860 {\ifcase\XC@@pos\space #1\or#2\or#3\or#4\or#5\or#6\or#7\or#8\fi} 4861% \end{macrocode} 4862% \end{macro} 4863% 4864% \begin{macro}{\ifXC@@getmod} 4865% Switch used to determine whether the model has to be retrieved (e.g., ordinary |\definecolor|) or not (e.g., |\definecolor| acting as subroutine to |\definecolorset|). 4866% \begin{macrocode} 4867\newif\ifXC@@getmod \XC@@getmodtrue 4868% \end{macrocode} 4869% \end{macro} 4870% \end{macro} 4871% 4872% \begin{macro}{\xdefinecolor} 4873% This command is identical with |\definecolor|, it is kept only for compatibility reasons. 4874% \begin{macrocode} 4875\let\xdefinecolor\definecolor 4876% \end{macrocode} 4877% \end{macro} 4878% 4879% \begin{macro}{\providecolor} 4880% \oarg{type}\marg{name}\marg{model-list}\marg{spec-list}\\ 4881% Similar to |\definecolor|, but the color \Meta{name} is only defined if it does not exist already. 4882% \begin{macrocode} 4883\def\providecolor{\@testopt{\XC@providecolor}{}} 4884\def\XC@providecolor[#1]#2% 4885 {\@testopt{\XC@providec@lor[#1]{#2}}\colornameprefix} 4886% \end{macrocode} 4887% 4888% \begin{macrocode} 4889\def\XC@providec@lor[#1]#2[#3]% 4890 {\XC@edef\XC@@tmp{#2}% 4891 \@ifundefinedcolor\XC@@tmp{\XC@definecolor[#1]{#2}[#3]}% 4892 {\ifnum\XC@tracing>0 4893 \PackageInfo{xcolor}{Ignoring color definition `\XC@@tmp'}\fi 4894 \@gobbletwo}} 4895% \end{macrocode} 4896% \end{macro} 4897% 4898% \begin{macro}{\xcolor@} 4899% \marg{type-spec}\marg{driver-spec}\marg{model}\marg{spec}\\ 4900% Simply grabs the driver-specific part of the color definition. 4901% Therefore, the command |\\color@|\Meta{name} behaves like in the original case, when first-level expanded. 4902% \begin{macrocode} 4903\def\xcolor@#1#2#3#4{#2} 4904% \end{macrocode} 4905% \end{macro} 4906% 4907% \begin{macro}{\colorlet} 4908% \oarg{type}\marg{name}\oarg{num model}\marg{color}\\ 4909% Create a color `name' consisting of \Meta{color}, converted to \Meta{num model} if non-empty. 4910% \begin{macrocode} 4911\def\colorlet{\@testopt{\XC@colorlet}{}} 4912\def\XC@colorlet[#1]#2{\@testopt{\XC@col@rlet[#1]{#2}}{}} 4913\def\XC@col@rlet[#1]#2[#3]#4% 4914 {\begingroup 4915 \edef\@@cls{#1}\XC@edef\@@nam{#2}\XC@sdef\@@mod{#3}\XC@edef\@@clr{#4}% 4916% \end{macrocode} 4917% 4918% 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. 4919% \begin{macrocode} 4920 \XC@info\@@clr\@@tmp\XC@@tstfalse 4921 \ifnum\@@tmp=\@ne\ifx\@@mod\@empty 4922 \ifx\@@cls\@empty 4923 \XC@@tsttrue 4924 \else 4925 \edef\@@tmp 4926 {\expandafter\expandafter\expandafter\@secondoffive 4927 \csname\string\color@\@@clr\endcsname}% 4928 \ifx\@@cls\@@tmp\XC@@tsttrue\fi 4929 \fi 4930 \fi\fi 4931 \ifXC@@tst 4932 \XC@logdef\@@nam\XC@c@l@rlet\@@nam\@@clr 4933 \else 4934 \extractcolorspec\@@clr\@@clr 4935 \ifx\@@mod\@empty\else 4936 \expandafter\convertcolorspec\@@clr\@@mod\@@clr 4937 \edef\@@clr{{\@@mod}{\@@clr}}\fi 4938 \edef\@@tmp{\noexpand\XC@definecolor[\@@cls]{\@@nam}\@@clr}% 4939 \fi 4940 \expandafter\endgroup\@@tmp\xglobal@stop} 4941% \end{macrocode} 4942% 4943% \begin{macrocode} 4944\def\XC@c@l@rlet#1#2% 4945 {\@ifundefinedcolor{#2}% 4946 {\c@lor@error{`#2'}\let\@@tmp\@empty}% 4947 {\edef\@@tmp 4948 {\ifglobalcolors\global\else\xglobal@\fi 4949 \noexpand\XC@let@cc{\string\color@#1}{\string\color@#2}}}} 4950% \end{macrocode} 4951% \end{macro} 4952% 4953% \begin{macro}{\DefineNamedColor} 4954% \marg{type}\marg{name}\marg{model-list}\marg{spec-list} 4955% \begin{macrocode} 4956\def\DefineNamedColor#1% 4957 {\@nameuse{XC@\ifdefinecolors defin\else prepar\fi ecolor}[#1]} 4958% \end{macrocode} 4959% \end{macro} 4960% 4961% 4962% \subsubsection{Deferred definition} 4963% 4964% \begin{macro}{\preparecolor} 4965% \oarg{type}\marg{name}\oarg{prefix}\marg{model-list}\marg{spec-list}\\ 4966% \begin{macrocode} 4967\def\preparecolor{\@testopt{\XC@preparecolor}{}} 4968\def\XC@preparecolor[#1]#2% 4969 {\@testopt{\XC@preparec@lor[#1]{#2}}\colornameprefix} 4970% \end{macrocode} 4971% 4972% \begin{macrocode} 4973\def\XC@preparec@lor[#1]#2[#3]#4#5% 4974 {\XC@sdef\@@cls{#1}\XC@edef\@@nam{#2}% 4975 \XC@getmodclr01{#4}{#5}{}% 4976 {\xdef\XC@@stack 4977 {\ifx\XC@@stack\@empty\else\XC@@stack,\fi{#1}{\@@nam}{#3}% 4978 {\ifx\@@Mod\XC@mod@ignore\@@mod\else\@@Mod\fi}{\@@clr}}}} 4979% \end{macrocode} 4980% 4981% \begin{macrocode} 4982\let\XC@@stack\@empty 4983% \end{macrocode} 4984% \end{macro} 4985% 4986% \begin{macro}{\definecolors} 4987% \marg{id-list} 4988% \begin{macrocode} 4989\def\definecolors#1% 4990 {\let\XC@@cmd\definecolor\let\XC@@glb\xglobal@ 4991 \expandafter\XC@definecolors#1,,} 4992% \end{macrocode} 4993% 4994% \begin{macrocode} 4995\def\XC@definecolors#1,% 4996 {\@ifxempty{#1}{}{\expandafter\XC@definec@lors#1=#1=:\XC@definecolors}} 4997% \end{macrocode} 4998% 4999% \begin{macrocode} 5000\def\XC@definec@lors#1=#2=#3:% 5001 {\XC@edef\@@nam{#1}\XC@edef\@@arg{#2}% 5002 \let\next\XC@definec@l@rs\expandafter\next\XC@@stack,,\@nnil} 5003% \end{macrocode} 5004% 5005% \begin{macrocode} 5006\def\XC@definec@l@rs#1,% 5007 {\ifx,#1,\let\next\remove@to@nnil\else\XC@defin@c@l@rs#1\fi\next} 5008% \end{macrocode} 5009% 5010% \begin{macrocode} 5011\def\XC@defin@c@l@rs#1#2#3#4#5% 5012 {\def\@@tmp{#2}% 5013 \ifx\@@tmp\@@arg 5014 \let\xglobal@\XC@@glb\XC@@cmd[#1]{\@@nam}[#3]{#4}{#5}% 5015 \let\next\remove@to@nnil 5016 \fi} 5017% \end{macrocode} 5018% \end{macro} 5019% 5020% \begin{macro}{\providecolors} 5021% \marg{id-list}\\ 5022% Similar to |\definecolor|, but based on |\providecolor|, thus the individual colors are defined only if they do not exist already. 5023% \begin{macrocode} 5024\def\providecolors#1% 5025 {\let\XC@@cmd\providecolor\let\XC@@glb\xglobal@ 5026 \expandafter\XC@definecolors#1,,} 5027% \end{macrocode} 5028% \end{macro} 5029% 5030% 5031% \subsubsection{Sets of colors} 5032% 5033% \begin{macro}{\definecolorset} 5034% \oarg{type}\marg{model-list}\marg{head}\marg{tail}\marg{set spec}\\ 5035% This command facilitates the construction of \emph{color sets} with common underlying \Meta{model-list} and \Meta{type}. 5036% 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). 5037% Individual colors are being constructed by |\definecolor|\oarg{type}|{|\Meta{head}\Meta[1]{name}\Meta{tail}|}|\marg{model-list}|{|\Meta[1]{spec-list}|}| etc. 5038% \begin{macrocode} 5039\def\definecolorset 5040 {\let\XC@@cmd\definecolor\@testopt{\XC@definecolorset}{}} 5041% \end{macrocode} 5042% 5043% \begin{macrocode} 5044\def\XC@definecolorset[#1]#2#3#4#5% 5045 {\XC@getmodclr10{#2}{}{}% 5046 {\XC@@getmodfalse\XC@edef\XC@@tmp{#5}\let\XC@@glb\xglobal@ 5047 \def\XC@definec@lorset##1,##2;% 5048 {\@ifxempty{##1}{}% 5049 {\let\xglobal@\XC@@glb 5050 \XC@@cmd[#1]{#3##1#4}{\@@mod}{##2}\XC@definec@lorset}}% 5051 \expandafter\XC@definec@lorset\XC@@tmp;,;\XC@@getmodtrue}} 5052% \end{macrocode} 5053% \end{macro} 5054% 5055% \begin{macro}{\providecolorset} 5056% \oarg{type}\marg{model-list}\marg{name-prefix}\marg{name-postfix}\marg{set spec}\\ 5057% Similar to |\definecolorset|, but based on |\providecolor|, thus the individual colors are defined only if they do not exist already. 5058% \begin{macrocode} 5059\def\providecolorset 5060 {\let\XC@@cmd\providecolor\@testopt{\XC@definecolorset}{}} 5061% \end{macrocode} 5062% \end{macro} 5063% 5064% \begin{macro}{\preparecolorset} 5065% \oarg{type}\marg{model-list}\marg{name-prefix}\marg{name-postfix}\marg{set spec}\\ 5066% Similar to |\definecolorset|, but dependent on |\ifdefinecolors|, either a |\definecolor| or a |\preparecolor| command will be executed for each single set member. 5067% \begin{macrocode} 5068\def\preparecolorset 5069 {\ifdefinecolors\let\XC@@cmd\definecolor\else\let\XC@@cmd\preparecolor\fi 5070 \@testopt{\XC@definecolorset}{}} 5071% \end{macrocode} 5072% \end{macro} 5073% 5074% 5075% \subsubsection{Color series} 5076% 5077% \begin{macro}{\definecolorseries} 5078% \marg{name}\marg{core model}\marg{method}\oarg{b-model}\marg{base color}\oarg{l-model}\marg{delta} 5079% \begin{macrocode} 5080\def\definecolorseries#1#2#3% 5081 {\@testopt{\XC@definecolorseries{#1}{#2}{#3}}{}} 5082% \end{macrocode} 5083% 5084% \begin{macrocode} 5085\def\XC@definecolorseries#1#2#3[#4]#5% 5086 {\@testopt{\XC@definec@lorseries{#1}{#2}{#3}[#4]{#5}}{}} 5087% \end{macrocode} 5088% 5089% \begin{macrocode} 5090\def\XC@definec@lorseries#1#2#3[#4]#5[#6]#7% 5091 {\begingroup 5092 \XC@sdef\@@mod{#2}% 5093 \@ifxempty{#4}{\extractcolorspec{#5}\@@clr}{\edef\@@clr{{#4}{#5}}}% 5094 \expandafter\convertcolorspec\@@clr\@@mod\@@clr 5095 \@namexdef{\string\colorB@#1}{{\@@mod}{\@@clr}}% 5096 \edef\@@met{#3}% 5097 \ifx\@@met\XC@met@last 5098 \@ifxempty{#6}{\extractcolorspec{#7}\@@tmp}{\edef\@@tmp{{#6}{#7}}}% 5099 \expandafter\convertcolorspec\@@tmp\@@mod\@@tmp 5100 \XC@inflate\@@mod\@@tmp\@@clr\@@tmp 5101 \expandafter\XC@sub\@@tmp,\@@tmp 5102 \else 5103 \edef\@@tmp{#7}% 5104 \fi 5105 \@namexdef{\string\colorD@#1}{{\@@met}{\@@tmp}}% 5106 \endgroup} 5107% \end{macrocode} 5108% \end{macro} 5109% 5110% \begin{macro}{\resetcolorseries} 5111% \oarg{div}\marg{name} 5112% \begin{macrocode} 5113\def\resetcolorseries{\@testopt{\XC@resetcolorseries}{}} 5114\def\XC@resetcolorseries[#1]#2% 5115 {\begingroup 5116 \@namexdef 5117 {\string\color@#2}{\noexpand\xcolor@{}{}\@nameuse{\string\colorB@#2}}% 5118 \XC@let@Nc\@@tmp{\string\colorD@#2}% 5119 \edef\@@met{\expandafter\@firstoftwo\@@tmp}% 5120 \edef\@@tmp{\expandafter\@secondoftwo\@@tmp}% 5121 \ifx\@@met\XC@met@step\else 5122 \edef\@@scl{\@ifxempty{#1}\colorseriescycle{#1}}% 5123 \expandafter\XC@calc@\@@tmp,,,,:D% 5124 \fi 5125 \@namexdef{\string\colorS@#2}{\@@tmp}% 5126 \endgroup} 5127% \end{macrocode} 5128% \end{macro} 5129% 5130% \begin{macro}{\XC@step} 5131% \begin{macro}{\XC@stepabs} 5132% \marg{name}\\ 5133% Perform a relative or absolute (= direct access) step within a color series \Meta{name}. 5134% In the relative case, the (non-negative) number of single steps is supposed to be stored in |\@tempcnta|. 5135% \begin{macrocode} 5136\def\XC@step#1% 5137 {\let\xcolor@\@gobbletwo\edef\@@tmp{\@nameuse{\string\color@#1}}% 5138 \expandafter\XC@st@p\@@tmp{#1}% 5139 \@namexdef{\string\color@#1}{\noexpand\xcolor@{}{}{\@@mod}{\@@tmp}}} 5140% \end{macrocode} 5141% 5142% \begin{macrocode} 5143\def\XC@st@p#1#2#3% 5144 {\def\@@mod{#1}\def\@@tmp{#2}\edef\@@vec{\@nameuse{\string\colorS@#3}}% 5145 \@whilenum\@tempcnta>\z@\do 5146 {\XC@inflate\@@mod\@@tmp\@@vec\@@tmp 5147 \expandafter\XC@add\@@tmp,\@@tmp \expandafter\XC@calc@\@@tmp,,,,:U% 5148 \advance\@tempcnta\m@ne}} 5149% \end{macrocode} 5150% 5151% \begin{macrocode} 5152\def\XC@stepabs#1% 5153 {\edef\@@tmp{\@nameuse{\string\colorB@#1}}% 5154 \expandafter\XC@st@p\@@tmp{#1}% 5155 \edef\@@tmp 5156 {\def\noexpand\@@mod{\@@mod}\def\noexpand\@@clr{\@@tmp}}} 5157% \end{macrocode} 5158% \end{macro} 5159% \end{macro} 5160% 5161% 5162% \subsubsection{Color blending} 5163% 5164% \begin{macro}{\blendcolors} 5165% \begin{macro}{\blendcolors*} 5166% \marg{mix expr}\\ 5167% Initialises all necessary parameters for color blending. 5168% The actual (completed) color blend expression is stored in |\colorblend|. 5169% In the starred version, the argument will be appended to a previously defined blend expression. 5170% An empty \Meta{mix expr} argument will switch blending off. 5171% \begin{macrocode} 5172\def\blendcolors{\@ifstar{\XC@blendcolors\colorblend}{\XC@blendcolors{}}} 5173\def\XC@blendcolors#1#2% 5174 {\edef\colorblend{#1}\XC@edef\XC@@tmp{#2}% 5175 \ifx\XC@@tmp\@empty 5176 \xglobal@\blendcolorsfalse 5177 \else 5178 \xglobal@\blendcolorstrue 5179 \expandafter\XC@blendc@lors\XC@@tmp!!\@nil 5180 \fi 5181 \xglobalize@\colorblend \xglobal@stop} 5182% \end{macrocode} 5183% 5184% \begin{macrocode} 5185\def\XC@blendc@lors!#1!#2!#3\@nil 5186 {\@ifxempty{#1}{}% 5187 {\@ifxempty{#2}% 5188 {\edef\colorblend{\colorblend!#1!white}}% 5189 {\edef\colorblend{\colorblend!#1!#2}\XC@blendc@lors!#3!\@nil}}} 5190% \end{macrocode} 5191% 5192% \begin{macrocode} 5193\blendcolors{} 5194% \end{macrocode} 5195% \end{macro} 5196% \end{macro} 5197% 5198% 5199% \subsubsection{Color masks and separation} 5200% 5201% \begin{macro}{\maskcolors} 5202% \oarg{core model}\marg{color}\\ 5203% Initialises all necessary parameters for color masking. 5204% The actual color mask expression is stored in |\colormask|. 5205% An empty \Meta{color} argument will switch masking off. 5206% The optional \Meta{core model} argument may be used to determine the underlying color model. 5207% \begin{macrocode} 5208\def\maskcolors{\@testopt{\XC@maskcolors}{}} 5209\def\XC@maskcolors[#1]#2% 5210 {\XC@edef\colormask{#2}% 5211 \ifx\colormask\@empty 5212 \xglobal@\maskcolorsfalse \def\XC@mmod{}\def\XC@mclr{}% 5213 \else 5214 \xglobal@\maskcolorstrue \extractcolorspecs\colormask\XC@mmod\XC@mclr 5215 \@ifxempty{#1}{}% 5216 {\convertcolorspec\XC@mmod\XC@mclr{#1}\XC@mclr \XC@sdef\XC@mmod{#1}}% 5217 \XC@coremodel\XC@mmod\XC@mclr 5218 \fi 5219 \xglobalize@\colormask \xglobalize@\XC@mmod \xglobalize@\XC@mclr 5220 \xglobal@stop} 5221% \end{macrocode} 5222% 5223% \begin{macrocode} 5224\maskcolors{} 5225% \end{macrocode} 5226% \end{macro} 5227% 5228% 5229% 5230% \subsection{Color application} 5231% 5232% \subsubsection{Standard color commands} 5233% 5234% \begin{macro}{\color} 5235% \marg{color}\\ 5236% \oarg{model-list}\marg{spec-list}\\ 5237% Switches to the color given either by name/expression or by model/specification. 5238% This color will stay in effect until the end of the current \TeX\ group. 5239% \begin{macrocode} 5240\DeclareRobustCommand\color 5241 {\@ifnextchar[\@undeclaredcolor\@declaredcolor} 5242% \end{macrocode} 5243% \end{macro} 5244% 5245% \begin{macro}{\@undeclaredcolor} 5246% \oarg{model-list}\marg{spec-list}\\ 5247% Display a color that is given by \Meta{model} name and numerical \Meta{spec}. 5248% \begin{macrocode} 5249\def\@undeclaredcolor[#1]#2% 5250 {\begingroup 5251 \let\@@cls\@empty 5252 \XC@getmodclr12{#1}{#2}{}% 5253 {\ifblendcolors 5254 \ifx\colorblend\@empty\else 5255 \edef\@@mix{\expandafter\@gobble\colorblend}\@tempswafalse 5256 \XC@coremodel\@@mod\@@clr\@xcolor@{}{}\@@mod\@@clr 5257 \fi 5258 \fi 5259 \ifconvertcolorsU 5260 \edef\@@tmp{\XC@tgt@mod{\@@mod}}% 5261 \convertcolorspec\@@mod\@@clr\@@tmp\@@clr \let\@@mod\@@tmp 5262 \fi 5263 \ifmaskcolors 5264 \convertcolorspec\@@mod\@@clr\XC@mmod\@@clr 5265 \let\@@mod\XC@mmod 5266 \XC@inflate\@@mod\XC@mclr\@@clr\@@tmp 5267 \expandafter\XC@mul\@@tmp,\@@clr 5268 \fi 5269 \edef\@@tmp{\noexpand\XC@undeclaredcolor{\@@mod}{\@@clr}}% 5270 \expandafter\endgroup\@@tmp}} 5271% \end{macrocode} 5272% 5273% \begin{macrocode} 5274\def\XC@undeclaredcolor#1#2% 5275 {\@ifundefinedmodel{#1}% 5276 {\c@lor@error{model `#1'}}% 5277 {\@nameuse{color@#1}\current@color{#2}% 5278 \edef\XC@current@color{\noexpand\xcolor@{}{\current@color}{#1}{#2}}% 5279 \XC@display}} 5280% \end{macrocode} 5281% \end{macro} 5282% 5283% \begin{macro}{\@declaredcolor} 5284% \marg{color}\\ 5285% Display a color that is given by an arbitrary \Meta{color}. 5286% \begin{macrocode} 5287\def\@declaredcolor#1% 5288 {\XC@edef\XC@@tmp{#1}\XC@@tstfalse 5289 \ifcase\XC@type\XC@@tmp\relax \XC@@tsttrue\or \relax\else 5290 \ifblendcolors\XC@@tsttrue\fi \ifmaskcolors\XC@@tsttrue\fi 5291 \ifconvertcolorsU\XC@@tsttrue\fi 5292 \fi 5293 \ifXC@@tst 5294 \expandafter\XC@declaredcolor\else 5295 \expandafter\XC@declaredc@lor\fi} 5296% \end{macrocode} 5297% 5298% \begin{macrocode} 5299\def\XC@declaredcolor 5300 {\XC@split\XC@@tmp 5301 \edef\@@tmp{\noexpand\@undeclaredcolor[\@@mod]{\@@clr}}% 5302 \expandafter\endgroup\@@tmp} 5303% \end{macrocode} 5304% 5305% \begin{macrocode} 5306\def\XC@declaredc@lor 5307 {\XC@let@Nc\XC@current@color{\string\color@\XC@@tmp}% 5308 \edef\current@color{\XC@current@color}% 5309 \XC@display} 5310% \end{macrocode} 5311% \end{macro} 5312% 5313% \begin{macro}{\textcolor} 5314% \marg{color}\marg{text}\\ 5315% \oarg{model-list}\marg{spec-list}\marg{text}\\ 5316% are just alternative syntax for |\color|, in which the groups are added implicitly. 5317% Thus \emph{text} appears in the specified color, but then the color reverts to its previous value. 5318% 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. 5319% Additionally, it calls |\leavevmode| to ensure the start of horizontal mode. 5320% \begin{macrocode} 5321\def\textcolor#1#{\@textcolor{#1}} 5322\def\@textcolor#1#2#3{\protect\leavevmode{\color#1{#2}#3}} 5323% \end{macrocode} 5324% \end{macro} 5325% 5326% \begin{macro}{\pagecolor} 5327% \marg{color}\\ 5328% \oarg{model-list}\marg{spec-list}\\ 5329% Specifies the background color for the current, and all following, pages. 5330% It is a global declaration which does not respect \TeX\ groups. 5331% \begin{macrocode} 5332\def\pagecolor 5333 {\begingroup 5334 \let\ignorespaces\endgroup \let\set@color\set@page@color 5335 \color} 5336% \end{macrocode} 5337% \end{macro} 5338% 5339% 5340% \subsubsection{Colored boxes} 5341% 5342% \begin{macro}{\colorbox} 5343% \marg{color}\marg{text}\\ 5344% \oarg{model}\marg{spec}\marg{text}\\ 5345% Takes the same argument forms as |\textcolor|, but the color specifies the \emph{background} color of the box. 5346% \begin{macrocode} 5347\def\colorbox#1#{\color@box{#1}} 5348\def\color@box#1#2{\color@b@x\relax{\color#1{#2}}} 5349% \end{macrocode} 5350% \end{macro} 5351% 5352% \begin{macro}{\fcolorbox} 5353% \marg{frame color}\marg{background color}\marg{text}\\ 5354% \oarg{model}\marg{frame spec}\marg{background spec}\marg{text}\\ 5355% \oarg{frame model}\marg{frame spec}\oarg{background model}\marg{background spec}\marg{text}\\ 5356% \marg{frame color}\oarg{background model}\marg{background spec}\marg{text}\\ 5357% Puts a frame of the first color around a box with a background specified by the second color. 5358% If only the first optional argument is given, it specifies the color model for both colors. 5359% \begin{macrocode} 5360\def\fcolorbox#1#{\color@fbox{#1}} 5361\def\color@fbox#1#2#3#{\color@fb@x{#1}{#2}{#3}} 5362\def\color@fb@x#1#2#3#4% 5363 {\color@b@x{\fboxsep\z@\color#1{#2}\XC@fbox}% 5364 {\@ifxempty{#3}{\color#1}{\color#3}{#4}}} 5365% \end{macrocode} 5366% \end{macro} 5367% 5368% \begin{macro}{\color@b@x} 5369% Internal macro for |\colorbox| and |\fcolorbox|. 5370% \begin{macrocode} 5371\long\def\color@b@x#1#2#3% 5372 {\leavevmode 5373 \setbox\z@\hbox{\kern\fboxsep{\set@color#3}\kern\fboxsep}% 5374 \dimen@\ht\z@\advance\dimen@\fboxsep\ht\z@\dimen@ 5375 \dimen@\dp\z@\advance\dimen@\fboxsep\dp\z@\dimen@ 5376 {#1{#2\color@block{\wd\z@}{\ht\z@}{\dp\z@}\box\z@}}} 5377% \end{macrocode} 5378% \end{macro} 5379% 5380% \begin{macro}{\XC@frameb@x} 5381% Common part of |\framebox| and |\fbox|. 5382% |#1| is a negative kern in the |\framebox| case so that the vertical rules do not add to the width of the box. 5383% Optimised by \People{Donald}{Arseneau}. 5384% \begin{macrocode} 5385\def\XC@frameb@x#1% 5386 {\hbox 5387 {\@tempdima\fboxrule \advance\@tempdima\fboxsep 5388 \advance\@tempdima\dp\@tempboxa 5389 \setbox\@tempboxa\hbox 5390 {\lower\@tempdima\hbox 5391 {\vbox 5392 {\kern\fboxrule 5393 \hbox 5394 {\kern\fboxrule#1% 5395 \vbox{\kern\fboxsep\box\@tempboxa\kern\fboxsep}% 5396 #1\kern\fboxrule}% 5397 \kern\fboxrule}}}% 5398 \@tempdima\wd\@tempboxa 5399 \edef\@tempa{{\the\@tempdima}{\the\ht\@tempboxa}{\the\dp\@tempboxa}}% 5400 \box\@tempboxa\kern-\@tempdima\expandafter\boxframe\@tempa}} 5401% \end{macrocode} 5402% \end{macro} 5403% 5404% \begin{macro}{\XC@fbox} 5405% \begin{macro}{\@frameb@x} 5406% If no \Option{kernelfbox} option was specified, switch to the new method in general, else only for |\fcolorbox|. 5407% \begin{macrocode} 5408\ifXC@@fbox 5409 \let\@frameb@x\XC@frameb@x \let\XC@fbox\fbox 5410\else 5411 \def\XC@fbox{\let\@frameb@x\XC@frameb@x\fbox} 5412\fi 5413% \end{macrocode} 5414% \end{macro} 5415% \end{macro} 5416% 5417% 5418% \subsubsection{Driver-specific and generic drawing} 5419% 5420% \begin{macro}{\color@block} 5421% \marg{width}\marg{height}\marg{depth}\\ 5422% Should take up no space for \TeX, but produce a block in the current color of the specified size. 5423% It is mainly used for producing box backgrounds. 5424% \begin{macro}{\boxframe} 5425% \marg{width}\marg{height}\marg{depth}\\ 5426% Draw a frame with a linewidth of |\fboxrule|. 5427% Return a |\hbox| with outer dimensions \meta{width}, \meta{height}, \meta{depth}. 5428 5429% \begin{macro}{\XC@boxframe} 5430% \marg{width}\marg{height}\marg{depth}\marg{frame construction}\\ 5431% Wrapper for |\boxframe| commands that return zero-dimension frames. 5432% \begin{macrocode} 5433\ifnum\XC@@xcd@>\m@ne 5434\def\XC@boxframe#1#2#3#4% 5435 {\hbox{\sbox\z@{\ifdim\fboxrule>\z@ #4\fi}% 5436 \wd\z@#1\relax\ht\z@#2\relax\dp\z@#3\relax\box\z@}} 5437\fi 5438% \end{macrocode} 5439% \end{macro} 5440% 5441% \textbf{\Option{dvips}-optimised code} 5442% \begin{macrocode} 5443\ifcase\XC@@xcd@ 5444% \end{macrocode} 5445% 5446% \begin{macrocode} 5447\providecommand*\color@block[3]% 5448 {{\set@color\hbox 5449 {\dimen@#3\edef\@tempa{ \number\dimen@\space}% 5450 \dimen@#2\edef\@tempa{ \number\dimen@\@tempa}% 5451 \dimen@#1\relax 5452 \XC@special{\number\dimen@\@tempa XCcolorblock}}}} 5453% \end{macrocode} 5454% 5455% \begin{macrocode} 5456\providecommand*\boxframe[3]% 5457 {\XC@boxframe{#1}{#2}{#3}% 5458 {\dimen@#3\edef\@tempa{ \number\dimen@\space}% 5459 \dimen@#2\edef\@tempa{ \number\dimen@\@tempa}% 5460 \dimen@#1\relax 5461 \XC@special{\number\fboxrule\space\number\dimen@\@tempa XCboxframe}}} 5462% \end{macrocode} 5463% 5464% \textbf{\Option{pdftex}-optimised code } 5465% There seems to be no improvement by adding a specific |\color@block| command, since the PDF format doesn't offer higher accuracy than \TeX. 5466% For |\boxframe| we want to achieve this PDF pseudo-code (besides initial scaling):\\[1ex] 5467% \centerline{\ttfamily $l$ w [] $0$ d $2$ J $0$ j $4$ M 5468% $1$ $0$ $0$ $1$ $\frac12\,l$ $\frac12\,l$ cm 5469% $0$ $-d$ $(w-l)$ $(h+d-l)$ re s} 5470% \begin{macrocode} 5471\or 5472% \end{macrocode} 5473% 5474% \begin{macrocode} 5475\providecommand*\boxframe[3]% 5476 {\XC@boxframe{#1}{#2}{#3}% 5477 {\dimen@#3\edef\@tempa{ 0 -\strip@pt\dimen@\space}% 5478 \edef\@tempb{\advance\dimen@\the\dimen@}% 5479 \dimen@#2\advance\dimen@-\fboxrule\@tempb 5480 \edef\@tempb{ \strip@pt\dimen@\space re s}% 5481 \dimen@#1\advance\dimen@-\fboxrule 5482 \edef\@tempb{ cm\@tempa\strip@pt\dimen@\@tempb}% 5483 \dimen@.5\fboxrule\edef\@tempa{ \strip@pt\dimen@}% 5484 \XC@special 5485 {0.996264 0 0 0.996264 0 0 cm 5486 \strip@pt\fboxrule\space w [] 0 d 2 J 0 j 4 M 5487 1 0 0 1\@tempa\@tempa\@tempb}}} 5488% \end{macrocode} 5489% 5490% \begin{macrocode} 5491\fi 5492% \end{macrocode} 5493% 5494% \textbf{Generic code } 5495% The definition here works by selecting a color, and then drawing a \TeX\ rule (unless |\ifcolors@false|). 5496% \begin{macrocode} 5497\providecommand*\color@block[3]% 5498 {{\set@color\rlap{\ifcolors@\vrule\@width#1\@height#2\@depth#3\fi}}} 5499% \end{macrocode} 5500% 5501% The following definition was optimised by \People{Donald}{Arseneau}. 5502% \begin{macrocode} 5503\providecommand*\boxframe[3]% 5504 {\hbox 5505 {\dimen@#2\advance\dimen@#3\relax 5506 \lower#3\vbox 5507 {\hrule\@height\fboxrule 5508 \@tempdima-0.5\fboxrule \ifodd\fboxrule\advance\@tempdima\m@ne sp\fi 5509 \kern\@tempdima 5510 \hbox 5511 {\advance\dimen@-\fboxrule 5512 \vrule\@width\fboxrule\@height\dimen@\@depth\z@ 5513 \@tempdima#1\advance\@tempdima-\tw@\fboxrule \kern\@tempdima 5514 \vrule\@width\fboxrule\@height\dimen@\@depth\z@}% 5515 \kern-0.5\fboxrule 5516 \hrule\@height\fboxrule}}} 5517% \end{macrocode} 5518% \end{macro} 5519% \end{macro} 5520% 5521% 5522% \subsubsection{Color argument processing} 5523% 5524% \begin{macro}{\@xcolor@} 5525% \marg{type-spec}\marg{driver-spec}\marg{model}\marg{spec}\\ 5526% This is the `work-horse' that does all necessary conversions and calculations if a color (expression) has to be displayed. 5527% \Meta{type-spec} and \Meta{driver-spec} are ignored. 5528% |\@@mix| may contain a mix expression without leading `!'. 5529% \begin{macrocode} 5530\def\@xcolor@#1#2#3#4% 5531 {\edef\@@mod{#3}\edef\@@clr{#4}% 5532 \ifx\@@mix\@empty\else\expandafter\@xcolor@@\@@mix!!!!\@nil\fi 5533 \if@tempswa 5534 \XC@let@Nc\@@tmp{XC@cnv@\@@mod @compl}% 5535 \ifx\@@tmp\relax \expandafter\XC@calc@\@@clr,,,,:C\else 5536 \expandafter\@@tmp\@@clr,\fi 5537 \let\@@clr\@@tmp 5538 \fi} 5539% \end{macrocode} 5540% 5541% \begin{macrocode} 5542\def\@xcolor@@#1!#2!#3!#4!#5\@nil 5543 {\dimen@\@ifxempty{#1}{100}{#1}\p@ 5544 \edef\@@mix{\@ifxempty{#2}{white}{#2}}% 5545 \ifdim\dimen@=100\p@ 5546 \expandafter\XC@postfix\@@mix]\relax 5547 \else\ifdim\dimen@=\z@ 5548 \extractcolorspecs\@@mix\@@mod\@@clr 5549 \else 5550 \XC@let@Nc\@@tmp{XC@clr@\@@mod @\@@mix}% 5551 \ifx\@@tmp\relax 5552 \extractcolorspec\@@mix\@@tmp 5553 \ifx\@@mod\XC@mod@gray 5554 \edef\@@mod{\expandafter\@firstoftwo\@@tmp}% 5555 \edef\@@tmp{\expandafter\@secondoftwo\@@tmp}% 5556 \convertcolorspec\XC@mod@gray\@@clr\@@mod\@@clr 5557 \else 5558 \expandafter\convertcolorspec\@@tmp\@@mod\@@tmp 5559 \fi 5560 \else 5561 \ifx\@@mod\XC@mod@hsb\expandafter\XC@extract@hue\@@clr:\@@hue\fi 5562 \fi 5563 \XC@inflate\@@mod\@@clr\@@tmp\@@tmp 5564 \expandafter\XC@mix\@@tmp,\@@clr 5565 \fi\fi 5566 \@ifxempty{#3}% 5567 {\@ifxempty{#4}{}{\@xcolor@@!#4!#5\@nil}}% 5568 {\@xcolor@@#3!#4!#5\@nil}} 5569% \end{macrocode} 5570% \end{macro} 5571% 5572% \begin{macro}{\XC@split} 5573% \marg{ext expr}\\ 5574% 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|. 5575% Note: |\XC@split| opens a group which has to be closed afterwards by |\endgroup|. 5576% \begin{macrocode} 5577\def\XC@split#1% 5578 {\begingroup\XC@edef\@@tmp{#1}\expandafter\XC@split@i\@@tmp>>\@nnil} 5579% \end{macrocode} 5580% 5581% \begin{macro}{\XC@split@i} 5582% Separate first part of expression chain and apply function(s) afterwards as requested. 5583% \begin{macrocode} 5584\def\XC@split@i#1>% 5585 {\def\@@tmp{#1}\XC@split@ii#1:\@nil \XC@func} 5586% \end{macrocode} 5587% \end{macro} 5588% 5589% \begin{macro}{\XC@split@ii} 5590% Check whether it is an \emph{extended} or \emph{standard} color expression. 5591% \begin{macrocode} 5592\def\XC@split@ii#1:#2\@nil 5593 {\@ifxempty{#2}{\XC@split@vi}{\XC@split@iii#1,,:#2}} 5594% \end{macrocode} 5595% \end{macro} 5596% 5597% \begin{macro}{\XC@split@iii} 5598% Initialisation for extended color expressions. 5599% The magic \Meta{div} is either given as second argument, or calculated as the sum of all weights. 5600% \begin{macrocode} 5601\def\XC@split@iii#1,#2,#3:#4:% 5602 {\edef\XC@@mod{#1}\let\@tempa\@empty 5603 \ifx,#2,\XC@@tsttrue\@tempdima\z@\else\XC@@tstfalse\@tempdima#2\p@\fi 5604 \XC@split@iv#4;,;} 5605% \end{macrocode} 5606% \end{macro} 5607% 5608% \begin{macro}{\XC@split@iv} 5609% \marg{expr}\marg{dec}\\ 5610% Step through the list of \Meta{expr},\Meta{dec} pairs. 5611% Add \Meta{dec} to the sum of weights (in order to calculate the ultimate \Meta{div}) and append pair information to |\@tempa| command. 5612% At the end of the list, execute |\@tempa| and map resulting parameter vector into unit cube. 5613% Finally, |\@@mod| and |\@@clr| contain the desired information about color model and parameters. 5614% \begin{macrocode} 5615\def\XC@split@iv#1,#2;% 5616 {\@ifxempty{#1}% 5617 {\let\XC@@clr\@empty \@tempa \expandafter\XC@calc@\XC@@clr,,,,:U% 5618 \let\@@mod\XC@@mod \let\@@clr\@@tmp} 5619 {\XC@append\@tempa{\XC@split@v{#1}{#2}}% 5620 \ifXC@@tst\advance\@tempdima#2\p@\fi 5621 \XC@split@iv}} 5622% \end{macrocode} 5623% \end{macro} 5624% 5625% \begin{macro}{\XC@split@v} 5626% \marg{expr}\marg{dec}\\ 5627% 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. 5628% \begin{macrocode} 5629\def\XC@split@v#1#2% 5630 {\def\@@tmp{#1}\XC@split@vi 5631 \ifx\@@mod\XC@@mod\else 5632 \convertcolorspec\@@mod\@@clr\XC@@mod\@@clr 5633 \fi 5634 \dimen@#2\p@ \rdivide\dimen@\@tempdima 5635 \edef\@@scl{\strip@pt\dimen@}% 5636 \expandafter\XC@calc@\@@clr,,,,:S% 5637 \ifx\XC@@clr\@empty\let\XC@@clr\@@tmp\else 5638 \XC@inflate\XC@@mod\XC@@clr\@@tmp\@@tmp 5639 \expandafter\XC@add\@@tmp,\XC@@clr 5640 \fi} 5641% \end{macrocode} 5642% \end{macro} 5643% 5644% \begin{macro}{\XC@split@vi} 5645% Start splitting process for standard color expression. 5646% \begin{macrocode} 5647\def\XC@split@vi{\count@\z@ \expandafter\XC@split@vii\@@tmp!\@nil} 5648% \end{macrocode} 5649% \end{macro} 5650% 5651% \begin{macro}{\XC@split@vii} 5652% Count number of `-' signs at the beginning of the string. 5653% \begin{macrocode} 5654\def\XC@split@vii#1% 5655 {\ifx#1-\advance\count@\@ne\expandafter\XC@split@vii 5656 \else\expandafter\XC@split@viii\expandafter#1\fi} 5657% \end{macrocode} 5658% \end{macro} 5659% 5660% \begin{macro}{\XC@split@viii} 5661% Extract \Meta{name} and \Meta{mix expr} part of color expression. 5662% Delegate control to |\@xcolor@|. 5663% \begin{macrocode} 5664\def\XC@split@viii#1!#2\@nil 5665 {\edef\@@nam{#1}\edef\@@mix{#2}% 5666 \ifodd\count@\@tempswatrue\else\@tempswafalse\fi 5667 \@ifundefinedcolor\@@nam 5668 {\c@lor@error{`\@@nam'}\def\@@nam{black}}{}% 5669 \let\xcolor@\@xcolor@\@nameuse{\string\color@\@@nam}} 5670% \end{macrocode} 5671% \end{macro} 5672% \end{macro} 5673% 5674% \begin{macro}{\XC@postfix} 5675% Examine the postfix of a color expression and derive the actions to be taken for color series. 5676% \begin{macrocode} 5677\def\XC@postfix#1#2]#3\relax 5678 {\begingroup 5679 \if[#1\@tempcnta#2\relax\XC@stepabs\@@nam 5680 \else\@tempcnta\z@ 5681 \@tfor\@@tok:=#1#2\do 5682 {\if+\@@tok\advance\@tempcnta\@ne 5683 \else\if-\@@tok\advance\@tempcnta\m@ne 5684 \else\@tempcnta\z@\expandafter\@break@tfor\fi\fi}% 5685 \ifnum\@tempcnta=\z@\relax\else\XC@step\@@nam\fi 5686 \let\@@tmp\@empty 5687 \fi\expandafter\endgroup\@@tmp} 5688% \end{macrocode} 5689% \end{macro} 5690% 5691% \begin{macro}{\XC@func} 5692% \marg{function}|,{|\Meta[1]{arg}|,...,{|\Meta[n]{arg}|}>...\@nnil>|\\ 5693% General macro to handle color functions. 5694% The number of arguments depends on the function. 5695% Multiple consecutive functions may be applied. 5696% Color model and specifications are input and output via |\@@mod| and |\@@clr|. 5697% \begin{macrocode} 5698\def\XC@func#1>{\@ifxempty{#1}{\remove@to@nnil}{\XC@fun@#1,>\XC@func}} 5699\def\XC@fun@#1,#2>{\@nameuse{XC@func@#1}#2,,>} 5700% \end{macrocode} 5701% \end{macro} 5702% 5703% \begin{macro}{\XC@func@wheel} 5704% \begin{macro}{\XC@func@twheel} 5705% \marg{angle}|,|\marg{full circle}|,>|\\ 5706% Calculate color wheel position according to \Model{Hsb} or \Model{tHsb} model: \emph{hue} is rotated by \meta{angle} relative to \meta{full circle}. 5707% The latter value is taken from |\rangeHsb| if left empty. 5708% Finally, |\@@mod| is changed to \Model{hsb}. 5709% \begin{macrocode} 5710\def\XC@func@wheel#1,#2,#3>{\XC@func@wh@el{#1}{#2}0} 5711% \end{macrocode} 5712% 5713% \begin{macrocode} 5714\def\XC@func@twheel#1,#2,#3>{\XC@func@wh@el{#1}{#2}1} 5715% \end{macrocode} 5716% 5717% \begin{macrocode} 5718\def\XC@func@wh@el#1#2#3% 5719 {\convertcolorspec\@@mod\@@clr 5720 {\ifcase#3 \XC@mod@Hsb\or\XC@mod@tHsb\fi}\@@clr 5721 \expandafter\XC@extract@hue\@@clr:\@@hue \dimen@#1\p@ 5722 \@ifxempty{#2}{}% 5723 {\rdivide\dimen@{#2}\lshift\dimen@ 5724 \dimen@\rangeHsb\dimen@\rshift\dimen@}% 5725 \advance\dimen@\@@hue\p@ \rdivide\dimen@\rangeHsb 5726 \edef\@@hue{\strip@pt\dimen@}\XC@calcU\@@hue\@@hue 5727 \ifcase#3 5728 \expandafter\XC@replace@hue\@@clr:\@@hue,\@@clr 5729 \or 5730 \XC@c@lcS\rangeHsb{}\@@hue\@@hue 5731 \expandafter\XC@replace@hue\@@clr:\@@hue,\@@clr 5732 \convertcolorspec\XC@mod@tHsb\@@clr\XC@mod@hsb\@@clr 5733 \fi 5734 \let\@@mod\XC@mod@hsb} 5735% \end{macrocode} 5736% \end{macro} 5737% \end{macro} 5738% 5739% \begin{macro}{\XC@display} 5740% Write information to log file and display the current color. 5741% \begin{macrocode} 5742\def\XC@display 5743 {\XC@bcolor\XC@let@cN{\string\color@.}\XC@current@color 5744 \ifnum\XC@type{.}=1 5745 \PackageWarning{xcolor}{Incompatible color definition}\else 5746 \ifnum\XC@tracing>2 5747 \begingroup \let\xcolor@\@empty \def\@nil{\string\@nil}% 5748 \PackageInfo{xcolor}{Setting color `\XC@current@color'}% 5749 \endgroup 5750 \fi\fi 5751 \XC@mcolor\set@color\XC@ecolor\ignorespaces} 5752% \end{macrocode} 5753% \end{macro} 5754% 5755% \begin{macro}{\XC@bcolor} 5756% \begin{macro}{\XC@mcolor} 5757% \begin{macro}{\XC@ecolor} 5758% Hooks that may be used to execute additional code within |\XC@display| immediately before/after a color is being displayed. 5759% 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. 5760% These hooks are intended for class/package writers and not used by \XC{} itself. 5761% In order to prevent unwanted side effects, please make sure that all internal \XC{} variables are restored properly at the end of |\XC@display|. 5762% \begin{macrocode} 5763\let\XC@bcolor\relax 5764\let\XC@mcolor\relax 5765\let\XC@ecolor\relax 5766% \end{macrocode} 5767% \end{macro} 5768% \end{macro} 5769% \end{macro} 5770% 5771% 5772% \subsubsection{Border colors for hyperlinks} 5773% 5774% \begin{macro}{\XC@bordercolor} 5775% \marg{type}\marg{color}\\ 5776% Basic macro to transform \Meta{color} into the format required by \Package{hyperref}. 5777% Here, \Meta{type} corresponds to the key `x\Meta{type}bordercolor'. 5778% \begin{macrocode} 5779\def\XC@bordercolor#1#2% 5780 {\extractcolorspec{#2}\XC@@tmp 5781 \expandafter\convertcolorspec\XC@@tmp\XC@mod@rgb\XC@@tmp 5782 \expandafter\edef\csname @#1bordercolor\endcsname 5783 {\expandafter\XC@strip@comma\XC@@tmp,\@nnil}} 5784% \end{macrocode} 5785% \end{macro} 5786% 5787% \begin{macro}{\XC@pdfborder} 5788% \Meta[1]{number}| |\Meta[2]{number}| |\Meta[3]{number}|\relax|\\ 5789% Basic macro to transform a pdfborder expression into a suitable format for \Program{dvips} with a resolution of 8000~dpi. 5790% \begin{macrocode} 5791\def\XC@pdfborder#1 #2 #3\relax 5792 {\def\@@scl{80}\XC@calc@#1,#2,#3,,:S% 5793 \edef\@pdfborder{\expandafter\XC@strip@comma\@@tmp,\@nnil}} 5794% \end{macrocode} 5795% \end{macro} 5796% 5797% 5798% \subsubsection{Colored rows in tables} 5799% 5800% The following definitions make only sense if the \Package{colortbl} package has been loaded by the \Option{table} option. 5801% \begin{macrocode} 5802\@ifXCopt{table}{% 5803% \end{macrocode} 5804% 5805% \begin{macro}{\rowcolors} 5806% \begin{macro}{\rowcolors*} 5807% \oarg{commands}\marg{row}\marg{odd-row color}\marg{even-row color}\\ 5808% Defines alternating colors for the next tabular environment. 5809% Starting with row \Meta{row}, odd and even rows get their respective colors. 5810% The color arguments may also be left empty (= no color). 5811% Optional commands may be |\hline| or |\noalign|\marg{stuff}. 5812% \begin{macrocode} 5813 \def\rowcolors 5814 {\@ifstar{\@rowcmdfalse\rowc@lors}{\@rowcmdtrue\rowc@lors}} 5815% \end{macrocode} 5816% 5817% \begin{macrocode} 5818 \def\rowc@lors{\@testopt{\rowc@l@rs}{}} 5819% \end{macrocode} 5820% 5821% \begin{macrocode} 5822 \def\rowc@l@rs[#1]#2#3#4% 5823 {\global\rownum=\z@ 5824 \global\@rowcolorstrue 5825 \@ifxempty{#3}% 5826 {\def\@oddrowcolor{\@norowcolor}}% 5827 {\def\@oddrowcolor{\gdef\CT@row@color{\CT@color{#3}}}}% 5828 \@ifxempty{#4}% 5829 {\def\@evenrowcolor{\@norowcolor}}% 5830 {\def\@evenrowcolor{\gdef\CT@row@color{\CT@color{#4}}}}% 5831 \if@rowcmd 5832 \def\@rowcolors 5833 {#1\if@rowcolors 5834 \noalign{\relax\ifnum\rownum<#2\@norowcolor\else 5835 \ifodd\rownum\@oddrowcolor\else\@evenrowcolor\fi\fi}% 5836 \fi}% 5837 \else 5838 \def\@rowcolors 5839 {\if@rowcolors 5840 \ifnum\rownum<#2\noalign{\@norowcolor}\else 5841 #1\noalign{\ifodd\rownum\@oddrowcolor\else\@evenrowcolor\fi}\fi 5842 \fi}% 5843 \fi 5844 \CT@everycr{\@rowc@lors\the\everycr}% 5845 \ignorespaces} 5846% \end{macrocode} 5847% 5848% \begin{macrocode} 5849 \def\@rowc@lors{\noalign{\global\advance\rownum\@ne}\@rowcolors} 5850 \let\@rowcolors\@empty 5851% \end{macrocode} 5852% \end{macro} 5853% \end{macro} 5854% 5855% \begin{macro}{\showrowcolors} 5856% \begin{macro}{\hiderowcolors} 5857% Switch coloring mode on/off. 5858% \begin{macrocode} 5859 \def\showrowcolors{\noalign{\global\@rowcolorstrue}\@rowcolors} 5860 \def\hiderowcolors{\noalign{\global\@rowcolorsfalse\@norowcolor}} 5861 \def\@norowcolor{\global\let\CT@row@color\relax} 5862 \@norowcolor 5863% \end{macrocode} 5864% \end{macro} 5865% \end{macro} 5866% 5867% \begin{macro}{\if@rowcolors} 5868% \begin{macro}{\if@rowcmd} 5869% \begin{macrocode} 5870 \newif\if@rowcolors 5871 \newif\if@rowcmd 5872% \end{macrocode} 5873% \end{macro} 5874% \end{macro} 5875% 5876% \begin{macro}{\rownum} 5877% Reserve a counter register. 5878% \begin{macrocode} 5879 \@ifundefined{rownum}{\newcount\rownum}{} 5880% \end{macrocode} 5881% \end{macro} 5882% 5883% \begin{macro}{\CT@extract} 5884% This is a fix for active `!' character to enable color expressions; it is apparently only necessary for |\columncolor| commands within |\multicolumn|. 5885% \begin{macrocode} 5886 \def\CT@extract#1\columncolor#2#3\@nil 5887 {\if!#2% 5888 \let\CT@column@color\@empty 5889 \else 5890 \if[#2% 5891 \expandafter\CT@extractb 5892 \else 5893 \XC@edef\XC@@tmp{#2}% 5894 \edef\CT@column@color{\noexpand\CT@color{\XC@@tmp}}% 5895 \expandafter\CT@extractd 5896 \fi 5897 {#1}#3\@nil 5898 \fi} 5899% \end{macrocode} 5900% \end{macro} 5901% 5902% End of conditional code for colored tables. 5903% \begin{macrocode} 5904}{} 5905% \end{macrocode} 5906% 5907% 5908% \subsubsection{Color information} 5909% 5910% \begin{macro}{\extractcolorspec} 5911% \marg{color}\marg{cmd}\\ 5912% Extracts the color specification of \Meta{color} and puts it into \Meta{cmd}; equivalent to 5913% |\def|\Meta{cmd}|{|\marg{model}\marg{spec}|}|. 5914% \begin{macrocode} 5915\def\extractcolorspec#1#2% 5916 {\XC@split{#1}\edef\@@tmp{{\@@mod}{\@@clr}}\aftergroupdef#2\@@tmp} 5917% \end{macrocode} 5918% \end{macro} 5919% 5920% \begin{macro}{\extractcolorspecs} 5921% \marg{color}\marg{model-cmd}\marg{color-cmd}\\ 5922% Extracts the color specification of \Meta{color} and puts it into \Meta{model-cmd} and \Meta{color-cmd}, respectively. 5923% \begin{macrocode} 5924\def\extractcolorspecs#1#2#3% 5925 {\extractcolorspec{#1}#3% 5926 \edef#2{\expandafter\@firstoftwo#3}% 5927 \edef#3{\expandafter\@secondoftwo#3}} 5928% \end{macrocode} 5929% \end{macro} 5930% 5931% \begin{macro}{\XC@extract@hue} 5932% Extract first entry of comma-separated value list. 5933% \begin{macrocode} 5934\def\XC@extract@hue#1,#2:#3{\edef#3{#1}} 5935% \end{macrocode} 5936% \end{macro} 5937% 5938% \begin{macro}{\XC@extract@hue} 5939% Change first entry of comma-separated value list. 5940% \begin{macrocode} 5941\def\XC@replace@hue#1,#2:#3,#4{\edef#4{#3,#2}} 5942% \end{macrocode} 5943% \end{macro} 5944% 5945% \begin{macro}{\@ifundefinedcolor} 5946% \marg{name}\marg{undefined}\marg{defined}\\ 5947% Checks whether \Meta{name} is a defined color name and executes the respective code. 5948% \begin{macrocode} 5949\def\@ifundefinedcolor#1{\@ifundefined{\string\color@#1}} 5950% \end{macrocode} 5951% \end{macro} 5952% 5953% \begin{macro}{\@ifundefinedmodel} 5954% \marg{model}\marg{undefined}\marg{defined}\\ 5955% Checks whether \Meta{model} is a defined color model and executes the respective code. 5956% \begin{macrocode} 5957\def\@ifundefinedmodel#1{\@ifundefined{color@#1}} 5958% \end{macrocode} 5959% \end{macro} 5960% 5961% \begin{macro}{\XC@type} 5962% \marg{name}\\ 5963% 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}): 5964% \begin{center} 5965% \begin{tabular}{cll} 5966% \em type& \em description& \em conditions\\ 5967% 0 & undefined\\ 5968% 1 & unidentified& $t_1\neq|\xcolor@|$\\ 5969% 2 & named & $t_1=|\xcolor@|\quad t_2\neq\emptyset$\\ 5970% 3 & declared & $t_1=|\xcolor@|\quad t_2=\emptyset\quad t_3\neq\emptyset$\\ 5971% 4 & undeclared & $t_1=|\xcolor@|\quad t_2=\emptyset\quad t_3=\emptyset$\\ 5972% \end{tabular} 5973% \end{center} 5974% \begin{macrocode} 5975\def\XC@type#1% 5976 {\expandafter\expandafter\expandafter\XC@typ@ 5977 \csname\string\color@#1\endcsname\@empty\@empty\@empty\XC@@} 5978% \end{macrocode} 5979% 5980% \begin{macrocode} 5981\def\XC@typ@#1#2#3#4\XC@@ 5982 {\ifx#1\relax 0\else 5983 \ifx#1\xcolor@ 5984 \ifx$#2$% 5985 \ifx$#3$4\else3\fi\@gobbletwo 5986 \else2\fi\@gobbletwo 5987 \else1\fi 5988 \fi} 5989% \end{macrocode} 5990% \end{macro} 5991% 5992% \begin{macro}{\XC@info} 5993% \marg{color}\marg{cmd}\\ 5994% Determines the \emph{type} of color \Meta{color}, expressed as a natural number; the result is stored in \Meta{cmd}. 5995% \begin{center} 5996% \begin{tabular}{cll} 5997% \em type& \em description& \em examples\\ 5998% 0 & implicit name& `|.|'\\ 5999% 1 & explicit name& `|red|', `|green|'\\ 6000% 2 & standard color expression& `|-red|', `|green!50|'\\ 6001% 3 & extended color expression& `|rgb:-red,1;green!50,2|'\\ 6002% 4 & color function expression& `|rgb:-red,1;green!50,2>wheel,30|'\\ 6003% \end{tabular} 6004% \end{center} 6005% \begin{macrocode} 6006\def\XC@info#1#2% 6007 {\XC@edef#2{#1}% 6008 \if.#2\def#2{0}\else\expandafter\in@\expandafter>\expandafter{#2}% 6009 \ifin@\def#2{4}\else\expandafter\in@\expandafter:\expandafter{#2}% 6010 \ifin@\def#2{3}\else\expandafter\in@\expandafter!\expandafter{#2}% 6011 \ifin@\def#2{2}\else\edef#2{\noexpand\in@{/-}{/#2}}#2% 6012 \edef#2{\ifin@2\else1\fi}\fi\fi\fi\fi} 6013% \end{macrocode} 6014% \end{macro} 6015% 6016% \begin{macro}{\tracingcolors} 6017% Put the integer following |\tracingcolors| into the macro |\XC@tracing|. 6018% \begin{macrocode} 6019\def\tracingcolors{\begingroup\afterassignment\XC@tracingcolors\count@} 6020\def\XC@tracingcolors{\aftergroupdef\XC@tracing{\the\count@}} 6021% \end{macrocode} 6022% 6023% \begin{macrocode} 6024\tracingcolors=0 6025% \end{macrocode} 6026% \end{macro} 6027% 6028% \begin{macro}{\XC@logdef} 6029% \marg{name}\\ 6030% Issue a log file information if color \Meta{name} is being (re)defined. 6031% \begin{macrocode} 6032\def\XC@logdef#1% 6033 {\ifnum\XC@tracing>1 6034 \@ifundefinedcolor{#1}% 6035 {\ifnum\XC@tracing>2 6036 \PackageInfo{xcolor}{Defining color `#1'}% 6037 \fi}% 6038 {\PackageInfo{xcolor}{Redefining color `#1'}}% 6039 \fi} 6040% \end{macrocode} 6041% \end{macro} 6042% 6043% 6044% \subsubsection{Color testing} 6045% 6046% \begin{environment}{testcolors} 6047% \oarg{num models}\\ 6048% 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. 6049% The optional \Meta{num models} argument is a comma-separated list of \emph{numerical} color models. 6050% \begin{macrocode} 6051\newenvironment*{testcolors}[1][rgb,cmyk,hsb,HTML]% 6052 {\let\@@nam\@empty\count@\z@ 6053 \@for\@@tmp:=#1\do 6054 {\advance\count@\@ne 6055 \XC@sdef\@@tmp{\@@tmp}\edef\@@nam{\@@nam{\@@tmp}}}% 6056 \edef\@@num{\the\count@}% 6057% \end{macrocode} 6058% 6059% Check whether the actual font belongs to a set of OT1-encoded monospaced fonts in order to display |>| instead of |\textgreater|. 6060% \begin{macro}{\XC@@gt} 6061% \begin{macrocode} 6062 \def\XC@@gt{\textgreater}\def\@@tmp{OT1}% 6063 \ifx\f@encoding\@@tmp 6064 \@expandtwoargs\in@{,\f@family,}{,cmtt,pcr,}% 6065 \ifin@\def\XC@@gt{>}\fi 6066 \fi 6067% \end{macrocode} 6068% \end{macro} 6069% 6070% Disable prologue and tracing commands for temporary color definitions. 6071% \begin{macrocode} 6072% \XC@@xcpfalse \ifnum\XC@tracing>1 \def\XC@tracing{1}\fi 6073 \def\XC@@xcp@{-1}\ifnum\XC@tracing>1 \def\XC@tracing{1}\fi 6074% \end{macrocode} 6075% 6076% \begin{macro}{\testcolor} 6077% \marg{color}\\ 6078% \oarg{model-list}\marg{spec-list}\\ 6079% Each |\testcolor| command generates a table row. 6080% If the column-model matches the model of the color in question, its parameters are underlined. 6081% \begin{macrocode} 6082 \def\testcolor{\@testopt{\@testcolor}{}}% 6083 \def\@testcolor[##1]##2% 6084 {\XC@mdef\@@mod{##1}\XC@edef\@@clr{##2}% 6085 \ifx\@@mod\@empty 6086 \let\@@arg\@@clr\XC@replace\@@arg>\XC@@gt\else 6087 \edef\@@arg{[\@@mod]{\@@clr}}\XC@definecolor[]{*}\@@mod\@@clr 6088 \def\@@clr{*}\fi 6089 \XC@append\@@arg{&}\extractcolorspecs\@@clr\@@mod\@@clr 6090 \@testc@lor}% 6091% \end{macrocode} 6092% \end{macro} 6093% 6094% Common loop macro for table head and |\testcolor| rows. 6095% Note that this command is only available within the |testcolors| environment. 6096% \begin{macrocode} 6097 \def\@testc@lor 6098 {\count@\z@ 6099 \expandafter\@tfor\expandafter\@@tmp\expandafter:\expandafter=\@@nam\do 6100 {\ifx\@@clr\@empty 6101 \edef\@@cmd{\noexpand\textbf{\@@tmp}}% 6102 \else 6103 \convertcolorspec\@@mod\@@clr\@@tmp\@@cmd 6104 \edef\@@cmd 6105 {\noexpand\@testc@l@r{\@@tmp}{\@@cmd}% 6106 \ifx\@@mod\@@tmp\noexpand\underline\fi 6107 {\expandafter\XC@strip@comma\@@cmd,,\@nnil}}% 6108 \fi 6109 \expandafter\XC@append\expandafter\@@arg\expandafter{\@@cmd}% 6110 \advance\count@\@ne 6111 \ifnum\count@=\@@num\XC@append\@@arg{\\}\else\XC@append\@@arg{&}\fi}% 6112 \@@arg}% 6113% \end{macrocode} 6114% 6115% Display color sample box: 6116% \begin{macrocode} 6117 \def\@testc@l@r##1##2% 6118 {\fboxsep\z@\fbox{\colorbox[##1]{##2}{\phantom{XX}}} }% 6119% \end{macrocode} 6120% 6121% Now start the table: 6122% \begin{macrocode} 6123 \tabular{@{}l*{\@@num}{l}@{}}% 6124 \def\@@arg{\textbf{color}& }\let\@@clr\@empty\@testc@lor}% 6125% \end{macrocode} 6126% 6127% End of environment: 6128% \begin{macrocode} 6129 {\endtabular\ignorespacesafterend} 6130% \end{macrocode} 6131% \end{environment} 6132% 6133% 6134% \subsubsection{Extra groups} 6135% Turning on extra groups in the standard \LaTeX\ commands, so that color commands are scoped corectly. 6136% 6137% Like |\normalcolor|, the following five commands are defined in the kernel, with empty definitions (|\relax|). 6138% This means that they can be used to make macros in packages `color safe'. 6139% 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. 6140% 6141% \begin{macro}{\color@setgroup} 6142% 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. 6143% A matching |\color@endgroup| should be used at the end of the text. 6144% \begin{macrocode} 6145\def\color@setgroup{\begingroup\set@color} 6146% \end{macrocode} 6147% \end{macro} 6148% 6149% \begin{macro}{\color@begingroup} 6150% 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. 6151% 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. 6152% A matching |\color@endgroup| should be used at the end of the text. 6153% \begin{macrocode} 6154\let\color@begingroup\begingroup 6155% \end{macrocode} 6156% \end{macro} 6157% 6158% \begin{macro}{\color@endgroup} 6159% To be used to close the `group' started by one of the above two commands. 6160% 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. 6161% \begin{macrocode} 6162\def\color@endgroup{\endgraf\endgroup} 6163% \end{macrocode} 6164% \end{macro} 6165% 6166% \begin{macro}{\color@hbox} 6167% To be used to open a `colored hbox' 6168% \begin{macrocode} 6169\def\color@hbox{\hbox\bgroup\color@begingroup} 6170% \end{macrocode} 6171% \end{macro} 6172% 6173% \begin{macro}{\color@vbox} 6174% To be used to open a `colored hbox' 6175% \begin{macrocode} 6176\def\color@vbox{\vbox\bgroup\color@begingroup} 6177% \end{macrocode} 6178% \end{macro} 6179% 6180% \begin{macro}{\color@endbox} 6181% To be used to close a `colored (h/v)box' 6182% \begin{macrocode} 6183\def\color@endbox{\color@endgroup\egroup} 6184% \end{macrocode} 6185% \end{macro} 6186% 6187% 6188% 6189% \subsection{Color calculation} 6190% 6191% \subsubsection{Color conversion} 6192% 6193% \begin{macro}{\convertcolorspec} 6194% \marg{source model}\marg{spec}\marg{target model}\marg{cmd}\\ 6195% General color conversion command. 6196% \begin{macrocode} 6197\def\convertcolorspec#1#2#3#4% 6198 {\begingroup 6199 \XC@sdef\sm{#1}\XC@sdef\tm{#3}\edef\@@tmp{#2}% 6200 \ifx\sm\XC@mod@named\extractcolorspecs\@@tmp\sm\@@tmp\fi 6201 \ifx\sm\tm\else\csname XC@cnv@\sm\expandafter\endcsname\@@tmp,\fi 6202 \aftergroupdef#4\@@tmp} 6203% \end{macrocode} 6204% \end{macro} 6205% 6206% \begin{macro}{\XC@coremodel} 6207% \marg{model-cmd}\marg{color-cmd}\\ 6208% Convert color, given by \marg{model-cmd} and \marg{color-cmd}, into parametrisation in one of the \emph{core} models. 6209% The result is again saved in \marg{model-cmd} and \marg{color-cmd}. 6210% \begin{macrocode} 6211\def\XC@coremodel#1#2% 6212 {\XC@ifxcase#1% 6213 {\XC@mod@RGB {\convertcolorspec#1#2\XC@mod@rgb#2\let#1\XC@mod@rgb}% 6214 \XC@mod@HTML{\convertcolorspec#1#2\XC@mod@rgb#2\let#1\XC@mod@rgb}% 6215 \XC@mod@Hsb {\convertcolorspec#1#2\XC@mod@hsb#2\let#1\XC@mod@hsb}% 6216 \XC@mod@tHsb{\convertcolorspec#1#2\XC@mod@hsb#2\let#1\XC@mod@hsb}% 6217 \XC@mod@HSB {\convertcolorspec#1#2\XC@mod@hsb#2\let#1\XC@mod@hsb}% 6218 \XC@mod@Gray{\convertcolorspec#1#2\XC@mod@gray#2\let#1\XC@mod@gray}% 6219 \XC@mod@wave{\convertcolorspec#1#2\XC@mod@hsb#2\let#1\XC@mod@hsb}% 6220 \XC@mod@named{}% 6221 \XC@mod@ps{}}% 6222 {\expandafter\XC@calc@#2,,,,:N\let#2\@@tmp}} 6223% \end{macrocode} 6224% \end{macro} 6225% 6226% \begin{macro}{\XC@cnv@rgb} 6227% \Meta{red}|,|\Meta{green}|,|\Meta{blue}|,| 6228% \begin{macrocode} 6229\def\XC@cnv@rgb#1,#2,#3,% 6230 {\XC@ifxcase\tm 6231 {\XC@mod@cmy {\XC@calc@#1,#2,#3,,:C}% 6232 \XC@mod@cmyk 6233 {\XC@calc@#1,#2,#3,,:C\expandafter\XC@cnv@cmy@cmyk\@@tmp,}% 6234 \XC@mod@RGB {\edef\@@scl{\rangeRGB}\XC@calc@#1,#2,#3,,:M}% 6235 \XC@mod@HTML{\edef\@@scl{\@cclv}\XC@calc@#1,#2,#3,,:M% 6236 \expandafter\XC@calc@\@@tmp,,:H% 6237 \expandafter\XC@cnv@rgb@HTML\@@tmp,}% 6238 \XC@mod@gray{\XC@cnv@rgb@gray#1,#2,#3,}% 6239 \XC@mod@Gray{\XC@cnv@rgb@gray#1,#2,#3,\XC@cnv@gray\@@tmp,}}% 6240 {\XC@cnv@rgb@hsb#1,#2,#3,\XC@cnv@hsb@}} 6241% \end{macrocode} 6242% 6243% \begin{macro}{\XC@cnv@rgb@} 6244% \begin{macrocode} 6245\def\XC@cnv@rgb@ 6246 {\ifx\tm\XC@mod@rgb\else\expandafter\XC@cnv@rgb\@@tmp,\fi} 6247% \end{macrocode} 6248% \end{macro} 6249% \end{macro} 6250% 6251% \begin{macro}{\XC@cnv@rgb@hsb} 6252% \Meta{red}|,|\Meta{green}|,|\Meta{blue}|,| 6253% \begin{macrocode} 6254\def\XC@cnv@rgb@hsb#1,#2,#3,% 6255 {\count@\z@ 6256 \ifdim#2\p@>#1\p@ \else\advance\count@4 \fi 6257 \ifdim#3\p@>#2\p@ \else\advance\count@2 \fi 6258 \ifdim#1\p@>#3\p@ \else\advance\count@1 \fi 6259 \ifcase\count@\or 6260 \XC@c@v@rgb@hsb{#3}{#2}{#1}3{}\or 6261 \XC@c@v@rgb@hsb{#2}{#1}{#3}1{}\or 6262 \XC@c@v@rgb@hsb{#2}{#3}{#1}3-\or 6263 \XC@c@v@rgb@hsb{#1}{#3}{#2}5{}\or 6264 \XC@c@v@rgb@hsb{#3}{#1}{#2}5-\or 6265 \XC@c@v@rgb@hsb{#1}{#2}{#3}1-\or 6266 \def\@tempa{0}\def\@tempb{0}\XC@calcN{#3}\@tempc 6267 \fi 6268 \edef\@@tmp{\@tempa,\@tempb,\@tempc}} 6269% \end{macrocode} 6270% \end{macro} 6271% 6272% \begin{macro}{\XC@c@v@rgb@hsb} 6273% \marg{max}\marg{med}\marg{min}\marg{const}\marg{sign} 6274% \begin{macrocode} 6275\def\XC@c@v@rgb@hsb#1#2#3#4#5% 6276 {\XC@calcN{#1}\@tempc \llshiftset\dimen@{#1}% 6277 \llshiftset\@tempdimb{-#3}\advance\@tempdimb\dimen@ 6278 \llshiftset\@tempdima{-#5#2}\advance\@tempdima#5\dimen@ 6279 \advance\@tempdima#4\@tempdimb \rdivide\@tempdima{6\@tempdimb}% 6280 \edef\@tempa{\ifdim\@tempdima>\p@1\else\strip@pt\@tempdima\fi}% 6281 \rdivide\@tempdimb\dimen@ 6282 \edef\@tempb{\strip@pt\@tempdimb}} 6283% \end{macrocode} 6284% \end{macro} 6285% 6286% \begin{macro}{\XC@cnv@rgb@gray} 6287% \Meta{red}|,|\Meta{green}|,|\Meta{blue}|,| 6288% \begin{macrocode} 6289\def\XC@cnv@rgb@gray#1,#2,#3,% 6290 {\llshiftset\dimen@{#1}\@tempdima30\dimen@ 6291 \llshiftset\dimen@{#2}\advance\@tempdima59\dimen@ 6292 \llshiftset\dimen@{#3}\advance\@tempdima11\dimen@ 6293 \rrshift\@tempdima \rdivide\@tempdima{100}% 6294 \edef\@@tmp{\strip@pt\@tempdima}} 6295% \end{macrocode} 6296% \end{macro} 6297% 6298% \begin{macro}{\XC@cnv@rgb@HTML} 6299% \Meta{red}|,|\Meta{green}|,|\Meta{blue}|,| 6300% \begin{macrocode} 6301\def\XC@cnv@rgb@HTML#1,#2,#3,% 6302 {\edef\@@tmp{#1#2#3}} 6303% \end{macrocode} 6304% \end{macro} 6305% 6306% 6307% \begin{macro}{\XC@cnv@cmy} 6308% \Meta{cyan}|,|\Meta{magenta}|,|\Meta{yellow}|,| 6309% \begin{macrocode} 6310\def\XC@cnv@cmy#1,#2,#3,% 6311 {\XC@ifxcase\tm 6312 {\XC@mod@cmyk{\XC@cnv@cmy@cmyk#1,#2,#3,}% 6313 \XC@mod@gray{\XC@cnv@rgb@gray#1,#2,#3,\XC@calcC\@@tmp\@@tmp}% 6314 \XC@mod@Gray{\XC@cnv@rgb@gray#1,#2,#3,\XC@calcC\@@tmp\@@tmp 6315 \XC@cnv@gray\@@tmp,}}% 6316 {\XC@calc@#1,#2,#3,,:C\XC@cnv@rgb@}} 6317% \end{macrocode} 6318% \end{macro} 6319% 6320% \begin{macro}{\XC@cnv@cmy@cmyk} 6321% \Meta{cyan}|,|\Meta{magenta}|,|\Meta{yellow}|,|\\ 6322% This transformation includes linear \emph{undercolor-removal} and \emph{black-generation}, as specified by the 4-dimensional parameter vector |\adjustUCRBG|. 6323% \begin{macrocode} 6324\def\XC@cnv@cmy@cmyk#1,#2,#3,% 6325 {\edef\@@scl 6326 {\ifdim#1\p@<#2\p@ 6327 \ifdim#1\p@<#3\p@ #1\else #3\fi \else 6328 \ifdim#2\p@<#3\p@ #2\else #3\fi \fi}% 6329 \expandafter\XC@calc@\adjustUCRBG,:S% 6330 \expandafter\XC@c@v@cmy@cmyk\@@tmp,#1,#2,#3,} 6331% \end{macrocode} 6332% 6333% \begin{macrocode} 6334\def\XC@c@v@cmy@cmyk#1,#2,#3,#4,#5,#6,#7,% 6335 {\XC@add#5,#6,#7,,-#1,-#2,-#3,,\@@tmp \edef\@@tmp{\@@tmp,#4}% 6336 \expandafter\XC@calc@\@@tmp,:N} 6337% \end{macrocode} 6338% \end{macro} 6339% 6340% 6341% \begin{macro}{\XC@cnv@cmyk} 6342% \Meta{cyan}|,|\Meta{magenta}|,|\Meta{yellow}|,|\Meta{black}|,| 6343% \begin{macrocode} 6344\def\XC@cnv@cmyk#1,#2,#3,#4,% 6345 {\XC@ifxcase\tm 6346 {\XC@mod@gray{\XC@cnv@rgb@gray#1,#2,#3,\edef\@@arg{#4}% 6347 \XC@calcT\@@tmp\@@tmp \XC@calcC\@@tmp\@@tmp}% 6348 \XC@mod@Gray{\XC@cnv@rgb@gray#1,#2,#3,\edef\@@arg{#4}% 6349 \XC@calcT\@@tmp\@@tmp \XC@calcC\@@tmp\@@tmp \XC@cnv@gray\@@tmp,}}% 6350 {\XC@cnv@cmyk@cmy#1,#2,#3,#4,% 6351 \ifx\tm\XC@mod@cmy\else\expandafter\XC@cnv@cmy\@@tmp,\fi}} 6352% \end{macrocode} 6353% \end{macro} 6354% 6355% \begin{macro}{\XC@cnv@cmyk@cmy} 6356% \Meta{cyan}|,|\Meta{magenta}|,|\Meta{yellow}|,|\Meta{black}|,| 6357% \begin{macrocode} 6358\def\XC@cnv@cmyk@cmy#1,#2,#3,#4,% 6359 {\edef\@@arg{#4}\XC@calc@#1,#2,#3,,:T} 6360% \end{macrocode} 6361% \end{macro} 6362% 6363% 6364% \begin{macro}{\XC@cnv@hsb} 6365% \Meta{hue}|,|\Meta{saturation}|,|\Meta{brightness}|,| 6366% \begin{macrocode} 6367\def\XC@cnv@hsb#1,#2,#3,% 6368 {\XC@ifxcase\tm 6369 {\XC@mod@Hsb {\XC@cnv@hsb@Hsb#1,#2,#3,}% 6370 \XC@mod@tHsb{\XC@cnv@hsb@Hsb#1,#2,#3,\expandafter\XC@cnv@Hsb\@@tmp,}% 6371 \XC@mod@HSB {\edef\@@scl{\rangeHSB}\XC@calc@#1,#2,#3,,:M}}% 6372 {\XC@cnv@hsb@rgb#1,#2,#3,\XC@cnv@rgb@}} 6373% \end{macrocode} 6374% 6375% \begin{macro}{\XC@cnv@hsb@} 6376% \begin{macrocode} 6377\def\XC@cnv@hsb@ 6378 {\ifx\tm\XC@mod@hsb\else\expandafter\XC@cnv@hsb\@@tmp,\fi} 6379% \end{macrocode} 6380% \end{macro} 6381% \end{macro} 6382% 6383% \begin{macro}{\XC@cnv@hsb@rgb} 6384% \Meta{hue}|,|\Meta{saturation}|,|\Meta{brightness}|,| 6385% \begin{macrocode} 6386\def\XC@cnv@hsb@rgb#1,#2,#3,% 6387 {\llshiftset\dimen@{#1}\dimen@6\dimen@ \rrshift\dimen@ 6388 \afterassignment\dimen@\count@=\the\dimen@ 6389 \edef\@@tmp{\strip@pt\dimen@}% 6390 \ifodd\count@\else\XC@calcC\@@tmp\@@tmp\fi 6391 \edef\@@tmp 6392 {\ifcase\count@ 0,\@@tmp,1\or \@@tmp,0,1\or 1,0,\@@tmp\or 6393 1,\@@tmp,0\or \@@tmp,1,0\or 0,1,\@@tmp\or 0,\@@tmp,1\fi}% 6394 \edef\@@scl{#2}\expandafter\XC@calc@\@@tmp,,:S% 6395 \expandafter\XC@calc@\@@tmp,,:C% 6396 \edef\@@scl{#3}\expandafter\XC@calc@\@@tmp,,:S% 6397 \expandafter\XC@calc@\@@tmp,,:N} 6398% \end{macrocode} 6399% \end{macro} 6400% 6401% \begin{macro}{\XC@cnv@hsb@Hsb} 6402% \Meta{hue}|,|\Meta{saturation}|,|\Meta{brightness}|,| 6403% \begin{macrocode} 6404\def\XC@cnv@hsb@Hsb#1,#2,#3,% 6405 {\XC@c@lcS\rangeHsb{,#2,#3}{#1}\@@tmp} 6406% \end{macrocode} 6407% \end{macro} 6408% 6409% \begin{macro}{\XC@cnv@gray} 6410% \Meta{gray}|,| 6411% \begin{macrocode} 6412\def\XC@cnv@gray#1,% 6413 {\XC@ifxcase\tm 6414 {\XC@mod@rgb {\XC@calcN{#1}\@@tmp \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}}% 6415 \XC@mod@cmy {\XC@calcC{#1}\@@tmp \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}}% 6416 \XC@mod@cmyk{\XC@calcC{#1}\@@tmp \edef\@@tmp{0,0,0,\@@tmp}}% 6417 \XC@mod@RGB {\edef\@@scl{\rangeRGB}\XC@calcM{#1}\@@tmp 6418 \edef\@@tmp{\@@tmp,\@@tmp,\@@tmp}}% 6419 \XC@mod@HTML{\edef\@@scl{\@cclv}\XC@calcM{#1}\@@tmp 6420 \XC@calcH\@@tmp\@@tmp \edef\@@tmp{\@@tmp\@@tmp\@@tmp}}% 6421 \XC@mod@HSB {\edef\@@scl{\rangeHSB}\XC@calcM{#1}\@@tmp 6422 \edef\@@tmp{0,0,\@@tmp}}% 6423 \XC@mod@Gray{\edef\@@scl{\rangeGray}\XC@calcM{#1}\@@tmp}}% 6424 {\XC@calcN{#1}\@@tmp \edef\@@tmp{0,0,\@@tmp}}} 6425% \end{macrocode} 6426% \end{macro} 6427% 6428% 6429% \begin{macro}{\XC@cnv@RGB} 6430% \Meta{Red}|,|\Meta{Green}|,|\Meta{Blue}|,| 6431% \begin{macrocode} 6432\def\XC@cnv@RGB#1,#2,#3,% 6433 {\edef\@@scl{\rangeRGB}\XC@calc@#1,#2,#3,,:D\XC@cnv@rgb@} 6434% \end{macrocode} 6435% \end{macro} 6436% 6437% 6438% \begin{macro}{\XC@cnv@HTML} 6439% \Meta{RRGGBB}|,| 6440% \begin{macrocode} 6441\def\XC@cnv@HTML#1,% 6442 {\edef\@@tmp{\expandafter\@hex@Hex#1\relax}\expandafter\XC@cnv@HTML@\@@tmp 6443 \edef\@@scl{\@cclv}\expandafter\XC@calc@\@@tmp,,:D\XC@cnv@rgb@} 6444% \end{macrocode} 6445% 6446% \begin{macrocode} 6447\def\XC@cnv@HTML@#1#2#3#4#5#6% 6448 {\edef\@@tmp{\number"#1#2,\number"#3#4,\number"#5#6}} 6449% \end{macrocode} 6450% \end{macro} 6451% 6452% 6453% \begin{macro}{\XC@cnv@Hsb} 6454% \Meta{hue\Circ}|,|\Meta{saturation}|,|\Meta{brightness}|,| 6455% \begin{macrocode} 6456\def\XC@cnv@Hsb#1,#2,#3,% 6457 {\ifx\tm\XC@mod@tHsb\XC@cnv@@Hsb#1,#2,#3,\XC@cnv@Hsb@ 6458 \else\XC@cnv@Hsb@hsb#1,#2,#3,\XC@cnv@hsb@\fi} 6459% \end{macrocode} 6460% \end{macro} 6461% 6462% \begin{macro}{\XC@cnv@Hsb@hsb} 6463% \Meta{hue\Circ}|,|\Meta{saturation}|,|\Meta{brightness}|,| 6464% \begin{macrocode} 6465\def\XC@cnv@Hsb@hsb#1,#2,#3,% 6466 {\XC@c@lcD\rangeHsb{,#2,#3}{#1}\@@tmp} 6467% \end{macrocode} 6468% \end{macro} 6469% 6470% \begin{macro}{\XC@cnv@@Hsb} 6471% \Meta{hue\Circ}|,|\Meta{saturation}|,|\Meta{brightness}|,|\marg{cmd} 6472% \begin{macrocode} 6473\def\XC@cnv@@Hsb#1,#2,#3,#4% 6474 {\dimen@\rangeHsb\p@ \advance\dimen@\p@ \edef\@@tmp{\strip@pt\dimen@}% 6475 \edef\@@tmp{0,0;\rangetHsb;\rangeHsb,\rangeHsb;\@@tmp,\@@tmp;}% 6476 \dimen@#1\p@ \expandafter#4\@@tmp\@nnil 6477 \edef\@@tmp{\strip@pt\dimen@,#2,#3}} 6478% \end{macrocode} 6479% \end{macro} 6480% 6481% \begin{macro}{\XC@cnv@Hsb@} 6482% \Meta{x}|,|\Meta{y}|;|\Meta{x'}|,|\Meta{y'}|;| 6483% \begin{macrocode} 6484\def\XC@cnv@Hsb@#1,#2;#3,#4;% 6485 {\ifdim\dimen@<#4\p@ 6486 \@tempdima#3\p@ \advance\@tempdima-#1\p@ 6487 \@tempdimb#4\p@ \advance\@tempdimb-#2\p@ 6488 \rdivide\@tempdima\@tempdimb 6489 \advance\dimen@-#2\p@ \rmultiply\dimen@{\strip@pt\@tempdima}% 6490 \advance\dimen@#1\p@ \expandafter\remove@to@nnil 6491 \else 6492 \def\@@tmp{\XC@cnv@Hsb@#3,#4;}\expandafter\@@tmp 6493 \fi} 6494% \end{macrocode} 6495% \end{macro} 6496% 6497% 6498% \begin{macro}{\XC@cnv@tHsb} 6499% \Meta{hue\Circ}|,|\Meta{saturation}|,|\Meta{brightness}|,| 6500% \begin{macrocode} 6501\def\XC@cnv@tHsb#1,#2,#3,% 6502 {\XC@cnv@@Hsb#1,#2,#3,\XC@cnv@tHsb@ 6503 \ifx\tm\XC@mod@Hsb\else\expandafter\XC@cnv@Hsb\@@tmp,\fi} 6504% \end{macrocode} 6505% \end{macro} 6506% 6507% \begin{macro}{\XC@cnv@tHsb@} 6508% \Meta{x}|,|\Meta{y}|;|\Meta{x'}|,|\Meta{y'}|;| 6509% \begin{macrocode} 6510\def\XC@cnv@tHsb@#1,#2;#3,#4;% 6511 {\ifdim\dimen@<#3\p@ 6512 \@tempdima#4\p@ \advance\@tempdima-#2\p@ 6513 \@tempdimb#3\p@ \advance\@tempdimb-#1\p@ 6514 \rdivide\@tempdima\@tempdimb 6515 \advance\dimen@-#1\p@ \rmultiply\dimen@{\strip@pt\@tempdima}% 6516 \advance\dimen@#2\p@ \expandafter\remove@to@nnil 6517 \else 6518 \def\@@tmp{\XC@cnv@tHsb@#3,#4;}\expandafter\@@tmp 6519 \fi} 6520% \end{macrocode} 6521% \end{macro} 6522% 6523% 6524% \begin{macro}{\XC@cnv@HSB} 6525% \Meta{Hue}|,|\Meta{Saturation}|,|\Meta{Brightness}|,| 6526% \begin{macrocode} 6527\def\XC@cnv@HSB#1,#2,#3,% 6528 {\edef\@@scl{\rangeHSB}\XC@calc@#1,#2,#3,,:D\XC@cnv@hsb@} 6529% \end{macrocode} 6530% \end{macro} 6531% 6532% 6533% \begin{macro}{\XC@cnv@Gray} 6534% \Meta{Gray}|,| 6535% \begin{macrocode} 6536\def\XC@cnv@Gray#1,% 6537 {\XC@c@lcD\rangeGray{}{#1}\@@tmp \XC@cnv@gray\@@tmp,} 6538% \end{macrocode} 6539% \end{macro} 6540% 6541% 6542% \begin{macro}{\XC@cnv@wave} 6543% \Meta{lambda}|,| 6544% \begin{macrocode} 6545\def\XC@cnv@wave#1,% 6546 {\XC@cnv@wave@hsb#1,\XC@cnv@hsb@} 6547% \end{macrocode} 6548% \end{macro} 6549% 6550% \begin{macro}{\XC@cnv@wave@hsb} 6551% \Meta{lambda}|,| 6552% \begin{macrocode} 6553\def\XC@cnv@wave@hsb#1,% 6554 {\@tempdima#1\p@ 6555% \end{macrocode} 6556% 6557% Calculate hue: 6558% \begin{macrocode} 6559 \ifdim\@tempdima<440\p@ 6560 \XC@c@v@wave@hsb{-.0166667}{7.33333}4{}\else 6561 \ifdim\@tempdima<490\p@ 6562 \XC@c@v@wave@hsb{.02}{-8.8}4-\else 6563 \ifdim\@tempdima<510\p@ 6564 \XC@c@v@wave@hsb{-.05}{25.5}2{}\else 6565 \ifdim\@tempdima<580\p@ 6566 \XC@c@v@wave@hsb{.0142857}{-7.28571}2-\else 6567 \ifdim\@tempdima<645\p@ 6568 \XC@c@v@wave@hsb{-.0153846}{9.92308}0{}\else 6569 \dimen@\z@ \fi\fi\fi\fi\fi 6570 \divide\dimen@6\relax 6571 \edef\@@tmp{\strip@pt\dimen@,1,}% 6572% \end{macrocode} 6573% 6574% Calculate brightness: 6575% \begin{macrocode} 6576 \ifdim\@tempdima<420\p@ 6577 \XC@c@v@wave@hsb{.0175}{-6.35}0{}\else 6578 \ifdim\@tempdima>700\p@ 6579 \XC@c@v@wave@hsb{-.00875}{7.125}0{}\else 6580 \dimen@\p@ \fi\fi 6581 \edef\@@tmp{\@@tmp\strip@pt\dimen@}} 6582% \end{macrocode} 6583% \end{macro} 6584% 6585% \begin{macro}{\XC@c@v@wave@hsb} 6586% \marg{factor}\marg{const}\marg{offset}\marg{sign}\\ 6587% Calculates $\Meta{offset} + \Meta{sign}\cdot\varrho\bigl(\Meta{const} + \Meta{factor}\cdot\lambda\bigr)$, where $\varrho$ is the reduction function. 6588% The result is stored in |\dimen@|. 6589% \begin{macrocode} 6590\def\XC@c@v@wave@hsb#1#2#3#4% 6591 {\dimen@#1\@tempdima \advance\dimen@#2\p@ 6592 \XC@calcR{\strip@pt\dimen@}\@tempa 6593 \dimen@#4\@tempa\p@ \advance\dimen@#3\p@} 6594% \end{macrocode} 6595% \end{macro} 6596% 6597% 6598% \subsubsection{Color complement} 6599% 6600% \begin{macro}{\XC@cnv@cmyk@compl} 6601% \Meta{cyan}|,|\Meta{magenta}|,|\Meta{yellow}|,|\Meta{black}|,| 6602% \begin{macrocode} 6603\def\XC@cnv@cmyk@compl#1,#2,#3,#4,% 6604 {\XC@cnv@cmyk@cmy#1,#2,#3,#4,% 6605 \expandafter\XC@calc@\@@tmp,,:C\expandafter\XC@cnv@cmy@cmyk\@@tmp,} 6606% \end{macrocode} 6607% \end{macro} 6608% 6609% \begin{macro}{\XC@cnv@hsb@compl} 6610% \Meta{hue}|,|\Meta{saturation}|,|\Meta{brightness}|,| 6611% \begin{macrocode} 6612\def\XC@cnv@hsb@compl#1,#2,#3,% 6613 {\lshiftset\dimen@{#1}\advance\dimen@\ifdim\dimen@<5\p@-\fi-5\p@ 6614 \rshift\dimen@ \edef\@@tmp{\strip@pt\dimen@}% 6615 \lshiftset\dimen@{#3}\@tempdima#2\dimen@ 6616 \@tempdimb\@tempdima \advance\@tempdimb10\p@ \advance\@tempdimb-\dimen@ 6617 \ifdim\@tempdimb=\z@ 6618 \edef\@@tmp{\@@tmp,0,0}% 6619 \else 6620 \rdivide\@tempdima\@tempdimb \rshift\@tempdimb 6621 \edef\@@tmp{\@@tmp,\strip@pt\@tempdima,\strip@pt\@tempdimb}% 6622 \fi} 6623% \end{macrocode} 6624% \end{macro} 6625% 6626% 6627% 6628% \subsection{Color initialisation} 6629% 6630% \subsubsection{Support for missing color models} 6631% 6632% These macros provide generic support for missing color models in specific drivers. 6633% For example, \File{pdftex.def} does not support the \Model{hsb} model. 6634% It is assumed that at least one of the models \Model{rgb}, \Model{RGB}, \Model{HTML}, \Model{hsb}, \Model{Hsb}, \Model{HSB}, \Model{cmy}, \Model{cmyk}, \Model{gray}, \Model{Gray} exists. 6635% 6636% \begin{macro}{\substitutecolormodel} 6637% \marg{source model}\marg{target model-list}\\ 6638% Substitute \Meta{source model} by the first actually present model from \Meta{target model-list}: 6639% 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}. 6640% \begin{macrocode} 6641\def\substitutecolormodel#1#2% 6642 {\XC@sdef\XC@@tmp{\expandafter\XC@substitutecolormodel#2/ignore/\@nnil}% 6643 \ifx\XC@@tmp\XC@mod@ignore 6644 \XC@let@cN{color@#1}\color@ignore 6645 \else 6646 \expandafter\edef\csname color@#1\endcsname##1##2% 6647 {\noexpand\convertcolorspec 6648 \expandafter\noexpand\csname XC@mod@#1\endcsname{##2}% 6649 \expandafter\noexpand\csname XC@mod@\XC@@tmp\endcsname 6650 \noexpand\XC@@tmp\noexpand\expandafter 6651 \expandafter\noexpand\csname color@\XC@@tmp\endcsname 6652 \noexpand\expandafter##1\noexpand\expandafter{\noexpand\XC@@tmp}}% 6653 \fi 6654 \expandafter\xglobalize@\csname color@#1\endcsname \xglobal@stop 6655 \PackageInfo{xcolor}{Model `#1' substituted by `\XC@@tmp'}} 6656% \end{macrocode} 6657% 6658% \begin{macrocode} 6659\def\XC@substitutecolormodel#1/% 6660 {\@ifundefinedmodel{#1}{\XC@substitutecolormodel}{#1\remove@to@nnil}} 6661% \end{macrocode} 6662% \end{macro} 6663% 6664% \begin{macro}{\color@ignore} 6665% \marg{cmd}\marg{spec}\\ 6666% Empty color model: no driver-specific representation at all. 6667% \begin{macrocode} 6668\def\color@ignore#1#2{\def#1{}} 6669% \end{macrocode} 6670% \end{macro} 6671% 6672% \begin{macro}{\color@rgb} 6673% \marg{cmd}\marg{spec}\\ 6674% Takes the color specification \Meta{spec}, turns it into a driver-specific representation and puts the result into the macro \Meta{cmd}. 6675% 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}|. 6676% In the case of \File{pdftex.def}, it will act like |\def\foo{1 0 0 rg 1 0 0 RG}| instead. 6677% \begin{macrocode} 6678\@ifundefinedmodel{rgb}% 6679 {\substitutecolormodel{rgb}{RGB/HTML/hsb/Hsb/HSB/cmy/cmyk/gray/Gray}}{} 6680% \end{macrocode} 6681% \end{macro} 6682% 6683% \begin{macro}{\color@cmyk} 6684% \marg{cmd}\marg{spec} 6685% \begin{macrocode} 6686\@ifundefinedmodel{cmyk}{\substitutecolormodel{cmyk}{cmy/rgb}}{} 6687% \end{macrocode} 6688% \end{macro} 6689% 6690% \begin{macro}{\color@cmy} 6691% \marg{cmd}\marg{spec} 6692% \begin{macrocode} 6693\@ifundefinedmodel{cmy}% 6694 {\PackageInfo{xcolor}{Model `cmy' substituted by `cmy0'} 6695 \def\color@cmy#1#2{\color@cmyk#1{#2,0}}}{} 6696% \end{macrocode} 6697% \end{macro} 6698% 6699% \begin{macro}{\color@hsb} 6700% \marg{cmd}\marg{spec}\\ 6701% Since the \Option{dvipdfm} and \Option{textures} drivers only pretend to support \Model{hsb}, we have to check for these drivers. 6702% \begin{macrocode} 6703\@ifundefinedmodel{hsb}{\@tempswatrue}% 6704 {\XC@ifcase\XC@@drv{{dvipdfm,textures}\@tempswatrue}\@tempswafalse} 6705\if@tempswa 6706 \substitutecolormodel{hsb}{Hsb/HSB/rgb} 6707\fi 6708% \end{macrocode} 6709% \end{macro} 6710% 6711% \begin{macro}{\color@RGB} 6712% \marg{cmd}\marg{spec}\\ 6713% If the model is supported and |\rangeRGB| equals 255, we stick to the algorithm provided by the driver. 6714% \begin{macrocode} 6715\@ifundefinedmodel{RGB}% 6716 {\substitutecolormodel{RGB}{HTML/rgb}} 6717 {\PackageInfo{xcolor}{Model `RGB' extended} 6718 \let\XC@color@RGB\color@RGB 6719 \def\color@RGB#1#2% 6720 {\relax\ifnum\rangeRGB=255 6721 \XC@color@RGB#1{#2}% 6722 \else 6723 \convertcolorspec\XC@mod@RGB{#2}\XC@mod@rgb\XC@@tmp 6724 \expandafter\color@rgb\expandafter#1\expandafter{\XC@@tmp}% 6725 \fi}} 6726% \end{macrocode} 6727% \end{macro} 6728% 6729% \begin{macro}{\color@gray} 6730% \begin{macro}{\color@HTML} 6731% \begin{macro}{\color@Hsb} 6732% \begin{macro}{\color@tHsb} 6733% \begin{macro}{\color@HSB} 6734% \begin{macro}{\color@Gray} 6735% \begin{macro}{\color@wave} 6736% \marg{cmd}\marg{spec} 6737% \begin{macrocode} 6738\@ifundefinedmodel{gray}{\substitutecolormodel{gray}{Gray/rgb}}{} 6739\@ifundefinedmodel{HTML}{\substitutecolormodel{HTML}{rgb}}{} 6740\@ifundefinedmodel{Hsb}{\substitutecolormodel{Hsb}{hsb}}{} 6741\@ifundefinedmodel{tHsb}{\substitutecolormodel{tHsb}{hsb}}{} 6742\@ifundefinedmodel{HSB}{\substitutecolormodel{HSB}{hsb}}{} 6743\@ifundefinedmodel{Gray}{\substitutecolormodel{Gray}{gray}}{} 6744\@ifundefinedmodel{wave}{\substitutecolormodel{wave}{hsb}}{} 6745% \end{macrocode} 6746% \end{macro} 6747% \end{macro} 6748% \end{macro} 6749% \end{macro} 6750% \end{macro} 6751% \end{macro} 6752% \end{macro} 6753% 6754% 6755% \subsubsection{PostScript-related stuff} 6756% 6757% \begin{macrocode} 6758\@ifundefined{XC@pst}{% 6759% \end{macrocode} 6760% 6761% \begin{macro}{\XC@getcolor} 6762% \marg{color}\marg{cmd}\\ 6763% \marg{color command}\marg{cmd}\\ 6764% |{|\oarg{model}\marg{spec}|}|\marg{cmd}\\ 6765% Transformation of a color, given by the first argument, especially needed for \Package{pstricks}. 6766% The result will always be an internal color representation (as described in section \vref{sec.definition}) and is stored in \Meta{cmd}. 6767% There are different ways of specifying the color: 6768% \begin{itemize} 6769% \item \Meta{color} is a color name, expression, etc., e.g., |\XC@getcolor{green!50}\foo|; 6770% \item \Meta{color command} is a macro whose \emph{first level} expansion is an internal color representation, e.g., |\XC@getcolor\pslinecolor\foo|; 6771% \item \Meta{model} and \Meta{spec} provide, as usual, explicit parameter specifications. 6772% \end{itemize} 6773% \begin{macrocode} 6774\def\XC@getcolor#1#2% 6775 {\begingroup\toks@{#1}\XC@getc@lor#1\XC@@\aftergroupdef#2{\@@tmp}} 6776% \end{macrocode} 6777% 6778% Check whether the argument consists of one or more tokens. 6779% In the first case, expand by one level and go to next check. 6780% 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). 6781% 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. 6782% \begin{macrocode} 6783\def\XC@getc@lor#1#2\XC@@ 6784 {\@ifxempty{#2}% 6785 {\expandafter\XC@getc@l@r#1\XC@@}% 6786 {\let\set@color\relax 6787 \ifx#1[% 6788 \expandafter\@undeclaredcolor\the\toks@\else 6789 \expandafter\@declaredcolor\expandafter{\the\toks@}\fi 6790 \let\@@tmp\XC@current@color}} 6791% \end{macrocode} 6792% 6793% Check whether the first token is |\xcolor@|. 6794% In that case, |#1#2| is assumed to be a complete internal color representation. 6795% Otherwise, perform a simulation as described before. 6796% \begin{macrocode} 6797\def\XC@getc@l@r#1#2\XC@@ 6798 {\ifx#1\xcolor@ 6799 \def\@@tmp{\xcolor@#2}% 6800 \else 6801 \let\set@color\relax 6802 \expandafter\@declaredcolor\expandafter{\the\toks@}% 6803 \let\@@tmp\XC@current@color 6804 \fi} 6805% \end{macrocode} 6806% \end{macro} 6807% 6808% This alternative code is temporarily needed for compatibility reasons if \Package{pstricks} is loaded via the \Option{pst} option: 6809% \begin{macrocode} 6810}{% compatibility code begin 6811\def\XC@getcolor#1#2% 6812 {\@ifundefinedcolor{#1}% 6813 {\begingroup\color{#1}% 6814 \edef\@@tmp 6815 {\edef\noexpand#2{\noexpand\expandafter\noexpand\c@lor@to@ps 6816 \current@color\noexpand\@@}}% 6817 \expandafter\endgroup\@@tmp}% 6818 {\edef#2{\XC@usecolor{#1}}}} 6819}% compatibility code end 6820% \end{macrocode} 6821% 6822% \begin{macro}{\XC@usecolor} 6823% \marg{name}\\ 6824% \marg{color command}\\ 6825% Transformation of a color into \Index{PostScript} code. 6826% 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}|). 6827% 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. 6828% \begin{macrocode} 6829\def\XC@usecolor#1{\expandafter\XC@usec@lor#1\XC@@} 6830\def\XC@usec@lor#1#2\XC@@ 6831 {\ifx#1\xcolor@ 6832 \expandafter\expandafter\expandafter\c@lor@to@ps#1#2\@@ 6833 \else 6834 \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter 6835 \expandafter\c@lor@to@ps\csname\string\color@#1#2\endcsname\@@ 6836 \fi 6837 \space} 6838% \end{macrocode} 6839% 6840% For compatibility reasons, we need the following command temporarily; however, |\XC@c@lor@to@ps| will disappear! 6841% \begin{macrocode} 6842\let\XC@c@lor@to@ps\XC@usecolor 6843% \end{macrocode} 6844% \end{macro} 6845% 6846% If \Package{pstcol} has been loaded, we have to redefine two macros from this package. 6847% The conditional code is needed temporarily, until nobody uses old \Package{pstricks} versions anymore. 6848% \begin{macrocode} 6849\let\pst@getcolor\XC@getcolor 6850\@ifundefined{XC@pst}{% 6851 \let\pst@usecolor\XC@usecolor 6852}{} 6853% \end{macrocode} 6854% 6855% 6856% \subsubsection{Whatsit \ldots} 6857% 6858% \begin{macro}{\c@lor@special} 6859% Some drivers do not support all the features of this package. 6860% They should always put a \Meta{whatsit} in the current list though. 6861% The following macro has most of the features of |\special|, but does not put anything into the \File{.dvi} file. 6862% It does write to the |log| file or the terminal (depending on the value of |#1|). 6863% \begin{macrocode} 6864\def\c@lor@special#1#2{\edef\@tempa{\write#1{#2}}\@tempa} 6865% \end{macrocode} 6866% \end{macro} 6867% 6868% 6869% \subsubsection{Default color} 6870% 6871% \begin{macro}{\normalcolor} 6872% |\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. 6873% It will have no effect until the \XCP{} is also loaded. 6874% \begin{macrocode} 6875\def\normalcolor{\let\current@color\default@color\set@color} 6876% \end{macrocode} 6877% \end{macro} 6878% 6879% \begin{macro}{\default@color} 6880% Internal macro to store the `default' color used by |\normalcolor|. 6881% \begin{macrocode} 6882\AtBeginDocument{\let\default@color\current@color} 6883% \end{macrocode} 6884% \end{macro} 6885% |\current@color| (which is the expansion of |\XC@current@color|) contains an internal representation of the color at this point in the document. 6886% 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. 6887% This is why drivers must maintain their own stack of colors in order to fully support these commands. 6888% 6889% 6890% \subsubsection{Driver-specific definitions for named colors} 6891% 6892% \begin{macro}{\c@lor@@named} 6893% \begin{macro}{\define@color@named} 6894% We have to modify a few driver-specific commands in order to avoid generation of superfluous macros. 6895% \begin{macrocode} 6896\XC@ifcase\XC@@drv 6897 {{dvipdf,dvipdfm,dvipdfmx,dvips,pctex32}% 6898 {\def\c@lor@@named#1,#2,#3\@@#4% 6899 {\edef#4{\expandafter\expandafter\expandafter\@thirdoffive 6900 \csname\string\color@#1\endcsname}} 6901 \def\define@color@named#1#2% 6902 {\@namedef{\string\color@#1}{{}{}{ \colornameprefix#1}{}{}}}}% 6903% \end{macrocode} 6904% 6905% \begin{macrocode} 6906 {dvipsone,pctexps,pdftex,tcidvi,truetex,vtex,xetex}% 6907 {\def\c@lor@@named#1,#2,#3\@@#4% 6908 {\edef#4{\expandafter\expandafter\expandafter\@thirdoffive 6909 \csname\string\color@#1\endcsname}} 6910 \def\define@color@named#1#2% 6911 {\let\@@cls\@empty\@namedef{\string\color@#1}{{}{}{#2}{}{}}}}% 6912% \end{macrocode} 6913% 6914% \begin{macrocode} 6915 {textures}% 6916 {\def\c@lor@@named#1,#2,#3\@@#4% 6917 {\edef\@tempa{\color@P@custom{#1}{\if!#2!1\else#2\fi}}% 6918 \expandafter\def\expandafter#4\@tempa} 6919 \def\define@color@named#1#2% 6920 {\edef\@tempa{{#1}{#2}}\expandafter\AddCustomColor\@tempa} 6921 \def\c@lor@ps@#1 #2\@@ 6922 {\expandafter\expandafter\expandafter\expandafter\expandafter 6923 \expandafter\expandafter\c@lor@to@ps@ 6924 \csname\string\color@#1\expandafter\endcsname\space 6925 #2. \@@{#1}}}% 6926% \end{macrocode} 6927% 6928% \begin{macrocode} 6929 }{} 6930% \end{macrocode} 6931% \end{macro} 6932% \end{macro} 6933% 6934% 6935% \subsubsection{Basic color definitions} 6936% 6937% \Model{rgb}-minded colors.\footnote{Generic definitions: 6938% \Color{orange} = \Color{red}|!|50|!|\Color{yellow}, 6939% \Color{violet} = \Color{blue}|!|50|!|\Color{red}, 6940% \Color{purple} = \Color{violet}|!|50|!|\Color{red}, 6941% \Color{brown} = \Color{violet}|!|50|!|\Color{yellow}, 6942% \Color{pink} = \Color{red}|!|25.} 6943% \begin{macrocode} 6944\definecolorset{rgb/hsb/cmyk/gray}{}{}% 6945 {red,1,0,0/0,1,1/0,1,1,0/.3;% 6946 green,0,1,0/.33333,1,1/1,0,1,0/.59;% 6947 blue,0,0,1/.66667,1,1/1,1,0,0/.11;% 6948 orange,1,.5,0/.083333,1,1/0,.5,1,0/.595;% 6949 violet,.5,0,.5/.83333,1,.5/0,.5,0,.5/.205;% 6950 purple,.75,0,.25/.94444,1,.75/0,.75,.5,.25/.2525;% 6951 brown,.75,.5,.25/.083333,.66667,.75/0,.25,.5,.25/.5475;% 6952 pink,1,.75,.75/0,.25,1/0,.25,.25,0/.825}% 6953% \end{macrocode} 6954% 6955% \Model{cmyk}-minded colors.\footnote{Generic definitions: 6956% \Color{olive} = \Color{red}|!|50|!|\Color{green}.} 6957% \begin{macrocode} 6958\definecolorset{cmyk/rgb/hsb/gray}{}{}% 6959 {cyan,1,0,0,0/0,1,1/.5,1,1/.7;% 6960 magenta,0,1,0,0/1,0,1/.83333,1,1/.41;% 6961 yellow,0,0,1,0/1,1,0/.16667,1,1/.89;% 6962 olive,0,0,1,.5/.5,.5,0/.16667,1,.5/.39} 6963% \end{macrocode} 6964% 6965% \Model{gray}-minded colors. 6966% \begin{macrocode} 6967\definecolorset{gray/rgb/hsb/cmyk}{}{}% 6968 {black,0/0,0,0/0,0,0/0,0,0,1;% 6969 darkgray,.25/.25,.25,.25/0,0,.25/0,0,0,.75;% 6970 gray,.5/.5,.5,.5/0,0,.5/0,0,0,.5;% 6971 lightgray,.75/.75,.75,.75/0,0,.75/0,0,0,.25;% 6972 white,1/1,1,1/0,0,1/0,0,0,0} 6973% \end{macrocode} 6974% 6975% Load predefined sets of colors (e.g., \File{dvipsnam.def}). 6976% \begin{macrocode} 6977\XC@@names 6978% \end{macrocode} 6979% 6980% 6981% \subsubsection{Finale} 6982% 6983% Clear color stack and restore catcodes. 6984% \begin{macrocode} 6985\AtBeginDocument{\let\XC@@stack\@empty} 6986\let\colornameprefix\XC@@nameprefix 6987\XC@catcodes 6988% \end{macrocode} 6989% 6990% \begin{macrocode} 6991\csname xcolorcmd\endcsname 6992\color{black} 6993%</package> 6994% \end{macrocode} 6995% 6996% 6997% \iffalse 6998%------------------------------------------------------------------------------- 6999% \fi 7000% 7001% \subsection{Auxiliary definitions} 7002% 7003% \subsubsection{\Index{PostScript} prologue file \File{xcolor.pro}} 7004% 7005% \begin{macrocode} 7006%<*dvips> 7007userdict begin 7008/setcmycolor{0 setcmykcolor}def 7009/XCbd{bind def}bind def 7010/XCed{exch def}XCbd 7011% \end{macrocode} 7012% 7013% \Index{PostScript} version of |\providecommand|. 7014% \begin{macrocode} 7015/XCdef{exch dup TeXDict exch known{pop pop}{XCed}ifelse}XCbd 7016% \end{macrocode} 7017% 7018% \Index{PostScript} version of |\providecolor|. 7019% \begin{macrocode} 7020/XCsetcolor{cvx counttomark array astore cvx exch pop XCdef}XCbd 7021% \end{macrocode} 7022% 7023% Now define model-dependent color definition commands. 7024% \begin{macrocode} 7025/XCcmy{mark exch exec/setcmycolor XCsetcolor}XCbd 7026/XCcmyk{mark exch exec/setcmykcolor XCsetcolor}XCbd 7027/XCgray{mark exch exec/setgray XCsetcolor}XCbd 7028/XChsb{mark exch exec/sethsbcolor XCsetcolor}XCbd 7029/XCrgb{mark exch exec/setrgbcolor XCsetcolor}XCbd 7030% \end{macrocode} 7031% 7032% Grouping operators. 7033% We have to disable the |setgray| operator which is invoked by |normalscale| as part of |@beginspecial| as defined by \File{special.pro}. 7034% \begin{macrocode} 7035/XC!b{save/setgray{pop}def}XCbd 7036/XC!e{restore}XCbd 7037% \end{macrocode} 7038% 7039% Scale `sp' coordinates back to `bp' units. 7040% \begin{macrocode} 7041/XCsp2bp{1 65781.76 div dup scale}XCbd 7042% \end{macrocode} 7043% 7044% \begin{macro}{XCsetline} 7045% \meta{linewidth} |XCsetline|\\ 7046% Common line definition. 7047% \begin{macrocode} 7048/XCsetline 7049 {setlinewidth [] 0 setdash 2 setlinecap 0 setlinejoin 4 setmiterlimit}XCbd 7050% \end{macrocode} 7051% \end{macro} 7052% 7053% \begin{macro}{XCboxframe} 7054% \meta{linewidth} \meta{width} \meta{height} \meta{depth} |XCboxframe|\\ 7055% Draw a frame in `sp' coordinates using LanguageLevel~2. 7056% \begin{macrocode} 7057/XCboxframe{/d XCed/h XCed/w XCed/l XCed w 0 gt{h d neg gt{l 0 gt 7058 {XCsp2bp l XCsetline 7059 l 2 div dup translate 7060 0 d neg w l sub h l sub d add rectstroke}if}if}if}XCbd 7061% \end{macrocode} 7062% \end{macro} 7063% 7064% \begin{macro}{XCcolorblock} 7065% \meta{width} \meta{height} \meta{depth} |XCcolorblock|\\ 7066% Draw a colored box in `sp' coordinates using LanguageLevel~2. 7067% \begin{macrocode} 7068/XCcolorblock{/d XCed/h XCed/w XCed w 0 gt{h d neg gt 7069 {XCsp2bp 0 XCsetline 7070 0 d neg w h d add rectfill}if}if}XCbd 7071% \end{macrocode} 7072% \end{macro} 7073% 7074% \begin{macrocode} 7075end 7076%</dvips> 7077% \end{macrocode} 7078% 7079% 7080% \clearpage 7081% \Finale 7082% \endinput 7083% 7084% 7085% \iffalse 7086%------------------------------------------------------------------------------- 7087%<*svgnames|x11names|hksknames|hksnnames|hksznames|pmsnames|ralnames> 7088\def\colornameprefix{XC@} 7089%</svgnames|x11names|hksknames|hksnnames|hksznames|pmsnames|ralnames> 7090% 7091%<*svgnames> 7092\preparecolorset{rgb}{}{}{% 7093AliceBlue,.94,.972,1;% 7094AntiqueWhite,.98,.92,.844;% 7095Aqua,0,1,1;% 7096Aquamarine,.498,1,.83;% 7097Azure,.94,1,1;% 7098Beige,.96,.96,.864;% 7099Bisque,1,.894,.77;% 7100Black,0,0,0;% 7101BlanchedAlmond,1,.92,.804;% 7102Blue,0,0,1;% 7103BlueViolet,.54,.17,.888;% 7104Brown,.648,.165,.165;% 7105BurlyWood,.87,.72,.53;% 7106CadetBlue,.372,.62,.628;% 7107Chartreuse,.498,1,0;% 7108Chocolate,.824,.41,.116;% 7109Coral,1,.498,.312;% 7110CornflowerBlue,.392,.585,.93;% 7111Cornsilk,1,.972,.864;% 7112Crimson,.864,.08,.235;% 7113Cyan,0,1,1;% 7114DarkBlue,0,0,.545;% 7115DarkCyan,0,.545,.545;% 7116DarkGoldenrod,.72,.525,.044;% 7117DarkGray,.664,.664,.664;% 7118DarkGreen,0,.392,0;% 7119DarkGrey,.664,.664,.664;% 7120DarkKhaki,.74,.716,.42;% 7121DarkMagenta,.545,0,.545;% 7122DarkOliveGreen,.332,.42,.185;% 7123DarkOrange,1,.55,0;% 7124DarkOrchid,.6,.196,.8;% 7125DarkRed,.545,0,0;% 7126DarkSalmon,.912,.59,.48;% 7127DarkSeaGreen,.56,.736,.56;% 7128DarkSlateBlue,.284,.24,.545;% 7129DarkSlateGray,.185,.31,.31;% 7130DarkSlateGrey,.185,.31,.31;% 7131DarkTurquoise,0,.808,.82;% 7132DarkViolet,.58,0,.828;% 7133DeepPink,1,.08,.576;% 7134DeepSkyBlue,0,.75,1;% 7135DimGray,.41,.41,.41;% 7136DimGrey,.41,.41,.41;% 7137DodgerBlue,.116,.565,1;% 7138FireBrick,.698,.132,.132;% 7139FloralWhite,1,.98,.94;% 7140ForestGreen,.132,.545,.132;% 7141Fuchsia,1,0,1;% 7142Gainsboro,.864,.864,.864;% 7143GhostWhite,.972,.972,1;% 7144Gold,1,.844,0;% 7145Goldenrod,.855,.648,.125;% 7146Gray,.5,.5,.5;% 7147Green,0,.5,0;% 7148GreenYellow,.68,1,.185;% 7149Grey,.5,.5,.5;% 7150Honeydew,.94,1,.94;% 7151HotPink,1,.41,.705;% 7152IndianRed,.804,.36,.36;% 7153Indigo,.294,0,.51;% 7154Ivory,1,1,.94;% 7155Khaki,.94,.9,.55;% 7156Lavender,.9,.9,.98;% 7157LavenderBlush,1,.94,.96;% 7158LawnGreen,.488,.99,0;% 7159LemonChiffon,1,.98,.804;% 7160LightBlue,.68,.848,.9;% 7161LightCoral,.94,.5,.5;% 7162LightCyan,.88,1,1;% 7163LightGoldenrod,.933,.867,.51;% 7164LightGoldenrodYellow,.98,.98,.824;% 7165LightGray,.828,.828,.828;% 7166LightGreen,.565,.932,.565;% 7167LightGrey,.828,.828,.828;% 7168LightPink,1,.712,.756;% 7169LightSalmon,1,.628,.48;% 7170LightSeaGreen,.125,.698,.668;% 7171LightSkyBlue,.53,.808,.98;% 7172LightSlateBlue,.518,.44,1;% 7173LightSlateGray,.468,.532,.6;% 7174LightSlateGrey,.468,.532,.6;% 7175LightSteelBlue,.69,.77,.87;% 7176LightYellow,1,1,.88;% 7177Lime,0,1,0;% 7178LimeGreen,.196,.804,.196;% 7179Linen,.98,.94,.9;% 7180Magenta,1,0,1;% 7181Maroon,.5,0,0;% 7182MediumAquamarine,.4,.804,.668;% 7183MediumBlue,0,0,.804;% 7184MediumOrchid,.73,.332,.828;% 7185MediumPurple,.576,.44,.86;% 7186MediumSeaGreen,.235,.7,.444;% 7187MediumSlateBlue,.484,.408,.932;% 7188MediumSpringGreen,0,.98,.604;% 7189MediumTurquoise,.284,.82,.8;% 7190MediumVioletRed,.78,.084,.52;% 7191MidnightBlue,.098,.098,.44;% 7192MintCream,.96,1,.98;% 7193MistyRose,1,.894,.884;% 7194Moccasin,1,.894,.71;% 7195NavajoWhite,1,.87,.68;% 7196Navy,0,0,.5;% 7197NavyBlue,0,0,.5;% 7198OldLace,.992,.96,.9;% 7199Olive,.5,.5,0;% 7200OliveDrab,.42,.556,.136;% 7201Orange,1,.648,0;% 7202OrangeRed,1,.27,0;% 7203Orchid,.855,.44,.84;% 7204PaleGoldenrod,.932,.91,.668;% 7205PaleGreen,.596,.985,.596;% 7206PaleTurquoise,.688,.932,.932;% 7207PaleVioletRed,.86,.44,.576;% 7208PapayaWhip,1,.936,.835;% 7209PeachPuff,1,.855,.725;% 7210Peru,.804,.52,.248;% 7211Pink,1,.752,.796;% 7212Plum,.868,.628,.868;% 7213PowderBlue,.69,.88,.9;% 7214Purple,.5,0,.5;% 7215Red,1,0,0;% 7216RosyBrown,.736,.56,.56;% 7217RoyalBlue,.255,.41,.884;% 7218SaddleBrown,.545,.27,.075;% 7219Salmon,.98,.5,.448;% 7220SandyBrown,.956,.644,.376;% 7221SeaGreen,.18,.545,.34;% 7222Seashell,1,.96,.932;% 7223Sienna,.628,.32,.176;% 7224Silver,.752,.752,.752;% 7225SkyBlue,.53,.808,.92;% 7226SlateBlue,.415,.352,.804;% 7227SlateGray,.44,.5,.565;% 7228SlateGrey,.44,.5,.565;% 7229Snow,1,.98,.98;% 7230SpringGreen,0,1,.498;% 7231SteelBlue,.275,.51,.705;% 7232Tan,.824,.705,.55;% 7233Teal,0,.5,.5;% 7234Thistle,.848,.75,.848;% 7235Tomato,1,.39,.28;% 7236Turquoise,.25,.88,.815;% 7237Violet,.932,.51,.932;% 7238VioletRed,.816,.125,.565;% 7239Wheat,.96,.87,.7;% 7240White,1,1,1;% 7241WhiteSmoke,.96,.96,.96;% 7242Yellow,1,1,0;% 7243YellowGreen,.604,.804,.196} 7244%</svgnames> 7245% 7246%<*x11names> 7247\preparecolorset{rgb}{}{}{% 7248AntiqueWhite1,1,.936,.86;% 7249AntiqueWhite2,.932,.875,.8;% 7250AntiqueWhite3,.804,.752,.69;% 7251AntiqueWhite4,.545,.512,.47;% 7252Aquamarine1,.498,1,.83;% 7253Aquamarine2,.464,.932,.776;% 7254Aquamarine3,.4,.804,.668;% 7255Aquamarine4,.27,.545,.455;% 7256Azure1,.94,1,1;% 7257Azure2,.88,.932,.932;% 7258Azure3,.756,.804,.804;% 7259Azure4,.512,.545,.545;% 7260Bisque1,1,.894,.77;% 7261Bisque2,.932,.835,.716;% 7262Bisque3,.804,.716,.62;% 7263Bisque4,.545,.49,.42;% 7264Blue1,0,0,1;% 7265Blue2,0,0,.932;% 7266Blue3,0,0,.804;% 7267Blue4,0,0,.545;% 7268Brown1,1,.25,.25;% 7269Brown2,.932,.23,.23;% 7270Brown3,.804,.2,.2;% 7271Brown4,.545,.136,.136;% 7272Burlywood1,1,.828,.608;% 7273Burlywood2,.932,.772,.57;% 7274Burlywood3,.804,.668,.49;% 7275Burlywood4,.545,.45,.332;% 7276CadetBlue1,.596,.96,1;% 7277CadetBlue2,.556,.898,.932;% 7278CadetBlue3,.48,.772,.804;% 7279CadetBlue4,.325,.525,.545;% 7280Chartreuse1,.498,1,0;% 7281Chartreuse2,.464,.932,0;% 7282Chartreuse3,.4,.804,0;% 7283Chartreuse4,.27,.545,0;% 7284Chocolate1,1,.498,.14;% 7285Chocolate2,.932,.464,.13;% 7286Chocolate3,.804,.4,.112;% 7287Chocolate4,.545,.27,.075;% 7288Coral1,1,.448,.336;% 7289Coral2,.932,.415,.312;% 7290Coral3,.804,.356,.27;% 7291Coral4,.545,.244,.185;% 7292Cornsilk1,1,.972,.864;% 7293Cornsilk2,.932,.91,.804;% 7294Cornsilk3,.804,.785,.694;% 7295Cornsilk4,.545,.532,.47;% 7296Cyan1,0,1,1;% 7297Cyan2,0,.932,.932;% 7298Cyan3,0,.804,.804;% 7299Cyan4,0,.545,.545;% 7300DarkGoldenrod1,1,.725,.06;% 7301DarkGoldenrod2,.932,.68,.055;% 7302DarkGoldenrod3,.804,.585,.048;% 7303DarkGoldenrod4,.545,.396,.03;% 7304DarkOliveGreen1,.792,1,.44;% 7305DarkOliveGreen2,.736,.932,.408;% 7306DarkOliveGreen3,.635,.804,.352;% 7307DarkOliveGreen4,.43,.545,.24;% 7308DarkOrange1,1,.498,0;% 7309DarkOrange2,.932,.464,0;% 7310DarkOrange3,.804,.4,0;% 7311DarkOrange4,.545,.27,0;% 7312DarkOrchid1,.75,.244,1;% 7313DarkOrchid2,.698,.228,.932;% 7314DarkOrchid3,.604,.196,.804;% 7315DarkOrchid4,.408,.132,.545;% 7316DarkSeaGreen1,.756,1,.756;% 7317DarkSeaGreen2,.705,.932,.705;% 7318DarkSeaGreen3,.608,.804,.608;% 7319DarkSeaGreen4,.41,.545,.41;% 7320DarkSlateGray1,.592,1,1;% 7321DarkSlateGray2,.552,.932,.932;% 7322DarkSlateGray3,.475,.804,.804;% 7323DarkSlateGray4,.32,.545,.545;% 7324DeepPink1,1,.08,.576;% 7325DeepPink2,.932,.07,.536;% 7326DeepPink3,.804,.064,.464;% 7327DeepPink4,.545,.04,.312;% 7328DeepSkyBlue1,0,.75,1;% 7329DeepSkyBlue2,0,.698,.932;% 7330DeepSkyBlue3,0,.604,.804;% 7331DeepSkyBlue4,0,.408,.545;% 7332DodgerBlue1,.116,.565,1;% 7333DodgerBlue2,.11,.525,.932;% 7334DodgerBlue3,.094,.455,.804;% 7335DodgerBlue4,.064,.305,.545;% 7336Firebrick1,1,.19,.19;% 7337Firebrick2,.932,.172,.172;% 7338Firebrick3,.804,.15,.15;% 7339Firebrick4,.545,.1,.1;% 7340Gold1,1,.844,0;% 7341Gold2,.932,.79,0;% 7342Gold3,.804,.68,0;% 7343Gold4,.545,.46,0;% 7344Goldenrod1,1,.756,.145;% 7345Goldenrod2,.932,.705,.132;% 7346Goldenrod3,.804,.608,.112;% 7347Goldenrod4,.545,.41,.08;% 7348Green1,0,1,0;% 7349Green2,0,.932,0;% 7350Green3,0,.804,0;% 7351Green4,0,.545,0;% 7352Honeydew1,.94,1,.94;% 7353Honeydew2,.88,.932,.88;% 7354Honeydew3,.756,.804,.756;% 7355Honeydew4,.512,.545,.512;% 7356HotPink1,1,.43,.705;% 7357HotPink2,.932,.415,.655;% 7358HotPink3,.804,.376,.565;% 7359HotPink4,.545,.228,.385;% 7360IndianRed1,1,.415,.415;% 7361IndianRed2,.932,.39,.39;% 7362IndianRed3,.804,.332,.332;% 7363IndianRed4,.545,.228,.228;% 7364Ivory1,1,1,.94;% 7365Ivory2,.932,.932,.88;% 7366Ivory3,.804,.804,.756;% 7367Ivory4,.545,.545,.512;% 7368Khaki1,1,.965,.56;% 7369Khaki2,.932,.9,.52;% 7370Khaki3,.804,.776,.45;% 7371Khaki4,.545,.525,.305;% 7372LavenderBlush1,1,.94,.96;% 7373LavenderBlush2,.932,.88,.898;% 7374LavenderBlush3,.804,.756,.772;% 7375LavenderBlush4,.545,.512,.525;% 7376LemonChiffon1,1,.98,.804;% 7377LemonChiffon2,.932,.912,.75;% 7378LemonChiffon3,.804,.79,.648;% 7379LemonChiffon4,.545,.536,.44;% 7380LightBlue1,.75,.936,1;% 7381LightBlue2,.698,.875,.932;% 7382LightBlue3,.604,.752,.804;% 7383LightBlue4,.408,.512,.545;% 7384LightCyan1,.88,1,1;% 7385LightCyan2,.82,.932,.932;% 7386LightCyan3,.705,.804,.804;% 7387LightCyan4,.48,.545,.545;% 7388LightGoldenrod1,1,.925,.545;% 7389LightGoldenrod2,.932,.864,.51;% 7390LightGoldenrod3,.804,.745,.44;% 7391LightGoldenrod4,.545,.505,.298;% 7392LightPink1,1,.684,.725;% 7393LightPink2,.932,.635,.68;% 7394LightPink3,.804,.55,.585;% 7395LightPink4,.545,.372,.396;% 7396LightSalmon1,1,.628,.48;% 7397LightSalmon2,.932,.585,.448;% 7398LightSalmon3,.804,.505,.385;% 7399LightSalmon4,.545,.34,.26;% 7400LightSkyBlue1,.69,.888,1;% 7401LightSkyBlue2,.644,.828,.932;% 7402LightSkyBlue3,.552,.712,.804;% 7403LightSkyBlue4,.376,.484,.545;% 7404LightSteelBlue1,.792,.884,1;% 7405LightSteelBlue2,.736,.824,.932;% 7406LightSteelBlue3,.635,.71,.804;% 7407LightSteelBlue4,.43,.484,.545;% 7408LightYellow1,1,1,.88;% 7409LightYellow2,.932,.932,.82;% 7410LightYellow3,.804,.804,.705;% 7411LightYellow4,.545,.545,.48;% 7412Magenta1,1,0,1;% 7413Magenta2,.932,0,.932;% 7414Magenta3,.804,0,.804;% 7415Magenta4,.545,0,.545;% 7416Maroon1,1,.204,.7;% 7417Maroon2,.932,.19,.655;% 7418Maroon3,.804,.16,.565;% 7419Maroon4,.545,.11,.385;% 7420MediumOrchid1,.88,.4,1;% 7421MediumOrchid2,.82,.372,.932;% 7422MediumOrchid3,.705,.32,.804;% 7423MediumOrchid4,.48,.215,.545;% 7424MediumPurple1,.67,.51,1;% 7425MediumPurple2,.624,.475,.932;% 7426MediumPurple3,.536,.408,.804;% 7427MediumPurple4,.365,.28,.545;% 7428MistyRose1,1,.894,.884;% 7429MistyRose2,.932,.835,.824;% 7430MistyRose3,.804,.716,.71;% 7431MistyRose4,.545,.49,.484;% 7432NavajoWhite1,1,.87,.68;% 7433NavajoWhite2,.932,.81,.63;% 7434NavajoWhite3,.804,.7,.545;% 7435NavajoWhite4,.545,.475,.37;% 7436OliveDrab1,.752,1,.244;% 7437OliveDrab2,.7,.932,.228;% 7438OliveDrab3,.604,.804,.196;% 7439OliveDrab4,.41,.545,.132;% 7440Orange1,1,.648,0;% 7441Orange2,.932,.604,0;% 7442Orange3,.804,.52,0;% 7443Orange4,.545,.352,0;% 7444OrangeRed1,1,.27,0;% 7445OrangeRed2,.932,.25,0;% 7446OrangeRed3,.804,.215,0;% 7447OrangeRed4,.545,.145,0;% 7448Orchid1,1,.512,.98;% 7449Orchid2,.932,.48,.912;% 7450Orchid3,.804,.41,.79;% 7451Orchid4,.545,.28,.536;% 7452PaleGreen1,.604,1,.604;% 7453PaleGreen2,.565,.932,.565;% 7454PaleGreen3,.488,.804,.488;% 7455PaleGreen4,.33,.545,.33;% 7456PaleTurquoise1,.732,1,1;% 7457PaleTurquoise2,.684,.932,.932;% 7458PaleTurquoise3,.59,.804,.804;% 7459PaleTurquoise4,.4,.545,.545;% 7460PaleVioletRed1,1,.51,.67;% 7461PaleVioletRed2,.932,.475,.624;% 7462PaleVioletRed3,.804,.408,.536;% 7463PaleVioletRed4,.545,.28,.365;% 7464PeachPuff1,1,.855,.725;% 7465PeachPuff2,.932,.796,.68;% 7466PeachPuff3,.804,.688,.585;% 7467PeachPuff4,.545,.468,.396;% 7468Pink1,1,.71,.772;% 7469Pink2,.932,.664,.72;% 7470Pink3,.804,.57,.62;% 7471Pink4,.545,.39,.424;% 7472Plum1,1,.732,1;% 7473Plum2,.932,.684,.932;% 7474Plum3,.804,.59,.804;% 7475Plum4,.545,.4,.545;% 7476Purple1,.608,.19,1;% 7477Purple2,.57,.172,.932;% 7478Purple3,.49,.15,.804;% 7479Purple4,.332,.1,.545;% 7480Red1,1,0,0;% 7481Red2,.932,0,0;% 7482Red3,.804,0,0;% 7483Red4,.545,0,0;% 7484RosyBrown1,1,.756,.756;% 7485RosyBrown2,.932,.705,.705;% 7486RosyBrown3,.804,.608,.608;% 7487RosyBrown4,.545,.41,.41;% 7488RoyalBlue1,.284,.464,1;% 7489RoyalBlue2,.264,.43,.932;% 7490RoyalBlue3,.228,.372,.804;% 7491RoyalBlue4,.152,.25,.545;% 7492Salmon1,1,.55,.41;% 7493Salmon2,.932,.51,.385;% 7494Salmon3,.804,.44,.33;% 7495Salmon4,.545,.298,.224;% 7496SeaGreen1,.33,1,.624;% 7497SeaGreen2,.305,.932,.58;% 7498SeaGreen3,.264,.804,.5;% 7499SeaGreen4,.18,.545,.34;% 7500Seashell1,1,.96,.932;% 7501Seashell2,.932,.898,.87;% 7502Seashell3,.804,.772,.75;% 7503Seashell4,.545,.525,.51;% 7504Sienna1,1,.51,.28;% 7505Sienna2,.932,.475,.26;% 7506Sienna3,.804,.408,.224;% 7507Sienna4,.545,.28,.15;% 7508SkyBlue1,.53,.808,1;% 7509SkyBlue2,.494,.752,.932;% 7510SkyBlue3,.424,.65,.804;% 7511SkyBlue4,.29,.44,.545;% 7512SlateBlue1,.512,.435,1;% 7513SlateBlue2,.48,.404,.932;% 7514SlateBlue3,.41,.35,.804;% 7515SlateBlue4,.28,.235,.545;% 7516SlateGray1,.776,.888,1;% 7517SlateGray2,.725,.828,.932;% 7518SlateGray3,.624,.712,.804;% 7519SlateGray4,.424,.484,.545;% 7520Snow1,1,.98,.98;% 7521Snow2,.932,.912,.912;% 7522Snow3,.804,.79,.79;% 7523Snow4,.545,.536,.536;% 7524SpringGreen1,0,1,.498;% 7525SpringGreen2,0,.932,.464;% 7526SpringGreen3,0,.804,.4;% 7527SpringGreen4,0,.545,.27;% 7528SteelBlue1,.39,.72,1;% 7529SteelBlue2,.36,.675,.932;% 7530SteelBlue3,.31,.58,.804;% 7531SteelBlue4,.21,.392,.545;% 7532Tan1,1,.648,.31;% 7533Tan2,.932,.604,.288;% 7534Tan3,.804,.52,.248;% 7535Tan4,.545,.352,.17;% 7536Thistle1,1,.884,1;% 7537Thistle2,.932,.824,.932;% 7538Thistle3,.804,.71,.804;% 7539Thistle4,.545,.484,.545;% 7540Tomato1,1,.39,.28;% 7541Tomato2,.932,.36,.26;% 7542Tomato3,.804,.31,.224;% 7543Tomato4,.545,.21,.15;% 7544Turquoise1,0,.96,1;% 7545Turquoise2,0,.898,.932;% 7546Turquoise3,0,.772,.804;% 7547Turquoise4,0,.525,.545;% 7548VioletRed1,1,.244,.59;% 7549VioletRed2,.932,.228,.55;% 7550VioletRed3,.804,.196,.47;% 7551VioletRed4,.545,.132,.32;% 7552Wheat1,1,.905,.73;% 7553Wheat2,.932,.848,.684;% 7554Wheat3,.804,.73,.59;% 7555Wheat4,.545,.494,.4;% 7556Yellow1,1,1,0;% 7557Yellow2,.932,.932,0;% 7558Yellow3,.804,.804,0;% 7559Yellow4,.545,.545,0;% 7560Gray0,.745,.745,.745;% 7561Green0,0,1,0;% 7562Grey0,.745,.745,.745;% 7563Maroon0,.69,.19,.376;% 7564Purple0,.628,.125,.94} 7565%</x11names> 7566% 7567%<*test1> 7568\documentclass[a4paper]{article} 7569 7570\usepackage{array,multicol,multido,textcomp} 7571\usepackage{xcolor}[2005/03/24] 7572\usepackage[hmargin={1.25cm,.75cm},vmargin=1.25cm,footskip=.5cm,nohead]{geometry} 7573 7574\newdimen\Argwd 7575\newdimen\Errsum 7576\newdimen\Errmax 7577\newcount\Colors 7578\newcount\Errors 7579\newcount\Loops 7580\newif\ifColor 7581 7582\makeatletter 7583 7584\def\DisplayColor#1#2#3% 7585 {\global\advance\Loops\@ne 7586 \@tempdima=#1\p@ \edef\@tempa{\the\@tempdima}% 7587 \edef\Colori{\strip@pt\@tempdima}% 7588 \ifColor 7589 \@tempdimb=#2\p@ \edef\@tempb{\the\@tempdimb}% 7590 \@tempdimc=#3\p@ \edef\@tempc{\the\@tempdimc}% 7591 \edef\Colori{\Colori,\strip@pt\@tempdimb,\strip@pt\@tempdimc}% 7592 \fi 7593 \Make12\Make23\Make34\Make45\Make56\Make67% 7594 \begin{tabular}{@{}ll*4{@{ }p{\Argwd}}@{}} 7595 \Row1\Row2\Row3\Row4\Row5\Row6\noalign{\medskip} 7596 \end{tabular} 7597 \global\advance\Colors1 \relax\ifnum\Colors=30 \newpage\global\Colors=0 \fi} 7598 7599\def\Make#1#2% 7600 {\edef\@@tmp 7601 {\noexpand\definecolor{Color\romannumeral#1}% 7602 {\@nameuse{Model\romannumeral#1}}{\@nameuse{Color\romannumeral#1}}% 7603 }\@@tmp 7604 \relax\ifnum#1<6 7605 \convertcolorspec 7606 {\@nameuse{Model\romannumeral#1}}{\@nameuse{Color\romannumeral#1}}% 7607 {\@nameuse{Model\romannumeral#2}}\@@tmp 7608 \XC@let@cN{Color\romannumeral#2}\@@tmp 7609 \fi} 7610\def\Row#1% 7611 {\edef\@@tmp{\@nameuse{Color\romannumeral#1}\@nameuse{Row\romannumeral#1}}% 7612 \expandafter\@Row\@@tmp} 7613 7614\def\@Row#1,#2,#3,#4,#5#6% 7615 {\fcolorbox{black}{Color\romannumeral#5}{\phantom{000}}& 7616 \csname Model\romannumeral#5\endcsname & 7617 \ifodd#6 \@Error{#1}\@tempa \else #1\fi & 7618 \ifColor\ifodd#6 \@Error{#2}\@tempb \else #2\fi\else #2\fi & 7619 \ifColor\ifodd#6 \@Error{#3}\@tempc \else #3\fi\else #3\fi & 7620 #4\\} 7621 7622\def\defModel#1#2#3#4% number, name, commas, check 7623 {\@namedef{Model\romannumeral#1}{#2}\@namedef{Row\romannumeral#1}{#3#1#4}} 7624 7625\def\@Error#1#2% 7626 {\ifdim#1\p@=#2\relax #1\else 7627 \textcolor{red}{#1}\global\advance\Errors\@ne 7628 \dimen@#2\advance\dimen@-#1\p@ \ifdim\dimen@<\z@\dimen@-\dimen@\fi 7629 \global\advance\Errsum\dimen@ 7630 \ifdim\dimen@>\Errmax \global\Errmax\dimen@ 7631 \dimen@\@tempa \edef\@@tempa{\strip@pt\dimen@}% 7632 \ifColor 7633 \dimen@\@tempb \edef\@@tempb{\strip@pt\dimen@}% 7634 \dimen@\@tempc \edef\@@tempc{\strip@pt\dimen@}% 7635 \xdef\Errcase{\@@tempa\noexpand~\@@tempb\noexpand~\@@tempc}% 7636 \else 7637 \xdef\Errcase{\@@tempa}% 7638 \fi 7639 \fi 7640 \fi} 7641 7642\newenvironment{ColorTest}[1]% 7643 {\addcontentsline{toc}{section}{Color conversion chain: #1} 7644 \Colors\z@ \Errors\z@ \Loops\z@ \Errsum\z@ \Errmax\z@ 7645 \begin{multicols}{3}\centering}% 7646 {\end{multicols}\bigskip 7647 \begin{tabular}{@{}l@{ = }l@{}} 7648 \multicolumn2{@{}l@{}}{Rounding error statistics of color conversion test}\\ 7649 \multicolumn2{@{}l@{}}% 7650 {$\textbf\Modeli\rightarrow \textbf\Modelii\rightarrow \textbf\Modeliii\rightarrow 7651 \textbf\Modeliv\rightarrow \textbf\Modelv\rightarrow \textbf\Modelvi$:}\\[1ex] 7652 number of examples& \number\Loops\\ 7653 number of errors& \number\Errors\\ 7654 sum of absolute errors& \strip@pt\Errsum\\ 7655 \ifnum\Errors>\z@ 7656 average error& \Errsum100\Errsum \dimen@\Errors\p@ \divide\dimen@\@m 7657 \rdivide\Errsum\dimen@ \strip@pt\Errsum\textperiodcentered10\textsuperscript{-5}\\ 7658 maximum error& \strip@pt\Errmax{} @ \Modeli~\Errcase\\ 7659 \fi 7660 \end{tabular}\newpage} 7661 7662\def\thepage{\sffamily\footnotesize\@nameuse{@arabic}\c@page} 7663 7664\makeatother 7665 7666\parindent0pt 7667\setcounter{secnumdepth}{-1} 7668 7669\begin{document} 7670 7671\title{Color conversion with the \textsf{xcolor} package --- Examples} 7672\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}.}} 7673\date{\XCfileversion{} (\XCfiledate)} 7674\maketitle 7675 7676\begin{center} 7677\begin{minipage}{.75\textwidth} 7678\tableofcontents 7679\end{minipage} 7680\end{center} 7681\newpage 7682 7683\sffamily\footnotesize 7684\fboxrule.25pt 7685\settowidth\Argwd{0.00000} 7686 7687\defModel1{rgb}{,,}0 7688\defModel2{cmy}{,,}0 7689\defModel3{cmyk}{,}0 7690\defModel4{hsb}{,,}0 7691\defModel5{rgb}{,,}1 7692\defModel6{gray}{,,,,}0 7693\Colortrue 7694 7695\begin{ColorTest}{rgb, cmy, cmyk, hsb, rgb, gray} 7696\multido{\nR=1+-.1}{11}% 7697 {\multido{\nG=1+-.1}{11}% 7698 {\multido{\nB=1+-.1}{11}% 7699 {\DisplayColor{\nR}{\nG}{\nB}}}}% 7700\end{ColorTest} 7701 7702\defModel1{gray}{,,,,}0 7703\defModel2{rgb}{,,}0 7704\defModel3{cmy}{,,}0 7705\defModel4{cmyk}{,}0 7706\defModel5{hsb}{,,}0 7707\defModel6{gray}{,,,,}1 7708\Colorfalse 7709 7710\begin{ColorTest}{gray, rgb, cmy, cmyk, hsb, gray} 7711\multido{\nG=1+-.01}{101}{\DisplayColor{\nG}{}{}}% 7712\end{ColorTest} 7713 7714\end{document} 7715%</test1> 7716% 7717%<*test2> 7718\listfiles 7719\documentclass{article} 7720 7721\usepackage{pstricks,pst-tree,pst-slpe,multido} 7722\makeatletter 7723\@ifpackagelater{pstricks}{2004/05/12}{}{\usepackage[pst]{xcolor}} 7724\makeatother 7725\usepackage{fvrb-ex} 7726 7727\def\textfraction{0.01} 7728\def\topfraction{0.99} 7729\def\bottomfraction{0.99} 7730\def\floatpagefraction{0.70} 7731\setlength\abovecaptionskip{12pt} 7732\setlength\belowcaptionskip{10pt} 7733\parindent0pt 7734 7735\begin{document} 7736\title{Color extensions with the \textsf{xcolor} package --- \textsf{pstricks} examples} 7737\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}.}} 7738\date{\XCfileversion{} (\XCfiledate)} 7739\maketitle 7740 7741\centerline{\fcolorbox{red}{yellow!50}{This document is not suitable for pdf\LaTeX! Please use \LaTeX{} + \texttt{dvips} etc.}} 7742 7743\begin{figure}[htb]\caption{Modified version of an example from the \textsf{pstricks} manual; requires \textsf{pst-tree}} 7744\begin{SideBySideExample}[fontsize=\footnotesize,xrightmargin=.45\textwidth] 7745 \begin{pspicture}(-0.5,-2)(3,2) 7746 \cnode(0,0){.5cm}{root} 7747 \cnode*[linecolor=red](3,1.5){4pt}{A} 7748 \cnode*[linecolor=red!72.5375!blue](3,0){4pt}{B} 7749 \cnode*[linecolor=-red](3,-1.5){4pt}{C} 7750 \psset{nodesep=3pt} 7751 \ncline[linecolor=green!50!red]{root}{A} 7752 \ncline[linecolor=blue]{root}{B} 7753 \ncline[linecolor=-green!50!red]{root}{C} 7754 \end{pspicture} 7755\end{SideBySideExample} 7756\end{figure} 7757 7758\begin{figure}[htb]\caption{Moving from one color to its complement; requires \textsf{pst-slpe}} 7759\begin{SideBySideExample}[fontsize=\footnotesize,xrightmargin=.45\textwidth] 7760 \begin{pspicture}(4,1) 7761 \psframe[fillstyle=slope, 7762 slopeangle=30, 7763 slopebegin=red!72.5375!blue, 7764 slopeend=-red!72.5375!blue](4,1) 7765 \end{pspicture} 7766\end{SideBySideExample} 7767\end{figure} 7768 7769\begin{figure}[htb]\caption{Explicit color specification via a loop command; requires \textsf{multido}} 7770\begin{SideBySideExample}[fontsize=\footnotesize,xrightmargin=.45\textwidth] 7771 \psset{unit=1.75}% 7772 \begin{pspicture}(0,-1)(2,1) 7773 \multido{\rHue=0.00+0.01}{100}% 7774 {\pscircle[linewidth=0.01, 7775 linecolor={[hsb]{\rHue,1,1}}](1,0){\rHue}} 7776 \end{pspicture} 7777\end{SideBySideExample} 7778\end{figure} 7779 7780\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} 7781\begin{SideBySideExample}[fontsize=\footnotesize,xrightmargin=.45\textwidth] 7782 \newcommand*\Sheep 7783 {\begin{pspicture}(3,1.5) 7784 \pscustom[liftpen=2,fillstyle=solid,fillcolor=sheep!!+]% 7785 {\pscurve(0.5,-0.2)(0.6,0.5)(0.2,1.3)(0,1.5)(0,1.5) 7786 (0.4,1.3)(0.8,1.5)(2.2,1.9)(3,1.5)(3,1.5)(3.2,1.3) 7787 (3.6,0.5)(3.4,-0.3)(3,0)(2.2,0.4)(0.5,-0.2)} 7788 \pscircle*(2.65,1.25){0.12\psunit}% Eye 7789 \psccurve*(3.5,0.3)(3.35,0.45)(3.5,0.6)(3.6,0.4)% Muzzle 7790 \pscurve(3,0.35)(3.3,0.1)(3.6,0.05)% Mouth 7791 \pscurve(2.3,1.3)(2.1,1.5)(2.15,1.7) 7792 \pscurve(2.1,1.7)(2.35,1.6)(2.45,1.4)% Ear 7793 \end{pspicture}} 7794 \definecolorseries 7795 {sheep}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37} 7796 \resetcolorseries{sheep} 7797 \psset{unit=0.4} 7798 \begin{pspicture}(-3,-6)(0,7.5) 7799 \Multido{\ry=6.0+-1.5}{5}% 7800 {\rput(0,\ry){\Multido{}{5}{\Sheep}}} 7801 \resetcolorseries{sheep}% 7802 \multirput(-6,-6)(3,0)5{\Sheep} 7803 \end{pspicture} 7804\end{SideBySideExample} 7805\end{figure} 7806 7807\begin{figure}[htb]\caption{Interaction with native PostScript code --- $\gamma$-corrected wavelengths} 7808\begin{Example}[fontsize=\footnotesize,xrightmargin=.45\textwidth] 7809 \newcount\WL \unitlength.75pt 7810 \def\WaveToPS#1% 7811 {\definecolor{tmp}{rgb:wave}{#1}\extractcolorspecs{tmp}\tmpm\tmpc 7812 \expandafter\WaveToPSi\tmpc,} 7813 \def\WaveToPSi#1,#2,#3,{\pstVerb{/Red{#1}def /Green{#2}def /Blue{#3}def}} 7814 \def\DisplayBar#1#2% 7815 {\linethickness{1.25\unitlength}\WL=360 7816 \pstVerb{/Gamma{#1}def}% 7817 \multiput(360,#2)(1,0){456}% 7818 {\WaveToPS{\the\WL}{\color{lambda}\line(0,1){50}}\global\advance\WL1}% 7819 \linethickness{0.25\unitlength}\WL=360 7820 \multiput(360,#2)(20,0){23}% 7821 {\picture(0,0) 7822 \line(0,-1){5}\multiput(5,0)(5,0){3}{\line(0,-1){2.5}}% 7823 \put(0,-10){\makebox(0,0){\the\WL}}\global\advance\WL20 7824 \endpicture}% 7825 \put(350,#2){\makebox(0,50)[r]{\small$\gamma$\,=\,#1}}} 7826 \pstVerb{/Corr{dup 0 gt {Gamma exp}if}def} 7827 \definecolor[ps]{lambda}{rgb}{Red Corr Green Corr Blue Corr}% 7828 \begin{picture}(510,345)(310,-10) 7829 \sffamily\tiny 7830 \DisplayBar{0.4}{0}% 7831 \DisplayBar{0.6}{70}% 7832 \DisplayBar{0.8}{140}% 7833 \DisplayBar{1.0}{210}% 7834 \DisplayBar{1.2}{280}% 7835 \end{picture} 7836\end{Example} 7837\end{figure} 7838 7839\end{document} 7840%</test2> 7841% 7842%<*test3> 7843\listfiles 7844\documentclass[a4paper]{article} 7845\usepackage[showerrors,table,dvipsnames*,hyperref]{xcolor}[2005/12/21] 7846\usepackage[margin=2.25cm]{geometry} 7847\usepackage 7848 [\GinDriver,hyperindex=false,bookmarks,bookmarksopen,bookmarksopenlevel=1,% 7849 pdftitle={xcolor3 \XCfileversion{} (\XCfiledate)},pdfauthor={Dr. Uwe Kern},% 7850 pdfsubject={Color extensions for LaTeX and pdfLaTeX},% 7851 pdfkeywords={xcolor,color,colour,model,tint,tone,shade,harmony,spot,latex,pdftex,dvips,% 7852 conversion,blend,mix,mask,separation,rgb,cmy,cmyk,hsb,gray,html,wave,thsb,wheel}]{hyperref} 7853 7854\tracingcolors=4 7855%%\tracingcolors=3 7856%%\tracingcolors=2 7857%%\tracingcolors=1 7858%%\tracingcolors=0 7859 7860\parindent0pt 7861\pagecolor{gray!25} 7862 7863\definecolors{JungleGreen,DarkOrchid} 7864 7865\begin{document} 7866\title{Color extensions with the \textsf{xcolor} package --- various examples} 7867\author{\href{mailto:xcolor@ukern.de}{\fboxrule0pt\fboxsep2pt\fbox{Dr. Uwe Kern}}} 7868\date{\XCfileversion{} (\XCfiledate) 7869\thanks{This file (\texttt{\jobname.tex}) is part of the \textsf{xcolor} distribution which can be downloaded from the CTAN mirrors \texttt{\href{http://www.ctan.org/tex-archive/macros/latex/contrib/xcolor/}{CTAN/macros/latex/contrib/xcolor/}} or the homepage \texttt{\href{http://www.ukern.de/tex/xcolor.html}{www.ukern.de/tex/xcolor.html}}. Please send error reports and suggestions for improvements to \texttt{\href{mailto:xcolor@ukern.de}{xcolor@ukern.de}}.}} 7870\maketitle 7871 7872The purpose of this file is to demonstrate a variety of capabilities including the logging facilities of the \textsf{xcolor} package. 7873By playing around with different values of \texttt{\string\tracingcolors}, one can observe the different behavior in the \texttt{log} file. 7874 7875\section{Predefined colors} 7876 7877\begingroup 7878\small\sffamily 7879\rowcolors1{}{} 7880\begin{testcolors}[rgb,cmyk,hsb,HTML,gray] 7881\testcolor{red} 7882\testcolor{green} 7883\testcolor{blue} 7884\testcolor{cyan} 7885\testcolor{magenta} 7886\testcolor{yellow} 7887\testcolor{orange} 7888\testcolor{violet} 7889\testcolor{purple} 7890\testcolor{brown} 7891\testcolor{pink} 7892\testcolor{olive} 7893\testcolor{black} 7894\testcolor{darkgray} 7895\testcolor{gray} 7896\testcolor{lightgray} 7897\testcolor{white} 7898\noalign{\medskip}\hline\noalign{\medskip} 7899\testcolor{-red} 7900\testcolor{-green} 7901\testcolor{-blue} 7902\testcolor{-cyan} 7903\testcolor{-magenta} 7904\testcolor{-yellow} 7905\testcolor{-orange} 7906\testcolor{-violet} 7907\testcolor{-purple} 7908\testcolor{-brown} 7909\testcolor{-pink} 7910\testcolor{-olive} 7911\testcolor{-black} 7912\testcolor{-darkgray} 7913\testcolor{-gray} 7914\testcolor{-lightgray} 7915\testcolor{-white} 7916\noalign{\medskip}\hline\noalign{\medskip} 7917\testcolor{JungleGreen} 7918\testcolor{DarkOrchid} 7919\noalign{\medskip}\hline\noalign{\medskip} 7920\testcolor{-JungleGreen} 7921\testcolor{-DarkOrchid} 7922\end{testcolors} 7923\endgroup 7924 7925\vfill 7926 7927\clearpage 7928\pagecolor{white} 7929 7930\section{Color definition and application} 7931 7932\providecolor{dummy}{rgb}{.6,.5,.4} 7933\definecolor{dummy}{rgb}{.6,.5,.4} 7934\providecolor{dummy}{rgb}{.6,.5,.4} 7935\hbox{\textcolor{dummy}{Test with \texttt{\string\definecolor}}} 7936 7937\bigskip 7938 7939Comma-separated and space-separated definitions: 7940 7941\definecolor{c1}{rgb}{.7,.6,.5} 7942\definecolor{c2}{rgb}{.7 .6 .5} 7943\colorlet{c1a}{c1} 7944\colorlet{c2a}{c2} 7945 7946\textcolor{c1}{identical} = 7947\textcolor{c2}{identical} = 7948\textcolor{c1a}{identical} = 7949\textcolor{c2a}{identical} = 7950\textcolor[rgb]{.7,.6,.5}{identical} = 7951\textcolor[rgb]{.7 .6 .5}{identical} = 7952\textcolor{rgb,10:red,7;green,6;blue,5}{identical} 7953\textcolor{rgb,15:red,10.5;green,9;blue,7.5}{identical} 7954 7955\medskip 7956 7957\begingroup 7958\sffamily 7959\begin{testcolors} 7960\testcolor{c1} 7961\testcolor{c2} 7962\testcolor{c1a} 7963\testcolor{c2a} 7964\testcolor[rgb]{.7,.6,.5} 7965\testcolor[rgb]{.7 .6 .5} 7966\testcolor{rgb,10:red,7;green,6;blue,5} 7967\testcolor{rgb,15:red,10.5;green,9;blue,7.5} 7968\end{testcolors} 7969\endgroup 7970 7971\bigskip 7972 7973\textcolor{rgb:red!50,4;green!25,2}{Another extended color expression (rgb:red!50,4;green!25,2)}. 7974 7975\bigskip 7976 7977\begingroup 7978\color{black} 7979Test with named colors:\par 7980\color{blue} 7981Test: \textcolor[named]{JungleGreen}{JungleGreen}; 7982Test: \textcolor{JungleGreen}{JungleGreen}; 7983Test: \textcolor{JungleGreen!50!DarkOrchid}{JungleGreen!50!DarkOrchid}; 7984Test: \textcolor{green!50!red}{green!50!red}. 7985\endgroup 7986 7987\bigskip 7988 7989{\color[rgb]{.4,.5,.6}Test with \texttt{\string\color}} 7990 7991\bigskip 7992Current color application:\par 7993\def\test{current, \textcolor{.!50}{50\%}, \textcolor{-.}{complement}, 7994 \textcolor{yellow!50!.}{mix}} 7995\textcolor{blue}{\test} and \textcolor{red}{\test},\par 7996\def\Test{\color{.!80}Test} 7997\textcolor{blue}{\Test\Test\Test\Test\Test} and 7998\textcolor{red}{\Test\Test\Test\Test\Test}. 7999 8000\bigskip 8001Current color test with \texttt{\string\definecolorseries}:\par 8002\begingroup 8003\color{blue} 8004\definecolorseries{foo}{rgb}{last}{.}{-.} 8005\resetcolorseries[5]{foo} 8006\def\test{\hbox to 1em{{\color{foo!!+}\vrule width 1em height 1.5ex}}} 8007Test\test\test\test\test\test\test Test 8008 8009\resetcolorseries[5]{foo} 8010\def\test{\hbox to 1em{{\color{foo!!++}\vrule width 1em height 1.5ex}}} 8011Test\test\test\test\test\test\test Test 8012 8013\resetcolorseries[5]{foo} 8014\def\test{\hbox to 1em{{\color{foo!![2]}\vrule width 1em height 1.5ex}}} 8015Test\test\test\test\test\test\test Test 8016 8017\endgroup 8018 8019\section{Color in tables} 8020 8021\rowcolors[\hline]{1}{green!25}{yellow!50} 8022\begin{tabular}{ll} 8023test & row \number\rownum\\ 8024test & row \number\rownum\\ 8025\rowcolor{blue!25} 8026test & row \number\rownum\\ 8027test & row \number\rownum\\ 8028\hiderowcolors 8029test & row \number\rownum\\ 8030test & row \number\rownum\\ 8031\showrowcolors 8032test & row \number\rownum\\ 8033test & row \number\rownum\\ 8034\multicolumn{1}% 8035 {>{\columncolor{red!12}}l}{test} & row \number\rownum\\ 8036\end{tabular} 8037 8038\section{Color information} 8039 8040Type test: 8041\makeatletter 8042\@namedef{\string\color@foo1}{foo1{}{}{}{}}\edef\tempa{\XC@type{foo1}}\tempa 8043\@namedef{\string\color@foo2}{\xcolor@{foo2}{}{}{}}\edef\tempb{\XC@type{foo2}}\tempb 8044\@namedef{\string\color@foo3}{\xcolor@{}{foo3}{}{}}\edef\tempc{\XC@type{foo3}}\tempc 8045\@namedef{\string\color@foo4}{\xcolor@{}{}{foo4}{}}\edef\tempd{\XC@type{foo4}}\tempd 8046\makeatother 8047 8048\end{document} 8049%</test3> 8050% 8051%<*test4> 8052\listfiles 8053\documentclass[a4paper]{article} 8054%%\PassOptionsToPackage{dvipdf}{xcolor} 8055%%\PassOptionsToPackage{dvipdfm}{xcolor} 8056%%\PassOptionsToPackage{dvipdfmx}{xcolor} 8057%%\PassOptionsToPackage{dvips}{xcolor} 8058%%\PassOptionsToPackage{dvipsone}{xcolor} 8059%%\PassOptionsToPackage{dviwin}{xcolor} 8060%%\PassOptionsToPackage{dviwindo}{xcolor} 8061%%\PassOptionsToPackage{emtex}{xcolor} 8062%%\PassOptionsToPackage{oztex}{xcolor} 8063%%\PassOptionsToPackage{pctex32}{xcolor} 8064%%\PassOptionsToPackage{pctexhp}{xcolor} 8065%%\PassOptionsToPackage{pctexps}{xcolor} 8066%%\PassOptionsToPackage{pctexwin}{xcolor} 8067%%\PassOptionsToPackage{pdftex}{xcolor} 8068%%\PassOptionsToPackage{tcidvi}{xcolor} 8069%%\PassOptionsToPackage{textures}{xcolor} 8070%%\PassOptionsToPackage{truetex}{xcolor} 8071%%\PassOptionsToPackage{vtex}{xcolor} 8072%%\PassOptionsToPackage{xdvi}{xcolor} 8073%%\PassOptionsToPackage{xetex}{xcolor} 8074%%\PassOptionsToPackage{prologue}{xcolor} 8075%%\PassOptionsToPackage{kernelfbox}{xcolor} 8076%%\PassOptionsToPackage{xcdraw}{xcolor} 8077\usepackage[emtex]{graphics} 8078\usepackage{xcolor} 8079\usepackage[margin=1.25cm,noheadfoot]{geometry} 8080\pagestyle{empty} 8081\parindent0pt 8082\nofiles 8083\let\familydefault\sfdefault 8084\makeatletter 8085%% special code for driver list construction via 8086%% latex \def\xcdriverlist{1}\input{xcolor4} 8087%% writes list in file xcolor4.tmp 8088\@ifundefined{xcdriverlist}{}{% 8089%% optional * (skips test whether #1.def exists) 8090%% #1 = driver 8091%% #2 = additional options (stored in \options@#2) 8092%% #3 = processor 1 8093%% #4 = output format 1 8094%% #5 = processor 2 8095%% #6 = output format 2 8096%% #7 = processor 3 8097%% #8 = output format 3 8098\def\0{\@ifstar 8099 {\def\@@tmp####1{\@firstoftwo}\1}{\def\@@tmp####1{\IfFileExists{####1.def}}\1}} 8100\def\1#1#2#3#4#5#6#7#8{\@@tmp{#1}% 8101 {\XC@let@Nc\@@tmp{options@#2} 8102 \ifx\@@tmp\@empty\else 8103 \edef\@@tmp{,\@@tmp}\XC@replace\@@tmp,{;#1-}\XC@replace\@@tmp;, 8104 \fi 8105 \edef\@@tmp{:=#1\@@tmp} 8106 \expandafter\@for\expandafter\@tempa\@@tmp\do 8107 {\let\@@tmp\@tempa\XC@replace\@@tmp-, 8108 \edef\@@tmp{\@tempa\space\string\PassOptionsToPackage{\@@tmp}{xcolor}} 8109 \@namexdef{list@#4}{\@nameuse{list@#4},#3 \@@tmp} 8110 \@namexdef{list@#6}{\@nameuse{list@#6},#5 \@@tmp} 8111 \@namexdef{list@#8}{\@nameuse{list@#8},#7 \@@tmp}}}% 8112 {\typeout{No file `#1.def' found.}}} 8113\def\list@{} 8114\def\list@dvi{} 8115\def\list@ps{} 8116\def\list@pdf{} 8117\@namedef{options@0}{} 8118\@namedef{options@1}{kernelfbox,prologue,xcdraw,kernelfbox-xcdraw,prologue-xcdraw} 8119\0{dvips}1{latex}{dvi}{dvips}{ps}{ps2pdf}{pdf} 8120\0{pctex32}0{latex}{dvi}{dvips}{ps}{ps2pdf}{pdf} 8121\0{dvipdf}0{latex}{dvi}{dvipdf}{pdf}{}{} 8122\0{dvipdfm}1{latex}{dvi}{dvipdfm}{pdf}{}{} 8123\0{dvipdfmx}0{latex}{dvi}{dvipdfmx}{pdf}{}{} 8124\0{dvipsone}0{latex}{dvi}{}{}{}{} 8125\0{dviwin}0{latex}{dvi}{}{}{}{} 8126\0*{dviwindo}0{latex}{dvi}{}{}{}{} 8127\0{emtex}0{latex}{dvi}{}{}{}{} 8128\0*{oztex}0{latex}{dvi}{}{}{}{} 8129\0{pctexhp}0{latex}{dvi}{}{}{}{} 8130\0{pctexps}0{latex}{dvi}{}{}{}{} 8131\0{pctexwin}0{latex}{dvi}{}{}{}{} 8132\0{tcidvi}0{latex}{dvi}{}{}{}{} 8133\0{textures}0{latex}{dvi}{}{}{}{} 8134\0{truetex}0{latex}{dvi}{}{}{}{} 8135\0*{xdvi}0{latex}{dvi}{}{}{}{} 8136\0{pdftex}1{pdflatex}{pdf}{}{}{}{} 8137\0{vtex}0{vlatex}{pdf}{}{}{}{} 8138\0{xetex}0{xelatex}{pdf}{}{}{}{} 8139\newwrite\@tempa\immediate\openout\@tempa=\jobname.tmp 8140\@tfor\@tempb:={dvi}{ps}{pdf}\do 8141 {\edef\@@tmp{\@nameuse{list@\@tempb}}\edef\@@tmp{:=\expandafter\@gobble\@@tmp} 8142 \expandafter\@for\expandafter\@@tmp\@@tmp\do 8143 {\immediate\write\@tempa{\@@tmp}}} 8144\immediate\closeout\@tempa 8145\@@end}% end of driver list construction code 8146\edef\Options{\expandafter\@gobble\XC@@opt} 8147\@tfor\@@tmp:={dvipdf}{dvipdfm}{dvipdfmx}{dvips}{dvipsone}{dviwin}{dviwindo}% 8148 {emtex}{oztex}{pctex32}{pctexhp}{pctexps}{pctexwin}{pdftex}% 8149 {tcidvi}{textures}{truetex}{vtex}{xdvi}{xetex}% 8150 {natural}{table}{fixpdftex}{hyperref}{showerrors}{hideerrors}% 8151 {override}{usenames}{nodvipsnames}{debugshow}\do 8152 {\expandafter\XC@replace\expandafter\Options\expandafter{\@@tmp,}{}} 8153\edef\Options{\XC@@drv,\Options} 8154\def\@@tmp#1,#2% 8155 {\ifx,#2#1\expandafter\remove@to@nnil\else#1', `\expandafter\@@tmp\fi#2} 8156\edef\Options{`\expandafter\@@tmp\Options,,\@nnil'} 8157\makeatother 8158\begin{document} 8159\vbox to\textheight{\vss\centering 8160{\Large\textbf{xcolor} driver test: \Options} 8161\vskip0.5cm 8162\begin{testcolors}[rgb,hsb,cmyk,gray,HTML] 8163\testcolor{magenta} 8164\testcolor[rgb]{1,0,1} 8165\testcolor[hsb]{0.83333,1,1} 8166\testcolor[cmyk]{0,1,0,0} 8167\testcolor[gray]{0.41} 8168\noalign{\medskip} 8169\testcolor{blue} 8170\testcolor[rgb]{0,0,1} 8171\testcolor[hsb]{0.66667,1,1} 8172\testcolor[cmyk]{1,1,0,0} 8173\testcolor[gray]{0.11} 8174\noalign{\medskip} 8175\testcolor{cyan} 8176\testcolor[rgb]{0,1,1} 8177\testcolor[hsb]{0.5,1,1} 8178\testcolor[cmyk]{1,0,0,0} 8179\testcolor[gray]{0.7} 8180\noalign{\medskip} 8181\testcolor{green} 8182\testcolor[rgb]{0,1,0} 8183\testcolor[hsb]{0.33333,1,1} 8184\testcolor[cmyk]{1,0,1,0} 8185\testcolor[gray]{0.59} 8186\noalign{\medskip} 8187\testcolor{yellow} 8188\testcolor[rgb]{1,1,0} 8189\testcolor[hsb]{0.16667,1,1} 8190\testcolor[cmyk]{0,0,1,0} 8191\testcolor[gray]{0.89} 8192\noalign{\medskip} 8193\testcolor{red} 8194\testcolor[rgb]{1,0,0} 8195\testcolor[hsb]{0,1,1} 8196\testcolor[cmyk]{0,1,1,0} 8197\testcolor[gray]{0.3} 8198\noalign{\medskip} 8199\testcolor{black} 8200\testcolor[rgb]{0,0,0} 8201\testcolor[hsb]{0,0,0} 8202\testcolor[cmyk]{0,0,0,1} 8203\testcolor[gray]{0} 8204\noalign{\medskip} 8205\testcolor{gray} 8206\testcolor[rgb]{0.5,0.5,0.5} 8207\testcolor[hsb]{0,0,0.5} 8208\testcolor[cmyk]{0,0,0,0.5} 8209\testcolor[gray]{0.5} 8210\noalign{\medskip} 8211\testcolor{white} 8212\testcolor[rgb]{1,1,1} 8213\testcolor[hsb]{0,0,1} 8214\testcolor[cmyk]{0,0,0,0} 8215\testcolor[gray]{1} 8216\noalign{\medskip\smallskip} 8217f(color)box & 8218\multicolumn5{c}{\def\i{\fbox{\a}}\def\ii{\fcolorbox{red}{yellow}{\a}}\def\iii{\scalebox{3}}% 8219\def\a{{\setbox0=\hbox to3ex{\hss\textcolor{blue}{\vrule width .75ex height1.5ex depth1.5ex}\hss}\ht0=0pt\dp0=0pt\box0}}% 8220\fboxsep0.333ex \i\quad\ii\quad\iii\i\quad\iii\ii\quad\fboxrule.75ex \iii\i\quad\iii\ii} 8221\end{testcolors} 8222\vskip0.5cm 8223{\footnotesize This table was generated with \textbf{xcolor4.tex} which is part of the \textbf{xcolor} package \XCfileversion{} (\XCfiledate) by Uwe Kern.} 8224\vss} 8225\end{document} 8226%</test4> 8227% 8228% \fi 8229\endinput 8230%% 8231%% End of file `xcolor.dtx'. 8232