A couple of improvements on Path#split().

This commit is contained in:
Jürg Lehni 2012-12-31 22:35:01 +01:00
parent 49fed1c46f
commit 49c8f8b6b5

View file

@ -822,21 +822,23 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
curves[index++].divide(parameter); curves[index++].divide(parameter);
} }
// Create the new path with the segments to the right of given // 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); var segs = this.removeSegments(index, this._segments.length);
// If the path is closed, open it and move the segments round, // If the path is closed, open it and move the segments round,
// otherwise create two paths. // otherwise create two paths.
if (this._closed) { if (this._closed) {
this.setClosed(false); this.setClosed(false);
this.insertSegments(0, segs); 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; return this;
} else if (index > 0) { } else if (index > 0) {
// Add dividing segment again // Add dividing segment again
this.addSegment(segs[0]); this.addSegment(segs[0]);
// TODO: Don't clone segments but everything else. How?
var path = new Path(segs); var path = new Path(segs);
path.setStyle(this.getStyle()); // Copy over all other attributes, including style
this._clone(path);
return path; return path;
} }
} }