@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,30 @@
|
|
|
1
|
+
import type { PathCommand } from '../types';
|
|
2
|
+
import { paramsCount } from './params-count';
|
|
3
|
+
import type { PathParser } from './path-parser';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Breaks the parsing of a pathString once a segment is finalized.
|
|
7
|
+
*/
|
|
8
|
+
export function finalizeSegment(path: PathParser) {
|
|
9
|
+
let pathCommand = path.pathValue[path.segmentStart] as PathCommand;
|
|
10
|
+
let LK = pathCommand.toLowerCase();
|
|
11
|
+
const { data } = path;
|
|
12
|
+
|
|
13
|
+
while (data.length >= paramsCount[LK]) {
|
|
14
|
+
// overloaded `moveTo`
|
|
15
|
+
// https://github.com/rveciana/svg-path-properties/blob/master/src/parse.ts
|
|
16
|
+
if (LK === 'm' && data.length > 2) {
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
path.segments.push([pathCommand, ...data.splice(0, 2)]);
|
|
19
|
+
LK = 'l';
|
|
20
|
+
pathCommand = pathCommand === 'm' ? 'l' : 'L';
|
|
21
|
+
} else {
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
path.segments.push([pathCommand, ...data.splice(0, paramsCount[LK])]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!paramsCount[LK]) {
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the character is or belongs to a number.
|
|
3
|
+
* [0-9]|+|-|.
|
|
4
|
+
*/
|
|
5
|
+
export function isDigitStart(code: number) {
|
|
6
|
+
return (
|
|
7
|
+
(code >= 48 && code <= 57) /* 0..9 */ || code === 0x2b /* + */ || code === 0x2d /* - */ || code === 0x2e
|
|
8
|
+
); /* . */
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function isDigit(code: number) {
|
|
12
|
+
return code >= 48 && code <= 57; // 0..9
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the character is a path command.
|
|
3
|
+
*/
|
|
4
|
+
export function isPathCommand(code: number) {
|
|
5
|
+
// eslint-disable-next-line no-bitwise -- Impossible to satisfy
|
|
6
|
+
switch (code | 0x20) {
|
|
7
|
+
case 0x6d /* m */:
|
|
8
|
+
case 0x7a /* z */:
|
|
9
|
+
case 0x6c /* l */:
|
|
10
|
+
case 0x68 /* h */:
|
|
11
|
+
case 0x76 /* v */:
|
|
12
|
+
case 0x63 /* c */:
|
|
13
|
+
case 0x73 /* s */:
|
|
14
|
+
case 0x71 /* q */:
|
|
15
|
+
case 0x74 /* t */:
|
|
16
|
+
case 0x61 /* a */:
|
|
17
|
+
// case 0x72/* r */:
|
|
18
|
+
return true;
|
|
19
|
+
default:
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the character is a space.
|
|
3
|
+
*/
|
|
4
|
+
export function isSpace(ch: number) {
|
|
5
|
+
const specialSpaces = [
|
|
6
|
+
0x1680, 0x180e, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200a, 0x202f,
|
|
7
|
+
0x205f, 0x3000, 0xfeff,
|
|
8
|
+
];
|
|
9
|
+
/* istanbul ignore next */
|
|
10
|
+
return (
|
|
11
|
+
ch === 0x0a ||
|
|
12
|
+
ch === 0x0d ||
|
|
13
|
+
ch === 0x2028 ||
|
|
14
|
+
ch === 0x2029 || // Line terminators
|
|
15
|
+
// White spaces
|
|
16
|
+
ch === 0x20 ||
|
|
17
|
+
ch === 0x09 ||
|
|
18
|
+
ch === 0x0b ||
|
|
19
|
+
ch === 0x0c ||
|
|
20
|
+
ch === 0xa0 ||
|
|
21
|
+
(ch >= 0x1680 && specialSpaces.includes(ch))
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { clonePath } from '../process/clone-path';
|
|
2
|
+
import { isPathArray } from '../util/is-path-array';
|
|
3
|
+
import type { PathArray } from '../types';
|
|
4
|
+
import { scanSegment } from './scan-segment';
|
|
5
|
+
import { skipSpaces } from './skip-spaces';
|
|
6
|
+
import { PathParser } from './path-parser';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Parses a path string value and returns an array
|
|
10
|
+
* of segments we like to call `pathArray`.
|
|
11
|
+
*/
|
|
12
|
+
export function parsePathString(pathInput: PathArray | string): PathArray | string {
|
|
13
|
+
if (isPathArray(pathInput)) {
|
|
14
|
+
return clonePath(pathInput) as PathArray;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const path = new PathParser(pathInput);
|
|
18
|
+
|
|
19
|
+
skipSpaces(path);
|
|
20
|
+
|
|
21
|
+
while (path.index < path.max && !path.err.length) {
|
|
22
|
+
scanSegment(path);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return path.err ? path.err : path.segments;
|
|
26
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { PathArray } from '../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The `PathParser` is used by the `parsePathString` static method
|
|
5
|
+
* to generate a `pathArray`.
|
|
6
|
+
*/
|
|
7
|
+
export class PathParser {
|
|
8
|
+
pathValue: string;
|
|
9
|
+
|
|
10
|
+
segments: PathArray;
|
|
11
|
+
|
|
12
|
+
max: number;
|
|
13
|
+
|
|
14
|
+
index: number;
|
|
15
|
+
|
|
16
|
+
param: number;
|
|
17
|
+
|
|
18
|
+
segmentStart: number;
|
|
19
|
+
|
|
20
|
+
data: any;
|
|
21
|
+
|
|
22
|
+
err: string;
|
|
23
|
+
|
|
24
|
+
constructor(pathString: string) {
|
|
25
|
+
this.pathValue = pathString;
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
this.segments = [];
|
|
28
|
+
this.max = pathString.length;
|
|
29
|
+
this.index = 0;
|
|
30
|
+
this.param = 0.0;
|
|
31
|
+
this.segmentStart = 0;
|
|
32
|
+
this.data = [];
|
|
33
|
+
this.err = '';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { PathParser } from './path-parser';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Validates an A (arc-to) specific path command value.
|
|
5
|
+
* Usually a `large-arc-flag` or `sweep-flag`.
|
|
6
|
+
*/
|
|
7
|
+
export function scanFlag(path: PathParser) {
|
|
8
|
+
const { index, pathValue } = path;
|
|
9
|
+
const code = pathValue.charCodeAt(index);
|
|
10
|
+
|
|
11
|
+
if (code === 0x30 /* 0 */) {
|
|
12
|
+
path.param = 0;
|
|
13
|
+
path.index += 1;
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (code === 0x31 /* 1 */) {
|
|
18
|
+
path.param = 1;
|
|
19
|
+
path.index += 1;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
path.err = `[path-util]: invalid Arc flag "${pathValue[index]}", expecting 0 or 1 at index ${index}`;
|
|
24
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { isDigit } from './is-digit-start';
|
|
2
|
+
import type { PathParser } from './path-parser';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Validates every character of the path string,
|
|
6
|
+
* every path command, negative numbers or floating point numbers.
|
|
7
|
+
*/
|
|
8
|
+
export function scanParam(path: PathParser) {
|
|
9
|
+
const { max, pathValue, index: start } = path;
|
|
10
|
+
let index = start;
|
|
11
|
+
let zeroFirst = false;
|
|
12
|
+
let hasCeiling = false;
|
|
13
|
+
let hasDecimal = false;
|
|
14
|
+
let hasDot = false;
|
|
15
|
+
let ch;
|
|
16
|
+
|
|
17
|
+
if (index >= max) {
|
|
18
|
+
// path.err = 'SvgPath: missed param (at pos ' + index + ')';
|
|
19
|
+
path.err = `[path-util]: Invalid path value at index ${index}, "pathValue" is missing param`;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
ch = pathValue.charCodeAt(index);
|
|
23
|
+
|
|
24
|
+
if (ch === 0x2b /* + */ || ch === 0x2d /* - */) {
|
|
25
|
+
index += 1;
|
|
26
|
+
// ch = (index < max) ? pathValue.charCodeAt(index) : 0;
|
|
27
|
+
ch = pathValue.charCodeAt(index);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// This logic is shamelessly borrowed from Esprima
|
|
31
|
+
// https://github.com/ariya/esprimas
|
|
32
|
+
if (!isDigit(ch) && ch !== 0x2e /* . */) {
|
|
33
|
+
// path.err = 'SvgPath: param should start with 0..9 or `.` (at pos ' + index + ')';
|
|
34
|
+
path.err = `[path-util]: Invalid path value at index ${index}, "${pathValue[index]}" is not a number`;
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (ch !== 0x2e /* . */) {
|
|
39
|
+
zeroFirst = ch === 0x30 /* 0 */;
|
|
40
|
+
index += 1;
|
|
41
|
+
|
|
42
|
+
ch = pathValue.charCodeAt(index);
|
|
43
|
+
|
|
44
|
+
if (zeroFirst && index < max) {
|
|
45
|
+
// decimal number starts with '0' such as '09' is illegal.
|
|
46
|
+
if (ch && isDigit(ch)) {
|
|
47
|
+
// path.err = 'SvgPath: numbers started with `0` such as `09`
|
|
48
|
+
// are illegal (at pos ' + start + ')';
|
|
49
|
+
path.err = `[path-util]: Invalid path value at index ${start}, "${pathValue[start]}" illegal number`;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
while (index < max && isDigit(pathValue.charCodeAt(index))) {
|
|
55
|
+
index += 1;
|
|
56
|
+
hasCeiling = true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
ch = pathValue.charCodeAt(index);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (ch === 0x2e /* . */) {
|
|
63
|
+
hasDot = true;
|
|
64
|
+
index += 1;
|
|
65
|
+
while (isDigit(pathValue.charCodeAt(index))) {
|
|
66
|
+
index += 1;
|
|
67
|
+
hasDecimal = true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
ch = pathValue.charCodeAt(index);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (ch === 0x65 /* e */ || ch === 0x45 /* E */) {
|
|
74
|
+
if (hasDot && !hasCeiling && !hasDecimal) {
|
|
75
|
+
path.err = `[path-util]: Invalid path value at index ${index}, "${pathValue[index]}" invalid float exponent`;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
index += 1;
|
|
80
|
+
|
|
81
|
+
ch = pathValue.charCodeAt(index);
|
|
82
|
+
|
|
83
|
+
if (ch === 0x2b /* + */ || ch === 0x2d /* - */) {
|
|
84
|
+
index += 1;
|
|
85
|
+
}
|
|
86
|
+
if (index < max && isDigit(pathValue.charCodeAt(index))) {
|
|
87
|
+
while (index < max && isDigit(pathValue.charCodeAt(index))) {
|
|
88
|
+
index += 1;
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
path.err = `[path-util]: Invalid path value at index ${index}, "${pathValue[index]}" invalid integer exponent`;
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
path.index = index;
|
|
97
|
+
path.param = +path.pathValue.slice(start, index);
|
|
98
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { finalizeSegment } from './finalize-segment';
|
|
2
|
+
import { paramsCount } from './params-count';
|
|
3
|
+
import { scanFlag } from './scan-flag';
|
|
4
|
+
import { scanParam } from './scan-param';
|
|
5
|
+
import { skipSpaces } from './skip-spaces';
|
|
6
|
+
import { isPathCommand } from './is-path-command';
|
|
7
|
+
import { isDigitStart } from './is-digit-start';
|
|
8
|
+
import { isArcCommand } from './is-arc-command';
|
|
9
|
+
import type { PathParser } from './path-parser';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Scans every character in the path string to determine
|
|
13
|
+
* where a segment starts and where it ends.
|
|
14
|
+
*/
|
|
15
|
+
export function scanSegment(path: PathParser) {
|
|
16
|
+
const { max, pathValue, index } = path;
|
|
17
|
+
const cmdCode = pathValue.charCodeAt(index);
|
|
18
|
+
const reqParams = paramsCount[pathValue[index].toLowerCase()];
|
|
19
|
+
|
|
20
|
+
path.segmentStart = index;
|
|
21
|
+
|
|
22
|
+
if (!isPathCommand(cmdCode)) {
|
|
23
|
+
path.err = `[path-util]: Invalid path value "${pathValue[index]}" is not a path command`;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
path.index += 1;
|
|
28
|
+
skipSpaces(path);
|
|
29
|
+
|
|
30
|
+
path.data = [];
|
|
31
|
+
|
|
32
|
+
if (!reqParams) {
|
|
33
|
+
// Z
|
|
34
|
+
finalizeSegment(path);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
for (;;) {
|
|
39
|
+
for (let i = reqParams; i > 0; i -= 1) {
|
|
40
|
+
if (isArcCommand(cmdCode) && (i === 3 || i === 4)) scanFlag(path);
|
|
41
|
+
else scanParam(path);
|
|
42
|
+
|
|
43
|
+
if (path.err.length) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
path.data.push(path.param);
|
|
47
|
+
|
|
48
|
+
skipSpaces(path);
|
|
49
|
+
|
|
50
|
+
// after ',' param is mandatory
|
|
51
|
+
if (path.index < max && pathValue.charCodeAt(path.index) === 0x2c /* , */) {
|
|
52
|
+
path.index += 1;
|
|
53
|
+
skipSpaces(path);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (path.index >= path.max) {
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Stop on next segment
|
|
62
|
+
if (!isDigitStart(pathValue.charCodeAt(path.index))) {
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
finalizeSegment(path);
|
|
68
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { isSpace } from './is-space';
|
|
2
|
+
import type { PathParser } from './path-parser';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Points the parser to the next character in the
|
|
6
|
+
* path string every time it encounters any kind of
|
|
7
|
+
* space character.
|
|
8
|
+
*/
|
|
9
|
+
export function skipSpaces(path: PathParser) {
|
|
10
|
+
const { pathValue, max } = path;
|
|
11
|
+
while (path.index < max && isSpace(pathValue.charCodeAt(path.index))) {
|
|
12
|
+
path.index += 1;
|
|
13
|
+
}
|
|
14
|
+
}
|