diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2016-11-03 02:04:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-03 02:04:15 +0100 |
commit | 083f9e16bdced2c10325c46f7f51e85b6e5f0158 (patch) | |
tree | d143c0b5f95646f05fe28db818a46f497385e122 /src | |
parent | e3eddcb2aa4feb1f847aad5f900fb9a0ecb62ee1 (diff) | |
parent | 7164e5617d7413b4c7806466457d7f08c1fd3220 (diff) | |
download | svg.js-083f9e16bdced2c10325c46f7f51e85b6e5f0158.tar.gz svg.js-083f9e16bdced2c10325c46f7f51e85b6e5f0158.zip |
Merge pull request #545 from RmiTtro/fix-skew-transform
Fix the implementation of the skew transform
Diffstat (limited to 'src')
-rw-r--r-- | src/matrix.js | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/matrix.js b/src/matrix.js index 37bd860..bcf39e4 100644 --- a/src/matrix.js +++ b/src/matrix.js @@ -113,12 +113,13 @@ SVG.Matrix = SVG.invent({ } // Scale matrix , scale: function(x, y, cx, cy) { - // support universal scale - if (arguments.length == 1 || arguments.length == 3) + // support uniformal scale + if (arguments.length == 1) { y = x - if (arguments.length == 3) { + } else if (arguments.length == 3) { cy = cx cx = y + y = x } return this.around(cx, cy, new SVG.Matrix(x, 0, 0, y, 0, 0)) @@ -136,15 +137,28 @@ SVG.Matrix = SVG.invent({ } // Skew , skew: function(x, y, cx, cy) { - return this.around(cx, cy, this.native().skewX(x || 0).skewY(y || 0)) + // support uniformal skew + if (arguments.length == 1) { + y = x + } else if (arguments.length == 3) { + cy = cx + cx = y + y = x + } + + // convert degrees to radians + x = SVG.utils.radians(x) + y = SVG.utils.radians(y) + + return this.around(cx, cy, new SVG.Matrix(1, Math.tan(y), Math.tan(x), 1, 0, 0)) } // SkewX , skewX: function(x, cx, cy) { - return this.around(cx, cy, this.native().skewX(x || 0)) + return this.skew(x, 0, cx, cy) } // SkewY , skewY: function(y, cx, cy) { - return this.around(cx, cy, this.native().skewY(y || 0)) + return this.skew(0, y, cx, cy) } // Transform around a center point , around: function(cx, cy, matrix) { |