diff options
author | wout <wout@impinc.co.uk> | 2014-07-28 22:16:35 +0200 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-07-28 22:16:35 +0200 |
commit | 5e9ab52bd68670208ac25cfcf95cca178d285545 (patch) | |
tree | 0e83007452b8195886798889d2c7eeabb229d226 /src/transform.js | |
parent | 0c336f2f4bc931c13779ed6ea3edf62f05f1f18f (diff) | |
download | svg.js-5e9ab52bd68670208ac25cfcf95cca178d285545.tar.gz svg.js-5e9ab52bd68670208ac25cfcf95cca178d285545.zip |
Added more control to SVG.Matrix
Diffstat (limited to 'src/transform.js')
-rw-r--r-- | src/transform.js | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/transform.js b/src/transform.js index d33a411..7c4902b 100644 --- a/src/transform.js +++ b/src/transform.js @@ -11,10 +11,10 @@ SVG.extend(SVG.Element, SVG.FX, { // singular getter else if (typeof o === 'string') return target.ctm().extract()[o] - + // get current matrix var matrix = new SVG.Matrix(target) - + // act on matrix if (o.a != null) matrix = matrix.multiply(new SVG.Matrix(o)) @@ -26,19 +26,31 @@ SVG.extend(SVG.Element, SVG.FX, { , o.cx == null ? target.bbox().cx : o.cx , o.cy == null ? target.bbox().cy : o.cy ) - + // act on scale else if (o.scale != null || o.scaleX != null || o.scaleY != null) matrix = matrix.scale( o.scale != null ? o.scale : o.scaleX != null ? o.scaleX : 1 , o.scale != null ? o.scale : o.scaleY != null ? o.scaleY : 1 - , o.cx != null ? o.cx : target.bbox().x - , o.cy != null ? o.cy : target.bbox().y + , o.cx == null ? target.bbox().x : o.cx + , o.cy == null ? target.bbox().y : o.cy ) // act on skew else if (o.skewX || o.skewY) - matrix = matrix.skew(o.skewX, o.skewY) + matrix = matrix.skew( + o.skewX + , o.skewY + , o.cx == null ? target.bbox().cx : o.cx + , o.cy == null ? target.bbox().cy : o.cy + ) + + // act on flip + else if (o.flip) + matrix = matrix.flip( + o.flip + , o.offset == null ? target.bbox()['c' + o.flip] : o.offset + ) // act on translate else if (o.x || o.y) |