vendredi 2 janvier 2015

Shading an SVG shape using control points


I'm using Inkscape to produce an SVG image which is supposed to reproduce a photo. I have some arbitrarily drawn shape, and I need to shade it. Here's an example photo:


a lump of clay


Here's how I would like to define the shading of the clay in the image above: define the color at a small set of control points, and have the color at every other point in the shape defined by interpolating between those control points. Or more sophisticatedly: define a set of control lines of constant color, so that the other pixels' colors interpolate between these lines. (I don't know what the interpolation algorithm should be; I imagine something like 2D Gouraud shading.)


However, I can't find how to do this. SVG only seems to provide linear and radial gradients. Other people seem to very carefully draw their naturalistic images in SVG using many shapes with combinations of these two shaders. For example:


shaded fish


This method is time-consuming, and only seems to work well for smooth, shiny things with a lot of specular highlights.


Is it possible to do something like my suggested shading method in SVG? I can imagine something which compiles a shading definition like the one I suggested, and produces an SVG approximation.


Alternatively, do technologies outside of SVG provide something like what I suggested?





Aucun commentaire:

Enregistrer un commentaire