# Figuring out RGB or HEX color from xcolor

I have defined a color using:

\definecolor{canvascolor}{rgb}{0.643,0.690,0.843}


Then this is used with this command like canvascolor!75!white from xcolor. This is actually done in the beamer theme wkbeamer.

I know the mix of these two colors but how do I output the RGB color of this to match in a paint program. This I figure should be easy. I looked through the xcolor manual and couldn't find how to do this. I also looked through to just see how it determines or algorithm it uses for the new RGB color from the mix but didn't see this. I didn't read the whole manual but from a quick look through I couldn't find the algorithm for this or tried outputting the color with a couple commands but none I could get working.

-

The \extractcolorspec macro will define a macro that contains the specification for a color; we can use it and the companion \convertcolorspec to define a macro containing the specifications for another model:

\definecolor{canvascolor}{rgb}{0.643,0.690,0.843}
\extractcolorspec{canvascolor!75!white}{\test}
\expandafter\convertcolorspec\test{HTML}\test


Now \test will expand to BBC4E1.

The first definition of \test will be {rgb}{0.73225,0.7675,0.88225} so this is good for putting it after \convertcolorspec, but we have to expand it first.

Use two different macros if you also need to keep the first specification around.

We can implement this in a function

\newcommand{\getColorSpec}[3][\getColorSpecTemp]{%
\extractcolorspec{#3}\getColorSpecTemp
\expandafter\convertcolorspec\getColorSpecTemp{#2}#1}


With \getColorSpec{HTML}{canvascolor!75!white} the specification will be stored in \getColorSpecTemp; with

\getColorSpec[\HTMLcolor]{HTML}{canvascolor!75!white}


the same specification will be stored in \HTMLcolor.

-
\documentclass{article}
\usepackage{xcolor}
\definecolor{canvascolor}{rgb}{0.643,0.690,0.843}
\colorlet{canvas75}{canvascolor!75!white}
\begin{document}
\noindent\ttfamily
\color{canvas75}RGB colour canvascolor!75!white\\
html : \convertcolorspec{named}{canvas75}{HTML}\HTMLcolour
\HTMLcolour\\
cmyk : \convertcolorspec{named}{canvas75}{cmyk}\CMYKcolour
\CMYKcolour

\end{document}


-