Tuesday 3 July 2007

I can has turbulence?

feTurbulence is a rather problematic filter to create. It would be certainly be useful for same reasons gaussian blur is useful: it's hard to achieve the same result with only vector shapes.

Well, the first problem is, that the description of this effect in the SVG standard is rather vague. It mostly consists of C-source, which implements this effect. Well, this code doesn't even compile with gcc. It has only a couple useful comments and they describe the simple RNG used for this effect. What I have, is code that presumably calculates the colour value for single pixel, if I manage to figure out, what exactly I should pass it as parameters.

The second problem is a long-time PIA. The filters rendering code receives a bounding box, which is almost but not quite what SVG standard defines as bounding box. Well, for non-rotated and non-skewed object coordinate systems at least. With this effect, one fills the whole filter effects area, which is usually specified relative to the bounding box. (default is to expand the bounding box by 10% to every direction) As feTurbulence fills this whole area, it's really important to have correct size for this area. Otherwise, this will result in inconsistency between different SVG viewers, potentially also between different Inkscape releases.

No comments: