[cairo] Subtractive API, part 1

Jon Cruz jon at joncruz.org
Sat Jan 30 21:38:46 PST 2010

On Jan 31, 2010, at 9:47 AM, ecir hana wrote:

> (This is just a thought experiment, it's far from complete, I plan to
> make it more complete in time - especially tints and multiple spots.
> But I thought we could try to tackle the problem from another side, to
> strip it to bare minimum and see where it grows.)
> Suppose you want to define a solid (100%) golden metallic spot color.
> Just one spot color and no shades. If I proposed:
> void cairo_set_source_spot(cairo_t *cr, const char *name);
> what do you think it is missing?

A very good experiment, and one that I've bounced around a bit myself.

> Obviously a fallback in a case the color in not available on the
> device. What else? Spot colors don't have ICC profiles and you cannot
> display golden color accurately, anyway. Therefore, what about:

But, yes, spot colors *can* have ICC profiles. You also can have profiles for metallics (though metallic print media and "metallic inks" are more common/useful).

Remember, an ICC profile does cover the viewing conditions and such (roughly speaking). So for the case of using a metallic spot color, an application could easily swap in and out different ICC profiles for a given color under a given condition. For example, I've discussed Inkscape plans in the past where we could use OpenGL (or pure software if needed) to simulate metallics, gloss, UV coating, etc. As the "paper" is turned by the user, Inkscape can leverage this viewing condition information to change the ICC profile for a given spot color in order to help the artist. In turn, and artist could use his inexpensive colorimeter to measure the color of a given metal at a few angles, and have an application deal with this at the high level.

> void cairo_set_source_spot(cairo_t *cr, const char *name, double cyan,
> double magenta, double yellow, double black);
> I know this is somewhat similar to the previous discussion but,
> please, could you tell me what do you think is missing from this
> proposal?

I do have to review the existing Cairo API again, but my first programmer instincts are to cringe at vague data pointers such as "char*" on the name. If a specific data type is used instead of the bare "raw random byte pointer", then a compiler can enforce a bit of safety later as the spot color is used.

Now... given the application use case mentioned, I think a helpful addition might be

void cairo_set_source_spot( cairo_t *cr, cairo_spot_t* spot );

and then

void cairo_spot_set_profile( cairo_spot* spot, cairo_profile* profile );
cairo_spot* cairo_create_spot( const char* name, ... ); // not really varargs, just TBD

But... we start to wander off into the realm of leveraging a pattern instead, and can patterns use patters, etc.

More information about the cairo mailing list