@pixerate/editor 0.33.0 → 0.34.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.
@@ -2651,6 +2651,24 @@ function intersectSubdivided(P, p0, p1, Q, q0, q1, fullP, fullQ, ctx, out, depth
2651
2651
  intersectSubdivided(P, p0, p1, qb, qm, q1, fullP, fullQ, ctx, out, depth + 1);
2652
2652
  }
2653
2653
  }
2654
+ function segmentIntersections(a, b, options = {}) {
2655
+ let size = 1;
2656
+ for (const [x, y] of [...a, ...b]) size = Math.max(size, Math.abs(x), Math.abs(y));
2657
+ const eps = options.epsilon ?? size * 1e-9;
2658
+ const found = [];
2659
+ const ctx = { eps, leaves: 0, budget: options.budget ?? 4096 };
2660
+ try {
2661
+ intersectSubdivided(a.slice(), 0, 1, b.slice(), 0, 1, a, b, ctx, found, 0);
2662
+ } catch (error) {
2663
+ if (!(error instanceof PathOpsError)) throw error;
2664
+ }
2665
+ const out = [];
2666
+ for (const ev of found.sort((x, y) => x.tp - y.tp)) {
2667
+ if (out.some((o) => dist2(o.point, ev.point) <= eps * 4)) continue;
2668
+ out.push({ ta: ev.tp, tb: ev.tq, point: ev.point });
2669
+ }
2670
+ return out;
2671
+ }
2654
2672
  function nearestOn(piece, p, eps) {
2655
2673
  if (p[0] < piece.minX - eps || p[0] > piece.maxX + eps || p[1] < piece.minY - eps || p[1] > piece.maxY + eps) return null;
2656
2674
  return segmentNearest(piece.pts, p);
@@ -3321,6 +3339,7 @@ export {
3321
3339
  distanceToBezierPath,
3322
3340
  flattenChain,
3323
3341
  PathOpsError,
3342
+ segmentIntersections,
3324
3343
  pathBoolean,
3325
3344
  unitePaths,
3326
3345
  intersectPaths,
@@ -3332,4 +3351,4 @@ export {
3332
3351
  pathBooleanRings,
3333
3352
  nestedRingsToPath
3334
3353
  };
3335
- //# sourceMappingURL=chunk-GQTXV2EQ.js.map
3354
+ //# sourceMappingURL=chunk-RK6HUKDI.js.map