mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Improve argument reading in Segment.
This commit is contained in:
parent
ac5c45906f
commit
8fdcbce5ac
1 changed files with 11 additions and 13 deletions
|
@ -125,20 +125,18 @@ var Segment = Base.extend(/** @lends Segment# */{
|
|||
} else {
|
||||
point = arg0;
|
||||
}
|
||||
} else if (count < 6) {
|
||||
if (count == 2 && arg1.x === undefined) {
|
||||
point = [ arg0, arg1 ];
|
||||
} else {
|
||||
point = arg0;
|
||||
// Doesn't matter if these arguments exist, SegmentPointcreate
|
||||
// produces creates points with (0, 0) otherwise
|
||||
handleIn = arg1;
|
||||
handleOut = arg2;
|
||||
}
|
||||
} else if (count === 6) {
|
||||
} else if (count === 2 && typeof arg0 === 'number') {
|
||||
point = [ arg0, arg1 ];
|
||||
handleIn = [ arg2, arg3 ];
|
||||
handleOut = [ arg4, arg5 ];
|
||||
} else if (count <= 3) {
|
||||
point = arg0;
|
||||
// Doesn't matter if these arguments exist, SegmentPointcreate
|
||||
// produces creates points with (0, 0) otherwise
|
||||
handleIn = arg1;
|
||||
handleOut = arg2;
|
||||
} else {
|
||||
point = arg0 !== undefined ? [ arg0, arg1 ] : null;
|
||||
handleIn = arg2 !== undefined ? [ arg2, arg3 ] : null;
|
||||
handleOut = arg4 !== undefined ? [ arg4, arg5 ] : null;
|
||||
}
|
||||
this._point = new SegmentPoint(point, this);
|
||||
this._handleIn = new SegmentPoint(handleIn, this);
|
||||
|
|
Loading…
Reference in a new issue