mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
A couple of improvements on Path#split().
This commit is contained in:
parent
49fed1c46f
commit
49c8f8b6b5
1 changed files with 6 additions and 4 deletions
|
@ -822,21 +822,23 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
|||
curves[index++].divide(parameter);
|
||||
}
|
||||
// Create the new path with the segments to the right of given
|
||||
// parameter
|
||||
// parameter, which are removed from the current path.
|
||||
var segs = this.removeSegments(index, this._segments.length);
|
||||
// If the path is closed, open it and move the segments round,
|
||||
// otherwise create two paths.
|
||||
if (this._closed) {
|
||||
this.setClosed(false);
|
||||
this.insertSegments(0, segs);
|
||||
this.addSegment(segs[0].clone());
|
||||
// Add bginning segment again at the end, since we opened a
|
||||
// closed path.
|
||||
this.addSegment(segs[0]);
|
||||
return this;
|
||||
} else if (index > 0) {
|
||||
// Add dividing segment again
|
||||
this.addSegment(segs[0]);
|
||||
// TODO: Don't clone segments but everything else. How?
|
||||
var path = new Path(segs);
|
||||
path.setStyle(this.getStyle());
|
||||
// Copy over all other attributes, including style
|
||||
this._clone(path);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue