Debian Codegraph @

texmf-dist/doc/latex/xcolor/xcolor1.tex

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