From 2736be370bdb4b7dc528126715b862ffe4be3c38 Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Fri, 18 Dec 2009 18:22:06 +0000 Subject: [PATCH] fixtransforms branch: resizing a skewed element now works properly git-svn-id: http://svg-edit.googlecode.com/svn/branches/fixtransforms@1069 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 29b35782..32a27191 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -1908,7 +1908,8 @@ function BatchCommand(text) { var operation = 0; var N = tlist.numberOfItems; - // first, if it was a scale then the second-last transform will be the [S] + // first, if it was a scale of a non-skewed element, then the second-last + // transform will be the [S] // if we had [M][T][S][T] we want to extract the matrix equivalent of // [T][S][T] and push it down to the element if (N >= 3 && tlist.getItem(N-2).type == 3 && @@ -1919,31 +1920,18 @@ function BatchCommand(text) { tlist.removeItem(N-1); tlist.removeItem(N-2); tlist.removeItem(N-3); - } // if we had [T][S][-T][M], then this was a matrix-element being - // resized. Thus, we simply combine it all into one matrix - else if(N == 4 && tlist.getItem(N-1).type == 1 && !angle) { + } // if we had [T][S][-T][M], then this was a skewed element being resized + // Thus, we simply combine it all into one matrix + else if(N == 4 && tlist.getItem(N-1).type == 1) { + operation = 3; // scale m = transformListToTransform(tlist).matrix; var e2t = svgroot.createSVGTransform(); e2t.setMatrix(m); tlist.clear(); tlist.appendItem(e2t); - return null; + // reset the matrix so that the element is not re-mapped + m = svgroot.createSVGMatrix(); } // if we had [R][T][S][-T][M], then this was a rotated matrix-element - // being resized. Thus, we simply combine the matrix and keep the rotate - else if(N == 4 && tlist.getItem(N-1).type == 1 && angle) { - m = transformListToTransform(tlist).matrix; - var e2t = svgroot.createSVGTransform(); - e2t.setMatrix(m); - tlist.clear(); - tlist.appendItem(e2t); - - // Not positioned correctly yet. - // FIXME codedread! You're my only hope... - var newRot = svgroot.createSVGTransform(); - newRot.setRotate(angle,newcenter.x,newcenter.y); - tlist.insertItemBefore(newRot, 0); - return null; - } // if we had [T1][M] we want to transform this into [M][T2] // therefore [ T2 ] = [ M_inv ] [ T1 ] [ M ] and we can push [T2] // down to the element