From 119c49e73ecda40e92303c03231086eae61295df Mon Sep 17 00:00:00 2001 From: Robert Meyer Date: Tue, 20 Aug 2013 15:00:13 +0000 Subject: FOP-2275: Quadratic Bezier curves not properly rendered git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1515840 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/svg/PDFGraphics2D.java | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index 526420d9c..efa71a225 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -1691,11 +1691,15 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand * @param iter PathIterator to process */ public void processPathIterator(PathIterator iter) { + double lastX = 0.0; + double lastY = 0.0; while (!iter.isDone()) { double[] vals = new double[6]; int type = iter.currentSegment(vals); switch (type) { case PathIterator.SEG_CUBICTO: + lastX = vals[4]; + lastY = vals[5]; currentStream.write(PDFNumber.doubleOut(vals[0], DEC) + " " + PDFNumber.doubleOut(vals[1], DEC) + " " + PDFNumber.doubleOut(vals[2], DEC) + " " @@ -1704,18 +1708,30 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand + PDFNumber.doubleOut(vals[5], DEC) + " c\n"); break; case PathIterator.SEG_LINETO: + lastX = vals[0]; + lastY = vals[1]; currentStream.write(PDFNumber.doubleOut(vals[0], DEC) + " " + PDFNumber.doubleOut(vals[1], DEC) + " l\n"); break; case PathIterator.SEG_MOVETO: + lastX = vals[0]; + lastY = vals[1]; currentStream.write(PDFNumber.doubleOut(vals[0], DEC) + " " + PDFNumber.doubleOut(vals[1], DEC) + " m\n"); break; case PathIterator.SEG_QUADTO: - currentStream.write(PDFNumber.doubleOut(vals[0], DEC) + " " - + PDFNumber.doubleOut(vals[1], DEC) + " " - + PDFNumber.doubleOut(vals[2], DEC) + " " - + PDFNumber.doubleOut(vals[3], DEC) + " y\n"); + double controlPointAX = lastX + ((2.0 / 3.0) * (vals[0] - lastX)); + double controlPointAY = lastY + ((2.0 / 3.0) * (vals[1] - lastY)); + double controlPointBX = vals[2] + ((2.0 / 3.0) * (vals[0] - vals[2])); + double controlPointBY = vals[3] + ((2.0 / 3.0) * (vals[1] - vals[3])); + currentStream.write(PDFNumber.doubleOut(controlPointAX, DEC) + " " + + PDFNumber.doubleOut(controlPointAY, DEC) + " " + + PDFNumber.doubleOut(controlPointBX, DEC) + " " + + PDFNumber.doubleOut(controlPointBY, DEC) + " " + + PDFNumber.doubleOut(vals[2], DEC) + " " + + PDFNumber.doubleOut(vals[3], DEC) + " c\n"); + lastX = vals[2]; + lastY = vals[3]; break; case PathIterator.SEG_CLOSE: currentStream.write("h\n"); -- cgit v1.2.3