[whatwg] Support filters in Canvas

Dirk Schulze dschulze at adobe.com
Sat Mar 15 00:03:00 PDT 2014


Hi,

Apologize if it was already discussed but I couldn’t find a mail to this topic.

In one of the early drafts of Filter Effects we had filter operation support for HTML Canvas. We deferred it and IMO it makes more sense to have it as part of the Canvas specification text.

I would suggest a filter attribute that takes a list of filter operations similar to the CSS Image filter function[1]. Similar to shadows[2], each drawing operation would be filtered. The API looks like this:

partial interface CanvasRenderingContext2D {
    attribute DOMString filter;
}

A filter DOMString could looks like: “contrast(50%) blur(3px)”

With the combination of grouping in canvas[3] it would be possible to group drawing operations and filter them together.

Filter functions include a reference to a <filter> element and a specification of SVG filters[4]. I am unsure if a reference do an element within a document can cause problems. If it does, we would just not support SVG filter references.

Greetings,
Dirk

[1] http://dev.w3.org/fxtf/filters/#interpolating-filter-image
[2] http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#shadows
[3] http://lists.w3.org/Archives/Public/public-canvas-api/2013AprJun/0009.html
[4] http://dev.w3.org/fxtf/filters/#FilterElement


More information about the whatwg mailing list