mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Fix issues with _angle caching in Point.
This commit is contained in:
parent
0ac19a8e82
commit
4f4261488e
1 changed files with 4 additions and 5 deletions
|
@ -11,17 +11,14 @@ var Point = Base.extend({
|
|||
} else if(first.x !== undefined) {
|
||||
this.x = first.x;
|
||||
this.y = first.y;
|
||||
this._angle = first.angle;
|
||||
} else if(first.width !== undefined) {
|
||||
this.x = first.width;
|
||||
this.y = first.height;
|
||||
this._angle = null;
|
||||
} else if(first.length !== undefined) {
|
||||
this.x = first[0];
|
||||
this.y = first.length > 1 ? first[1] : first[0];
|
||||
} else if(typeof first === 'number') {
|
||||
this.x = this.y = first;
|
||||
this._angle = null;
|
||||
} else {
|
||||
this.x = this.y = 0;
|
||||
}
|
||||
|
@ -166,7 +163,9 @@ var Point = Base.extend({
|
|||
angle = Math.acos(this.dot(point) / div);
|
||||
}
|
||||
} else {
|
||||
angle = this._angle = Math.atan2(this.y, this.x);
|
||||
if (this._angle == null)
|
||||
this._angle = Math.atan2(this.y, this.x);
|
||||
angle = this._angle;
|
||||
}
|
||||
return angle * 180 / Math.PI;
|
||||
},
|
||||
|
@ -298,4 +297,4 @@ var Point = Base.extend({
|
|||
return new Point(Math.random(), Math.random());
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue