mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -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)
|
* @see Path#splitAt(offset)
|
||||||
*/
|
*/
|
||||||
splitAt: function(location) {
|
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
|
* @return {Path} the newly created path after splitting, if any
|
||||||
* @see Path#splitAt(offset)
|
* @see Path#splitAt(offset)
|
||||||
*/
|
*/
|
||||||
splitAtTime: function(t) {
|
splitAtTime: function(time) {
|
||||||
return this.splitAt(this.getLocationAtTime(t));
|
return this.splitAt(this.getLocationAtTime(time));
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: Remove in 1.0.0? (deprecated January 2016):
|
// TODO: Remove in 1.0.0? (deprecated January 2016):
|
||||||
|
|
|
@ -289,17 +289,23 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{
|
||||||
|
|
||||||
divide: function() {
|
divide: function() {
|
||||||
var curve = this.getCurve(),
|
var curve = this.getCurve(),
|
||||||
res = null;
|
res = curve && curve.divideAtTime(this.getTime());
|
||||||
// Change to the newly inserted segment, also adjusts _time.
|
// Change to the newly inserted segment, also adjusts _time.
|
||||||
if (curve && (res = curve.divideAtTime(this.getTime()))) {
|
if (res) {
|
||||||
this._setSegment(res._segment1);
|
this._setSegment(res._segment1);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
|
|
||||||
split: function() {
|
split: function() {
|
||||||
var curve = this.getCurve();
|
var curve = this.getCurve(),
|
||||||
return curve ? curve.splitAtTime(this.getTime()) : null;
|
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