From 6bb1df2bf063802dfa25671b69861dd4bdf7b075 Mon Sep 17 00:00:00 2001 From: bakedpotatolord Date: Tue, 24 Jun 2025 12:10:21 -0600 Subject: [PATCH] revert changes --- src/geo/polygons.js | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/geo/polygons.js b/src/geo/polygons.js index dcc59489..86d866a6 100644 --- a/src/geo/polygons.js +++ b/src/geo/polygons.js @@ -620,18 +620,14 @@ function offset(polys, dist, opts = {}) { } } - let { - count = 1, - depth = 0, - fill = FillNonZero, - join = JoinType.jtMiter, - type = EndType.etClosedPolygon, - } = opts; - let orig = polys, + count = numOrDefault(opts.count, 1), + depth = numOrDefault(opts.depth, 0), clean = opts.clean !== false, simple = opts.simple !== false, - + fill = numOrDefault(opts.fill, FillNonZero), + join = numOrDefault(opts.join, JoinType.jtMiter), + type = numOrDefault(opts.type, EndType.etClosedPolygon), // if dist is array with values, shift out next offset offs = Array.isArray(dist) ? (dist.length > 1 ? dist.shift() : dist[0]) : dist, mina = numOrDefault(opts.minArea, 0.1), @@ -667,7 +663,11 @@ function offset(polys, dist, opts = {}) { // if specified, perform offset gap analysis if (opts.gaps && polys.length) { + let oneg = offset(polys, -offs, { + fill: opts.fill, join: opts.join, type: opts.type, z: opts.z, minArea: mina + }); let suba = []; + let diff = subtract(orig, oneg, suba, null, zed); opts.gaps.append(suba, opts.flat); } @@ -678,14 +678,6 @@ function offset(polys, dist, opts = {}) { // if specified, perform up to *count* successive offsets if (polys.length) { - // decrement count, increment depth - opts.count = --count; - opts.depth = ++depth; - - //set poly depth - polys.forEach(p => { - p.depth = depth; - }); // ensure opts has offset accumulator array opts.outs = opts.outs || []; // store polys in accumulator @@ -696,6 +688,9 @@ function offset(polys, dist, opts = {}) { } // check for more offsets if (count > 1) { + // decrement count, increment depth + opts.count = count - 1; + opts.depth = depth + 1; // call next offset offset(polys, dist, opts); }