@dxyl/utils 1.0.0 → 1.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/dist/index.es.js +8985 -0
- package/dist/index.umd.js +28 -0
- package/lib/glslang/glslang.d.ts +14 -0
- package/lib/glslang/glslang.js +113 -0
- package/lib/glslang/glslang.wasm +0 -0
- package/lib/twgsl/twgsl.js +53 -0
- package/lib/twgsl/twgsl.wasm +0 -0
- package/package.json +27 -34
- package/readme.md +0 -0
- package/types/Color.d.ts +69 -0
- package/types/Options.d.ts +70 -0
- package/types/antv-util/color/arr2rgb.d.ts +12 -0
- package/types/antv-util/color/gradient.d.ts +6 -0
- package/types/antv-util/color/index.d.ts +4 -0
- package/types/antv-util/color/rgb2arr.d.ts +6 -0
- package/types/antv-util/color/tocssgradient.d.ts +1 -0
- package/types/antv-util/color/torgb.d.ts +6 -0
- package/types/antv-util/helper/index.d.ts +2 -0
- package/types/antv-util/helper/mod.d.ts +1 -0
- package/types/antv-util/helper/to-radian.d.ts +1 -0
- package/types/antv-util/index.d.ts +3 -0
- package/types/antv-util/matrix/index.d.ts +27 -0
- package/types/antv-util/path/convert/path-2-absolute.d.ts +2 -0
- package/types/antv-util/path/convert/path-2-curve.d.ts +2 -0
- package/types/antv-util/path/convert/path-2-string.d.ts +6 -0
- package/types/antv-util/path/index.d.ts +17 -0
- package/types/antv-util/path/parser/finalize-segment.d.ts +5 -0
- package/types/antv-util/path/parser/is-arc-command.d.ts +4 -0
- package/types/antv-util/path/parser/is-digit-start.d.ts +6 -0
- package/types/antv-util/path/parser/is-path-command.d.ts +4 -0
- package/types/antv-util/path/parser/is-space.d.ts +4 -0
- package/types/antv-util/path/parser/params-count.d.ts +13 -0
- package/types/antv-util/path/parser/params-parser.d.ts +10 -0
- package/types/antv-util/path/parser/parse-path-string.d.ts +6 -0
- package/types/antv-util/path/parser/path-parser.d.ts +16 -0
- package/types/antv-util/path/parser/scan-flag.d.ts +6 -0
- package/types/antv-util/path/parser/scan-param.d.ts +6 -0
- package/types/antv-util/path/parser/scan-segment.d.ts +6 -0
- package/types/antv-util/path/parser/skip-spaces.d.ts +7 -0
- package/types/antv-util/path/process/arc-2-cubic.d.ts +7 -0
- package/types/antv-util/path/process/clone-path.d.ts +2 -0
- package/types/antv-util/path/process/fix-arc.d.ts +2 -0
- package/types/antv-util/path/process/line-2-cubic.d.ts +1 -0
- package/types/antv-util/path/process/normalize-path.d.ts +8 -0
- package/types/antv-util/path/process/normalize-segment.d.ts +6 -0
- package/types/antv-util/path/process/quad-2-cubic.d.ts +1 -0
- package/types/antv-util/path/process/reverse-curve.d.ts +2 -0
- package/types/antv-util/path/process/round-path.d.ts +6 -0
- package/types/antv-util/path/process/segment-2-cubic.d.ts +2 -0
- package/types/antv-util/path/types.d.ts +122 -0
- package/types/antv-util/path/util/distance-square-root.d.ts +1 -0
- package/types/antv-util/path/util/equalize-segments.d.ts +2 -0
- package/types/antv-util/path/util/get-draw-direction.d.ts +2 -0
- package/types/antv-util/path/util/get-path-area.d.ts +8 -0
- package/types/antv-util/path/util/get-path-bbox-total-length.d.ts +5 -0
- package/types/antv-util/path/util/get-path-bbox.d.ts +5 -0
- package/types/antv-util/path/util/get-point-at-length.d.ts +5 -0
- package/types/antv-util/path/util/get-properties-at-length.d.ts +6 -0
- package/types/antv-util/path/util/get-properties-at-point.d.ts +7 -0
- package/types/antv-util/path/util/get-rotated-curve.d.ts +2 -0
- package/types/antv-util/path/util/get-total-length.d.ts +8 -0
- package/types/antv-util/path/util/is-absolute-array.d.ts +6 -0
- package/types/antv-util/path/util/is-curve-array.d.ts +9 -0
- package/types/antv-util/path/util/is-normalized-array.d.ts +7 -0
- package/types/antv-util/path/util/is-path-array.d.ts +5 -0
- package/types/antv-util/path/util/is-point-in-stroke.d.ts +5 -0
- package/types/antv-util/path/util/mid-point.d.ts +1 -0
- package/types/antv-util/path/util/path-length-factory.d.ts +7 -0
- package/types/antv-util/path/util/rotate-vector.d.ts +4 -0
- package/types/antv-util/path/util/segment-arc-factory.d.ts +6 -0
- package/types/antv-util/path/util/segment-cubic-factory.d.ts +6 -0
- package/types/antv-util/path/util/segment-line-factory.d.ts +6 -0
- package/types/antv-util/path/util/segment-quad-factory.d.ts +6 -0
- package/types/callbacks.d.ts +30 -0
- package/types/color/colord/src/colorModels/cmyk.d.ts +23 -0
- package/types/color/colord/src/colorModels/cmykString.d.ts +7 -0
- package/types/color/colord/src/colorModels/hex.d.ts +5 -0
- package/types/color/colord/src/colorModels/hsl.d.ts +8 -0
- package/types/color/colord/src/colorModels/hslString.d.ts +7 -0
- package/types/color/colord/src/colorModels/hsv.d.ts +6 -0
- package/types/color/colord/src/colorModels/hwb.d.ts +6 -0
- package/types/color/colord/src/colorModels/hwbString.d.ts +7 -0
- package/types/color/colord/src/colorModels/lab.d.ts +18 -0
- package/types/color/colord/src/colorModels/lch.d.ts +19 -0
- package/types/color/colord/src/colorModels/lchString.d.ts +7 -0
- package/types/color/colord/src/colorModels/rgb.d.ts +13 -0
- package/types/color/colord/src/colorModels/rgbString.d.ts +7 -0
- package/types/color/colord/src/colorModels/xyz.d.ts +30 -0
- package/types/color/colord/src/colord.d.ts +103 -0
- package/types/color/colord/src/constants.d.ts +10 -0
- package/types/color/colord/src/extend.d.ts +4 -0
- package/types/color/colord/src/get/getBrightness.d.ts +7 -0
- package/types/color/colord/src/get/getContrast.d.ts +6 -0
- package/types/color/colord/src/get/getLuminance.d.ts +6 -0
- package/types/color/colord/src/get/getPerceivedDifference.d.ts +24 -0
- package/types/color/colord/src/helpers.d.ts +20 -0
- package/types/color/colord/src/index.d.ts +5 -0
- package/types/color/colord/src/manipulate/changeAlpha.d.ts +2 -0
- package/types/color/colord/src/manipulate/invert.d.ts +2 -0
- package/types/color/colord/src/manipulate/lighten.d.ts +2 -0
- package/types/color/colord/src/manipulate/mix.d.ts +2 -0
- package/types/color/colord/src/manipulate/saturate.d.ts +2 -0
- package/types/color/colord/src/parse.d.ts +8 -0
- package/types/color/colord/src/plugins/a11y.d.ts +38 -0
- package/types/color/colord/src/plugins/cmyk.d.ts +24 -0
- package/types/color/colord/src/plugins/harmonies.d.ts +16 -0
- package/types/color/colord/src/plugins/hwb.d.ts +23 -0
- package/types/color/colord/src/plugins/lab.d.ts +23 -0
- package/types/color/colord/src/plugins/lch.d.ts +24 -0
- package/types/color/colord/src/plugins/minify.d.ts +20 -0
- package/types/color/colord/src/plugins/mix.d.ts +27 -0
- package/types/color/colord/src/plugins/names.d.ts +19 -0
- package/types/color/colord/src/plugins/xyz.d.ts +14 -0
- package/types/color/colord/src/random.d.ts +2 -0
- package/types/color/colord/src/types.d.ts +67 -0
- package/types/data/immer.d.ts +262 -0
- package/types/data/immutable.d.ts +5127 -0
- package/types/data/mobx.d.ts +154 -0
- package/types/data/reactivity.d.ts +755 -0
- package/types/data/signals.d.ts +144 -0
- package/types/deepmerge.d.ts +16 -0
- package/types/events/eventTarget.d.ts +93 -0
- package/types/events/event_emiter.d.ts +43 -0
- package/types/events/eventemitter3.d.ts +135 -0
- package/types/events/mitt.d.ts +21 -0
- package/types/fast-deep-equal.d.ts +1 -0
- package/types/index.d.ts +20 -0
- package/types/ismobilejs.d.ts +46 -0
- package/types/lodash/augment.d.ts +2 -0
- package/types/lodash/cache.d.ts +14 -0
- package/types/lodash/clamp.d.ts +2 -0
- package/types/lodash/clear-animation-frame.d.ts +1 -0
- package/types/lodash/clone.d.ts +2 -0
- package/types/lodash/contains.d.ts +2 -0
- package/types/lodash/debounce.d.ts +2 -0
- package/types/lodash/deep-mix.d.ts +2 -0
- package/types/lodash/difference.d.ts +11 -0
- package/types/lodash/each.d.ts +2 -0
- package/types/lodash/ends-with.d.ts +3 -0
- package/types/lodash/every.d.ts +7 -0
- package/types/lodash/extend.d.ts +2 -0
- package/types/lodash/filter.d.ts +2 -0
- package/types/lodash/find-index.d.ts +2 -0
- package/types/lodash/find.d.ts +3 -0
- package/types/lodash/first-value.d.ts +2 -0
- package/types/lodash/fixed-base.d.ts +2 -0
- package/types/lodash/flatten-deep.d.ts +12 -0
- package/types/lodash/flatten.d.ts +11 -0
- package/types/lodash/for-in.d.ts +2 -0
- package/types/lodash/get-range.d.ts +6 -0
- package/types/lodash/get-type.d.ts +2 -0
- package/types/lodash/get-wrap-behavior.d.ts +9 -0
- package/types/lodash/get.d.ts +8 -0
- package/types/lodash/group-by.d.ts +6 -0
- package/types/lodash/group-to-map.d.ts +8 -0
- package/types/lodash/group.d.ts +2 -0
- package/types/lodash/has-key.d.ts +2 -0
- package/types/lodash/has-value.d.ts +2 -0
- package/types/lodash/has.d.ts +2 -0
- package/types/lodash/head.d.ts +1 -0
- package/types/lodash/identity.d.ts +2 -0
- package/types/lodash/index-of.d.ts +2 -0
- package/types/lodash/index.d.ts +108 -0
- package/types/lodash/is-arguments.d.ts +2 -0
- package/types/lodash/is-array-like.d.ts +2 -0
- package/types/lodash/is-array.d.ts +2 -0
- package/types/lodash/is-boolean.d.ts +2 -0
- package/types/lodash/is-date.d.ts +2 -0
- package/types/lodash/is-decimal.d.ts +2 -0
- package/types/lodash/is-element.d.ts +6 -0
- package/types/lodash/is-empty.d.ts +2 -0
- package/types/lodash/is-equal-with.d.ts +24 -0
- package/types/lodash/is-equal.d.ts +2 -0
- package/types/lodash/is-error.d.ts +2 -0
- package/types/lodash/is-even.d.ts +2 -0
- package/types/lodash/is-finite.d.ts +1 -0
- package/types/lodash/is-function.d.ts +2 -0
- package/types/lodash/is-integer.d.ts +2 -0
- package/types/lodash/is-match.d.ts +2 -0
- package/types/lodash/is-negative.d.ts +2 -0
- package/types/lodash/is-nil.d.ts +2 -0
- package/types/lodash/is-null.d.ts +2 -0
- package/types/lodash/is-number-equal.d.ts +1 -0
- package/types/lodash/is-number.d.ts +2 -0
- package/types/lodash/is-object-like.d.ts +2 -0
- package/types/lodash/is-object.d.ts +2 -0
- package/types/lodash/is-odd.d.ts +2 -0
- package/types/lodash/is-plain-object.d.ts +2 -0
- package/types/lodash/is-positive.d.ts +2 -0
- package/types/lodash/is-prototype.d.ts +2 -0
- package/types/lodash/is-reg-exp.d.ts +2 -0
- package/types/lodash/is-segment-equal.d.ts +2 -0
- package/types/lodash/is-string.d.ts +2 -0
- package/types/lodash/is-type.d.ts +2 -0
- package/types/lodash/is-undefined.d.ts +2 -0
- package/types/lodash/keys.d.ts +2 -0
- package/types/lodash/last.d.ts +1 -0
- package/types/lodash/lower-case.d.ts +2 -0
- package/types/lodash/lower-first.d.ts +2 -0
- package/types/lodash/map-values.d.ts +6 -0
- package/types/lodash/map.d.ts +2 -0
- package/types/lodash/max-by.d.ts +16 -0
- package/types/lodash/max.d.ts +19 -0
- package/types/lodash/memoize.d.ts +11 -0
- package/types/lodash/merge.d.ts +7 -0
- package/types/lodash/min-by.d.ts +16 -0
- package/types/lodash/min.d.ts +19 -0
- package/types/lodash/mix.d.ts +1 -0
- package/types/lodash/mod.d.ts +2 -0
- package/types/lodash/noop.d.ts +2 -0
- package/types/lodash/number2color.d.ts +2 -0
- package/types/lodash/omit.d.ts +3 -0
- package/types/lodash/parse-radius.d.ts +9 -0
- package/types/lodash/pick.d.ts +16 -0
- package/types/lodash/pull-at.d.ts +2 -0
- package/types/lodash/pull.d.ts +2 -0
- package/types/lodash/reduce.d.ts +3 -0
- package/types/lodash/remove.d.ts +2 -0
- package/types/lodash/request-animation-frame.d.ts +1 -0
- package/types/lodash/set.d.ts +8 -0
- package/types/lodash/size.d.ts +1 -0
- package/types/lodash/some.d.ts +7 -0
- package/types/lodash/sort-by.d.ts +7 -0
- package/types/lodash/starts-with.d.ts +3 -0
- package/types/lodash/substitute.d.ts +5 -0
- package/types/lodash/throttle.d.ts +6 -0
- package/types/lodash/to-array.d.ts +2 -0
- package/types/lodash/to-degree.d.ts +2 -0
- package/types/lodash/to-integer.d.ts +1 -0
- package/types/lodash/to-radian.d.ts +2 -0
- package/types/lodash/to-string.d.ts +2 -0
- package/types/lodash/types/index.d.ts +3 -0
- package/types/lodash/union.d.ts +2 -0
- package/types/lodash/uniq.d.ts +1 -0
- package/types/lodash/unique-id.d.ts +2 -0
- package/types/lodash/upper-case.d.ts +2 -0
- package/types/lodash/upper-first.d.ts +2 -0
- package/types/lodash/values-of-key.d.ts +2 -0
- package/types/lodash/values.d.ts +2 -0
- package/types/lodash/wrap-behavior.d.ts +9 -0
- package/types/parse-svg-path.d.ts +19 -0
- package/types/priority_queue.d.ts +41 -0
- package/types/radash/array.d.ts +209 -0
- package/types/radash/async.d.ts +99 -0
- package/types/radash/curry.d.ts +113 -0
- package/types/radash/index.d.ts +10 -0
- package/types/radash/number.d.ts +27 -0
- package/types/radash/object.d.ts +112 -0
- package/types/radash/random.d.ts +11 -0
- package/types/radash/series.d.ts +13 -0
- package/types/radash/string.d.ts +71 -0
- package/types/radash/typed.d.ts +26 -0
- package/types/stats.module.d.ts +3 -0
- package/README.md +0 -1
- package/dist/cjs/index.js +0 -19
- package/dist/umd/index.js +0 -23
- package/esm/extend.js +0 -3
- package/esm/index.js +0 -3
- package/lib/extend.js +0 -6
- package/lib/index.js +0 -6
- package/src/extend.ts +0 -6
- package/src/index.ts +0 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mod(n: number, m: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toRadian(degree: number): number;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 根据 actions 来做 transform
|
|
3
|
+
* @param m
|
|
4
|
+
* @param actions
|
|
5
|
+
*/
|
|
6
|
+
export declare function transform(m: number[], actions: any[][]): number[];
|
|
7
|
+
/**
|
|
8
|
+
* 向量 v1 到 向量 v2 夹角的方向
|
|
9
|
+
* @param {Array} v1 向量
|
|
10
|
+
* @param {Array} v2 向量
|
|
11
|
+
* @return {Boolean} >= 0 顺时针 < 0 逆时针
|
|
12
|
+
*/
|
|
13
|
+
export declare function direction(v1: number[], v2: number[]): number;
|
|
14
|
+
/**
|
|
15
|
+
* 二维向量 v1 到 v2 的夹角
|
|
16
|
+
* @param v1
|
|
17
|
+
* @param v2
|
|
18
|
+
* @param direct
|
|
19
|
+
*/
|
|
20
|
+
export declare function angleTo(v1: [number, number], v2: [number, number], direct?: boolean): number;
|
|
21
|
+
/**
|
|
22
|
+
* 计算二维向量的垂直向量
|
|
23
|
+
* @param out
|
|
24
|
+
* @param v
|
|
25
|
+
* @param flag
|
|
26
|
+
*/
|
|
27
|
+
export declare function vertical(out: number[], v: number[], flag: boolean): number[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { path2String } from './convert/path-2-string';
|
|
2
|
+
export { path2Curve } from './convert/path-2-curve';
|
|
3
|
+
export { path2Absolute } from './convert/path-2-absolute';
|
|
4
|
+
export { clonePath } from './process/clone-path';
|
|
5
|
+
export { normalizePath } from './process/normalize-path';
|
|
6
|
+
export { reverseCurve } from './process/reverse-curve';
|
|
7
|
+
export { getPathBBox } from './util/get-path-bbox';
|
|
8
|
+
export { getTotalLength } from './util/get-total-length';
|
|
9
|
+
export { getPathBBoxTotalLength } from './util/get-path-bbox-total-length';
|
|
10
|
+
export { getRotatedCurve } from './util/get-rotated-curve';
|
|
11
|
+
export { getPathArea } from './util/get-path-area';
|
|
12
|
+
export { getDrawDirection } from './util/get-draw-direction';
|
|
13
|
+
export { getPointAtLength } from './util/get-point-at-length';
|
|
14
|
+
export { isPointInStroke } from './util/is-point-in-stroke';
|
|
15
|
+
export { distanceSquareRoot } from './util/distance-square-root';
|
|
16
|
+
export { equalizeSegments } from './util/equalize-segments';
|
|
17
|
+
export * from './types';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PathArray } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* The `PathParser` is used by the `parsePathString` static method
|
|
4
|
+
* to generate a `pathArray`.
|
|
5
|
+
*/
|
|
6
|
+
export declare class PathParser {
|
|
7
|
+
pathValue: string;
|
|
8
|
+
segments: PathArray;
|
|
9
|
+
max: number;
|
|
10
|
+
index: number;
|
|
11
|
+
param: number;
|
|
12
|
+
segmentStart: number;
|
|
13
|
+
data: any;
|
|
14
|
+
err: string;
|
|
15
|
+
constructor(pathString: string);
|
|
16
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts A (arc-to) segments to C (cubic-bezier-to).
|
|
3
|
+
*
|
|
4
|
+
* For more information of where this math came from visit:
|
|
5
|
+
* http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
|
|
6
|
+
*/
|
|
7
|
+
export declare function arcToCubic(X1: number, Y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, X2: number, Y2: number, recursive: number[]): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function lineToCubic(x1: number, y1: number, x2: number, y2: number): number[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PathArray, NormalArray } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* @example
|
|
4
|
+
* const path = 'M0 0 H50';
|
|
5
|
+
* const normalizedPath = SVGPathCommander.normalizePath(path);
|
|
6
|
+
* // result => [['M', 0, 0], ['L', 50, 0]]
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizePath(pathInput: string | PathArray): NormalArray;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function quadToCubic(x1: number, y1: number, qx: number, qy: number, x2: number, y2: number): number[];
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export type Point = {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
};
|
|
5
|
+
export type MCommand = 'M';
|
|
6
|
+
export type mCommand = 'm';
|
|
7
|
+
export type LCommand = 'L';
|
|
8
|
+
export type lCommand = 'l';
|
|
9
|
+
export type VCommand = 'V';
|
|
10
|
+
export type vCommand = 'v';
|
|
11
|
+
export type HCommand = 'H';
|
|
12
|
+
export type hCommand = 'h';
|
|
13
|
+
export type ZCommand = 'Z';
|
|
14
|
+
export type zCommand = 'z';
|
|
15
|
+
export type CCommand = 'C';
|
|
16
|
+
export type cCommand = 'c';
|
|
17
|
+
export type SCommand = 'S';
|
|
18
|
+
export type sCommand = 's';
|
|
19
|
+
export type QCommand = 'Q';
|
|
20
|
+
export type qCommand = 'q';
|
|
21
|
+
export type TCommand = 'T';
|
|
22
|
+
export type tCommand = 't';
|
|
23
|
+
export type ACommand = 'A';
|
|
24
|
+
export type aCommand = 'a';
|
|
25
|
+
export type AbsoluteCommand = MCommand | LCommand | VCommand | HCommand | ZCommand | CCommand | SCommand | QCommand | TCommand | ACommand;
|
|
26
|
+
export type RelativeCommand = mCommand | lCommand | vCommand | hCommand | zCommand | cCommand | sCommand | qCommand | tCommand | aCommand;
|
|
27
|
+
export type PathCommand = AbsoluteCommand | RelativeCommand;
|
|
28
|
+
export type MSegment = [MCommand, number, number];
|
|
29
|
+
export type mSegment = [mCommand, number, number];
|
|
30
|
+
export type MoveSegment = MSegment | mSegment;
|
|
31
|
+
export type LSegment = [LCommand, number, number];
|
|
32
|
+
export type lSegment = [lCommand, number, number];
|
|
33
|
+
export type LineSegment = LSegment | lSegment;
|
|
34
|
+
export type VSegment = [VCommand, number];
|
|
35
|
+
export type vSegment = [vCommand, number];
|
|
36
|
+
export type VertLineSegment = vSegment | VSegment;
|
|
37
|
+
export type HSegment = [HCommand, number];
|
|
38
|
+
export type hSegment = [hCommand, number];
|
|
39
|
+
export type HorLineSegment = HSegment | hSegment;
|
|
40
|
+
export type ZSegment = [ZCommand];
|
|
41
|
+
export type zSegment = [zCommand];
|
|
42
|
+
export type CloseSegment = ZSegment | zSegment;
|
|
43
|
+
export type CSegment = [CCommand, number, number, number, number, number, number];
|
|
44
|
+
export type cSegment = [cCommand, number, number, number, number, number, number];
|
|
45
|
+
export type CubicSegment = CSegment | cSegment;
|
|
46
|
+
export type SSegment = [SCommand, number, number, number, number];
|
|
47
|
+
export type sSegment = [sCommand, number, number, number, number];
|
|
48
|
+
export type ShortCubicSegment = SSegment | sSegment;
|
|
49
|
+
export type QSegment = [QCommand, number, number, number, number];
|
|
50
|
+
export type qSegment = [qCommand, number, number, number, number];
|
|
51
|
+
export type QuadSegment = QSegment | qSegment;
|
|
52
|
+
export type TSegment = [TCommand, number, number];
|
|
53
|
+
export type tSegment = [tCommand, number, number];
|
|
54
|
+
export type ShortQuadSegment = TSegment | tSegment;
|
|
55
|
+
export type ASegment = [ACommand, number, number, number, number, number, number, number];
|
|
56
|
+
export type aSegment = [aCommand, number, number, number, number, number, number, number];
|
|
57
|
+
export type ArcSegment = ASegment | aSegment;
|
|
58
|
+
export type PathSegment = MoveSegment | LineSegment | VertLineSegment | HorLineSegment | CloseSegment | CubicSegment | ShortCubicSegment | QuadSegment | ShortQuadSegment | ArcSegment;
|
|
59
|
+
export interface SegmentProperties {
|
|
60
|
+
/** the segment */
|
|
61
|
+
segment: PathSegment;
|
|
62
|
+
/** the segment index */
|
|
63
|
+
index: number;
|
|
64
|
+
/** the segment length */
|
|
65
|
+
length: number;
|
|
66
|
+
/** the length including the segment length */
|
|
67
|
+
lengthAtSegment: number;
|
|
68
|
+
[key: string]: any;
|
|
69
|
+
}
|
|
70
|
+
export type ShortSegment = VertLineSegment | HorLineSegment | ShortCubicSegment | ShortQuadSegment | CloseSegment;
|
|
71
|
+
export type AbsoluteSegment = MSegment | LSegment | VSegment | HSegment | CSegment | SSegment | QSegment | TSegment | ASegment | ZSegment;
|
|
72
|
+
export type RelativeSegment = mSegment | lSegment | vSegment | hSegment | cSegment | sSegment | qSegment | tSegment | aSegment | zSegment;
|
|
73
|
+
export type NormalSegment = MSegment | LSegment | CSegment | QSegment | ASegment | ZSegment;
|
|
74
|
+
export type PathArray = [MSegment | mSegment, ...PathSegment[]];
|
|
75
|
+
export type AbsoluteArray = [MSegment, ...AbsoluteSegment[]];
|
|
76
|
+
export type RelativeArray = [MSegment, ...RelativeSegment[]];
|
|
77
|
+
export type NormalArray = [MSegment, ...NormalSegment[]];
|
|
78
|
+
export type CurveArray = [MSegment, ...CSegment[]];
|
|
79
|
+
export type PolygonArray = [MSegment, ...LSegment[], ZSegment];
|
|
80
|
+
export type PolylineArray = [MSegment, ...LSegment[]];
|
|
81
|
+
export interface ParserParams {
|
|
82
|
+
x1: number;
|
|
83
|
+
y1: number;
|
|
84
|
+
x2: number;
|
|
85
|
+
y2: number;
|
|
86
|
+
x: number;
|
|
87
|
+
y: number;
|
|
88
|
+
qx: number | null;
|
|
89
|
+
qy: number | null;
|
|
90
|
+
}
|
|
91
|
+
export interface PathBBox {
|
|
92
|
+
width: number;
|
|
93
|
+
height: number;
|
|
94
|
+
x: number;
|
|
95
|
+
y: number;
|
|
96
|
+
x2: number;
|
|
97
|
+
y2: number;
|
|
98
|
+
cx: number;
|
|
99
|
+
cy: number;
|
|
100
|
+
cz: number;
|
|
101
|
+
}
|
|
102
|
+
export interface PathBBoxTotalLength extends PathBBox {
|
|
103
|
+
length: number;
|
|
104
|
+
}
|
|
105
|
+
export interface SegmentLimits {
|
|
106
|
+
min: Point;
|
|
107
|
+
max: Point;
|
|
108
|
+
}
|
|
109
|
+
export interface PointProperties {
|
|
110
|
+
closest: {
|
|
111
|
+
x: number;
|
|
112
|
+
y: number;
|
|
113
|
+
};
|
|
114
|
+
distance: number;
|
|
115
|
+
segment?: SegmentProperties;
|
|
116
|
+
}
|
|
117
|
+
export interface LengthFactory {
|
|
118
|
+
length: number;
|
|
119
|
+
point: Point;
|
|
120
|
+
min: Point;
|
|
121
|
+
max: Point;
|
|
122
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function distanceSquareRoot(a: [number, number], b: [number, number]): number;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PathArray, SegmentProperties } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the segment, its index and length as well as
|
|
4
|
+
* the length to that segment at a given length in a path.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getPropertiesAtLength(pathInput: string | PathArray, distance?: number): SegmentProperties;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Point, PathArray, PointProperties } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the point and segment in path closest to a given point as well as
|
|
4
|
+
* the distance to the path stroke.
|
|
5
|
+
* @see https://bl.ocks.org/mbostock/8027637
|
|
6
|
+
*/
|
|
7
|
+
export declare function getPropertiesAtPoint(pathInput: string | PathArray, point: Point): PointProperties;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PathArray } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the shape total length, or the equivalent to `shape.getTotalLength()`.
|
|
4
|
+
*
|
|
5
|
+
* The `normalizePath` version is lighter, faster, more efficient and more accurate
|
|
6
|
+
* with paths that are not `curveArray`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getTotalLength(pathInput: string | PathArray): number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PathArray } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Iterates an array to check if it's a `PathArray`
|
|
4
|
+
* with all C (cubic bezier) segments.
|
|
5
|
+
*
|
|
6
|
+
* @param {string | PathArray} path the `Array` to be checked
|
|
7
|
+
* @returns {boolean} iteration result
|
|
8
|
+
*/
|
|
9
|
+
export declare function isCurveArray(path: string | PathArray): path is PathArray;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PathArray } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Iterates an array to check if it's a `PathArray`
|
|
4
|
+
* with all segments are in non-shorthand notation
|
|
5
|
+
* with absolute values.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isNormalizedArray(path: string | PathArray): path is PathArray;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function midPoint(a: number[], b: number[], t: number): number[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PathArray, LengthFactory } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a {x,y} point at a given length
|
|
4
|
+
* of a shape, the shape total length and
|
|
5
|
+
* the shape minimum and maximum {x,y} coordinates.
|
|
6
|
+
*/
|
|
7
|
+
export declare function pathLengthFactory(pathInput: string | PathArray, distance?: number): LengthFactory;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LengthFactory } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a {x,y} point at a given length, the total length and
|
|
4
|
+
* the shape minimum and maximum {x,y} coordinates of an A (arc-to) segment.
|
|
5
|
+
*/
|
|
6
|
+
export declare function segmentArcFactory(X1: number, Y1: number, RX: number, RY: number, angle: number, LAF: number, SF: number, X2: number, Y2: number, distance: number): LengthFactory;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LengthFactory } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the length of a C (cubic-bezier) segment
|
|
4
|
+
* or an {x,y} point at a given length.
|
|
5
|
+
*/
|
|
6
|
+
export declare function segmentCubicFactory(x1: number, y1: number, c1x: number, c1y: number, c2x: number, c2y: number, x2: number, y2: number, distance: number): LengthFactory;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LengthFactory } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a {x,y} point at a given length, the total length and
|
|
4
|
+
* the minimum and maximum {x,y} coordinates of a line (L,V,H,Z) segment.
|
|
5
|
+
*/
|
|
6
|
+
export declare function segmentLineFactory(x1: number, y1: number, x2: number, y2: number, distance: number): LengthFactory;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LengthFactory } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a {x,y} point at a given length, the total length and
|
|
4
|
+
* the minimum and maximum {x,y} coordinates of a Q (quadratic-bezier) segment.
|
|
5
|
+
*/
|
|
6
|
+
export declare function segmentQuadFactory(x1: number, y1: number, qx: number, qy: number, x2: number, y2: number, distance: number): LengthFactory;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
type CallbacksOptions = {
|
|
2
|
+
once?: boolean;
|
|
3
|
+
memory?: boolean;
|
|
4
|
+
unique?: boolean;
|
|
5
|
+
stopOnFalse?: boolean;
|
|
6
|
+
};
|
|
7
|
+
type ListHandle<Args extends any[] = any> = (...args: Args) => any;
|
|
8
|
+
export declare class Callbacks<Args extends any[] = any, Context extends any = any> {
|
|
9
|
+
firing: boolean;
|
|
10
|
+
memory: any;
|
|
11
|
+
fired: boolean;
|
|
12
|
+
locked: boolean;
|
|
13
|
+
list: ListHandle<Args>[];
|
|
14
|
+
queue: any[];
|
|
15
|
+
firingIndex: number;
|
|
16
|
+
destroyedList: boolean;
|
|
17
|
+
options: Required<CallbacksOptions>;
|
|
18
|
+
constructor(options?: CallbacksOptions);
|
|
19
|
+
private _fire;
|
|
20
|
+
add(...args: (ListHandle<Args> | ListHandle<Args>[])[]): this;
|
|
21
|
+
remove(...args: ListHandle[]): this;
|
|
22
|
+
has(fn: ListHandle): boolean;
|
|
23
|
+
empty(): this;
|
|
24
|
+
disable(): this;
|
|
25
|
+
disabled(): boolean;
|
|
26
|
+
lock(): this;
|
|
27
|
+
fireWith(context: Context, args: Args): this;
|
|
28
|
+
fire(...args: Args): this;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RgbaColor, InputObject, CmykaColor } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Clamps the CMYK color object values.
|
|
4
|
+
*/
|
|
5
|
+
export declare const clampCmyka: (cmyka: CmykaColor) => CmykaColor;
|
|
6
|
+
/**
|
|
7
|
+
* Rounds the CMYK color object values.
|
|
8
|
+
*/
|
|
9
|
+
export declare const roundCmyka: (cmyka: CmykaColor) => CmykaColor;
|
|
10
|
+
/**
|
|
11
|
+
* Transforms the CMYK color object to RGB.
|
|
12
|
+
* https://www.rapidtables.com/convert/color/cmyk-to-rgb.html
|
|
13
|
+
*/
|
|
14
|
+
export declare function cmykaToRgba(cmyka: CmykaColor): RgbaColor;
|
|
15
|
+
/**
|
|
16
|
+
* Convert RGB Color Model object to CMYK.
|
|
17
|
+
* https://www.rapidtables.com/convert/color/rgb-to-cmyk.html
|
|
18
|
+
*/
|
|
19
|
+
export declare function rgbaToCmyka(rgba: RgbaColor): CmykaColor;
|
|
20
|
+
/**
|
|
21
|
+
* Parses the CMYK color object into RGB.
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseCmyka({ c, m, y, k, a }: InputObject): RgbaColor | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RgbaColor } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a valid CMYK CSS color function/string
|
|
4
|
+
* https://www.w3.org/TR/css-color-4/#device-cmyk
|
|
5
|
+
*/
|
|
6
|
+
export declare const parseCmykaString: (input: string) => RgbaColor | null;
|
|
7
|
+
export declare function rgbaToCmykaString(rgb: RgbaColor): string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RgbaColor } from '../types';
|
|
2
|
+
/** Parses any valid Hex3, Hex4, Hex6 or Hex8 string and converts it to an RGBA object */
|
|
3
|
+
export declare const parseHex: (hex: string) => RgbaColor | null;
|
|
4
|
+
/** Converts RGBA object to Hex6 or (if it has alpha channel) Hex8 string */
|
|
5
|
+
export declare const rgbaToHex: (rgba: RgbaColor) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InputObject, RgbaColor, HslaColor, HsvaColor } from '../types';
|
|
2
|
+
export declare const clampHsla: (hsla: HslaColor) => HslaColor;
|
|
3
|
+
export declare const roundHsla: (hsla: HslaColor) => HslaColor;
|
|
4
|
+
export declare const parseHsla: ({ h, s, l, a }: InputObject) => RgbaColor | null;
|
|
5
|
+
export declare const hslaToHsva: ({ h, s, l, a }: HslaColor) => HsvaColor;
|
|
6
|
+
export declare const hsvaToHsla: ({ h, s, v, a }: HsvaColor) => HslaColor;
|
|
7
|
+
export declare const hslaToRgba: (hsla: HslaColor) => RgbaColor;
|
|
8
|
+
export declare const rgbaToHsla: (rgba: RgbaColor) => HslaColor;
|