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
.
I think the simplest is to put your definitions in a local package so they can easily be shared between documents and customised to different profiles.
In your document put something like
\usepackage[CoatedFOGRA39]{mycolor}
if you specify a profile that you have set up, relevant definitions are made, otherwise you get an error. mycolor.sty
could look something like this:
\RequirePackage{color}
\DeclareOption{CoatedFOGRA39}{\def\mycolor{CoatedFOGRA39}}
\def\mycolorprofileA{CoatedFOGRA39}
\ProcessOptions\relax
\ifx\mycolor\@undefined
\PackageError{mycolor}{No color profile declared}{declare a color profile}
\fi
\ifx\mycolor\mycolorprofileA
\DefineNamedColor{named}{mycolor}{cmyk}{0.3203,0.1602,0.1172,0.0000}
\fi
The above just declares one colour in one profile, but it could be extended...
Best Answer
To 1. Yes, there is. We could convert color from
hsb
torgb
color model and list color specifications by the\extractcolorspec
command from thexcolor
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.