diff options
author | wout <wout@impinc.co.uk> | 2014-07-12 14:18:52 +0200 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-07-12 14:18:52 +0200 |
commit | 0f74fe7d0a2fb1c02c5beebf5f0f8360020f1fc1 (patch) | |
tree | 82bdcd06a6d581414ebf7e5ec472c587bdc77bd7 /src | |
parent | 501cb5387007a89af382717376c773a1ec6b68ae (diff) | |
download | svg.js-0f74fe7d0a2fb1c02c5beebf5f0f8360020f1fc1.tar.gz svg.js-0f74fe7d0a2fb1c02c5beebf5f0f8360020f1fc1.zip |
Eliminate matrix translation errors
Diffstat (limited to 'src')
-rwxr-xr-x | src/group.js | 4 | ||||
-rw-r--r-- | src/helpers.js | 6 | ||||
-rw-r--r-- | src/matrix.js | 6 |
3 files changed, 8 insertions, 8 deletions
diff --git a/src/group.js b/src/group.js index a7ec2e0..1808b3f 100755 --- a/src/group.js +++ b/src/group.js @@ -9,11 +9,11 @@ SVG.G = SVG.invent({ , extend: { // Move over x-axis x: function(x) { - return x == null ? this.ctm().x : this.transform('x', x) + return x == null ? this.transform('x') : this.transform({ x: x }) } // Move over y-axis , y: function(y) { - return y == null ? this.ctm().y : this.transform('y', y) + return y == null ? this.transform('y') : this.transform({ y: y }) } // Move by center over x-axis , cx: function(x) { diff --git a/src/helpers.js b/src/helpers.js index b22a559..ae4eb04 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -42,10 +42,10 @@ function proportionalSize(box, width, height) { } // Delta transform point -function deltaTransformPoint(matrix, point) { +function deltaTransformPoint(matrix, x, y) { return { - x: point.x * matrix.a + point.y * matrix.c + 0 - , y: point.x * matrix.b + point.y * matrix.d + 0 + x: x * matrix.a + y * matrix.c + 0 + , y: x * matrix.b + y * matrix.d + 0 } } diff --git a/src/matrix.js b/src/matrix.js index b6c839d..314e1e0 100644 --- a/src/matrix.js +++ b/src/matrix.js @@ -4,7 +4,7 @@ SVG.Matrix = SVG.invent({ var i, base = arrayToMatrix([1, 0, 0, 1, 0, 0]) // Ensure source as object - source = source.node && source.node.getCTM ? + source = source && source.node && source.node.getCTM ? source.node.getCTM() : typeof source === 'string' ? arrayToMatrix(source.replace(/\s/g, '').split(',')) : @@ -25,8 +25,8 @@ SVG.Matrix = SVG.invent({ // Extract individual transformations extract: function() { // Find transform points - var px = deltaTransformPoint(this, { x: 0, y: 1 }) - , py = deltaTransformPoint(this, { x: 1, y: 0 }) + var px = deltaTransformPoint(this, 0, 1) + , py = deltaTransformPoint(this, 1, 0) , skewX = 180 / Math.PI * Math.atan2(px.y, px.x) - 90 return { |