W3C home > Mailing lists > Public > public-fx@w3.org > January to March 2012

Re: [filters] Custom filter functions proposal

From: Chris Marrin <cmarrin@apple.com>
Date: Sat, 25 Feb 2012 09:06:15 -0800
Cc: Lea Verou <leaverou@gmail.com>, "public-fx@w3.org" <public-fx@w3.org>
Message-id: <604B23CB-FFF3-4631-AE88-E3CA7D82201C@apple.com>
To: Vincent Hardy <vhardy@adobe.com>

On Feb 24, 2012, at 6:56 PM, Vincent Hardy wrote:

> Hi Lea,
> 
> On Feb 21, 2012, at 12:57 PM, Lea Verou wrote:
> 
>> Hi Vincent,
>> 
>> About your question, let's assume we have a filter in filterlib.svg with the id #foobar and the parameters x, y, z of types number, length and color respectively and we want them specified in the same order in our filter function, which is going to be called foo(). With my proposal, it would be something along these lines:
>> 
>> @filter foo {
>>     src: url(filterlib.svg#foobar);
>>     parameters: x, y, z;
>>     default: 0 1pt black; /* this means that filter: foo(); is equivalent to filter: foo(0 1pt black); */
>> }
>> 
>> I didn't use "array" like in your example, since that doesn't correspond to a CSS type.
> 
> [vh] Yes. But for CSS shaders, we do have arrays, see the <param> description at:
> 
> https://dvcs.w3.org/hg/FXTF/raw-file/tip/custom/index.html#feCustom
> 
> so it would be good to have a solution to pass arrays into shaders. But we can deal with that later I think.
> 
> If I try to convert one of the existing CSS shaders example:
> 
> filter: custom(url('wave.vs') url('old-paper.fs'), 20 20, phase 0, amplitude 50);
> 
> we could have something like:
> 
> @filter old-wave {
> 	src: shader(url('wave.vs') url(old-paper.fs));
> 	mesh: 20 20;
> 	parameters: phase, amplitude;
> 	default: 0 0;
> }
> 
> So one thing I would note for shaders is that we would need a property for the mesh in the @filter rule (the syntax is described at:
> 
> https://dvcs.w3.org/hg/FXTF/raw-file/tip/custom/index.html#vertexMesh-attribute

I don't like the idea of a property specifically for the shader function, it's not very extensible. I'd rather see something like:

	@filter old-wave {
		src: shader(url('wave.vs') url(old-paper.fs), 20 20);
		parameters: phase, amplitude;
		default: 0 0;
	}

This keeps the properties consistent regardless of the src type. 

I also think src is no longer the right property name. It would be better to call it 'function' and then use an svg(). So for the first example you'd have:

	@filter foo {
    		function: svg(url(filterlib.svg#foobar));
    		parameters: x, y, z;
    		default: 0 1pt black; /* this means that filter: foo(); is equivalent to filter: foo(0 1pt black); */
	}

Just some ideas...

-----
~Chris
cmarrin@apple.com
Received on Saturday, 25 February 2012 17:06:43 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 25 February 2012 17:06:45 GMT