mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Fix issue with reading selected segment points from JSON when there are no handles.
The segment short form was misunderstood by the constructor.
This commit is contained in:
parent
f7c21144a1
commit
782f5c8f7e
2 changed files with 7 additions and 4 deletions
|
@ -25,6 +25,7 @@
|
|||
to: [100, 225],
|
||||
fillColor: 'green'
|
||||
});
|
||||
rectangle.lastSegment.point.selected = true;
|
||||
|
||||
var group = new Group(circle, rectangle);
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ var Segment = Base.extend(/** @lends Segment# */{
|
|||
if (count === 0) {
|
||||
// Nothing
|
||||
} else if (count === 1) {
|
||||
// Note: This copies from existing segments through bean getters
|
||||
// Note: This copies from existing segments through accessors.
|
||||
if (arg0.point) {
|
||||
point = arg0.point;
|
||||
handleIn = arg0.handleIn;
|
||||
|
@ -125,15 +125,17 @@ var Segment = Base.extend(/** @lends Segment# */{
|
|||
} else {
|
||||
point = arg0;
|
||||
}
|
||||
} else if (count === 2 && typeof arg0 === 'number') {
|
||||
point = [ arg0, arg1 ];
|
||||
} else if ((count === 2 || count === 3) && typeof arg0 === 'number') {
|
||||
// We check for 3 and 2 because there is an optional boolean
|
||||
// argument for segment points to mark them as selected.
|
||||
point = arguments;
|
||||
} 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 {
|
||||
} else { // Read points from the arguments list as a row of numbers
|
||||
point = arg0 !== undefined ? [ arg0, arg1 ] : null;
|
||||
handleIn = arg2 !== undefined ? [ arg2, arg3 ] : null;
|
||||
handleOut = arg4 !== undefined ? [ arg4, arg5 ] : null;
|
||||
|
|
Loading…
Reference in a new issue