Improve argument reading in Segment.

This commit is contained in:
Jürg Lehni 2013-10-16 13:15:08 +02:00
parent ac5c45906f
commit 8fdcbce5ac

View file

@ -125,20 +125,18 @@ var Segment = Base.extend(/** @lends Segment# */{
} else { } else {
point = arg0; point = arg0;
} }
} else if (count < 6) { } else if (count === 2 && typeof arg0 === 'number') {
if (count == 2 && arg1.x === undefined) {
point = [ arg0, arg1 ]; point = [ arg0, arg1 ];
} else { } else if (count <= 3) {
point = arg0; point = arg0;
// Doesn't matter if these arguments exist, SegmentPointcreate // Doesn't matter if these arguments exist, SegmentPointcreate
// produces creates points with (0, 0) otherwise // produces creates points with (0, 0) otherwise
handleIn = arg1; handleIn = arg1;
handleOut = arg2; handleOut = arg2;
} } else {
} else if (count === 6) { point = arg0 !== undefined ? [ arg0, arg1 ] : null;
point = [ arg0, arg1 ]; handleIn = arg2 !== undefined ? [ arg2, arg3 ] : null;
handleIn = [ arg2, arg3 ]; handleOut = arg4 !== undefined ? [ arg4, arg5 ] : null;
handleOut = [ arg4, arg5 ];
} }
this._point = new SegmentPoint(point, this); this._point = new SegmentPoint(point, this);
this._handleIn = new SegmentPoint(handleIn, this); this._handleIn = new SegmentPoint(handleIn, this);