Debian Codegraph @

texmf-dist/source/latex/colorwav/colorwav.dtx

raw
1 % \iffalse
2 %
3 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
4 %<package>\ProvidesPackage{colorwav}
5 %<package> [2023/05/03 v1.0 specify wavelength for color]
6 %<package>\RequirePackage{ifthen}
7 %<package>\RequirePackage{fp}
8 %
9 % Update on 2023/05/03 purely to clarify the license; no code changes.
10 % This package is released under the GNU LGPL.
11 %
12 %<*driver>
13 \documentclass{ltxdoc}
14 \usepackage{colorwav}
15 \usepackage{color}
16 \usepackage{url}
17 \EnableCrossrefs
18 \CodelineIndex
19 \RecordChanges
20 \begin{document}
21 \DocInput{colorwav.dtx}
22 \end{document}
23 %</driver>
24 % \fi
25 %
26 % \CheckSum{252}
27 %
28 %% \CharacterTable
29 %% {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
30 %% 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
31 %% Digits \0\1\2\3\4\5\6\7\8\9
32 %% Exclamation \! Double quote \" Hash (number) \#
33 %% Dollar \$ Percent \% Ampersand \&
34 %% Acute accent \' Left paren \( Right paren \)
35 %% Asterisk \* Plus \+ Comma \,
36 %% Minus \- Point \. Solidus \/
37 %% Colon \: Semicolon \; Less than \<
38 %% Equals \= Greater than \> Question mark \?
39 %% Commercial at \@ Left bracket \[ Backslash \\
40 %% Right bracket \] Circumflex \^ Underscore \_
41 %% Grave accent \` Left brace \{ Vertical bar \|
42 %% Right brace \} Tilde \~}
43 %
44 % \changes{v1.0}{2007/04/12}{Initial Release}
45 %
46 % \GetFileInfo{colorwav.sty}
47 %
48 % \DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ ,\!,\(,\),\,}
49 % \DoNotIndex{\@ne,\expandafter,\noexpand}
50 % \DoNotIndex{\advance,\begingroup,\catcode,\closein}
51 % \DoNotIndex{\newcommand,\renewcommand,\providecommand}
52 % \DoNotIndex{\closeout,\day,\def,\edef,\gdef,\xdef,\let,\empty,\endgroup}
53 % \DoNotIndex{\newcounter,\providecounter,\addtocounter,\setcounter,\stepcounter,\value,\arabic}
54 % \DoNotIndex{\if,\fi,\ifthenelse,\else,\setboolean,\boolean,\newboolean,\provideboolean,\equal,\AND,\OR,\NOT,\whiledo}
55 % \DoNotIndex{\ifcase,\ifcat,\or,\else}
56 % \DoNotIndex{\par,\parbox,\mbox,\hbox,\begin,\end,\nabla,\partial}
57 % \DoNotIndex{\overline,\bar,\small,\tiny,\mathchoice,\scriptsize,\textrm,\texttt}
58 % \DoNotIndex{\alpha,\beta,\gamma,\epsilon,\varepsilon,\delta,\zeta,\eta,\theta,\vartheta,\iota,\kappa,\lambda,\mu,\nu}
59 % \DoNotIndex{\xi,\omicron,\pi,\varpi,\rho,\varrho,\sigma,\tau,\upsilon,\phi,\varphi,\chi,\psi,\omega}
60 % \DoNotIndex{\Delta,\Gamma,\Theta,\Lambda,\Xi,\Pi,\Sigma,\Phi,\Psi,\Omega}
61 % \DoNotIndex{\digamma,\lceil,\rceil,\lfloor,\rfloor,\left,\right,\inp,\inb,\inbr,\inap,\nop}
62 % \DoNotIndex{\PackageError,\PackageWarning}
63 % \DoNotIndex{\csname,\endcsname,\ifx,\ifnum}
64 % \DoNotIndex{\FPround,\FPadd,\FPsub,\FPmul,\FPdiv,\FPpow,\FPiflt,\FPifgt,\FPifzero}
65 % \DoNotIndex{\COLORWAV@tempA,\COLORWAV@tempB}
66 %
67 % \title{The \textsf{colorwav} package\thanks{This document
68 % corresponds to \textsf{colorwav}~\fileversion,
69 % dated~\filedate.}}
70 % \author{nsetzer}
71 %
72 % \maketitle
73 %
74 % \setcounter{IndexColumns}{2}
75 % \StopEventually{\PrintChanges\PrintIndex}
76 %
77 % The \textsf{colorwav} package defines a command to return the RGB values for a color corresponding to a given wavelength.
78 % The \LaTeX{} code is based upon the FORTRAN code found at \url{http://www.efg2.com/Lab/ScienceAndEngineering/Spectra.htm}
79 % which is based upon Dan Bruton's FORTRAN code.
80 %
81 % For more information on the mapping and the original FORTRAN code, see \url{http://www.midnightkite.com/color.html}
82 %
83 %
84 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86 %\section{Basics}
87 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89 %
90 % The physics of this is far too complicated to get into, but it may come about that you have a wavelength
91 % of light that you need to express as a color and this code will do that for you.
92 %
93 %
94 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
96 %\section{Descriptions}
97 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99 %
100 % \DescribeMacro{\storeRGBofWavelength}
101 % |\storeRGBofWavelength|\marg{R value command}\marg{G value command}\marg{B value commmand}\marg{wavelength} stores
102 % the RGB values of \meta{wavelength} in \meta{R value command}, \meta{G value command}, \meta{B value command}
103 % respectively
104 %
105 %
106 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
108 %\section{Test Cases}
109 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111 %
112 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
113 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
114 %\subsection{Wavelengths in Nanometers (default)}
115 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
116 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117 %
118 % \DescribeMacro{\storeRGBofWavelength}
119 %
120 % \newcommand{\Rval}{}
121 % \newcommand{\Gval}{}
122 % \newcommand{\Bval}{}
123 %
124 % \begin{tabular}{ll}
125 % \hline
126 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{400}| \\
127 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{400}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{400} \textcolor[rgb]{\Rval,\Gval,\Bval}{400} \\ \\
128 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{430}| \\
129 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{430}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{430} \textcolor[rgb]{\Rval,\Gval,\Bval}{430} \\ \\
130 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{460}| \\
131 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{460}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{460} \textcolor[rgb]{\Rval,\Gval,\Bval}{460} \\ \\
132 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{490}| \\
133 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{490}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{490} \textcolor[rgb]{\Rval,\Gval,\Bval}{490} \\ \\
134 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{520}| \\
135 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{520}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{520} \textcolor[rgb]{\Rval,\Gval,\Bval}{520} \\ \\
136 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{550}| \\
137 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{550}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{550} \textcolor[rgb]{\Rval,\Gval,\Bval}{550} \\ \\
138 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{580}| \\
139 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{580}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{580} \textcolor[rgb]{\Rval,\Gval,\Bval}{580} \\ \\
140 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{600}| \\
141 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{600}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{600} \textcolor[rgb]{\Rval,\Gval,\Bval}{600} \\ \\
142 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{630}| \\
143 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{630}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{630} \textcolor[rgb]{\Rval,\Gval,\Bval}{630} \\ \\
144 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{660}| \\
145 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{660}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{660} \textcolor[rgb]{\Rval,\Gval,\Bval}{660} \\ \\
146 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{690}| \\
147 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{690}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{690} \textcolor[rgb]{\Rval,\Gval,\Bval}{690} \\
148 % \hline
149 % \end{tabular}
150 %
151 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
152 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
153 %\subsection{Wavelengths in Angstroms}
154 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
155 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
156 %
157 % \DescribeMacro{\storeRGBofWavelength}
158 %
159 % Change the units to Angstroms
160 % |\setUnitsE{-10}|
161 % \setUnitsE{-10}
162 %
163 %
164 %
165 %
166 % \begin{tabular}{lll}
167 % \hline
168 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{4000}| \\
169 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{4000}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{4000} \textcolor[rgb]{\Rval,\Gval,\Bval}{4000} \\ \\
170 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{4300}| \\
171 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{4300}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{4300} \textcolor[rgb]{\Rval,\Gval,\Bval}{4300} \\ \\
172 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{4600}| \\
173 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{4600}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{4600} \textcolor[rgb]{\Rval,\Gval,\Bval}{4600} \\ \\
174 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{4900}| \\
175 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{4900}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{4900} \textcolor[rgb]{\Rval,\Gval,\Bval}{4900} \\ \\
176 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{5200}| \\
177 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{5200}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{5200} \textcolor[rgb]{\Rval,\Gval,\Bval}{5200} \\ \\
178 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{5500}| \\
179 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{5500}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{5500} \textcolor[rgb]{\Rval,\Gval,\Bval}{5500} \\ \\
180 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{5800}| \\
181 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{5800}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{5800} \textcolor[rgb]{\Rval,\Gval,\Bval}{5800} \\ \\
182 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{6000}| \\
183 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{6000}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{6000} \textcolor[rgb]{\Rval,\Gval,\Bval}{6000} \\ \\
184 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{6300}| \\
185 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{6300}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{6300} \textcolor[rgb]{\Rval,\Gval,\Bval}{6300} \\ \\
186 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{6600}| \\
187 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{6600}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{6600} \textcolor[rgb]{\Rval,\Gval,\Bval}{6600} \\ \\
188 % |\storeRGBofWavelength{\Rval}{\Gval}{\Bval}{6900}| \\
189 % |\textcolor[rgb]{\Rval,\Gval,\Bval}{6900}| & \storeRGBofWavelength{\Rval}{\Gval}{\Bval}{6900} \textcolor[rgb]{\Rval,\Gval,\Bval}{6900} \\
190 % \hline
191 % \end{tabular}
192 %
193 %
194 %
195 %
196 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
197 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
198 %\section{Acknowledgments}
199 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
200 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
201 %
202 % Special Thanks to \url{http://www.efg2.com/Lab/ScienceAndEngineering/Spectra.htm} and Dan Bruton for placing their
203 % code online so that it may be translated to other languages.
204 %
205 %
206 %
207 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
208 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
209 %\section{Implementation}
210 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
211 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
212 %
213 %
214 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
215 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
216 %\subsection{Constants and Parameters}
217 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
218 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
219 %
220 %
221 % \begin{macro}{\COLORWAV@gamma}
222 % This is the gamma correction factor.
223 % \begin{macrocode}
224 \newcommand{\COLORWAV@gamma}{0.8}%
225 % \end{macrocode}
226 % \end{macro}
227 %
228 %
229 %
230 % \begin{macro}{\setGammaCorrection}
231 % Allow the user to set the gamma correction
232 % \begin{macrocode}
233 \newcommand{\setGammaCorrection}[1]{%
234 \renewcommand{\COLORWAV@gamma}{#1}%
235 }
236 % \end{macrocode}
237 % \end{macro}
238 %
239 %
240 %
241 % \begin{macro}{\COLORWAV@powerOfTen}
242 % The power of ten representing the units of the wavelength.
243 % $\lambda$ is in $10$ to the |\COLORWAV@powerOfTen| meters
244 % \begin{macrocode}
245 \newcommand{\COLORWAV@powerOfTen}{-9}%
246 % \end{macrocode}
247 % \end{macro}
248 %
249 %
250 %
251 % \begin{macro}{\setUnitsE}
252 % Set the power of ten of the units
253 % \begin{macrocode}
254 \newcommand{\setUnitsE}[1]{%
255 \renewcommand{\COLORWAV@powerOfTen}{#1}%
256 }%
257 % \end{macrocode}
258 % \end{macro}
259 %
260 %
261 %
262 % \begin{macro}{\COLORWAV@minWavelength}
263 % The minimum wavelength to accept
264 % \begin{macrocode}
265 \newcommand{\COLORWAV@minWavelength}{380}%
266 % \end{macrocode}
267 % \end{macro}
268 %
269 %
270 %
271 % \begin{macro}{\setMinVisibleWavelength}
272 % Set the min wavelength
273 % \begin{macrocode}
274 \newcommand{\setMinVisibleWavelength}[1]{%
275 \renewcommand{\COLORWAV@minWavelength}{#1}%
276 }%
277 % \end{macrocode}
278 % \end{macro}
279 %
280 %
281 %
282 % \begin{macro}{\COLORWAV@maxWavelength}
283 % Max visible wavelength
284 % \begin{macrocode}
285 \newcommand{\COLORWAV@maxWavelength}{780}%
286 % \end{macrocode}
287 % \end{macro}
288 %
289 %
290 %
291 % \begin{macro}{\setMaxVisibleWavelength}
292 % Set the maximum visible wavelength
293 % \begin{macrocode}
294 \newcommand{\setMaxVisibleWavelength}[1]{%
295 \renewcommand{\COLORWAV@maxWavelength}{#1}%
296 }%
297 % \end{macrocode}
298 % \end{macro}
299 %
300 %
301 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
302 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
303 %\subsection{Internal Functions}
304 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
305 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
306 %
307 %
308 % \begin{macro}{\COLORWAV@colorAdjust}
309 % a function that adjust things.
310 % \begin{macrocode}
311 \newcommand{\COLORWAV@colorAdjust}[3]{%
312 \FPifzero{#2}%
313 \xdef#1{0}%
314 \else%
315 \FPmul{\COLORWAV@tempA}{#2}{#3}%
316 \FPpow{\COLORWAV@tempA}{\COLORWAV@tempA}{\COLORWAV@gamma}%
317 \xdef#1{\COLORWAV@tempA}%
318 \fi%
319 }%
320 % \end{macrocode}
321 % \end{macro}
322 %
323 %
324 %
325 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
326 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
327 %\subsection{Internal Parameters}
328 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
329 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
330 %
331 %
332 % \begin{macrocode}
333 \newboolean{COLORWAV@lessthansmallest}%
334 \newboolean{COLORWAV@greaterthanlargest}%
335 \newboolean{COLORWAV@isnearuv}%
336 \newboolean{COLORWAV@isviolet}%
337 \newboolean{COLORWAV@isindigo}%
338 \newboolean{COLORWAV@isblue}%
339 \newboolean{COLORWAV@isgreen}%
340 \newboolean{COLORWAV@isorange}%
341 \newboolean{COLORWAV@isnearir}%
342 % \end{macrocode}
343 %
344 %
345 %
346 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
347 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
348 %\subsection{The Workhorse}
349 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
350 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
351 %
352 %
353 %
354 % \begin{macro}{\storeRGBofWavelength}
355 % |\storeRGBofWavlength|\marg{R value command}\marg{G value command}\marg{B value command}\marg{wavelength}
356 % stores the wavelength's R value number in \meta{R value command}, etc
357 % \begin{macrocode}
358 \newcommand{\storeRGBofWavelength}[4]{%
359 % \end{macrocode}
360 % initialize booleans
361 % \begin{macrocode}
362 \setboolean{COLORWAV@lessthansmallest}{false}%
363 \setboolean{COLORWAV@greaterthanlargest}{false}%
364 \setboolean{COLORWAV@isnearuv}{false}%
365 \setboolean{COLORWAV@isviolet}{false}%
366 \setboolean{COLORWAV@isindigo}{false}%
367 \setboolean{COLORWAV@isblue}{false}%
368 \setboolean{COLORWAV@isgreen}{false}%
369 \setboolean{COLORWAV@isorange}{false}%
370 \setboolean{COLORWAV@isnearir}{false}%
371 % \end{macrocode}
372 % get the current units and convert to nanometers
373 % \begin{macrocode}
374 \FPsub{\COLORWAV@tempA}{\COLORWAV@powerOfTen}{-9}%
375 \FPpow{\COLORWAV@tempA}{10}{\COLORWAV@tempA}%
376 \FPmul{\COLORWAV@thewavelen}{#4}{\COLORWAV@tempA}%
377 % \end{macrocode}
378 % Now set the booleans based upon the wavelength.
379 % One can't just use the FP conditionals since they aren't always expanded
380 % and this leads to ``extra" |\fi|'s
381 % \begin{macrocode}
382 \FPiflt{\COLORWAV@thewavelen}{\COLORWAV@minWavelength}%
383 \setboolean{COLORWAV@lessthansmallest}{true}%
384 \fi%
385 %
386 \FPifgt{\COLORWAV@thewavelen}{\COLORWAV@maxWavelength}%
387 \setboolean{COLORWAV@greaterthanlargest}{true}%
388 \fi%
389 %
390 \FPiflt{\COLORWAV@thewavelen}{440}%
391 \setboolean{COLORWAV@isviolet}{true}%
392 \fi%
393 %
394 \FPiflt{\COLORWAV@thewavelen}{490}%
395 \setboolean{COLORWAV@isindigo}{true}%
396 \fi%
397 %
398 \FPiflt{\COLORWAV@thewavelen}{510}%
399 \setboolean{COLORWAV@isblue}{true}%
400 \fi%
401 %
402 \FPiflt{\COLORWAV@thewavelen}{580}%
403 \setboolean{COLORWAV@isgreen}{true}%
404 \fi%
405 %
406 \FPiflt{\COLORWAV@thewavelen}{645}%
407 \setboolean{COLORWAV@isorange}{true}%
408 \fi%
409 % \end{macrocode}
410 % now determine what to do
411 % \begin{macrocode}
412 \ifthenelse{ \boolean{COLORWAV@lessthansmallest} \OR \boolean{COLORWAV@greaterthanlargest} }%
413 {%
414 \gdef\COLORWAV@redValue{0}%
415 \gdef\COLORWAV@greenValue{0}%
416 \gdef\COLORWAV@blueValue{0}%
417 }%
418 {\ifthenelse{ \boolean{COLORWAV@isviolet} }%
419 {%
420 % R
421 \FPsub{\COLORWAV@tempA}{440}{\COLORWAV@minWavelength}%
422 \FPsub{\COLORWAV@tempB}{440}{\COLORWAV@thewavelen}%
423 \FPdiv{\COLORWAV@redValue}{\COLORWAV@tempB}{\COLORWAV@tempA}%
424 % G
425 \gdef\COLORWAV@greenValue{0.0}%
426 % B
427 \gdef\COLORWAV@blueValue{1.0}%
428 }%
429 {\ifthenelse{ \boolean{COLORWAV@isindigo} }%
430 {%
431 % R
432 \gdef\COLORWAV@redValue{0.0}%
433 % G
434 \FPsub{\COLORWAV@tempA}{490}{440}%
435 \FPsub{\COLORWAV@tempB}{\COLORWAV@thewavelen}{440}%
436 \FPdiv{\COLORWAV@greenValue}{\COLORWAV@tempB}{\COLORWAV@tempA}%
437 % B
438 \gdef\COLORWAV@blueValue{1.0}%
439 }%
440 {\ifthenelse{ \boolean{COLORWAV@isblue} }%
441 {%
442 %R
443 \gdef\COLORWAV@redValue{0.0}%
444 %G
445 \gdef\COLORWAV@greenValue{1.0}%
446 %B
447 \FPsub{\COLORWAV@tempA}{510}{490}%
448 \FPsub{\COLORWAV@tempB}{510}{\COLORWAV@thewavelen}%
449 \FPdiv{\COLORWAV@blueValue}{\COLORWAV@tempB}{\COLORWAV@tempA}%
450 }%
451 {\ifthenelse{ \boolean{COLORWAV@isgreen} }%
452 {%
453 %R
454 \FPsub{\COLORWAV@tempA}{580}{510}%
455 \FPsub{\COLORWAV@tempB}{\COLORWAV@thewavelen}{510}%
456 \FPdiv{\COLORWAV@redValue}{\COLORWAV@tempB}{\COLORWAV@tempA}%
457 %G
458 \gdef\COLORWAV@greenValue{1.0}%
459 %B
460 \gdef\COLORWAV@blueValue{0.0}%
461 }%
462 {\ifthenelse{ \boolean{COLORWAV@isorange} }%
463 {%
464 %R
465 \gdef\COLORWAV@redValue{1.0}%
466 %G
467 \FPsub{\COLORWAV@tempA}{645}{580}%
468 \FPsub{\COLORWAV@tempB}{645}{\COLORWAV@thewavelen}%
469 \FPdiv{\COLORWAV@greenValue}{\COLORWAV@tempB}{\COLORWAV@tempA}%
470 %B
471 \gdef\COLORWAV@blueValue{0.0}%
472 }%
473 % Else
474 {%
475 %R
476 \gdef\COLORWAV@redValue{1.0}%
477 %G
478 \gdef\COLORWAV@greenValue{0.0}%
479 %B
480 \gdef\COLORWAV@blueValue{0.0}%
481 }}}}}}%
482 % \end{macrocode}
483 % now adjust intensity to fall off near vision limits
484 % \begin{macrocode}
485 \FPiflt{\COLORWAV@thewavelen}{420}%
486 \setboolean{COLORWAV@isnearuv}{true}%
487 \fi%
488 %
489 \FPifgt{\COLORWAV@thewavelen}{700}%
490 \setboolean{COLORWAV@isnearir}{true}%
491 \fi%
492 %
493 \ifthenelse{ \boolean{COLORWAV@lessthansmallest} \OR \boolean{COLORWAV@greaterthanlargest} }%
494 {%
495 \gdef\COLORWAV@multFactor{0}%
496 }%
497 {\ifthenelse{ \boolean{COLORWAV@isnearuv} }%
498 {%
499 \FPsub{\COLORWAV@tempA}{420}{\COLORWAV@minWavelength}%
500 \FPsub{\COLORWAV@tempB}{\COLORWAV@thewavelen}{\COLORWAV@minWavelength}%
501 \FPdiv{\COLORWAV@multFactor}{\COLORWAV@tempB}{\COLORWAV@tempA}%
502 \FPmul{\COLORWAV@multFactor}{0.7}{\COLORWAV@multFactor}%
503 \FPadd{\COLORWAV@multFactor}{0.3}{\COLORWAV@multFactor}%
504 }%
505 {\ifthenelse{ \boolean{COLORWAV@isnearir} }%
506 {%
507 \FPsub{\COLORWAV@tempA}{\COLORWAV@maxWavelength}{700}%
508 \FPsub{\COLORWAV@tempB}{\COLORWAV@maxWavelength}{\COLORWAV@thewavelen}%
509 \FPdiv{\COLORWAV@multFactor}{\COLORWAV@tempB}{\COLORWAV@tempA}%
510 \FPmul{\COLORWAV@multFactor}{0.7}{\COLORWAV@multFactor}%
511 \FPadd{\COLORWAV@multFactor}{0.3}{\COLORWAV@multFactor}%
512 }%
513 % Else
514 {%
515 \gdef\COLORWAV@multFactor{1.0}%
516 }}}%
517 % \end{macrocode}
518 % finally, adjust and return the colors
519 % \begin{macrocode}
520 \COLORWAV@colorAdjust{#1}{\COLORWAV@redValue}{\COLORWAV@multFactor}%
521 \COLORWAV@colorAdjust{#2}{\COLORWAV@greenValue}{\COLORWAV@multFactor}%
522 \COLORWAV@colorAdjust{#3}{\COLORWAV@blueValue}{\COLORWAV@multFactor}%
523 }%
524 %
525 % \end{macrocode}
526 % \end{macro}
527 %
528 %
529 %
530 %
531 %
532 %
533 %
534 % \Finale
535 \endinput