mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Minor code minifier
We can minify some codes which relate matrix.decompose(), because matrix.decompose() must return non-null object
This commit is contained in:
parent
6a3b8fc384
commit
f50a81e089
2 changed files with 12 additions and 19 deletions
|
@ -672,12 +672,11 @@ var Matrix = Base.extend(/** @lends Matrix# */{
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to decompose the affine transformation described by this matrix
|
* Decomposes the affine transformation described by this matrix into
|
||||||
* into `scaling`, `rotation` and `skewing`, and returns an object with
|
* `scaling`, `rotation` and `skewing`, and returns an object with
|
||||||
* these properties if it succeeded, `null` otherwise.
|
* these properties.
|
||||||
*
|
*
|
||||||
* @return {Object} the decomposed matrix, or `null` if decomposition is not
|
* @return {Object} the decomposed matrix
|
||||||
* possible
|
|
||||||
*/
|
*/
|
||||||
decompose: function() {
|
decompose: function() {
|
||||||
// http://dev.w3.org/csswg/css3-2d-transforms/#matrix-decomposition
|
// http://dev.w3.org/csswg/css3-2d-transforms/#matrix-decomposition
|
||||||
|
@ -795,7 +794,7 @@ var Matrix = Base.extend(/** @lends Matrix# */{
|
||||||
* @see #decompose()
|
* @see #decompose()
|
||||||
*/
|
*/
|
||||||
getScaling: function() {
|
getScaling: function() {
|
||||||
return (this.decompose() || {}).scaling;
|
return this.decompose().scaling;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -806,7 +805,7 @@ var Matrix = Base.extend(/** @lends Matrix# */{
|
||||||
* @see #decompose()
|
* @see #decompose()
|
||||||
*/
|
*/
|
||||||
getRotation: function() {
|
getRotation: function() {
|
||||||
return (this.decompose() || {}).rotation;
|
return this.decompose().rotation;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -525,11 +525,9 @@ var View = Base.extend(Emitter, /** @lends View# */{
|
||||||
* @see #getScaling()
|
* @see #getScaling()
|
||||||
*/
|
*/
|
||||||
getZoom: function() {
|
getZoom: function() {
|
||||||
var decomposed = this._decompose(),
|
var scaling = this._decompose().scaling;
|
||||||
scaling = decomposed && decomposed.scaling;
|
// Use average since it can be non-uniform.
|
||||||
// Use average since it can be non-uniform, and return 0 when it can't
|
return (scaling.x + scaling.y) / 2;
|
||||||
// be decomposed.
|
|
||||||
return scaling ? (scaling.x + scaling.y) / 2 : 0;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setZoom: function(zoom) {
|
setZoom: function(zoom) {
|
||||||
|
@ -545,8 +543,7 @@ var View = Base.extend(Emitter, /** @lends View# */{
|
||||||
* @type Number
|
* @type Number
|
||||||
*/
|
*/
|
||||||
getRotation: function() {
|
getRotation: function() {
|
||||||
var decomposed = this._decompose();
|
return this._decompose().rotation;
|
||||||
return decomposed && decomposed.rotation;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setRotation: function(rotation) {
|
setRotation: function(rotation) {
|
||||||
|
@ -565,11 +562,8 @@ var View = Base.extend(Emitter, /** @lends View# */{
|
||||||
* @see #getZoom()
|
* @see #getZoom()
|
||||||
*/
|
*/
|
||||||
getScaling: function() {
|
getScaling: function() {
|
||||||
var decomposed = this._decompose(),
|
var scaling = this._decompose().scaling;
|
||||||
scaling = decomposed && decomposed.scaling;
|
return new LinkedPoint(scaling.x, scaling.y, this, 'setScaling');
|
||||||
return scaling
|
|
||||||
? new LinkedPoint(scaling.x, scaling.y, this, 'setScaling')
|
|
||||||
: undefined;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setScaling: function(/* scaling */) {
|
setScaling: function(/* scaling */) {
|
||||||
|
|
Loading…
Reference in a new issue