[cairo] Spot colors (and CMYK)

Bill Spitzak spitzak at gmail.com
Wed Jan 13 11:36:06 PST 2010

I certainly don't want to see a malloc/free pair just to set a color!

I think instead the apis can take an enumeration describing the "type" 
of color followed by a pointer to the data. I would purposely not allow 
any ability to get colors *from* Cairo so that the backend is free to 
immediatly translate to device space (ie to 32 bit color) and not keep 
the original color around.

Something like this:

   cairo_set_source_color(cairo_t*, cairo_color_type_enum, float data[]);

I can't see any good way around having to cast the final pointer if the 
data is not an array of floats.

Besides CMYK and spot colors I would like to see the ability to specify 
the color as a 32-bit BGRA number, so that users can pull colors out of 
the very same images they are telling Cairo to draw and guarantee they 
are getting a matching color. Currently you have to "guess" what the 
translation from float is and the end result is that whatever 
rounding/etc Cairo does will have to be fixed and can never be changed 
even if people decide it was wrong.

Adrian Johnson wrote:

> A starting point for an API proposal to support CMYK colors is the 
> following:
> 1) Expose cairo_color_t as an opaque type. This will allow supporting 
> various types of color without an explosion in the number of API 
> functions every time a new type of color is added.
> cairo_color_t *
> cairo_color_reference (cairo_color_t *color);
> cairo_status_t
> cairo_color_status (cairo_color_t *color);
> void
> cairo_color_destroy (cairo_color_t *color);

More information about the cairo mailing list