diff options
author | Saivan <savian@me.com> | 2018-03-04 01:56:12 +1100 |
---|---|---|
committer | Saivan <savian@me.com> | 2018-03-04 01:56:12 +1100 |
commit | 86dee4db2f6a4b2f3123c6f5b062758eb3fecd2e (patch) | |
tree | 4411fe672bf8de3b5c03e3c49bf46a1c7cdc73c3 /src/sugar.js | |
parent | e065a4415b7d6991ac14de81646f109e43bef9e7 (diff) | |
download | svg.js-86dee4db2f6a4b2f3123c6f5b062758eb3fecd2e.tar.gz svg.js-86dee4db2f6a4b2f3123c6f5b062758eb3fecd2e.zip |
Fixed most of the tests relating to transformations
Diffstat (limited to 'src/sugar.js')
-rw-r--r-- | src/sugar.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/sugar.js b/src/sugar.js index b1c6f38..add423c 100644 --- a/src/sugar.js +++ b/src/sugar.js @@ -34,6 +34,12 @@ var sugar = { }) SVG.extend([SVG.Element, SVG.FX], { + // Let the user set the matrix directly + matrix: function (mat, b, c, d, e, f) { + var matrix = new SVG.Matrix(arguments.length > 1 ? [mat, b, c, d, e, f] : mat) + return this.attr('transform', matrix) + }, + // Map rotation to transform rotate: function (angle, cx, cy) { return this.transform({rotate: angle, origin: [cx, cy]}, true) @@ -69,11 +75,15 @@ SVG.extend([SVG.Element, SVG.FX], { // Map flip to transform flip: function (direction, around) { + var directionString = typeof direction == 'string' ? direction + : isFinite(direction) ? 'both' + : 'both' var origin = (direction === 'both' && isFinite(around)) ? [around, around] : (direction === 'x') ? [around, 0] : (direction === 'y') ? [0, around] + : isFinite(direction) ? [direction, direction] : [0, 0] - this.transform({flip: direction || 'both', origin: origin}, true) + this.transform({flip: directionString, origin: origin}, true) }, // Opacity |