[metapost] ANN: colordef package preview
Stephan Hennig
mailing_list at arcor.de
Fri Feb 6 14:04:46 CET 2009
Dan&Jan Luecking schrieb:
> At 04:40 PM 2/5/2009, you wrote:
>
> You could have ! examine its second operand. If it is a number, save
> that number somewhere. If it is a color, assume it is the second ! of
> a colA!tint!colB and make use of the previously saved numeric to
> recover colA.
The problem with this approach is that it doesn't work with grey scale
colors, since that are numerics, too. So you cannot distinguish between
a grey scale color and a tint argument. In the following example
0.618!30!.2
both ! see two numeric arguments. One could let the first ! return a
non-numeric argument to flag this case, but then
0.618!30
would fail, since it /should/ return a numeric. A possible approach to
detect this case could be by checking the value of the arguments. Grey
scale color arguments should always lie in the range [0, 1], but for
0.618!0.5!0.2
that failed, too. :(
>>In the second case, however, there is the problem that from a MetaPost
>>point of view ! has two different meanings.
>>
>> primarydef colA ! tint ! colB=
>>
>>doesn't seem to work.
>
> It couldn't possibly, as MP doesn't have trinary operators,
> or any means to define them.
Thanks, I wasn't sure about that.
> Personally, I don't like the notation red!80!blue and prefer
> a simple vardef with three arguments:
> vardef !(expr clrA, tint, clrB)=
> % etc.
> enddef
I'd like to be able to use xcolor's syntax, since that is a
well-established standard in the TeX world and works with MetaPost's
colleagues, PSTricks and pgf, too. Additionally, one can chain xcolor's
! operators.
The closest I can think of, currently, would be to have two operators !
and ? like in
red!80 = .8[white,red]
red!80?lime = .8[lime, red]
red!80?lime!20 = .2[white, .8[lime, red]]
red!80?lime!20?orange = .2[orange, .8[lime, red]]
etc.
Or the other way around ...
Thought?
Best regards,
Stephan Hennig
More information about the metapost
mailing list