Add support for Quadratic Beziers

Bug #1009765 reported by Shriramana Sharma on 2012-06-06
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Wishlist
Unassigned

Bug Description

Inkscape currently supports Cubic Beziers. Quadratic Bezier curves are also an integral part of the SVG specification. It would be simply great if Inkscape would help us edit quadratic Beziers.

I am told that currently Inkscape can read quadratic Beziers from SVG files but it elevates them to cubic. It seems that this is a lossy conversion in the sense that the quadratic nature of that curve is not and one is allowed to edit the two generated control points mutually independently, and hence while saving back, (whether the generated control points were modified or not) the original quadratic nature is lost and the curve is henceforth a cubic.

I feel it is important that Inkscape should provide native support for quadratic Beziers. Rendering it on screen for editing purposes would not be a problem, since even if you only do cubic rendering using Cairo or such, you can always temporarily elevate the quadratic to cubic for rendering purposes. But there should be a quadratic mode for the Bezier drawing tool, which would only allow for specifying one control point per curve segment.

I realize that there has been a recent discussion of this on the devel list: http://thread.gmane.org/gmane.comp.graphics.inkscape.devel/36297/focus=36308

But it seems (http://inkscape.13.n6.nabble.com/UI-ideas-for-quadratic-and-elliptic-curves-tp2850060p2850075.html) that adding support for quadratic Beziers is not all that difficult, since all you need to do is to glue two cubic handles together as Krzysztof remarked on that thread. Apparently the only confusion (mentioned in the UI thread) is about how to provide support for elliptic segments.

But obviously it is not necessary to wait for the elliptic question to be resolved for the quadratic feature to be provided. Quadratic editing capabilities would be a great boon for users with specific requirements like me! I hope this link: http://forum.high-logic.com/viewtopic.php?f=8&t=3850 would show how quadratic editing capabilities would be tremendously useful especially in font creation!

su_v (suv-lp) on 2012-06-07
tags: added: node-editing svg
Changed in inkscape:
importance: Undecided → Wishlist
status: New → Confirmed
Shriramana Sharma (jamadagni) wrote :

Hello. I've been investigating this and it seems that one should not simply join the cubic's control points together. Since Cairo (IIRC Inkscape from the current development onwards uses Cairo) does not have a built-in function to draw quadratic curves (http://www.cairographics.org/manual/cairo-Paths.html) the behind-the-scenes cubic control point pair equivalent to a single quadratic control point have to be calculated by degree-elevation.

The generic formula is available at http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Degree_elevation but the relevant version for the present situation is given by: http://caffeineowl.com/graphics/2d/vectorial/cubic2quad01.html

<quote>
A quadratic Bezier can be always represented by a cubic one by applying the degree elevation algorithm. The resulted cubic representation will share its anchor points with the original quadratic, while the control points will be at 2/3 of the quadratic handle segments:

C1 = (2·C + P1)/3
C2 = (2·C + P2)/3
</quote>

Shriramana Sharma (jamadagni) wrote :

So I did some more digging:

1. Apparently a quadratic can't be substituted by a cubic where both cubic controls are set equal to the single quadratic one, or one cubic control is set equal to a node and the other is set equal to the quadratic control. Only the 2/3 formula will work. See attached images. (http://processingjs.nihongoresources.com/bezierinfo/)

2. FWIW I submitted some simple patches for Cairo to support quadratics: http://lists.cairographics.org/archives/cairo/2012-August/023397.html

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers