Bug 1122 : Fix algorithm for quadratic to cubic curve conversion in PGraphicsOpenGL and PShapeSVG
Last modified: 2009-02-21 06:47




Status:
RESOLVED
Resolution:
FIXED -
Priority:
P2
Severity:
normal

 

Reporter:
bnadeau
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2009-01-13 12:26
In opengl library, PGraphicsOpenGL.java, textCharShapeImpl(...) uses the
bezierPoint(...) function to tessellate characters for rendering.

When parsing a quad curve, the function breaks the curve in segments based
on 'bezierDetail'. It computes vertices on the curve using the following
(line 1614):

vertex = new double[] {
x + bezierPoint(lastX, textPoints[0], textPoints[2], textPoints[2], t),
y + bezierPoint(lastY, textPoints[1], textPoints[3], textPoints[3], t), 0
};

This seem to convert a quad(x1, y1, cx, cy, x2, y2) to bezier(x1, y1, cx,
cy, x2, y2, x2, y2), which is wrong.

quad(x1, y1, cx, cy, x2, y2) is really equal to bezier(x1, y1, x1 +
((cx-x1)*2/3), y1 + ((cy-y1)*2/3), x2 + ((cx-x2)*2/3), y2 + ((cy-y2)2*/3),
x2, y2)
Additional Comment #1 From fry 2009-02-21 06:47
Huh, not sure where I picked up the wrong solution, but it's now fixed for
1.0.2. Thanks for the heads up.