mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 10:48:38 -05:00
Implement Item#parentToLocal() and #localToParent()
As outlined in #530
This commit is contained in:
parent
3389687c42
commit
762113230a
1 changed files with 26 additions and 4 deletions
|
@ -2980,8 +2980,8 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
},
|
||||
|
||||
/**
|
||||
* Converts the specified point from global project coordinates to local
|
||||
* coordinates in relation to the the item's own coordinate space.
|
||||
* Converts the specified point from global project coordinate space to the
|
||||
* item's own local coordinate space.
|
||||
*
|
||||
* @param {Point} point the point to be transformed
|
||||
* @return {Point} the transformed point as a new instance
|
||||
|
@ -2992,8 +2992,8 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
},
|
||||
|
||||
/**
|
||||
* Converts the specified point from local coordinates to global coordinates
|
||||
* in relation to the the project coordinate space.
|
||||
* Converts the specified point from the item's own local coordinate space
|
||||
* to the global project coordinate space.
|
||||
*
|
||||
* @param {Point} point the point to be transformed
|
||||
* @return {Point} the transformed point as a new instance
|
||||
|
@ -3003,6 +3003,28 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
Point.read(arguments));
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts the specified point from the parent's coordinate space to
|
||||
* item's own local coordinate space.
|
||||
*
|
||||
* @param {Point} point the point to be transformed
|
||||
* @return {Point} the transformed point as a new instance
|
||||
*/
|
||||
parentToLocal: function(/* point */) {
|
||||
return this._matrix._inverseTransform(Point.read(arguments));
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts the specified point from the item's own local coordinate space
|
||||
* to the parent's coordinate space.
|
||||
*
|
||||
* @param {Point} point the point to be transformed
|
||||
* @return {Point} the transformed point as a new instance
|
||||
*/
|
||||
localToParent: function(/* point */) {
|
||||
return this._matrix._transformPoint(Point.read(arguments));
|
||||
},
|
||||
|
||||
/**
|
||||
* Transform the item so that its {@link #bounds} fit within the specified
|
||||
* rectangle, without changing its aspect ratio.
|
||||
|
|
Loading…
Reference in a new issue