mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-07-27 22:29:11 -04:00
Expose rotation and scaling transformations through Item#rotation and Item#scaling properties, by moving the setters from Matrix to Item.
This commit is contained in:
parent
3ea5c2d728
commit
9ca92165ee
2 changed files with 37 additions and 28 deletions
src/basic
|
@ -522,9 +522,8 @@ var Matrix = Base.extend(/** @lends Matrix# */{
|
|||
|
||||
/**
|
||||
* Attempts to decompose the affine transformation described by this matrix
|
||||
* into {@code translation}, {@code scaling}, {@code rotation} and
|
||||
* {@code shearing}, and returns an object with these properties if it
|
||||
* succeeded, {@code null} otherwise.
|
||||
* into {@code scaling}, {@code rotation} and {@code shearing}, and returns
|
||||
* an object with these properties if it succeeded, {@code null} otherwise.
|
||||
*
|
||||
* @return {Object} the decomposed matrix, or {@code null} if decomposition
|
||||
* is not possible.
|
||||
|
@ -562,7 +561,6 @@ var Matrix = Base.extend(/** @lends Matrix# */{
|
|||
}
|
||||
|
||||
return {
|
||||
translation: this.getTranslation(),
|
||||
scaling: new Point(scaleX, scaleY),
|
||||
rotation: -Math.atan2(b, a) * 180 / Math.PI,
|
||||
shearing: shear
|
||||
|
@ -635,17 +633,10 @@ var Matrix = Base.extend(/** @lends Matrix# */{
|
|||
* @bean
|
||||
*/
|
||||
getTranslation: function() {
|
||||
// No decomposition is required to extract translation, so treat this
|
||||
// No decomposition is required to extract translation.
|
||||
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.
|
||||
*
|
||||
|
@ -657,15 +648,6 @@ 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.
|
||||
*
|
||||
|
@ -677,12 +659,6 @@ 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue