@antv/util 3.0.0 → 3.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/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 +36 -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 +40 -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/.DS_Store +0 -0
- package/src/path/.DS_Store +0 -0
- 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 +37 -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 -57
- 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 -61
- 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 -63
- 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
package/README.md
CHANGED
|
@@ -2,21 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
> AntV 底层依赖的工具库,不建议在自己业务中使用。
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
[](https://github.com/antvis/util/actions)
|
|
7
6
|
[](https://www.npmjs.com/package/@antv/util)
|
|
8
7
|
[](https://www.npmjs.com/package/@antv/util)
|
|
9
8
|
[](https://www.npmjs.com/package/@antv/util)
|
|
10
9
|
|
|
11
|
-
|
|
12
10
|
## Usage
|
|
13
11
|
|
|
14
12
|
```ts
|
|
15
13
|
import { gradient } from '@antv/util';
|
|
16
|
-
|
|
17
14
|
```
|
|
18
15
|
|
|
19
|
-
|
|
20
16
|
## 原则
|
|
21
17
|
|
|
22
18
|
- util 只有一个 npm 包,按照目录来组织不同类型的方法,避免 monorepo 互相依赖
|
|
@@ -24,7 +20,174 @@ import { gradient } from '@antv/util';
|
|
|
24
20
|
- 不使用的方法,及时删除,并保持新增方法可以按需引入
|
|
25
21
|
- 旧版本的不维护,如果 AntV 技术栈的旧版本需要迭代,请升级到 v3
|
|
26
22
|
|
|
23
|
+
## API
|
|
24
|
+
|
|
25
|
+
提供以下 Path 工具方法,包含转换、几何计算等。
|
|
26
|
+
|
|
27
|
+
### path2String
|
|
28
|
+
|
|
29
|
+
将 PathArray 转换成字符串形式,不会对原始定义中的命令进行修改:
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
const str: PathArray = [
|
|
33
|
+
['M', 10, 10],
|
|
34
|
+
['L', 100, 100],
|
|
35
|
+
['l', 10, 10],
|
|
36
|
+
['h', 20],
|
|
37
|
+
['v', 20],
|
|
38
|
+
];
|
|
39
|
+
expect(path2String(str)).toEqual('M10 10L100 100l10 10h20v20');
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### path2Absolute
|
|
43
|
+
|
|
44
|
+
将定义中的相对命令转换成绝对命令,例如:
|
|
45
|
+
|
|
46
|
+
- l -> L
|
|
47
|
+
- h -> H
|
|
48
|
+
- v -> V
|
|
49
|
+
|
|
50
|
+
完整方法签名如下:
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
path2Absolute(pathInput: string | PathArray): AbsoluteArray;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
const str: PathArray = [
|
|
58
|
+
['M', 10, 10],
|
|
59
|
+
['L', 100, 100],
|
|
60
|
+
['l', 10, 10],
|
|
61
|
+
['h', 20],
|
|
62
|
+
['v', 20],
|
|
63
|
+
];
|
|
64
|
+
const arr = path2Absolute(str);
|
|
65
|
+
expect(arr).toEqual([
|
|
66
|
+
['M', 10, 10],
|
|
67
|
+
['L', 100, 100],
|
|
68
|
+
['L', 110, 110],
|
|
69
|
+
['H', 130],
|
|
70
|
+
['V', 130],
|
|
71
|
+
]);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### path2Curve
|
|
75
|
+
|
|
76
|
+
将部分命令转曲,例如 L / A 转成 C 命令,借助 cubic bezier 易于分割的特性用于实现形变动画。
|
|
77
|
+
该方法内部会调用 [path2Absolute](#path2Absolute),因此最终返回的 PathArray 中仅包含 M 和 C 命令。
|
|
78
|
+
|
|
79
|
+
完整方法签名如下:
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
path2Curve(pathInput: string | PathArray): CurveArray;
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
expect(
|
|
87
|
+
path2Curve([
|
|
88
|
+
['M', 0, 0],
|
|
89
|
+
['L', 100, 100],
|
|
90
|
+
]),
|
|
91
|
+
).toEqual([
|
|
92
|
+
['M', 0, 0],
|
|
93
|
+
['C', 44.194173824159215, 44.194173824159215, 68.75, 68.75, 100, 100],
|
|
94
|
+
]);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### clonePath
|
|
98
|
+
|
|
99
|
+
复制路径:
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
const cloned = clonePath(pathInput);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### reverseCurve
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
const pathArray: CurveArray = [
|
|
109
|
+
['M', 170, 90],
|
|
110
|
+
['C', 150, 90, 155, 10, 130, 10],
|
|
111
|
+
['C', 105, 10, 110, 90, 90, 90],
|
|
112
|
+
['C', 70, 90, 75, 10, 50, 10],
|
|
113
|
+
['C', 25, 10, 30, 90, 10, 90],
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
const reversed = reverseCurve(pathArray);
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### getPathBBox
|
|
120
|
+
|
|
121
|
+
获取几何定义下的包围盒,形如:
|
|
122
|
+
|
|
123
|
+
```js
|
|
124
|
+
export interface PathBBox {
|
|
125
|
+
width: number;
|
|
126
|
+
height: number;
|
|
127
|
+
x: number;
|
|
128
|
+
y: number;
|
|
129
|
+
x2: number;
|
|
130
|
+
y2: number;
|
|
131
|
+
cx: number;
|
|
132
|
+
cy: number;
|
|
133
|
+
cz: number;
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
```js
|
|
138
|
+
const bbox = getPathBBox([['M', 0, 0], ['L', 100, 0], ['L', 100, 100], ['L', 0, 100], ['Z']]);
|
|
139
|
+
|
|
140
|
+
expect(bbox).toEqual({ cx: 50, cy: 50, cz: 150, height: 100, width: 100, x: 0, x2: 100, y: 0, y2: 100 });
|
|
141
|
+
```
|
|
27
142
|
|
|
143
|
+
### getTotalLength
|
|
144
|
+
|
|
145
|
+
获取路径总长度。
|
|
146
|
+
|
|
147
|
+
```js
|
|
148
|
+
const length = getTotalLength([['M', 0, 0], ['L', 100, 0], ['L', 100, 100], ['L', 0, 100], ['Z']]);
|
|
149
|
+
|
|
150
|
+
expect(length).toEqual(400);
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### getPointAtLength
|
|
154
|
+
|
|
155
|
+
获取路径上从起点出发,到指定距离的点。
|
|
156
|
+
|
|
157
|
+
```js
|
|
158
|
+
const point = getPointAtLength([['M', 0, 0], ['L', 100, 0], ['L', 100, 100], ['L', 0, 100], ['Z']], 0);
|
|
159
|
+
expect(point).toEqual({ x: 0, y: 0 });
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### getPathArea
|
|
163
|
+
|
|
164
|
+
计算路径包围的面积。内部实现中首先通过 [path2Curve](#path2Curve) 转曲,再计算 cubic curve 面积,[详见](https://stackoverflow.com/a/15845996)。
|
|
165
|
+
|
|
166
|
+
### isPointInStroke
|
|
167
|
+
|
|
168
|
+
判断一个点是否在路径上,仅通过几何定义,不考虑其他样式属性例如线宽、lineJoin、miter 等。
|
|
169
|
+
|
|
170
|
+
```js
|
|
171
|
+
const result = isPointInStroke(segments, { x: 10, y: 10 });
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### distanceSquareRoot
|
|
175
|
+
|
|
176
|
+
计算两点之间的距离。
|
|
177
|
+
|
|
178
|
+
方法签名如下:
|
|
179
|
+
|
|
180
|
+
```js
|
|
181
|
+
distanceSquareRoot(a: [number, number], b: [number, number]): number;
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### equalizeSegments
|
|
185
|
+
|
|
186
|
+
将两条路径处理成段数相同,用于形变动画前的分割操作。
|
|
187
|
+
|
|
188
|
+
```js
|
|
189
|
+
const [formattedPath1, formattedPath2] = equalizeSegments(path1, path2);
|
|
190
|
+
```
|
|
28
191
|
|
|
29
192
|
## License
|
|
30
193
|
|
package/dist/util.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).util={})}(this,function(t){"use strict";function n(t){return[parseInt(t.substr(1,2),16),parseInt(t.substr(3,2),16),parseInt(t.substr(5,2),16)]}function r(t){t=Math.round(t).toString(16);return 1===t.length?"0"+t:t}function u(t){return"#"+r(t[0])+r(t[1])+r(t[2])}var a,z=/rgba?\(([\s.,0-9]+)\)/;function e(t){if("#"===t[0]&&7===t.length)return t;a||((n=document.createElement("i")).title="Web Colour Picker",n.style.display="none",document.body.appendChild(n),a=n),a.style.color=t;var n=document.defaultView.getComputedStyle(a,"").getPropertyValue("color");return u(z.exec(n)[1].split(/\s*,\s*/).map(function(t){return Number(t)}))}function i(t,n,r,a){return t[a]+(n[a]-t[a])*r}var N=/^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i,V=/^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i,Z=/[\d.]+:(#[^\s]+|[^)]+\))/gi;var o="undefined"!=typeof Float32Array?Float32Array:Array;function l(t,n,r){var a=n[0],e=n[1],o=n[2],u=n[3],i=n[4],c=n[5],h=n[6],s=n[7],n=n[8],f=r[0],l=r[1],p=r[2],x=r[3],y=r[4],v=r[5],g=r[6],M=r[7],r=r[8];return t[0]=f*a+l*u+p*h,t[1]=f*e+l*i+p*s,t[2]=f*o+l*c+p*n,t[3]=x*a+y*u+v*h,t[4]=x*e+y*i+v*s,t[5]=x*o+y*c+v*n,t[6]=g*a+M*u+r*h,t[7]=g*e+M*i+r*s,t[8]=g*o+M*c+r*n,t}function c(){var t=new o(3);return o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function h(t,n,r){var a=new o(3);return a[0]=t,a[1]=n,a[2]=r,a}Math.hypot||(Math.hypot=function(){for(var t=0,n=arguments.length;n--;)t+=arguments[n]*arguments[n];return Math.sqrt(t)});function s(){var t=new o(4);return o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}c(),v=new o(4),o!=Float32Array&&(v[0]=0,v[1]=0,v[2]=0,v[3]=0);function b(t,n,r){return t[0]=n[0]+r[0],t[1]=n[1]+r[1],t}function A(t,n,r){return t[0]=Math.min(n[0],r[0]),t[1]=Math.min(n[1],r[1]),t}function w(t,n,r){return t[0]=Math.max(n[0],r[0]),t[1]=Math.max(n[1],r[1]),t}function P(t,n,r){return t[0]=n[0]*r,t[1]=n[1]*r,t}function T(t,n){var r=n[0]-t[0],n=n[1]-t[1];return Math.hypot(r,n)}c(),h(1,0,0),h(0,1,0),s(),s(),v=new o(9),o!=Float32Array&&(v[1]=0,v[2]=0,v[3]=0,v[5]=0,v[6]=0,v[7]=0),v[0]=1,v[4]=1,v[8]=1;var k=function(t,n,r){return t[0]=n[0]-r[0],t[1]=n[1]-r[1],t};function R(t,n,r){var a,e,o=[0,0,0,0,0,0,0,0,0];a=o,r=r,e=Math.sin(r),r=Math.cos(r),a[0]=r,a[1]=e,a[2]=0,a[3]=-e,a[4]=r,a[5]=0,a[6]=0,a[7]=0,a[8]=1,l(t,o,n)}function f(t,n){return t[0]*n[1]-n[0]*t[1]}v=new o(2),o!=Float32Array&&(v[0]=0,v[1]=0);var H=/[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/gi,E=/[^\s,]+/gi;function C(t){var a=t||[];return Array.isArray(a)?a:"string"==typeof a?((a=a.match(H)).forEach(function(r,t){var n;1<(r=r.match(E))[0].length&&(n=r[0].charAt(0),r.splice(1,0,r[0].substr(1)),r[0]=n),r.forEach(function(t,n){isNaN(t)||(r[n]=+t)}),a[t]=r}),a):void 0}function X(t,n){var o=[],u=[];return t.length&&function t(n,r){if(1===n.length)o.push(n[0]),u.push(n[0]);else{for(var a=[],e=0;e<n.length-1;e++)0===e&&o.push(n[0]),e===n.length-2&&u.push(n[e+1]),a[e]=[(1-r)*n[e][0]+r*n[e+1][0],(1-r)*n[e][1]+r*n[e+1][1]];t(a,r)}}(t,n),{left:o,right:u.reverse()}}function Y(t,n,r){if(1===r)return[[].concat(t)];var a=[];if("L"===n[0]||"C"===n[0]||"Q"===n[0])a=a.concat(function(t,n,r){for(var t=[[t[1],t[2]]],a=(r=r||2,[]),e=("A"===n[0]?(t.push(n[6]),t.push(n[7])):"C"===n[0]?(t.push([n[1],n[2]]),t.push([n[3],n[4]]),t.push([n[5],n[6]])):"S"===n[0]||"Q"===n[0]?(t.push([n[1],n[2]]),t.push([n[3],n[4]])):t.push([n[1],n[2]]),t),o=1/r,u=0;u<r-1;u++){var i=X(e,o/(1-o*u));a.push(i.left),e=i.right}return a.push(e),a.map(function(t){var n=[];return 4===t.length&&(n.push("C"),n=n.concat(t[2])),3<=t.length&&(3===t.length&&n.push("Q"),n=n.concat(t[1])),2===t.length&&n.push("L"),n=n.concat(t[t.length-1])})}(t,n,r));else{var e=[].concat(t);"M"===e[0]&&(e[0]="L");for(var o=0;o<=r-1;o++)a.push(e)}return a}var B=function t(n,r){if(n===r)return!0;if(n&&r&&"object"==typeof n&&"object"==typeof r){if(n.constructor!==r.constructor)return!1;var a,e,o;if(Array.isArray(n)){if((a=n.length)!=r.length)return!1;for(e=a;0!=e--;)if(!t(n[e],r[e]))return!1;return!0}if(n.constructor===RegExp)return n.source===r.source&&n.flags===r.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===r.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===r.toString();if((a=(o=Object.keys(n)).length)!==Object.keys(r).length)return!1;for(e=a;0!=e--;)if(!Object.prototype.hasOwnProperty.call(r,o[e]))return!1;for(e=a;0!=e--;){var u=o[e];if(!t(n[u],r[u]))return!1}return!0}return n!=n&&r!=r};function p(t){var n=[];switch(t[0]){case"M":case"L":n.push([t[1],t[2]]);break;case"A":n.push([t[6],t[7]]);break;case"Q":n.push([t[3],t[4]]),n.push([t[1],t[2]]);break;case"T":n.push([t[1],t[2]]);break;case"C":n.push([t[5],t[6]]),n.push([t[1],t[2]]),n.push([t[3],t[4]]);break;case"S":n.push([t[3],t[4]]),n.push([t[1],t[2]]);break;case"H":case"V":n.push([t[1],t[1]])}return n}function x(t,n,r){for(var a,e=[].concat(t),o=1/(r+1),u=p(n)[0],i=1;i<=r;i++)o*=i,0===(a=Math.floor(t.length*o))?e.unshift([u[0]*o+t[a][0]*(1-o),u[1]*o+t[a][1]*(1-o)]):e.splice(a,0,[u[0]*o+t[a][0]*(1-o),u[1]*o+t[a][1]*(1-o)]);return e}function y(t,n,r,a,e){return e?[["M",+t+ +e,n],["l",r-2*e,0],["a",e,e,0,0,1,e,e],["l",0,a-2*e],["a",e,e,0,0,1,-e,e],["l",2*e-r,0],["a",e,e,0,0,1,-e,-e],["l",0,2*e-a],["a",e,e,0,0,1,e,-e],["z"]]:[["M",t,n],["l",r,0],["l",0,a],["l",-r,0],["z"]]}var v="\t\n\v\f\r \u2028\u2029",G=new RegExp("([a-z])["+v+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+v+"]*,?["+v+"]*)+)","ig"),_=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+v+"]*,?["+v+"]*","ig");function d(t){if(!t)return null;if(Array.isArray(t))return t;var o={a:7,c:6,o:2,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,u:3,z:0},u=[];return String(t).replace(G,function(t,n,r){var a=[],e=n.toLowerCase();if(r.replace(_,function(t,n){n&&a.push(+n)}),"m"===e&&2<a.length&&(u.push([n].concat(a.splice(0,2))),e="l",n="m"===n?"l":"L"),"o"===e&&1===a.length&&u.push([n,a[0]]),"r"===e)u.push([n].concat(a));else for(;a.length>=o[e]&&(u.push([n].concat(a.splice(0,o[e]))),o[e]););return""}),u}var D=/[a-z]/;function U(t,n){return[n[0]+(n[0]-t[0]),n[1]+(n[1]-t[1])]}function W(t){var n=d(t);if(!n||!n.length)return[["M",0,0]];for(var r=!1,a=0;a<n.length;a++){var e=n[a][0];if(D.test(e)||0<=["V","H","T","S"].indexOf(e)){r=!0;break}}if(!r)return n;var o=[],u=0,i=0,c=0,h=0,t=0,s=n[0];"M"!==s[0]&&"m"!==s[0]||(c=u=+s[1],h=i=+s[2],t++,o[0]=["M",u,i]);for(var a=t,f=n.length;a<f;a++){var l=n[a],p=o[a-1],x=[],y=(e=l[0]).toUpperCase();if(e!==y)switch(x[0]=y){case"A":x[1]=l[1],x[2]=l[2],x[3]=l[3],x[4]=l[4],x[5]=l[5],x[6]=+l[6]+u,x[7]=+l[7]+i;break;case"V":x[1]=+l[1]+i;break;case"H":x[1]=+l[1]+u;break;case"M":c=+l[1]+u,h=+l[2]+i,x[1]=c,x[2]=h;break;default:for(var v=1,g=l.length;v<g;v++)x[v]=+l[v]+(v%2?u:i)}else x=n[a];switch(y){case"Z":u=+c,i=+h;break;case"H":x=["L",u=x[1],i];break;case"V":x=["L",u,i=x[1]];break;case"T":var u=x[1],i=x[2],M=U([p[1],p[2]],[p[3],p[4]]),x=["Q",M[0],M[1],u,i];break;case"S":u=x[x.length-2],i=x[x.length-1];var M=p.length,m=U([p[M-4],p[M-3]],[p[M-2],p[M-1]]);x=["C",m[0],m[1],x[1],x[2],u,i];break;case"M":c=x[x.length-2],h=x[x.length-1];break;default:u=x[x.length-2],i=x[x.length-1]}o.push(x)}return o}function $(t,n,r,a){var e=t*r+n*a;return(e=1<e?1:e)<-1&&(e=-1),(t*a-n*r<0?-1:1)*Math.acos(e)}function J(t){var n=t.px,r=t.py,a=t.cx,e=t.cy,o=t.rx,u=t.ry,i=void 0===(i=t.xAxisRotation)?0:i,c=void 0===(c=t.largeArcFlag)?0:c,t=void 0===(t=t.sweepFlag)?0:t,h=[];if(0===o||0===u)return[{x1:0,y1:0,x2:0,y2:0,x:a,y:e}];var s=Math.sin(i*F/360),f=Math.cos(i*F/360),l=-s*(n-a)/2+f*(r-e)/2;if(0==(i=f*(n-a)/2+s*(r-e)/2)&&0==l)return[{x1:0,y1:0,x2:0,y2:0,x:a,y:e}];var o=Math.abs(o),u=Math.abs(u),p=Math.pow(i,2)/Math.pow(o,2)+Math.pow(l,2)/Math.pow(u,2);1<p&&(o*=Math.sqrt(p),u*=Math.sqrt(p));var x=(p=tt(n,r,a,e,o,u,c,t,s,f,i,l))[0],y=p[1],v=p[2],g=p[3],n=Math.abs(g)/(F/4),M=(Math.abs(1-n)<1e-7&&(n=1),Math.max(Math.ceil(n),1));g/=M;for(var m=0;m<M;m++)h.push(K(v,g)),v+=g;return h.map(function(t){var n=S(t[0],o,u,f,s,x,y),r=n.x,n=n.y,a=S(t[1],o,u,f,s,x,y),e=a.x,a=a.y,t=S(t[2],o,u,f,s,x,y);return{x1:r,y1:n,x2:e,y2:a,x:t.x,y:t.y}})}var F=2*Math.PI,S=function(t,n,r,a,e,o,u){var i=t.x,t=t.y;return{x:a*(i*=n)-e*(t*=r)+o,y:e*i+a*t+u}},K=function(t,n){var r=1.5707963267948966===n?.551915024494:-1.5707963267948966===n?-.551915024494:4/3*Math.tan(n/4),a=Math.cos(t),e=Math.sin(t),o=Math.cos(t+n),t=Math.sin(t+n);return[{x:a-e*r,y:e+a*r},{x:o+t*r,y:t-o*r},{x:o,y:t}]},tt=function(t,n,r,a,e,o,u,i,c,h,s,f){var l=Math.pow(e,2),p=Math.pow(o,2),x=Math.pow(s,2),y=Math.pow(f,2),v=l*p-l*y-p*x,l=(v<0&&(v=0),v/=l*y+p*x,(v=Math.sqrt(v)*(u===i?-1:1))*e/o*f),y=v*-o/e*s,p=h*l-c*y+(t+r)/2,x=c*l+h*y+(n+a)/2,u=(s-l)/e,v=(f-y)/o,t=(-s-l)/e,r=(-f-y)/o,c=$(1,0,u,v),h=$(u,v,t,r);return 0===i&&0<h&&(h-=F),1===i&&h<0&&(h+=F),[p,x,c,h]};function g(t,n,r,a){return[t,n,r,a,r,a]}function nt(t,n){"TQ".indexOf(t[0])<0&&(n.qx=null,n.qy=null);var r=t.slice(1),a=r[0],e=r[1];switch(t[0]){case"M":return n.x=a,n.y=e,t;case"A":return["C"].concat(function(t,n,r,a,e,o,u,i,c){return J({px:t,py:n,cx:i,cy:c,rx:r,ry:a,xAxisRotation:e,largeArcFlag:o,sweepFlag:u}).reduce(function(t,n){var r=n.x1,a=n.y1,e=n.x2,o=n.y2,u=n.x,n=n.y;return t.push(r,a,e,o,u,n),t},[])}.apply(0,[n.x1,n.y1].concat(t.slice(1))));case"Q":return n.qx=a,n.qy=e,["C"].concat(function(t,n,r,a,e,o){return[1/3*t+2/3*r,1/3*n+2/3*a,1/3*e+2/3*r,1/3*o+2/3*a,e,o]}.apply(0,[n.x1,n.y1].concat(t.slice(1))));case"L":return["C"].concat(g(n.x1,n.y1,t[1],t[2]));case"H":return["C"].concat(g(n.x1,n.y1,t[1],n.y1));case"V":return["C"].concat(g(n.x1,n.y1,n.x1,t[1]));case"Z":return["C"].concat(g(n.x1,n.y1,n.x,n.y))}return t}function q(t,n){void 0===n&&(n=!1);for(var r,a,e=W(t),o={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null},u=[],i="",c=e.length,h=[],s=0;s<c;s+=1){e[s]&&(i=e[s][0]),u[s]=i,e[s]=nt(e[s],o),y=x=p=l=f=void 0;var f=e,l=u,p=s;if(7<f[p].length){f[p].shift();for(var x=f[p],y=p;x.length;)l[p]="A",f.splice(y+=1,0,["C"].concat(x.splice(0,6)));f.splice(p,1)}c=e.length,"Z"===i&&h.push(s),a=(r=e[s]).length,o.x1=+r[a-2],o.y1=+r[a-1],o.x2=+r[a-4]||o.x1,o.y2=+r[a-3]||o.y1}return n?[e,h]:e}function rt(t,n,r,a,e){return t*(t*(-3*n+9*r-9*a+3*e)+6*n-12*r+6*a)-3*n+3*r}function at(t,n,r,a,e,o,u,i,c){for(var h=(c=1<(c=null===c?1:c)?1:c<0?0:c)/2,s=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],f=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],l=0,p=0;p<12;p++){var x=h*s[p]+h,y=rt(x,t,r,e,u),x=rt(x,n,a,o,i);l+=f[p]*Math.sqrt(y*y+x*x)}return h*l}function L(t,n,r){return n>=t.x&&n<=t.x+t.width&&r>=t.y&&r<=t.y+t.height}function I(t,n,r,a){return null===t&&(t=n=r=a=0),null===n&&(n=t.y,r=t.width,a=t.height,t=t.x),{x:t,y:n,width:r,w:r,height:a,h:a,x2:t+r,y2:n+a,cx:t+r/2,cy:n+a/2,r1:Math.min(r,a)/2,r2:Math.max(r,a)/2,r0:Math.sqrt(r*r+a*a)/2,path:y(t,n,r,a),vb:[t,n,r,a].join(" ")}}function et(t,n,r,a,e,o,u,i){return Array.isArray(t)||(t=[t,n,r,a,e,o,u,i]),n=function(t,n,r,a,e,o,u,i){for(var c,h,s,f=[],l=[[],[]],p=0;p<2;++p){var x,y=0===p?(h=6*t-12*r+6*e,c=-3*t+9*r-9*e+3*u,3*r-3*t):(h=6*n-12*a+6*o,c=-3*n+9*a-9*o+3*i,3*a-3*n);Math.abs(c)<1e-12?Math.abs(h)<1e-12||0<(s=-y/h)&&s<1&&f.push(s):(y=h*h-4*y*c,x=Math.sqrt(y),y<0||(0<(y=(-h+x)/(2*c))&&y<1&&f.push(y),0<(y=(-h-x)/(2*c))&&y<1&&f.push(y)))}for(var v,g=f.length,M=g;g--;)s=f[g],l[0][g]=(v=1-s)*v*v*t+3*v*v*s*r+3*v*s*s*e+s*s*s*u,l[1][g]=v*v*v*n+3*v*v*s*a+3*v*s*s*o+s*s*s*i;return l[0][M]=t,l[1][M]=n,l[0][M+1]=u,l[1][M+1]=i,l[0].length=l[1].length=M+2,{min:{x:Math.min.apply(0,l[0]),y:Math.min.apply(0,l[1])},max:{x:Math.max.apply(0,l[0]),y:Math.max.apply(0,l[1])}}}.apply(null,t),I(n.min.x,n.min.y,n.max.x-n.min.x,n.max.y-n.min.y)}function ot(t,n,r,a,e,o,u,i,c){var h=1-c,s=Math.pow(h,3),f=Math.pow(h,2),l=c*c,p=l*c,x=t+2*c*(r-t)+l*(e-2*r+t),y=n+2*c*(a-n)+l*(o-2*a+n),v=r+2*c*(e-r)+l*(u-2*e+r);return{x:s*t+3*f*c*r+3*h*c*c*e+p*u,y:s*n+3*f*c*a+3*h*c*c*o+p*i,m:{x:x,y:y},n:{x:v,y:l=a+2*c*(o-a)+l*(i-2*o+a)},start:{x:h*t+c*r,y:h*n+c*a},end:{x:h*e+c*u,y:h*o+c*i},alpha:90-180*Math.atan2(x-v,y-l)/Math.PI}}var ut=function(t,n,r){var a=et(t),e=et(n);if(e=e,a=I(a=a),e=I(e),!(L(e,a.x,a.y)||L(e,a.x2,a.y)||L(e,a.x,a.y2)||L(e,a.x2,a.y2)||L(a,e.x,e.y)||L(a,e.x2,e.y)||L(a,e.x,e.y2)||L(a,e.x2,e.y2)||(a.x<e.x2&&a.x>e.x||e.x<a.x2&&e.x>a.x)&&(a.y<e.y2&&a.y>e.y||e.y<a.y2&&e.y>a.y)))return r?0:[];for(var o=~~(at.apply(0,t)/8),u=~~(at.apply(0,n)/8),i=[],c=[],h={},s=r?0:[],f=0;f<1+o;f++){var l=ot.apply(0,t.concat(f/o));i.push({x:l.x,y:l.y,t:f/o})}for(f=0;f<1+u;f++){l=ot.apply(0,n.concat(f/u));c.push({x:l.x,y:l.y,t:f/u})}for(f=0;f<o;f++)for(var p=0;p<u;p++){var x=i[f],y=i[f+1],v=c[p],g=c[p+1],M=Math.abs(y.x-x.x)<.001?"y":"x",m=Math.abs(g.x-v.x)<.001?"y":"x",d=function(t,n,r,a,e,o,u,i){if(!(Math.max(t,r)<Math.min(e,u)||Math.min(t,r)>Math.max(e,u)||Math.max(n,a)<Math.min(o,i)||Math.min(n,a)>Math.max(o,i))){var c=(t*a-n*r)*(e-u)-(t-r)*(e*i-o*u),h=(t*a-n*r)*(o-i)-(n-a)*(e*i-o*u),s=(t-r)*(o-i)-(n-a)*(e-u);if(s){var c=c/s,h=h/s,s=+c.toFixed(2),f=+h.toFixed(2);if(!(s<+Math.min(t,r).toFixed(2)||s>+Math.max(t,r).toFixed(2)||s<+Math.min(e,u).toFixed(2)||s>+Math.max(e,u).toFixed(2)||f<+Math.min(n,a).toFixed(2)||f>+Math.max(n,a).toFixed(2)||f<+Math.min(o,i).toFixed(2)||f>+Math.max(o,i).toFixed(2)))return{x:c,y:h}}}}(x.x,x.y,y.x,y.y,v.x,v.y,g.x,g.y);d&&h[d.x.toFixed(4)]!==d.y.toFixed(4)&&(h[d.x.toFixed(4)]=d.y.toFixed(4),M=x.t+Math.abs((d[M]-x[M])/(y[M]-x[M]))*(y.t-x.t),y=v.t+Math.abs((d[m]-v[m])/(g[m]-v[m]))*(g.t-v.t),0<=M&&M<=1&&0<=y&&y<=1&&(r?s++:s.push({x:d.x,y:d.y,t1:M,t2:y})))}return s};var it=/,?([a-z]),?/gi;var ct=Math.PI/180;function M(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function m(t,n){return M(t)*M(n)?(t[0]*n[0]+t[1]*n[1])/(M(t)*M(n)):1}function ht(t,n){return(t[0]*n[1]<t[1]*n[0]?-1:1)*Math.acos(m(t,n))}function Q(t,n){return t[0]===n[0]&&t[1]===n[1]}function st(t,n){var r=n[1],a=n[2],e=(e=n[3],e=ct*e,o=2*Math.PI,(e%o+o)%o),o=n[4],u=n[5],i=t[0],c=t[1],h=n[6],n=n[7],s=Math.cos(e)*(i-h)/2+Math.sin(e)*(c-n)/2,f=-1*Math.sin(e)*(i-h)/2+Math.cos(e)*(c-n)/2,l=s*s/(r*r)+f*f/(a*a),l=(1<l&&(r*=Math.sqrt(l),a*=Math.sqrt(l)),r*r*(f*f)+a*a*(s*s)),l=l?Math.sqrt((r*r*(a*a)-l)/l):1,p=(o===u&&(l*=-1),isNaN(l)&&(l=0),a?l*r*f/a:0),l=r?l*-a*s/r:0,i=(i+h)/2+Math.cos(e)*p-Math.sin(e)*l,c=(c+n)/2+Math.sin(e)*p+Math.cos(e)*l,x=[(s-p)/r,(f-l)/a],s=[(-1*s-p)/r,(-1*f-l)/a],p=ht([1,0],x),f=ht(x,s);return m(x,s)<=-1&&(f=Math.PI),1<=m(x,s)&&(f=0),0===u&&0<f&&(f-=2*Math.PI),1===u&&f<0&&(f+=2*Math.PI),{cx:i,cy:c,rx:Q(t,[h,n])?0:r,ry:Q(t,[h,n])?0:a,startAngle:p,endAngle:p+f,xRotation:e,arcFlag:o,sweepFlag:u}}function ft(t,n){return[n[0]+(n[0]-t[0]),n[1]+(n[1]-t[1])]}function lt(t,n,r){return n<=t&&t<=r}function pt(t,n,r,a){var e=r.x-t.x,o=r.y-t.y,u=n.x-t.x,n=n.y-t.y,i=a.x-r.x,a=a.y-r.y,r=u*a-n*i,c=null;return.001*(u*u+n*n)*(i*i+a*a)<r*r&&(lt(a=(e*a-o*i)/r,0,1)&<((e*n-o*u)/r,0,1)&&(c={x:t.x+a*u,y:t.y+a*n})),c}var xt=1e-6;function O(t){return Math.abs(t)<xt?0:t<0?-1:1}function j(t,n,r){var a=!1,e=t.length;if(e<=2)return!1;for(var o,u,i,c=0;c<e;c++){var h=t[c],s=t[(c+1)%e];if(u=s,((i=[n,r])[0]-(o=h)[0])*(u[1]-o[1])==(u[0]-o[0])*(i[1]-o[1])&&Math.min(o[0],u[0])<=i[0]&&i[0]<=Math.max(o[0],u[0])&&Math.min(o[1],u[1])<=i[1]&&i[1]<=Math.max(o[1],u[1]))return!0;0<O(h[1]-r)!=0<O(s[1]-r)&&O(n-(r-h[1])*(h[0]-s[0])/(h[1]-s[1])-h[0])<0&&(a=!a)}return a}function yt(t){for(var n,r,a=[],e=t.length,o=0;o<e-1;o++){var u=t[o],i=t[o+1];a.push({from:{x:u[0],y:u[1]},to:{x:i[0],y:i[1]}})}return 1<a.length&&(n=t[0],r=t[e-1],a.push({from:{x:r[0],y:r[1]},to:{x:n[0],y:n[1]}})),a}function vt(t){var n=t.map(function(t){return t[0]}),t=t.map(function(t){return t[1]});return{minX:Math.min.apply(null,n),maxX:Math.max.apply(null,n),minY:Math.min.apply(null,t),maxY:Math.max.apply(null,t)}}t.angleTo=function(t,n,r){e=n,u=(a=t)[0],a=a[1],i=e[0],e=e[1],o=Math.sqrt(u*u+a*a)*Math.sqrt(i*i+e*e);var a,e,o,u=Math.acos(Math.min(Math.max(o&&(u*i+a*e)/o,-1),1)),i=0<=f(t,n);return r?i?2*Math.PI-u:u:i?u:2*Math.PI-u},t.catmullRom2Bezier=function(t,n,r){void 0===r&&(r=[[0,0],[1,1]]);for(var n=!!(n=void 0===n?!1:n),a=[],e=0,o=t.length;e<o;e+=2)a.push([t[e],t[e+1]]);for(var u,i,c,h=function(t,n,r,a){var e,o=[],u=!!a;if(u){h=a[0],s=a[1];for(var i=0,c=t.length;i<c;i+=1)var h=A([0,0],h,d=t[i]),s=w([0,0],s,d)}for(var i=0,f=t.length;i<f;i+=1){var l,p,x,y,v,g,M,m,d=t[i];0!==i||r?i!==f-1||r?(l=t[[i?i-1:f-1,i-1][r?0:1]],p=t[r?(i+1)%f:i+1],g=P(g=k([0,0],p,l),g,n),0!==(v=(x=T(d,l))+(y=T(d,p)))&&(x/=v,y/=v),v=P([0,0],g,-x),g=P([0,0],g,y),M=b([0,0],d,v),m=A([0,0],m=b([0,0],d,g),w([0,0],p,d)),m=w([0,0],m,A([0,0],p,d)),M=A([0,0],M=b([0,0],d,v=P([0,0],v=k([0,0],m,d),-x/y)),w([0,0],l,d)),M=w([0,0],M,A([0,0],l,d)),m=b([0,0],d,g=P([0,0],g=k([0,0],d,M),y/x)),u&&(M=A([0,0],M=w([0,0],M,h),s),m=A([0,0],m=w([0,0],m,h),s)),o.push(e),o.push(M),e=m):(M=d,o.push(e),o.push(M)):e=d}return r&&o.push(o.shift()),o}(a,.4,n,r),s=a.length,f=[],e=0;e<s-1;e+=1)u=h[2*e],i=h[2*e+1],c=a[e+1],f.push(["C",u[0],u[1],i[0],i[1],c[0],c[1]]);return n&&(u=h[s],i=h[s+1],c=a[0],f.push(["C",u[0],u[1],i[0],i[1],c[0],c[1]])),f},t.direction=f,t.fillPath=function(a,t){if(1===a.length)return a;var e=a.length-1,n=t.length-1,r=e/n,o=[];if(1===a.length&&"M"===a[0][0]){for(var u=0;u<n-e;u++)a.push(a[0]);return a}for(u=0;u<n;u++){var i=Math.floor(r*u);o[i]=(o[i]||0)+1}var c=o.reduce(function(t,n,r){return r===e?t.concat(a[e]):t.concat(Y(a[r],a[r+1],n))},[]);return c.unshift(a[0]),"Z"!==t[n]&&"z"!==t[n]||c.push("Z"),c},t.fillPathByDiff=function(t,n){var r=function(t,n){var r=t.length,a=n.length,e=0;if(0===r||0===a)return null;for(var o=[],u=0;u<=r;u++)o[u]=[],o[u][0]={min:u};for(var i=0;i<=a;i++)o[0][i]={min:i};for(var c,u=1;u<=r;u++)for(var h=t[u-1],i=1;i<=a;i++){var s=n[i-1],e=B(h,s)?0:1,s=o[u-1][i].min+1,f=o[u][i-1].min+1,l=o[u-1][i-1].min+e;o[u][i]=(void 0,c=null,(f=f)<(l=l)&&(l=f,c="add"),(f=s)<l&&(l=f,c="del"),{type:c,min:l})}return o}(t,n),a=t.length,e=n.length,o=[],u=1,i=1;if(r[a][e]!==a){for(var c=1;c<=a;c++){for(var h=r[c][c].min,i=c,s=u;s<=e;s++)r[c][s].min<h&&(h=r[c][s].min,i=s);u=i,r[c][u].type&&o.push({index:c-1,type:r[c][u].type})}for(c=o.length-1;0<=c;c--)u=o[c].index,"add"===o[c].type?t.splice(u,0,[].concat(t[u])):t.splice(u,1)}if((a=t.length)<e)for(c=0;c<e-a;c++)"z"===t[a-1][0]||"Z"===t[a-1][0]?t.splice(a-2,0,t[a-2]):t.push(t[a-1]);return t},t.formatPath=function(t,n){if(t.length<=1)return t;for(var r,a=0;a<n.length;a++)if(t[a][0]!==n[a][0])switch(r=p(t[a]),n[a][0]){case"M":t[a]=["M"].concat(r[0]);break;case"L":t[a]=["L"].concat(r[0]);break;case"A":t[a]=[].concat(n[a]),t[a][6]=r[0][0],t[a][7]=r[0][1];break;case"Q":if(r.length<2){if(!(0<a)){t[a]=n[a];break}r=x(r,t[a-1],1)}t[a]=["Q"].concat(r.reduce(function(t,n){return t.concat(n)},[]));break;case"T":t[a]=["T"].concat(r[0]);break;case"C":if(r.length<3){if(!(0<a)){t[a]=n[a];break}r=x(r,t[a-1],2)}t[a]=["C"].concat(r.reduce(function(t,n){return t.concat(n)},[]));break;case"S":if(r.length<2){if(!(0<a)){t[a]=n[a];break}r=x(r,t[a-1],1)}t[a]=["S"].concat(r.reduce(function(t,n){return t.concat(n)},[]));break;default:t[a]=n[a]}return t},t.getArcParams=st,t.getLineIntersect=pt,t.gradient=function(t){var o=("string"==typeof t?t.split("-"):t).map(function(t){return n(-1===t.indexOf("#")?e(t):t)});return function(t){return n=o,t=t,t=isNaN(Number(t))||t<0?0:1<t?1:Number(t),r=n.length-1,a=Math.floor(r*t),t=r*t-a,e=n[a],r=a===r?e:n[a+1],u([i(e,r,t,0),i(e,r,t,1),i(e,r,t,2)]);var n,r,a,e}},t.isPointInPolygon=j,t.isPolygonsIntersect=function(n,r){if(n.length<2||r.length<2)return!1;var t=vt(n),a=vt(r);if(t=t,(a=a).minX>t.maxX||a.maxX<t.minX||a.minY>t.maxY||a.maxY<t.minY)return!1;if(r.some(function(t){return j(n,t[0],t[1])}))return!0;if(n.some(function(t){return j(r,t[0],t[1])}))return!0;var o=yt(n);return yt(r).some(function(t){for(var n=o,r=t,a=0;a<n.length;a++){var e=n[a];if(pt(e.from,e.to,r.from,r.to))return!0}return!1})},t.parsePath=C,t.parsePathArray=function(t){return t.join(",").replace(it,"$1")},t.parsePathString=d,t.path2Absolute=W,t.path2Curve=q,t.path2Segments=function(t){for(var n=[],r=null,a=null,e=null,o=0,u=(t=C(t)).length,i=0;i<u;i++){var c=t[i],a=t[i+1],h=c[0],s={command:h,prePoint:r,params:c,startTangent:null,endTangent:null};switch(h){case"M":e=[c[1],c[2]],o=i;break;case"A":var f=st(r,c);s.arcParams=f}"Z"===h?(r=e,a=t[o+1]):r=[c[(P=c.length)-2],c[P-1]],a&&"Z"===a[0]&&(a=t[o],n[o]&&(n[o].prePoint=r)),s.currentPoint=r,n[o]&&Q(r,n[o].currentPoint)&&(n[o].prePoint=s.prePoint);var l,p,x,y,v,g,M,m,d,b,A,w,P=a?[a[a.length-2],a[a.length-1]]:null,T=(s.nextPoint=P,s.prePoint);["L","H","V"].includes(h)?(s.startTangent=[T[0]-r[0],T[1]-r[1]],s.endTangent=[r[0]-T[0],r[1]-T[1]]):"Q"===h?(l=[c[1],c[2]],s.startTangent=[T[0]-l[0],T[1]-l[1]],s.endTangent=[r[0]-l[0],r[1]-l[1]]):"T"===h?(l=ft((p=n[i-1]).currentPoint,T),"Q"===p.command?(s.command="Q",s.startTangent=[T[0]-l[0],T[1]-l[1]],s.endTangent=[r[0]-l[0],r[1]-l[1]]):(s.command="TL",s.startTangent=[T[0]-r[0],T[1]-r[1]],s.endTangent=[r[0]-T[0],r[1]-T[1]])):"C"===h?(x=[c[1],c[2]],y=[c[3],c[4]],s.startTangent=[T[0]-x[0],T[1]-x[1]],s.endTangent=[r[0]-y[0],r[1]-y[1]],0===s.startTangent[0]&&0===s.startTangent[1]&&(s.startTangent=[x[0]-y[0],x[1]-y[1]]),0===s.endTangent[0]&&0===s.endTangent[1]&&(s.endTangent=[y[0]-x[0],y[1]-x[1]])):"S"===h?(x=ft((p=n[i-1]).currentPoint,T),y=[c[1],c[2]],"C"===p.command?(s.command="C",s.startTangent=[T[0]-x[0],T[1]-x[1]]):(s.command="SQ",s.startTangent=[T[0]-y[0],T[1]-y[1]]),s.endTangent=[r[0]-y[0],r[1]-y[1]]):"A"===h&&(h=.001,v=void 0===(v=(b=s.arcParams||{}).cx)?0:v,g=void 0===(g=b.cy)?0:g,A=b.rx,M=void 0===(M=b.ry)?0:M,m=b.sweepFlag,d=void 0===(d=b.startAngle)?0:d,b=void 0===(b=b.endAngle)?0:b,0===(void 0===m?0:m)&&(h*=-1),A=(m=void 0===A?0:A)*Math.cos(d-h)+v,w=M*Math.sin(d-h)+g,s.startTangent=[A-e[0],w-e[1]],A=m*Math.cos(d+b+h)+v,w=M*Math.sin(d+b-h)+g,s.endTangent=[T[0]-A,T[1]-w]),n.push(s)}return n},t.pathIntersection=function(t,n){var r=t,a=n,e=void 0;r=q(r),a=q(a);for(var o,u,i,c,h,s,f,l,p=e?0:[],x=0,y=r.length;x<y;x++){var v=r[x];if("M"===v[0])o=i=v[1],g=c=v[2];else for(var g="C"===v[0]?(o=(f=[o,g].concat(v.slice(1)))[6],f[7]):(f=[o,g,o,g,i,c,i,c],o=i,c),M=0,m=a.length;M<m;M++){var d=a[M];if("M"===d[0])u=h=d[1],b=s=d[2];else{var b="C"===d[0]?(u=(l=[u,b].concat(d.slice(1)))[6],l[7]):(l=[u,b,u,b,h,s,h,s],u=h,s),A=ut(f,l,e);if(e)p+=A;else{for(var w=0,P=A.length;w<P;w++)A[w].segment1=x,A[w].segment2=M,A[w].bez1=f,A[w].bez2=l;p=p.concat(A)}}}}return p},t.rectPath=y,t.rgb2arr=n,t.toCSSGradient=function(t){var n,r,a,e,o;return/^[r,R,L,l]{1}[\s]*\(/.test(t)?(r=void 0,"l"===t[0]?(n=+(e=N.exec(t))[1]+90,r=e[2],a="linear-gradient("+n+"deg, "):"r"===t[0]&&(a="radial-gradient(",r=(e=V.exec(t))[4]),(o=r.match(Z)).forEach(function(t,n){t=t.split(":");a+=t[1]+" "+100*Number(t[0])+"%",n!==o.length-1&&(a+=", ")}),a+=")"):t},t.toRGB=e,t.transform=function(t,n){for(var r,a,e,o,u,i,c=t?[].concat(t):[1,0,0,0,1,0,0,0,1],h=0,s=n.length;h<s;h++){var f=n[h];switch(f[0]){case"t":e=a=c,o=[f[1],f[2]],u=void 0,o=o,(u=i=[0,0,0,0,0,0,0,0,0])[0]=1,u[1]=0,u[2]=0,u[3]=0,u[4]=1,u[5]=0,u[6]=o[0],u[7]=o[1],u[8]=1,l(a,i,e);break;case"s":u=o=c,a=[f[1],f[2]],i=void 0,(i=e=[0,0,0,0,0,0,0,0,0])[0]=(a=a)[0],i[1]=0,i[2]=0,i[3]=0,i[4]=a[1],i[5]=0,i[6]=0,i[7]=0,i[8]=1,l(o,e,u);break;case"r":R(c,c,f[1]);break;case"m":r=f[1],l(c,r,c)}}return c},t.vertical=function(t,n,r){return r?(t[0]=n[1],t[1]=-1*n[0]):(t[0]=-1*n[1],t[1]=n[0]),t},Object.defineProperty(t,"__esModule",{value:!0})});
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).util={})}(this,function(t){"use strict";function n(t){return[parseInt(t.substr(1,2),16),parseInt(t.substr(3,2),16),parseInt(t.substr(5,2),16)]}function e(t){t=Math.round(t).toString(16);return 1===t.length?"0"+t:t}function o(t){return"#"+e(t[0])+e(t[1])+e(t[2])}const F=/rgba?\(([\s.,0-9]+)\)/;let a;function r(t){if("#"===t[0]&&7===t.length)return t;(a=a||function(){const t=document.createElement("i");return t.title="Web Colour Picker",t.style.display="none",document.body.appendChild(t),t}()).style.color=t;t=document.defaultView.getComputedStyle(a,"").getPropertyValue("color");const e=F.exec(t);return o(e[1].split(/\s*,\s*/).map(t=>Number(t)))}function c(t,e,n,a){return t[a]+(e[a]-t[a])*n}const Q=/^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i,j=/^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i,Z=/[\d.]+:(#[^\s]+|[^)]+\))/gi;var i="undefined"!=typeof Float32Array?Float32Array:Array;function u(t,e,n){var a=e[0],r=e[1],i=e[2],o=e[3],c=e[4],l=e[5],s=e[6],h=e[7],e=e[8],u=n[0],x=n[1],p=n[2],f=n[3],m=n[4],y=n[5],d=n[6],M=n[7],n=n[8];return t[0]=u*a+x*o+p*s,t[1]=u*r+x*c+p*h,t[2]=u*i+x*l+p*e,t[3]=f*a+m*o+y*s,t[4]=f*r+m*c+y*h,t[5]=f*i+m*l+y*e,t[6]=d*a+M*o+n*s,t[7]=d*r+M*c+n*h,t[8]=d*i+M*l+n*e,t}function l(){var t=new i(3);return i!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function s(t,e,n){var a=new i(3);return a[0]=t,a[1]=e,a[2]=n,a}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});function h(){var t=new i(4);return i!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}l(),x=new i(4),i!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0,x[3]=0);var x;function B(t,e,n){var a,r,i=[0,0,0,0,0,0,0,0,0];a=i,n=n,r=Math.sin(n),n=Math.cos(n),a[0]=n,a[1]=r,a[2]=0,a[3]=-r,a[4]=n,a[5]=0,a[6]=0,a[7]=0,a[8]=1,u(t,i,e)}function p(t,e){return t[0]*e[1]-e[0]*t[1]}function m(t){return t.map(t=>Array.isArray(t)?[...t]:t)}l(),s(1,0,0),s(0,1,0),h(),h(),x=new i(9),i!=Float32Array&&(x[1]=0,x[2]=0,x[3]=0,x[5]=0,x[6]=0,x[7]=0),x[0]=1,x[4]=1,x[8]=1,x=new i(2),i!=Float32Array&&(x[0]=0,x[1]=0);const y={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};const f={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function d(t){return Array.isArray(t)&&t.every(t=>{var e=t[0].toLowerCase();return f[e]===t.length-1&&"achlmqstvz".includes(e)})}function M(t){return d(t)&&t.every(([t])=>t===t.toUpperCase())}function g(t){return M(t)&&t.every(([t])=>"ACLMQZ".includes(t))}function v(t){let e=t.pathValue[t.segmentStart],n=e.toLowerCase();const a=t["data"];for(;a.length>=f[n]&&("m"===n&&2<a.length?(t.segments.push([e,...a.splice(0,2)]),n="l",e="m"===e?"l":"L"):t.segments.push([e,...a.splice(0,f[n])]),f[n]););}function w(t){return 48<=t&&t<=57}function b(t){const{pathValue:e,max:n}=t;for(;t.index<n&&(10===(a=e.charCodeAt(t.index))||13===a||8232===a||8233===a||32===a||9===a||11===a||12===a||160===a||5760<=a&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(a));)t.index+=1;var a}function E(e){const{max:n,pathValue:a,index:t}=e;var r,i=a.charCodeAt(t),o=f[a[t].toLowerCase()];if(e.segmentStart=t,function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return 1;default:return}}(i))if(e.index+=1,b(e),e.data=[],o){for(;;){for(let t=o;0<t;--t){if(97!=(32|i)||3!==t&&4!==t)(function(t){const{max:e,pathValue:n,index:a}=t;let r=a;var i;let o=!1,c=!1,l=!1,s;if(r>=e)t.err=`[path-util]: Invalid path value at index ${r}, "pathValue" is missing param`;else if(43!==(s=n.charCodeAt(r))&&45!==s||(r+=1,s=n.charCodeAt(r)),w(s)||46===s){if(46!==s){if(i=48===s,r+=1,s=n.charCodeAt(r),i&&r<e&&s&&w(s))return t.err=`[path-util]: Invalid path value at index ${a}, "${n[a]}" illegal number`;for(;r<e&&w(n.charCodeAt(r));)r+=1,o=!0;s=n.charCodeAt(r)}if(46===s){for(l=!0,r+=1;w(n.charCodeAt(r));)r+=1,c=!0;s=n.charCodeAt(r)}if(101===s||69===s){if(l&&!o&&!c)return t.err=`[path-util]: Invalid path value at index ${r}, "${n[r]}" invalid float exponent`;if(r+=1,43!==(s=n.charCodeAt(r))&&45!==s||(r+=1),!(r<e&&w(n.charCodeAt(r))))return t.err=`[path-util]: Invalid path value at index ${r}, "${n[r]}" invalid integer exponent`;for(;r<e&&w(n.charCodeAt(r));)r+=1}t.index=r,t.param=+t.pathValue.slice(a,r)}else t.err=`[path-util]: Invalid path value at index ${r}, "${n[r]}" is not a number`})(e);else{l=c=void 0;var c=e;const{index:s,pathValue:h}=c;var l=h.charCodeAt(s);48===l?(c.param=0,c.index+=1):49===l?(c.param=1,c.index+=1):c.err=`[path-util]: invalid Arc flag "${h[s]}", expecting 0 or 1 at index `+s}if(e.err.length)return;e.data.push(e.param),b(e),e.index<n&&44===a.charCodeAt(e.index)&&(e.index+=1,b(e))}if(e.index>=e.max)break;if(!(48<=(r=a.charCodeAt(e.index))&&r<=57||43===r||45===r||46===r))break}v(e)}else v(e);else e.err=`[path-util]: Invalid path value "${a[t]}" is not a path command`}class O{constructor(t){this.pathValue=t,this.segments=[],this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""}}function A(t){if(d(t))return m(t);var e=new O(t);for(b(e);e.index<e.max&&!e.err.length;)E(e);return e.err||e.segments}function C(t){if(M(t))return m(t);const e=A(t);let c=0,l=0,s=0,h=0;return e.map(t=>{const e=t.slice(1).map(Number),[n]=t;var a=n.toUpperCase();if("M"===n)return[c,l]=e,s=c,h=l,["M",c,l];let r;if(n!==a)switch(a){case"A":r=[a,e[0],e[1],e[2],e[3],e[4],e[5]+c,e[6]+l];break;case"V":r=[a,e[0]+l];break;case"H":r=[a,e[0]+c];break;default:var i=e.map((t,e)=>t+(e%2?l:c));r=[a,...i]}else r=[a,...e];var o=r.length;switch(a){case"Z":c=s,l=h;break;case"H":[,c]=r;break;case"V":[,l]=r;break;default:c=r[o-2],l=r[o-1],"M"===a&&(s=c,h=l)}return r})}function q(t){if(g(t))return m(t);const e=C(t),n=Object.assign({},y);var a=e.length;for(let t=0;t<a;t+=1){e[t],e[t]=function(t,e){var[n]=t,{x1:a,y1:r,x2:i,y2:o}=e,c=t.slice(1).map(Number);let l=t;return"TQ".includes(n)||(e.qx=null,e.qy=null),"H"===n?l=["L",t[1],r]:"V"===n?l=["L",a,t[1]]:"S"===n?(t=2*r-o,e.x1=o=2*a-i,e.y1=t,l=["C",o,t,...c]):"T"===n?(i=2*a-e.qx,o=2*r-e.qy,e.qx=i,e.qy=o,l=["Q",i,o,...c]):"Q"===n&&([t,a]=c,e.qx=t,e.qy=a),l}(e[t],n);var r=e[t],i=r.length;n.x1=+r[i-2],n.y1=+r[i-1],n.x2=+r[i-4]||n.x1,n.y2=+r[i-3]||n.y1}return e}function I(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function P(t,e,n){var a=t[0],t=t[1];return[a+(e[0]-a)*n,t+(e[1]-t)*n]}function S(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}function $(t,e,n,a,r){var i=S([t,e],[n,a]);let o={x:0,y:0};return{length:i,point:o="number"==typeof r?0===r?{x:t,y:e}:i<=r?{x:n,y:a}:([r,i]=P([t,e],[n,a],r/i),{x:r,y:i}):o,min:{x:Math.min(t,n),y:Math.min(e,a)},max:{x:Math.max(t,n),y:Math.max(e,a)}}}function k(t,e,n,a){var t=[t,e],e=[n,a],r=P(t,e,.5),i=P(e,r,.5),o=P(r,i,.5),c=P(i,o,.5),l=P(o,c,.5),t=$(...[...t,...r,...o,...l,.5]).point,r=$(...[...l,...c,...i,...e,0]).point;return[t.x,t.y,r.x,r.y,n,a]}function R(t,e){var[n]=t,a=t.slice(1).map(Number),[r,i]=a;let o;var c,l,s,h,u,x,{x1:p,y1:f,x:m,y}=e;switch("TQ".includes(n)||(e.qx=null,e.qy=null),n){case"M":return e.x=r,e.y=i,t;case"A":return["C",...function t(e,n,a,r,i,o,c,l,s,h){let u=e,x=n,p=a,f=r,m=l,y=s;var e=120*Math.PI/180,d=Math.PI/180*(+i||0);let M=[],g,v,w,b;h?[g,v,w,b]=h:(n=I(u,x,-d),u=n.x,x=n.y,n=I(m,y,-d),m=n.x,y=n.y,a=(u-m)/2,r=(x-y)/2,1<(l=a*a/(p*p)+r*r/(f*f))&&(l=Math.sqrt(l),p*=l,f*=l),s=p*p,n=f*f,l=(o===c?-1:1)*Math.sqrt(Math.abs((s*n-s*r*r-n*a*a)/(s*r*r+n*a*a))),w=l*p*r/f+(u+m)/2,b=l*-f*a/p+(x+y)/2,g=(Math.asin((x-b)/f)*Math.pow(10,9)>>0)/Math.pow(10,9),v=(Math.asin((y-b)/f)*Math.pow(10,9)>>0)/Math.pow(10,9),g=u<w?Math.PI-g:g,v=m<w?Math.PI-v:v,g<0&&(g=2*Math.PI+g),v<0&&(v=2*Math.PI+v),c&&g>v&&(g-=2*Math.PI),!c&&v>g&&(v-=2*Math.PI));o=v-g,Math.abs(o)>e&&(s=v,n=m,r=y,v=g+e*(c&&v>g?1:-1),m=w+p*Math.cos(v),y=b+f*Math.sin(v),M=t(m,y,p,f,i,0,c,n,r,[v,s,w,b])),o=v-g,l=Math.cos(g),a=Math.sin(g),e=Math.cos(v),i=Math.sin(v),c=Math.tan(o/4),n=4/3*p*c,r=4/3*f*c,s=[u,x];const A=[u+n*a,x-r*l];o=[m+n*i,y-r*e],c=[m,y];if(A[0]=2*s[0]-A[0],A[1]=2*s[1]-A[1],h)return[...A,...o,...c,...M];const C=[];for(let t=0,e=(M=[...A,...o,...c,...M]).length;t<e;t+=1)C[t]=t%2?I(M[t-1],M[t],d).y:I(M[t],M[t+1],d).x;return C}(...o=[p,f,...a])];case"Q":return e.qx=r,e.qy=i,o=[p,f,...a],["C",...([c,l,s,h,u,x]=[...o],[1/3*c+2/3*s,1/3*l+2/3*h,1/3*u+2/3*s,1/3*x+2/3*h,u,x])];case"L":return["C",...k(p,f,r,i)];case"Z":return p===m&&f===y?["C",p,f,m,y,m,y]:["C",...k(p,f,m,y)]}return t}function L(t,e=!1){var n,a;if(g(n=t)&&n.every(([t])=>"MC".includes(t)))return n=m(t),e?[n,[]]:n;const r=q(t),i=Object.assign({},y),o=[];let c="",l=r.length;const s=[];for(let t=0;t<l;t+=1){r[t]&&([c]=r[t]),o[t]=c;var h=R(r[t],i),u=(r[t]=h,p=x=u=void 0,r),x=o,p=t;if(7<u[p].length){u[p].shift();const f=u[p];let t=p;for(;f.length;)x[p]="A",u.splice(t+=1,0,["C"].concat(f.splice(0,6)));u.splice(p,1)}l=r.length,"Z"===c&&s.push(t),a=(h=r[t]).length,i.x1=+h[a-2],i.y1=+h[a-1],i.x2=+h[a-4]||i.x1,i.y2=+h[a-3]||i.y1}return e?[r,s]:r}function V(t,e){var{x:t,y:n}=t,{x:e,y:a}=e,r=t*e+n*a,i=Math.sqrt((Math.pow(t,2)+Math.pow(n,2))*(Math.pow(e,2)+Math.pow(a,2)));return(t*a-n*e<0?-1:1)*Math.acos(r/i)}function H(e,n,a,r,i,o,c,l,s,h){var u="number"==typeof h;let x=e,p=n,f=0,m=[x,p,f],y=[x,p];let d={x:0,y:0},M=[{x:x,y:p}];u&&0===h&&(d={x:x,y:p});for(let t=0;t<=300;t+=1){var g=t/300;({x,y:p}=function(t,e,n,a,r,i,o,c,l,s){const{abs:h,sin:u,cos:x,sqrt:p,PI:f}=Math;let m=h(n),y=h(a);if(n=f/180*((r%360+360)%360),t===c&&e===l)return{x:t,y:e};if(0===m||0===y)return $(t,e,c,l,s).point;a=(t-c)/2,r=(e-l)/2,a={x:x(n)*a+u(n)*r,y:-u(n)*a+x(n)*r},1<(r=Math.pow(a.x,2)/Math.pow(m,2)+Math.pow(a.y,2)/Math.pow(y,2))&&(m*=p(r),y*=p(r));let d=(r=Math.pow(m,2)*Math.pow(y,2)-Math.pow(m,2)*Math.pow(a.y,2)-Math.pow(y,2)*Math.pow(a.x,2))/(Math.pow(m,2)*Math.pow(a.y,2)+Math.pow(y,2)*Math.pow(a.x,2));d=d<0?0:d;const M=(r=(i!==o?1:-1)*p(d))*(m*a.y/y),g=r*(-y*a.x/m),v=x(n)*M-u(n)*g+(t+c)/2,w=u(n)*M+x(n)*g+(e+l)/2;i={x:(a.x-M)/m,y:(a.y-g)/y},r=V({x:1,y:0},i);let b=V(i,{x:(-a.x-M)/m,y:(-a.y-g)/y});return!o&&0<b?b-=2*f:o&&b<0&&(b+=2*f),t=r+(b%=2*f)*s,c=m*x(t),e=y*u(t),{x:x(n)*c-u(n)*e+v,y:u(n)*c+x(n)*e+w}}(e,n,a,r,i,o,c,l,s,g)),M=[...M,{x:x,y:p}],f+=S(y,[x,p]),y=[x,p],u&&f>h&&h>m[2]&&(g=(f-h)/(f-m[2]),d={x:y[0]*(1-g)+m[0]*g,y:y[1]*(1-g)+m[1]*g}),m=[x,p,f]}return u&&h>=f&&(d={x:l,y:s}),{length:f,point:d,min:{x:Math.min(...M.map(t=>t.x)),y:Math.min(...M.map(t=>t.y))},max:{x:Math.max(...M.map(t=>t.x)),y:Math.max(...M.map(t=>t.y))}}}function D(e,n,a,r,i,o,c,l,s){var h="number"==typeof s;let u=e,x=n,p=0,f=[u,x,p],m=[u,x];let y={x:0,y:0},d=[{x:u,y:x}];h&&0===s&&(y={x:u,y:x});var M,g,v,w,b,A,C,q;for(let t=0;t<=20;t+=1){var I,P=t/20;({x:u,y:x}=(I=e,M=n,g=a,v=r,w=i,b=o,A=c,C=l,q=void 0,q=1-(P=P),{x:Math.pow(q,3)*I+3*Math.pow(q,2)*P*g+3*q*Math.pow(P,2)*w+Math.pow(P,3)*A,y:Math.pow(q,3)*M+3*Math.pow(q,2)*P*v+3*q*Math.pow(P,2)*b+Math.pow(P,3)*C})),d=[...d,{x:u,y:x}],p+=S(m,[u,x]),m=[u,x],h&&p>s&&s>f[2]&&(I=(p-s)/(p-f[2]),y={x:m[0]*(1-I)+f[0]*I,y:m[1]*(1-I)+f[1]*I}),f=[u,x,p]}return h&&s>=p&&(y={x:c,y:l}),{length:p,point:y,min:{x:Math.min(...d.map(t=>t.x)),y:Math.min(...d.map(t=>t.y))},max:{x:Math.max(...d.map(t=>t.x)),y:Math.max(...d.map(t=>t.y))}}}function G(e,n,a,r,i,o,c){var l="number"==typeof c;let s=e,h=n,u=0,x=[s,h,u],p=[s,h];let f={x:0,y:0},m=[{x:s,y:h}];l&&0===c&&(f={x:s,y:h});var y,d,M,g,v,w;for(let t=0;t<=300;t+=1){var b,A=t/300;({x:s,y:h}=(b=e,y=n,d=a,M=r,g=i,v=o,w=void 0,w=1-(A=A),{x:Math.pow(w,2)*b+2*w*A*d+Math.pow(A,2)*g,y:Math.pow(w,2)*y+2*w*A*M+Math.pow(A,2)*v})),m=[...m,{x:s,y:h}],u+=S(p,[s,h]),p=[s,h],l&&u>c&&c>x[2]&&(b=(u-c)/(u-x[2]),f={x:p[0]*(1-b)+x[0]*b,y:p[1]*(1-b)+x[1]*b}),x=[s,h,u]}return l&&c>=u&&(f={x:i,y:o}),{length:u,point:f,min:{x:Math.min(...m.map(t=>t.x)),y:Math.min(...m.map(t=>t.y))},max:{x:Math.max(...m.map(t=>t.x)),y:Math.max(...m.map(t=>t.y))}}}function N(t,n){var a,r,i=q(t),o="number"==typeof n;let c=[],l=0,s=0,h=0,u=0,x,p=[],f=[],m=0,y={x:0,y:0},d=y,M=y,g=y,v=0;for(let t=0,e=i.length;t<e;t+=1)[r]=x=i[t],a="M"===r,c=a?c:[l,s,...x.slice(1)],a?([,h,u]=x,y={x:h,y:u},d=y,m=0,o&&n<.001&&(g=y)):"L"===r?{length:m,min:y,max:d,point:M}=$(...c,(n||0)-v):"A"===r?{length:m,min:y,max:d,point:M}=H(...c,(n||0)-v):"C"===r?{length:m,min:y,max:d,point:M}=D(...c,(n||0)-v):"Q"===r?{length:m,min:y,max:d,point:M}=G(...c,(n||0)-v):"Z"===r&&(c=[l,s,h,u],{length:m,min:y,max:d,point:M}=$(...c,(n||0)-v)),o&&v<n&&v+m>=n&&(g=M),f=[...f,d],p=[...p,y],v+=m,[l,s]="Z"!==r?x.slice(-2):[h,u];return o&&n>=v&&(g={x:l,y:s}),{length:v,point:g,min:{x:Math.min(...p.map(t=>t.x)),y:Math.min(...p.map(t=>t.y))},max:{x:Math.max(...f.map(t=>t.x)),y:Math.max(...f.map(t=>t.y))}}}function T(t){return N(t).length}function U(t){let s=0,h=0,u;return L(t).map(t=>{return"M"!==t[0]?(u=([e,n,a,r,i,o,c,l]=[s,h,...t.slice(1)],3*((l-n)*(a+i)-(c-e)*(r+o)+r*(e-i)-a*(n-o)+l*(i+e/3)-c*(o+n/3))/20),[s,h]=t.slice(-2),u):([,s,h]=t,0);var e,n,a,r,i,o,c,l}).reduce((t,e)=>t+e,0)}function z(t,e){return N(t,e).point}function _(t,n){var e,t=A(t),a=q(t),r=T(t),i=t=>{var e=t.x-n.x,t=t.y-n.y;return e*e+t*t};let o=8;var c,l,s;let h,u=0,x=1/0;for(let t=0;t<=r;t+=o)(c=i(e=z(a,t)))<x&&(h=e,u=t,x=c);o/=2;for(var p,f,m,y;.5<o;)m=i(l=z(a,p=u-o)),y=i(s=z(a,f=u+o)),0<=p&&m<x?(h=l,u=p,x=m):f<=r&&y<x?(h=s,u=f,x=y):o/=2;var t=function(t,e){const n=A(t);if("string"==typeof n)throw TypeError(n);let a=[...n],r=T(a),i=a.length-1,o=0,c=0,l=n[0];var[t,s]=l.slice(-2),t={x:t,y:s};if(i<=0||!e||!Number.isFinite(e))return{segment:l,index:0,length:c,point:t,lengthAtSegment:o};if(e>=r)return a=n.slice(0,-1),o=T(a),c=r-o,{segment:n[i],index:i,length:c,lengthAtSegment:o};const h=[];for(;0<i;)l=a[i],a=a.slice(0,-1),o=T(a),c=r-o,r=o,h.push({segment:l,index:i,length:c,lengthAtSegment:o}),--i;return h.find(({lengthAtSegment:t})=>t<=e)}(t,u),d=Math.sqrt(x);return{closest:h,distance:d,segment:t}}function W(t){return t.map((t,e,n)=>{var a,r,i,o,n=e&&n[e-1].slice(-2).concat(t.slice(1)),c=e?D(...n).length:0;let l;return{s:t,ss:l=e?c?(e=.5,a=(n=n).slice(0,2),r=n.slice(2,4),i=n.slice(4,6),n=n.slice(6,8),a=P(a,r,e),r=P(r,i,e),i=P(i,n,e),o=P(a,r,e),r=P(r,i,e),e=P(o,r,e),[["C"].concat(a,o,e),["C"].concat(r,i,n)]):[t,t]:[t],l:c}})}t.angleTo=function(t,e,n){r=e,o=(a=t)[0],a=a[1],c=r[0],r=r[1],i=Math.sqrt(o*o+a*a)*Math.sqrt(c*c+r*r);var a,r,i,o=Math.acos(Math.min(Math.max(i&&(o*c+a*r)/i,-1),1)),c=0<=p(t,e);return n?c?2*Math.PI-o:o:c?o:2*Math.PI-o},t.clonePath=m,t.direction=p,t.distanceSquareRoot=S,t.equalizeSegments=function t(e,n,a){const r=W(e),i=W(n);var e=r.length,n=i.length,o=r.filter(t=>t.l).length,c=i.filter(t=>t.l).length,o=r.filter(t=>t.l).reduce((t,{l:e})=>t+e,0)/o||0,c=i.filter(t=>t.l).reduce((t,{l:e})=>t+e,0)/c||0;const l=a||Math.max(e,n),s=[o,c],h=[l-e,l-n];let u;a=[r,i].map((t,n)=>t.l===l?t.map(t=>t.s):t.map((t,e)=>(u=e&&h[n]&&t.l>=s[n],h[n]-=u?1:0,u?t.ss:[t.s])).flat());return a[0].length===a[1].length?a:t(a[0],a[1],l)},t.getDrawDirection=function(t){return 0<=U(t)},t.getPathArea=U,t.getPathBBox=function(t){if(!t)return{x:0,y:0,width:0,height:0,x2:0,y2:0,cx:0,cy:0,cz:0};var{min:{x:t,y:e},max:{x:n,y:a}}=N(t),r=n-t,i=a-e;return{width:r,height:i,x:t,y:e,x2:n,y2:a,cx:t+r/2,cy:e+i/2,cz:Math.max(r,i)+Math.min(r,i)/2}},t.getPathBBoxTotalLength=function(t){if(!t)return{length:0,x:0,y:0,width:0,height:0,x2:0,y2:0,cx:0,cy:0,cz:0};var{length:t,min:{x:e,y:n},max:{x:a,y:r}}=N(t),i=a-e,o=r-n;return{length:t,width:i,height:o,x:e,y:n,x2:a,y2:r,cx:e+i/2,cy:n+o/2,cz:Math.max(i,o)+Math.min(i,o)/2}},t.getPointAtLength=z,t.getRotatedCurve=function(a,r){const i=a.length-1,e=[];var t;let o=0;const n=function(i){const o=i.length,c=o-1;return i.map((t,r)=>i.map((t,e)=>{let n=r+e,a;return 0===e||i[n]&&"M"===i[n][0]?(a=i[n],["M"].concat(a.slice(-2))):(n>=o&&(n-=c),i[n])}))}(a);return n.forEach((t,n)=>{a.slice(1).forEach((t,e)=>{o+=S(a[(n+e)%i].slice(-2),r[e%i].slice(-2))}),e[n]=o,o=0}),t=e.indexOf(Math.min.apply(null,e)),n[t]},t.getTotalLength=T,t.gradient=function(t){const e="string"==typeof t?t.split("-"):t,i=e.map(t=>n(-1===t.indexOf("#")?r(t):t));return t=>{return e=i,t=t,t=isNaN(Number(t))||t<0?0:1<t?1:Number(t),n=e.length-1,a=Math.floor(n*t),t=n*t-a,r=e[a],n=a===n?r:e[a+1],o([c(r,n,t,0),c(r,n,t,1),c(r,n,t,2)]);var e,n,a,r}},t.isPointInStroke=function(t,e){return t=_(t,e).distance,Math.abs(t)<.001},t.normalizePath=q,t.path2Absolute=C,t.path2Curve=L,t.path2String=function(t,e="off"){return function(t,n){if("off"===n)return m(t);const a="number"==typeof n&&1<=n?Math.pow(10,n):1;return t.map(t=>{var e=t.slice(1).map(Number).map(t=>n?Math.round(t*a)/a:Math.round(t));return[t[0],...e]})}(t,e).map(t=>t[0]+t.slice(1).join(" ")).join("")},t.reverseCurve=function(a){const t=a.slice(1).map((t,e,n)=>(e?n[e-1].slice(-2):a[0].slice(1)).concat(t.slice(1))).map(n=>n.map((t,e)=>n[n.length-e-2*(1-e%2)])).reverse();return[["M"].concat(t[0].slice(0,2))].concat(t.map(t=>["C"].concat(t.slice(2))))},t.rgb2arr=n,t.toCSSGradient=function(e){if(/^[r,R,L,l]{1}[\s]*\(/.test(e)){let n,t;var a,r;"l"===e[0]?(a=+(r=Q.exec(e))[1]+90,t=r[2],n=`linear-gradient(${a}deg, `):"r"===e[0]&&(n="radial-gradient(",r=j.exec(e),t=r[4]);const i=t.match(Z);return i.forEach((t,e)=>{t=t.split(":");n+=`${t[1]} ${100*Number(t[0])}%`,e!==i.length-1&&(n+=", ")}),n+=")"}return e},t.toRGB=r,t.transform=function(t,n){var a,r,i,o,c,l,s=t?[].concat(t):[1,0,0,0,1,0,0,0,1];for(let t=0,e=n.length;t<e;t++){var h=n[t];switch(h[0]){case"t":i=r=s,o=[h[1],h[2]],c=void 0,o=o,(c=l=[0,0,0,0,0,0,0,0,0])[0]=1,c[1]=0,c[2]=0,c[3]=0,c[4]=1,c[5]=0,c[6]=o[0],c[7]=o[1],c[8]=1,u(r,l,i);break;case"s":c=o=s,r=[h[1],h[2]],l=void 0,(l=i=[0,0,0,0,0,0,0,0,0])[0]=(r=r)[0],l[1]=0,l[2]=0,l[3]=0,l[4]=r[1],l[5]=0,l[6]=0,l[7]=0,l[8]=1,u(o,i,c);break;case"r":B(s,s,h[1]);break;case"m":a=h[1],u(s,a,s)}}return s},t.vertical=function(t,e,n){return n?(t[0]=e[1],t[1]=-1*e[0]):(t[0]=-1*e[1],t[1]=e[0]),t},Object.defineProperty(t,"__esModule",{value:!0})});
|
package/esm/color/arr2rgb.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @returns
|
|
5
5
|
*/
|
|
6
6
|
export function toHex(value) {
|
|
7
|
-
|
|
8
|
-
return x16Value.length === 1 ?
|
|
7
|
+
const x16Value = Math.round(value).toString(16);
|
|
8
|
+
return x16Value.length === 1 ? `0${x16Value}` : x16Value;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* 数组转换成颜色
|
|
@@ -13,6 +13,6 @@ export function toHex(value) {
|
|
|
13
13
|
* @returns
|
|
14
14
|
*/
|
|
15
15
|
export function arr2rgb(arr) {
|
|
16
|
-
return
|
|
16
|
+
return `#${toHex(arr[0])}${toHex(arr[1])}${toHex(arr[2])}`;
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=arr2rgb.js.map
|
package/esm/color/arr2rgb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arr2rgb.js","sourceRoot":"src/","sources":["color/arr2rgb.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,
|
|
1
|
+
{"version":3,"file":"arr2rgb.js","sourceRoot":"src/","sources":["color/arr2rgb.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEhD,OAAO,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC3D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,GAAa;IACnC,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC7D,CAAC"}
|
package/esm/color/gradient.js
CHANGED
|
@@ -19,12 +19,12 @@ function getValue(start, end, percent, index) {
|
|
|
19
19
|
* @returns
|
|
20
20
|
*/
|
|
21
21
|
function calColor(points, percent) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
const fixedPercent = isNaN(Number(percent)) || percent < 0 ? 0 : percent > 1 ? 1 : Number(percent);
|
|
23
|
+
const steps = points.length - 1;
|
|
24
|
+
const step = Math.floor(steps * fixedPercent);
|
|
25
|
+
const left = steps * fixedPercent - step;
|
|
26
|
+
const start = points[step];
|
|
27
|
+
const end = step === steps ? start : points[step + 1];
|
|
28
28
|
return arr2rgb([getValue(start, end, left, 0), getValue(start, end, left, 1), getValue(start, end, left, 2)]);
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
@@ -33,12 +33,12 @@ function calColor(points, percent) {
|
|
|
33
33
|
* @return 颜色值
|
|
34
34
|
*/
|
|
35
35
|
export function gradient(colors) {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const colorArray = typeof colors === 'string' ? colors.split('-') : colors;
|
|
37
|
+
const points = colorArray.map((color) => {
|
|
38
38
|
return rgb2arr(color.indexOf('#') === -1 ? toRGB(color) : color);
|
|
39
39
|
});
|
|
40
40
|
// 返回一个函数
|
|
41
|
-
return
|
|
41
|
+
return (percent) => {
|
|
42
42
|
return calColor(points, percent);
|
|
43
43
|
};
|
|
44
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gradient.js","sourceRoot":"src/","sources":["color/gradient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;;;;;;GAOG;AACH,SAAS,QAAQ,CAAC,KAAe,EAAE,GAAa,EAAE,OAAe,EAAE,KAAa;IAC9E,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,OAAO,CAAC;AAC9D,CAAC;AAED;;;;;GAKG;AACH,SAAS,QAAQ,CAAC,MAAkB,EAAE,OAAe;IACnD,
|
|
1
|
+
{"version":3,"file":"gradient.js","sourceRoot":"src/","sources":["color/gradient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;;;;;;GAOG;AACH,SAAS,QAAQ,CAAC,KAAe,EAAE,GAAa,EAAE,OAAe,EAAE,KAAa;IAC9E,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,OAAO,CAAC;AAC9D,CAAC;AAED;;;;;GAKG;AACH,SAAS,QAAQ,CAAC,MAAkB,EAAE,OAAe;IACnD,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAEnG,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAEhC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,YAAY,CAAC,CAAC;IAE9C,MAAM,IAAI,GAAG,KAAK,GAAG,YAAY,GAAG,IAAI,CAAC;IAEzC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAE3B,MAAM,GAAG,GAAG,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;IAEtD,OAAO,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAChH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAyB;IAChD,MAAM,UAAU,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAE,MAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAEvF,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACtC,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,SAAS;IACT,OAAO,CAAC,OAAe,EAAU,EAAE;QACjC,OAAO,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
|
|
2
|
+
const regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
|
|
3
|
+
const regexColorStop = /[\d.]+:(#[^\s]+|[^)]+\))/gi;
|
|
4
4
|
function isGradientColor(val) {
|
|
5
5
|
return /^[r,R,L,l]{1}[\s]*\(/.test(val);
|
|
6
6
|
}
|
|
7
7
|
export function toCSSGradient(gradientColor) {
|
|
8
8
|
if (isGradientColor(gradientColor)) {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
let cssColor;
|
|
10
|
+
let steps;
|
|
11
11
|
if (gradientColor[0] === 'l') {
|
|
12
12
|
// 线性渐变
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const arr = regexLG.exec(gradientColor);
|
|
14
|
+
const angle = +arr[1] + 90; // css 和 g 的渐变起始角度不同
|
|
15
15
|
steps = arr[2];
|
|
16
|
-
|
|
16
|
+
cssColor = `linear-gradient(${angle}deg, `;
|
|
17
17
|
}
|
|
18
18
|
else if (gradientColor[0] === 'r') {
|
|
19
19
|
// 径向渐变
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
cssColor = 'radial-gradient(';
|
|
21
|
+
const arr = regexRG.exec(gradientColor);
|
|
22
22
|
steps = arr[4];
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (index !==
|
|
29
|
-
|
|
24
|
+
const colorStops = steps.match(regexColorStop);
|
|
25
|
+
colorStops.forEach((item, index) => {
|
|
26
|
+
const itemArr = item.split(':');
|
|
27
|
+
cssColor += `${itemArr[1]} ${Number(itemArr[0]) * 100}%`;
|
|
28
|
+
if (index !== colorStops.length - 1) {
|
|
29
|
+
cssColor += ', ';
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
|
-
|
|
33
|
-
return
|
|
32
|
+
cssColor += ')';
|
|
33
|
+
return cssColor;
|
|
34
34
|
}
|
|
35
35
|
return gradientColor;
|
|
36
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tocssgradient.js","sourceRoot":"src/","sources":["color/tocssgradient.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"tocssgradient.js","sourceRoot":"src/","sources":["color/tocssgradient.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,iCAAiC,CAAC;AAClD,MAAM,OAAO,GAAG,+DAA+D,CAAC;AAChF,MAAM,cAAc,GAAG,4BAA4B,CAAC;AAEpD,SAAS,eAAe,CAAC,GAAG;IAC1B,OAAO,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,aAAa;IACzC,IAAI,eAAe,CAAC,aAAa,CAAC,EAAE;QAClC,IAAI,QAAQ,CAAC;QACb,IAAI,KAAK,CAAC;QACV,IAAI,aAAa,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;YAC5B,OAAO;YACP,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACxC,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,oBAAoB;YAChD,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YAEf,QAAQ,GAAG,mBAAmB,KAAK,OAAO,CAAC;SAC5C;aAAM,IAAI,aAAa,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;YACnC,OAAO;YACP,QAAQ,GAAG,kBAAkB,CAAC;YAC9B,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACxC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;SAChB;QAED,MAAM,UAAU,GAAa,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAEzD,UAAU,CAAC,OAAO,CAAC,CAAC,IAAY,EAAE,KAAa,EAAE,EAAE;YACjD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAChC,QAAQ,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;YACzD,IAAI,KAAK,KAAK,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;gBACnC,QAAQ,IAAI,IAAI,CAAC;aAClB;QACH,CAAC,CAAC,CAAC;QAEH,QAAQ,IAAI,GAAG,CAAC;QAEhB,OAAO,QAAQ,CAAC;KACjB;IAED,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
package/esm/color/torgb.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { arr2rgb } from './arr2rgb';
|
|
2
|
-
|
|
2
|
+
const RGB_REG = /rgba?\(([\s.,0-9]+)\)/;
|
|
3
3
|
/**
|
|
4
4
|
* 创建辅助 tag 取颜色
|
|
5
5
|
* @returns
|
|
6
6
|
*/
|
|
7
7
|
function createTmp() {
|
|
8
|
-
|
|
8
|
+
const i = document.createElement('i');
|
|
9
9
|
i.title = 'Web Colour Picker';
|
|
10
10
|
i.style.display = 'none';
|
|
11
11
|
document.body.appendChild(i);
|
|
12
12
|
return i;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
let iEl;
|
|
15
15
|
/**
|
|
16
16
|
* 将颜色转换到 rgb 的格式
|
|
17
17
|
* @param {color} color 颜色
|
|
@@ -27,9 +27,9 @@ export function toRGB(color) {
|
|
|
27
27
|
iEl = createTmp();
|
|
28
28
|
}
|
|
29
29
|
iEl.style.color = color;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
let rst = document.defaultView.getComputedStyle(iEl, '').getPropertyValue('color');
|
|
31
|
+
const matches = RGB_REG.exec(rst);
|
|
32
|
+
const cArray = matches[1].split(/\s*,\s*/).map((s) => Number(s));
|
|
33
33
|
rst = arr2rgb(cArray);
|
|
34
34
|
return rst;
|
|
35
35
|
}
|
package/esm/color/torgb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"torgb.js","sourceRoot":"src/","sources":["color/torgb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,
|
|
1
|
+
{"version":3,"file":"torgb.js","sourceRoot":"src/","sources":["color/torgb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,OAAO,GAAG,uBAAuB,CAAC;AAExC;;;GAGG;AACH,SAAS,SAAS;IAChB,MAAM,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC,CAAC,KAAK,GAAG,mBAAmB,CAAC;IAC9B,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAC7B,OAAO,CAAC,CAAC;AACX,CAAC;AAED,IAAI,GAAgB,CAAC;AAErB;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,eAAe;IACf,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1C,OAAO,KAAK,CAAC;KACd;IAED,IAAI,CAAC,GAAG,EAAE;QACR,YAAY;QACZ,GAAG,GAAG,SAAS,EAAE,CAAC;KACnB;IAED,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;IAExB,IAAI,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,gBAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAEnF,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAa,CAAC;IAC9C,MAAM,MAAM,GAAa,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3E,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEtB,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/esm/helper/to-radian.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-radian.js","sourceRoot":"src/","sources":["helper/to-radian.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"to-radian.js","sourceRoot":"src/","sources":["helper/to-radian.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;AAE7B,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,OAAO,MAAM,GAAG,MAAM,CAAC;AACzB,CAAC"}
|
package/esm/matrix/index.js
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
* */
|
|
4
4
|
import { mat3, vec2 } from 'gl-matrix';
|
|
5
5
|
function leftTranslate(out, a, v) {
|
|
6
|
-
|
|
6
|
+
const transMat = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
7
7
|
mat3.fromTranslation(transMat, v);
|
|
8
8
|
return mat3.multiply(out, transMat, a);
|
|
9
9
|
}
|
|
10
10
|
function leftRotate(out, a, rad) {
|
|
11
|
-
|
|
11
|
+
const rotateMat = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
12
12
|
mat3.fromRotation(rotateMat, rad);
|
|
13
13
|
return mat3.multiply(out, rotateMat, a);
|
|
14
14
|
}
|
|
15
15
|
function leftScale(out, a, v) {
|
|
16
|
-
|
|
16
|
+
const scaleMat = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
17
17
|
mat3.fromScaling(scaleMat, v);
|
|
18
18
|
return mat3.multiply(out, scaleMat, a);
|
|
19
19
|
}
|
|
@@ -26,9 +26,9 @@ function leftMultiply(out, a, a1) {
|
|
|
26
26
|
* @param actions
|
|
27
27
|
*/
|
|
28
28
|
export function transform(m, actions) {
|
|
29
|
-
|
|
30
|
-
for (
|
|
31
|
-
|
|
29
|
+
const matrix = m ? [].concat(m) : [1, 0, 0, 0, 1, 0, 0, 0, 1];
|
|
30
|
+
for (let i = 0, len = actions.length; i < len; i++) {
|
|
31
|
+
const action = actions[i];
|
|
32
32
|
switch (action[0]) {
|
|
33
33
|
case 't':
|
|
34
34
|
leftTranslate(matrix, matrix, [action[1], action[2]]);
|
|
@@ -64,8 +64,8 @@ export function direction(v1, v2) {
|
|
|
64
64
|
* @param direct
|
|
65
65
|
*/
|
|
66
66
|
export function angleTo(v1, v2, direct) {
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
const ang = vec2.angle(v1, v2);
|
|
68
|
+
const angleLargeThanPI = direction(v1, v2) >= 0;
|
|
69
69
|
if (direct) {
|
|
70
70
|
if (angleLargeThanPI) {
|
|
71
71
|
return Math.PI * 2 - ang;
|
package/esm/matrix/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["matrix/index.ts"],"names":[],"mappings":"AAAA;;KAEK;AACL,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIvC,SAAS,aAAa,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;IAC9B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["matrix/index.ts"],"names":[],"mappings":"AAAA;;KAEK;AACL,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIvC,SAAS,aAAa,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;IAC9B,MAAM,QAAQ,GAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACvD,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,UAAU,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG;IAC7B,MAAM,SAAS,GAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACxD,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;IAC1B,MAAM,QAAQ,GAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACvD,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,YAAY,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;IAC9B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AACnC,CAAC;AACD;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,CAAW,EAAE,OAAgB;IACrD,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAE9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QAClD,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1B,QAAQ,MAAM,CAAC,CAAC,CAAC,EAAE;YACjB,KAAK,GAAG;gBACN,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACtD,MAAM;YACR,KAAK,GAAG;gBACN,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAClD,MAAM;YACR,KAAK,GAAG;gBACN,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBACtC,MAAM;YACR,KAAK,GAAG;gBACN,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxC,MAAM;YACR;gBACE,MAAM;SACT;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,EAAY,EAAE,EAAY;IAClD,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,EAAoB,EAAE,EAAoB,EAAE,MAAgB;IAClF,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC/B,MAAM,gBAAgB,GAAG,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAChD,IAAI,MAAM,EAAE;QACV,IAAI,gBAAgB,EAAE;YACpB,OAAO,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;SAC1B;QACD,OAAO,GAAG,CAAC;KACZ;IAED,IAAI,gBAAgB,EAAE;QACpB,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;AAC3B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAa,EAAE,CAAW,EAAE,IAAa;IAChE,IAAI,IAAI,EAAE;QACR,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACd,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KACpB;SAAM;QACL,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACnB,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KACf;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { clonePath } from '../process/clone-path';
|
|
2
|
+
import { isAbsoluteArray } from '../util/is-absolute-array';
|
|
3
|
+
import { parsePathString } from '../parser/parse-path-string';
|
|
4
|
+
export function path2Absolute(pathInput) {
|
|
5
|
+
if (isAbsoluteArray(pathInput)) {
|
|
6
|
+
return clonePath(pathInput);
|
|
7
|
+
}
|
|
8
|
+
const path = parsePathString(pathInput);
|
|
9
|
+
// if (!path || !path.length) {
|
|
10
|
+
// return [['M', 0, 0]];
|
|
11
|
+
// }
|
|
12
|
+
let x = 0;
|
|
13
|
+
let y = 0;
|
|
14
|
+
let mx = 0;
|
|
15
|
+
let my = 0;
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
return path.map((segment) => {
|
|
18
|
+
const values = segment.slice(1).map(Number);
|
|
19
|
+
const [pathCommand] = segment;
|
|
20
|
+
const absCommand = pathCommand.toUpperCase();
|
|
21
|
+
if (pathCommand === 'M') {
|
|
22
|
+
[x, y] = values;
|
|
23
|
+
mx = x;
|
|
24
|
+
my = y;
|
|
25
|
+
return ['M', x, y];
|
|
26
|
+
}
|
|
27
|
+
let absoluteSegment;
|
|
28
|
+
if (pathCommand !== absCommand) {
|
|
29
|
+
switch (absCommand) {
|
|
30
|
+
case 'A':
|
|
31
|
+
absoluteSegment = [
|
|
32
|
+
absCommand,
|
|
33
|
+
values[0],
|
|
34
|
+
values[1],
|
|
35
|
+
values[2],
|
|
36
|
+
values[3],
|
|
37
|
+
values[4],
|
|
38
|
+
values[5] + x,
|
|
39
|
+
values[6] + y,
|
|
40
|
+
];
|
|
41
|
+
break;
|
|
42
|
+
case 'V':
|
|
43
|
+
absoluteSegment = [absCommand, values[0] + y];
|
|
44
|
+
break;
|
|
45
|
+
case 'H':
|
|
46
|
+
absoluteSegment = [absCommand, values[0] + x];
|
|
47
|
+
break;
|
|
48
|
+
default: {
|
|
49
|
+
// use brakets for `eslint: no-case-declaration`
|
|
50
|
+
// https://stackoverflow.com/a/50753272/803358
|
|
51
|
+
const absValues = values.map((n, j) => n + (j % 2 ? y : x));
|
|
52
|
+
// for n, l, c, s, q, t
|
|
53
|
+
absoluteSegment = [absCommand, ...absValues];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
absoluteSegment = [absCommand, ...values];
|
|
59
|
+
}
|
|
60
|
+
const segLength = absoluteSegment.length;
|
|
61
|
+
switch (absCommand) {
|
|
62
|
+
case 'Z':
|
|
63
|
+
x = mx;
|
|
64
|
+
y = my;
|
|
65
|
+
break;
|
|
66
|
+
case 'H':
|
|
67
|
+
[, x] = absoluteSegment;
|
|
68
|
+
break;
|
|
69
|
+
case 'V':
|
|
70
|
+
[, y] = absoluteSegment;
|
|
71
|
+
break;
|
|
72
|
+
default:
|
|
73
|
+
x = absoluteSegment[segLength - 2];
|
|
74
|
+
y = absoluteSegment[segLength - 1];
|
|
75
|
+
if (absCommand === 'M') {
|
|
76
|
+
mx = x;
|
|
77
|
+
my = y;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return absoluteSegment;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=path-2-absolute.js.map
|