W3C home > Mailing lists > Public > www-style@w3.org > May 2011

Re: [css3-images] cross-fade()

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Mon, 9 May 2011 12:32:14 -0700
Message-ID: <BANLkTi=qJpO9t6s8HR6-QLuD=tiu+wzK+g@mail.gmail.com>
To: "L. David Baron" <dbaron@dbaron.org>
Cc: www-style@w3.org
On Wed, May 4, 2011 at 9:40 AM, L. David Baron <dbaron@dbaron.org> wrote:
> I think the current definition of cross-fade() in
> http://dev.w3.org/csswg/css3-images/#cross-fade-function is
> incorrect.  It defines cross-fade() in terms of the porter-duff over
> operator, which is not symmetric.  This means that cross-fade(A, B,
> 30%) is different from cross-fade(B, A, 70%).
>
> I *think*, though I'm not sure, that the right way to define
> cross-fade is in terms of the plus operator described in section 4.5
> of the original Porter-Duff paper:
> http://keithp.com/~keithp/porterduff/

You are correct that 'src-over' is wrong and 'plus' is correct.  This
isn't because src-over is asymmetric, but rather because src-over
simply doesn't do what we want here.

As currently (well, previously, now that fantasai's made some edits)
defined, doing:

cross-fade(image(red), image(red), 50%)

...would result in a partially-transparent red image, even though both
the src and dst images are fully opaque.  This is not what we want.

There's another option, which is to do src-over with B as src and A as
dst, ramping the opacity of B while leaving A unaltered.  This would
make two opaque images fade correctly, but is completely wrong if B is
partially transparent.

Doing a 'plus' is the preferred operation here, as it keeps the first
example working as we want (always a fully-opaque red image,
regardless of the fade percentage), and works well if either A or B
are partially transparent.



2011/5/6 Brendan Kenny <bckenny@gmail.com>:
> To back up all the "I think"s with another, this looks correct. It
> does seem a little strange to algebraically define how to linearly
> interpolate the image size but then defer to Porter-Duff for addition,
> though :)

Yeah, my detail level is sometimes inconsistent.  ^_^  I'll fix this up.


> It seems like the more important phrase to be careful with is "has a
> global alpha applied to it." Is this defined elsewhere? It's not a
> huge leap, but it seems better to just identify this as Porter-Duff's
> dissolve operator and dispel any confusion about premultiplication or
> whether all components are scaled equally.

As explained above, we don't want 'dissolve', as it does the wrong
thing, particularly when both src and dst are fully opaque.  Instead
we want imagick's 'blend' operator, which uses the 'plus' operator.

However, the exact wording around alpha and such does indeed need to
be worked on.  I'll fix it up.

~TJ
Received on Monday, 9 May 2011 19:33:02 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:40 GMT