[cairo] Path Representation In Qahirah

Krzysztof Kosiński tweenk.pl at gmail.com
Wed Mar 25 17:12:13 PDT 2015


2015-03-24 23:09 GMT+01:00 Lawrence D'Oliveiro <ldo at geek-central.gen.nz>:
> 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


More information about the cairo mailing list