4.13 Color
\Configure{color}{\:gobble}
\Configure{HColor:gray}{%
\int:of\:tempa{255}{#1}%
\Configure{HColor}{}{rgb(\:tempa,\:tempa,\:tempa)}%
}
\Configure{HColor:rgb}{%
\int:of\:tempa{255}{#1}%
\int:of\:tempb{255}{#2}%
\int:of\:tempc{255}{#3}%
\Configure{HColor}{}{rgb(\:tempa,\:tempb,\:tempc)}%
}
\Configure{HColor:cmyk}{%
\int:of\:Cyan{255}{#1}%
\int:of\:Magenta{255}{#2}%
\int:of\:Yellow{255}{#3}%
\int:of\:Black{255}{#4}%
\:cmyk\:tempa\:Cyan
\:cmyk\:tempb\:Magenta
\:cmyk\:tempc\:Yellow
\Configure{HColor}{}{rgb(\:tempa,\:tempb,\:tempc)}%
}
<.HColor util.> -_-_-
\def\int:of#1#2#3{%
\tmp:dim=#3pt \tmp:dim=#2\tmp:dim
\edef\:temp{\tmp:cnt\the\tmp:dim//}%
\def#1##1//{}\afterassignment#1\:temp
\edef#1{\the\tmp:cnt}%
}
-_-_-
cmyk -> gray
(1 - 0.299c - 0.587m - 0.114y)(1 - k)
cmyk -> rgb
Red = 1-minimum(1,Cyan *(1-Black)+Black)
Green = 1-minimum(1,Magenta*(1-Black)+Black)
Blue = 1-minimum(1,Yellow *(1-Black)+Black)
\def\:cmyk#1#2{%
\tmp:cnt=255 \advance\tmp:cnt by -\:Black
\multiply\tmp:cnt by#2 \advance\tmp:cnt by \:Black
\advance\tmp:cnt by -255 \tmp:cnt=-\tmp:cnt
\ifnum \tmp:cnt<0 \tmp:cnt=0 \fi
\edef#1{\the\tmp:cnt}%
}
-_-_-