Boolean: Implement optimization for operands without crossings.

Closes 
This commit is contained in:
Jürg Lehni 2016-07-20 16:15:10 +02:00
parent 88db4473a4
commit f988445dad
3 changed files with 208 additions and 100 deletions

View file

@ -101,7 +101,10 @@ PathItem.inject(new function() {
CurveLocation.expand(_path1.getCrossings(_path2))),
segments = [],
// Aggregate of all curves in both operands.
curves = [];
curves = [],
paths1 = _path1._children || [_path1],
paths2 = _path2 && (_path2._children || [_path2]),
paths;
function collect(paths) {
for (var i = 0, l = paths.length; i < l; i++) {
@ -114,39 +117,74 @@ PathItem.inject(new function() {
}
}
// Collect all segments and monotonic curves
collect(_path1._children || [_path1]);
if (_path2)
collect(_path2._children || [_path2]);
// Propagate the winding contribution. Winding contribution of curves
// does not change between two crossings.
// First, propagate winding contributions for curve chains starting in
// all crossings:
for (var i = 0, l = crossings.length; i < l; i++) {
propagateWinding(crossings[i]._segment, _path1, _path2, curves,
operator);
function contains(paths1, paths2) {
return false;
}
// Now process the segments that are not part of any intersecting chains
for (var i = 0, l = segments.length; i < l; i++) {
var segment = segments[i],
inter = segment._intersection;
if (segment._winding == null) {
propagateWinding(segment, _path1, _path2, curves, operator);
// When there are no crossings, and the two paths are not contained
// within each other, the result can be known ahead of tracePaths(),
// largely simplifying the processing required:
if (!crossings.length) {
// If we have two operands, check their bounds to find cases where
// one path is fully contained in another. These cases cannot be
// simplified, we still need tracePaths() for them.
var ok = true;
if (paths2) {
for (var i1 = 0, l1 = paths1.length; i1 < l1 && ok; i1++) {
var bounds1 = paths1[i1].getBounds();
for (var i2 = 0, l2 = paths2.length; i2 < l2 && ok; i2++) {
var bounds2 = paths2[i2].getBounds();
// If either of the bounds fully contains the other,
// skip the simple approach and delegate to tracePaths()
ok = !bounds1._containsRectangle(bounds2) &&
!bounds2._containsRectangle(bounds1);
}
}
}
// See if there are any valid segments that aren't part of overlaps.
// This information is used to determine where to start tracing the
// path, and how to treat encountered invalid segments.
if (!(inter && inter._overlap)) {
var path = segment._path;
path._overlapsOnly = false;
// This is not an overlap. If it is valid, take note that there
// are valid intersections other than overlaps in this path.
if (operator[segment._winding])
path._validOverlapsOnly = false;
if (ok) {
paths = operator.unite || operator.exclude ? [_path1, _path2]
: operator.subtract ? [_path1]
// No result, but let's return an empty path to keep
// chainability and transfer styles to the result.
: operator.intersect ? [new Path(Item.NO_INSERT)]
: null;
}
}
return createResult(CompoundPath, tracePaths(segments, operator), true,
path1, path2);
if (!paths) {
// Collect all segments and monotonic curves
collect(paths1);
if (paths2)
collect(paths2);
// Propagate the winding contribution. Winding contribution of
// curves does not change between two crossings.
// First, propagate winding contributions for curve chains starting
// in all crossings:
for (var i = 0, l = crossings.length; i < l; i++) {
propagateWinding(crossings[i]._segment, _path1, _path2, curves,
operator);
}
for (var i = 0, l = segments.length; i < l; i++) {
var segment = segments[i],
inter = segment._intersection;
if (segment._winding == null) {
propagateWinding(segment, _path1, _path2, curves, operator);
}
// See if there are any valid segments that aren't part of
// overlaps. Use this information to determine how to deal with
// various edge-cases in tracePaths().
if (!(inter && inter._overlap)) {
var path = segment._path;
path._overlapsOnly = false;
// This is no overlap. If it is valid, take note that this
// path contains valid intersections other than overlaps.
if (operator[segment._winding])
path._validOverlapsOnly = false;
}
}
paths = tracePaths(segments, operator);
}
return createResult(CompoundPath, paths, true, path1, path2);
}
function computeOpenBoolean(path1, path2, operator) {
@ -383,7 +421,7 @@ PathItem.inject(new function() {
windingPrev = vPrev[io] > vPrev[io + 6] ? 1 : -1,
a3Prev = vPrev[ia + 6];
if (po !== o0) {
// Standard case, curve is crossed by not at its start point.
// Standard case, curve is not crossed at its starting point.
if (a < paL) {
pathWindingL += winding;
} else if (a > paR) {
@ -394,7 +432,7 @@ PathItem.inject(new function() {
pathWindingR += winding;
}
} else if (winding !== windingPrev) {
// Curve is crossed at start point and winding changes from
// Curve is crossed at starting point and winding changes from
// previous. Cancel winding contribution from previous curve.
if (a3Prev < paR) {
pathWindingL += winding;
@ -495,8 +533,8 @@ PathItem.inject(new function() {
// If the point is on the path and the windings canceled
// each other, we treat the point as if it was inside the
// path. A point inside a path has a winding of [+1,-1]
// for clockwise and [-1,+1] for counter-clockwise paths.
// If the ray is cast in y direction (dir == 1), the
// for clockwise and [-1,+1] for counter-clockwise paths.
// If the ray is cast in y direction (dir == 1), the
// windings always have opposite sign.
var add = path.isClockwise() ^ dir ? 1 : -1;
windingL += add;
@ -1077,9 +1115,9 @@ PathItem.inject(new function() {
o2 = v[5],
o3 = v[7];
if (y >= min(o0, o1, o2, o3) && y <= max(o0, o1, o2, o3)) {
var monos = Curve.getMonoCurves(v);
for (var j = 0, m = monos.length; j < m; j++) {
var mv = monos[j],
var monoCurves = Curve.getMonoCurves(v);
for (var j = 0, m = monoCurves.length; j < m; j++) {
var mv = monoCurves[j],
mo0 = mv[1],
mo3 = mv[7];
// Only handle curves that are not horizontal and

View file

@ -156,6 +156,14 @@ var comparePixels = function(actual, expected, message, options) {
+ '" src="' + raster.source + '">';
}
if (!expected) {
return QUnit.strictEqual(actual, expected, message, options);
} else if (!actual) {
// In order to compare pixels, just create an empty item that can be
// rasterized to an empty raster.
actual = new Group();
}
options = options || {};
// In order to properly compare pixel by pixel, we need to put each item
// into a group with a white background of the united dimensions of the
@ -452,10 +460,15 @@ var compareBoolean = function(actual, expected, message, options) {
message = getFunctionMessage(actual);
actual = actual();
}
actual.style = expected.style = {
var style = {
strokeColor: 'black',
fillColor: expected.closed || expected.children ? 'yellow' : null
fillColor: expected &&
(expected.closed || expected.children && 'yellow') || null
};
if (actual)
actual.style = style;
if (expected)
expected.style = style;
equals(actual, expected, message, Base.set({ rasterize: true }, options));
};

View file

@ -723,117 +723,139 @@ test('Isolated edge-cases from @iconexperience\'s boolean-test suite', function(
[240, 270, 0, 0, 0, 0],
[250.53466323186618, 221.0057178821544, 0, 0, 0, 0],
[237.67824477332854, 193.79795691566554, 0, 0, 0, 0],
[320, 240, 0, 0, 0, 0]
[320, 240, 0, 0, 0, 0],
true
], [
[263.31216874462405, 248.04647709671602, 0, 0, 0, 0],
[230, 250, 0, 0, 0, 0],
[237.6782447781314, 193.79795691339606, 0, 0, 0, 0]
[237.6782447781314, 193.79795691339606, 0, 0, 0, 0],
true
]
], [
[
[450, 230, 0, 0, 0, 0],
[362.46932779553646, 264.4394368330295, 0, 0, 0, 0],
[329.00715661950534, 214.6369961279195, 0, 0, 0, 0]
[329.00715661950534, 214.6369961279195, 0, 0, 0, 0],
true
], [
[362.46932779553646, 264.4394368330295, 0, 0, 0.5029830904762775, -0.33795344231873514],
[331.7750437531172, 267.3071389516512, 0.33347583635435285, -3.453534396532916, 0, 0],
[329.00715661950534, 214.6369961279195, 0, 0, 0, 0]
[329.00715661950534, 214.6369961279195, 0, 0, 0, 0],
true
]
], [
[
[211.76470809030513, 391.5530064242439, 0, 0, -1.1306561612996688, -11.284564044000547],
[206.28516988159765, 416.3206370377553, 9.29930425192211, -12.510751934521268, 0, 0],
[142.17355611649077, 367.3087985311291, 0, 0, 0, 0]
[142.17355611649077, 367.3087985311291, 0, 0, 0, 0],
true
], [
[152.06363005021922, 397.5347520600572, 0, 0, 0, 0],
[218.65631922872535, 332.74836297575644, 0, 0, -9.581012775680733, 10.097912103353224],
[211.76470809030513, 391.55300642424385, -1.8914123817368989, -18.8773252964819, 0, 0]
[211.76470809030513, 391.55300642424385, -1.8914123817368989, -18.8773252964819, 0, 0],
true
]
], [
[
[138.3141655808707, 456.06810826237086, 0, 0, 1.6246548956081597, -1.188772469512287],
[103.70383447788026, 471.4426853592628, 15.914191732656704, 1.2415901505934812, 0, 0],
[147.64340975918196, 340.17263448268653, 0, 0, 0, 0]
[147.64340975918196, 340.17263448268653, 0, 0, 0, 0],
true
], [
[102.88355437423151, 307.6462971693936, 0, 0, 0, 0],
[311.9175162439421, 379.75248280363354, 0, 0, -68.45789375971557, 0.5465997368099806],
[138.3141655808706, 456.06810826237097, 33.643258081480184, -24.617030422937262, 0, 0]
[138.3141655808706, 456.06810826237097, 33.643258081480184, -24.617030422937262, 0, 0],
true
]
], [
[
[260.5630488345416, 240.11728335016855, 0, 0, 0, 0],
[230.82205831331396, 236.1805613638536, 0, 0, 0, 0],
[300.041224753361, 200, 0, 0, 0, 0],
[300, 300, 0, 0, 0, 0]
[300, 300, 0, 0, 0, 0],
true
], [
[290.30323645974596, 244.0538990495128, 0, 0, 0, 0],
[320, 280, 0, 0, 0, 0],
[230.82205831199582, 236.18056137381197, 0, 0, 0, 0]
[230.82205831199582, 236.18056137381197, 0, 0, 0, 0],
true
]
], [
[
[266.2339624919457, 249.28592706878334, 0, 0, 0, 0],
[236.42561910533144, 245.88969337410168, 0, 0, 0, 0],
[320, 240, 0, 0, 0, 0],
[280, 300, 0, 0, 0, 0]
[280, 300, 0, 0, 0, 0],
true
], [
[296.03993000559, 252.68189006496056, 0, 0, 0, 0],
[320, 300, 0, 0, 0, 0],
[236.42561910512714, 245.8896933758947, 0, 0, 0, 0]
[236.42561910512714, 245.8896933758947, 0, 0, 0, 0],
true
]
], [
[
[109.2693308633721, 249.31916869409733, 0, 0, 0, 0],
[157.6368865573791, 284.8238100271277, 0, 0, 0, 0],
[150, 329.3972954455561, 0, 0, 0, 0]
[150, 329.3972954455561, 0, 0, 0, 0],
true
], [
[109.26933086337212, 249.3191686940973, 0, 0, 0, 0],
[157.1468245594682, 224.11329044817836, 0, 0, 0, 0],
[161.745373658654, 283.93680878488584, 0, 0, -4.753441100107182, 0.365390282896783],
[157.63688655737909, 284.82381002712776, -0.5599416549340219, 0.7628019369743697, 0, 0]
[157.63688655737909, 284.82381002712776, -0.5599416549340219, 0.7628019369743697, 0, 0],
true
]
], [
[
[249.53400844979302, 269.5706278725207, 0, 0, -5.202299838213264, 1.3434437726778015],
[243.02912232136828, 272.45353289318496, -0.02459817048722357, 0.029126503110205704, 0, 0],
[197.1892333604494, 233.7404268430289, 0, 0, 0, 0]
[197.1892333604494, 233.7404268430289, 0, 0, 0, 0],
true
], [
[243.02912232136822, 272.453532893185, 0, 0, 0.44566136595048533, -0.527704170852985],
[242.66927041668393, 276.2408467361064, -0.16957999946740188, -3.971488536288973, 0, 0],
[197.18923336044946, 233.74042684302884, 0, 0, 0, 0]
[197.18923336044946, 233.74042684302884, 0, 0, 0, 0],
true
]
], [
[
[326.356206851053, 259.5165810014779, 0, 0, 2.309307036608857, -4.052538199979125],
[327.9512902239682, 255.73918757869137, -0.3651148630259513, -1.1113992742978098, 0, 0],
[384.95409529898944, 237.01272999645926, 0, 0, 0, 0],
[350, 300, 0, 0, 0, 0]
[350, 300, 0, 0, 0, 0],
true
], [
[327.9512902239682, 255.73918757869126, 0, 0, 0, 0],
[320, 250, 0, 0, 0, 0],
[384.95409529898944, 237.01272999645937, 0, 0, 0, 0]
[384.95409529898944, 237.01272999645937, 0, 0, 0, 0],
true
]
], [
[
[231.45710796909526, 304.56978671182316, 0, 0, 6.965195106563414, -10.698308411775713],
[230.61969090209206, 265.2654116388295, 4.522412663592235, 13.984636258635192, 0, 0],
[287.7087867546365, 246.8036908431129, 0, 0, 0, 0]
[287.7087867546365, 246.8036908431129, 0, 0, 0, 0],
true
], [
[267.0542186716473, 253.4830551491999, 0, 0, 0, 0],
[230.61969090209206, 265.26541163882956, 0, 0, 2.0144954400552137, 6.22941515281218],
[229.4516168394906, 239.90168380046367, -4.821444118085253, 13.349082266661071, 0, 0]
[229.4516168394906, 239.90168380046367, -4.821444118085253, 13.349082266661071, 0, 0],
true
]
], [ // 10
[
[534.4141795042503, 349.4135521611639, 0, 0, 0.9952674258736351, -5.064332094235169],
[518.8256109308445, 384.2317022309883, 13.426353275139377, -9.450213278660101, 0, 0],
[487.8821067425946, 340.2688405948006, 0, 0, 0, 0],
[529.4025393039343, 348.4286400051758, 0, 0, -0.93900751246872, -2.1407484665217567]
[529.4025393039343, 348.4286400051758, 0, 0, -0.93900751246872, -2.1407484665217567],
true
], [
[475.5403232814915, 337.8433726698194, 0, 0, 0, 0],
[538.3223483008236, 152.20174200302918, 0, 0, 0, 0],
[576.6459309452254, 198.36777944721226, 0, 0, -12.4717091442418, 10.353077772467884],
[534.4141795042503, 349.41355216116364, 9.869907229687897, -50.22216808367796, 0, 0]
[534.4141795042503, 349.41355216116364, 9.869907229687897, -50.22216808367796, 0, 0],
true
]
], [
[
@ -841,11 +863,13 @@ test('Isolated edge-cases from @iconexperience\'s boolean-test suite', function(
[192.98476439737567, 381.03840618337944, 0, 0, 0, 0],
[191.58826071683484, 405.5453629318501, 0, 0, 1.76117811362775, 0.1003589202450712],
[158.80881838193744, 396.40041814383164, 11.345470204261431, 9.97219009394314, 0, 0],
true
], [
[195.00176127688619, 345.64254151310115, 0, 0, 0, 0],
[481.252611684097, 441.78388187198607, 0, 0, 0, 0],
[448.747388315903, 492.21611812801393, 0, 0, -122.96965958186621, -79.25796175143017],
[191.5882607168351, 405.54536293185015, 35.244503935513166, 2.0083717439883912, 0, 0]
[191.5882607168351, 405.54536293185015, 35.244503935513166, 2.0083717439883912, 0, 0],
true
]
], [
[
@ -853,73 +877,87 @@ test('Isolated edge-cases from @iconexperience\'s boolean-test suite', function(
[226.29027430947582, 456.0825533500981, 0, 0, -0.2832959470065646, -8.800441169464932],
[219.2838668275147, 483.73556312076016, 10.02977284964885, -11.976298343562064, 0, 0],
[200, 500, 0, 0, 0, 0],
true
], [
[166.32133819059692, 458.01301981440685, 0, 0, 0, 0],
[204.6120898437701, 320.4482218772343, 0, 0, 0, 0],
[244.3462523224993, 365.40593903584846, 0, 0, -18.086870972805855, 15.985390615581537],
[226.29027430947582, 456.08255335009807, -0.8931629157136456, -27.74564118385956, 0, 0]
[226.29027430947582, 456.08255335009807, -0.8931629157136456, -27.74564118385956, 0, 0],
true
]
], [
[
[134.30251416753708, 172.0081092040946, 0, 0, 97.01301228604092, -2.2561165647916255],
[223.30038363130024, 161.29265138604404, 7.832155210448377, -11.227084549308643, 0, 0],
[135.69748583246292, 231.99189079590533, 0, 0, 0, 0]
[135.69748583246292, 231.99189079590533, 0, 0, 0, 0],
true
], [
[248.04309709886002, 178.55347910623016, 0, 0, 0, 0],
[223.30038363130373, 161.29265138603904, 0, 0, -6.854532836619114, 9.825701564243673],
[240.2776561840474, 149.3557271403692, -14.092989377677696, 3.748174738020822, 0, 0]
[240.2776561840474, 149.3557271403692, -14.092989377677696, 3.748174738020822, 0, 0],
true
]
], [
[
[517.5047187481108, 202.91541735696418, 6.513140197398911, -18.244597886454756, 0, 0],
[545.7583411018326, 213.0016798561104, 0, 0, 0, 0],
[557.8431595513716, 185.5433980031361, -8.326516730755202, -3.664629555367924, 0, 0],
[545.7583424843119, 213.00167993223172, 0, 0, -1.1368683772161603e-13, 0]
[545.7583424843119, 213.00167993223172, 0, 0, -1.1368683772161603e-13, 0],
true
], [
[550.3546243594556, 242.6474912770306, 0, 0, 11.17102286717818, -1.7319541248482437],
[541.1620576122966, 183.35586693936358, -11.180538230113825, 1.733429385644115, 0, 0]
[541.1620576122966, 183.35586693936358, -11.180538230113825, 1.733429385644115, 0, 0],
true
]
], [
[
[290.1253327484206, 287.90652074109494, 0, 0, 0, 0],
[342.6480156335393, 281.88796157138086, 0, 0, 0, 0],
[340.20645047153664, 251.98747653472907, 0, 0, 0, 0],
[370.8816252545162, 292.03012917196776, 0, 0, 0, 0]
[370.8816252545162, 292.03012917196776, 0, 0, 0, 0],
true
], [
[345.08958029318296, 311.78843842619824, 0, 0, 0, 0],
[300.0082518321038, 300.98900280805503, 0, 0, 0, 0],
[340.20645030689445, 251.98747654817316, 0, 0, 0, 0]
[340.20645030689445, 251.98747654817316, 0, 0, 0, 0],
true
]
], [
[
[371.53493854231004, 257.22260275739484, 0, 0, -5.3406979774814545, -1.8674091727692712],
[360.1944182950855, 257.04852958152196, 1.4950314859081004, -0.8166674734584944, 0, 0],
[430.4144838319712, 235.2349421258068, -7.8035474909103755, -18.555544116219835, 0, 0]
[430.4144838319712, 235.2349421258068, -7.8035474909103755, -18.555544116219835, 0, 0],
true
], [
[360.1944182950853, 257.0485295815221, 0, 0, 0.09209791202033557, -0.05030888635417341],
[358.8995515281498, 260.3188854078006, 0.4901759953118585, -3.4265416599628793, 0, 0],
[300, 230, 0, 0, 0, 0]
[300, 230, 0, 0, 0, 0],
true
]
], [
[
[409.2490311439771, 253.4403128346141, 0, 0, -4.356295913055419, 1.322648861578557],
[403.6254675741819, 256.25364724519244, 0.0777100557439212, -0.09457550986331853, 0, 0],
[357.2674295740252, 218.16254181654907, 0, 0, 0, 0]
[357.2674295740252, 218.16254181654907, 0, 0, 0, 0],
true
], [
[403.625467574182, 256.2536472451924, 0, 0, 0.27347672342176566, -0.33282952001209765],
[403.0346093549582, 261.0014812561057, -0.21747734382410044, -4.397037948600143, 0, 0],
[357.26742957402513, 218.16254181654915, 0, 0, 0, 0]
[357.26742957402513, 218.16254181654915, 0, 0, 0, 0],
true
]
], [
[
[292.9399983081827, 321.04496242335836, 0, 0, 0, 0],
[301.41124169557446, 297.40574481030876, 0, 0, 0, 0],
[271.4382902635834, 296.1319728479751, 0, 0, 0, 0],
[319.88255402047366, 273.7665574434494, 0, 0, 0, 0]
[319.88255402047366, 273.7665574434494, 0, 0, 0, 0],
true
], [
[331.38418270096264, 298.67951674085646, 0, 0, 0, 0],
[350, 345.76013009266507, 0, 0, 0, 0],
[271.4382902810318, 296.1319724373992, 0, 0, 0, 0]
[271.4382902810318, 296.1319724373992, 0, 0, 0, 0],
true
]
], [
[
@ -927,79 +965,93 @@ test('Isolated edge-cases from @iconexperience\'s boolean-test suite', function(
[306.8847250793194, 310.8417788081535, 0, 0, 0, 0],
[317.34865046978905, 286.0848942283935, 0, 0, 0, 0],
[295.03238113332606, 289.30770347326694, 0, 0, 0, 0],
true
], [
[306.8847250793191, 310.8417788081534, 0, 0, 0, 0],
[308.40196713650136, 308.29790890842884, 0, 0, 0, 0],
[297.432392604982, 249.3091944403423, 0, 0, 0, 0],
[330.2439214313423, 255.57562328972034, 0, 0, 0, 0]
[330.2439214313423, 255.57562328972034, 0, 0, 0, 0],
true
]
], [ // 20
[
[150, 290, 0, 0, 0, 0],
[180, 260, 0, 0, 0, 0],
[220, 300, 0, 0, 0, 0]
[220, 300, 0, 0, 0, 0],
true
], [
[180, 260, 0, 0, 0, 0],
[230, 270, 0, 0, 0, 0],
[170, 310, 0, 0, 0, 0],
[220, 300, 0, 0, 0, 0]
[220, 300, 0, 0, 0, 0],
true
]
], [
[
[299.7385339651986, 102.20556080028058, -8.846854364457954, -13.558854632211663, 0, 0],
[324.85949771228013, 85.81468459475798, 0, 0, 0, 0],
[331.26017128225755, 56.500458549069435, 0, 0, 0, 0],
[349.988176980811, 69.4187741812245, 0, 0, 9.063133638672639, 13.890328297113285]
[349.988176980811, 69.4187741812245, 0, 0, 9.063133638672639, 13.890328297113285],
true
], [
[318.4609036471463, 115.11938678905685, 0, 0, 0, 0],
[340.9228398583517, 111.1463404606569, 0, 0, 0, 0],
[308.7912208820021, 60.47525341924158, 0, 0, 0, 0],
[331.2601712818937, 56.50045854899, 0, 0, 0, 0]
[331.2601712818937, 56.50045854899, 0, 0, 0, 0],
true
]
], [
[
[388.9213889025063, 223.3215931867822, 0, 0, 120.27613015930797, -2.2436869719875574],
[597.6181955110758, 242.94850207232983, 0, 0, 0, 0],
[628.0354673841999, 243.03685701873312, 0, 0, -0.031041118475286567, 10.686285016774008],
[419.2789142850017, 364.27077547853787, 0, 0]
[419.2789142850017, 364.27077547853787, 0, 0],
true
], [
[568.0357205119291, 242.86257201242702, 0, 0, 0, 0],
[576.294245114903, 263.4873716612576, -0, 0, 0, 0],
[619.5200435607698, 221.87571045051882, 0, 0, 0, 0],
[628.0354673841999, 243.03685701876972, 0.030302631585300333, -10.432051860541975, 0, 0]
[628.0354673841999, 243.03685701876972, 0.030302631585300333, -10.432051860541975, 0, 0],
true
]
], [
[
[250, 130, 0, 0, 0, 0],
[274.2339539863471, 194.10449080567912, 0, 0, 0.10568701547992987, -0.053016796189552906],
[272.11154618911314, 196.81853259861245, 1.370678992642354, -2.513969427633242, 0, 0]
[272.11154618911314, 196.81853259861245, 1.370678992642354, -2.513969427633242, 0, 0],
true
], [
[250, 130, 0, 0, 0, 0],
[282.64261453718956, 194.05831848298737, 0, 0, -6.1766919512210166, -1.0441192545144133],
[274.23395398634705, 194.10449080567915, 0.11866362575074163, -0.05952637826862883, 0, 0]
[274.23395398634705, 194.10449080567915, 0.11866362575074163, -0.05952637826862883, 0, 0],
true
]
], [
[
[386.4093435542647, 270.73026596496675, 0, 0, 77.41690321854611, 15.777187877165375],
[528.635149558586, 289.6368596320347, -12.835362144855708, 5.740740187064205, 0, 0],
[553.1321511797777, 344.4081743101702, 0, 0, 0, 0]
[553.1321511797777, 344.4081743101702, 0, 0, 0, 0],
true
], [
[528.6351495585858, 289.6368596320348, 0, 0, -0.31548183780626005, 0.14110231126664985],
[522.9057367288372, 295.33394762583623, 2.3982010141742194, -4.106159119428241, 0, 0],
[574.716309478071, 325.5938972523037, 0, 0, 0, 0],
[553.1321511797779, 344.40817431017007, 0, 0, 0, 0]
[553.1321511797779, 344.40817431017007, 0, 0, 0, 0],
true
]
], [
[
[525, 345, 0, 0, 0, 0],
[557.3179687742295, 363.04379418599376, 0, 0, 0, 0],
[587.1223034990716, 366.54087021669767, 0, 0, 0, 0],
[500, 400, 0, 0, 0, 0]
[500, 400, 0, 0, 0, 0],
true
], [
[527.5311085637297, 359.5487685170587, 0, 0, 0, 0],
[533.6060904205631, 381.4080959083297, 0, 0, 0, 0],
[581.0430044030195, 344.66929908778826, 0, 0, 0, 0],
[587.1223034989287, 366.54087021791537, 0, 0, 0, 0]
[587.1223034989287, 366.54087021791537, 0, 0, 0, 0],
true
]
], [
[
@ -1008,21 +1060,25 @@ test('Isolated edge-cases from @iconexperience\'s boolean-test suite', function(
[205.60227766791786, 189.2546311484904, 0, 0, 0, 0],
[205.60227766791786, 189.4546311484904, 0, 0, 0, 0],
[205.61255586021304, 189.25209037995552, 0, 0, 0, 0],
[263.84900039629053, 174.85604471078497, 0, 0, 0, 0]
[263.84900039629053, 174.85604471078497, 0, 0, 0, 0],
true
], [
[225.84313834895474, 153.1048226009985, 0, 0, 0, 0],
[180, 190, 0, 0, 0, 0],
[243.48255333255608, 210.4533277169673, 0, 0, 0, 0]
[243.48255333255608, 210.4533277169673, 0, 0, 0, 0],
true
]
], [
[
[598.5486959306086, 408.11025390080914, 0, 0, 0, 0],
[556.2683544908633, 467.2163769525839, 0, 0, 0, 0],
[552.429221746517, 437.22810161381835, 0, 0, 0, 0],
true
], [
[556.2683546136653, 467.2163769491477, 0, 0, 0, 0],
[518.5330018076562, 379.67700053006695, 0, 0, 0, 0],
[554.5900896267148, 407.2398529865706, 0, 0, 0, 0]
[554.5900896267148, 407.2398529865706, 0, 0, 0, 0],
true
]
], [
[
@ -1030,11 +1086,13 @@ test('Isolated edge-cases from @iconexperience\'s boolean-test suite', function(
[575.8176000300452, 323.5855681222093, 0, 0, 0, 0],
[547.6444566349796, 309.1465641549448, 0, 0, 0, 0],
[578.8341920603752, 304.57835489946484, 0, 0, -5.7225406635552645e-9, -3.907138079739525e-8],
[519.4675806753132, 313.27349449897866, 0, 0, 0, 0]
[519.4675806753132, 313.27349449897866, 0, 0, 0, 0],
true
], [
[575.8176000300631, 323.58556812217466, 0, 0, 0, 0],
[560, 300, 0, 0, 0, 0],
[522.421811145802, 296.21971842903645, 0, 0, 0, 0]
[522.421811145802, 296.21971842903645, 0, 0, 0, 0],
true
]
], [
[
@ -1042,12 +1100,14 @@ test('Isolated edge-cases from @iconexperience\'s boolean-test suite', function(
[93.61538461538461, 0, -2.9185159236061224, 0, 2.2538650858334677, 0],
[100.17943209134619, 0, -2.11714516843503, 0, 8.39247295673077, 0],
[100.17943209134613, 0, -4.131239081724743, 0, -2.1880158253205195, 0],
[93.61538461538458, 0, 2.1880158253205053, 0, -2.0904997996794776, 0]
[93.61538461538458, 0, 2.1880158253205053, 0, -2.0904997996794776, 0],
true
], [
[163.8269230769231, 0, 0, 0, 0, 0],
[160.90144230769232, 0, 1.6090144230769283, 0, 0, 0],
[2.9254807692307696, 0, 0, 0, -1.6090144230769234, 0],
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0],
true
]
], [
'M419.20344565830516,384.34607379092466c5.844713611412715,3.313058909545532 8.737629565616828,3.6008009941920136 9.663847696961,3.5457774486854987c0.4249875971154893,-0.23215482613579752 3.134401138218834,-1.9001699951828073 6.912521889816844,-9.027614775318739c33.358079343370036,-62.930193110079074 15.048818377810562,-263.53585410399967 14.89110904614597,-264.2035689431943l58.39331120497843,-13.792070421750992c0.38461989956749676,1.6284160973869177 24.314056080847877,221.98511298279283 -20.271816008415897,306.09659649109955c-7.779727674038611,14.676497403570863 -19.843728834889646,29.87171953249475 -38.60350857895327,37.0189975138764c-20.692089248499826,7.88346749760683 -41.830098370105475,3.183730282850888 -60.57334789311045,-7.440826188961864z',
@ -1090,14 +1150,11 @@ test('Isolated edge-cases from @iconexperience\'s boolean-test suite', function(
['M419.20345,384.34607c5.84471,3.31306 8.73763,3.6008 9.66385,3.54578c0.42499,-0.23215 3.1344,-1.90017 6.91252,-9.02761c31.69382,-59.79056 16.74714,-243.86183 15.04159,-262.65257c-3.42808,-8.00965 -2.79156,-12.73288 -0.15048,-1.551l29.19538,-6.89574l-2.9917,-29.85552c34.20913,-3.42795 37.91991,47.22024 32.18962,22.95919c0.38462,1.62842 24.31406,221.98511 -20.27182,306.0966c-7.77973,14.6765 -19.84373,29.87172 -38.60351,37.019c-20.69209,7.88347 -41.8301,3.18373 -60.57335,-7.44083z', 'M450.8214,116.21167c-0.08956,-0.98671 -0.14261,-1.51768 -0.15048,-1.551l29.19538,-6.89574l2.99069,29.84549c-18.44587,1.84838 -28.02391,-12.02551 -32.0356,-21.39876z'],
['M224.2508,238.43767c2.45124,34.92471 9.86647,54.1339 17.20117,64.07402c4.07985,5.52909 8.23969,8.37799 12.35502,9.97162c7.6805,2.97421 19.93299,3.22543 38.3191,-2.95557c81.13187,-27.27474 190.74601,-146.01269 198.63572,-155.10754c0.92148,-1.70426 1.39237,-2.07227 0.44507,-0.53656l25.35355,15.63944l29.94723,-4.25223c1.89126,13.31958 -6.82114,24.30584 -4.2348,20.11304c-5.40958,8.76963 -129.41512,146.85628 -231.02757,181.01613c-24.82193,8.34458 -52.91092,12.17808 -79.10499,2.03465c-15.35707,-5.9469 -28.53272,-16.15682 -38.96756,-30.29832c-16.97074,-22.99908 -25.95119,-55.26903 -28.7747,-95.49783z', 'M490.76181,154.42019c0.26299,-0.30316 0.41295,-0.48449 0.44507,-0.53656l25.35355,15.63944l-29.45692,4.18261c-1.21879,-8.58358 1.97318,-16.16889 3.6583,-19.28549z']
];
function createPath(data) {
return typeof data === 'string' ? PathItem.create(data) : new Path({ segments: data, closed: true });
}
for (var i = 0; i < paths.length; i++) {
var entry = paths[i],
result = results[i],
path1 = createPath(entry[0]),
path2 = createPath(entry[1]);
path1 = PathItem.create(entry[0]),
path2 = PathItem.create(entry[1]);
compareBoolean(path1.unite(path2), result[0], 'path1.unite(path2); // Test ' + (i + 1));
compareBoolean(path1.intersect(path2), result[1], 'path1.intersect(path2); // Test ' + (i + 1));
}