mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-07 19:49:09 -04:00
Define CompoundPath#reverse() and #clockwise, and replace reversePath() with it.
This commit is contained in:
parent
bd3031cdff
commit
25e5582a35
3 changed files with 33 additions and 22 deletions
src/path
|
@ -108,21 +108,6 @@ PathItem.inject(new function() {
|
|||
return baseWinding;
|
||||
}
|
||||
|
||||
function reversePath(path) {
|
||||
var baseWinding;
|
||||
if (path instanceof CompoundPath) {
|
||||
var children = path.children, i, len;
|
||||
for (i = 0, len = children.length; i < len; i++) {
|
||||
children[i].reverse();
|
||||
}
|
||||
baseWinding = children[0].clockwise;
|
||||
} else {
|
||||
path.reverse();
|
||||
baseWinding = path.clockwise;
|
||||
}
|
||||
return baseWinding;
|
||||
}
|
||||
|
||||
function computeBoolean(path1, path2, operator, subtract, _cache) {
|
||||
var _path1, _path2, path1Clockwise, path2Clockwise;
|
||||
var ixs, path1Id, path2Id;
|
||||
|
@ -147,8 +132,10 @@ PathItem.inject(new function() {
|
|||
path1Id = _path1.id;
|
||||
path2Id = _path2.id;
|
||||
// Do operator specific calculations before we begin
|
||||
if (subtract)
|
||||
path2Clockwise = reversePath(_path2);
|
||||
if (subtract) {
|
||||
_path2.reverse();
|
||||
path2Clockwise = !path2Clockwise;
|
||||
}
|
||||
|
||||
var i, j, len, path, crv;
|
||||
var paths = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue