From 54e327b22b06f3a9c2f98463f645ba44fc6a500e Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Wed, 16 Dec 2009 07:11:33 +0000 Subject: [PATCH] fixtransforms branch: undo some damage I did to normal shapes being rotated/resized, but skewed+rotated shapes go back to jumping git-svn-id: http://svg-edit.googlecode.com/svn/branches/fixtransforms@1048 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 54527914..6075efbf 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -1744,13 +1744,8 @@ function BatchCommand(text) { // else, it's a non-group else { var box = canvas.getBBox(selected); - // TODO: fix this, it is not correct in the case of a skewed element - // - use transformBox? - // TODO: if a rotated, skewed element is moved, at first no problem - // however, if another element is selected, then back to the first element - // it will hop around... var center = {x: (box.x+box.width/2), y: (box.y+box.height/2)}; - var newcenter = transformPoint(center.x,center.y,transformListToTransform(tlist).matrix);//{x: center.x, y: center.y }; + var newcenter = transformPoint(center.x,center.y,transformListToTransform(tlist).matrix); var m = svgroot.createSVGMatrix(); // temporarily strip off the rotate @@ -1797,14 +1792,9 @@ function BatchCommand(text) { } // if the shape was rotated, calculate what the center will be - var xcenter = null; + var xcenter = {x:0, y:0}; if (angle) { - // calculate the new center from the translate - if (operation == 2) { - // TODO: avoid this? -// newcenter = transformPoint(center.x,center.y,m); - } - else if (operation == 3) { + if (operation == 3) { xcenter = transformPoint(center.x,center.y,m); } } @@ -1822,24 +1812,14 @@ function BatchCommand(text) { // at this point, the element looks exactly how we want it to look but its // rotational center may be off in the case of a resize - we need to fix that - // TODO: if we get in here, I think there are problems - if (angle && operation == 3) { - box = canvas.getBBox(selected); - m = transformListToTransform(tlist).matrix; - - // get its actual center - newcenter = transformPoint(box.x+box.width/2, box.y+box.height/2, m); - + if (false && angle && operation == 3) { // determine the resultant delta translate to re-center var dx = newcenter.x - xcenter.x, dy = newcenter.y - xcenter.y; var delta = svgroot.createSVGMatrix().translate(dx,dy); + console.log([dx,dy]); remapElement(selected,changes,delta); - - var newRot = svgroot.createSVGTransform(); - newRot.setRotate(angle,newcenter.x,newcenter.y); - tlist.replaceItem(newRot,0); } } // a non-group