-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathjs-bindings.d.ts
More file actions
226 lines (201 loc) · 7.57 KB
/
Copy pathjs-bindings.d.ts
File metadata and controls
226 lines (201 loc) · 7.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
/* auto-generated by NAPI-RS */
/* eslint-disable */
/** Mutable SVG builder exposed to JavaScript. */
export declare class SvgFile {
/** Create an empty SVG document. */
constructor(width: number, height: number, pathPrecision?: number | undefined | null);
/** SVG width in pixels. */
get width(): number;
/** SVG height in pixels. */
get height(): number;
/** Decimal precision used when writing path data. */
get pathPrecision(): number | null;
/** Number of paths currently stored in the SVG. */
get pathCount(): number;
/** Serialize the SVG document to a string. */
toString(): string;
}
export type JsSvgFile = SvgFile;
/** RGBA color value. */
export interface Color {
/** Red channel from 0 to 255. */
r: number;
/** Green channel from 0 to 255. */
g: number;
/** Blue channel from 0 to 255. */
b: number;
/** Optional alpha channel from 0 to 255. */
a?: number;
}
/** Check whether an RGB color exists in decoded image data asynchronously. */
export declare function colorExistsInImage(
img: ImageData,
color: Color,
signal?: AbortSignal | undefined | null,
): Promise<boolean>;
/** Check whether an RGB color exists in decoded image data synchronously. */
export declare function colorExistsInImageSync(img: ImageData, color: Color): boolean;
/** Input color interpretation mode. */
export declare enum ColorMode {
/** Trace the image using color clusters. */
Color = 0,
/** Trace the image as a black and white image. */
Binary = 1,
}
/** Vectorization configuration. */
export interface Config {
/** True color image or binary image (black and white) */
colorMode: ColorMode;
/** Hierarchial clustering or non-stacked. Only applicable to color images. */
hierarchical: Hierarchical;
/** Discard patches smaller than X pixels in size (cleaner) */
filterSpeckle: number;
/** The number of significant bits to use in an RGB channel (more accurate) */
colorPrecision: number;
/** The color difference between gradient layers (less layers) */
layerDifference: number;
/** Curve fitting mode */
mode: PathSimplifyMode;
/** Minimum momentary angle (degree) to be considered a corner (smoother) */
cornerThreshold: number;
/** Perform iterative subdivide smooth until all segments are shorter than this length */
lengthThreshold: number;
/** The maximum number of iterations to perform */
maxIterations: number;
/** Minimum angle displacement (degree) to splice a spline (less accurate) */
spliceThreshold: number;
/** Number of decimal places to use in path string */
pathPrecision?: number;
/** Random color search attempts after the reserved key colors are exhausted */
unusedColorIterations?: number;
/** Transparent boundary fraction required before keying is applied */
keyingThreshold?: number;
/** Maximum cluster bounds treated as a small circle in spline mode */
smallCircle?: number;
}
/** Find an RGB color that does not exist in decoded image data asynchronously. */
export declare function findUnusedColorInImage(
img: ImageData,
options?: InternalOptions | undefined | null,
signal?: AbortSignal | undefined | null,
): Promise<Color>;
/** Find an RGB color that does not exist in decoded image data synchronously. */
export declare function findUnusedColorInImageSync(img: ImageData, options?: InternalOptions | undefined | null): Color;
/** Color image layer composition mode. */
export declare enum Hierarchical {
/** Render traced layers stacked on top of each other. */
Stacked = 0,
/** Render traced layers as cutouts. */
Cutout = 1,
}
/** Decoded RGBA image data. */
export interface ImageData {
/** Image width in pixels. */
width: number;
/** Image height in pixels. */
height: number;
/** RGBA pixel data with four bytes per pixel. */
pixels: Buffer;
}
/** Internal helper options. */
export interface InternalOptions {
/** Random color search attempts after reserved key colors are exhausted. */
unusedColorIterations?: number;
}
/** Optimize an SVG string asynchronously. */
export declare function optimize(
input: string,
options?: OptimizeOptions | undefined | null,
signal?: AbortSignal | undefined | null,
): Promise<string>;
/** Options for SVG optimization. */
export interface OptimizeOptions {
/** Built-in optimizer job preset. */
preset?: OptimizePreset;
/** SVGO Config["plugins"] compatible job config. When provided, this defines the optimizer job set. */
plugins?: Array<string | { name: string; params?: unknown }>;
/** Optimizer job names to omit. Names can be camelCase, kebab-case, or snake_case. */
omit?: Array<string>;
/** Run optimization repeatedly until output stops changing or the iteration limit is reached. */
multipass?: boolean;
/** Maximum multipass iterations. Defaults to 10 when multipass is enabled. */
multipassIterations?: number;
}
/** Built-in optimization presets. */
export declare enum OptimizePreset {
/** Run the default OXVG optimizer job set. */
Default = 0,
/** Run the safer OXVG optimizer job set. */
Safe = 1,
/** Start with no optimizer jobs. */
None = 2,
}
/** Optimize an SVG string synchronously. */
export declare function optimizeSync(input: string, options?: OptimizeOptions | undefined | null): string;
/** Path simplification strategy used while fitting vector paths. */
export declare enum PathSimplifyMode {
/** Do not simplify paths. */
None = 0,
/** Simplify paths into polygons. */
Polygon = 1,
/** Fit paths as splines. */
Spline = 2,
}
/** Preconfigured vectorization settings. */
export declare enum Preset {
/** Black and white tracing preset. */
Bw = 0,
/** Poster-like color tracing preset. */
Poster = 1,
/** Photo-like color tracing preset. */
Photo = 2,
}
/** Dimensions for raw RGBA pixel buffers. */
export interface RawDataConfig {
/** Raw image width in pixels. */
width: number;
/** Raw image height in pixels. */
height: number;
}
/** Decode an encoded image buffer or raw RGBA pixel buffer asynchronously. */
export declare function readImage(
source: Buffer,
args?: RawDataConfig | undefined | null,
signal?: AbortSignal | undefined | null,
): Promise<ImageData>;
/** Decode an encoded image buffer or raw RGBA pixel buffer synchronously. */
export declare function readImageSync(source: Buffer, args?: RawDataConfig | undefined | null): ImageData;
/** Vectorize an encoded image buffer asynchronously. */
export declare function vectorize(
source: Buffer,
config?: Config | Preset | undefined | null,
signal?: AbortSignal | undefined | null,
): Promise<string>;
/** Vectorize a raw RGBA pixel buffer asynchronously. */
export declare function vectorizeRaw(
source: Buffer,
args: RawDataConfig,
config?: Config | Preset | undefined | null,
signal?: AbortSignal | undefined | null,
): Promise<string>;
/** Vectorize a raw RGBA pixel buffer synchronously. */
export declare function vectorizeRawSync(
source: Buffer,
args: RawDataConfig,
config?: Config | Preset | undefined | null,
): string;
/** Vectorize a raw RGBA pixel buffer and emit SVG chunks to a callback. */
export declare function vectorizeRawToCallback(
source: Buffer,
args: RawDataConfig,
config: Config | Preset | undefined | null,
callback: (chunk: string, progress: number) => void,
): void;
/** Vectorize an encoded image buffer synchronously. */
export declare function vectorizeSync(source: Buffer, config?: Config | Preset | undefined | null): string;
/** Vectorize an encoded image buffer and emit SVG chunks to a callback. */
export declare function vectorizeToCallback(
source: Buffer,
config: Config | Preset | undefined | null,
callback: (chunk: string, progress: number) => void,
): void;