From 963566c2c1c45e7e30316dd37d851718f4f1aa9a Mon Sep 17 00:00:00 2001 From: kitfox Date: Tue, 16 Oct 2012 22:47:09 +0000 Subject: Fixing path calculation error for continuous joins. git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@137 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b --- .../java/com/kitfox/svg/pathcmd/CubicSmooth.java | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/main/java/com/kitfox/svg/pathcmd/CubicSmooth.java') diff --git a/src/main/java/com/kitfox/svg/pathcmd/CubicSmooth.java b/src/main/java/com/kitfox/svg/pathcmd/CubicSmooth.java index a54b9e4..9128452 100644 --- a/src/main/java/com/kitfox/svg/pathcmd/CubicSmooth.java +++ b/src/main/java/com/kitfox/svg/pathcmd/CubicSmooth.java @@ -56,23 +56,30 @@ public class CubicSmooth extends PathCommand { // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) public void appendPath(GeneralPath path, BuildHistory hist) { - float offx = isRelative ? hist.history[0].x : 0f; - float offy = isRelative ? hist.history[0].y : 0f; + float offx = isRelative ? hist.lastPoint.x : 0f; + float offy = isRelative ? hist.lastPoint.y : 0f; - float oldKx = hist.history.length >= 2 ? hist.history[1].x : hist.history[0].x; - float oldKy = hist.history.length >= 2 ? hist.history[1].y : hist.history[0].y; - float oldX = hist.history[0].x; - float oldY = hist.history[0].y; + float oldKx = hist.lastKnot.x; + float oldKy = hist.lastKnot.y; + float oldX = hist.lastPoint.x; + float oldY = hist.lastPoint.y; //Calc knot as reflection of old knot float k1x = oldX * 2f - oldKx; float k1y = oldY * 2f - oldKy; path.curveTo(k1x, k1y, k2x + offx, k2y + offy, x + offx, y + offy); - hist.setPointAndKnot(x + offx, y + offy, k2x + offx, k2y + offy); + hist.setLastPoint(x + offx, y + offy); + hist.setLastKnot(k2x + offx, k2y + offy); } public int getNumKnotsAdded() { return 6; } + + public String toString() + { + return "S " + k2x + " " + k2y + + " " + x + " " + y; + } } -- cgit v1.2.3-55-g7522