1%%
2%% This is file `xcolor1.tex',
3%% generated with the docstrip utility.
4%%
5%% The original source files were:
6%%
7%% xcolor.dtx  (with options: `test1')
8%%
9%% IMPORTANT NOTICE:
10%%
11%% For the copyright see the source file.
12%%
13%% Any modified versions of this file must be renamed
14%% with new filenames distinct from xcolor1.tex.
15%%
16%% For distribution of the original source see the terms
17%% for copying and modification in the file xcolor.dtx.
18%%
19%% This generated file may be distributed as long as the
20%% original source files, as listed above, are part of the
21%% same distribution. (The sources need not necessarily be
22%% in the same archive or directory.)
23%%
24\ProvidesFile{xcolor1}
25 [2005/12/21 v2.09 Color conversion test (UK)]
26%%
27%% ----------------------------------------------------------------
28%% Copyright (C) 2003-2005 by Dr. Uwe Kern <xcolor at ukern dot de>
29%% ----------------------------------------------------------------
30%%
31\def\XCfileversion{v2.09}%
32\def\XCfiledate{2005/12/21}%
33\documentclass[a4paper]{article}
34
35\usepackage{array,multicol,multido,textcomp}
36\usepackage{xcolor}[2005/03/24]
37\usepackage[hmargin={1.25cm,.75cm},vmargin=1.25cm,footskip=.5cm,nohead]{geometry}
38
39\newdimen\Argwd
40\newdimen\Errsum
41\newdimen\Errmax
42\newcount\Colors
43\newcount\Errors
44\newcount\Loops
45\newif\ifColor
46
47\makeatletter
48
49\def\DisplayColor#1#2#3%
50 {\global\advance\Loops\@ne
51  \@tempdima=#1\p@ \edef\@tempa{\the\@tempdima}%
52  \edef\Colori{\strip@pt\@tempdima}%
53  \ifColor
54    \@tempdimb=#2\p@ \edef\@tempb{\the\@tempdimb}%
55    \@tempdimc=#3\p@ \edef\@tempc{\the\@tempdimc}%
56    \edef\Colori{\Colori,\strip@pt\@tempdimb,\strip@pt\@tempdimc}%
57  \fi
58  \Make12\Make23\Make34\Make45\Make56\Make67%
59  \begin{tabular}{@{}ll*4{@{ }p{\Argwd}}@{}}
60  \Row1\Row2\Row3\Row4\Row5\Row6\noalign{\medskip}
61  \end{tabular}
62  \global\advance\Colors1 \relax\ifnum\Colors=30 \newpage\global\Colors=0 \fi}
63
64\def\Make#1#2%
65 {\edef\@@tmp
66   {\noexpand\definecolor{Color\romannumeral#1}%
67     {\@nameuse{Model\romannumeral#1}}{\@nameuse{Color\romannumeral#1}}%
68   }\@@tmp
69  \relax\ifnum#1<6
70    \convertcolorspec
71     {\@nameuse{Model\romannumeral#1}}{\@nameuse{Color\romannumeral#1}}%
72     {\@nameuse{Model\romannumeral#2}}\@@tmp
73    \XC@let@cN{Color\romannumeral#2}\@@tmp
74  \fi}
75\def\Row#1%
76 {\edef\@@tmp{\@nameuse{Color\romannumeral#1}\@nameuse{Row\romannumeral#1}}%
77  \expandafter\@Row\@@tmp}
78
79\def\@Row#1,#2,#3,#4,#5#6%
80 {\fcolorbox{black}{Color\romannumeral#5}{\phantom{000}}&
81  \csname Model\romannumeral#5\endcsname &
82  \ifodd#6 \@Error{#1}\@tempa \else #1\fi &
83  \ifColor\ifodd#6 \@Error{#2}\@tempb \else #2\fi\else #2\fi &
84  \ifColor\ifodd#6 \@Error{#3}\@tempc \else #3\fi\else #3\fi &
85  #4\\}
86
87\def\defModel#1#2#3#4% number, name, commas, check
88 {\@namedef{Model\romannumeral#1}{#2}\@namedef{Row\romannumeral#1}{#3#1#4}}
89
90\def\@Error#1#2%
91 {\ifdim#1\p@=#2\relax #1\else
92    \textcolor{red}{#1}\global\advance\Errors\@ne
93    \dimen@#2\advance\dimen@-#1\p@ \ifdim\dimen@<\z@\dimen@-\dimen@\fi
94    \global\advance\Errsum\dimen@
95    \ifdim\dimen@>\Errmax \global\Errmax\dimen@
96      \dimen@\@tempa \edef\@@tempa{\strip@pt\dimen@}%
97      \ifColor
98        \dimen@\@tempb \edef\@@tempb{\strip@pt\dimen@}%
99        \dimen@\@tempc \edef\@@tempc{\strip@pt\dimen@}%
100        \xdef\Errcase{\@@tempa\noexpand~\@@tempb\noexpand~\@@tempc}%
101      \else
102        \xdef\Errcase{\@@tempa}%
103      \fi
104    \fi
105  \fi}
106
107\newenvironment{ColorTest}[1]%
108 {\addcontentsline{toc}{section}{Color conversion chain: #1}
109  \Colors\z@ \Errors\z@ \Loops\z@ \Errsum\z@ \Errmax\z@
110  \begin{multicols}{3}\centering}%
111 {\end{multicols}\bigskip
112  \begin{tabular}{@{}l@{ = }l@{}}
113  \multicolumn2{@{}l@{}}{Rounding error statistics of color conversion test}\\
114  \multicolumn2{@{}l@{}}%
115   {$\textbf\Modeli\rightarrow \textbf\Modelii\rightarrow \textbf\Modeliii\rightarrow
116     \textbf\Modeliv\rightarrow \textbf\Modelv\rightarrow \textbf\Modelvi$:}\\[1ex]
117  number of examples& \number\Loops\\
118  number of errors& \number\Errors\\
119  sum of absolute errors& \strip@pt\Errsum\\
120  \ifnum\Errors>\z@
121    average error& \Errsum100\Errsum \dimen@\Errors\p@ \divide\dimen@\@m
122    \rdivide\Errsum\dimen@ \strip@pt\Errsum\textperiodcentered10\textsuperscript{-5}\\
123    maximum error& \strip@pt\Errmax{} @ \Modeli~\Errcase\\
124  \fi
125  \end{tabular}\newpage}
126
127\def\thepage{\sffamily\footnotesize\@nameuse{@arabic}\c@page}
128
129\makeatother
130
131\parindent0pt
132\setcounter{secnumdepth}{-1}
133
134\begin{document}
135
136\title{Color conversion with the \textsf{xcolor} package --- Examples}
137\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}.}}
138\date{\XCfileversion{} (\XCfiledate)}
139\maketitle
140
141\begin{center}
142\begin{minipage}{.75\textwidth}
143\tableofcontents
144\end{minipage}
145\end{center}
146\newpage
147
148\sffamily\footnotesize
149\fboxrule.25pt
150\settowidth\Argwd{0.00000}
151
152\defModel1{rgb}{,,}0
153\defModel2{cmy}{,,}0
154\defModel3{cmyk}{,}0
155\defModel4{hsb}{,,}0
156\defModel5{rgb}{,,}1
157\defModel6{gray}{,,,,}0
158\Colortrue
159
160\begin{ColorTest}{rgb, cmy, cmyk, hsb, rgb, gray}
161\multido{\nR=1+-.1}{11}%
162 {\multido{\nG=1+-.1}{11}%
163  {\multido{\nB=1+-.1}{11}%
164   {\DisplayColor{\nR}{\nG}{\nB}}}}%
165\end{ColorTest}
166
167\defModel1{gray}{,,,,}0
168\defModel2{rgb}{,,}0
169\defModel3{cmy}{,,}0
170\defModel4{cmyk}{,}0
171\defModel5{hsb}{,,}0
172\defModel6{gray}{,,,,}1
173\Colorfalse
174
175\begin{ColorTest}{gray, rgb, cmy, cmyk, hsb, gray}
176\multido{\nG=1+-.01}{101}{\DisplayColor{\nG}{}{}}%
177\end{ColorTest}
178
179\end{document}
180\endinput
181%%
182%% End of file `xcolor1.tex'.
183