@antv/util 3.0.2 → 3.1.2
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/README.md +167 -4
- package/dist/util.min.js +1 -1
- package/esm/color/arr2rgb.js +3 -3
- package/esm/color/arr2rgb.js.map +1 -1
- package/esm/color/gradient.js +9 -9
- package/esm/color/gradient.js.map +1 -1
- package/esm/color/tocssgradient.js +18 -18
- package/esm/color/tocssgradient.js.map +1 -1
- package/esm/color/torgb.js +6 -6
- package/esm/color/torgb.js.map +1 -1
- package/esm/helper/to-radian.js +1 -1
- package/esm/helper/to-radian.js.map +1 -1
- package/esm/matrix/index.js +8 -8
- package/esm/matrix/index.js.map +1 -1
- package/esm/path/convert/path-2-absolute.d.ts +2 -0
- package/esm/path/convert/path-2-absolute.js +83 -0
- package/esm/path/convert/path-2-absolute.js.map +1 -0
- package/esm/path/convert/path-2-curve.d.ts +2 -0
- package/esm/path/convert/path-2-curve.js +56 -0
- package/esm/path/convert/path-2-curve.js.map +1 -0
- package/esm/path/convert/path-2-string.d.ts +6 -0
- package/esm/path/convert/path-2-string.js +11 -0
- package/esm/path/convert/path-2-string.js.map +1 -0
- package/esm/path/index.d.ts +17 -16
- package/esm/path/index.js +17 -16
- package/esm/path/index.js.map +1 -1
- package/esm/path/parser/finalize-segment.d.ts +5 -0
- package/esm/path/parser/finalize-segment.js +27 -0
- package/esm/path/parser/finalize-segment.js.map +1 -0
- package/esm/path/parser/is-arc-command.d.ts +4 -0
- package/esm/path/parser/is-arc-command.js +7 -0
- package/esm/path/parser/is-arc-command.js.map +1 -0
- package/esm/path/parser/is-digit-start.d.ts +6 -0
- package/esm/path/parser/is-digit-start.js +11 -0
- package/esm/path/parser/is-digit-start.js.map +1 -0
- package/esm/path/parser/is-path-command.d.ts +4 -0
- package/esm/path/parser/is-path-command.js +23 -0
- package/esm/path/parser/is-path-command.js.map +1 -0
- package/esm/path/parser/is-space.d.ts +4 -0
- package/esm/path/parser/is-space.js +22 -0
- package/esm/path/parser/is-space.js.map +1 -0
- package/esm/path/parser/params-count.d.ts +13 -0
- package/esm/path/parser/params-count.js +14 -0
- package/esm/path/parser/params-count.js.map +1 -0
- package/esm/path/parser/params-parser.d.ts +10 -0
- package/esm/path/parser/params-parser.js +11 -0
- package/esm/path/parser/params-parser.js.map +1 -0
- package/esm/path/parser/parse-path-string.d.ts +6 -0
- package/esm/path/parser/parse-path-string.js +21 -0
- package/esm/path/parser/parse-path-string.js.map +1 -0
- package/esm/path/parser/path-parser.d.ts +16 -0
- package/esm/path/parser/path-parser.js +18 -0
- package/esm/path/parser/path-parser.js.map +1 -0
- package/esm/path/parser/scan-flag.d.ts +6 -0
- package/esm/path/parser/scan-flag.js +20 -0
- package/esm/path/parser/scan-flag.js.map +1 -0
- package/esm/path/parser/scan-param.d.ts +6 -0
- package/esm/path/parser/scan-param.js +83 -0
- package/esm/path/parser/scan-param.js.map +1 -0
- package/esm/path/parser/scan-segment.d.ts +6 -0
- package/esm/path/parser/scan-segment.js +57 -0
- package/esm/path/parser/scan-segment.js.map +1 -0
- package/esm/path/parser/skip-spaces.d.ts +7 -0
- package/esm/path/parser/skip-spaces.js +13 -0
- package/esm/path/parser/skip-spaces.js.map +1 -0
- package/esm/path/process/arc-2-cubic.d.ts +7 -1
- package/esm/path/process/arc-2-cubic.js +276 -133
- package/esm/path/process/arc-2-cubic.js.map +1 -1
- package/esm/path/process/clone-path.d.ts +2 -0
- package/esm/path/process/clone-path.js +4 -0
- package/esm/path/process/clone-path.js.map +1 -0
- package/esm/path/process/fix-arc.d.ts +2 -0
- package/esm/path/process/fix-arc.js +16 -0
- package/esm/path/process/fix-arc.js.map +1 -0
- package/esm/path/process/line-2-cubic.js +17 -32
- package/esm/path/process/line-2-cubic.js.map +1 -1
- package/esm/path/process/normalize-path.d.ts +8 -0
- package/esm/path/process/normalize-path.js +35 -0
- package/esm/path/process/normalize-path.js.map +1 -0
- package/esm/path/process/normalize-segment.d.ts +6 -0
- package/esm/path/process/normalize-segment.js +42 -0
- package/esm/path/process/normalize-segment.js.map +1 -0
- package/esm/path/process/quad-2-cubic.js +2 -2
- package/esm/path/process/quad-2-cubic.js.map +1 -1
- package/esm/path/process/reverse-curve.d.ts +2 -0
- package/esm/path/process/reverse-curve.js +13 -0
- package/esm/path/process/reverse-curve.js.map +1 -0
- package/esm/path/process/round-path.d.ts +6 -0
- package/esm/path/process/round-path.js +20 -0
- package/esm/path/process/round-path.js.map +1 -0
- package/esm/path/process/segment-2-cubic.d.ts +2 -2
- package/esm/path/process/segment-2-cubic.js +23 -19
- package/esm/path/process/segment-2-cubic.js.map +1 -1
- package/esm/path/types.d.ts +114 -17
- package/esm/path/util/distance-square-root.d.ts +1 -0
- package/esm/path/util/distance-square-root.js +4 -0
- package/esm/path/util/distance-square-root.js.map +1 -0
- package/esm/path/util/equalize-segments.d.ts +2 -0
- package/esm/path/util/equalize-segments.js +68 -0
- package/esm/path/util/equalize-segments.js.map +1 -0
- package/esm/path/util/get-draw-direction.d.ts +2 -0
- package/esm/path/util/get-draw-direction.js +5 -0
- package/esm/path/util/get-draw-direction.js.map +1 -0
- package/esm/path/util/get-path-area.d.ts +8 -0
- package/esm/path/util/get-path-area.js +68 -0
- package/esm/path/util/get-path-area.js.map +1 -0
- package/esm/path/util/get-path-bbox-total-length.d.ts +5 -0
- package/esm/path/util/get-path-bbox-total-length.js +37 -0
- package/esm/path/util/get-path-bbox-total-length.js.map +1 -0
- package/esm/path/util/get-path-bbox.d.ts +5 -0
- package/esm/path/util/get-path-bbox.js +35 -0
- package/esm/path/util/get-path-bbox.js.map +1 -0
- package/esm/path/util/get-point-at-length.d.ts +5 -0
- package/esm/path/util/get-point-at-length.js +8 -0
- package/esm/path/util/get-point-at-length.js.map +1 -0
- package/esm/path/util/get-properties-at-length.d.ts +6 -0
- package/esm/path/util/get-properties-at-length.js +58 -0
- package/esm/path/util/get-properties-at-length.js.map +1 -0
- package/esm/path/util/get-properties-at-point.d.ts +7 -0
- package/esm/path/util/get-properties-at-point.js +69 -0
- package/esm/path/util/get-properties-at-point.js.map +1 -0
- package/esm/path/util/get-rotated-curve.d.ts +2 -0
- package/esm/path/util/get-rotated-curve.js +34 -0
- package/esm/path/util/get-rotated-curve.js.map +1 -0
- package/esm/path/util/get-total-length.d.ts +8 -0
- package/esm/path/util/get-total-length.js +11 -0
- package/esm/path/util/get-total-length.js.map +1 -0
- package/esm/path/util/is-absolute-array.d.ts +6 -0
- package/esm/path/util/is-absolute-array.js +11 -0
- package/esm/path/util/is-absolute-array.js.map +1 -0
- package/esm/path/util/is-curve-array.d.ts +9 -0
- package/esm/path/util/is-curve-array.js +12 -0
- package/esm/path/util/is-curve-array.js.map +1 -0
- package/esm/path/util/is-normalized-array.d.ts +7 -0
- package/esm/path/util/is-normalized-array.js +10 -0
- package/esm/path/util/is-normalized-array.js.map +1 -0
- package/esm/path/util/is-path-array.d.ts +5 -0
- package/esm/path/util/is-path-array.js +12 -0
- package/esm/path/util/is-path-array.js.map +1 -0
- package/esm/path/util/is-point-in-stroke.d.ts +5 -0
- package/esm/path/util/is-point-in-stroke.js +9 -0
- package/esm/path/util/is-point-in-stroke.js.map +1 -0
- package/esm/path/util/mid-point.d.ts +1 -0
- package/esm/path/util/mid-point.js +8 -0
- package/esm/path/util/mid-point.js.map +1 -0
- package/esm/path/util/path-length-factory.d.ts +7 -0
- package/esm/path/util/path-length-factory.js +94 -0
- package/esm/path/util/path-length-factory.js.map +1 -0
- package/esm/path/util/rotate-vector.d.ts +4 -0
- package/esm/path/util/rotate-vector.js +6 -0
- package/esm/path/util/rotate-vector.js.map +1 -0
- package/esm/path/util/segment-arc-factory.d.ts +6 -0
- package/esm/path/util/segment-arc-factory.js +135 -0
- package/esm/path/util/segment-arc-factory.js.map +1 -0
- package/esm/path/util/segment-cubic-factory.d.ts +6 -0
- package/esm/path/util/segment-cubic-factory.js +63 -0
- package/esm/path/util/segment-cubic-factory.js.map +1 -0
- package/esm/path/util/segment-line-factory.d.ts +6 -0
- package/esm/path/util/segment-line-factory.js +35 -0
- package/esm/path/util/segment-line-factory.js.map +1 -0
- package/esm/path/util/segment-quad-factory.d.ts +6 -0
- package/esm/path/util/segment-quad-factory.js +65 -0
- package/esm/path/util/segment-quad-factory.js.map +1 -0
- package/lib/color/arr2rgb.js +3 -3
- package/lib/color/arr2rgb.js.map +1 -1
- package/lib/color/gradient.js +12 -12
- package/lib/color/gradient.js.map +1 -1
- package/lib/color/tocssgradient.js +18 -18
- package/lib/color/tocssgradient.js.map +1 -1
- package/lib/color/torgb.js +7 -7
- package/lib/color/torgb.js.map +1 -1
- package/lib/helper/to-radian.js +1 -1
- package/lib/helper/to-radian.js.map +1 -1
- package/lib/matrix/index.js +9 -9
- package/lib/matrix/index.js.map +1 -1
- package/lib/path/convert/path-2-absolute.d.ts +2 -0
- package/lib/path/convert/path-2-absolute.js +87 -0
- package/lib/path/convert/path-2-absolute.js.map +1 -0
- package/lib/path/convert/path-2-curve.d.ts +2 -0
- package/lib/path/convert/path-2-curve.js +60 -0
- package/lib/path/convert/path-2-curve.js.map +1 -0
- package/lib/path/convert/path-2-string.d.ts +6 -0
- package/lib/path/convert/path-2-string.js +15 -0
- package/lib/path/convert/path-2-string.js.map +1 -0
- package/lib/path/index.d.ts +17 -16
- package/lib/path/index.js +42 -31
- package/lib/path/index.js.map +1 -1
- package/lib/path/parser/finalize-segment.d.ts +5 -0
- package/lib/path/parser/finalize-segment.js +31 -0
- package/lib/path/parser/finalize-segment.js.map +1 -0
- package/lib/path/parser/is-arc-command.d.ts +4 -0
- package/lib/path/parser/is-arc-command.js +11 -0
- package/lib/path/parser/is-arc-command.js.map +1 -0
- package/lib/path/parser/is-digit-start.d.ts +6 -0
- package/lib/path/parser/is-digit-start.js +16 -0
- package/lib/path/parser/is-digit-start.js.map +1 -0
- package/lib/path/parser/is-path-command.d.ts +4 -0
- package/lib/path/parser/is-path-command.js +27 -0
- package/lib/path/parser/is-path-command.js.map +1 -0
- package/lib/path/parser/is-space.d.ts +4 -0
- package/lib/path/parser/is-space.js +26 -0
- package/lib/path/parser/is-space.js.map +1 -0
- package/lib/path/parser/params-count.d.ts +13 -0
- package/lib/path/parser/params-count.js +17 -0
- package/lib/path/parser/params-count.js.map +1 -0
- package/lib/path/parser/params-parser.d.ts +10 -0
- package/lib/path/parser/params-parser.js +14 -0
- package/lib/path/parser/params-parser.js.map +1 -0
- package/lib/path/parser/parse-path-string.d.ts +6 -0
- package/lib/path/parser/parse-path-string.js +25 -0
- package/lib/path/parser/parse-path-string.js.map +1 -0
- package/lib/path/parser/path-parser.d.ts +16 -0
- package/lib/path/parser/path-parser.js +22 -0
- package/lib/path/parser/path-parser.js.map +1 -0
- package/lib/path/parser/scan-flag.d.ts +6 -0
- package/lib/path/parser/scan-flag.js +24 -0
- package/lib/path/parser/scan-flag.js.map +1 -0
- package/lib/path/parser/scan-param.d.ts +6 -0
- package/lib/path/parser/scan-param.js +87 -0
- package/lib/path/parser/scan-param.js.map +1 -0
- package/lib/path/parser/scan-segment.d.ts +6 -0
- package/lib/path/parser/scan-segment.js +61 -0
- package/lib/path/parser/scan-segment.js.map +1 -0
- package/lib/path/parser/skip-spaces.d.ts +7 -0
- package/lib/path/parser/skip-spaces.js +17 -0
- package/lib/path/parser/skip-spaces.js.map +1 -0
- package/lib/path/process/arc-2-cubic.d.ts +7 -1
- package/lib/path/process/arc-2-cubic.js +276 -133
- package/lib/path/process/arc-2-cubic.js.map +1 -1
- package/lib/path/process/clone-path.d.ts +2 -0
- package/lib/path/process/clone-path.js +8 -0
- package/lib/path/process/clone-path.js.map +1 -0
- package/lib/path/process/fix-arc.d.ts +2 -0
- package/lib/path/process/fix-arc.js +20 -0
- package/lib/path/process/fix-arc.js.map +1 -0
- package/lib/path/process/line-2-cubic.js +17 -32
- package/lib/path/process/line-2-cubic.js.map +1 -1
- package/lib/path/process/normalize-path.d.ts +8 -0
- package/lib/path/process/normalize-path.js +39 -0
- package/lib/path/process/normalize-path.js.map +1 -0
- package/lib/path/process/normalize-segment.d.ts +6 -0
- package/lib/path/process/normalize-segment.js +46 -0
- package/lib/path/process/normalize-segment.js.map +1 -0
- package/lib/path/process/quad-2-cubic.js +2 -2
- package/lib/path/process/quad-2-cubic.js.map +1 -1
- package/lib/path/process/reverse-curve.d.ts +2 -0
- package/lib/path/process/reverse-curve.js +17 -0
- package/lib/path/process/reverse-curve.js.map +1 -0
- package/lib/path/process/round-path.d.ts +6 -0
- package/lib/path/process/round-path.js +24 -0
- package/lib/path/process/round-path.js.map +1 -0
- package/lib/path/process/segment-2-cubic.d.ts +2 -2
- package/lib/path/process/segment-2-cubic.js +26 -22
- package/lib/path/process/segment-2-cubic.js.map +1 -1
- package/lib/path/types.d.ts +114 -17
- package/lib/path/util/distance-square-root.d.ts +1 -0
- package/lib/path/util/distance-square-root.js +8 -0
- package/lib/path/util/distance-square-root.js.map +1 -0
- package/lib/path/util/equalize-segments.d.ts +2 -0
- package/lib/path/util/equalize-segments.js +72 -0
- package/lib/path/util/equalize-segments.js.map +1 -0
- package/lib/path/util/get-draw-direction.d.ts +2 -0
- package/lib/path/util/get-draw-direction.js +9 -0
- package/lib/path/util/get-draw-direction.js.map +1 -0
- package/lib/path/util/get-path-area.d.ts +8 -0
- package/lib/path/util/get-path-area.js +72 -0
- package/lib/path/util/get-path-area.js.map +1 -0
- package/lib/path/util/get-path-bbox-total-length.d.ts +5 -0
- package/lib/path/util/get-path-bbox-total-length.js +41 -0
- package/lib/path/util/get-path-bbox-total-length.js.map +1 -0
- package/lib/path/util/get-path-bbox.d.ts +5 -0
- package/lib/path/util/get-path-bbox.js +39 -0
- package/lib/path/util/get-path-bbox.js.map +1 -0
- package/lib/path/util/get-point-at-length.d.ts +5 -0
- package/lib/path/util/get-point-at-length.js +12 -0
- package/lib/path/util/get-point-at-length.js.map +1 -0
- package/lib/path/util/get-properties-at-length.d.ts +6 -0
- package/lib/path/util/get-properties-at-length.js +62 -0
- package/lib/path/util/get-properties-at-length.js.map +1 -0
- package/lib/path/util/get-properties-at-point.d.ts +7 -0
- package/lib/path/util/get-properties-at-point.js +73 -0
- package/lib/path/util/get-properties-at-point.js.map +1 -0
- package/lib/path/util/get-rotated-curve.d.ts +2 -0
- package/lib/path/util/get-rotated-curve.js +38 -0
- package/lib/path/util/get-rotated-curve.js.map +1 -0
- package/lib/path/util/get-total-length.d.ts +8 -0
- package/lib/path/util/get-total-length.js +15 -0
- package/lib/path/util/get-total-length.js.map +1 -0
- package/lib/path/util/is-absolute-array.d.ts +6 -0
- package/lib/path/util/is-absolute-array.js +15 -0
- package/lib/path/util/is-absolute-array.js.map +1 -0
- package/lib/path/util/is-curve-array.d.ts +9 -0
- package/lib/path/util/is-curve-array.js +16 -0
- package/lib/path/util/is-curve-array.js.map +1 -0
- package/lib/path/util/is-normalized-array.d.ts +7 -0
- package/lib/path/util/is-normalized-array.js +14 -0
- package/lib/path/util/is-normalized-array.js.map +1 -0
- package/lib/path/util/is-path-array.d.ts +5 -0
- package/lib/path/util/is-path-array.js +16 -0
- package/lib/path/util/is-path-array.js.map +1 -0
- package/lib/path/util/is-point-in-stroke.d.ts +5 -0
- package/lib/path/util/is-point-in-stroke.js +13 -0
- package/lib/path/util/is-point-in-stroke.js.map +1 -0
- package/lib/path/util/mid-point.d.ts +1 -0
- package/lib/path/util/mid-point.js +12 -0
- package/lib/path/util/mid-point.js.map +1 -0
- package/lib/path/util/path-length-factory.d.ts +7 -0
- package/lib/path/util/path-length-factory.js +98 -0
- package/lib/path/util/path-length-factory.js.map +1 -0
- package/lib/path/util/rotate-vector.d.ts +4 -0
- package/lib/path/util/rotate-vector.js +10 -0
- package/lib/path/util/rotate-vector.js.map +1 -0
- package/lib/path/util/segment-arc-factory.d.ts +6 -0
- package/lib/path/util/segment-arc-factory.js +139 -0
- package/lib/path/util/segment-arc-factory.js.map +1 -0
- package/lib/path/util/segment-cubic-factory.d.ts +6 -0
- package/lib/path/util/segment-cubic-factory.js +67 -0
- package/lib/path/util/segment-cubic-factory.js.map +1 -0
- package/lib/path/util/segment-line-factory.d.ts +6 -0
- package/lib/path/util/segment-line-factory.js +39 -0
- package/lib/path/util/segment-line-factory.js.map +1 -0
- package/lib/path/util/segment-quad-factory.d.ts +6 -0
- package/lib/path/util/segment-quad-factory.js +69 -0
- package/lib/path/util/segment-quad-factory.js.map +1 -0
- package/package.json +1 -1
- package/src/path/convert/path-2-absolute.ts +90 -0
- package/src/path/convert/path-2-curve.ts +68 -0
- package/src/path/convert/path-2-string.ts +12 -0
- package/src/path/index.ts +18 -16
- package/src/path/parser/finalize-segment.ts +30 -0
- package/src/path/parser/is-arc-command.ts +6 -0
- package/src/path/parser/is-digit-start.ts +13 -0
- package/src/path/parser/is-path-command.ts +22 -0
- package/src/path/parser/is-space.ts +23 -0
- package/src/path/parser/params-count.ts +13 -0
- package/src/path/parser/params-parser.ts +10 -0
- package/src/path/parser/parse-path-string.ts +26 -0
- package/src/path/parser/path-parser.ts +35 -0
- package/src/path/parser/scan-flag.ts +24 -0
- package/src/path/parser/scan-param.ts +98 -0
- package/src/path/parser/scan-segment.ts +68 -0
- package/src/path/parser/skip-spaces.ts +14 -0
- package/src/path/process/arc-2-cubic.ts +332 -215
- package/src/path/process/clone-path.ts +5 -0
- package/src/path/process/fix-arc.ts +17 -0
- package/src/path/process/line-2-cubic.ts +17 -33
- package/src/path/process/normalize-path.ts +42 -0
- package/src/path/process/normalize-segment.ts +42 -0
- package/src/path/process/reverse-curve.ts +18 -0
- package/src/path/process/round-path.ts +22 -0
- package/src/path/process/segment-2-cubic.ts +28 -27
- package/src/path/types.ts +190 -17
- package/src/path/util/distance-square-root.ts +3 -0
- package/src/path/util/equalize-segments.ts +79 -0
- package/src/path/util/get-draw-direction.ts +6 -0
- package/src/path/util/get-path-area.ts +83 -0
- package/src/path/util/get-path-bbox-total-length.ts +45 -0
- package/src/path/util/get-path-bbox.ts +42 -0
- package/src/path/util/get-point-at-length.ts +9 -0
- package/src/path/util/get-properties-at-length.ts +65 -0
- package/src/path/util/get-properties-at-point.ts +73 -0
- package/src/path/util/get-rotated-curve.ts +42 -0
- package/src/path/util/get-total-length.ts +12 -0
- package/src/path/util/is-absolute-array.ts +14 -0
- package/src/path/util/is-curve-array.ts +13 -0
- package/src/path/util/is-normalized-array.ts +11 -0
- package/src/path/util/is-path-array.ts +15 -0
- package/src/path/util/is-point-in-stroke.ts +10 -0
- package/src/path/util/mid-point.ts +7 -0
- package/src/path/util/path-length-factory.ts +98 -0
- package/src/path/util/rotate-vector.ts +5 -0
- package/src/path/util/segment-arc-factory.ts +186 -0
- package/src/path/util/segment-cubic-factory.ts +92 -0
- package/src/path/util/segment-line-factory.ts +36 -0
- package/src/path/util/segment-quad-factory.ts +90 -0
- package/esm/path/catmull-rom-2-bezier.d.ts +0 -10
- package/esm/path/catmull-rom-2-bezier.js +0 -115
- package/esm/path/catmull-rom-2-bezier.js.map +0 -1
- package/esm/path/fill-path-by-diff.d.ts +0 -5
- package/esm/path/fill-path-by-diff.js +0 -110
- package/esm/path/fill-path-by-diff.js.map +0 -1
- package/esm/path/fill-path.d.ts +0 -1
- package/esm/path/fill-path.js +0 -129
- package/esm/path/fill-path.js.map +0 -1
- package/esm/path/format-path.d.ts +0 -1
- package/esm/path/format-path.js +0 -139
- package/esm/path/format-path.js.map +0 -1
- package/esm/path/get-arc-params.d.ts +0 -17
- package/esm/path/get-arc-params.js +0 -90
- package/esm/path/get-arc-params.js.map +0 -1
- package/esm/path/get-line-intersect.d.ts +0 -14
- package/esm/path/get-line-intersect.js +0 -33
- package/esm/path/get-line-intersect.js.map +0 -1
- package/esm/path/is-polygons-intersect.d.ts +0 -1
- package/esm/path/is-polygons-intersect.js +0 -81
- package/esm/path/is-polygons-intersect.js.map +0 -1
- package/esm/path/parse-path-array.d.ts +0 -1
- package/esm/path/parse-path-array.js +0 -5
- package/esm/path/parse-path-array.js.map +0 -1
- package/esm/path/parse-path-string.d.ts +0 -1
- package/esm/path/parse-path-string.js +0 -61
- package/esm/path/parse-path-string.js.map +0 -1
- package/esm/path/parse-path.d.ts +0 -1
- package/esm/path/parse-path.js +0 -33
- package/esm/path/parse-path.js.map +0 -1
- package/esm/path/path-2-absolute.d.ts +0 -1
- package/esm/path/path-2-absolute.js +0 -124
- package/esm/path/path-2-absolute.js.map +0 -1
- package/esm/path/path-2-curve.d.ts +0 -2
- package/esm/path/path-2-curve.js +0 -63
- package/esm/path/path-2-curve.js.map +0 -1
- package/esm/path/path-2-segments.d.ts +0 -1
- package/esm/path/path-2-segments.js +0 -138
- package/esm/path/path-2-segments.js.map +0 -1
- package/esm/path/path-intersection.d.ts +0 -9
- package/esm/path/path-intersection.js +0 -366
- package/esm/path/path-intersection.js.map +0 -1
- package/esm/path/point-in-polygon.d.ts +0 -5
- package/esm/path/point-in-polygon.js +0 -49
- package/esm/path/point-in-polygon.js.map +0 -1
- package/esm/path/rect-path.d.ts +0 -4
- package/esm/path/rect-path.js +0 -19
- package/esm/path/rect-path.js.map +0 -1
- package/lib/path/catmull-rom-2-bezier.d.ts +0 -10
- package/lib/path/catmull-rom-2-bezier.js +0 -119
- package/lib/path/catmull-rom-2-bezier.js.map +0 -1
- package/lib/path/fill-path-by-diff.d.ts +0 -5
- package/lib/path/fill-path-by-diff.js +0 -117
- package/lib/path/fill-path-by-diff.js.map +0 -1
- package/lib/path/fill-path.d.ts +0 -1
- package/lib/path/fill-path.js +0 -133
- package/lib/path/fill-path.js.map +0 -1
- package/lib/path/format-path.d.ts +0 -1
- package/lib/path/format-path.js +0 -143
- package/lib/path/format-path.js.map +0 -1
- package/lib/path/get-arc-params.d.ts +0 -17
- package/lib/path/get-arc-params.js +0 -95
- package/lib/path/get-arc-params.js.map +0 -1
- package/lib/path/get-line-intersect.d.ts +0 -14
- package/lib/path/get-line-intersect.js +0 -37
- package/lib/path/get-line-intersect.js.map +0 -1
- package/lib/path/is-polygons-intersect.d.ts +0 -1
- package/lib/path/is-polygons-intersect.js +0 -85
- package/lib/path/is-polygons-intersect.js.map +0 -1
- package/lib/path/parse-path-array.d.ts +0 -1
- package/lib/path/parse-path-array.js +0 -9
- package/lib/path/parse-path-array.js.map +0 -1
- package/lib/path/parse-path-string.d.ts +0 -1
- package/lib/path/parse-path-string.js +0 -65
- package/lib/path/parse-path-string.js.map +0 -1
- package/lib/path/parse-path.d.ts +0 -1
- package/lib/path/parse-path.js +0 -37
- package/lib/path/parse-path.js.map +0 -1
- package/lib/path/path-2-absolute.d.ts +0 -1
- package/lib/path/path-2-absolute.js +0 -128
- package/lib/path/path-2-absolute.js.map +0 -1
- package/lib/path/path-2-curve.d.ts +0 -2
- package/lib/path/path-2-curve.js +0 -67
- package/lib/path/path-2-curve.js.map +0 -1
- package/lib/path/path-2-segments.d.ts +0 -1
- package/lib/path/path-2-segments.js +0 -142
- package/lib/path/path-2-segments.js.map +0 -1
- package/lib/path/path-intersection.d.ts +0 -9
- package/lib/path/path-intersection.js +0 -370
- package/lib/path/path-intersection.js.map +0 -1
- package/lib/path/point-in-polygon.d.ts +0 -5
- package/lib/path/point-in-polygon.js +0 -53
- package/lib/path/point-in-polygon.js.map +0 -1
- package/lib/path/rect-path.d.ts +0 -4
- package/lib/path/rect-path.js +0 -23
- package/lib/path/rect-path.js.map +0 -1
- package/src/path/catmull-rom-2-bezier.ts +0 -141
- package/src/path/fill-path-by-diff.ts +0 -116
- package/src/path/fill-path.ts +0 -129
- package/src/path/format-path.ts +0 -142
- package/src/path/get-arc-params.ts +0 -102
- package/src/path/get-line-intersect.ts +0 -46
- package/src/path/is-polygons-intersect.ts +0 -95
- package/src/path/parse-path-array.ts +0 -5
- package/src/path/parse-path-string.ts +0 -62
- package/src/path/parse-path.ts +0 -34
- package/src/path/path-2-absolute.ts +0 -132
- package/src/path/path-2-curve.ts +0 -69
- package/src/path/path-2-segments.ts +0 -142
- package/src/path/path-intersection.ts +0 -419
- package/src/path/point-in-polygon.ts +0 -56
- package/src/path/rect-path.ts +0 -22
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { path2Curve } from '../convert/path-2-curve';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the area of a single cubic-bezier segment.
|
|
4
|
+
*
|
|
5
|
+
* http://objectmix.com/graphics/133553-area-closed-bezier-curve.html
|
|
6
|
+
*/
|
|
7
|
+
function getCubicSegArea(x1, y1, c1x, c1y, c2x, c2y, x2, y2) {
|
|
8
|
+
// https://stackoverflow.com/a/15845996
|
|
9
|
+
return ((3 *
|
|
10
|
+
((y2 - y1) * (c1x + c2x) -
|
|
11
|
+
(x2 - x1) * (c1y + c2y) +
|
|
12
|
+
c1y * (x1 - c2x) -
|
|
13
|
+
c1x * (y1 - c2y) +
|
|
14
|
+
y2 * (c2x + x1 / 3) -
|
|
15
|
+
x2 * (c2y + y1 / 3))) /
|
|
16
|
+
20);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns the area of a shape.
|
|
20
|
+
* @author Jürg Lehni & Jonathan Puckey
|
|
21
|
+
*
|
|
22
|
+
* @see https://github.com/paperjs/paper.js/blob/develop/src/path/Path.js
|
|
23
|
+
*/
|
|
24
|
+
export function getPathArea(path) {
|
|
25
|
+
let x = 0;
|
|
26
|
+
let y = 0;
|
|
27
|
+
let len = 0;
|
|
28
|
+
return path2Curve(path)
|
|
29
|
+
.map((seg) => {
|
|
30
|
+
switch (seg[0]) {
|
|
31
|
+
case 'M':
|
|
32
|
+
[, x, y] = seg;
|
|
33
|
+
return 0;
|
|
34
|
+
default:
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
len = getCubicSegArea(x, y, ...seg.slice(1));
|
|
37
|
+
[x, y] = seg.slice(-2);
|
|
38
|
+
return len;
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
.reduce((a, b) => a + b, 0);
|
|
42
|
+
}
|
|
43
|
+
// export function getPathArea(pathArray: AbsoluteArray) {
|
|
44
|
+
// let x = 0;
|
|
45
|
+
// let y = 0;
|
|
46
|
+
// let mx = 0;
|
|
47
|
+
// let my = 0;
|
|
48
|
+
// let len = 0;
|
|
49
|
+
// return pathArray
|
|
50
|
+
// .map((seg) => {
|
|
51
|
+
// switch (seg[0]) {
|
|
52
|
+
// case 'M':
|
|
53
|
+
// case 'Z':
|
|
54
|
+
// mx = seg[0] === 'M' ? seg[1] : mx;
|
|
55
|
+
// my = seg[0] === 'M' ? seg[2] : my;
|
|
56
|
+
// x = mx;
|
|
57
|
+
// y = my;
|
|
58
|
+
// return 0;
|
|
59
|
+
// default:
|
|
60
|
+
// // @ts-ignore
|
|
61
|
+
// len = getCubicSegArea.apply(0, [x, y].concat(seg.slice(1)));
|
|
62
|
+
// [x, y] = seg.slice(-2) as [number, number];
|
|
63
|
+
// return len;
|
|
64
|
+
// }
|
|
65
|
+
// })
|
|
66
|
+
// .reduce((a, b) => a + b, 0);
|
|
67
|
+
// }
|
|
68
|
+
//# sourceMappingURL=get-path-area.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-path-area.js","sourceRoot":"src/","sources":["path/util/get-path-area.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD;;;;GAIG;AACH,SAAS,eAAe,CACtB,EAAU,EACV,EAAU,EACV,GAAW,EACX,GAAW,EACX,GAAW,EACX,GAAW,EACX,EAAU,EACV,EAAU;IAEV,uCAAuC;IACvC,OAAO,CACL,CAAC,CAAC;QACA,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC;YACtB,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC;YACvB,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC;YAChB,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC;YAChB,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC;YACnB,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;QACzB,EAAE,CACH,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,IAAe;IACzC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,GAAG,GAAG,CAAC,CAAC;IAEZ,OAAO,UAAU,CAAC,IAAI,CAAC;SACpB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACX,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE;YACd,KAAK,GAAG;gBACN,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC;gBACf,OAAO,CAAC,CAAC;YACX;gBACE,aAAa;gBACb,GAAG,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC7C,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBACvB,OAAO,GAAG,CAAC;SACd;IACH,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;AAChC,CAAC;AAED,0DAA0D;AAC1D,eAAe;AACf,eAAe;AACf,gBAAgB;AAChB,gBAAgB;AAChB,iBAAiB;AACjB,qBAAqB;AACrB,sBAAsB;AACtB,0BAA0B;AAC1B,oBAAoB;AACpB,oBAAoB;AACpB,+CAA+C;AAC/C,+CAA+C;AAC/C,oBAAoB;AACpB,oBAAoB;AACpB,sBAAsB;AACtB,mBAAmB;AACnB,0BAA0B;AAC1B,yEAAyE;AACzE,wDAAwD;AACxD,wBAAwB;AACxB,UAAU;AACV,SAAS;AACT,mCAAmC;AACnC,IAAI"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { pathLengthFactory } from './path-length-factory';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the bounding box of a shape.
|
|
4
|
+
*/
|
|
5
|
+
export function getPathBBoxTotalLength(path) {
|
|
6
|
+
if (!path) {
|
|
7
|
+
return {
|
|
8
|
+
length: 0,
|
|
9
|
+
x: 0,
|
|
10
|
+
y: 0,
|
|
11
|
+
width: 0,
|
|
12
|
+
height: 0,
|
|
13
|
+
x2: 0,
|
|
14
|
+
y2: 0,
|
|
15
|
+
cx: 0,
|
|
16
|
+
cy: 0,
|
|
17
|
+
cz: 0,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const { length, min: { x: xMin, y: yMin }, max: { x: xMax, y: yMax }, } = pathLengthFactory(path);
|
|
21
|
+
const width = xMax - xMin;
|
|
22
|
+
const height = yMax - yMin;
|
|
23
|
+
return {
|
|
24
|
+
length,
|
|
25
|
+
width,
|
|
26
|
+
height,
|
|
27
|
+
x: xMin,
|
|
28
|
+
y: yMin,
|
|
29
|
+
x2: xMax,
|
|
30
|
+
y2: yMax,
|
|
31
|
+
cx: xMin + width / 2,
|
|
32
|
+
cy: yMin + height / 2,
|
|
33
|
+
// an estimted guess
|
|
34
|
+
cz: Math.max(width, height) + Math.min(width, height) / 2,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=get-path-bbox-total-length.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-path-bbox-total-length.js","sourceRoot":"src/","sources":["path/util/get-path-bbox-total-length.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAe;IACpD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO;YACL,MAAM,EAAE,CAAC;YACT,CAAC,EAAE,CAAC;YACJ,CAAC,EAAE,CAAC;YACJ,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;YACT,EAAE,EAAE,CAAC;YACL,EAAE,EAAE,CAAC;YACL,EAAE,EAAE,CAAC;YACL,EAAE,EAAE,CAAC;YACL,EAAE,EAAE,CAAC;SACN,CAAC;KACH;IAED,MAAM,EACJ,MAAM,EACN,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EACzB,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,GAC1B,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAE5B,MAAM,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IAE3B,OAAO;QACL,MAAM;QACN,KAAK;QACL,MAAM;QACN,CAAC,EAAE,IAAI;QACP,CAAC,EAAE,IAAI;QACP,EAAE,EAAE,IAAI;QACR,EAAE,EAAE,IAAI;QACR,EAAE,EAAE,IAAI,GAAG,KAAK,GAAG,CAAC;QACpB,EAAE,EAAE,IAAI,GAAG,MAAM,GAAG,CAAC;QACrB,oBAAoB;QACpB,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC;KAC1D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { pathLengthFactory } from './path-length-factory';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the bounding box of a shape.
|
|
4
|
+
*/
|
|
5
|
+
export function getPathBBox(path) {
|
|
6
|
+
if (!path) {
|
|
7
|
+
return {
|
|
8
|
+
x: 0,
|
|
9
|
+
y: 0,
|
|
10
|
+
width: 0,
|
|
11
|
+
height: 0,
|
|
12
|
+
x2: 0,
|
|
13
|
+
y2: 0,
|
|
14
|
+
cx: 0,
|
|
15
|
+
cy: 0,
|
|
16
|
+
cz: 0,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const { min: { x: xMin, y: yMin }, max: { x: xMax, y: yMax }, } = pathLengthFactory(path);
|
|
20
|
+
const width = xMax - xMin;
|
|
21
|
+
const height = yMax - yMin;
|
|
22
|
+
return {
|
|
23
|
+
width,
|
|
24
|
+
height,
|
|
25
|
+
x: xMin,
|
|
26
|
+
y: yMin,
|
|
27
|
+
x2: xMax,
|
|
28
|
+
y2: yMax,
|
|
29
|
+
cx: xMin + width / 2,
|
|
30
|
+
cy: yMin + height / 2,
|
|
31
|
+
// an estimted guess
|
|
32
|
+
cz: Math.max(width, height) + Math.min(width, height) / 2,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=get-path-bbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-path-bbox.js","sourceRoot":"src/","sources":["path/util/get-path-bbox.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,IAAwB;IAClD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO;YACL,CAAC,EAAE,CAAC;YACJ,CAAC,EAAE,CAAC;YACJ,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;YACT,EAAE,EAAE,CAAC;YACL,EAAE,EAAE,CAAC;YACL,EAAE,EAAE,CAAC;YACL,EAAE,EAAE,CAAC;YACL,EAAE,EAAE,CAAC;SACN,CAAC;KACH;IAED,MAAM,EACJ,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EACzB,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,GAC1B,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAE5B,MAAM,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IAE3B,OAAO;QACL,KAAK;QACL,MAAM;QACN,CAAC,EAAE,IAAI;QACP,CAAC,EAAE,IAAI;QACP,EAAE,EAAE,IAAI;QACR,EAAE,EAAE,IAAI;QACR,EAAE,EAAE,IAAI,GAAG,KAAK,GAAG,CAAC;QACpB,EAAE,EAAE,IAAI,GAAG,MAAM,GAAG,CAAC;QACrB,oBAAoB;QACpB,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC;KAC1D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { pathLengthFactory } from './path-length-factory';
|
|
2
|
+
/**
|
|
3
|
+
* Returns [x,y] coordinates of a point at a given length of a shape.
|
|
4
|
+
*/
|
|
5
|
+
export function getPointAtLength(pathInput, distance) {
|
|
6
|
+
return pathLengthFactory(pathInput, distance).point;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=get-point-at-length.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-point-at-length.js","sourceRoot":"src/","sources":["path/util/get-point-at-length.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAA6B,EAAE,QAAgB;IAC9E,OAAO,iBAAiB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PathArray, SegmentProperties } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the segment, its index and length as well as
|
|
4
|
+
* the length to that segment at a given length in a path.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getPropertiesAtLength(pathInput: string | PathArray, distance?: number): SegmentProperties;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { parsePathString } from '../parser/parse-path-string';
|
|
2
|
+
import { getTotalLength } from './get-total-length';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the segment, its index and length as well as
|
|
5
|
+
* the length to that segment at a given length in a path.
|
|
6
|
+
*/
|
|
7
|
+
export function getPropertiesAtLength(pathInput, distance) {
|
|
8
|
+
const pathArray = parsePathString(pathInput);
|
|
9
|
+
if (typeof pathArray === 'string') {
|
|
10
|
+
throw TypeError(pathArray);
|
|
11
|
+
}
|
|
12
|
+
let pathTemp = [...pathArray];
|
|
13
|
+
let pathLength = getTotalLength(pathTemp);
|
|
14
|
+
let index = pathTemp.length - 1;
|
|
15
|
+
let lengthAtSegment = 0;
|
|
16
|
+
let length = 0;
|
|
17
|
+
let segment = pathArray[0];
|
|
18
|
+
const [x, y] = segment.slice(-2);
|
|
19
|
+
const point = { x, y };
|
|
20
|
+
// If the path is empty, return 0.
|
|
21
|
+
if (index <= 0 || !distance || !Number.isFinite(distance)) {
|
|
22
|
+
return {
|
|
23
|
+
segment,
|
|
24
|
+
index: 0,
|
|
25
|
+
length,
|
|
26
|
+
point,
|
|
27
|
+
lengthAtSegment,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (distance >= pathLength) {
|
|
31
|
+
pathTemp = pathArray.slice(0, -1);
|
|
32
|
+
lengthAtSegment = getTotalLength(pathTemp);
|
|
33
|
+
length = pathLength - lengthAtSegment;
|
|
34
|
+
return {
|
|
35
|
+
segment: pathArray[index],
|
|
36
|
+
index,
|
|
37
|
+
length,
|
|
38
|
+
lengthAtSegment,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const segments = [];
|
|
42
|
+
while (index > 0) {
|
|
43
|
+
segment = pathTemp[index];
|
|
44
|
+
pathTemp = pathTemp.slice(0, -1);
|
|
45
|
+
lengthAtSegment = getTotalLength(pathTemp);
|
|
46
|
+
length = pathLength - lengthAtSegment;
|
|
47
|
+
pathLength = lengthAtSegment;
|
|
48
|
+
segments.push({
|
|
49
|
+
segment,
|
|
50
|
+
index,
|
|
51
|
+
length,
|
|
52
|
+
lengthAtSegment,
|
|
53
|
+
});
|
|
54
|
+
index -= 1;
|
|
55
|
+
}
|
|
56
|
+
return segments.find(({ lengthAtSegment: l }) => l <= distance);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=get-properties-at-length.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-properties-at-length.js","sourceRoot":"src/","sources":["path/util/get-properties-at-length.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAA6B,EAAE,QAAiB;IACpF,MAAM,SAAS,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;IAE7C,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;QACjC,MAAM,SAAS,CAAC,SAAS,CAAC,CAAC;KAC5B;IAED,IAAI,QAAQ,GAAc,CAAC,GAAG,SAAS,CAAC,CAAC;IACzC,IAAI,UAAU,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC1C,IAAI,KAAK,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IAChC,IAAI,eAAe,GAAG,CAAC,CAAC;IACxB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,OAAO,GAAgB,SAAS,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAEvB,kCAAkC;IAClC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QACzD,OAAO;YACL,OAAO;YACP,KAAK,EAAE,CAAC;YACR,MAAM;YACN,KAAK;YACL,eAAe;SAChB,CAAC;KACH;IAED,IAAI,QAAQ,IAAI,UAAU,EAAE;QAC1B,QAAQ,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAc,CAAC;QAC/C,eAAe,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC3C,MAAM,GAAG,UAAU,GAAG,eAAe,CAAC;QACtC,OAAO;YACL,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC;YACzB,KAAK;YACL,MAAM;YACN,eAAe;SAChB,CAAC;KACH;IAED,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,OAAO,KAAK,GAAG,CAAC,EAAE;QAChB,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC1B,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAc,CAAC;QAC9C,eAAe,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC3C,MAAM,GAAG,UAAU,GAAG,eAAe,CAAC;QACtC,UAAU,GAAG,eAAe,CAAC;QAC7B,QAAQ,CAAC,IAAI,CAAC;YACZ,OAAO;YACP,KAAK;YACL,MAAM;YACN,eAAe;SAChB,CAAC,CAAC;QACH,KAAK,IAAI,CAAC,CAAC;KACZ;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Point, PathArray, PointProperties } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the point and segment in path closest to a given point as well as
|
|
4
|
+
* the distance to the path stroke.
|
|
5
|
+
* @see https://bl.ocks.org/mbostock/8027637
|
|
6
|
+
*/
|
|
7
|
+
export declare function getPropertiesAtPoint(pathInput: string | PathArray, point: Point): PointProperties;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { parsePathString } from '../parser/parse-path-string';
|
|
2
|
+
import { normalizePath } from '../process/normalize-path';
|
|
3
|
+
import { getPointAtLength } from './get-point-at-length';
|
|
4
|
+
import { getPropertiesAtLength } from './get-properties-at-length';
|
|
5
|
+
import { getTotalLength } from './get-total-length';
|
|
6
|
+
/**
|
|
7
|
+
* Returns the point and segment in path closest to a given point as well as
|
|
8
|
+
* the distance to the path stroke.
|
|
9
|
+
* @see https://bl.ocks.org/mbostock/8027637
|
|
10
|
+
*/
|
|
11
|
+
export function getPropertiesAtPoint(pathInput, point) {
|
|
12
|
+
const path = parsePathString(pathInput);
|
|
13
|
+
const normalPath = normalizePath(path);
|
|
14
|
+
const pathLength = getTotalLength(path);
|
|
15
|
+
const distanceTo = (p) => {
|
|
16
|
+
const dx = p.x - point.x;
|
|
17
|
+
const dy = p.y - point.y;
|
|
18
|
+
return dx * dx + dy * dy;
|
|
19
|
+
};
|
|
20
|
+
let precision = 8;
|
|
21
|
+
let scan;
|
|
22
|
+
let scanDistance = 0;
|
|
23
|
+
let closest;
|
|
24
|
+
let bestLength = 0;
|
|
25
|
+
let bestDistance = Infinity;
|
|
26
|
+
// linear scan for coarse approximation
|
|
27
|
+
for (let scanLength = 0; scanLength <= pathLength; scanLength += precision) {
|
|
28
|
+
scan = getPointAtLength(normalPath, scanLength);
|
|
29
|
+
scanDistance = distanceTo(scan);
|
|
30
|
+
if (scanDistance < bestDistance) {
|
|
31
|
+
closest = scan;
|
|
32
|
+
bestLength = scanLength;
|
|
33
|
+
bestDistance = scanDistance;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// binary search for precise estimate
|
|
37
|
+
precision /= 2;
|
|
38
|
+
let before;
|
|
39
|
+
let after;
|
|
40
|
+
let beforeLength = 0;
|
|
41
|
+
let afterLength = 0;
|
|
42
|
+
let beforeDistance = 0;
|
|
43
|
+
let afterDistance = 0;
|
|
44
|
+
while (precision > 0.5) {
|
|
45
|
+
beforeLength = bestLength - precision;
|
|
46
|
+
before = getPointAtLength(normalPath, beforeLength);
|
|
47
|
+
beforeDistance = distanceTo(before);
|
|
48
|
+
afterLength = bestLength + precision;
|
|
49
|
+
after = getPointAtLength(normalPath, afterLength);
|
|
50
|
+
afterDistance = distanceTo(after);
|
|
51
|
+
if (beforeLength >= 0 && beforeDistance < bestDistance) {
|
|
52
|
+
closest = before;
|
|
53
|
+
bestLength = beforeLength;
|
|
54
|
+
bestDistance = beforeDistance;
|
|
55
|
+
}
|
|
56
|
+
else if (afterLength <= pathLength && afterDistance < bestDistance) {
|
|
57
|
+
closest = after;
|
|
58
|
+
bestLength = afterLength;
|
|
59
|
+
bestDistance = afterDistance;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
precision /= 2;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const segment = getPropertiesAtLength(path, bestLength);
|
|
66
|
+
const distance = Math.sqrt(bestDistance);
|
|
67
|
+
return { closest, distance, segment };
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=get-properties-at-point.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-properties-at-point.js","sourceRoot":"src/","sources":["path/util/get-properties-at-point.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAA6B,EAAE,KAAY;IAC9E,MAAM,IAAI,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;IACxC,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,UAAU,GAAG,CAAC,CAAQ,EAAE,EAAE;QAC9B,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;QACzB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;QACzB,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IAC3B,CAAC,CAAC;IACF,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,IAAW,CAAC;IAChB,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,OAAc,CAAC;IACnB,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,YAAY,GAAG,QAAQ,CAAC;IAE5B,uCAAuC;IACvC,KAAK,IAAI,UAAU,GAAG,CAAC,EAAE,UAAU,IAAI,UAAU,EAAE,UAAU,IAAI,SAAS,EAAE;QAC1E,IAAI,GAAG,gBAAgB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAChD,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,YAAY,GAAG,YAAY,EAAE;YAC/B,OAAO,GAAG,IAAI,CAAC;YACf,UAAU,GAAG,UAAU,CAAC;YACxB,YAAY,GAAG,YAAY,CAAC;SAC7B;KACF;IAED,qCAAqC;IACrC,SAAS,IAAI,CAAC,CAAC;IACf,IAAI,MAAa,CAAC;IAClB,IAAI,KAAY,CAAC;IACjB,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,aAAa,GAAG,CAAC,CAAC;IAEtB,OAAO,SAAS,GAAG,GAAG,EAAE;QACtB,YAAY,GAAG,UAAU,GAAG,SAAS,CAAC;QACtC,MAAM,GAAG,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QACpD,cAAc,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QACpC,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;QACrC,KAAK,GAAG,gBAAgB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAClD,aAAa,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,YAAY,IAAI,CAAC,IAAI,cAAc,GAAG,YAAY,EAAE;YACtD,OAAO,GAAG,MAAM,CAAC;YACjB,UAAU,GAAG,YAAY,CAAC;YAC1B,YAAY,GAAG,cAAc,CAAC;SAC/B;aAAM,IAAI,WAAW,IAAI,UAAU,IAAI,aAAa,GAAG,YAAY,EAAE;YACpE,OAAO,GAAG,KAAK,CAAC;YAChB,UAAU,GAAG,WAAW,CAAC;YACzB,YAAY,GAAG,aAAa,CAAC;SAC9B;aAAM;YACL,SAAS,IAAI,CAAC,CAAC;SAChB;KACF;IAED,MAAM,OAAO,GAAG,qBAAqB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAEzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { distanceSquareRoot } from './distance-square-root';
|
|
2
|
+
function getRotations(a) {
|
|
3
|
+
const segCount = a.length;
|
|
4
|
+
const pointCount = segCount - 1;
|
|
5
|
+
return a.map((f, idx) => a.map((p, i) => {
|
|
6
|
+
let oldSegIdx = idx + i;
|
|
7
|
+
let seg;
|
|
8
|
+
if (i === 0 || (a[oldSegIdx] && a[oldSegIdx][0] === 'M')) {
|
|
9
|
+
seg = a[oldSegIdx];
|
|
10
|
+
return ['M'].concat(seg.slice(-2));
|
|
11
|
+
}
|
|
12
|
+
if (oldSegIdx >= segCount)
|
|
13
|
+
oldSegIdx -= pointCount;
|
|
14
|
+
return a[oldSegIdx];
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
export function getRotatedCurve(a, b) {
|
|
18
|
+
const segCount = a.length - 1;
|
|
19
|
+
const lineLengths = [];
|
|
20
|
+
let computedIndex = 0;
|
|
21
|
+
let sumLensSqrd = 0;
|
|
22
|
+
const rotations = getRotations(a);
|
|
23
|
+
rotations.forEach((r, i) => {
|
|
24
|
+
a.slice(1).forEach((s, j) => {
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
sumLensSqrd += distanceSquareRoot(a[(i + j) % segCount].slice(-2), b[j % segCount].slice(-2));
|
|
27
|
+
});
|
|
28
|
+
lineLengths[i] = sumLensSqrd;
|
|
29
|
+
sumLensSqrd = 0;
|
|
30
|
+
});
|
|
31
|
+
computedIndex = lineLengths.indexOf(Math.min.apply(null, lineLengths));
|
|
32
|
+
return rotations[computedIndex];
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=get-rotated-curve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-rotated-curve.js","sourceRoot":"src/","sources":["path/util/get-rotated-curve.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,SAAS,YAAY,CAAC,CAAa;IACjC,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1B,MAAM,UAAU,GAAG,QAAQ,GAAG,CAAC,CAAC;IAEhC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CACtB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACb,IAAI,SAAS,GAAG,GAAG,GAAG,CAAC,CAAC;QACxB,IAAI,GAAG,CAAC;QAER,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,EAAE;YACxD,GAAG,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC;YACnB,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACpC;QACD,IAAI,SAAS,IAAI,QAAQ;YAAE,SAAS,IAAI,UAAU,CAAC;QACnD,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC;IACtB,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,CAAa,EAAE,CAAa;IAC1D,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9B,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,MAAM,SAAS,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IAElC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACzB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YAC1B,aAAa;YACb,WAAW,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChG,CAAC,CAAC,CAAC;QACH,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;QAC7B,WAAW,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;IAEvE,OAAO,SAAS,CAAC,aAAa,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PathArray } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the shape total length, or the equivalent to `shape.getTotalLength()`.
|
|
4
|
+
*
|
|
5
|
+
* The `normalizePath` version is lighter, faster, more efficient and more accurate
|
|
6
|
+
* with paths that are not `curveArray`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getTotalLength(pathInput: string | PathArray): number;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { pathLengthFactory } from './path-length-factory';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the shape total length, or the equivalent to `shape.getTotalLength()`.
|
|
4
|
+
*
|
|
5
|
+
* The `normalizePath` version is lighter, faster, more efficient and more accurate
|
|
6
|
+
* with paths that are not `curveArray`.
|
|
7
|
+
*/
|
|
8
|
+
export function getTotalLength(pathInput) {
|
|
9
|
+
return pathLengthFactory(pathInput).length;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=get-total-length.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-total-length.js","sourceRoot":"src/","sources":["path/util/get-total-length.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,SAA6B;IAC1D,OAAO,iBAAiB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isPathArray } from './is-path-array';
|
|
2
|
+
/**
|
|
3
|
+
* Iterates an array to check if it's a `PathArray`
|
|
4
|
+
* with all absolute values.
|
|
5
|
+
*/
|
|
6
|
+
export function isAbsoluteArray(path) {
|
|
7
|
+
return (isPathArray(path) &&
|
|
8
|
+
// @ts-ignore -- `isPathArray` also checks if it's `Array`
|
|
9
|
+
path.every(([x]) => x === x.toUpperCase()));
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=is-absolute-array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-absolute-array.js","sourceRoot":"src/","sources":["path/util/is-absolute-array.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,IAAwB;IACtD,OAAO,CACL,WAAW,CAAC,IAAI,CAAC;QACjB,0DAA0D;QAC1D,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC,CAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PathArray } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Iterates an array to check if it's a `PathArray`
|
|
4
|
+
* with all C (cubic bezier) segments.
|
|
5
|
+
*
|
|
6
|
+
* @param {string | PathArray} path the `Array` to be checked
|
|
7
|
+
* @returns {boolean} iteration result
|
|
8
|
+
*/
|
|
9
|
+
export declare function isCurveArray(path: string | PathArray): path is PathArray;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isNormalizedArray } from './is-normalized-array';
|
|
2
|
+
/**
|
|
3
|
+
* Iterates an array to check if it's a `PathArray`
|
|
4
|
+
* with all C (cubic bezier) segments.
|
|
5
|
+
*
|
|
6
|
+
* @param {string | PathArray} path the `Array` to be checked
|
|
7
|
+
* @returns {boolean} iteration result
|
|
8
|
+
*/
|
|
9
|
+
export function isCurveArray(path) {
|
|
10
|
+
return isNormalizedArray(path) && path.every(([pc]) => 'MC'.includes(pc));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=is-curve-array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-curve-array.js","sourceRoot":"src/","sources":["path/util/is-curve-array.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,IAAwB;IACnD,OAAO,iBAAiB,CAAC,IAAI,CAAC,IAAK,IAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AAC3F,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PathArray } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Iterates an array to check if it's a `PathArray`
|
|
4
|
+
* with all segments are in non-shorthand notation
|
|
5
|
+
* with absolute values.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isNormalizedArray(path: string | PathArray): path is PathArray;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isAbsoluteArray } from './is-absolute-array';
|
|
2
|
+
/**
|
|
3
|
+
* Iterates an array to check if it's a `PathArray`
|
|
4
|
+
* with all segments are in non-shorthand notation
|
|
5
|
+
* with absolute values.
|
|
6
|
+
*/
|
|
7
|
+
export function isNormalizedArray(path) {
|
|
8
|
+
return isAbsoluteArray(path) && path.every(([pc]) => 'ACLMQZ'.includes(pc));
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=is-normalized-array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-normalized-array.js","sourceRoot":"src/","sources":["path/util/is-normalized-array.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAwB;IACxD,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { paramsCount } from '../parser/params-count';
|
|
2
|
+
/**
|
|
3
|
+
* Iterates an array to check if it's an actual `PathArray`.
|
|
4
|
+
*/
|
|
5
|
+
export function isPathArray(path) {
|
|
6
|
+
return (Array.isArray(path) &&
|
|
7
|
+
path.every((seg) => {
|
|
8
|
+
const lk = seg[0].toLowerCase();
|
|
9
|
+
return paramsCount[lk] === seg.length - 1 && 'achlmqstvz'.includes(lk);
|
|
10
|
+
}));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=is-path-array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-path-array.js","sourceRoot":"src/","sources":["path/util/is-path-array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGrD;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,IAAwB;IAClD,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACnB,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACjB,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;YAChC,OAAO,WAAW,CAAC,EAAE,CAAC,KAAK,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACzE,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { getPropertiesAtPoint } from './get-properties-at-point';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a given point is in the stroke of a path.
|
|
4
|
+
*/
|
|
5
|
+
export function isPointInStroke(pathInput, point) {
|
|
6
|
+
const { distance } = getPropertiesAtPoint(pathInput, point);
|
|
7
|
+
return Math.abs(distance) < 0.001; // 0.01 might be more permissive
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=is-point-in-stroke.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-point-in-stroke.js","sourceRoot":"src/","sources":["path/util/is-point-in-stroke.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,SAA6B,EAAE,KAAY;IACzE,MAAM,EAAE,QAAQ,EAAE,GAAG,oBAAoB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC5D,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,CAAC,gCAAgC;AACrE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function midPoint(a: number[], b: number[], t: number): number[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mid-point.js","sourceRoot":"src/","sources":["path/util/mid-point.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,CAAW,EAAE,CAAW,EAAE,CAAS;IAC1D,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAChB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAChB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAChB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PathArray, LengthFactory } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a {x,y} point at a given length
|
|
4
|
+
* of a shape, the shape total length and
|
|
5
|
+
* the shape minimum and maximum {x,y} coordinates.
|
|
6
|
+
*/
|
|
7
|
+
export declare function pathLengthFactory(pathInput: string | PathArray, distance?: number): LengthFactory;
|