Implement setters for Matrix#translation, #rotation and #scaling.

Propagating the changes down to the owning Item too.
This commit is contained in:
Jürg Lehni 2013-11-26 19:28:18 +01:00
parent b96f9ff57b
commit f3832e0780

View file

@ -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