Re: Path Representation In Qahirah
Krzysztof Kosiński <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <CAFLw2WRK41RCd9hUX4kZtmmsu2KAqf=+ccCCiS7GNGM6_AyP0g@mail.gmail.com> |
2015-03-24 23:09 GMT+01:00 Lawrence D'Oliveiro <[email protected]>: > So I have changed the internal representation I use. This is now a > sequence of Segments, each of which is a sequence of Points, together > with an open/closed indication for the Segment. Each Point has a > coordinate Vector, together with an on-curve/off-curve flag. Two > successive on-curve points produce a straight line; a single off-curve > point in-between defines a quadratic Bézier, while two off-curve points > in-between make for a cubic Bézier. Each Segment must begin and end > with an on-curve Point. You may find this approach hard to generalize to elliptical arcs, as encountered in SVG. For comparison, Inkscape's geometry library lib2geom stores paths as a sequence of curves (functions mapping the unit interval to the plane), each of which can store different data. A Bezier segment stores all control points, an elliptical arc segment stores the same data as an SVG elliptical arc command plus some precomputed values, and there is also a segment that represents a curve in symmetric power basis (SBasis). Linear segment is just a Bezier with 2 control points. Although this representation is somewhat redundant (in the worst case of a path with linear segments only, all points are stored twice), it is very convenient and leads to an easy to use API. Regards, Krzysztof -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo