W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2016

Re: [whatwg] Support filters in Canvas

From: Justin Novosad <junov@google.com>
Date: Fri, 26 Feb 2016 11:20:10 -0500
Message-ID: <CABpaAqSprt=Ls0OwwST=HpvjkLt3nYKsD6XeRrBf6khXHhVW_w@mail.gmail.com>
To: Anne van Kesteren <annevk@annevk.nl>
Cc: WHATWG <whatwg@whatwg.org>, Ali Juma <ajuma@chromium.org>, mstange@themasta.com
On Fri, Feb 26, 2016 at 10:40 AM, Anne van Kesteren <annevk@annevk.nl>
wrote:

> On Fri, Feb 26, 2016 at 4:34 PM, Ali Juma <ajuma@chromium.org> wrote:
> > The current canvas filters proposal [1] allows using SVG reference
> filters
> > defined in external documents (e.g. “url(file.svg#filter)”). Since the
> > external document needs to be loaded before the filter can be applied,
> > there’s a delay between setting the context’s filter attribute to such a
> > filter and actually having the filter apply to drawing operations.
>
> Perhaps we could support assigning an SVG filter directly (as an
> object)? Developers would be responsible to load them if they're
> external. Adding yet another network API that's a thin layer on top of
> some CSS syntax seems a little hackish. I'd prefer if we exposed
> filters at a lower level somehow.
>

Just thought of a way to solve this problem without new API. You can load
the svg file as xml using XHR, and therefore guarantee the resource's
continued availability thereafter. In order to make the filter node
reachable for setting it as a canvas filter using the url() syntax, I think
you'd have to pull it in to your HTML with something like:
someLocalElement.innerHTML = new
XMLSerializer().serializeToString(svgObtainedViaXHR.documentElement);
I know this is gross (parse->serialize->re-parse), but I'm just saying
there is a way (I think).



> --
> https://annevankesteren.nl/
>
Received on Friday, 26 February 2016 16:20:40 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:37 UTC