Re: [filters] Custom filter functions proposal

I agree this is a good idea. We had considered proposing this from the start, but figured it would slow the process down (I expect we would spend a lot of time iterating over syntax). It's also a change to parsing in SVG.

I hope we can get to it soon.

Dean

On 19/02/2012, at 8:31 AM, Lea Verou wrote:

> On 19/2/12 17:48, Rik Cabanier wrote:
> > Hi Lea,
> > I can see how this would be very useful.
> > It would also allow people to create libraries with filters that could be used as short hands.
> 
> Exactly! This is one of the benefits I mentioned ;)
> 
> > Can you write out a complete example of such a filter?
> > Rik
> 
> Sure. My imagination is running kinda low at the moment, so lets assume hue-rotate wasn't already in the draft.
> 
> An author would include this filter in an SVG called filterlib.svg (which could obviously include other filters as well):
> 
> <filter id="hue-rotate">
>  <feColorMatrix type="hueRotate" values="param(angle) 0"/>
> </filter>
> 
> Note that the syntax of param() and its default value (of 0 here) is defined in SVGParam [1].
> 
> And then would define it as a function in their CSS like so:
> 
> @filter {
>  src: url(/path/to/filterlib.svg#hue-rotate);
>  name: hue-rotate;
>  parameters: angle;
>  default: 0;
> }
> 
> And then they'd be able to use hue-rotate() as is currently defined by the Filter Effects draft.
> 
> An alternative syntax could include the function name outside the braces, @keyframes-style:
> 
> @filter hue-rotate {
>  src: url(/path/to/filterlib.svg#hue-rotate);
>  parameters: angle;
>  default: 0;
> }
> 
> `default` isn't really needed in this case, as the SVG already defines a default, so it could be omitted.
> 
> [1]: http://www.w3.org/TR/SVGParam/
> 
> -- 
> Lea Verou (http://lea.verou.me | @LeaVerou)
> 

Received on Monday, 20 February 2012 21:00:17 UTC