flo-mat 4.1.4 → 5.0.1
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.
- package/__tests__/closest-boundary-point/get-endpoint-info.spec.ts +140 -0
- package/__tests__/closest-boundary-point/root-interval-to-distance-squared-interval.spec.ts +87 -0
- package/__tests__/cp-node/circle-identity.spec.ts +56 -0
- package/__tests__/cp-node/fs/get-all-on-loop-by-loop.spec.ts +55 -0
- package/__tests__/cp-node/fs/get-angle-between-mat-curves.spec.ts +39 -3
- package/__tests__/cp-node/fs/get-boundary-bezier-parts-to-next.spec.ts +87 -3
- package/__tests__/cp-node/fs/get-boundary-beziers-between.spec.ts +68 -3
- package/__tests__/cp-node/fs/get-boundary-beziers-to-next.spec.ts +41 -3
- package/__tests__/cp-node/fs/get-boundary-distance-to-next.spec.ts +20 -3
- package/__tests__/cp-node/fs/get-branch-beziers.spec.ts +42 -3
- package/__tests__/cp-node/fs/get-branch.spec.ts +60 -3
- package/__tests__/cp-node/fs/get-cp-node-ordering.spec.ts +19 -3
- package/__tests__/cp-node/fs/get-distance-to-next.spec.ts +37 -4
- package/__tests__/cp-node/fs/get-edge-direction.spec.ts +50 -3
- package/__tests__/cp-node/fs/get-first-exit.spec.ts +78 -3
- package/__tests__/cp-node/fs/get-hole-closers.spec.ts +32 -3
- package/__tests__/cp-node/fs/get-implied-boundary-bezier-between.spec.ts +48 -3
- package/__tests__/cp-node/fs/get-mat-curve-between.spec.ts +77 -3
- package/__tests__/cp-node/fs/get-mat-curve-to-next.spec.ts +17 -4
- package/__tests__/cp-node/fs/get-mat-curves-between.spec.ts +38 -3
- package/__tests__/cp-node/fs/get-salience.spec.ts +68 -3
- package/__tests__/cp-node/fs/get-vertex-forward-children.spec.ts +40 -3
- package/__tests__/cp-node/fs/insert-cp-node.spec.ts +87 -3
- package/__tests__/cp-node/fs/is-special.spec.ts +1 -1
- package/__tests__/cp-node/fs/remove-cp-node.spec.ts +42 -3
- package/__tests__/find-2-prong/calc-seperation-tolerance.spec.ts +46 -0
- package/__tests__/find-2-prong/get-medial/dd-get-medial-point-coeffs-same-curve.spec.ts +7 -5
- package/__tests__/find-2-prong/get-medial/dd-get-medial-point-coeffs.spec.ts +4 -2
- package/__tests__/find-2-prong/get-medial/get-closest-points.spec.ts +1 -1
- package/__tests__/floyd-warshall/get-graph.spec.ts +100 -0
- package/__tests__/get-mats-with-hole.ts +28 -0
- package/__tests__/get-mats1.spec.ts +61 -0
- package/__tests__/get-mats1.ts +75 -67
- package/__tests__/helpers/cp-node-by-id.ts +27 -0
- package/__tests__/helpers/expect-point-close.ts +42 -0
- package/__tests__/mat/hausdorff-distance-one-sided-exceeds.spec.ts +129 -0
- package/__tests__/mat/simplify-mat.spec.ts +85 -0
- package/__tests__/reconstruct-from-mat/reconstruct-from-mat.spec.ts +39 -0
- package/__tests__/specific-cases/test-svgs/achispado.svg +14 -0
- package/__tests__/utils/get-beziers-from-tangents.spec.ts +142 -0
- package/browser/index.js +17882 -13800
- package/browser/index.min.js +1 -1
- package/node/add-n-prong.ts/join-spokes.js +3 -2
- package/node/add-n-prong.ts/join-spokes.js.map +1 -1
- package/node/closest-boundary-point/cull-curve-pieces.d.ts +21 -0
- package/node/closest-boundary-point/cull-curve-pieces.js +40 -0
- package/node/closest-boundary-point/cull-curve-pieces.js.map +1 -0
- package/node/closest-boundary-point/get-close-boundary-points-certified.js +5 -2
- package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
- package/node/closest-boundary-point/get-endpoint-info.d.ts +39 -0
- package/node/closest-boundary-point/get-endpoint-info.js +78 -0
- package/node/closest-boundary-point/get-endpoint-info.js.map +1 -0
- package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js +5 -19
- package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js.map +1 -1
- package/node/closest-boundary-point/root-interval-to-distance-squared-interval.d.ts +17 -5
- package/node/closest-boundary-point/root-interval-to-distance-squared-interval.js +37 -50
- package/node/closest-boundary-point/root-interval-to-distance-squared-interval.js.map +1 -1
- package/node/corner/get-corner.d.ts +18 -1
- package/node/corner/get-corner.js +8 -1
- package/node/corner/get-corner.js.map +1 -1
- package/node/corner/get-interface-ccw.js.map +1 -1
- package/node/cp-node/cp-node.d.ts +4 -3
- package/node/cp-node/fs/enhance-cp-node.d.ts +9 -9
- package/node/cp-node/fs/get-all-on-loop-by-loop.js +0 -4
- package/node/cp-node/fs/get-all-on-loop-by-loop.js.map +1 -1
- package/node/cp-node/fs/get-angle-between-mat-curves.d.ts +1 -1
- package/node/cp-node/fs/get-angle-between-mat-curves.js +7 -4
- package/node/cp-node/fs/get-angle-between-mat-curves.js.map +1 -1
- package/node/cp-node/fs/get-boundary-beziers-between.d.ts +6 -4
- package/node/cp-node/fs/get-boundary-beziers-between.js +6 -4
- package/node/cp-node/fs/get-boundary-beziers-between.js.map +1 -1
- package/node/cp-node/fs/get-branch-beziers.d.ts +2 -1
- package/node/cp-node/fs/get-branch-beziers.js +3 -2
- package/node/cp-node/fs/get-branch-beziers.js.map +1 -1
- package/node/cp-node/fs/get-branch.js +1 -2
- package/node/cp-node/fs/get-branch.js.map +1 -1
- package/node/cp-node/fs/get-distance-to-next.js +4 -2
- package/node/cp-node/fs/get-distance-to-next.js.map +1 -1
- package/node/cp-node/fs/get-edge-direction.js +3 -2
- package/node/cp-node/fs/get-edge-direction.js.map +1 -1
- package/node/cp-node/fs/get-first-exit.d.ts +7 -3
- package/node/cp-node/fs/get-first-exit.js +13 -11
- package/node/cp-node/fs/get-first-exit.js.map +1 -1
- package/node/cp-node/fs/get-implied-boundary-bezier-between.d.ts +10 -2
- package/node/cp-node/fs/get-implied-boundary-bezier-between.js +11 -54
- package/node/cp-node/fs/get-implied-boundary-bezier-between.js.map +1 -1
- package/node/cp-node/fs/get-mat-curve-between.d.ts +5 -3
- package/node/cp-node/fs/get-mat-curve-between.js +6 -49
- package/node/cp-node/fs/get-mat-curve-between.js.map +1 -1
- package/node/cp-node/fs/get-mat-curve-to-next.d.ts +1 -1
- package/node/cp-node/fs/get-mat-curves-between.d.ts +8 -0
- package/node/cp-node/fs/get-mat-curves-between.js +9 -2
- package/node/cp-node/fs/get-mat-curves-between.js.map +1 -1
- package/node/cp-node/fs/get-real-prong-count.d.ts +2 -1
- package/node/cp-node/fs/get-real-prong-count.js +11 -5
- package/node/cp-node/fs/get-real-prong-count.js.map +1 -1
- package/node/cp-node/fs/get-salience.d.ts +10 -0
- package/node/cp-node/fs/get-salience.js +17 -1
- package/node/cp-node/fs/get-salience.js.map +1 -1
- package/node/cp-node/fs/is-fully-terminating.d.ts +4 -2
- package/node/cp-node/fs/is-fully-terminating.js +6 -17
- package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
- package/node/cp-node/fs/is-on-same-circle.d.ts +3 -0
- package/node/cp-node/fs/is-on-same-circle.js +4 -4
- package/node/cp-node/fs/is-on-same-circle.js.map +1 -1
- package/node/cp-node/fs/is-on-same-loop.d.ts +1 -1
- package/node/cp-node/fs/is-special.d.ts +7 -0
- package/node/cp-node/fs/is-special.js +9 -2
- package/node/cp-node/fs/is-special.js.map +1 -1
- package/node/cp-node/fs/is-vertex.d.ts +1 -1
- package/node/cp-node/fs/traverse-edges.d.ts +7 -3
- package/node/cp-node/fs/traverse-edges.js +7 -3
- package/node/cp-node/fs/traverse-edges.js.map +1 -1
- package/node/cp-node/stringification/from-stringifyable.d.ts +2 -2
- package/node/cp-node/stringification/from-stringifyable.js +17 -1
- package/node/cp-node/stringification/from-stringifyable.js.map +1 -1
- package/node/cp-node/stringification/to-stringifyable.d.ts +3 -3
- package/node/cp-node/stringification/to-stringifyable.js +3 -3
- package/node/debug/debug.d.ts +26 -3
- package/node/debug/debug.js +16 -5
- package/node/debug/debug.js.map +1 -1
- package/node/find-2-prong/add-2-prong.js +7 -9
- package/node/find-2-prong/add-2-prong.js.map +1 -1
- package/node/find-2-prong/calc-seperation-tolerance.d.ts +28 -5
- package/node/find-2-prong/calc-seperation-tolerance.js +32 -89
- package/node/find-2-prong/calc-seperation-tolerance.js.map +1 -1
- package/node/find-2-prong/find-2-prong.js +8 -10
- package/node/find-2-prong/find-2-prong.js.map +1 -1
- package/node/find-2-prong/find-and-add-2-prongs.js +2 -2
- package/node/find-2-prong/find-and-add-2-prongs.js.map +1 -1
- package/node/find-2-prong/get-medial/get-antipodal-points.d.ts +1 -2
- package/node/find-2-prong/get-medial/get-antipodal-points.js +2 -3
- package/node/find-2-prong/get-medial/get-antipodal-points.js.map +1 -1
- package/node/find-2-prong/get-medial/get-closest-points.d.ts +1 -8
- package/node/find-2-prong/get-medial/get-closest-points.js +4 -40
- package/node/find-2-prong/get-medial/get-closest-points.js.map +1 -1
- package/node/find-2-prong/reduce-radius.d.ts +1 -1
- package/node/find-2-prong/reduce-radius.js +6 -3
- package/node/find-2-prong/reduce-radius.js.map +1 -1
- package/node/find-3-prong/calc-better-x.js +1 -1
- package/node/find-3-prong/calc-better-x.js.map +1 -1
- package/node/find-3-prong/find-3-prong-for-delta3s.d.ts +3 -2
- package/node/find-3-prong/find-3-prong-for-delta3s.js +36 -42
- package/node/find-3-prong/find-3-prong-for-delta3s.js.map +1 -1
- package/node/find-3-prong/find-3-prong.js +3 -1
- package/node/find-3-prong/find-3-prong.js.map +1 -1
- package/node/find-3-prong/find-and-add-3-prongs.js +16 -0
- package/node/find-3-prong/find-and-add-3-prongs.js.map +1 -1
- package/node/find-mat/create-initial-cp-tree.js +2 -2
- package/node/find-mat/create-initial-cp-tree.js.map +1 -1
- package/node/find-mat/find-mat.js +3 -4
- package/node/find-mat/find-mat.js.map +1 -1
- package/node/find-mat/find-mats.d.ts +6 -12
- package/node/find-mat/find-mats.js +10 -27
- package/node/find-mat/find-mats.js.map +1 -1
- package/node/find-mat/get-dull-corners-on-loop.js +2 -2
- package/node/find-mat/get-dull-corners-on-loop.js.map +1 -1
- package/node/find-mat/get-for-1-prongs-on-loop.js +36 -8
- package/node/find-mat/get-for-1-prongs-on-loop.js.map +1 -1
- package/node/find-mat/get-meta.d.ts +14 -4
- package/node/find-mat/get-meta.js +30 -24
- package/node/find-mat/get-meta.js.map +1 -1
- package/node/find-mat/get-sharp-corners.js +2 -2
- package/node/find-mat/get-sharp-corners.js.map +1 -1
- package/node/find-mat/mat-options.d.ts +2 -2
- package/node/floyd-warshall/get-graph.d.ts +12 -1
- package/node/floyd-warshall/get-graph.js +41 -38
- package/node/floyd-warshall/get-graph.js.map +1 -1
- package/node/geometry/get-bounding-box-.d.ts +16 -2
- package/node/geometry/get-bounding-box-.js +5 -2
- package/node/geometry/get-bounding-box-.js.map +1 -1
- package/node/geometry/get-closest-square-distance-to-rect.d.ts +3 -0
- package/node/geometry/get-closest-square-distance-to-rect.js +7 -5
- package/node/geometry/get-closest-square-distance-to-rect.js.map +1 -1
- package/node/geometry/get-closest-squared-distance-to-rotated-rect.d.ts +4 -0
- package/node/geometry/get-closest-squared-distance-to-rotated-rect.js +12 -5
- package/node/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -1
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js +1 -2
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js.map +1 -1
- package/node/index.d.ts +3 -2
- package/node/index.js +2 -1
- package/node/index.js.map +1 -1
- package/node/mat/clone-mat.d.ts +9 -0
- package/node/mat/clone-mat.js +17 -0
- package/node/mat/clone-mat.js.map +1 -0
- package/node/mat/clone-meta.d.ts +12 -0
- package/node/mat/clone-meta.js +24 -0
- package/node/mat/clone-meta.js.map +1 -0
- package/node/mat/get-boundary-piece-beziers.d.ts +5 -0
- package/node/mat/get-boundary-piece-beziers.js +7 -93
- package/node/mat/get-boundary-piece-beziers.js.map +1 -1
- package/node/mat/get-closeby-cp-if-exist.js +2 -1
- package/node/mat/get-closeby-cp-if-exist.js.map +1 -1
- package/node/mat/get-largest-3-prong.d.ts +6 -0
- package/node/mat/get-largest-3-prong.js +8 -5
- package/node/mat/get-largest-3-prong.js.map +1 -1
- package/node/mat/get-largest-vertex.d.ts +15 -1
- package/node/mat/get-largest-vertex.js +20 -7
- package/node/mat/get-largest-vertex.js.map +1 -1
- package/node/mat/hausdorff-distance-one-sided-exceeds.d.ts +79 -0
- package/node/mat/hausdorff-distance-one-sided-exceeds.js +251 -0
- package/node/mat/hausdorff-distance-one-sided-exceeds.js.map +1 -0
- package/node/mat/mat-meta.d.ts +0 -6
- package/node/mat/simplify-mat.d.ts +25 -8
- package/node/mat/simplify-mat.js +182 -53
- package/node/mat/simplify-mat.js.map +1 -1
- package/node/mat/trim-mat.d.ts +4 -2
- package/node/mat/trim-mat.js +3 -1
- package/node/mat/trim-mat.js.map +1 -1
- package/node/point-on-shape/get-boundary-tangent-line.d.ts +19 -0
- package/node/point-on-shape/get-boundary-tangent-line.js +33 -0
- package/node/point-on-shape/get-boundary-tangent-line.js.map +1 -0
- package/node/point-on-shape/get-osculating-circle.d.ts +6 -4
- package/node/point-on-shape/get-osculating-circle.js +6 -4
- package/node/point-on-shape/get-osculating-circle.js.map +1 -1
- package/node/point-on-shape/get-pos-corner.js +2 -2
- package/node/point-on-shape/get-pos-corner.js.map +1 -1
- package/node/point-on-shape/point-on-shape.d.ts +5 -0
- package/node/reconstruct-from-mat/reconstruct-from-mat.js +20 -80
- package/node/reconstruct-from-mat/reconstruct-from-mat.js.map +1 -1
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.d.ts +4 -0
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js +4 -0
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js.map +1 -1
- package/node/sat/cull.d.ts +7 -6
- package/node/sat/cull.js +13 -16
- package/node/sat/cull.js.map +1 -1
- package/node/sat/get-sat-culls.d.ts +12 -2
- package/node/sat/get-sat-culls.js +21 -16
- package/node/sat/get-sat-culls.js.map +1 -1
- package/node/svg/get-shape-bounds.d.ts +1 -12
- package/node/svg/get-shape-bounds.js +2 -3
- package/node/svg/get-shape-bounds.js.map +1 -1
- package/node/sweep-line/sweep-line.js.map +1 -1
- package/node/utils/get-beziers-from-tangents.d.ts +28 -0
- package/node/utils/get-beziers-from-tangents.js +92 -0
- package/node/utils/get-beziers-from-tangents.js.map +1 -0
- package/node/vertex/remove-vertex.d.ts +5 -3
- package/node/vertex/remove-vertex.js +5 -3
- package/node/vertex/remove-vertex.js.map +1 -1
- package/package.json +16 -16
- package/qv-infinite-loop.md +120 -0
- package/src/add-n-prong.ts/join-spokes.ts +4 -2
- package/src/closest-boundary-point/cull-curve-pieces.ts +49 -0
- package/src/closest-boundary-point/get-close-boundary-points-certified.ts +5 -2
- package/src/closest-boundary-point/get-endpoint-info.ts +96 -0
- package/src/closest-boundary-point/get-potential-closest-points-on-curve-certified.ts +5 -23
- package/src/closest-boundary-point/root-interval-to-distance-squared-interval.ts +42 -60
- package/src/corner/get-corner.ts +10 -1
- package/src/corner/get-interface-ccw.ts +2 -2
- package/src/cp-node/cp-node.ts +4 -3
- package/src/cp-node/fs/get-all-on-loop-by-loop.ts +0 -4
- package/src/cp-node/fs/get-angle-between-mat-curves.ts +9 -5
- package/src/cp-node/fs/get-boundary-beziers-between.ts +10 -8
- package/src/cp-node/fs/get-branch-beziers.ts +3 -2
- package/src/cp-node/fs/get-branch.ts +1 -2
- package/src/cp-node/fs/get-distance-to-next.ts +4 -2
- package/src/cp-node/fs/get-edge-direction.ts +4 -2
- package/src/cp-node/fs/get-first-exit.ts +15 -14
- package/src/cp-node/fs/get-implied-boundary-bezier-between.ts +18 -70
- package/src/cp-node/fs/get-mat-curve-between.ts +10 -67
- package/src/cp-node/fs/get-mat-curves-between.ts +9 -2
- package/src/cp-node/fs/get-real-prong-count.ts +11 -7
- package/src/cp-node/fs/get-salience.ts +15 -2
- package/src/cp-node/fs/is-fully-terminating.ts +6 -22
- package/src/cp-node/fs/is-on-same-circle.ts +6 -7
- package/src/cp-node/fs/is-on-same-loop.ts +2 -2
- package/src/cp-node/fs/is-special.ts +11 -6
- package/src/cp-node/fs/is-vertex.ts +1 -1
- package/src/cp-node/fs/traverse-edges.ts +8 -4
- package/src/cp-node/stringification/from-stringifyable.ts +75 -58
- package/src/cp-node/stringification/to-stringifyable.ts +3 -3
- package/src/debug/debug.ts +44 -8
- package/src/find-2-prong/add-2-prong.ts +9 -11
- package/src/find-2-prong/calc-seperation-tolerance.ts +34 -115
- package/src/find-2-prong/find-2-prong.ts +9 -11
- package/src/find-2-prong/find-and-add-2-prongs.ts +2 -2
- package/src/find-2-prong/get-medial/get-antipodal-points.ts +1 -3
- package/src/find-2-prong/get-medial/get-closest-points.ts +6 -51
- package/src/find-2-prong/reduce-radius.ts +6 -4
- package/src/find-3-prong/calc-better-x.ts +2 -2
- package/src/find-3-prong/find-3-prong-for-delta3s.ts +197 -214
- package/src/find-3-prong/find-3-prong.ts +54 -51
- package/src/find-3-prong/find-and-add-3-prongs.ts +20 -1
- package/src/find-mat/create-initial-cp-tree.ts +2 -2
- package/src/find-mat/find-mat.ts +4 -6
- package/src/find-mat/find-mats.ts +83 -105
- package/src/find-mat/get-dull-corners-on-loop.ts +2 -2
- package/src/find-mat/get-for-1-prongs-on-loop.ts +40 -8
- package/src/find-mat/get-meta.ts +34 -39
- package/src/find-mat/get-sharp-corners.ts +2 -2
- package/src/find-mat/mat-options.ts +2 -2
- package/src/floyd-warshall/get-graph.ts +46 -47
- package/src/geometry/get-bounding-box-.ts +5 -2
- package/src/geometry/get-closest-square-distance-to-rect.ts +7 -7
- package/src/geometry/get-closest-squared-distance-to-rotated-rect.ts +15 -13
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.ts +1 -2
- package/src/index.ts +3 -2
- package/src/mat/clone-mat.ts +9 -3
- package/src/mat/clone-meta.ts +8 -0
- package/src/mat/get-boundary-piece-beziers.ts +16 -117
- package/src/mat/get-closeby-cp-if-exist.ts +3 -1
- package/src/mat/get-largest-3-prong.ts +9 -6
- package/src/mat/get-largest-vertex.ts +25 -9
- package/src/mat/hausdorff-distance-one-sided-exceeds.ts +314 -0
- package/src/mat/mat-meta.ts +0 -9
- package/src/mat/simplify-mat.ts +254 -116
- package/src/mat/trim-mat.ts +6 -4
- package/src/point-on-shape/get-boundary-tangent-line.ts +36 -0
- package/src/point-on-shape/get-osculating-circle.ts +7 -5
- package/src/point-on-shape/get-pos-corner.ts +2 -2
- package/src/point-on-shape/point-on-shape.ts +5 -0
- package/src/reconstruct-from-mat/reconstruct-from-mat.ts +22 -111
- package/src/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.ts +4 -0
- package/src/sat/cull.ts +16 -20
- package/src/sat/get-sat-culls.ts +28 -23
- package/src/svg/get-shape-bounds.ts +2 -3
- package/src/sweep-line/sweep-line.ts +1 -1
- package/src/utils/deg-to-rad.ts +4 -2
- package/src/utils/get-beziers-from-tangents.ts +110 -0
- package/src/utils/map-map.ts +1 -1
- package/src/utils/rad-to-deg.ts +4 -1
- package/src/vertex/remove-vertex.ts +5 -3
- package/webpack.config.cjs +7 -2
- package/__tests__/cp-node/fs/get-distance-between.spec.ts +0 -7
- package/__tests__/cp-node/fs/get-terminating-on-circle.spec.ts +0 -24
- package/__tests__/cp-node/fs/is-single-3-prong.spec.ts +0 -17
- package/__tests__/cp-node/fs/iterate-all-on-loop.spec.ts +0 -17
- package/__tests__/cp-node/fs/traverse-all-forward.spec.ts +0 -14
- package/node/closest-boundary-point/cull-bezier-pieces-1.d.ts +0 -9
- package/node/closest-boundary-point/cull-bezier-pieces-1.js +0 -17
- package/node/closest-boundary-point/cull-bezier-pieces-1.js.map +0 -1
- package/node/closest-boundary-point/cull-by-loose-bounding-box.d.ts +0 -13
- package/node/closest-boundary-point/cull-by-loose-bounding-box.js +0 -27
- package/node/closest-boundary-point/cull-by-loose-bounding-box.js.map +0 -1
- package/node/closest-boundary-point/cull-by-tight-boundary-box.d.ts +0 -11
- package/node/closest-boundary-point/cull-by-tight-boundary-box.js +0 -27
- package/node/closest-boundary-point/cull-by-tight-boundary-box.js.map +0 -1
- package/node/cp-node/fs/find-first.d.ts +0 -10
- package/node/cp-node/fs/find-first.js +0 -19
- package/node/cp-node/fs/find-first.js.map +0 -1
- package/node/debug/functions/check-ordering.d.ts +0 -4
- package/node/debug/functions/check-ordering.js +0 -43
- package/node/debug/functions/check-ordering.js.map +0 -1
- package/node/find-2-prong/cull-bezier-pieces.d.ts +0 -13
- package/node/find-2-prong/cull-bezier-pieces.js +0 -43
- package/node/find-2-prong/cull-bezier-pieces.js.map +0 -1
- package/node/floyd-warshall/get-hole-closer-pairs.d.ts +0 -8
- package/node/floyd-warshall/get-hole-closer-pairs.js +0 -27
- package/node/floyd-warshall/get-hole-closer-pairs.js.map +0 -1
- package/node/utils/dual-set.d.ts +0 -27
- package/node/utils/dual-set.js +0 -55
- package/node/utils/dual-set.js.map +0 -1
- package/node/utils/tri-map.d.ts +0 -27
- package/node/utils/tri-map.js +0 -49
- package/node/utils/tri-map.js.map +0 -1
- package/src/closest-boundary-point/cull-bezier-pieces-1.ts +0 -36
- package/src/closest-boundary-point/cull-by-loose-bounding-box.ts +0 -42
- package/src/closest-boundary-point/cull-by-tight-boundary-box.ts +0 -43
- package/src/closest-boundary-point/get-p-from-box.ts +0 -14
- package/src/cp-node/fs/add-distance-from.ts +0 -49
- package/src/cp-node/fs/get-distance-between.ts +0 -16
- package/src/cp-node/fs/get-terminating-on-circle.ts +0 -24
- package/src/cp-node/fs/is-single-3-prong.ts +0 -15
- package/src/cp-node/fs/iterate-all-on-loop.ts +0 -15
- package/src/cp-node/fs/traverse-all-forward.ts +0 -24
- package/src/debug/functions/draw/draw-beziers-as-single-path.ts +0 -40
- package/src/debug/functions/draw/draw-disk.ts +0 -34
- package/src/debug/functions/draw/xmlns.ts +0 -5
- package/src/find-2-prong/cull-bezier-pieces.ts +0 -61
- package/src/find-2-prong/find-and-add-2-prong.ts +0 -30
- package/src/find-2-prong/get-medial/get-closest-points-d.ts +0 -213
- package/src/find-2-prong/x-for-debugging.ts +0 -13
- package/src/floyd-warshall/get-hole-closer-pairs.ts +0 -35
- package/src/mat/get-two-prong-type.ts +0 -13
- package/src/point-on-shape/is-pos-dull-corner.ts +0 -18
- package/src/point-on-shape/is-pos-quite-dull-corner.ts +0 -18
- package/src/point-on-shape/is-pos-quite-sharp-corner.ts +0 -18
- package/src/point-on-shape/pos-to-human-string.ts +0 -18
- package/src/sweep-line/are-boxes-intersecting.ts +0 -37
|
@@ -1,51 +1,54 @@
|
|
|
1
|
-
import type { CpNode } from '../cp-node/cp-node.js';
|
|
2
|
-
import type { ThreeProngInfo } from './three-prong-info.js';
|
|
3
|
-
import { find3ProngForDelta3s } from './find-3-prong-for-delta3s.js';
|
|
4
|
-
import { getBoundaryPieceBeziers } from '../mat/get-boundary-piece-beziers.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Find and return a 3-prong from the given boundary piece.
|
|
9
|
-
*
|
|
10
|
-
* @param δs A boundary piece
|
|
11
|
-
* @param maxCoordPowerOf2 The maximum coordinate power of 2 value used to
|
|
12
|
-
* calculate floating point tolerances.
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
1
|
+
import type { CpNode } from '../cp-node/cp-node.js';
|
|
2
|
+
import type { ThreeProngInfo } from './three-prong-info.js';
|
|
3
|
+
import { find3ProngForDelta3s } from './find-3-prong-for-delta3s.js';
|
|
4
|
+
import { getBoundaryPieceBeziers } from '../mat/get-boundary-piece-beziers.js';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Find and return a 3-prong from the given boundary piece.
|
|
9
|
+
*
|
|
10
|
+
* @param δs A boundary piece
|
|
11
|
+
* @param maxCoordPowerOf2 The maximum coordinate power of 2 value used to
|
|
12
|
+
* calculate floating point tolerances.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
function find3Prong(
|
|
18
|
+
δs: [CpNode, CpNode][],
|
|
19
|
+
maxCoordPowerOf2: number): ThreeProngInfo {
|
|
20
|
+
|
|
21
|
+
// FUTURE if `δs.length > (some threshold (say 4 or 5))` then add two-prongs
|
|
22
|
+
// to reduced the number of permutations required
|
|
23
|
+
// if (δs.length > 3) { console.log(δs.length); }
|
|
24
|
+
|
|
25
|
+
const curvePiecess = δs.map(getBoundaryPieceBeziers);
|
|
26
|
+
// all the curve pieces of all the boundary pieces (for culling against)
|
|
27
|
+
const allCurvePieces = curvePiecess.flat();
|
|
28
|
+
|
|
29
|
+
// The best candidate amongst the different 'permutations' of the given δs.
|
|
30
|
+
let threeProng: ThreeProngInfo;
|
|
31
|
+
|
|
32
|
+
let smallestError = Infinity;
|
|
33
|
+
for (let i=1; i<δs.length - 1; i++) {
|
|
34
|
+
for (let k=0; k<3; k++) {
|
|
35
|
+
const r = find3ProngForDelta3s(
|
|
36
|
+
δs, i, k, curvePiecess, allCurvePieces, maxCoordPowerOf2
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
if (r === undefined) { continue; }
|
|
40
|
+
|
|
41
|
+
const { error, threeProngInfo } = r;
|
|
42
|
+
|
|
43
|
+
if (error < smallestError) {
|
|
44
|
+
smallestError = error;
|
|
45
|
+
threeProng = threeProngInfo;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return threeProng!;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
export { find3Prong }
|
|
@@ -36,12 +36,31 @@ function findAndAdd3Prongs(
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
const addedCpNodes: CpNode[][] = [];
|
|
39
|
+
let maxIterations: number | undefined = undefined;
|
|
40
|
+
let iterations = 0;
|
|
39
41
|
do {
|
|
40
42
|
if (cpStart === undefined) { continue; }
|
|
41
43
|
const visitedCps = traverseCp(cpStart);
|
|
42
|
-
|
|
44
|
+
|
|
43
45
|
if (visitedCps.length <= 2) { break; }
|
|
44
46
|
|
|
47
|
+
// Each added 3-prong splits off a part of the traversed face so the
|
|
48
|
+
// number of iterations is bounded by the initial face size. If the
|
|
49
|
+
// face does not shrink (e.g. a geometrically invalid vertex causing the
|
|
50
|
+
// same 3-prong to be re-inserted again and again) fail loudly instead
|
|
51
|
+
// of looping forever.
|
|
52
|
+
if (maxIterations === undefined) {
|
|
53
|
+
maxIterations = 2*visitedCps.length + 16;
|
|
54
|
+
}
|
|
55
|
+
if (++iterations > maxIterations) {
|
|
56
|
+
const pos = cpStart.pointOnShape;
|
|
57
|
+
throw new Error(
|
|
58
|
+
`findAndAdd3Prongs: no convergence after ${iterations} iterations ` +
|
|
59
|
+
`(face with ${visitedCps.length} vertices, start CpNode id ${cpStart.id} ` +
|
|
60
|
+
`on curve ${pos.curve.idx} at t = ${pos.t}, radius ${pos.circle.radius})`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
45
64
|
const { closeBysFor3Prong, cpNodes } = findAndAdd3Prong(meta, visitedCps);
|
|
46
65
|
|
|
47
66
|
addedCpNodes.push(cpNodes);
|
|
@@ -41,8 +41,8 @@ function createInitialCpTree(
|
|
|
41
41
|
const pos1: PointOnShape = { ...ppos, curve, t: 1, circle, order: -1, order2: 0 };
|
|
42
42
|
const pos2: PointOnShape = { ...ppos, curve: curve.next, t: 0, circle, order: +1, order2: 0 };
|
|
43
43
|
|
|
44
|
-
cpNode1 = insertCpNode(true, false, false, cpTree, pos1, cpNode2, undefined,
|
|
45
|
-
cpNode2 = insertCpNode(true, false, false, cpTree, pos2, cpNode1, undefined,
|
|
44
|
+
cpNode1 = insertCpNode(true, false, false, cpTree, pos1, cpNode2, undefined, lastInsertId)!;
|
|
45
|
+
cpNode2 = insertCpNode(true, false, false, cpTree, pos2, cpNode1, undefined, lastInsertId)!;
|
|
46
46
|
|
|
47
47
|
cpNode1.prevOnCircle = cpNode2;
|
|
48
48
|
cpNode2.prevOnCircle = cpNode1;
|
package/src/find-mat/find-mat.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { MatOptions } from './mat-options.js';
|
|
|
8
8
|
import type { MatMeta } from '../mat/mat-meta.js';
|
|
9
9
|
import { findAndAdd3ProngsOnLoop } from '../find-3-prong/find-and-add-3-prongs-on-loop.js';
|
|
10
10
|
import { createInitialCpTree } from './create-initial-cp-tree.js';
|
|
11
|
-
import {
|
|
11
|
+
import { addDebugElems, addDebugInfo1, addDebugInfo2, addDebugInfo3, addDebugInfo4 } from './get-meta.js';
|
|
12
12
|
import { getSharpCornersOnLoop } from './get-sharp-corners.js';
|
|
13
13
|
import { getDullCornersOnLoop } from './get-dull-corners-on-loop.js';
|
|
14
14
|
import { findAndAdd2ProngsOnAllLoops } from '../find-2-prong/find-and-add-2-prongs-on-all-loops.js';
|
|
@@ -16,7 +16,6 @@ import { getFor2ProngsOnLoop } from './get-for-2-prongs-on-loop.js';
|
|
|
16
16
|
import { getFor1ProngsOnLoop } from './get-for-1-prongs-on-loop.js';
|
|
17
17
|
import { findAndAddHoleClosing2Prongs } from '../find-2-prong/find-and-add-hole-closing-2-prongs.js';
|
|
18
18
|
import { getShapeBounds } from '../svg/get-shape-bounds.js';
|
|
19
|
-
import { checkOrdering } from '../debug/functions/check-ordering.js';
|
|
20
19
|
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -34,6 +33,7 @@ function findMat(
|
|
|
34
33
|
} {
|
|
35
34
|
|
|
36
35
|
addDebugInfo1();
|
|
36
|
+
addDebugElems(loops);
|
|
37
37
|
|
|
38
38
|
const { minBezLength, maxCurviness, maxLength, angleIncrement } = options;
|
|
39
39
|
|
|
@@ -51,10 +51,9 @@ function findMat(
|
|
|
51
51
|
const lastInsertId = { id: 0 };
|
|
52
52
|
const cpTrees = createInitialCpTree(loops, sharpCornersPerLoop, lastInsertId);
|
|
53
53
|
|
|
54
|
-
const _meta = getPartialMeta(loops);
|
|
55
54
|
const meta: MatMeta = {
|
|
56
55
|
maxCoordPowerOf2, squaredDiagonalLength, loops, cpTrees,// pointToCpNode,
|
|
57
|
-
lastInsertId
|
|
56
|
+
lastInsertId
|
|
58
57
|
};
|
|
59
58
|
|
|
60
59
|
let cpNode: CpNode | undefined;
|
|
@@ -89,7 +88,6 @@ function findMat(
|
|
|
89
88
|
if (_debug_.directives.stopAfterThreeProngs) { return { cpNode, meta }; }
|
|
90
89
|
}
|
|
91
90
|
|
|
92
|
-
// if (cpNode !== undefined) { checkOrdering(meta, cpNode); }
|
|
93
91
|
|
|
94
92
|
const mat = { cpNode, meta };
|
|
95
93
|
|
|
@@ -105,4 +103,4 @@ export { findMat }
|
|
|
105
103
|
|
|
106
104
|
/** Curvilinear Shape Features (CSFs) */
|
|
107
105
|
// const csfs = getCsfs(meta, minBezLength, loops);
|
|
108
|
-
// const ligatures = getLigatures(meta, csfs);
|
|
106
|
+
// const ligatures = getLigatures(meta, csfs);
|
|
@@ -1,105 +1,83 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getLoopsMetrics } from '../loop/get-max-coordinate.js';
|
|
3
|
-
import { Mat } from '../mat/mat.js';
|
|
4
|
-
import { simplifyMat } from '../mat/simplify-mat.js';
|
|
5
|
-
import { toScaleAxis } from '../sat/to-scale-axis.js';
|
|
6
|
-
import { clipOptions } from './clip-options.js';
|
|
7
|
-
import { findMat } from './find-mat.js';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Returns an SVG path string representation of the given bezier loops.
|
|
90
|
-
* @param loops An array of loops having an array of bezier curves each given as
|
|
91
|
-
* an array of control points.
|
|
92
|
-
*/
|
|
93
|
-
function loopsToSvgPathStr(
|
|
94
|
-
loops: number[][][][]) {
|
|
95
|
-
|
|
96
|
-
let str = '';
|
|
97
|
-
for (const loop of loops) {
|
|
98
|
-
str = str + beziersToSvgPathStr(loop) + '\n';
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return str;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
export { findMats }
|
|
1
|
+
import { simplifyPaths } from 'flo-boolean';
|
|
2
|
+
import { getLoopsMetrics } from '../loop/get-max-coordinate.js';
|
|
3
|
+
import { Mat } from '../mat/mat.js';
|
|
4
|
+
import { simplifyMat } from '../mat/simplify-mat.js';
|
|
5
|
+
import { toScaleAxis } from '../sat/to-scale-axis.js';
|
|
6
|
+
import { clipOptions } from './clip-options.js';
|
|
7
|
+
import { findMat } from './find-mat.js';
|
|
8
|
+
import { resetDebugElems } from './get-meta.js';
|
|
9
|
+
import { defaultMatOptions, MatOptions } from './mat-options.js';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const { ceil, log2 } = Math;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Finds and returns the Medial Axis Transforms (MATs) from the given array of
|
|
17
|
+
* bezier loops representing shape boundaries.
|
|
18
|
+
*
|
|
19
|
+
* @param bezierLoops An array of (possibly intersecting) loops with each loop
|
|
20
|
+
* representing one or more piecewise smooth closed curves (i.e. shapes). Each
|
|
21
|
+
* loop consists of an array of beziers represented by an array of control
|
|
22
|
+
* points with 2,3 or 4 elements corresponding to linear, quadratic and cubic
|
|
23
|
+
* beziers respectively. Each point is a two-element array (ordered pair), the
|
|
24
|
+
* first of which is the x-coordinate and the second the y-coordinate.
|
|
25
|
+
*
|
|
26
|
+
* @param options the `MatOptions` (see there for a description of each option
|
|
27
|
+
* and its default), e.g. `maxCurviness` and `maxLength` together determine the
|
|
28
|
+
* accuracy of the MAT, `simplify` and `simplifyTolerance` control the
|
|
29
|
+
* simplification of the result and `applySat` and `satScale` whether and how
|
|
30
|
+
* the Scale Axis Transform is applied. Missing options take their defaults
|
|
31
|
+
* (`defaultMatOptions`) and all values are clipped to their allowed ranges.
|
|
32
|
+
*/
|
|
33
|
+
function findMats(
|
|
34
|
+
bezierLoops: number[][][][],
|
|
35
|
+
options?: MatOptions): Mat[] {
|
|
36
|
+
|
|
37
|
+
// if (typeof _debug_ !== 'undefined') { var timingStart = performance.now(); }
|
|
38
|
+
resetDebugElems();
|
|
39
|
+
const { maxCoordinate } = getLoopsMetrics(bezierLoops);
|
|
40
|
+
const maxCoordPowerOf2 = ceil(log2(maxCoordinate));
|
|
41
|
+
|
|
42
|
+
const options_: Required<MatOptions> = clipOptions(
|
|
43
|
+
maxCoordPowerOf2, {
|
|
44
|
+
...defaultMatOptions,
|
|
45
|
+
...(options || {})
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const {
|
|
49
|
+
applySat, simplify,
|
|
50
|
+
satScale, simplifyTolerance
|
|
51
|
+
} = options_;
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
const loopss = simplifyPaths(bezierLoops, {
|
|
55
|
+
forceOrientationNegative: true,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
const mats: Mat[] = [];
|
|
60
|
+
for (const loops of loopss) {
|
|
61
|
+
let mat = findMat(loops, maxCoordPowerOf2, options_);
|
|
62
|
+
if (mat === undefined) { continue; }
|
|
63
|
+
|
|
64
|
+
if (applySat) {
|
|
65
|
+
mat = toScaleAxis(mat, satScale);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (simplify) {
|
|
69
|
+
mat = simplifyMat(mat, simplifyTolerance)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
mats.push(mat);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// console.log(structuredClone(circumCenter.getStats()));
|
|
76
|
+
// circumCenter.resetStats();
|
|
77
|
+
|
|
78
|
+
return mats;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
export { findMats }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PrePointOnShape } from '../point-on-shape/point-on-shape.js';
|
|
2
2
|
import type { Loop } from 'flo-boolean';
|
|
3
3
|
import { controlPointLinesLength } from 'flo-bezier3';
|
|
4
|
-
import { getCorner } from '../corner/get-corner.js';
|
|
4
|
+
import { getCorner$ } from '../corner/get-corner.js';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
/** @internal */
|
|
@@ -20,7 +20,7 @@ function getDullCornersOnLoop(
|
|
|
20
20
|
|
|
21
21
|
const { next, ps } = curve;
|
|
22
22
|
|
|
23
|
-
if (getCorner(ps, next.ps).isQuiteDull) {
|
|
23
|
+
if (getCorner$(ps, next.ps).isQuiteDull) {
|
|
24
24
|
const p = ps[ps.length - 1];
|
|
25
25
|
const pDd = [[0,p[0]], [0,p[1]]];
|
|
26
26
|
|
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import type { Loop } from 'flo-boolean';
|
|
2
2
|
import type { PrePointOnShape } from '../point-on-shape/point-on-shape.js';
|
|
3
3
|
import { getCurvatureExtremaDd, controlPointLinesLength } from 'flo-bezier3';
|
|
4
|
+
import { distanceBetween } from 'flo-vector2d';
|
|
4
5
|
import { toP } from '../point-on-shape/to-p.js';
|
|
5
6
|
|
|
6
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
* Curvature maxima closer than this (in parameter space) to a curve endpoint
|
|
11
|
+
* are ignored - they are handled by the corner logic.
|
|
12
|
+
*/
|
|
13
|
+
const EDGE_T_TOLERANCE = 2**-20;
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
* Curvature maxima closer than this fraction of the curve's control polygon
|
|
17
|
+
* length to a curve endpoint are ignored. A curve with (near) coincident
|
|
18
|
+
* control points at an end has (near) zero speed there and its curvature
|
|
19
|
+
* blows up towards that end; the resulting "maximum" (that can be well
|
|
20
|
+
* inside the parameter tolerance above) is an artifact and not a feature of
|
|
21
|
+
* the shape.
|
|
22
|
+
*/
|
|
23
|
+
const EDGE_DISTANCE_TOLERANCE = 2**-20;
|
|
24
|
+
|
|
25
|
+
|
|
7
26
|
/**
|
|
8
27
|
* Get points of maximum curvature.
|
|
9
28
|
*
|
|
@@ -19,24 +38,37 @@ function getFor1ProngsOnLoop(
|
|
|
19
38
|
|
|
20
39
|
for (let i=0; i<loop.curves.length; i++) {
|
|
21
40
|
const curve = loop.curves[i];
|
|
41
|
+
const { ps } = curve;
|
|
22
42
|
|
|
23
|
-
|
|
43
|
+
const len = controlPointLinesLength(ps);
|
|
44
|
+
if (len < minBezLength) {
|
|
24
45
|
continue;
|
|
25
46
|
}
|
|
26
47
|
|
|
27
|
-
const
|
|
48
|
+
const pS = ps[0];
|
|
49
|
+
const pE = ps[ps.length-1];
|
|
50
|
+
const edgeDistanceTolerance = len * EDGE_DISTANCE_TOLERANCE;
|
|
51
|
+
|
|
52
|
+
for (const t of getCurvatureExtremaDd(ps).maxima) {
|
|
53
|
+
// keep away from edges (in parameter space)
|
|
54
|
+
if (t < EDGE_T_TOLERANCE || t > 1 - EDGE_T_TOLERANCE) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
28
57
|
|
|
29
|
-
poss.push(...getCurvatureExtremaDd(ps).maxima.map(t => {
|
|
30
58
|
const pDd = toP(ps, t);
|
|
31
59
|
const p = pDd.map(c => c[0] + c[1]);
|
|
32
60
|
|
|
33
|
-
|
|
34
|
-
|
|
61
|
+
// keep away from edges (in distance)
|
|
62
|
+
if (distanceBetween(p, pS) < edgeDistanceTolerance ||
|
|
63
|
+
distanceBetween(p, pE) < edgeDistanceTolerance) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
poss.push({ curve, t, isSource: true, p, pDd });
|
|
68
|
+
}
|
|
35
69
|
}
|
|
36
70
|
|
|
37
|
-
return poss
|
|
38
|
-
// keep away from edges
|
|
39
|
-
.filter(pos => pos.t > 2**-20 && pos.t < 2**-20);
|
|
71
|
+
return poss;
|
|
40
72
|
}
|
|
41
73
|
}
|
|
42
74
|
|
package/src/find-mat/get-meta.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { Debug } from '../debug/debug.js';
|
|
2
2
|
import type { Loop } from 'flo-boolean';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { getBoundingHull, getBoundingBoxTight } from 'flo-bezier3';
|
|
6
|
-
import { getBoundingBox$ } from '../geometry/get-bounding-box-.js';
|
|
3
|
+
import { getBoundingHull } from 'flo-bezier3';
|
|
4
|
+
import { getBoundingBox$, getBoundingBoxTight$ } from '../geometry/get-bounding-box-.js';
|
|
7
5
|
import { getCorner } from '../corner/get-corner.js';
|
|
6
|
+
import { createEmptyElems } from '../debug/debug.js';
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
/** @internal */
|
|
@@ -14,38 +13,41 @@ declare const _debug_: Debug;
|
|
|
14
13
|
let timingStart: number;
|
|
15
14
|
|
|
16
15
|
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
* Resets the generated debug `_debug_.elems` (if debug is enabled) so that
|
|
19
|
+
* they only reflect the current `findMats` call.
|
|
20
|
+
*/
|
|
21
|
+
function resetDebugElems() {
|
|
22
|
+
if (typeof _debug_ === 'undefined') { return; }
|
|
23
|
+
|
|
24
|
+
_debug_.elems = { ..._debug_.elems, ...createEmptyElems() };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
* Adds (if debug is enabled) the loose and tight bounding boxes, the bounding
|
|
31
|
+
* hulls and the sharp and dull corners of the given loops' curves to
|
|
32
|
+
* `_debug_.elems` for later inspection by consumers.
|
|
33
|
+
*/
|
|
34
|
+
function addDebugElems(loops: Loop[]) {
|
|
35
|
+
if (typeof _debug_ === 'undefined') { return; }
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
looseBoundingBoxes, tightBoundingBoxes, boundingHulls,
|
|
39
|
+
sharpCorners, dullCorners
|
|
40
|
+
} = _debug_.elems;
|
|
34
41
|
|
|
35
42
|
for (const loop of loops) {
|
|
36
43
|
for (const curve of loop.curves) {
|
|
37
44
|
const ps = curve.ps;
|
|
38
|
-
const hull = getBoundingHull(ps, true)!;
|
|
39
|
-
|
|
40
|
-
boundingHulls.push(hull);
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
looseBoundingBoxes.push(
|
|
46
|
+
boundingHulls.push(getBoundingHull(ps, true)!);
|
|
47
|
+
looseBoundingBoxes.push(getBoundingBox$(ps));
|
|
48
|
+
tightBoundingBoxes.push(getBoundingBoxTight$(ps));
|
|
44
49
|
|
|
45
|
-
const
|
|
46
|
-
tightBoundingBoxes.push(tightBoundingBox);
|
|
47
|
-
|
|
48
|
-
const corner = getCorner(curve.ps, curve.next.ps);
|
|
50
|
+
const corner = getCorner(ps, curve.next.ps);
|
|
49
51
|
if (corner.isQuiteSharp) {
|
|
50
52
|
sharpCorners.push(curve);
|
|
51
53
|
} else if (corner.isQuiteDull) {
|
|
@@ -53,14 +55,6 @@ function getPartialMeta(
|
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
looseBoundingBoxes,
|
|
59
|
-
tightBoundingBoxes,
|
|
60
|
-
boundingHulls,
|
|
61
|
-
sharpCorners,
|
|
62
|
-
dullCorners
|
|
63
|
-
}
|
|
64
58
|
}
|
|
65
59
|
|
|
66
60
|
|
|
@@ -102,7 +96,8 @@ function addDebugInfo4() {
|
|
|
102
96
|
|
|
103
97
|
|
|
104
98
|
export {
|
|
105
|
-
|
|
99
|
+
resetDebugElems,
|
|
100
|
+
addDebugElems,
|
|
106
101
|
addDebugInfo1,
|
|
107
102
|
addDebugInfo2,
|
|
108
103
|
addDebugInfo3,
|
|
@@ -2,7 +2,7 @@ import type { PrePointOnShape } from '../point-on-shape/point-on-shape.js';
|
|
|
2
2
|
import type { Loop } from 'flo-boolean';
|
|
3
3
|
import { controlPointLinesLength } from 'flo-bezier3';
|
|
4
4
|
import { toP } from '../point-on-shape/to-p.js';
|
|
5
|
-
import { getCorner } from '../corner/get-corner.js';
|
|
5
|
+
import { getCorner$ } from '../corner/get-corner.js';
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
/** @internal */
|
|
@@ -19,7 +19,7 @@ function getSharpCornersOnLoop(
|
|
|
19
19
|
continue;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
if (getCorner(curve.ps, curve.next.ps).isQuiteSharp) {
|
|
22
|
+
if (getCorner$(curve.ps, curve.next.ps).isQuiteSharp) {
|
|
23
23
|
const { ps } = curve;
|
|
24
24
|
|
|
25
25
|
const p = ps[ps.length - 1];
|
|
@@ -59,7 +59,7 @@ interface MatOptions {
|
|
|
59
59
|
*
|
|
60
60
|
* * Only applies if `simplify` is `true`
|
|
61
61
|
* * Defaults to `1/16`
|
|
62
|
-
* * The value is clipped in `[2**-
|
|
62
|
+
* * The value is clipped in `[2**-20,2**20]`
|
|
63
63
|
* * scaled to a 1024x1024 vector image size, i.e. a value of `1` on such
|
|
64
64
|
* a vector image will have a `1` pixel accuracy. If the vector is, say,
|
|
65
65
|
* 512x400 then the accuracy is scaled to `1/2` a pixel. This ensures
|
|
@@ -72,7 +72,7 @@ interface MatOptions {
|
|
|
72
72
|
*
|
|
73
73
|
* * it is not recommended to change this value
|
|
74
74
|
* * scaled to a 1024x1024 vector image size
|
|
75
|
-
* * Defaults to `1/
|
|
75
|
+
* * Defaults to `1/64`
|
|
76
76
|
*/
|
|
77
77
|
readonly minBezLength?: number;
|
|
78
78
|
|