flo-mat 4.0.3 → 4.1.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.
- 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__/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 +1686 -2738
- 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-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.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 +14 -8
- 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-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 +0 -1
- 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-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
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { expect, test } from '@jest/globals';
|
|
2
|
+
import { squares } from 'squares-rng';
|
|
3
|
+
import { getMedialPointCoeffsBez2_SameCurve, getMedialPointCoeffsBez3_SameCurve } from 'flo-bezier3';
|
|
4
|
+
import { ddGetMedialPointCoeffsBez2_SameCurve } from '../../../src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.js';
|
|
5
|
+
import { ddGetMedialPointCoeffsBez3_SameCurve } from '../../../src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.js';
|
|
6
|
+
import { ddNormal } from 'flo-bezier3';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
function toDdVec(v: number[]): number[][] {
|
|
10
|
+
return v.map(x => [0, x]);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function ddPolyToDouble(poly: number[][]): number[] {
|
|
14
|
+
return poly.map(c => c[0] + c[1]);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function normalizedPoly(poly: number[]): number[] {
|
|
18
|
+
let m = 0;
|
|
19
|
+
for (const x of poly) {
|
|
20
|
+
const ax = Math.abs(x);
|
|
21
|
+
if (ax > m) { m = ax; }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (m === 0) {
|
|
25
|
+
return poly.slice();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return poly.map(x => x / m);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function randomNumberIn01(seed: number): number {
|
|
32
|
+
return squares(seed) * 2**-32;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function randomSignedValue(seed: number): number {
|
|
36
|
+
const sign = randomNumberIn01(seed) < 0.5 ? -1 : 1;
|
|
37
|
+
const exponent = Math.floor(randomNumberIn01(seed + 1) * 61) - 30;
|
|
38
|
+
const mantissa = 1 + Math.floor(randomNumberIn01(seed + 2) * 2**20);
|
|
39
|
+
|
|
40
|
+
return sign * mantissa * 2**exponent;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function randomPoint(seed: number): number[] {
|
|
44
|
+
return [
|
|
45
|
+
randomSignedValue(seed),
|
|
46
|
+
randomSignedValue(seed + 1009)
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
test('dd same-curve coefficients match flo-bezier3 double coefficients', function() {
|
|
52
|
+
const epsMain = [2**16];
|
|
53
|
+
const epsD = [2**8];
|
|
54
|
+
const epsH = [2**13];
|
|
55
|
+
const casesPerOrder = 32;
|
|
56
|
+
let seed = 246813579;
|
|
57
|
+
|
|
58
|
+
for (let i = 0; i < casesPerOrder; i++) {
|
|
59
|
+
const t = 0.01 + 0.98 * randomNumberIn01(seed); seed += 7;
|
|
60
|
+
|
|
61
|
+
const ps2 = [
|
|
62
|
+
randomPoint(seed),
|
|
63
|
+
randomPoint(seed + 13),
|
|
64
|
+
randomPoint(seed + 29)
|
|
65
|
+
];
|
|
66
|
+
seed += 43;
|
|
67
|
+
|
|
68
|
+
const n2Dd = ddNormal(ps2, t);
|
|
69
|
+
let v2 = [n2Dd[0][1], n2Dd[1][1]];
|
|
70
|
+
if (Math.abs(v2[0]) + Math.abs(v2[1]) < 2**-20) {
|
|
71
|
+
v2 = [v2[0] + 1, v2[1] - 1];
|
|
72
|
+
}
|
|
73
|
+
const v2Dd = toDdVec(v2);
|
|
74
|
+
|
|
75
|
+
const coeffs2 = getMedialPointCoeffsBez2_SameCurve(t, v2, ps2);
|
|
76
|
+
const ddCoeffs2 = ddGetMedialPointCoeffsBez2_SameCurve(t, v2Dd, ps2);
|
|
77
|
+
|
|
78
|
+
expect(normalizedPoly(coeffs2.A)).toBeNearly(epsMain, normalizedPoly(ddPolyToDouble(ddCoeffs2.A)));
|
|
79
|
+
expect(normalizedPoly(coeffs2.B)).toBeNearly(epsMain, normalizedPoly(ddPolyToDouble(ddCoeffs2.B)));
|
|
80
|
+
expect(normalizedPoly(coeffs2.H)).toBeNearly(epsH, normalizedPoly(ddPolyToDouble(ddCoeffs2.H)));
|
|
81
|
+
|
|
82
|
+
const ps3 = [
|
|
83
|
+
randomPoint(seed),
|
|
84
|
+
randomPoint(seed + 17),
|
|
85
|
+
randomPoint(seed + 31),
|
|
86
|
+
randomPoint(seed + 47)
|
|
87
|
+
];
|
|
88
|
+
seed += 59;
|
|
89
|
+
|
|
90
|
+
const n3Dd = ddNormal(ps3, t);
|
|
91
|
+
let v3 = [n3Dd[0][1], n3Dd[1][1]];
|
|
92
|
+
if (Math.abs(v3[0]) + Math.abs(v3[1]) < 2**-20) {
|
|
93
|
+
v3 = [v3[0] + 1, v3[1] - 1];
|
|
94
|
+
}
|
|
95
|
+
const v3Dd = toDdVec(v3);
|
|
96
|
+
|
|
97
|
+
const coeffs3 = getMedialPointCoeffsBez3_SameCurve(t, v3, ps3);
|
|
98
|
+
const ddCoeffs3 = ddGetMedialPointCoeffsBez3_SameCurve(t, v3Dd, ps3);
|
|
99
|
+
|
|
100
|
+
expect(normalizedPoly(coeffs3.A)).toBeNearly(epsMain, normalizedPoly(ddPolyToDouble(ddCoeffs3.A)));
|
|
101
|
+
expect(normalizedPoly(coeffs3.B)).toBeNearly(epsMain, normalizedPoly(ddPolyToDouble(ddCoeffs3.B)));
|
|
102
|
+
expect(normalizedPoly(coeffs3.C)).toBeNearly(epsMain, normalizedPoly(ddPolyToDouble(ddCoeffs3.C)));
|
|
103
|
+
expect(normalizedPoly(coeffs3.D)).toBeNearly(epsD, normalizedPoly(ddPolyToDouble(ddCoeffs3.D)));
|
|
104
|
+
expect(normalizedPoly(coeffs3.H)).toBeNearly(epsH, normalizedPoly(ddPolyToDouble(ddCoeffs3.H)));
|
|
105
|
+
}
|
|
106
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { expect, test } from '@jest/globals';
|
|
2
|
+
import { getMedialPointCoeffs } from 'flo-bezier3';
|
|
3
|
+
import { ddGetMedialPointCoeffs } from '../../../src/get-medial-points/double-double/dd-get-medial-point-coeffs.js';
|
|
4
|
+
import { squares } from 'squares-rng';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
function toDdVec(v: number[]): number[][] {
|
|
8
|
+
return v.map(x => [0, x]);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function ddPolyToDouble(poly: number[][]): number[] {
|
|
12
|
+
return poly.map(c => c[1]);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
function randomNumberIn01(seed: number): number {
|
|
17
|
+
return squares(seed) * 2**-32;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function randomSignedValue(seed: number): number {
|
|
21
|
+
const sign = randomNumberIn01(seed) < 0.5 ? -1 : 1;
|
|
22
|
+
const exponent = Math.floor(randomNumberIn01(seed + 1) * 81) - 40;
|
|
23
|
+
const mantissa = 1 + randomNumberIn01(seed + 2);
|
|
24
|
+
|
|
25
|
+
return sign * mantissa * 2**exponent;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function randomPoint(seed: number): number[] {
|
|
29
|
+
return [
|
|
30
|
+
randomSignedValue(seed),
|
|
31
|
+
randomSignedValue(seed + 1009)
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
test('ddGetMedialPointCoeffs matches flo-bezier3 double coefficients', function() {
|
|
37
|
+
const ulps = 2**12;
|
|
38
|
+
|
|
39
|
+
const cases: { p: number[]; v: number[]; ps: number[][] }[] = [];
|
|
40
|
+
const casesPerOrder = 24;
|
|
41
|
+
let seed = 123456789;
|
|
42
|
+
|
|
43
|
+
for (let controlPointCount = 1; controlPointCount <= 4; controlPointCount++) {
|
|
44
|
+
for (let i = 0; i < casesPerOrder; i++) {
|
|
45
|
+
const p = randomPoint(seed); seed += 11;
|
|
46
|
+
let v = randomPoint(seed); seed += 11;
|
|
47
|
+
|
|
48
|
+
// Keep the direction away from near-zero vectors.
|
|
49
|
+
if (Math.abs(v[0]) + Math.abs(v[1]) < 2**-20) {
|
|
50
|
+
v = [v[0] + 1, v[1] - 1];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const ps: number[][] = [];
|
|
54
|
+
for (let j = 0; j < controlPointCount; j++) {
|
|
55
|
+
ps.push(randomPoint(seed));
|
|
56
|
+
seed += 13;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
cases.push({ p, v, ps });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
for (const { p, v, ps } of cases) {
|
|
64
|
+
const coeffs = getMedialPointCoeffs(p, v, ps);
|
|
65
|
+
const ddCoeffs = ddGetMedialPointCoeffs(toDdVec(p), toDdVec(v), ps);
|
|
66
|
+
|
|
67
|
+
expect(coeffs.A).toBeNearly(ulps, ddPolyToDouble(ddCoeffs.A));
|
|
68
|
+
expect(coeffs.B).toBeNearly(ulps, ddPolyToDouble(ddCoeffs.B));
|
|
69
|
+
expect(coeffs.C).toBeNearly(ulps, ddPolyToDouble(ddCoeffs.C));
|
|
70
|
+
expect(coeffs.D).toBeNearly(ulps, ddPolyToDouble(ddCoeffs.D));
|
|
71
|
+
expect(coeffs.H).toBeNearly(ulps, ddPolyToDouble(ddCoeffs.H));
|
|
72
|
+
}
|
|
73
|
+
});
|
|
@@ -11,9 +11,11 @@ import { translate } from 'flo-vector2d';
|
|
|
11
11
|
test('getClosestPoints', function() {
|
|
12
12
|
const maxPowerOf2 = 11;
|
|
13
13
|
const nnorm = [20.25, 239];
|
|
14
|
+
const nnormDd = [[0,20.25], [0,239]];
|
|
14
15
|
const ps = [[610, -20], [484, -20], [384, 20.5]];
|
|
15
16
|
const t = 0.25;
|
|
16
17
|
const p = [548.625, -17.46875];
|
|
18
|
+
const pDd = [[0,548.625], [0,-17.46875]];
|
|
17
19
|
const xO = translate(p, nnorm);//?
|
|
18
20
|
const curve: Curve = {
|
|
19
21
|
idx: 0,
|
|
@@ -25,7 +27,8 @@ test('getClosestPoints', function() {
|
|
|
25
27
|
|
|
26
28
|
const yPos: PrePointOnShape = {
|
|
27
29
|
isSource: true,
|
|
28
|
-
p, t, curve
|
|
30
|
+
p, t, curve,
|
|
31
|
+
pDd
|
|
29
32
|
};
|
|
30
33
|
const for1Prong = false;
|
|
31
34
|
const angle = 0;
|
|
@@ -41,7 +44,7 @@ test('getClosestPoints', function() {
|
|
|
41
44
|
const def = deflate(H,t);//?
|
|
42
45
|
// def = [47279295, -157379071.5, 100304568, -23598664.03125, 1904993.75390625]
|
|
43
46
|
|
|
44
|
-
const r = getClosestPoint(maxPowerOf2, nnorm, yPos, for1Prong, angle, curvePiece);
|
|
47
|
+
const r = getClosestPoint(maxPowerOf2, nnorm, nnormDd, yPos, for1Prong, angle, curvePiece);
|
|
45
48
|
|
|
46
49
|
r;//?
|
|
47
50
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ObjOrArray } from "./obj-or-array.js";
|
|
2
|
+
import { eps } from '../../src/error-analysis/gamma.js';
|
|
2
3
|
|
|
3
|
-
const {
|
|
4
|
-
const abs = Math.abs;
|
|
4
|
+
const { abs } = Math;
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @param ulpsOrEps
|
|
9
|
-
* else if an array containing a single number then 1 means 1 eps
|
|
8
|
+
* @param ulpsOrEps if a number then 2\*\*1 means last bit, 2\*\*2 means last 2 bits, etc...
|
|
9
|
+
* else if an array containing a single number then 1 means 1 `eps`, 2 means 2 `eps`, etc...
|
|
10
10
|
*/
|
|
11
11
|
function closeTo(ulpsOrEps: number | number[]) {
|
|
12
12
|
let isUlps = true;
|
|
@@ -22,7 +22,7 @@ function closeTo(ulpsOrEps: number | number[]) {
|
|
|
22
22
|
if (typeof expected === 'number') {
|
|
23
23
|
if (typeof actual !== 'number') { return false; }
|
|
24
24
|
const actual_ = actual as number;
|
|
25
|
-
if (expected ===
|
|
25
|
+
if (expected === Infinity) { return actual_ === Infinity; }
|
|
26
26
|
const error = abs((isUlps ? expected : 1)*(ulpsOrEps as number)*eps);
|
|
27
27
|
|
|
28
28
|
return (
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as cheerio from 'cheerio';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
async function loadSvgs(
|
|
7
|
+
pathToSvg: string) {
|
|
8
|
+
|
|
9
|
+
const absolutePath = resolve(process.cwd(), '__tests__', 'specific-cases', pathToSvg);
|
|
10
|
+
const data = await readFile(absolutePath, 'utf8');
|
|
11
|
+
|
|
12
|
+
const $ = cheerio.load(data, { xmlMode : true });
|
|
13
|
+
|
|
14
|
+
const $svgs = $('glyph');
|
|
15
|
+
|
|
16
|
+
const svgs: { name: string; d: string; }[] = [];
|
|
17
|
+
for (let i=0; i<$svgs.length; i++) {
|
|
18
|
+
const $svg = $svgs[i];
|
|
19
|
+
const attribs = $svg.attribs;
|
|
20
|
+
svgs.push({
|
|
21
|
+
name: attribs["glyph-name"],
|
|
22
|
+
d: attribs.d
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return svgs;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
export { loadSvgs }
|
|
@@ -1,6 +1,170 @@
|
|
|
1
|
-
import { expect, test } from '@jest/globals';
|
|
1
|
+
import { describe, expect, test } from '@jest/globals';
|
|
2
|
+
import { reconstructFromMats } from '../../src/reconstruct-from-mat/reconstruct-from-mat.js';
|
|
3
|
+
import { findMats } from '../../src/find-mat/find-mats.js';
|
|
4
|
+
import { loadSvgs } from './load-svg/load-svg.js';
|
|
5
|
+
import { getPathsFromStr, ddGetShapeArea, simplifyPaths } from 'flo-boolean';
|
|
6
|
+
import { sum } from '../../src/utils/sum.js';
|
|
7
|
+
import { Mat } from '../../src/mat/mat.js';
|
|
2
8
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
9
|
+
const { abs, max, sqrt } = Math;
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const MIN_NUM_ACCURATE_BITS_SQRT_AREA = 14;
|
|
13
|
+
const MIN_NUM_ACCURATE_BITS_RADIUS = 20;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
type TestCase = {
|
|
17
|
+
filename: string;
|
|
18
|
+
svgNames: string[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const testCaseSvgs = [
|
|
23
|
+
".notdef", "woodland", "exclam", "testD", "testL", "testO",
|
|
24
|
+
"testComplex", "ampersand", "testComplexish", "quotesingle", "parenleft", "parenright",
|
|
25
|
+
"asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two",
|
|
26
|
+
"three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon",
|
|
27
|
+
"less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E2",
|
|
28
|
+
"E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "T2",
|
|
29
|
+
"U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum",
|
|
30
|
+
"underscore", "grave", "a", "b", "c", "d", "e", "f", "g", "h2", "h", "i", "j",
|
|
31
|
+
"k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w",
|
|
32
|
+
"x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "Agrave", "Aacute",
|
|
33
|
+
"Acircumflex", "Atilde", "Adieresis", "Aring", "AE", "Ccedilla", "Eth",
|
|
34
|
+
|
|
35
|
+
"3",
|
|
36
|
+
// "AA", // boolean
|
|
37
|
+
// "aaa", // boolean
|
|
38
|
+
"ae", "exclammm", "MM", "Mt", "Mt2", "Mt3", "Mt4", "Mt5",
|
|
39
|
+
"Mth", "notdef", "onehalf", "yen", "ant", "arab",
|
|
40
|
+
// "BBB",
|
|
41
|
+
// "bb",
|
|
42
|
+
"bump_tube1",
|
|
43
|
+
// "bump_tube2",
|
|
44
|
+
// "china",
|
|
45
|
+
"china1", "circle_in_circle", "circle_in_square", "concave_poly",
|
|
46
|
+
"EEE", "fff", "gecko", "hart",
|
|
47
|
+
// "hat",
|
|
48
|
+
"A-2", "B-2",
|
|
49
|
+
"CCC", "DDD", "E-2", "holepole", "holy_poly", "intersecting", "intersecting1",
|
|
50
|
+
// "intersecting2",
|
|
51
|
+
"koldat", "koldat14", "koldat15", "koldat16", "koldat17", "koldat18",
|
|
52
|
+
"koldat19", "koldat2", "koldat20", "koldat21", "koldat22", "koldat23", "koldat24", "koldat25",
|
|
53
|
+
"koldat26", "koldat3", "koldat4",
|
|
54
|
+
// "koldat51", // just reconstruct that's a bit off
|
|
55
|
+
"koldat52", "koldat53", "koldat54",
|
|
56
|
+
"koldat55", "koldat56", "koldat57", "koldat58", "koldat59",
|
|
57
|
+
// "koldat6",
|
|
58
|
+
"koldat60", "koldat61",
|
|
59
|
+
"koldat62", "koldat63", "koldat64", "koldat7", "Lamda",
|
|
60
|
+
"lb",
|
|
61
|
+
"matthew",
|
|
62
|
+
"new1",
|
|
63
|
+
"new2", "new3", "noobd3v1", "noobd3v2", "OO", "PP", "p1", "p2",
|
|
64
|
+
"p3", "p4", "p5", "play1", "play2",
|
|
65
|
+
// "play3",
|
|
66
|
+
"l1", "l2", "poly", "poly-04",
|
|
67
|
+
"poly-11", "poly-12", "poly-121",
|
|
68
|
+
// "quad_blob",
|
|
69
|
+
"ra", "SSS", "simple",
|
|
70
|
+
// "so copy",
|
|
71
|
+
"so", "square", "square_in_circle", "square_in_square",
|
|
72
|
+
// "TTT",
|
|
73
|
+
"T2",
|
|
74
|
+
"geck1", "t4", "test1", "test2", "test3", "test4", "tt", "two_hole"
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
test('Should correctly reconstruct original shape from medial axis for specific test cases', async function() {
|
|
78
|
+
const testCases: TestCase[] = [
|
|
79
|
+
{
|
|
80
|
+
filename: 'achispado',
|
|
81
|
+
svgNames: testCaseSvgs
|
|
82
|
+
// svgNames: ['percent']
|
|
83
|
+
}
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
for (const testCase of testCases) {
|
|
87
|
+
await testIt(testCase);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
async function testIt(
|
|
92
|
+
testCase: TestCase) {
|
|
93
|
+
|
|
94
|
+
const { filename, svgNames } = testCase;
|
|
95
|
+
|
|
96
|
+
const svgs = await loadSvgs(`./test-svgs/${filename}.svg`);
|
|
97
|
+
|
|
98
|
+
for (const svgName of svgNames) {
|
|
99
|
+
const pathStr = svgs.find(glyph => glyph.name === svgName)!.d;
|
|
100
|
+
|
|
101
|
+
const bezierLoops = getPathsFromStr(pathStr);
|
|
102
|
+
|
|
103
|
+
const loopss = simplifyPaths(bezierLoops, undefined, { forceOrientationNegative: true });
|
|
104
|
+
|
|
105
|
+
let mats: Mat[];
|
|
106
|
+
try {
|
|
107
|
+
mats = findMats(bezierLoops, {
|
|
108
|
+
applySat: false,
|
|
109
|
+
simplify: false,
|
|
110
|
+
satScale: 1.01,
|
|
111
|
+
maxCurviness: 0.25,
|
|
112
|
+
maxLength: 40,
|
|
113
|
+
angleIncrement: 15,
|
|
114
|
+
// simplifyTolerance: 2**-5
|
|
115
|
+
// minBezLength-\
|
|
116
|
+
});
|
|
117
|
+
} catch (e) {
|
|
118
|
+
console.log(`Unable to find MATs for ${svgName}`)
|
|
119
|
+
throw e;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const maxPO2 = max(...mats.map(mat => mat.meta.maxCoordPowerOf2));
|
|
123
|
+
|
|
124
|
+
const areass = loopss.map(loops => {
|
|
125
|
+
const areas = loops.map(loop => ddGetShapeArea(loop.beziers)[1]);
|
|
126
|
+
return areas;
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const piecesss = reconstructFromMats(mats, MIN_NUM_ACCURATE_BITS_RADIUS);
|
|
130
|
+
|
|
131
|
+
const areass_ = piecesss.map(piecess => {
|
|
132
|
+
return piecess.map(loop => {
|
|
133
|
+
return ddGetShapeArea(loop)[1];
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
checkAreas(maxPO2, svgName, areass, areass_);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
6
140
|
});
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
function checkAreas(
|
|
144
|
+
maxPO2: number,
|
|
145
|
+
svgName: string,
|
|
146
|
+
areass: number[][],
|
|
147
|
+
areass_: number[][]) {
|
|
148
|
+
|
|
149
|
+
if (areass.length !== areass_.length) {
|
|
150
|
+
throw new Error('number of areas mismatch')
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const areas = areass.map(sum);
|
|
154
|
+
const areas_ = areass_.map(sum);
|
|
155
|
+
|
|
156
|
+
const tol = 2**(maxPO2 - MIN_NUM_ACCURATE_BITS_SQRT_AREA);
|
|
157
|
+
|
|
158
|
+
for (let i=0; i<areas.length; i++) {
|
|
159
|
+
const area = areas[i];
|
|
160
|
+
const area_ = areas_[i];
|
|
161
|
+
|
|
162
|
+
// area;//?
|
|
163
|
+
// area_;//?
|
|
164
|
+
const err = sqrt(abs(area)) - sqrt(abs(area_));
|
|
165
|
+
|
|
166
|
+
if (err > tol) {
|
|
167
|
+
throw new Error(`Areas mismatch (${svgName}), area idx ${i}, found: sqrt(area): ${sqrt(abs(area))} vs ${sqrt(abs(area_))}, err: ${err}, tol: ${tol}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|