6

I have the following color:

\definecolor{SEviolet}{wave}{377}

Which is a violet with a wavelength of 377nm. How do I convert this value to rgb?

The xcolor package goes over some conversions on wave defined colors on section 6.3.12. but I find two main difficulties:

  1. I'm not sure if I should do the calculations manually or if there is a better way to do it.
  2. The equations are defined for conversions of wavelengths over 380 nm, and my color is 377.
Mario S. E.
  • 18,609

1 Answers1

8

To 1. Yes, there is. We could convert color from hsb to rgb color model and list color specifications by the \extractcolorspec command from the xcolor package.

To 2. Yes, there is a marginal difference in brightness (hsb), after conversion, there is a marginal difference in red and blue (rgb), please see the first half of the example below.

I enclose an example with wave colors 377, 380, 400, 600 and its preview.

\documentclass[a4paper]{article}
\pagestyle{empty}
\usepackage{xcolor}
\usepackage{pgffor}
\begin{document}\bfseries
\foreach \mcolor in {377,380,400,600} {
  \definecolor{SEviolet}{wave}{\mcolor}
  \colorlet{malviolet}[rgb]{SEviolet}% from hsb->rgb
  \color{SEviolet} Hello World!\par
  \extractcolorspec{SEviolet}{\malcolor}
  Color specification \mcolor\ (hsb): \malcolor\par
  \extractcolorspec{malviolet}{\malcolor}
  Color specification \mcolor\ (rgb): \malcolor\par\medskip
  }% End of \foreach...
\end{document}

mwe

Malipivo
  • 13,287