From f3832e0780fa028b37b4bfe0b2d521eef481b64b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 26 Nov 2013 19:28:18 +0100 Subject: [PATCH] Implement setters for Matrix#translation, #rotation and #scaling. Propagating the changes down to the owning Item too. --- src/basic/Matrix.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/basic/Matrix.js b/src/basic/Matrix.js index 960c5d35..638cf71e 100644 --- a/src/basic/Matrix.js +++ b/src/basic/Matrix.js @@ -605,6 +605,13 @@ var Matrix = Base.extend(/** @lends Matrix# */{ return new Point(this._tx, this._ty); }, + setTranslation: function(/* point */) { + var point = Point.read(arguments); + this._tx = point.x; + this._ty = point.y; + this._changed(); + }, + /** * The scaling values of the matrix, if it can be decomposed. * @@ -616,6 +623,15 @@ var Matrix = Base.extend(/** @lends Matrix# */{ return (this.decompose() || {}).scaling; }, + setScaling: function(/* scale */) { + var scaling = this.getScaling(); + if (scaling != null) { + var scale = Point.read(arguments); + (this._owner || this).scale( + scale.x / scaling.x, scale.y / scaling.y); + } + }, + /** * The rotation angle of the matrix, if it can be decomposed. * @@ -627,6 +643,12 @@ var Matrix = Base.extend(/** @lends Matrix# */{ return (this.decompose() || {}).rotation; }, + setRotation: function(angle) { + var rotation = this.getRotation(); + if (rotation != null) + (this._owner || this).rotate(angle - rotation); + }, + /** * Inverts the transformation of the matrix. If the matrix is not invertible * (in which case {@link #isSingular()} returns true), {@code null } is