Re: [CSSWG] Minutes and Resolutions 2009-02-04: box-shadow and border-image

On Feb 12, 2009, at 4:15 PM, Robert O'Callahan wrote:

> On Fri, Feb 13, 2009 at 10:52 AM, Brad Kemper  
> <brad.kemper@gmail.com> wrote:
> On Thu, Feb 12, 2009 at 12:22 PM, Robert O'Callahan <robert@ocallahan.org 
> > wrote:
> On Fri, Feb 13, 2009 at 8:43 AM, Brad Kemper <brad.kemper@gmail.com>  
> wrote:
> 1. How to deal with soft image edges, where there is variable  
> opacity? Currently, WebKit seems to clip shadows to the vector edge  
> of the border box, and not draw them behind areas of variable  
> opacity (such as backgrounds). It seems like for a raster image that  
> was 50% opaque, it would have draw the shadow behind the whole image  
> at 50% of its normal opacity.
>
> That's the way to go. What you would do is construct a mask the size  
> of the border-box whose alpha values in the border are the border- 
> image's alpha values, and whose alpha values in the padding-box are  
> 1. Then you apply blur to that mask (or not)
>
> ..and then clip out the padding-box from that, which ordinarily  
> would not have a shadow from the border cast onto it (or does this  
> shadow still get drawn behind the padding box?)...
>
> You build the element's mask, then you build the shadow, then you  
> cut the mask out of the shadow by painting alpha=0 with the "source"  
> Porter-Duff operator using the element's mask as the mask. The alpha  
> values of the cut-out shadow will be the shadow alpha value  
> multiplied by (1 - the mask alpha value). So no shadow will draw  
> under the padding-box.

I think Brad's point is that no shadow should appear under the  
original location of the padding box either.  It's a given that the  
shadow itself when offset will contain only transparent pixels in its  
own offset padding area, but the offset "border" portion of the shadow  
should also not appear behind the original padding box.

Basically you clip out the original padding box from any drawing you  
do right up front just as with normal box shadow, and then build/paint  
the shadow as you suggested.

dave
(hyatt@apple.com)

Received on Thursday, 12 February 2009 22:23:00 UTC