Questions about EllipticalArc, BezierCurve, and Path
Dear Inkscape-devel,
I would like to convert a path that internally stores EllipticalArcs into a path with a bunch of BezierCurves. Is there a method that already does this? One way I think can be used is to convert path to pwd2, and convert back again to pathVector using path_from_piecewise() because internally it only uses Bezier curves, but I am wondering if there is a more direct way to do this.
If I have a PathVector structure, and I know all Paths inside are connected to each other, is there an easy way to convert such PathVector into Path?
Thank you.
Regards, _______________________ Papoj "Hua" Thamjaroenporn papojt@...3117...
On Dec 23, 2015 01:05, "Papoj Thamjaroenporn" <pt2277@...3110...> wrote:
Dear Inkscape-devel,
I would like to convert a path that internally stores EllipticalArcs into
a path with a bunch of BezierCurves. Is there a method that already does this? One way I think can be used is to convert path to pwd2, and convert back again to pathVector using path_from_piecewise() because internally it only uses Bezier curves, but I am wondering if there is a more direct way to do this.
Look at pathv_to_linear_and_cubic_beziers(), I think it was either in helper/geom.h or in util/geom.h. Going via SBasis is not recommended.
If I have a PathVector structure, and I know all Paths inside are
connected to each other, is there an easy way to convert such PathVector into Path?
I don't understand this. How are they "connected"? The final point of one path is equal to the initial point of the next one?
Best regards, Krzysztof
By connected I mean, say I feed in a Circle into Path, and then convert Path to pwd2 type. Now, if I convert this back using path_from_piecewise, I get PathVector. But I prefer to get a Path back and I know that the input curves share final point and the next initial point. Is there a way to convert such PathVector to Path?
Thank you Krzysztof! __________________________________ Papoj "Hua" Thamjaroenporn papojt@...3117...
On Dec 24, 2015, at 5:01 AM, Krzysztof Kosiński <tweenk.pl@...400...> wrote:
On Dec 23, 2015 01:05, "Papoj Thamjaroenporn" <pt2277@...3110...> wrote:
Dear Inkscape-devel,
I would like to convert a path that internally stores EllipticalArcs into a path with a bunch of BezierCurves. Is there a method that already does this? One way I think can be used is to convert path to pwd2, and convert back again to pathVector using path_from_piecewise() because internally it only uses Bezier curves, but I am wondering if there is a more direct way to do this.
Look at pathv_to_linear_and_cubic_beziers(), I think it was either in helper/geom.h or in util/geom.h. Going via SBasis is not recommended.
If I have a PathVector structure, and I know all Paths inside are connected to each other, is there an easy way to convert such PathVector into Path?
I don't understand this. How are they "connected"? The final point of one path is equal to the initial point of the next one?
Best regards, Krzysztof
On Dec 24, 2015 03:21, "Papoj Thamjaroenporn" <pt2277@...3110...> wrote:
By connected I mean, say I feed in a Circle into Path, and then convert
Path to pwd2 type. Now, if I convert this back using path_from_piecewise, I get PathVector. But I prefer to get a Path back and I know that the input curves share final point and the next initial point. Is there a way to convert such PathVector to Path?
If there is always only one path, just use pv[0].
If there can be multiple paths, but the final point of each path coincides with the initial point of the next path, then IIRC you can iterate over the pathvector and call append() with each path in turn:
Path result(pv[0].initialPoint()); for (unsigned i = 0; i < pv.size(); ++i) { result.append(pv[i]); }
You can also turn on stitching for the result path if the points do not exactly coincide. This has to be done before any append operation, of course. Stitching will add line segments so that the path remains continuous.
result.setStitching(true);
Best regards, Krzysztof
participants (2)
-
Krzysztof Kosiński
-
Papoj Thamjaroenporn