[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cairo
Subject:    Re: [cairo] more svg to cairo stuff
From:       Dirk_Schönberger <dirk.schoenberger () sz-online ! de>
Date:       2007-11-07 20:20:32
Message-ID: 00fd01c8217b$aa3ede40$14b2a8c0 () rincewind
[Download RAW message or body]

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
interesting.

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
styles.

Regards
Dirk







_______________________________________________
cairo mailing list
cairo@cairographics.org
http://lists.cairographics.org/mailman/listinfo/cairo
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic