From 762113230ada2e88a2771cee23620d271e98d70c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 25 Sep 2014 17:53:08 +0200 Subject: [PATCH] Implement Item#parentToLocal() and #localToParent() As outlined in #530 --- src/item/Item.js | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index 8842d39f..a2b7d909 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -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.