@pixerate/editor 0.36.0 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -275,6 +275,25 @@ function buildOverlay(inputs, options) {
275
275
  const edges = [...byKey.values()].filter((e) => e.mult.some((m) => m !== 0));
276
276
  const right = [];
277
277
  const left = [];
278
+ const bandCount = Math.max(1, Math.min(4096, Math.ceil(Math.sqrt(edges.length))));
279
+ const bandIndex = (horizontal) => {
280
+ const lo = (e) => horizontal ? Math.min(-e.a.x, -e.b.x) : Math.min(e.a.y, e.b.y);
281
+ const hi = (e) => horizontal ? Math.max(-e.a.x, -e.b.x) : Math.max(e.a.y, e.b.y);
282
+ let min = Infinity;
283
+ let max = -Infinity;
284
+ for (const e of edges) {
285
+ min = Math.min(min, lo(e));
286
+ max = Math.max(max, hi(e));
287
+ }
288
+ const size = max > min ? (max - min) / bandCount : 1;
289
+ const band = (v) => Math.min(bandCount - 1, Math.max(0, Math.floor((v - min) / size)));
290
+ const bands = Array.from({ length: bandCount }, () => []);
291
+ edges.forEach((e, j) => {
292
+ for (let k = band(lo(e)); k <= band(hi(e)); k++) bands[k].push(j);
293
+ });
294
+ return (v) => bands[band(v)];
295
+ };
296
+ const bandsFor = /* @__PURE__ */ new Map();
278
297
  for (let i = 0; i < edges.length; i++) {
279
298
  const edge = edges[i];
280
299
  const horizontal = Math.abs(edge.b.y - edge.a.y) < Math.abs(edge.b.x - edge.a.x);
@@ -287,7 +306,8 @@ function buildOverlay(inputs, options) {
287
306
  const mx = (ax + bx) / 2;
288
307
  const my = (ay + by) / 2;
289
308
  const winding = new Array(count).fill(0);
290
- for (let j = 0; j < edges.length; j++) {
309
+ if (!bandsFor.has(horizontal)) bandsFor.set(horizontal, bandIndex(horizontal));
310
+ for (const j of bandsFor.get(horizontal)(my)) {
291
311
  if (j === i) continue;
292
312
  const other = edges[j];
293
313
  const oax = tx(other.a);
@@ -3776,6 +3796,7 @@ export {
3776
3796
  windingNumber,
3777
3797
  pointInBezierPath,
3778
3798
  distanceToBezierPath,
3799
+ flattenChain,
3779
3800
  PathOpsError,
3780
3801
  segmentIntersections,
3781
3802
  pathBoolean,
@@ -3791,4 +3812,4 @@ export {
3791
3812
  outlineStroke,
3792
3813
  offsetPath
3793
3814
  };
3794
- //# sourceMappingURL=chunk-EGPIVUEF.js.map
3815
+ //# sourceMappingURL=chunk-HPEKB352.js.map