[cairo] more svg to cairo stuff
dirk.schoenberger at sz-online.de
Wed Nov 7 12:20:32 PST 2007
Somehow I don't see the problem ;)
The SVG rendering model is conceptionally similar to the cairo rendering
model (both use a vector path model).
So you need to extract the following information:
- Path construction
- Path rendering
Path construction is done by calling the actual path construction operators.
> I found some neat code that will parse it and one looks like this:
> [['M', [591.42857000000004, 835.21933000000001]],
> ['C', [861.36627999999996, 952.71894999999995,
101.54696, -257.41887000000003, 100.0, 146.64789999999999]],
> ['C', [98.453036999999995, 550.71466999999996, 321.49086,
717.71970999999996, 591.42857000000004, 835.21933000000001]],
> ['Z', ]]
These are the operators:
M is a "moveto" operator, which has two floating point operands
C is a "curveto" operator, which has six floating point operands
Z is a closepath operator without operands
A moveto matches to cairo_moveto (resp its equivalent in the Python
binding), curveto matches to cairo_curveto, closepath to cairo_close_path
There exist a couple more operators in the SVG spec, but these are the most
After you have built the path, you may render it. In SVG here apply the
stroke and fill attributes, with match cairo_fill and cairo_stroke.
The interesting part is to extract the information about how to draw (i.e.
using a solid colour, a pattern, a gradient or whatever). This may get a
little tricky, and potentially complex, if you have descend to e.g. CSS
More information about the cairo