From 15a46f55512a394bd854a7c7e1dcf814b1e3805a Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Wed, 17 Jun 2009 18:05:45 +0000 Subject: [PATCH] Fix Issue 25: un-normalize path segments that webkit has munged git-svn-id: http://svg-edit.googlecode.com/svn/trunk@141 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 4ed07e4c..d23efdcd 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -443,10 +443,20 @@ function SvgCanvas(c) case "path": // extract the x,y from the path, adjust it and write back the new path var M = selected.pathSegList.getItem(0); - var newd = "M" + (M.x+dx) + "," + (M.y+dy); + var curx = M.x, cury = M.y; + var newd = "M" + (curx+dx) + "," + (cury+dy); for (var i = 1; i < selected.pathSegList.numberOfItems; ++i) { var l = selected.pathSegList.getItem(i); - newd += " l" + l.x + "," + l.y; + var x = l.x, y = l.y; + // webkit browsers normalize things and this becomes an absolute + // line segment! we need to turn this back into a rel line segment + if (l.pathSegType == 4) { + x -= curx; + y -= cury; + curx += x; + cury += y; + } + newd += " l" + x + "," + y; } selected.setAttributeNS(null, "d", newd); break;