From cca6606f7231a88147e74d6bcd6b7f51be9846bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ju=CC=88rg=20Lehni?= Date: Sun, 4 Jan 2015 01:51:27 +0100 Subject: [PATCH] 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. --- src/path/PathItem.Boolean.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/path/PathItem.Boolean.js b/src/path/PathItem.Boolean.js index f04db087..889c309e 100644 --- a/src/path/PathItem.Boolean.js +++ b/src/path/PathItem.Boolean.js @@ -71,12 +71,10 @@ PathItem.inject(new function() { // i.e. subtraction(A:Path, B:Path):CompoundPath etc. var _path1 = preparePath(path1), _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. - if (!_path1.isClockwise()) - _path1.reverse(); - if (_path2 && !(/^(subtract|exclude)$/.test(operation) - ^ _path2.isClockwise())) + if (_path2 && /^(subtract|exclude)$/.test(operation) + ^ (_path2.isClockwise() !== _path1.isClockwise())) _path2.reverse(); // Split curves at intersections on both paths. Note that for self // intersection, _path2 will be null and getIntersections() handles it.