[whatwg] <canvas> shadow compositing oddities

Eric Butler ebutler at mozilla.com
Mon Aug 4 14:29:12 PDT 2008


Philip Taylor wrote:
> On Sun, Jul 27, 2008 at 8:06 PM, Eric Butler <ebutler at mozilla.com> wrote:
>   
>> [...]
>> However, following the spec's drawing model, there are a few operators that
>> behave rather unexpectedly if the shadow color is left at its default value.
>> For instance, since A in B always results in transparency if either A or B
>> is fully transparent, source-in will always simply clear the clipping region
>> to fully transparent no matter what the source and destination are.
>>     
>
> Oops - that does seem quite broken. (It's probably my fault - I didn't
> notice that problem when I was looking at how shadows should work...

The need to be able to disable shadows explicitly seems clear. But I 
also believe that the spec should provide
for a means to disable normal drawing and only draw shadows to increase 
the usefulness of shadows.

As it stands, if you draw with shadows, you'll end up getting some of 
the shadows drawn on top of some of
the actual shapes. But perhaps the developer wants to have all shadows 
behind all shapes for a particular set
of shapes. The only way to accomplish that would be to create a second 
canvas, do all the drawing without
shadows on that, then draw the canvas with its shadow back to the 
original, which seems cumbersome
to use and is terribly inefficient.

It would be simpler if the user could simply turn on only shadows, do 
the drawing once, then turn on only
normal rendering and do the drawing again. You cannot simply set the 
fill/stroke style to transparent for
the same reason that it doesn't quite work for shadows. So I believe 
that the spec should provide for the
means to explicitly disable both shadows and normal drawing separately.

To that end, perhaps there could be an attribute which indicated what 
the current state of the drawing model
was: object only, shadow only, or objects and shadows, defaulting to 
drawing only objects. This would create
more expected output for all composite operators, and would allow 
developers to do some more complex
tricks with shadows.

Oliver Hunt wrote:
>
> We could special case opacity 0, with 0,0 offset, and 0 blur radius as 
> being a "do not draw shadow" flag perhaps?
>
This wouldn't solve the problem of disabling normal drawing and doesn't 
seem like a very clean API to me.
A more explicit attribute seems better in my opinion.

While it is true that having shadows and objects always in the drawing 
model can be hacked around when all but
certain uncommon composite operators are being used, it seems unclean to 
have to keep flipping the style back
and forth to hack around things. Furthermore, it is extremely difficult 
if not impossible to achieve certain effects
without the ability to modify the drawing model. So I believe such a 
means should be provided.

-Eric Butler



More information about the whatwg mailing list