W3C home > Mailing lists > Public > www-style@w3.org > February 2013

Re: [CSS4 color][CSS4 transition] color pre-multiplied vs non pre-multiplied was (Re: [CSSWG] Minutes TPAC Tue 2012-10-30 AM I: Abstract Directions, Transforms, Transitions)

From: Rik Cabanier <cabanier@gmail.com>
Date: Wed, 27 Feb 2013 08:25:12 -0800
Message-ID: <CAGN7qDBWsRUUMRU9xLjz=327dYSA-_6NpQO1nSoyfDizE0nUDQ@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: Liam Quin <liam@w3.org>, "www-style@w3.org" <www-style@w3.org>
On Tue, Feb 26, 2013 at 11:27 PM, Tab Atkins Jr. <jackalmage@gmail.com>wrote:

> On Tue, Feb 26, 2013 at 11:00 PM, Rik Cabanier <cabanier@gmail.com> wrote:
> > non-premultiplied gradients are not a restriction. I can't think of a
> single
> > design application or graphics library that implements this idiom.
> > The CSS WG introduced this so they wouldn't have to special case
> > 'transparent'; not because it made sense.
> No, we've been over this.  While it's possible to hack gradients by
> duplicating the transparent color where the color is distributed on a
> line (linear, radial, and the future conical gradients all satisfy
> this), this stops working as soon as the color is distributed over an
> area, like the mesh gradients being added to SVG.  We don't want to be
> inconsistent across our gradient types.

I'm glad you bring mesh gradients up.
All mesh gradients in existence today (in PDF) also don't use premultiplied
alpha. Adobe's authoring applications that use meshes internally (but
produce images because the UA doesn't support them) also don't premultiply
the alpha.
We can ask inkscape what they did in their implementation, but it's most
likely that they just interpolated the colors.
As you know SVG and Canvas also don't premultiply the colors. Are you
suggesting they change their behavior?

> Implementations that can't do premultiplied gradients natively can
> hack them by doing the transparent-color duplication behind the
> scenes, and then just drawing a non-premultiplied gradient.  They'll
> have problems with mesh gradients, but I don't think Core Graphics can
> do mesh gradients natively anyway, so it'll require either additions
> to CG or some other method to implement.
> So, summing up, premultiplied gradients:
> * are more convenient for authors, because they don't produce
> confusing behavior due to "transparent" having an
> otherwise-undetectable color (like a transparent->white gradient being
> gray in the middle)

Special casing 'transparent' fixes that in an intuitive way. It's more
confusing to authors that CSS gradients are different from any other type
of gradient.
Good luck trying to match that CSS gradient with the one in PhotoShop!

> * can't be hacked by authors when doing 2d gradients, like the mesh
> gradients being added to SVG2, so we should be consistent across the
> gradients

Agreed. so no premultiplied alpha.

> * for the 1d gradients, can be automatically hacked by implementations
> that only do non-premultiplied natively, by just duplicating and
> coloring "transparent" color-stops behind the scenes

That might be do-able today.
However, we've talked about being able to change the 'midpoint' of the
gradient curve. I *think* that would be difficult to implement so it
renders correctly.
Received on Wednesday, 27 February 2013 16:25:44 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:26 UTC