mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Simplify and document Segment#_serialize().
This commit is contained in:
parent
6029f59494
commit
69512ac396
1 changed files with 5 additions and 5 deletions
|
@ -115,9 +115,9 @@ var Segment = this.Segment = Base.extend(/** @lends Segment# */{
|
||||||
createPoint = SegmentPoint.create,
|
createPoint = SegmentPoint.create,
|
||||||
point, handleIn, handleOut;
|
point, handleIn, handleOut;
|
||||||
// TODO: Use Point.read or Point.readNamed to read these?
|
// TODO: Use Point.read or Point.readNamed to read these?
|
||||||
if (count == 0) {
|
if (count === 0) {
|
||||||
// Nothing
|
// Nothing
|
||||||
} else if (count == 1) {
|
} else if (count === 1) {
|
||||||
// Note: This copies from existing segments through bean getters
|
// Note: This copies from existing segments through bean getters
|
||||||
if (arg0.point) {
|
if (arg0.point) {
|
||||||
point = arg0.point;
|
point = arg0.point;
|
||||||
|
@ -136,7 +136,7 @@ var Segment = this.Segment = Base.extend(/** @lends Segment# */{
|
||||||
handleIn = arg1;
|
handleIn = arg1;
|
||||||
handleOut = arg2;
|
handleOut = arg2;
|
||||||
}
|
}
|
||||||
} else if (count == 6) {
|
} else if (count === 6) {
|
||||||
point = [ arg0, arg1 ];
|
point = [ arg0, arg1 ];
|
||||||
handleIn = [ arg2, arg3 ];
|
handleIn = [ arg2, arg3 ];
|
||||||
handleOut = [ arg4, arg5 ];
|
handleOut = [ arg4, arg5 ];
|
||||||
|
@ -147,8 +147,8 @@ var Segment = this.Segment = Base.extend(/** @lends Segment# */{
|
||||||
},
|
},
|
||||||
|
|
||||||
_serialize: function(options) {
|
_serialize: function(options) {
|
||||||
return Base.serialize(this._handleIn.isZero() && this._handleOut.isZero()
|
// If the Segment is linear, only serialize point, otherwise handles too
|
||||||
? this._point
|
return Base.serialize(this.isLinear() ? this._point
|
||||||
: [this._point, this._handleIn, this._handleOut], options, true);
|
: [this._point, this._handleIn, this._handleOut], options, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue