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 |
|
61 | segment: PathSegment;
|
62 |
|
63 | index: number;
|
64 |
|
65 | length: number;
|
66 |
|
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 PathLengthFactoryOptions {
|
106 | bbox: boolean;
|
107 | length: boolean;
|
108 | sampleSize: number;
|
109 | }
|
110 | export interface SegmentLimits {
|
111 | min: Point;
|
112 | max: Point;
|
113 | }
|
114 | export interface PointProperties {
|
115 | closest: {
|
116 | x: number;
|
117 | y: number;
|
118 | };
|
119 | distance: number;
|
120 | segment?: SegmentProperties;
|
121 | }
|
122 | export interface LengthFactory {
|
123 | length: number;
|
124 | point: Point;
|
125 | min: Point;
|
126 | max: Point;
|
127 | }
|