flo-mat 4.0.3 → 4.1.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__/find-2-prong/get-medial/dd-get-medial-point-coeffs-same-curve.spec.ts +106 -0
- package/__tests__/find-2-prong/get-medial/dd-get-medial-point-coeffs.spec.ts +73 -0
- package/__tests__/find-2-prong/get-medial/get-closest-points.spec.ts +5 -2
- package/__tests__/helpers/close-to.ts +5 -5
- package/__tests__/helpers/jest.setup.ts +35 -0
- package/__tests__/specific-cases/load-svg/load-svg.ts +30 -0
- package/__tests__/specific-cases/specific-cases.spec.ts +168 -4
- package/__tests__/specific-cases/test-svgs/achispado.svg +5052 -0
- package/browser/index.js +16089 -16854
- package/browser/index.min.js +1 -1
- package/{jest.config.cjs → jest.config.ts} +8 -3
- package/node/closest-boundary-point/get-close-boundary-points-certified.js +3 -2
- package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
- package/node/corner/get-corner.js +1 -1
- package/node/corner/get-corner.js.map +1 -1
- package/node/{reconstruct-from-mat → cp-node/fs}/get-all-on-loop-by-loop.d.ts +6 -2
- package/node/{reconstruct-from-mat → cp-node/fs}/get-all-on-loop-by-loop.js +5 -1
- package/node/cp-node/fs/get-all-on-loop-by-loop.js.map +1 -0
- package/node/cp-node/fs/get-boundary-beziers-to-next.d.ts +1 -0
- package/node/cp-node/fs/get-boundary-beziers-to-next.js +1 -59
- package/node/cp-node/fs/get-boundary-beziers-to-next.js.map +1 -1
- package/node/cp-node/fs/get-edge-direction.d.ts +3 -1
- package/node/cp-node/fs/get-edge-direction.js +5 -3
- package/node/cp-node/fs/get-edge-direction.js.map +1 -1
- package/node/cp-node/fs/get-implied-boundary-bezier-between.js.map +1 -1
- package/node/cp-node/fs/get-mat-curve-between.js +6 -6
- package/node/cp-node/fs/get-mat-curve-between.js.map +1 -1
- package/node/cp-node/fs/is-fully-terminating.js +12 -0
- package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
- package/node/debug/debug.d.ts +4 -13
- package/node/debug/debug.js +3 -30
- package/node/debug/debug.js.map +1 -1
- package/node/find-2-prong/find-2-prong.js +24 -10
- package/node/find-2-prong/find-2-prong.js.map +1 -1
- package/node/find-2-prong/get-medial/get-antipodal-points.d.ts +1 -1
- package/node/find-2-prong/get-medial/get-antipodal-points.js +2 -2
- 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 +7 -1
- package/node/find-2-prong/get-medial/get-closest-points.js +60 -14
- package/node/find-2-prong/get-medial/get-closest-points.js.map +1 -1
- package/node/find-2-prong/reduce-radius.d.ts +3 -1
- package/node/find-2-prong/reduce-radius.js +8 -6
- package/node/find-2-prong/reduce-radius.js.map +1 -1
- package/node/find-3-prong/calc-better-x.js +1 -3
- package/node/find-3-prong/calc-better-x.js.map +1 -1
- package/node/find-3-prong/calc-initial-3-prong-center.js +1 -2
- package/node/find-3-prong/calc-initial-3-prong-center.js.map +1 -1
- package/node/find-3-prong/find-3-prong-for-delta3s.js +1 -4
- package/node/find-3-prong/find-3-prong-for-delta3s.js.map +1 -1
- package/node/find-3-prong/find-3-prong.js.map +1 -1
- package/node/find-3-prong/find-and-add-3-prong.js +0 -14
- package/node/find-3-prong/find-and-add-3-prong.js.map +1 -1
- package/node/find-mat/find-mat.js +2 -1
- package/node/find-mat/find-mat.js.map +1 -1
- package/node/find-mat/find-mats.js +3 -1
- package/node/find-mat/find-mats.js.map +1 -1
- package/node/find-mat/get-dull-corners-on-loop.js +3 -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 +6 -3
- package/node/find-mat/get-for-1-prongs-on-loop.js.map +1 -1
- package/node/find-mat/get-for-2-prongs-on-loop.js +5 -1
- package/node/find-mat/get-for-2-prongs-on-loop.js.map +1 -1
- package/node/find-mat/get-meta.d.ts +4 -1
- package/node/find-mat/get-meta.js +9 -1
- package/node/find-mat/get-meta.js.map +1 -1
- package/node/find-mat/get-sharp-corners.js +4 -2
- package/node/find-mat/get-sharp-corners.js.map +1 -1
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0.d.ts +21 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0.js +46 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez1.d.ts +28 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez1.js +97 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez1.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.d.ts +28 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.js +109 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2.d.ts +29 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2.js +123 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.d.ts +30 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.js +177 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.d.ts +29 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js +156 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs.d.ts +28 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs.js +40 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs.js.map +1 -0
- package/node/index.d.ts +4 -10
- package/node/index.js +3 -6
- package/node/index.js.map +1 -1
- package/node/point-on-shape/point-on-shape.d.ts +2 -0
- package/node/point-on-shape/to-p.d.ts +1 -1
- package/node/point-on-shape/to-p.js +1 -1
- package/node/point-on-shape/to-p.js.map +1 -1
- package/node/reconstruct-from-mat/get-cp-nodess-for-sat.js +2 -2
- package/node/reconstruct-from-mat/get-cp-nodess-for-sat.js.map +1 -1
- package/node/reconstruct-from-mat/reconstruct-from-mat.d.ts +8 -2
- package/node/reconstruct-from-mat/reconstruct-from-mat.js +154 -22
- package/node/reconstruct-from-mat/reconstruct-from-mat.js.map +1 -1
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js +1 -1
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js.map +1 -1
- package/node/svg/get-loop-bounds.js +6 -2
- package/node/svg/get-loop-bounds.js.map +1 -1
- package/node/utils/map-deep.d.ts +15 -0
- package/node/utils/map-deep.js +34 -0
- package/node/utils/map-deep.js.map +1 -0
- package/package.json +18 -12
- package/src/closest-boundary-point/get-close-boundary-points-certified.ts +3 -2
- package/src/corner/get-corner.ts +1 -1
- package/src/{reconstruct-from-mat → cp-node/fs}/get-all-on-loop-by-loop.ts +7 -3
- package/src/cp-node/fs/get-all-on-loop.ts +1 -1
- package/src/cp-node/fs/get-boundary-beziers-to-next.ts +1 -72
- package/src/cp-node/fs/get-edge-direction.ts +8 -4
- package/src/cp-node/fs/get-implied-boundary-bezier-between.ts +0 -1
- package/src/cp-node/fs/get-mat-curve-between.ts +6 -6
- package/src/cp-node/fs/is-fully-terminating.ts +16 -0
- package/src/debug/debug.ts +8 -50
- package/src/find-2-prong/find-2-prong.ts +37 -14
- package/src/find-2-prong/get-medial/get-antipodal-points.ts +3 -2
- package/src/find-2-prong/get-medial/get-closest-points-d.ts +213 -0
- package/src/find-2-prong/get-medial/get-closest-points.ts +74 -13
- package/src/find-2-prong/reduce-radius.ts +8 -5
- package/src/find-3-prong/calc-better-x.ts +1 -3
- package/src/find-3-prong/calc-initial-3-prong-center.ts +1 -2
- package/src/find-3-prong/find-3-prong-for-delta3s.ts +1 -4
- package/src/find-3-prong/find-3-prong.ts +0 -1
- package/src/find-3-prong/find-and-add-3-prong.ts +1 -15
- package/src/find-mat/find-mat.ts +3 -1
- package/src/find-mat/find-mats.ts +3 -2
- package/src/find-mat/get-dull-corners-on-loop.ts +4 -3
- package/src/find-mat/get-for-1-prongs-on-loop.ts +8 -3
- package/src/find-mat/get-for-2-prongs-on-loop.ts +6 -1
- package/src/find-mat/get-meta.ts +11 -0
- package/src/find-mat/get-sharp-corners.ts +5 -1
- package/src/get-medial-curve/__pycache__/get-cubic-self-medial-curve.cpython-313.pyc +0 -0
- package/src/get-medial-curve/get-cubic-self-medial-curve.py +419 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0-with-running-err.ts +76 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0.ts +61 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez1.ts +116 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.ts +129 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2.ts +142 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.ts +199 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.ts +177 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs.ts +48 -0
- package/src/get-medial-points/double-double/error-bound-calc.txt +72 -0
- package/src/index.ts +4 -10
- package/src/point-on-shape/point-on-shape.ts +3 -0
- package/src/point-on-shape/to-p.ts +2 -2
- package/src/reconstruct-from-mat/get-cp-nodess-for-sat.ts +2 -2
- package/src/reconstruct-from-mat/reconstruct-from-mat.ts +202 -21
- package/src/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.ts +1 -1
- package/src/svg/get-loop-bounds.ts +11 -3
- package/src/utils/map-deep.ts +75 -0
- package/src/utils/map-map.ts +33 -0
- package/wallaby.mjs +4 -4
- package/node/debug/debug-elem-types.d.ts +0 -26
- package/node/debug/debug-elem-types.js +0 -22
- package/node/debug/debug-elem-types.js.map +0 -1
- package/node/debug/functions/draw/draw-beziers-as-single-path.d.ts +0 -2
- package/node/debug/functions/draw/draw-beziers-as-single-path.js +0 -30
- package/node/debug/functions/draw/draw-beziers-as-single-path.js.map +0 -1
- package/node/debug/functions/draw/xmlns.d.ts +0 -2
- package/node/debug/functions/draw/xmlns.js +0 -3
- package/node/debug/functions/draw/xmlns.js.map +0 -1
- package/node/debug/functions/draw-elem/bounding-hull.d.ts +0 -3
- package/node/debug/functions/draw-elem/bounding-hull.js +0 -8
- package/node/debug/functions/draw-elem/bounding-hull.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-branch.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-branch.js +0 -26
- package/node/debug/functions/draw-elem/draw-branch.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-circle-percent.d.ts +0 -3
- package/node/debug/functions/draw-elem/draw-circle-percent.js +0 -13
- package/node/debug/functions/draw-elem/draw-circle-percent.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-cp-node.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-cp-node.js +0 -26
- package/node/debug/functions/draw-elem/draw-cp-node.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-cull.d.ts +0 -3
- package/node/debug/functions/draw-elem/draw-cull.js +0 -9
- package/node/debug/functions/draw-elem/draw-cull.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-dull-corner.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-dull-corner.js +0 -10
- package/node/debug/functions/draw-elem/draw-dull-corner.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-elem.d.ts +0 -10
- package/node/debug/functions/draw-elem/draw-elem.js +0 -39
- package/node/debug/functions/draw-elem/draw-elem.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-leaves.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-leaves.js +0 -34
- package/node/debug/functions/draw-elem/draw-leaves.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-loop.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-loop.js +0 -11
- package/node/debug/functions/draw-elem/draw-loop.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-loops.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-loops.js +0 -6
- package/node/debug/functions/draw-elem/draw-loops.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-loose-bounding-box.d.ts +0 -3
- package/node/debug/functions/draw-elem/draw-loose-bounding-box.js +0 -10
- package/node/debug/functions/draw-elem/draw-loose-bounding-box.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-mat.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-mat.js +0 -34
- package/node/debug/functions/draw-elem/draw-mat.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-max-vertex.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-max-vertex.js +0 -9
- package/node/debug/functions/draw-elem/draw-max-vertex.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-min-y.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-min-y.js +0 -10
- package/node/debug/functions/draw-elem/draw-min-y.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.js +0 -22
- package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-one-prong.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-one-prong.js +0 -13
- package/node/debug/functions/draw-elem/draw-one-prong.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-sharp-corner.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-sharp-corner.js +0 -10
- package/node/debug/functions/draw-elem/draw-sharp-corner.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-three-prong.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-three-prong.js +0 -26
- package/node/debug/functions/draw-elem/draw-three-prong.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-tight-bounding-box.d.ts +0 -3
- package/node/debug/functions/draw-elem/draw-tight-bounding-box.js +0 -8
- package/node/debug/functions/draw-elem/draw-tight-bounding-box.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-two-prong.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-two-prong.js +0 -49
- package/node/debug/functions/draw-elem/draw-two-prong.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-vertex.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-vertex.js +0 -13
- package/node/debug/functions/draw-elem/draw-vertex.js.map +0 -1
- package/node/find-3-prong/timed-cc.d.ts +0 -3
- package/node/find-3-prong/timed-cc.js +0 -5
- package/node/find-3-prong/timed-cc.js.map +0 -1
- package/node/reconstruct-from-mat/filter-zero-length.d.ts +0 -10
- package/node/reconstruct-from-mat/filter-zero-length.js +0 -14
- package/node/reconstruct-from-mat/filter-zero-length.js.map +0 -1
- package/node/reconstruct-from-mat/get-all-on-loop-by-loop.js.map +0 -1
- package/node/reconstruct-from-mat/get-bezier-piece-length.d.ts +0 -3
- package/node/reconstruct-from-mat/get-bezier-piece-length.js +0 -6
- package/node/reconstruct-from-mat/get-bezier-piece-length.js.map +0 -1
- package/node/reconstruct-from-mat/get-boundary.d.ts +0 -7
- package/node/reconstruct-from-mat/get-boundary.js +0 -18
- package/node/reconstruct-from-mat/get-boundary.js.map +0 -1
- package/node/reconstruct-from-mat/get-matching-beziers.d.ts +0 -10
- package/node/reconstruct-from-mat/get-matching-beziers.js +0 -29
- package/node/reconstruct-from-mat/get-matching-beziers.js.map +0 -1
- package/node/reconstruct-from-mat/get-mbss-by-loop-per-sat.d.ts +0 -6
- package/node/reconstruct-from-mat/get-mbss-by-loop-per-sat.js +0 -10
- package/node/reconstruct-from-mat/get-mbss-by-loop-per-sat.js.map +0 -1
- package/node/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.d.ts +0 -7
- package/node/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.js +0 -47
- package/node/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.js.map +0 -1
- package/node/reconstruct-from-mat/get-sats2.d.ts +0 -10
- package/node/reconstruct-from-mat/get-sats2.js +0 -16
- package/node/reconstruct-from-mat/get-sats2.js.map +0 -1
- package/node/reconstruct-from-mat/is-fully-terminating.d.ts +0 -3
- package/node/reconstruct-from-mat/is-fully-terminating.js +0 -19
- package/node/reconstruct-from-mat/is-fully-terminating.js.map +0 -1
- package/node/reconstruct-from-mat/matched-beziers.d.ts +0 -10
- package/node/reconstruct-from-mat/matched-beziers.js +0 -2
- package/node/reconstruct-from-mat/matched-beziers.js.map +0 -1
- package/node/reconstruct-from-mat/split-tri-path.d.ts +0 -5
- package/node/reconstruct-from-mat/split-tri-path.js +0 -209
- package/node/reconstruct-from-mat/split-tri-path.js.map +0 -1
- package/node/utils/clip.d.ts +0 -2
- package/node/utils/clip.js +0 -6
- package/node/utils/clip.js.map +0 -1
- package/node/utils/time-function-call.d.ts +0 -14
- package/node/utils/time-function-call.js +0 -32
- package/node/utils/time-function-call.js.map +0 -1
- package/src/debug/debug-elem-types.ts +0 -43
- package/src/debug/functions/draw/draw-bezier-pieces.ts +0 -35
- package/src/debug/functions/draw-elem/bounding-hull.ts +0 -18
- package/src/debug/functions/draw-elem/culls.ts +0 -39
- package/src/debug/functions/draw-elem/draw-branch.ts +0 -37
- package/src/debug/functions/draw-elem/draw-circle-percent.ts +0 -23
- package/src/debug/functions/draw-elem/draw-cp-node.ts +0 -46
- package/src/debug/functions/draw-elem/draw-cull.ts +0 -21
- package/src/debug/functions/draw-elem/draw-dull-corner.ts +0 -21
- package/src/debug/functions/draw-elem/draw-elem.ts +0 -64
- package/src/debug/functions/draw-elem/draw-leaves.ts +0 -51
- package/src/debug/functions/draw-elem/draw-loop.ts +0 -16
- package/src/debug/functions/draw-elem/draw-loops.ts +0 -10
- package/src/debug/functions/draw-elem/draw-loose-bounding-box.ts +0 -21
- package/src/debug/functions/draw-elem/draw-mat.ts +0 -43
- package/src/debug/functions/draw-elem/draw-max-vertex.ts +0 -15
- package/src/debug/functions/draw-elem/draw-min-y.ts +0 -18
- package/src/debug/functions/draw-elem/draw-one-prong-at-dull-corner.ts +0 -40
- package/src/debug/functions/draw-elem/draw-one-prong.ts +0 -25
- package/src/debug/functions/draw-elem/draw-sharp-corner.ts +0 -21
- package/src/debug/functions/draw-elem/draw-three-prong.ts +0 -44
- package/src/debug/functions/draw-elem/draw-tight-bounding-box.ts +0 -18
- package/src/debug/functions/draw-elem/draw-two-prong.ts +0 -68
- package/src/debug/functions/draw-elem/draw-vertex.ts +0 -27
- package/src/debug/functions/draw-elem/dull-corner.ts +0 -21
- package/src/debug/functions/draw-elem/leaves.ts +0 -20
- package/src/debug/functions/draw-elem/loop.ts +0 -16
- package/src/debug/functions/draw-elem/loops.ts +0 -10
- package/src/debug/functions/draw-elem/loose-bounding-box.ts +0 -21
- package/src/debug/functions/draw-elem/mat.ts +0 -47
- package/src/debug/functions/draw-elem/max-vertex.ts +0 -15
- package/src/debug/functions/draw-elem/min-y.ts +0 -18
- package/src/debug/functions/draw-elem/one-prong-at-dull-corner.ts +0 -26
- package/src/debug/functions/draw-elem/one-prong.ts +0 -23
- package/src/debug/functions/draw-elem/sharp-corner.ts +0 -20
- package/src/debug/functions/draw-elem/three-prong.ts +0 -30
- package/src/debug/functions/draw-elem/tight-bounding-box.ts +0 -18
- package/src/debug/functions/draw-elem/two-prong.ts +0 -50
- package/src/debug/functions/draw-elem/vertex.ts +0 -51
- package/src/find-3-prong/timed-cc.ts +0 -9
- package/src/reconstruct-from-mat/filter-zero-length.ts +0 -23
- package/src/reconstruct-from-mat/get-bezier-piece-length.ts +0 -12
- package/src/reconstruct-from-mat/get-boundary.ts +0 -32
- package/src/reconstruct-from-mat/get-matching-beziers.ts +0 -46
- package/src/reconstruct-from-mat/get-mbss-by-loop-per-sat.ts +0 -19
- package/src/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.ts +0 -69
- package/src/reconstruct-from-mat/get-sats2.ts +0 -25
- package/src/reconstruct-from-mat/is-fully-terminating.ts +0 -27
- package/src/reconstruct-from-mat/matched-beziers.ts +0 -14
- package/src/reconstruct-from-mat/split-tri-path.ts +0 -280
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
import type { BezierPiece } from 'flo-bezier3';
|
|
2
|
-
import type { MatchedBeziers } from './matched-beziers.js';
|
|
3
|
-
import { getTAtLength } from 'flo-bezier3';
|
|
4
|
-
import { sum } from '../utils/sum.js';
|
|
5
|
-
import { clip } from '../utils/clip.js';
|
|
6
|
-
import { getBezierPieceLength } from './get-bezier-piece-length.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const EPS = 1e-9;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function splitTriPath(
|
|
13
|
-
boundaryBeziers: BezierPiece[],
|
|
14
|
-
medialBezier: BezierPiece,
|
|
15
|
-
boundaryBeziersOpp: BezierPiece[] | undefined): MatchedBeziers[] {
|
|
16
|
-
|
|
17
|
-
const _boundaryBeziersOpp = boundaryBeziersOpp ?? [];
|
|
18
|
-
|
|
19
|
-
const boundaryBeziersOpp_ =
|
|
20
|
-
_boundaryBeziersOpp.map(reverseBezierPiece).toReversed();
|
|
21
|
-
|
|
22
|
-
// Importantly, we need to split on boundaryBeziersOpp_ as well, to ensure
|
|
23
|
-
// the number of returned pieces is the same for both sides, so that they
|
|
24
|
-
// can be interpolated.
|
|
25
|
-
const _paths = boundaryBeziersOpp_.length > 0
|
|
26
|
-
? [boundaryBeziers, [medialBezier], boundaryBeziersOpp_]
|
|
27
|
-
: [boundaryBeziers, [medialBezier]];
|
|
28
|
-
|
|
29
|
-
const paths = splitTriPath_(_paths);
|
|
30
|
-
|
|
31
|
-
const matchedBezierss: MatchedBeziers[] = [];
|
|
32
|
-
for (let i=0; i<paths.length; i++) {
|
|
33
|
-
const path = paths[i];
|
|
34
|
-
// const pathOpp = paths[paths.length - 1 - i];
|
|
35
|
-
|
|
36
|
-
const [boundaryBezier, medialBezier] = path;
|
|
37
|
-
// const boundaryBezierOpp = pathOpp[2];
|
|
38
|
-
const matchedBeziers: MatchedBeziers = {
|
|
39
|
-
boundaryBezier,
|
|
40
|
-
medialBezier,
|
|
41
|
-
// boundaryBezierOpp
|
|
42
|
-
};
|
|
43
|
-
matchedBezierss.push(matchedBeziers);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return matchedBezierss;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
function reverseBezierPiece(
|
|
51
|
-
bezierPiece: BezierPiece) {
|
|
52
|
-
|
|
53
|
-
const { ps, ts: [tS, tE] } = bezierPiece;
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
ps: ps.toReversed(),
|
|
57
|
-
ts: [1 - tE, 1 - tS]
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Returns an array of arrays of `BezierPiece`s, where each inner array
|
|
64
|
-
* contains `BezierPiece`s that correspond to each other across the different
|
|
65
|
-
* paths by normalized length.
|
|
66
|
-
*
|
|
67
|
-
* For example, if there are 3 paths, then each inner array will contain 3
|
|
68
|
-
* `BezierPiece`s, one from each path, that correspond to each other by normalized
|
|
69
|
-
* length.
|
|
70
|
-
*
|
|
71
|
-
* @param bezierPiecess
|
|
72
|
-
*/
|
|
73
|
-
function splitTriPath_(
|
|
74
|
-
bezierPiecess: BezierPiece[][]): BezierPiece[][] {
|
|
75
|
-
|
|
76
|
-
const lenss = mapmap(bezierPiecess, getBezierPieceLength);
|
|
77
|
-
const lens = lenss.map(sum);
|
|
78
|
-
const cums = lenss.map(getCumLengths);
|
|
79
|
-
|
|
80
|
-
const normCums = cums.map((cum,i) => {
|
|
81
|
-
const len = lens[i];
|
|
82
|
-
if (len <= EPS) {
|
|
83
|
-
return cum.map((_,j) => j === 0 ? 0 : 1);
|
|
84
|
-
// return cum.map(() => Number.POSITIVE_INFINITY);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return cum.map(l => l/len);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
/** Current position of start t */
|
|
92
|
-
let ts = new Array(bezierPiecess.length).fill(0);
|
|
93
|
-
/** Current position of i */
|
|
94
|
-
let is = new Array(bezierPiecess.length).fill(0);
|
|
95
|
-
|
|
96
|
-
const matchedBezierss: BezierPiece[][] = [];
|
|
97
|
-
|
|
98
|
-
normCums;//?
|
|
99
|
-
|
|
100
|
-
let ii = 0;
|
|
101
|
-
const maxIterations = 100;
|
|
102
|
-
while (ts.some(t => t < 1) && ii++ < maxIterations) {
|
|
103
|
-
const normCumsNext: number[] = [];
|
|
104
|
-
for (let k=0; k<bezierPiecess.length; k++) {
|
|
105
|
-
const i_ = is[k];
|
|
106
|
-
|
|
107
|
-
const normCum_ = normCums[k][i_ + 1];//?
|
|
108
|
-
const normCum = normCum_ === undefined
|
|
109
|
-
? Number.POSITIVE_INFINITY
|
|
110
|
-
: normCum_;
|
|
111
|
-
|
|
112
|
-
normCumsNext.push(normCum);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
normCumsNext;//?
|
|
116
|
-
|
|
117
|
-
const minIdx = getMinIdx(normCumsNext)!;//?
|
|
118
|
-
const idxs = getIdxs(normCumsNext, normCumsNext[minIdx]);//?
|
|
119
|
-
const curCum = normCumsNext[minIdx];
|
|
120
|
-
|
|
121
|
-
// if (idxs.length === 0) {
|
|
122
|
-
// throw new Error('splitTriPath_: unable to make progress');
|
|
123
|
-
// }
|
|
124
|
-
|
|
125
|
-
const nextPieces: BezierPiece[] = new Array(bezierPiecess.length).fill([]);
|
|
126
|
-
for (let m=0; m<bezierPiecess.length; m++) {
|
|
127
|
-
const bezierPieces = bezierPiecess[m];
|
|
128
|
-
const _i = is[m];
|
|
129
|
-
|
|
130
|
-
// This path is already finished; keep emitting a degenerate tail.
|
|
131
|
-
if (_i >= bezierPieces.length) {
|
|
132
|
-
const lastBezierPiece = bezierPieces[bezierPieces.length - 1];
|
|
133
|
-
nextPieces[m] = {
|
|
134
|
-
ps: lastBezierPiece.ps,
|
|
135
|
-
ts: [1, 1]
|
|
136
|
-
};
|
|
137
|
-
ts[m] = 1;
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (idxs.includes(m)) {
|
|
142
|
-
const _t = ts[m];
|
|
143
|
-
const bezierPiece = bezierPieces[_i];
|
|
144
|
-
const [pieceTS, pieceTE] = bezierPiece.ts;
|
|
145
|
-
const pieceDt = pieceTE - pieceTS;
|
|
146
|
-
|
|
147
|
-
nextPieces[m] = {
|
|
148
|
-
ps: bezierPiece.ps,
|
|
149
|
-
ts: [pieceTS + _t*pieceDt, pieceTE]
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
const nextI = _i + 1;
|
|
153
|
-
is[m] = nextI;
|
|
154
|
-
ts[m] = nextI >= bezierPieces.length ? 1 : 0;
|
|
155
|
-
} else {
|
|
156
|
-
const _t = ts[m];
|
|
157
|
-
const bezierPiece = bezierPieces[_i];
|
|
158
|
-
const [pieceTS, pieceTE] = bezierPiece.ts;
|
|
159
|
-
const pieceDt = pieceTE - pieceTS;
|
|
160
|
-
const bezierLen = getBezierPieceLength({ ps: bezierPiece.ps, ts: [0, 1] });
|
|
161
|
-
|
|
162
|
-
const normCumStart = normCums[m][_i];
|
|
163
|
-
const normCumEnd = normCums[m][_i + 1];
|
|
164
|
-
const normCumDt = normCumEnd - normCumStart;
|
|
165
|
-
const normWithinPiece = normCumDt <= EPS
|
|
166
|
-
? _t
|
|
167
|
-
: clip((curCum - normCumStart) / normCumDt, _t, 1);
|
|
168
|
-
|
|
169
|
-
const t1 = bezierLen <= EPS
|
|
170
|
-
? _t
|
|
171
|
-
: clip(getTAtLength(bezierPiece.ps, bezierLen * normWithinPiece), _t, 1);
|
|
172
|
-
|
|
173
|
-
nextPieces[m] = {
|
|
174
|
-
ps: bezierPiece.ps,
|
|
175
|
-
ts: [pieceTS + _t*pieceDt, pieceTS + t1*pieceDt]
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
if (closeToEps(t1, 1)) {
|
|
179
|
-
const nextI = _i + 1;
|
|
180
|
-
is[m] = nextI;
|
|
181
|
-
ts[m] = nextI >= bezierPieces.length ? 1 : 0;
|
|
182
|
-
} else {
|
|
183
|
-
is[m] = _i;
|
|
184
|
-
ts[m] = t1;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
matchedBezierss.push(nextPieces);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (ts.some(t => t < 1)) {
|
|
193
|
-
throw new Error('splitTriPath_: exceeded maximum iterations');
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return matchedBezierss;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
function getCumLengths(lens: number[]) {
|
|
201
|
-
const cum: number[] = [0];
|
|
202
|
-
let cumLen = 0;
|
|
203
|
-
for (let j=0; j<lens.length; j++) {
|
|
204
|
-
cumLen += lens[j];
|
|
205
|
-
cum.push(cumLen);
|
|
206
|
-
}
|
|
207
|
-
return cum;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Returns the index within the given array of the number with the highest
|
|
213
|
-
* value.
|
|
214
|
-
*
|
|
215
|
-
* * returns `undefined` if the array is empty
|
|
216
|
-
*/
|
|
217
|
-
function getMinIdx(
|
|
218
|
-
vs: number[]): number | undefined {
|
|
219
|
-
|
|
220
|
-
let minIdx: number | undefined = undefined;
|
|
221
|
-
let minVal = Number.POSITIVE_INFINITY;
|
|
222
|
-
for (let i=0; i<vs.length; i++) {
|
|
223
|
-
if (vs[i] <= minVal) {
|
|
224
|
-
minVal = vs[i];
|
|
225
|
-
minIdx = i;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return minIdx;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Returns the indices within the given array of the numbers that are equal to
|
|
235
|
-
* the given max value (within an EPS value).
|
|
236
|
-
*
|
|
237
|
-
* @param vs
|
|
238
|
-
* @param maxVal
|
|
239
|
-
*/
|
|
240
|
-
function getIdxs(
|
|
241
|
-
vs: number[],
|
|
242
|
-
maxVal: number): number[] {
|
|
243
|
-
|
|
244
|
-
const maxIdxs: number[] = [];
|
|
245
|
-
for (let i=0; i<vs.length; i++) {
|
|
246
|
-
if (vs[i] === maxVal || closeToEps(vs[i], maxVal)) {
|
|
247
|
-
maxIdxs.push(i);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return maxIdxs;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
function closeToEps(a: number, b: number) {
|
|
256
|
-
return Math.abs(a - b) <= EPS;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
export { splitTriPath, getCumLengths };
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
// KEEP FOR TESTING! - one in opentype-ts doesn't work with tests due to aliases
|
|
265
|
-
function mapmap<T,U>(
|
|
266
|
-
tss: T[][],
|
|
267
|
-
f: (t: T) => U): U[][] {
|
|
268
|
-
|
|
269
|
-
const tss_: U[][] = [];
|
|
270
|
-
for (let i=0; i<tss.length; i++) {
|
|
271
|
-
const ts = tss[i];
|
|
272
|
-
const ts_: U[] = [];
|
|
273
|
-
for (let j=0; j<ts.length; j++) {
|
|
274
|
-
ts_.push(f(ts[j]));
|
|
275
|
-
}
|
|
276
|
-
tss_.push(ts_);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
return tss_;
|
|
280
|
-
}
|