Background
In MetaPost, colours can be lightened or darkened by calling the transparency function. However, this allows other colours to show through, which isn't necessarily desirable all the time. Sometimes a colour should be lightened or darkened independently of its transparency, by changing its value.
Problem
Colours can be adjusted in MetaPost with multiplication, such as:
\definecolor[BaseColour][h=66CEF1]
\startuseMPgraphic{page:ThemeElement}
color baseColour;
baseColour := .5 * \MPcolor{BaseColour};
\stopuseMPgraphic
However, that changes the saturation, and possibly the hue as well.
Question
In MetaPost, how do you control a colour's value, saturation, and hue, independently?
Related
The following ConTeXt code illustrates, conceptually at least, what I'd like to do in MetaPost:
\definecolor[BaseColour][h=66CEF1]
\definespotcolor[BaseColourSaturation][BaseColour][s=.625]
\definespotcolor[BaseColourValue][BaseColour][value=.625]
\definespotcolor[BaseColourHue][BaseColour][hue=.625]
The MetaPost Applications manual defines:
SetupColors( auto-SV, shading-SV, grayscale )
From the mailing list:
It appears that these functions all render the same output when viewed in Evince (the PDF reader I am using).
From the manual you can employ a complementary factor:
.7[red,white]
For example:
fill unitsquare scaled 1cm withcolor .7[red,white];
However, this does not provide enough control.
withrgbcolor
orwithcmykcolor
give you enough control? You can find HSV to RGB/CMYK algorithms easily enough. – Thruston Oct 8 '13 at 23:01withcmykcolor
is not required, MetaFun assumes a CMYK colour if a colour with four elements is provided and interprets it correctly. HSV is not supported, though (well, strictly speaking CMYK is not supported either). – Marco Oct 9 '13 at 21:55