[cairo] Cairo gradients and pre-mul data

Keith Packard keithp at keithp.com
Tue Jun 20 23:55:27 PDT 2006


On Wed, 2006-06-21 at 01:14 -0500, Federico Mena Quintero wrote:

> What's the premultiplied equivalent of a non-premult gradient from
> (1, 0, 0, 0) to (1, 1, 1, 0)?  I.e. transparent red to solid white.  On
> the GIMP this gives me a transparent-to-white gradient with a red tinge
> in the middle section.

That's the point -- premultplied gives you only one transparent value
(0,0,0,0). So, there's no way to move towards transparent 'red'.

As a trade off, premultiplied gives you 'superluminescent' pixels which
provide color above their opacity.

In isolation, premultiplied values are 'better'; they do more than
non-premulitplied values. However, gradients change that as the notion
of 'transparent red' actually makes a twisted kind of sense; twisted
enough that SVG actually uses it. Sigh.

> Would one need to overlay two premultiplied gradients or something like
> that?

yes, you'd use separate mask and color gradients. But, cairo doesn't
have separate mask and geometry operands, so you'd end up with a lot of
temporary alpha masks to make this work.

The obvious alternative is to just add pre-multiplied color stops;
computing the gradient with a combination of such stops should even be
easy to define; the output is always a set of premultiplied values in
any case.

-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060620/952238d4/attachment-0001.pgp


More information about the cairo mailing list