[whatwg] Adding SVG Filter-like functionality to Canvas 2D Context

Hans Schmucker hansschmucker at gmail.com
Mon Jul 6 17:10:39 PDT 2009


On Tue, Jul 7, 2009 at 1:47 AM, Robert O'Callahan<robert at ocallahan.org> wrote:
> On Tue, Jul 7, 2009 at 11:37 AM, Hans Schmucker <hansschmucker at gmail.com>
> wrote:
>>
>> I should really add one point. The Canvas spec, above all, is
>> predictable. You pretty much know exactly what you'll get when you
>> perform certain actions.
>
> Like arcTo?

OK, there may be some border cases. But in general Canvas is a whole
lot more predictable than anything else you'll find in a browser.

>
>>
>> Relying directly on SVG filters makes things
>> harder to understand and predict. A flat, stripped-down API
>
> APIs don't remain stripped-down for long.

They can, if the individual modules are specific enough. Future
versions may add more filters, but the basic API would stay the same.
When you use SVG filters, there are lots of question marks in the
equation. Like, how will it render dynamic content loaded from inside
the current document, how an animation from an outside document, how
will it deal with foreignContent, how with form data inside it? All
this is largely irrelevant for Canvas, but it would still have to be
considered. A simple API could get rid of such cases straight away.


>
>> If you directly include SVG, a developer who wants to use it has to
>> understand all of SVG,
>
> That is completely untrue.

That was a bit over-dramatic. But try to learn SVG filters without an
in-depth knowledge of SVG first. There are many points that you can
trip over. Stuff that your garden-variety HTML/JS developer would just
understand differently (color spaces, units, rectangles, ...).

>> which is a pretty big spec, with lots of
>> unexpected behaviour. And as a result, often incorrect behaviour in
>> implementations.
>
> Yet you're asking us to duplicate code, which inevitably leads to even more
> bugs.

Again, you can share as much drawing code as you like, but after all,
how the filter is applied to Canvas would have to be written from
scratch anyway,


More information about the whatwg mailing list