mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Rearrange method sequence in Item.
This commit is contained in:
parent
56f25e8742
commit
b96f9ff57b
1 changed files with 69 additions and 69 deletions
138
src/item/Item.js
138
src/item/Item.js
|
@ -766,75 +766,6 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
// translate the item. Pass true for dontLink, as we do not need a
|
// translate the item. Pass true for dontLink, as we do not need a
|
||||||
// LinkedPoint to simply calculate this distance.
|
// LinkedPoint to simply calculate this distance.
|
||||||
this.translate(Point.read(arguments).subtract(this.getPosition(true)));
|
this.translate(Point.read(arguments).subtract(this.getPosition(true)));
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The item's transformation matrix, defining position and dimensions in
|
|
||||||
* relation to its parent item in which it is contained.
|
|
||||||
*
|
|
||||||
* @type Matrix
|
|
||||||
* @bean
|
|
||||||
*/
|
|
||||||
getMatrix: function() {
|
|
||||||
return this._matrix;
|
|
||||||
},
|
|
||||||
|
|
||||||
setMatrix: function(matrix) {
|
|
||||||
// Use Matrix#initialize to easily copy over values.
|
|
||||||
this._matrix.initialize(matrix);
|
|
||||||
if (this._transformContent)
|
|
||||||
this.applyMatrix(true);
|
|
||||||
this._changed(/*#=*/ Change.GEOMETRY);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The item's global transformation matrix in relation to the global project
|
|
||||||
* coordinate space.
|
|
||||||
*
|
|
||||||
* @type Matrix
|
|
||||||
* @bean
|
|
||||||
*/
|
|
||||||
getGlobalMatrix: function() {
|
|
||||||
// TODO: if drawCount is out of sync, we still need to walk up the chain
|
|
||||||
// and concatenate the matrices.
|
|
||||||
return this._drawCount === this._project._drawCount
|
|
||||||
&& this._globalMatrix || null;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts the specified point from global project coordinates to local
|
|
||||||
* coordinates in relation to the the item's own coordinate space.
|
|
||||||
*
|
|
||||||
* @param {Point} point the point to be transformed
|
|
||||||
* @return {Point} the transformed point as a new instance
|
|
||||||
*/
|
|
||||||
globalToLocal: function(/* point */) {
|
|
||||||
var matrix = this.getGlobalMatrix();
|
|
||||||
return matrix && matrix._transformPoint(Point.read(arguments));
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts the specified point from local coordinates to global coordinates
|
|
||||||
* in relation to the the project coordinate space.
|
|
||||||
*
|
|
||||||
* @param {Point} point the point to be transformed
|
|
||||||
* @return {Point} the transformed point as a new instance
|
|
||||||
*/
|
|
||||||
localToGlobal: function(/* point */) {
|
|
||||||
var matrix = this.getGlobalMatrix();
|
|
||||||
return matrix && matrix._inverseTransform(Point.read(arguments));
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies whether the item has any content or not. The meaning of what
|
|
||||||
* content is differs from type to type. For example, a {@link Group} with
|
|
||||||
* no children, a {@link TextItem} with no text content and a {@link Path}
|
|
||||||
* with no segments all are considered empty.
|
|
||||||
*
|
|
||||||
* @return Boolean
|
|
||||||
*/
|
|
||||||
isEmpty: function() {
|
|
||||||
return !this._children || this._children.length == 0;
|
|
||||||
}
|
}
|
||||||
}, Base.each(['getBounds', 'getStrokeBounds', 'getHandleBounds', 'getRoughBounds'],
|
}, Base.each(['getBounds', 'getStrokeBounds', 'getHandleBounds', 'getRoughBounds'],
|
||||||
function(name) {
|
function(name) {
|
||||||
|
@ -1025,6 +956,39 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
}), /** @lends Item# */{
|
}), /** @lends Item# */{
|
||||||
|
/**
|
||||||
|
* The item's transformation matrix, defining position and dimensions in
|
||||||
|
* relation to its parent item in which it is contained.
|
||||||
|
*
|
||||||
|
* @type Matrix
|
||||||
|
* @bean
|
||||||
|
*/
|
||||||
|
getMatrix: function() {
|
||||||
|
return this._matrix;
|
||||||
|
},
|
||||||
|
|
||||||
|
setMatrix: function(matrix) {
|
||||||
|
// Use Matrix#initialize to easily copy over values.
|
||||||
|
this._matrix.initialize(matrix);
|
||||||
|
if (this._transformContent)
|
||||||
|
this.applyMatrix(true);
|
||||||
|
this._changed(/*#=*/ Change.GEOMETRY);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The item's global transformation matrix in relation to the global project
|
||||||
|
* coordinate space.
|
||||||
|
*
|
||||||
|
* @type Matrix
|
||||||
|
* @bean
|
||||||
|
*/
|
||||||
|
getGlobalMatrix: function() {
|
||||||
|
// TODO: if drawCount is out of sync, we still need to walk up the chain
|
||||||
|
// and concatenate the matrices.
|
||||||
|
return this._drawCount === this._project._drawCount
|
||||||
|
&& this._globalMatrix || null;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@grouptitle Project Hierarchy}
|
* {@grouptitle Project Hierarchy}
|
||||||
* The project that this item belongs to.
|
* The project that this item belongs to.
|
||||||
|
@ -2004,6 +1968,18 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
// locking an item currently has no effect
|
// locking an item currently has no effect
|
||||||
/**
|
/**
|
||||||
* {@grouptitle Tests}
|
* {@grouptitle Tests}
|
||||||
|
* Specifies whether the item has any content or not. The meaning of what
|
||||||
|
* content is differs from type to type. For example, a {@link Group} with
|
||||||
|
* no children, a {@link TextItem} with no text content and a {@link Path}
|
||||||
|
* with no segments all are considered empty.
|
||||||
|
*
|
||||||
|
* @return Boolean
|
||||||
|
*/
|
||||||
|
isEmpty: function() {
|
||||||
|
return !this._children || this._children.length == 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
* Checks whether the item is editable.
|
* Checks whether the item is editable.
|
||||||
*
|
*
|
||||||
* @return {Boolean} {@true when neither the item, nor its parents are
|
* @return {Boolean} {@true when neither the item, nor its parents are
|
||||||
|
@ -2601,6 +2577,30 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
this._changed(/*#=*/ Change.GEOMETRY);
|
this._changed(/*#=*/ Change.GEOMETRY);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the specified point from global project coordinates to local
|
||||||
|
* coordinates in relation to the the item's own coordinate space.
|
||||||
|
*
|
||||||
|
* @param {Point} point the point to be transformed
|
||||||
|
* @return {Point} the transformed point as a new instance
|
||||||
|
*/
|
||||||
|
globalToLocal: function(/* point */) {
|
||||||
|
var matrix = this.getGlobalMatrix();
|
||||||
|
return matrix && matrix._transformPoint(Point.read(arguments));
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the specified point from local coordinates to global coordinates
|
||||||
|
* in relation to the the project coordinate space.
|
||||||
|
*
|
||||||
|
* @param {Point} point the point to be transformed
|
||||||
|
* @return {Point} the transformed point as a new instance
|
||||||
|
*/
|
||||||
|
localToGlobal: function(/* point */) {
|
||||||
|
var matrix = this.getGlobalMatrix();
|
||||||
|
return matrix && matrix._inverseTransform(Point.read(arguments));
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform the item so that its {@link #bounds} fit within the specified
|
* Transform the item so that its {@link #bounds} fit within the specified
|
||||||
* rectangle, without changing its aspect ratio.
|
* rectangle, without changing its aspect ratio.
|
||||||
|
|
Loading…
Reference in a new issue