mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Improve handling of new segments in CurveLocation#divide() and #split()
This commit is contained in:
parent
f16b91e0fe
commit
f089c3c620
2 changed files with 14 additions and 7 deletions
|
@ -525,7 +525,8 @@ var Curve = Base.extend(/** @lends Curve# */{
|
|||
* @see Path#splitAt(offset)
|
||||
*/
|
||||
splitAt: function(location) {
|
||||
return this._path ? this._path.splitAt(location) : null;
|
||||
var path = this._path;
|
||||
return path ? path.splitAt(location) : null;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -538,8 +539,8 @@ var Curve = Base.extend(/** @lends Curve# */{
|
|||
* @return {Path} the newly created path after splitting, if any
|
||||
* @see Path#splitAt(offset)
|
||||
*/
|
||||
splitAtTime: function(t) {
|
||||
return this.splitAt(this.getLocationAtTime(t));
|
||||
splitAtTime: function(time) {
|
||||
return this.splitAt(this.getLocationAtTime(time));
|
||||
},
|
||||
|
||||
// TODO: Remove in 1.0.0? (deprecated January 2016):
|
||||
|
|
|
@ -289,17 +289,23 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{
|
|||
|
||||
divide: function() {
|
||||
var curve = this.getCurve(),
|
||||
res = null;
|
||||
res = curve && curve.divideAtTime(this.getTime());
|
||||
// Change to the newly inserted segment, also adjusts _time.
|
||||
if (curve && (res = curve.divideAtTime(this.getTime()))) {
|
||||
if (res) {
|
||||
this._setSegment(res._segment1);
|
||||
}
|
||||
return res;
|
||||
},
|
||||
|
||||
split: function() {
|
||||
var curve = this.getCurve();
|
||||
return curve ? curve.splitAtTime(this.getTime()) : null;
|
||||
var curve = this.getCurve(),
|
||||
path = curve._path,
|
||||
res = curve && curve.splitAtTime(this.getTime());
|
||||
if (res) {
|
||||
// Set the segment to the end-segment of the path after splitting.
|
||||
this._setSegment(path.getLastSegment());
|
||||
}
|
||||
return res;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue