mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Reduce the amount of path reversing required.
We don't need paths at clockwise / counter-clockwise orientation. We simply need them oriented the same way, or the opposite way.
This commit is contained in:
parent
390ef324f2
commit
cca6606f72
1 changed files with 3 additions and 5 deletions
|
@ -71,12 +71,10 @@ PathItem.inject(new function() {
|
||||||
// i.e. subtraction(A:Path, B:Path):CompoundPath etc.
|
// i.e. subtraction(A:Path, B:Path):CompoundPath etc.
|
||||||
var _path1 = preparePath(path1),
|
var _path1 = preparePath(path1),
|
||||||
_path2 = path2 && path1 !== path2 && preparePath(path2);
|
_path2 = path2 && path1 !== path2 && preparePath(path2);
|
||||||
// Give both paths clockwise orientation except for subtraction
|
// Give both paths the same orientation except for subtraction
|
||||||
// and exclusion, where we need them at opposite orientation.
|
// and exclusion, where we need them at opposite orientation.
|
||||||
if (!_path1.isClockwise())
|
if (_path2 && /^(subtract|exclude)$/.test(operation)
|
||||||
_path1.reverse();
|
^ (_path2.isClockwise() !== _path1.isClockwise()))
|
||||||
if (_path2 && !(/^(subtract|exclude)$/.test(operation)
|
|
||||||
^ _path2.isClockwise()))
|
|
||||||
_path2.reverse();
|
_path2.reverse();
|
||||||
// Split curves at intersections on both paths. Note that for self
|
// Split curves at intersections on both paths. Note that for self
|
||||||
// intersection, _path2 will be null and getIntersections() handles it.
|
// intersection, _path2 will be null and getIntersections() handles it.
|
||||||
|
|
Loading…
Reference in a new issue