mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Do not usse LinkedPoint internally for PointText#point, since we're returning new instances each time now in #getPoint().
This commit is contained in:
parent
fe1b2ca8a0
commit
7c95eb7694
1 changed files with 10 additions and 15 deletions
|
@ -37,9 +37,8 @@ var PointText = this.PointText = TextItem.extend(/** @lends PointText# */{
|
||||||
*/
|
*/
|
||||||
initialize: function(point) {
|
initialize: function(point) {
|
||||||
this.base();
|
this.base();
|
||||||
point = Point.read(arguments);
|
this._point = Point.read(arguments).clone();
|
||||||
this._point = LinkedPoint.create(this, 'setPoint', point.x, point.y);
|
this._matrix = new Matrix().translate(this._point);
|
||||||
this._matrix = new Matrix().translate(point);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
clone: function() {
|
clone: function() {
|
||||||
|
@ -56,13 +55,10 @@ var PointText = this.PointText = TextItem.extend(/** @lends PointText# */{
|
||||||
* @bean
|
* @bean
|
||||||
*/
|
*/
|
||||||
getPoint: function() {
|
getPoint: function() {
|
||||||
// this._point is a LinkedPoint, so we can use _x and _y.
|
// Se Item#getPosition for an explanation why we create new LinkedPoint
|
||||||
// Do not cache LinkedPoints directly, since we would not be able to
|
// objects each time.
|
||||||
// use them to calculate the difference in #setPoint, as when it is
|
return LinkedPoint.create(this, 'setPoint',
|
||||||
// modified, it would hold new values already and only then cause the
|
this._point.x, this._point.y);
|
||||||
// calling of #setPoint.
|
|
||||||
return LinkedPoint.create(this, 'setPoint', this._point._x,
|
|
||||||
this._point._y);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setPoint: function(point) {
|
setPoint: function(point) {
|
||||||
|
@ -72,7 +68,8 @@ var PointText = this.PointText = TextItem.extend(/** @lends PointText# */{
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: Position should be the center point of the bounds but we currently
|
// TODO: Position should be the center point of the bounds but we currently
|
||||||
// don't support bounds for PointText.
|
// don't support bounds for PointText, so let's return the same as #point
|
||||||
|
// for the time being.
|
||||||
getPosition: function() {
|
getPosition: function() {
|
||||||
return this.getPoint();
|
return this.getPoint();
|
||||||
},
|
},
|
||||||
|
@ -83,10 +80,8 @@ var PointText = this.PointText = TextItem.extend(/** @lends PointText# */{
|
||||||
|
|
||||||
_transform: function(matrix, flags) {
|
_transform: function(matrix, flags) {
|
||||||
this._matrix.preConcatenate(matrix);
|
this._matrix.preConcatenate(matrix);
|
||||||
// We need to transform the LinkedPoint, passing true for dontNotify so
|
// Also transform _point:
|
||||||
// chaning it won't trigger calls of setPoint(), leading to an endless
|
matrix._transformPoint(this._point, this._point);
|
||||||
// recursion.
|
|
||||||
matrix._transformPoint(this._point, this._point, true);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
draw: function(ctx) {
|
draw: function(ctx) {
|
||||||
|
|
Loading…
Reference in a new issue