mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 23:39:59 -05:00
Improve Point#normalize().
This commit is contained in:
parent
2cdb15f2d6
commit
77c19601ff
1 changed files with 6 additions and 6 deletions
|
@ -166,14 +166,14 @@ var Point = this.Point = Base.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
normalize: function(length) {
|
normalize: function(length) {
|
||||||
if (length === null)
|
if (length === undefined)
|
||||||
length = 1;
|
length = 1;
|
||||||
var len = this.getLength();
|
var current = this.getLength(),
|
||||||
var scale = len != 0 ? length / len : 0;
|
scale = current != 0 ? length / current : 0,
|
||||||
var res = Point.create(this.x * scale, this.y * scale);
|
point = Point.create(this.x * scale, this.y * scale);
|
||||||
// Preserve angle.
|
// Preserve angle.
|
||||||
res._angle = this._angle;
|
point._angle = this._angle;
|
||||||
return res;
|
return point;
|
||||||
},
|
},
|
||||||
|
|
||||||
getQuadrant: function() {
|
getQuadrant: function() {
|
||||||
|
|
Loading…
Reference in a new issue