@shotstack/shotstack-canvas 1.7.2 → 1.8.1
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/entry.node.cjs +1533 -31
- package/dist/entry.node.d.cts +413 -14
- package/dist/entry.node.d.ts +413 -14
- package/dist/entry.node.js +1499 -31
- package/dist/entry.web.d.ts +408 -14
- package/dist/entry.web.js +1452 -15
- package/package.json +2 -2
package/dist/entry.web.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { components } from '@shotstack/schemas';
|
|
3
|
+
export { svgAssetSchema, svgGradientStopSchema, svgLinearGradientFillSchema, svgRadialGradientFillSchema, svgShadowSchema, svgShapeSchema, svgSolidFillSchema, svgStrokeSchema, svgTransformSchema } from '@shotstack/schemas/zod';
|
|
3
4
|
|
|
4
5
|
declare const CanvasRichTextAssetSchema: z.ZodObject<{
|
|
5
6
|
type: z.ZodLiteral<"rich-text">;
|
|
@@ -7,11 +8,11 @@ declare const CanvasRichTextAssetSchema: z.ZodObject<{
|
|
|
7
8
|
width: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
8
9
|
height: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
9
10
|
font: z.ZodOptional<z.ZodObject<{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}>>;
|
|
11
|
+
stroke: z.ZodOptional<z.ZodObject<{
|
|
12
|
+
width: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
13
|
+
color: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
14
|
+
opacity: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
15
|
+
}, z.core.$strip>>;
|
|
15
16
|
family: z.ZodDefault<z.ZodString>;
|
|
16
17
|
size: z.ZodDefault<z.ZodNumber>;
|
|
17
18
|
weight: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
@@ -58,7 +59,7 @@ declare const CanvasRichTextAssetSchema: z.ZodObject<{
|
|
|
58
59
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
59
60
|
}, z.core.$strip>>;
|
|
60
61
|
background: z.ZodOptional<z.ZodObject<{
|
|
61
|
-
borderRadius: z.ZodDefault<z.ZodOptional<z.
|
|
62
|
+
borderRadius: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
62
63
|
color: z.ZodOptional<z.ZodString>;
|
|
63
64
|
opacity: z.ZodDefault<z.ZodNumber>;
|
|
64
65
|
}, z.core.$strip>>;
|
|
@@ -117,8 +118,146 @@ declare const CanvasRichTextAssetSchema: z.ZodObject<{
|
|
|
117
118
|
}, z.core.$strip>>>;
|
|
118
119
|
}, z.core.$strict>;
|
|
119
120
|
type CanvasRichTextAsset = z.infer<typeof CanvasRichTextAssetSchema>;
|
|
121
|
+
declare const CanvasSvgAssetSchema: z.ZodObject<{
|
|
122
|
+
type: z.ZodEnum<{
|
|
123
|
+
svg: "svg";
|
|
124
|
+
}>;
|
|
125
|
+
src: z.ZodOptional<z.ZodString>;
|
|
126
|
+
shape: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
127
|
+
type: z.ZodEnum<{
|
|
128
|
+
rectangle: "rectangle";
|
|
129
|
+
}>;
|
|
130
|
+
width: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
131
|
+
height: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
132
|
+
cornerRadius: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
133
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
134
|
+
type: z.ZodEnum<{
|
|
135
|
+
circle: "circle";
|
|
136
|
+
}>;
|
|
137
|
+
radius: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
138
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
139
|
+
type: z.ZodEnum<{
|
|
140
|
+
ellipse: "ellipse";
|
|
141
|
+
}>;
|
|
142
|
+
radiusX: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
143
|
+
radiusY: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
144
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
145
|
+
type: z.ZodEnum<{
|
|
146
|
+
line: "line";
|
|
147
|
+
}>;
|
|
148
|
+
length: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
149
|
+
thickness: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
150
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
151
|
+
type: z.ZodEnum<{
|
|
152
|
+
polygon: "polygon";
|
|
153
|
+
}>;
|
|
154
|
+
sides: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
155
|
+
radius: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
156
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
157
|
+
type: z.ZodEnum<{
|
|
158
|
+
star: "star";
|
|
159
|
+
}>;
|
|
160
|
+
points: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
161
|
+
outerRadius: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
162
|
+
innerRadius: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
163
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
164
|
+
type: z.ZodEnum<{
|
|
165
|
+
arrow: "arrow";
|
|
166
|
+
}>;
|
|
167
|
+
length: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
168
|
+
headWidth: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
169
|
+
headLength: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
170
|
+
shaftWidth: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
171
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
172
|
+
type: z.ZodEnum<{
|
|
173
|
+
heart: "heart";
|
|
174
|
+
}>;
|
|
175
|
+
size: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
176
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
177
|
+
type: z.ZodEnum<{
|
|
178
|
+
cross: "cross";
|
|
179
|
+
}>;
|
|
180
|
+
width: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
181
|
+
height: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
182
|
+
thickness: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
183
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
184
|
+
type: z.ZodEnum<{
|
|
185
|
+
ring: "ring";
|
|
186
|
+
}>;
|
|
187
|
+
outerRadius: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
188
|
+
innerRadius: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
189
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
190
|
+
type: z.ZodEnum<{
|
|
191
|
+
path: "path";
|
|
192
|
+
}>;
|
|
193
|
+
d: z.ZodString;
|
|
194
|
+
}, z.core.$strip>], "type">>;
|
|
195
|
+
fill: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
196
|
+
type: z.ZodEnum<{
|
|
197
|
+
solid: "solid";
|
|
198
|
+
}>;
|
|
199
|
+
color: z.ZodDefault<z.ZodString>;
|
|
200
|
+
opacity: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
201
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
202
|
+
type: z.ZodEnum<{
|
|
203
|
+
linear: "linear";
|
|
204
|
+
}>;
|
|
205
|
+
angle: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
206
|
+
stops: z.ZodArray<z.ZodObject<{
|
|
207
|
+
offset: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
208
|
+
color: z.ZodString;
|
|
209
|
+
}, z.core.$strip>>;
|
|
210
|
+
opacity: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
211
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
212
|
+
type: z.ZodEnum<{
|
|
213
|
+
radial: "radial";
|
|
214
|
+
}>;
|
|
215
|
+
stops: z.ZodArray<z.ZodObject<{
|
|
216
|
+
offset: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>;
|
|
217
|
+
color: z.ZodString;
|
|
218
|
+
}, z.core.$strip>>;
|
|
219
|
+
opacity: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
220
|
+
}, z.core.$strip>], "type">>;
|
|
221
|
+
stroke: z.ZodOptional<z.ZodObject<{
|
|
222
|
+
color: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
223
|
+
width: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
224
|
+
opacity: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
225
|
+
lineCap: z.ZodOptional<z.ZodEnum<{
|
|
226
|
+
butt: "butt";
|
|
227
|
+
round: "round";
|
|
228
|
+
square: "square";
|
|
229
|
+
}>>;
|
|
230
|
+
lineJoin: z.ZodOptional<z.ZodEnum<{
|
|
231
|
+
round: "round";
|
|
232
|
+
miter: "miter";
|
|
233
|
+
bevel: "bevel";
|
|
234
|
+
}>>;
|
|
235
|
+
dashArray: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
236
|
+
dashOffset: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
237
|
+
}, z.core.$strip>>;
|
|
238
|
+
shadow: z.ZodOptional<z.ZodObject<{
|
|
239
|
+
offsetX: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
240
|
+
offsetY: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
241
|
+
blur: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
242
|
+
color: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
243
|
+
opacity: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
244
|
+
}, z.core.$strip>>;
|
|
245
|
+
transform: z.ZodOptional<z.ZodObject<{
|
|
246
|
+
x: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
247
|
+
y: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
248
|
+
rotation: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
249
|
+
scale: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
250
|
+
originX: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
251
|
+
originY: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
252
|
+
}, z.core.$strip>>;
|
|
253
|
+
opacity: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>>;
|
|
254
|
+
width: z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>;
|
|
255
|
+
height: z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedNumber<unknown>>>;
|
|
256
|
+
}, z.core.$strip>;
|
|
257
|
+
type CanvasSvgAsset = z.infer<typeof CanvasSvgAssetSchema>;
|
|
120
258
|
|
|
121
259
|
type ShotstackRichTextAsset = components["schemas"]["RichTextAsset"];
|
|
260
|
+
type ShotstackSvgAsset = components["schemas"]["SvgAsset"];
|
|
122
261
|
type RGBA = {
|
|
123
262
|
r: number;
|
|
124
263
|
g: number;
|
|
@@ -145,6 +284,24 @@ type GradientSpec = {
|
|
|
145
284
|
}[];
|
|
146
285
|
opacity: number;
|
|
147
286
|
};
|
|
287
|
+
type StrokeSpec = {
|
|
288
|
+
width: number;
|
|
289
|
+
color: string;
|
|
290
|
+
opacity: number;
|
|
291
|
+
dashArray?: number[];
|
|
292
|
+
lineCap?: "butt" | "round" | "square";
|
|
293
|
+
lineJoin?: "miter" | "round" | "bevel";
|
|
294
|
+
};
|
|
295
|
+
type Point2D = {
|
|
296
|
+
x: number;
|
|
297
|
+
y: number;
|
|
298
|
+
};
|
|
299
|
+
type BoundingBox = {
|
|
300
|
+
x: number;
|
|
301
|
+
y: number;
|
|
302
|
+
w: number;
|
|
303
|
+
h: number;
|
|
304
|
+
};
|
|
148
305
|
type Glyph = {
|
|
149
306
|
id: number;
|
|
150
307
|
xAdvance: number;
|
|
@@ -156,6 +313,7 @@ type Glyph = {
|
|
|
156
313
|
family: string;
|
|
157
314
|
weight?: string | number;
|
|
158
315
|
};
|
|
316
|
+
isColorEmoji?: boolean;
|
|
159
317
|
};
|
|
160
318
|
type ShapedLine = {
|
|
161
319
|
glyphs: Glyph[];
|
|
@@ -180,12 +338,7 @@ type DrawOp = {
|
|
|
180
338
|
y: number;
|
|
181
339
|
fill: GradientSpec;
|
|
182
340
|
scale?: number;
|
|
183
|
-
gradientBBox?:
|
|
184
|
-
x: number;
|
|
185
|
-
y: number;
|
|
186
|
-
w: number;
|
|
187
|
-
h: number;
|
|
188
|
-
};
|
|
341
|
+
gradientBBox?: BoundingBox;
|
|
189
342
|
isShadow?: boolean;
|
|
190
343
|
} | {
|
|
191
344
|
op: "StrokePath";
|
|
@@ -229,6 +382,54 @@ type DrawOp = {
|
|
|
229
382
|
opacity: number;
|
|
230
383
|
};
|
|
231
384
|
borderRadius?: number;
|
|
385
|
+
} | {
|
|
386
|
+
op: "DrawColorEmoji";
|
|
387
|
+
char: string;
|
|
388
|
+
x: number;
|
|
389
|
+
y: number;
|
|
390
|
+
fontSize: number;
|
|
391
|
+
fontFamily: string;
|
|
392
|
+
} | {
|
|
393
|
+
op: "Ellipse";
|
|
394
|
+
cx: number;
|
|
395
|
+
cy: number;
|
|
396
|
+
rx: number;
|
|
397
|
+
ry: number;
|
|
398
|
+
fill: GradientSpec;
|
|
399
|
+
rotation?: number;
|
|
400
|
+
gradientBBox?: BoundingBox;
|
|
401
|
+
} | {
|
|
402
|
+
op: "EllipseStroke";
|
|
403
|
+
cx: number;
|
|
404
|
+
cy: number;
|
|
405
|
+
rx: number;
|
|
406
|
+
ry: number;
|
|
407
|
+
stroke: StrokeSpec;
|
|
408
|
+
rotation?: number;
|
|
409
|
+
} | {
|
|
410
|
+
op: "Polygon";
|
|
411
|
+
points: Point2D[];
|
|
412
|
+
fill: GradientSpec;
|
|
413
|
+
closed?: boolean;
|
|
414
|
+
gradientBBox?: BoundingBox;
|
|
415
|
+
} | {
|
|
416
|
+
op: "PolygonStroke";
|
|
417
|
+
points: Point2D[];
|
|
418
|
+
stroke: StrokeSpec;
|
|
419
|
+
closed?: boolean;
|
|
420
|
+
} | {
|
|
421
|
+
op: "ShapePath";
|
|
422
|
+
path: string;
|
|
423
|
+
x: number;
|
|
424
|
+
y: number;
|
|
425
|
+
fill: GradientSpec;
|
|
426
|
+
gradientBBox?: BoundingBox;
|
|
427
|
+
} | {
|
|
428
|
+
op: "ShapePathStroke";
|
|
429
|
+
path: string;
|
|
430
|
+
x: number;
|
|
431
|
+
y: number;
|
|
432
|
+
stroke: StrokeSpec;
|
|
232
433
|
};
|
|
233
434
|
type EngineInit = {
|
|
234
435
|
width: number;
|
|
@@ -240,7 +441,7 @@ type Renderer = {
|
|
|
240
441
|
render(ops: DrawOp[]): Promise<void>;
|
|
241
442
|
toPNG?: () => Promise<Buffer>;
|
|
242
443
|
};
|
|
243
|
-
type ValidAsset = CanvasRichTextAsset;
|
|
444
|
+
type ValidAsset = CanvasRichTextAsset | CanvasSvgAsset;
|
|
244
445
|
declare const isShadowFill: (op: DrawOp) => op is Extract<DrawOp, {
|
|
245
446
|
op: "FillPath";
|
|
246
447
|
}> & {
|
|
@@ -252,6 +453,199 @@ declare const isGlyphFill: (op: DrawOp) => op is Extract<DrawOp, {
|
|
|
252
453
|
isShadow?: false;
|
|
253
454
|
};
|
|
254
455
|
|
|
456
|
+
declare function createWebPainter(canvas: HTMLCanvasElement | OffscreenCanvas): {
|
|
457
|
+
render(ops: DrawOp[]): Promise<void>;
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
type ShapeType = "rectangle" | "circle" | "ellipse" | "line" | "triangle" | "polygon" | "star" | "arrow" | "heart" | "cross" | "ring";
|
|
461
|
+
interface RectangleParams {
|
|
462
|
+
width: number;
|
|
463
|
+
height: number;
|
|
464
|
+
cornerRadius?: number;
|
|
465
|
+
}
|
|
466
|
+
interface CircleParams {
|
|
467
|
+
radius: number;
|
|
468
|
+
}
|
|
469
|
+
interface EllipseParams {
|
|
470
|
+
radiusX: number;
|
|
471
|
+
radiusY: number;
|
|
472
|
+
}
|
|
473
|
+
interface LineParams {
|
|
474
|
+
length: number;
|
|
475
|
+
thickness: number;
|
|
476
|
+
}
|
|
477
|
+
interface TriangleParams {
|
|
478
|
+
width: number;
|
|
479
|
+
height: number;
|
|
480
|
+
}
|
|
481
|
+
interface PolygonParams {
|
|
482
|
+
sides: number;
|
|
483
|
+
radius: number;
|
|
484
|
+
}
|
|
485
|
+
interface StarParams {
|
|
486
|
+
points: number;
|
|
487
|
+
outerRadius: number;
|
|
488
|
+
innerRadius: number;
|
|
489
|
+
}
|
|
490
|
+
interface ArrowParams {
|
|
491
|
+
length: number;
|
|
492
|
+
headWidth: number;
|
|
493
|
+
headLength: number;
|
|
494
|
+
shaftWidth: number;
|
|
495
|
+
}
|
|
496
|
+
interface HeartParams {
|
|
497
|
+
size: number;
|
|
498
|
+
}
|
|
499
|
+
interface CrossParams {
|
|
500
|
+
width: number;
|
|
501
|
+
height: number;
|
|
502
|
+
thickness: number;
|
|
503
|
+
}
|
|
504
|
+
interface RingParams {
|
|
505
|
+
outerRadius: number;
|
|
506
|
+
innerRadius: number;
|
|
507
|
+
}
|
|
508
|
+
type ShapeParams = ({
|
|
509
|
+
shape: "rectangle";
|
|
510
|
+
} & RectangleParams) | ({
|
|
511
|
+
shape: "circle";
|
|
512
|
+
} & CircleParams) | ({
|
|
513
|
+
shape: "ellipse";
|
|
514
|
+
} & EllipseParams) | ({
|
|
515
|
+
shape: "line";
|
|
516
|
+
} & LineParams) | ({
|
|
517
|
+
shape: "triangle";
|
|
518
|
+
} & TriangleParams) | ({
|
|
519
|
+
shape: "polygon";
|
|
520
|
+
} & PolygonParams) | ({
|
|
521
|
+
shape: "star";
|
|
522
|
+
} & StarParams) | ({
|
|
523
|
+
shape: "arrow";
|
|
524
|
+
} & ArrowParams) | ({
|
|
525
|
+
shape: "heart";
|
|
526
|
+
} & HeartParams) | ({
|
|
527
|
+
shape: "cross";
|
|
528
|
+
} & CrossParams) | ({
|
|
529
|
+
shape: "ring";
|
|
530
|
+
} & RingParams);
|
|
531
|
+
declare function generateShapePath(params: ShapeParams): string;
|
|
532
|
+
declare function generateRectanglePath(params: RectangleParams): string;
|
|
533
|
+
declare function generateCirclePath(params: CircleParams): string;
|
|
534
|
+
declare function generateEllipsePath(params: EllipseParams): string;
|
|
535
|
+
declare function generateLinePath(params: LineParams): string;
|
|
536
|
+
declare function generateTrianglePath(params: TriangleParams): string;
|
|
537
|
+
declare function generatePolygonPath(params: PolygonParams): string;
|
|
538
|
+
declare function generatePolygonPoints(sides: number, radius: number): Point2D[];
|
|
539
|
+
declare function generateStarPath(params: StarParams): string;
|
|
540
|
+
declare function generateStarPoints(pointCount: number, outerRadius: number, innerRadius: number): Point2D[];
|
|
541
|
+
declare function generateArrowPath(params: ArrowParams): string;
|
|
542
|
+
declare function generateHeartPath(params: HeartParams): string;
|
|
543
|
+
declare function generateCrossPath(params: CrossParams): string;
|
|
544
|
+
declare function generateRingPath(params: RingParams): string;
|
|
545
|
+
declare function pointsToPath(points: Point2D[], closed?: boolean): string;
|
|
546
|
+
declare function reverseWindingOrder(path: string): string;
|
|
547
|
+
declare function computePathBounds(path: string): BoundingBox;
|
|
548
|
+
declare function translatePath(path: string, dx: number, dy: number): string;
|
|
549
|
+
declare function scalePath(path: string, sx: number, sy?: number): string;
|
|
550
|
+
declare function rotatePath(path: string, angleDegrees: number): string;
|
|
551
|
+
declare function centerPath(path: string): string;
|
|
552
|
+
declare function normalizePathToSize(path: string, targetWidth: number, targetHeight: number): string;
|
|
553
|
+
|
|
554
|
+
type PathCommandType = "M" | "m" | "L" | "l" | "H" | "h" | "V" | "v" | "C" | "c" | "S" | "s" | "Q" | "q" | "T" | "t" | "A" | "a" | "Z" | "z";
|
|
555
|
+
interface MoveToCommand {
|
|
556
|
+
type: "M";
|
|
557
|
+
x: number;
|
|
558
|
+
y: number;
|
|
559
|
+
}
|
|
560
|
+
interface LineToCommand {
|
|
561
|
+
type: "L";
|
|
562
|
+
x: number;
|
|
563
|
+
y: number;
|
|
564
|
+
}
|
|
565
|
+
interface CubicBezierCommand {
|
|
566
|
+
type: "C";
|
|
567
|
+
x1: number;
|
|
568
|
+
y1: number;
|
|
569
|
+
x2: number;
|
|
570
|
+
y2: number;
|
|
571
|
+
x: number;
|
|
572
|
+
y: number;
|
|
573
|
+
}
|
|
574
|
+
interface QuadraticBezierCommand {
|
|
575
|
+
type: "Q";
|
|
576
|
+
x1: number;
|
|
577
|
+
y1: number;
|
|
578
|
+
x: number;
|
|
579
|
+
y: number;
|
|
580
|
+
}
|
|
581
|
+
interface ArcCommand {
|
|
582
|
+
type: "A";
|
|
583
|
+
rx: number;
|
|
584
|
+
ry: number;
|
|
585
|
+
xAxisRotation: number;
|
|
586
|
+
largeArcFlag: boolean;
|
|
587
|
+
sweepFlag: boolean;
|
|
588
|
+
x: number;
|
|
589
|
+
y: number;
|
|
590
|
+
}
|
|
591
|
+
interface ClosePathCommand {
|
|
592
|
+
type: "Z";
|
|
593
|
+
}
|
|
594
|
+
type NormalizedPathCommand = MoveToCommand | LineToCommand | CubicBezierCommand | QuadraticBezierCommand | ClosePathCommand;
|
|
595
|
+
type ParsedPathCommand = MoveToCommand | LineToCommand | CubicBezierCommand | QuadraticBezierCommand | ArcCommand | ClosePathCommand;
|
|
596
|
+
declare function parseSvgPath(pathData: string): ParsedPathCommand[];
|
|
597
|
+
declare function normalizePath(commands: ParsedPathCommand[]): NormalizedPathCommand[];
|
|
598
|
+
declare function commandsToPathString(commands: NormalizedPathCommand[]): string;
|
|
599
|
+
declare function normalizePathString(pathData: string): string;
|
|
600
|
+
declare function arcToCubicBeziers(x1: number, y1: number, rx: number, ry: number, phi: number, largeArc: boolean, sweep: boolean, x2: number, y2: number): CubicBezierCommand[] | LineToCommand[];
|
|
601
|
+
declare function quadraticToCubic(x0: number, y0: number, qx: number, qy: number, x: number, y: number): CubicBezierCommand;
|
|
602
|
+
|
|
603
|
+
interface SvgImportResult {
|
|
604
|
+
width: number;
|
|
605
|
+
height: number;
|
|
606
|
+
viewBox?: {
|
|
607
|
+
x: number;
|
|
608
|
+
y: number;
|
|
609
|
+
width: number;
|
|
610
|
+
height: number;
|
|
611
|
+
};
|
|
612
|
+
paths: SvgImportPath[];
|
|
613
|
+
}
|
|
614
|
+
interface SvgImportPath {
|
|
615
|
+
d: string;
|
|
616
|
+
fill?: string;
|
|
617
|
+
fillOpacity?: number;
|
|
618
|
+
stroke?: string;
|
|
619
|
+
strokeWidth?: number;
|
|
620
|
+
strokeOpacity?: number;
|
|
621
|
+
opacity?: number;
|
|
622
|
+
transform?: string;
|
|
623
|
+
}
|
|
624
|
+
interface ParsedSvgAsset {
|
|
625
|
+
type: "svg";
|
|
626
|
+
shape: {
|
|
627
|
+
type: "path";
|
|
628
|
+
d: string;
|
|
629
|
+
};
|
|
630
|
+
fill?: {
|
|
631
|
+
type: "solid";
|
|
632
|
+
color: string;
|
|
633
|
+
opacity?: number;
|
|
634
|
+
};
|
|
635
|
+
stroke?: {
|
|
636
|
+
color: string;
|
|
637
|
+
width: number;
|
|
638
|
+
opacity?: number;
|
|
639
|
+
};
|
|
640
|
+
opacity?: number;
|
|
641
|
+
width?: number;
|
|
642
|
+
height?: number;
|
|
643
|
+
}
|
|
644
|
+
declare function parseSvgMarkup(svgString: string): SvgImportResult;
|
|
645
|
+
declare function svgToAsset(svgString: string): ParsedSvgAsset | ParsedSvgAsset[];
|
|
646
|
+
declare function svgToSingleAsset(svgString: string): ParsedSvgAsset;
|
|
647
|
+
declare function importSvg(svgString: string): ParsedSvgAsset;
|
|
648
|
+
|
|
255
649
|
declare function createTextEngine(opts?: {
|
|
256
650
|
width?: number;
|
|
257
651
|
height?: number;
|
|
@@ -277,4 +671,4 @@ declare function createTextEngine(opts?: {
|
|
|
277
671
|
destroy(): void;
|
|
278
672
|
}>;
|
|
279
673
|
|
|
280
|
-
export { type CanvasRichTextAsset, CanvasRichTextAssetSchema, type DrawOp, type EngineInit, type Glyph, type GradientSpec, type RGBA, type Renderer, type ShapedLine, type ShotstackRichTextAsset, type ValidAsset, createTextEngine, isGlyphFill, isShadowFill };
|
|
674
|
+
export { type ArcCommand, type ArrowParams, type BoundingBox, type CanvasRichTextAsset, CanvasRichTextAssetSchema, type CanvasSvgAsset, CanvasSvgAssetSchema, type CircleParams, type ClosePathCommand, type CrossParams, type CubicBezierCommand, type DrawOp, type EllipseParams, type EngineInit, type Glyph, type GradientSpec, type HeartParams, type LineParams, type LineToCommand, type MoveToCommand, type NormalizedPathCommand, type ParsedPathCommand, type ParsedSvgAsset, type PathCommandType, type Point2D, type PolygonParams, type QuadraticBezierCommand, type RGBA, type RectangleParams, type Renderer, type RingParams, type ShapeParams, type ShapeType, type ShapedLine, type ShotstackRichTextAsset, type ShotstackSvgAsset, type StarParams, type StrokeSpec, type SvgImportPath, type SvgImportResult, type TriangleParams, type ValidAsset, arcToCubicBeziers, centerPath, commandsToPathString, computePathBounds, createTextEngine, createWebPainter, generateArrowPath, generateCirclePath, generateCrossPath, generateEllipsePath, generateHeartPath, generateLinePath, generatePolygonPath, generatePolygonPoints, generateRectanglePath, generateRingPath, generateShapePath, generateStarPath, generateStarPoints, generateTrianglePath, importSvg, isGlyphFill, isShadowFill, normalizePath, normalizePathString, normalizePathToSize, parseSvgMarkup, parseSvgPath, pointsToPath, quadraticToCubic, reverseWindingOrder, rotatePath, scalePath, svgToAsset, svgToSingleAsset, translatePath };
|