I have the following color:


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.

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.

\foreach \mcolor in {377,380,400,600} {
  \colorlet{malviolet}[rgb]{SEviolet}% from hsb->rgb
  \color{SEviolet} Hello World!\par
  Color specification \mcolor\ (hsb): \malcolor\par
  Color specification \mcolor\ (rgb): \malcolor\par\medskip
  }% End of \foreach...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.