aboutsummaryrefslogtreecommitdiffstats
path: root/src/matrix.js
diff options
context:
space:
mode:
authorRémi Tétreault <tetreault.remi@gmail.com>2016-11-02 18:25:35 -0400
committerRémi Tétreault <tetreault.remi@gmail.com>2016-11-02 18:25:35 -0400
commit7164e5617d7413b4c7806466457d7f08c1fd3220 (patch)
treed143c0b5f95646f05fe28db818a46f497385e122 /src/matrix.js
parente3eddcb2aa4feb1f847aad5f900fb9a0ecb62ee1 (diff)
downloadsvg.js-7164e5617d7413b4c7806466457d7f08c1fd3220.tar.gz
svg.js-7164e5617d7413b4c7806466457d7f08c1fd3220.zip
Fix the implementation of the skew transform
Also fix a bug where when calling scale with 3 parameters, cx was not set with the right value.
Diffstat (limited to 'src/matrix.js')
-rw-r--r--src/matrix.js26
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) {