From 274f1a4b55dab7c7686955282d6cbd5ec9fc0461 Mon Sep 17 00:00:00 2001 From: hkrish Date: Sun, 24 Nov 2013 13:32:01 +0100 Subject: [PATCH] Sort sub-paths before 'reorienting' during boolean calculations --- src/path/PathItem.Boolean.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/path/PathItem.Boolean.js b/src/path/PathItem.Boolean.js index de0f8065..a5027718 100644 --- a/src/path/PathItem.Boolean.js +++ b/src/path/PathItem.Boolean.js @@ -76,11 +76,17 @@ PathItem.inject(new function() { */ function reorientPath(path) { if (path instanceof CompoundPath) { - var children = path._children, + var children = path.removeChildren(), length = children.length, bounds = new Array(length), counters = new Array(length), - clockwise = children[0].isClockwise(); + clockwise; + children.sort(function(a, b){ + var b1 = a.getBounds(), b2 = b.getBounds(); + return b1._width * b1._height < b2._width * b2._height; + }); + path.addChildren(children); + clockwise = children[0].isClockwise(); for (var i = 0; i < length; i++) { bounds[i] = children[i].getBounds(); counters[i] = 0;