diff --git a/src/basic/Matrix.js b/src/basic/Matrix.js index f65802e1..17a3a9d0 100644 --- a/src/basic/Matrix.js +++ b/src/basic/Matrix.js @@ -95,10 +95,15 @@ var Matrix = Base.extend({ * @return {Matrix} This affine transform. */ scale: function(sx, sy /* | scale */, center) { - // TODO: Make single scale parameter work with center points! - // Check arguments.length and typeof arguments[1], if object, assume - // scale - center = Point.read(arguments, 2); + if (arguments.length < 2 || typeof sy == 'object') { + // sx is the single scale parameter, representing both sx and sy + // Read center first from argument 1, then set sy = sx (thus + // modifing the content of argument 1!) + center = Point.read(arguments, 1); + sy = sx; + } else { + center = Point.read(arguments, 2); + } if (center) this.translate(center); this._m00 *= sx; @@ -150,7 +155,13 @@ var Matrix = Base.extend({ * @return {Matrix} This affine transform. */ shear: function(shx, shy, center) { - center = Point.read(arguments, 2); + // See #scale() for explanation of this: + if (arguments.length < 2 || typeof shy == 'object') { + center = Point.read(arguments, 1); + sy = sx; + } else { + center = Point.read(arguments, 2); + } if (center) this.translate(center); var m00 = this._m00; diff --git a/src/item/Item.js b/src/item/Item.js index aca04392..ca076cba 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -507,8 +507,11 @@ Item = Base.extend({ * @see Matrix#scale(double, double, Point center) */ scale: function(sx, sy /* | scale */, center) { - // TODO: Make single scale parameter work, and still pass center - // or position + // See Matrix#scale for explanation of this: + if (arguments.length < 2 || typeof sy == 'object') { + center = sy; + sy = sx; + } this.transform(new Matrix().scale(sx, sy, center || this.position)); }, @@ -535,6 +538,11 @@ Item = Base.extend({ */ shear: function(shx, shy, center) { // TODO: Add support for center back to Scriptographer too! + // See Matrix#scale for explanation of this: + if (arguments.length < 2 || typeof sy == 'object') { + center = shy; + shy = shx; + } this.transform(new Matrix().shear(shx, shy, center || this.position)); } }); diff --git a/test/tests/Path_Bounds.js b/test/tests/Path_Bounds.js index 226c274e..43db98c2 100644 --- a/test/tests/Path_Bounds.js +++ b/test/tests/Path_Bounds.js @@ -18,7 +18,7 @@ test('path.bounds', function() { comparePoints(path.position, { x: 192.66016, y: 349.13184 }); // Scale the path by 0.5 and check bounds - path.scale(0.5, 0.5); + path.scale(0.5); compareRectangles(path.bounds, { x: 153.7437, y: 312.09976, width: 77.8329, height: 74.06381 }); // Move the path to another position and check bounds