mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
parent
ca3993fe8e
commit
cbefaf0dd1
1 changed files with 11 additions and 3 deletions
|
@ -541,6 +541,10 @@ var Point = Base.extend(/** @lends Point# */{
|
||||||
},
|
},
|
||||||
|
|
||||||
setAngle: function(angle) {
|
setAngle: function(angle) {
|
||||||
|
// We store a reference to _angle internally so we still preserve it
|
||||||
|
// when the vector's length is set to zero, and then anything else.
|
||||||
|
// Note that we cannot rely on it if x and y are something else than 0,
|
||||||
|
// since updating x / y does not automatically change _angle!
|
||||||
angle = this._angle = angle * Math.PI / 180;
|
angle = this._angle = angle * Math.PI / 180;
|
||||||
if (!this.isZero()) {
|
if (!this.isZero()) {
|
||||||
var length = this.getLength();
|
var length = this.getLength();
|
||||||
|
@ -573,9 +577,13 @@ var Point = Base.extend(/** @lends Point# */{
|
||||||
getAngleInRadians: function(/* point */) {
|
getAngleInRadians: function(/* point */) {
|
||||||
// Hide parameters from Bootstrap so it injects bean too
|
// Hide parameters from Bootstrap so it injects bean too
|
||||||
if (arguments[0] === undefined) {
|
if (arguments[0] === undefined) {
|
||||||
if (this._angle == null)
|
return this.isZero()
|
||||||
this._angle = Math.atan2(this.y, this.x);
|
// Return the preseved angle in case the vector has no
|
||||||
return this._angle;
|
// length, and update the internal _angle in case the
|
||||||
|
// vector has a length. See #setAngle() for more
|
||||||
|
// explanations.
|
||||||
|
? this._angle || 0
|
||||||
|
: this._angle = Math.atan2(this.y, this.x);
|
||||||
} else {
|
} else {
|
||||||
var point = Point.read(arguments),
|
var point = Point.read(arguments),
|
||||||
div = this.getLength() * point.getLength();
|
div = this.getLength() * point.getLength();
|
||||||
|
|
Loading…
Reference in a new issue