mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Go back to using Group for divide() results.
As they may contain multiple CompoundPaths.
This commit is contained in:
parent
1103c7036f
commit
bfa0459c52
1 changed files with 11 additions and 9 deletions
|
@ -53,10 +53,10 @@ PathItem.inject(new function() {
|
||||||
.transform(null, true, true);
|
.transform(null, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function finishBoolean(paths, path1, path2, reduce) {
|
function finishBoolean(ctor, paths, path1, path2, reduce) {
|
||||||
var result = new CompoundPath(Item.NO_INSERT);
|
var result = new ctor(Item.NO_INSERT);
|
||||||
result.addChildren(paths, true);
|
result.addChildren(paths, true);
|
||||||
// See if the CompoundPath can be reduced to just a simple Path.
|
// See if the item can be reduced to just a simple Path.
|
||||||
if (reduce)
|
if (reduce)
|
||||||
result = result.reduce();
|
result = result.reduce();
|
||||||
// Insert the resulting path above whichever of the two paths appear
|
// Insert the resulting path above whichever of the two paths appear
|
||||||
|
@ -143,8 +143,8 @@ PathItem.inject(new function() {
|
||||||
operation);
|
operation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return finishBoolean(tracePaths(segments, operation), path1, path2,
|
return finishBoolean(CompoundPath, tracePaths(segments, operation),
|
||||||
true);
|
path1, path2, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function logIntersection(title, inter) {
|
function logIntersection(title, inter) {
|
||||||
|
@ -855,7 +855,8 @@ PathItem.inject(new function() {
|
||||||
*/
|
*/
|
||||||
exclude: function(path) {
|
exclude: function(path) {
|
||||||
return computeBoolean(this, path, 'exclude');
|
return computeBoolean(this, path, 'exclude');
|
||||||
// return finishBoolean([this.subtract(path), path.subtract(this)],
|
// return finishBoolean(CompoundPath,
|
||||||
|
// [this.subtract(path), path.subtract(this)],
|
||||||
// this, path, true);
|
// this, path, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -867,7 +868,8 @@ PathItem.inject(new function() {
|
||||||
* @return {Group} the resulting group item
|
* @return {Group} the resulting group item
|
||||||
*/
|
*/
|
||||||
divide: function(path) {
|
divide: function(path) {
|
||||||
return finishBoolean([this.subtract(path), this.intersect(path)],
|
return finishBoolean(Group,
|
||||||
|
[this.subtract(path), this.intersect(path)],
|
||||||
this, path, true);
|
this, path, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -891,8 +893,8 @@ PathItem.inject(new function() {
|
||||||
for (var i = 0, l = paths.length; i < l; i++) {
|
for (var i = 0, l = paths.length; i < l; i++) {
|
||||||
segments.push.apply(segments, paths[i]._segments);
|
segments.push.apply(segments, paths[i]._segments);
|
||||||
}
|
}
|
||||||
var res = finishBoolean(tracePaths(segments), this, null, false)
|
var res = finishBoolean(CompoundPath, tracePaths(segments),
|
||||||
.reorient();
|
this, null, false).reorient();
|
||||||
window.reportSegments = reportSegments;
|
window.reportSegments = reportSegments;
|
||||||
window.reportWindings = reportWindings;
|
window.reportWindings = reportWindings;
|
||||||
window.reportIntersections = reportIntersections;
|
window.reportIntersections = reportIntersections;
|
||||||
|
|
Loading…
Reference in a new issue