Improve arguments reading in Line constructors.

Avoid parameter overriding.
This commit is contained in:
Jürg Lehni 2012-12-27 19:12:30 +01:00
parent 03b5d58e79
commit fdb4bab479

View file

@ -34,15 +34,16 @@ var Line = this.Line = Base.extend(/** @lends Line# */{
// intersection outside the line segment are allowed. // intersection outside the line segment are allowed.
// With two parameters, the 2nd parameter is a direction, and infinite // With two parameters, the 2nd parameter is a direction, and infinite
// is automatially true, since we're describing an infinite line. // is automatially true, since we're describing an infinite line.
point1 = Point.read(arguments); var _point1 = Point.read(arguments),
point2 = Point.read(arguments); _point2 = Point.read(arguments),
if (arguments.length == 3) { _infinite = Base.readValue(arguments);
this.point = point1; if (_infinite !== undefined) {
this.vector = point2.subtract(point1); this.point = _point1;
this.infinite = infinite; this.vector = _point2.subtract(_point1);
this.infinite = _infinite;
} else { } else {
this.point = point1; this.point = _point1;
this.vector = point2; this.vector = _point2;
this.infinite = true; this.infinite = true;
} }
}, },