UNPKG

4.85 kBTypeScriptView Raw
1export type Point = {
2 x: number;
3 y: number;
4};
5export type MCommand = 'M';
6export type mCommand = 'm';
7export type LCommand = 'L';
8export type lCommand = 'l';
9export type VCommand = 'V';
10export type vCommand = 'v';
11export type HCommand = 'H';
12export type hCommand = 'h';
13export type ZCommand = 'Z';
14export type zCommand = 'z';
15export type CCommand = 'C';
16export type cCommand = 'c';
17export type SCommand = 'S';
18export type sCommand = 's';
19export type QCommand = 'Q';
20export type qCommand = 'q';
21export type TCommand = 'T';
22export type tCommand = 't';
23export type ACommand = 'A';
24export type aCommand = 'a';
25export type AbsoluteCommand = MCommand | LCommand | VCommand | HCommand | ZCommand | CCommand | SCommand | QCommand | TCommand | ACommand;
26export type RelativeCommand = mCommand | lCommand | vCommand | hCommand | zCommand | cCommand | sCommand | qCommand | tCommand | aCommand;
27export type PathCommand = AbsoluteCommand | RelativeCommand;
28export type MSegment = [MCommand, number, number];
29export type mSegment = [mCommand, number, number];
30export type MoveSegment = MSegment | mSegment;
31export type LSegment = [LCommand, number, number];
32export type lSegment = [lCommand, number, number];
33export type LineSegment = LSegment | lSegment;
34export type VSegment = [VCommand, number];
35export type vSegment = [vCommand, number];
36export type VertLineSegment = vSegment | VSegment;
37export type HSegment = [HCommand, number];
38export type hSegment = [hCommand, number];
39export type HorLineSegment = HSegment | hSegment;
40export type ZSegment = [ZCommand];
41export type zSegment = [zCommand];
42export type CloseSegment = ZSegment | zSegment;
43export type CSegment = [CCommand, number, number, number, number, number, number];
44export type cSegment = [cCommand, number, number, number, number, number, number];
45export type CubicSegment = CSegment | cSegment;
46export type SSegment = [SCommand, number, number, number, number];
47export type sSegment = [sCommand, number, number, number, number];
48export type ShortCubicSegment = SSegment | sSegment;
49export type QSegment = [QCommand, number, number, number, number];
50export type qSegment = [qCommand, number, number, number, number];
51export type QuadSegment = QSegment | qSegment;
52export type TSegment = [TCommand, number, number];
53export type tSegment = [tCommand, number, number];
54export type ShortQuadSegment = TSegment | tSegment;
55export type ASegment = [ACommand, number, number, number, number, number, number, number];
56export type aSegment = [aCommand, number, number, number, number, number, number, number];
57export type ArcSegment = ASegment | aSegment;
58export type PathSegment = MoveSegment | LineSegment | VertLineSegment | HorLineSegment | CloseSegment | CubicSegment | ShortCubicSegment | QuadSegment | ShortQuadSegment | ArcSegment;
59export 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}
70export type ShortSegment = VertLineSegment | HorLineSegment | ShortCubicSegment | ShortQuadSegment | CloseSegment;
71export type AbsoluteSegment = MSegment | LSegment | VSegment | HSegment | CSegment | SSegment | QSegment | TSegment | ASegment | ZSegment;
72export type RelativeSegment = mSegment | lSegment | vSegment | hSegment | cSegment | sSegment | qSegment | tSegment | aSegment | zSegment;
73export type NormalSegment = MSegment | LSegment | CSegment | QSegment | ASegment | ZSegment;
74export type PathArray = [MSegment | mSegment, ...PathSegment[]];
75export type AbsoluteArray = [MSegment, ...AbsoluteSegment[]];
76export type RelativeArray = [MSegment, ...RelativeSegment[]];
77export type NormalArray = [MSegment, ...NormalSegment[]];
78export type CurveArray = [MSegment, ...CSegment[]];
79export type PolygonArray = [MSegment, ...LSegment[], ZSegment];
80export type PolylineArray = [MSegment, ...LSegment[]];
81export 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}
91export 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}
102export interface PathBBoxTotalLength extends PathBBox {
103 length: number;
104}
105export interface PathLengthFactoryOptions {
106 bbox: boolean;
107 length: boolean;
108 sampleSize: number;
109}
110export interface SegmentLimits {
111 min: Point;
112 max: Point;
113}
114export interface PointProperties {
115 closest: {
116 x: number;
117 y: number;
118 };
119 distance: number;
120 segment?: SegmentProperties;
121}
122export interface LengthFactory {
123 length: number;
124 point: Point;
125 min: Point;
126 max: Point;
127}