[metapost] quadratic bezier paths ?

Dan Luecking luecking at uark.edu
Sun May 10 05:03:30 CEST 2009

At 08:34 PM 5/8/2009, you wrote:

>Dan writes concerning the introduction of "cmyk"
>  > I am already finding it hard to update my MP stuff
>  > to handle the new color data types with backward
>  > compatability. I have to replace every color
>  > assignment
>  >    A:=B; and every color declaration
>  >    color A; and every color test
>  >    if color A: with macros that check what color
>  > type is needed before running the appropriate
>  > command.
>Could this agony have been avoided by making "color"
>synonymous with "rgbcolor" before introducing
>"cmykcolor" (more or less in parallel with

I wrote macros that allow a user to specify a color and that
color is used to color all objects of a certain type. Before,
I just wrote something like:
   color specialcolor;
   specialcolor := black; % default
   def UserSetColor (expr ..., X, ...) =
     specialcolor := X;
If the user now inserts a cmykcolor for X, this fails.
In my more enlightened moments, I coded such assignments as:
   if color X: specialcolor := X; fi
which still fails in the sense that it fails to assign
a new value if X is a cmykcolor (it also fails in older MP
if X is a quadruple (c,m,y,k).

Of course I could simply change the documentation, saying I don't
support cmykcolor or graycolor. For various reasons, I'd rather not
do that. The easy way out would be to change such assignments to
   specialcolor = colorcast(X).
where colorcast is a macro like
   vardef cast (expr Y) =
     if numeric Y: Y*white
     elseif cmykcolor Y:
     else: black
But now the output will contain only rgbcolor and not true cmykcolor.

That this can be a problem was brought to my attention when an mfpic
user colored something yellow in an mfpic figure (which uses MP
and its formerly only rgb model) and colored something else yellow
using the color package (which defines yellow to be a cmyk color). The
two yellows didn't match.

The only solution I've found is to store special colors in macros and
let withcolor work out what to do with it. But this requires a
rewrite of most mfpic TeX macros that write color to the .mp file,
as well as some special coding so cmyk colors still work in pre-cmyk
metapost. All doable and not rocket science, but agonizingly tedious.


Daniel H. Luecking
Department of Mathematical Sciences
University of Arkansas
"Dubito ergo cogito, cogito ergo sum" --Descartes

More information about the metapost mailing list