@shotstack/shotstack-canvas 1.8.0 → 1.8.2
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 +1344 -18
- package/dist/entry.node.d.cts +405 -14
- package/dist/entry.node.d.ts +405 -14
- package/dist/entry.node.js +1310 -18
- package/dist/entry.web.d.ts +400 -14
- package/dist/entry.web.js +1289 -2
- package/package.json +2 -2
package/dist/entry.node.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;
|
|
@@ -181,12 +338,7 @@ type DrawOp = {
|
|
|
181
338
|
y: number;
|
|
182
339
|
fill: GradientSpec;
|
|
183
340
|
scale?: number;
|
|
184
|
-
gradientBBox?:
|
|
185
|
-
x: number;
|
|
186
|
-
y: number;
|
|
187
|
-
w: number;
|
|
188
|
-
h: number;
|
|
189
|
-
};
|
|
341
|
+
gradientBBox?: BoundingBox;
|
|
190
342
|
isShadow?: boolean;
|
|
191
343
|
} | {
|
|
192
344
|
op: "StrokePath";
|
|
@@ -237,6 +389,47 @@ type DrawOp = {
|
|
|
237
389
|
y: number;
|
|
238
390
|
fontSize: number;
|
|
239
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;
|
|
240
433
|
};
|
|
241
434
|
type EngineInit = {
|
|
242
435
|
width: number;
|
|
@@ -248,7 +441,7 @@ type Renderer = {
|
|
|
248
441
|
render(ops: DrawOp[]): Promise<void>;
|
|
249
442
|
toPNG?: () => Promise<Buffer>;
|
|
250
443
|
};
|
|
251
|
-
type ValidAsset = CanvasRichTextAsset;
|
|
444
|
+
type ValidAsset = CanvasRichTextAsset | CanvasSvgAsset;
|
|
252
445
|
declare const isShadowFill: (op: DrawOp) => op is Extract<DrawOp, {
|
|
253
446
|
op: "FillPath";
|
|
254
447
|
}> & {
|
|
@@ -277,6 +470,204 @@ interface VideoGenerationOptions {
|
|
|
277
470
|
ffmpegPath?: string;
|
|
278
471
|
}
|
|
279
472
|
|
|
473
|
+
declare function createNodePainter(opts: {
|
|
474
|
+
width: number;
|
|
475
|
+
height: number;
|
|
476
|
+
pixelRatio: number;
|
|
477
|
+
}): Promise<{
|
|
478
|
+
render(ops: DrawOp[]): Promise<void>;
|
|
479
|
+
toPNG(): Promise<Buffer>;
|
|
480
|
+
}>;
|
|
481
|
+
|
|
482
|
+
type ShapeType = "rectangle" | "circle" | "ellipse" | "line" | "triangle" | "polygon" | "star" | "arrow" | "heart" | "cross" | "ring";
|
|
483
|
+
interface RectangleParams {
|
|
484
|
+
width: number;
|
|
485
|
+
height: number;
|
|
486
|
+
cornerRadius?: number;
|
|
487
|
+
}
|
|
488
|
+
interface CircleParams {
|
|
489
|
+
radius: number;
|
|
490
|
+
}
|
|
491
|
+
interface EllipseParams {
|
|
492
|
+
radiusX: number;
|
|
493
|
+
radiusY: number;
|
|
494
|
+
}
|
|
495
|
+
interface LineParams {
|
|
496
|
+
length: number;
|
|
497
|
+
thickness: number;
|
|
498
|
+
}
|
|
499
|
+
interface TriangleParams {
|
|
500
|
+
width: number;
|
|
501
|
+
height: number;
|
|
502
|
+
}
|
|
503
|
+
interface PolygonParams {
|
|
504
|
+
sides: number;
|
|
505
|
+
radius: number;
|
|
506
|
+
}
|
|
507
|
+
interface StarParams {
|
|
508
|
+
points: number;
|
|
509
|
+
outerRadius: number;
|
|
510
|
+
innerRadius: number;
|
|
511
|
+
}
|
|
512
|
+
interface ArrowParams {
|
|
513
|
+
length: number;
|
|
514
|
+
headWidth: number;
|
|
515
|
+
headLength: number;
|
|
516
|
+
shaftWidth: number;
|
|
517
|
+
}
|
|
518
|
+
interface HeartParams {
|
|
519
|
+
size: number;
|
|
520
|
+
}
|
|
521
|
+
interface CrossParams {
|
|
522
|
+
width: number;
|
|
523
|
+
height: number;
|
|
524
|
+
thickness: number;
|
|
525
|
+
}
|
|
526
|
+
interface RingParams {
|
|
527
|
+
outerRadius: number;
|
|
528
|
+
innerRadius: number;
|
|
529
|
+
}
|
|
530
|
+
type ShapeParams = ({
|
|
531
|
+
shape: "rectangle";
|
|
532
|
+
} & RectangleParams) | ({
|
|
533
|
+
shape: "circle";
|
|
534
|
+
} & CircleParams) | ({
|
|
535
|
+
shape: "ellipse";
|
|
536
|
+
} & EllipseParams) | ({
|
|
537
|
+
shape: "line";
|
|
538
|
+
} & LineParams) | ({
|
|
539
|
+
shape: "triangle";
|
|
540
|
+
} & TriangleParams) | ({
|
|
541
|
+
shape: "polygon";
|
|
542
|
+
} & PolygonParams) | ({
|
|
543
|
+
shape: "star";
|
|
544
|
+
} & StarParams) | ({
|
|
545
|
+
shape: "arrow";
|
|
546
|
+
} & ArrowParams) | ({
|
|
547
|
+
shape: "heart";
|
|
548
|
+
} & HeartParams) | ({
|
|
549
|
+
shape: "cross";
|
|
550
|
+
} & CrossParams) | ({
|
|
551
|
+
shape: "ring";
|
|
552
|
+
} & RingParams);
|
|
553
|
+
declare function generateShapePath(params: ShapeParams): string;
|
|
554
|
+
declare function generateRectanglePath(params: RectangleParams): string;
|
|
555
|
+
declare function generateCirclePath(params: CircleParams): string;
|
|
556
|
+
declare function generateEllipsePath(params: EllipseParams): string;
|
|
557
|
+
declare function generateLinePath(params: LineParams): string;
|
|
558
|
+
declare function generateTrianglePath(params: TriangleParams): string;
|
|
559
|
+
declare function generatePolygonPath(params: PolygonParams): string;
|
|
560
|
+
declare function generatePolygonPoints(sides: number, radius: number): Point2D[];
|
|
561
|
+
declare function generateStarPath(params: StarParams): string;
|
|
562
|
+
declare function generateStarPoints(pointCount: number, outerRadius: number, innerRadius: number): Point2D[];
|
|
563
|
+
declare function generateArrowPath(params: ArrowParams): string;
|
|
564
|
+
declare function generateHeartPath(params: HeartParams): string;
|
|
565
|
+
declare function generateCrossPath(params: CrossParams): string;
|
|
566
|
+
declare function generateRingPath(params: RingParams): string;
|
|
567
|
+
declare function pointsToPath(points: Point2D[], closed?: boolean): string;
|
|
568
|
+
declare function reverseWindingOrder(path: string): string;
|
|
569
|
+
declare function computePathBounds(path: string): BoundingBox;
|
|
570
|
+
declare function translatePath(path: string, dx: number, dy: number): string;
|
|
571
|
+
declare function scalePath(path: string, sx: number, sy?: number): string;
|
|
572
|
+
declare function rotatePath(path: string, angleDegrees: number): string;
|
|
573
|
+
declare function centerPath(path: string): string;
|
|
574
|
+
declare function normalizePathToSize(path: string, targetWidth: number, targetHeight: number): string;
|
|
575
|
+
|
|
576
|
+
type PathCommandType = "M" | "m" | "L" | "l" | "H" | "h" | "V" | "v" | "C" | "c" | "S" | "s" | "Q" | "q" | "T" | "t" | "A" | "a" | "Z" | "z";
|
|
577
|
+
interface MoveToCommand {
|
|
578
|
+
type: "M";
|
|
579
|
+
x: number;
|
|
580
|
+
y: number;
|
|
581
|
+
}
|
|
582
|
+
interface LineToCommand {
|
|
583
|
+
type: "L";
|
|
584
|
+
x: number;
|
|
585
|
+
y: number;
|
|
586
|
+
}
|
|
587
|
+
interface CubicBezierCommand {
|
|
588
|
+
type: "C";
|
|
589
|
+
x1: number;
|
|
590
|
+
y1: number;
|
|
591
|
+
x2: number;
|
|
592
|
+
y2: number;
|
|
593
|
+
x: number;
|
|
594
|
+
y: number;
|
|
595
|
+
}
|
|
596
|
+
interface QuadraticBezierCommand {
|
|
597
|
+
type: "Q";
|
|
598
|
+
x1: number;
|
|
599
|
+
y1: number;
|
|
600
|
+
x: number;
|
|
601
|
+
y: number;
|
|
602
|
+
}
|
|
603
|
+
interface ArcCommand {
|
|
604
|
+
type: "A";
|
|
605
|
+
rx: number;
|
|
606
|
+
ry: number;
|
|
607
|
+
xAxisRotation: number;
|
|
608
|
+
largeArcFlag: boolean;
|
|
609
|
+
sweepFlag: boolean;
|
|
610
|
+
x: number;
|
|
611
|
+
y: number;
|
|
612
|
+
}
|
|
613
|
+
interface ClosePathCommand {
|
|
614
|
+
type: "Z";
|
|
615
|
+
}
|
|
616
|
+
type NormalizedPathCommand = MoveToCommand | LineToCommand | CubicBezierCommand | QuadraticBezierCommand | ClosePathCommand;
|
|
617
|
+
type ParsedPathCommand = MoveToCommand | LineToCommand | CubicBezierCommand | QuadraticBezierCommand | ArcCommand | ClosePathCommand;
|
|
618
|
+
declare function parseSvgPath(pathData: string): ParsedPathCommand[];
|
|
619
|
+
declare function normalizePath(commands: ParsedPathCommand[]): NormalizedPathCommand[];
|
|
620
|
+
declare function commandsToPathString(commands: NormalizedPathCommand[]): string;
|
|
621
|
+
declare function normalizePathString(pathData: string): string;
|
|
622
|
+
declare function arcToCubicBeziers(x1: number, y1: number, rx: number, ry: number, phi: number, largeArc: boolean, sweep: boolean, x2: number, y2: number): CubicBezierCommand[] | LineToCommand[];
|
|
623
|
+
declare function quadraticToCubic(x0: number, y0: number, qx: number, qy: number, x: number, y: number): CubicBezierCommand;
|
|
624
|
+
|
|
625
|
+
interface SvgImportResult {
|
|
626
|
+
width: number;
|
|
627
|
+
height: number;
|
|
628
|
+
viewBox?: {
|
|
629
|
+
x: number;
|
|
630
|
+
y: number;
|
|
631
|
+
width: number;
|
|
632
|
+
height: number;
|
|
633
|
+
};
|
|
634
|
+
paths: SvgImportPath[];
|
|
635
|
+
}
|
|
636
|
+
interface SvgImportPath {
|
|
637
|
+
d: string;
|
|
638
|
+
fill?: string;
|
|
639
|
+
fillOpacity?: number;
|
|
640
|
+
stroke?: string;
|
|
641
|
+
strokeWidth?: number;
|
|
642
|
+
strokeOpacity?: number;
|
|
643
|
+
opacity?: number;
|
|
644
|
+
transform?: string;
|
|
645
|
+
}
|
|
646
|
+
interface ParsedSvgAsset {
|
|
647
|
+
type: "svg";
|
|
648
|
+
shape: {
|
|
649
|
+
type: "path";
|
|
650
|
+
d: string;
|
|
651
|
+
};
|
|
652
|
+
fill?: {
|
|
653
|
+
type: "solid";
|
|
654
|
+
color: string;
|
|
655
|
+
opacity?: number;
|
|
656
|
+
};
|
|
657
|
+
stroke?: {
|
|
658
|
+
color: string;
|
|
659
|
+
width: number;
|
|
660
|
+
opacity?: number;
|
|
661
|
+
};
|
|
662
|
+
opacity?: number;
|
|
663
|
+
width?: number;
|
|
664
|
+
height?: number;
|
|
665
|
+
}
|
|
666
|
+
declare function parseSvgMarkup(svgString: string): SvgImportResult;
|
|
667
|
+
declare function svgToAsset(svgString: string): ParsedSvgAsset | ParsedSvgAsset[];
|
|
668
|
+
declare function svgToSingleAsset(svgString: string): ParsedSvgAsset;
|
|
669
|
+
declare function importSvg(svgString: string): ParsedSvgAsset;
|
|
670
|
+
|
|
280
671
|
declare function createTextEngine(opts?: {
|
|
281
672
|
width?: number;
|
|
282
673
|
height?: number;
|
|
@@ -308,4 +699,4 @@ declare function createTextEngine(opts?: {
|
|
|
308
699
|
destroy(): void;
|
|
309
700
|
}>;
|
|
310
701
|
|
|
311
|
-
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 };
|
|
702
|
+
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, createNodePainter, createTextEngine, 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 };
|