@splinetool/ui-wasm 1.0.0

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/build/ui.d.ts ADDED
@@ -0,0 +1,4865 @@
1
+ // Minimum TypeScript Version: 4.4
2
+ /// <reference types="@webgpu/types" />
3
+
4
+ export default function CanvasKitInit(opts?: CanvasKitInitOptions): Promise<CanvasKit>;
5
+
6
+ export interface CanvasKitInitOptions {
7
+ /**
8
+ * This callback will be invoked when the CanvasKit loader needs to fetch a file (e.g.
9
+ * the blob of WASM code). The correct url prefix should be applied.
10
+ * @param file - the name of the file that is about to be loaded.
11
+ */
12
+ locateFile(file: string): string;
13
+ }
14
+
15
+ export interface CanvasKit {
16
+ // Helpers
17
+ /**
18
+ * Constructs a Color with the same API as CSS's rgba(), that is
19
+ * Internally, Colors are four unpremultiplied 32-bit floats: r, g, b, a.
20
+ * In order to construct one with more precision or in a wider gamut,
21
+ * use CanvasKit.Color4f().
22
+ *
23
+ * @param r - red value, clamped to [0, 255].
24
+ * @param g - green value, clamped to [0, 255].
25
+ * @param b - blue value, clamped to [0, 255].
26
+ * @param a - alpha value, from 0 to 1.0. By default is 1.0 (opaque).
27
+ */
28
+ Color(r: number, g: number, b: number, a?: number): Color;
29
+
30
+ /**
31
+ * Construct a 4-float color. Float values are typically between 0.0 and 1.0.
32
+ * @param r - red value.
33
+ * @param g - green value.
34
+ * @param b - blue value.
35
+ * @param a - alpha value. By default is 1.0 (opaque).
36
+ */
37
+ Color4f(r: number, g: number, b: number, a?: number): Color;
38
+
39
+ /**
40
+ * Constructs a Color as a 32 bit unsigned integer, with 8 bits assigned to each channel.
41
+ * Channels are expected to be between 0 and 255 and will be clamped as such.
42
+ * If a is omitted, it will be 255 (opaque).
43
+ *
44
+ * This is not the preferred way to use colors in Skia APIs, use Color or Color4f.
45
+ * @param r - red value, clamped to [0, 255].
46
+ * @param g - green value, clamped to [0, 255].
47
+ * @param b - blue value, clamped to [0, 255].
48
+ * @param a - alpha value, from 0 to 1.0. By default is 1.0 (opaque).
49
+ */
50
+ ColorAsInt(r: number, g: number, b: number, a?: number): ColorInt;
51
+
52
+ /**
53
+ * Returns a css style [r, g, b, a] where r, g, b are returned as
54
+ * ints in the range [0, 255] and where a is scaled between 0 and 1.0.
55
+ * [Deprecated] - this is trivial now that Color is 4 floats.
56
+ */
57
+ getColorComponents(c: Color): number[];
58
+
59
+ /**
60
+ * Takes in a CSS color value and returns a CanvasKit.Color
61
+ * (which is an array of 4 floats in RGBA order). An optional colorMap
62
+ * may be provided which maps custom strings to values.
63
+ * In the CanvasKit canvas2d shim layer, we provide this map for processing
64
+ * canvas2d calls, but not here for code size reasons.
65
+ */
66
+ parseColorString(color: string, colorMap?: Record<string, Color>): Color;
67
+
68
+ /**
69
+ * Returns a copy of the passed in color with a new alpha value applied.
70
+ * [Deprecated] - this is trivial now that Color is 4 floats.
71
+ */
72
+ multiplyByAlpha(c: Color, alpha: number): Color;
73
+
74
+ /**
75
+ * Computes color values for one-pass tonal alpha.
76
+ * Note, if malloced colors are passed in, the memory pointed at by the MallocObj
77
+ * will be overwritten with the computed tonal colors (and thus the return val can be
78
+ * ignored).
79
+ * @param colors
80
+ */
81
+ computeTonalColors(colors: TonalColorsInput): TonalColorsOutput;
82
+
83
+ /**
84
+ * Returns a rectangle with the given paramaters. See Rect.h for more.
85
+ * @param left - The x coordinate of the upper-left corner.
86
+ * @param top - The y coordinate of the upper-left corner.
87
+ * @param right - The x coordinate of the lower-right corner.
88
+ * @param bottom - The y coordinate of the lower-right corner.
89
+ */
90
+ LTRBRect(left: number, top: number, right: number, bottom: number): Rect;
91
+
92
+ /**
93
+ * Returns a rectangle with the given paramaters. See Rect.h for more.
94
+ * @param x - The x coordinate of the upper-left corner.
95
+ * @param y - The y coordinate of the upper-left corner.
96
+ * @param width - The width of the rectangle.
97
+ * @param height - The height of the rectangle.
98
+ */
99
+ XYWHRect(x: number, y: number, width: number, height: number): Rect;
100
+
101
+ /**
102
+ * Returns a rectangle with the given integer paramaters. See Rect.h for more.
103
+ * @param left - The x coordinate of the upper-left corner.
104
+ * @param top - The y coordinate of the upper-left corner.
105
+ * @param right - The x coordinate of the lower-right corner.
106
+ * @param bottom - The y coordinate of the lower-right corner.
107
+ */
108
+ LTRBiRect(left: number, top: number, right: number, bottom: number): IRect;
109
+
110
+ /**
111
+ * Returns a rectangle with the given paramaters. See Rect.h for more.
112
+ * @param x - The x coordinate of the upper-left corner.
113
+ * @param y - The y coordinate of the upper-left corner.
114
+ * @param width - The width of the rectangle.
115
+ * @param height - The height of the rectangle.
116
+ */
117
+ XYWHiRect(x: number, y: number, width: number, height: number): IRect;
118
+
119
+ /**
120
+ * Returns a rectangle with rounded corners consisting of the given rectangle and
121
+ * the same radiusX and radiusY for all four corners.
122
+ * @param rect - The base rectangle.
123
+ * @param rx - The radius of the corners in the x direction.
124
+ * @param ry - The radius of the corners in the y direction.
125
+ */
126
+ RRectXY(rect: InputRect, rx: number, ry: number): RRect;
127
+
128
+ /**
129
+ * Generate bounding box for shadows relative to path. Includes both the ambient and spot
130
+ * shadow bounds. This pairs with Canvas.drawShadow().
131
+ * See SkShadowUtils.h for more details.
132
+ * @param ctm - Current transformation matrix to device space.
133
+ * @param path - The occluder used to generate the shadows.
134
+ * @param zPlaneParams - Values for the plane function which returns the Z offset of the
135
+ * occluder from the canvas based on local x and y values (the current
136
+ * matrix is not applied).
137
+ * @param lightPos - The 3D position of the light relative to the canvas plane. This is
138
+ * independent of the canvas's current matrix.
139
+ * @param lightRadius - The radius of the disc light.
140
+ * @param flags - See SkShadowUtils.h; 0 means use default options.
141
+ * @param dstRect - if provided, the bounds will be copied into this rect instead of allocating
142
+ * a new one.
143
+ * @returns The bounding rectangle or null if it could not be computed.
144
+ */
145
+ getShadowLocalBounds(ctm: InputMatrix, path: Path, zPlaneParams: InputVector3,
146
+ lightPos: InputVector3, lightRadius: number, flags: number,
147
+ dstRect?: Rect): Rect | null;
148
+
149
+ /**
150
+ * Malloc returns a TypedArray backed by the C++ memory of the
151
+ * given length. It should only be used by advanced users who
152
+ * can manage memory and initialize values properly. When used
153
+ * correctly, it can save copying of data between JS and C++.
154
+ * When used incorrectly, it can lead to memory leaks.
155
+ * Any memory allocated by CanvasKit.Malloc needs to be released with CanvasKit.Free.
156
+ *
157
+ * const mObj = CanvasKit.Malloc(Float32Array, 20);
158
+ * Get a TypedArray view around the malloc'd memory (this does not copy anything).
159
+ * const ta = mObj.toTypedArray();
160
+ * // store data into ta
161
+ * const cf = CanvasKit.ColorFilter.MakeMatrix(ta); // mObj could also be used.
162
+ *
163
+ * // eventually...
164
+ * CanvasKit.Free(mObj);
165
+ *
166
+ * @param typedArray - constructor for the typedArray.
167
+ * @param len - number of *elements* to store.
168
+ */
169
+ Malloc(typedArray: TypedArrayConstructor, len: number): MallocObj;
170
+
171
+ /**
172
+ * As Malloc but for GlyphIDs. This helper exists to make sure the JS side and the C++ side
173
+ * stay in agreement with how wide GlyphIDs are.
174
+ * @param len - number of GlyphIDs to make space for.
175
+ */
176
+ MallocGlyphIDs(len: number): MallocObj;
177
+
178
+ /**
179
+ * Free frees the memory returned by Malloc.
180
+ * Any memory allocated by CanvasKit.Malloc needs to be released with CanvasKit.Free.
181
+ */
182
+ Free(m: MallocObj): void;
183
+
184
+ // Surface related functions
185
+ /**
186
+ * Creates a Surface on a given canvas. If both GPU and CPU modes have been compiled in, this
187
+ * will first try to create a GPU surface and then fallback to a CPU one if that fails. If just
188
+ * the CPU mode has been compiled in, a CPU surface will be created.
189
+ * @param canvas - either the canvas element itself or a string with the DOM id of it.
190
+ * @deprecated - Use MakeSWCanvasSurface, MakeWebGLCanvasSurface, or MakeGPUCanvasSurface.
191
+ */
192
+ MakeCanvasSurface(canvas: HTMLCanvasElement | string): Surface | null;
193
+
194
+ /**
195
+ * Creates a Raster (CPU) Surface that will draw into the provided Malloc'd buffer. This allows
196
+ * clients to efficiently be able to read the current pixels w/o having to copy.
197
+ * The length of pixels must be at least height * bytesPerRow bytes big.
198
+ * @param ii
199
+ * @param pixels
200
+ * @param bytesPerRow - How many bytes are per row. This is at least width * bytesPerColorType. For example,
201
+ * an 8888 ColorType has 4 bytes per pixel, so a 5 pixel wide 8888 surface needs at least
202
+ * 5 * 4 = 20 bytesPerRow. Some clients may have more than the usual to make the data line
203
+ * up with a particular multiple.
204
+ */
205
+ MakeRasterDirectSurface(ii: ImageInfo, pixels: MallocObj, bytesPerRow: number): Surface | null;
206
+
207
+ /**
208
+ * Creates a CPU backed (aka raster) surface.
209
+ * @param canvas - either the canvas element itself or a string with the DOM id of it.
210
+ */
211
+ MakeSWCanvasSurface(canvas: HTMLCanvasElement | string): Surface | null;
212
+
213
+ /**
214
+ * A helper for creating a WebGL backed (aka GPU) surface and falling back to a CPU surface if
215
+ * the GPU one cannot be created. This works for both WebGL 1 and WebGL 2.
216
+ * @param canvas - Either the canvas element itself or a string with the DOM id of it.
217
+ * @param colorSpace - One of the supported color spaces. Default is SRGB.
218
+ * @param opts - Options that will get passed to the creation of the WebGL context.
219
+ */
220
+ MakeWebGLCanvasSurface(canvas: HTMLCanvasElement | string, colorSpace?: ColorSpace,
221
+ opts?: WebGLOptions): Surface | null;
222
+
223
+ /**
224
+ * Returns a CPU backed surface with the given dimensions, an SRGB colorspace, Unpremul
225
+ * alphaType and 8888 color type. The pixels belonging to this surface will be in memory and
226
+ * not visible.
227
+ * @param width - number of pixels of the width of the drawable area.
228
+ * @param height - number of pixels of the height of the drawable area.
229
+ */
230
+ MakeSurface(width: number, height: number): Surface | null;
231
+
232
+ /**
233
+ * Creates a WebGL Context from the given canvas with the given options. If options are omitted,
234
+ * sensible defaults will be used.
235
+ * @param canvas
236
+ * @param opts
237
+ */
238
+ GetWebGLContext(canvas: HTMLCanvasElement, opts?: WebGLOptions): WebGLContextHandle;
239
+
240
+ /**
241
+ * Creates a GrDirectContext from the given WebGL Context.
242
+ * @param ctx
243
+ * @deprecated Use MakeWebGLContext instead.
244
+ */
245
+ MakeGrContext(ctx: WebGLContextHandle): GrDirectContext | null;
246
+
247
+ /**
248
+ * Creates a GrDirectContext from the given WebGL Context.
249
+ * @param ctx
250
+ */
251
+ MakeWebGLContext(ctx: WebGLContextHandle): GrDirectContext | null;
252
+
253
+ /**
254
+ * Creates a Surface that will be drawn to the given GrDirectContext (and show up on screen).
255
+ * @param ctx
256
+ * @param width - number of pixels of the width of the visible area.
257
+ * @param height - number of pixels of the height of the visible area.
258
+ * @param colorSpace
259
+ * @param sampleCount - sample count value from GL_SAMPLES. If not provided this will be looked up from
260
+ * the canvas.
261
+ * @param stencil - stencil count value from GL_STENCIL_BITS. If not provided this will be looked up
262
+ * from the WebGL Context.
263
+ */
264
+ MakeOnScreenGLSurface(ctx: GrDirectContext, width: number, height: number,
265
+ colorSpace: ColorSpace, sampleCount?: number, stencil?: number): Surface | null;
266
+
267
+ /**
268
+ * Creates a context that operates over the given WebGPU Device.
269
+ * @param device
270
+ */
271
+ MakeGPUDeviceContext(device: GPUDevice): WebGPUDeviceContext | null;
272
+
273
+ /**
274
+ * Creates a Surface that draws to the given GPU texture.
275
+ * @param ctx
276
+ * @param texture - A texture that was created on the GPU device associated with `ctx`.
277
+ * @param width - Width of the visible region in pixels.
278
+ * @param height - Height of the visible region in pixels.
279
+ * @param colorSpace
280
+ */
281
+ MakeGPUTextureSurface(ctx: WebGPUDeviceContext, texture: GPUTexture, width: number, height: number,
282
+ colorSpace: ColorSpace): Surface | null;
283
+
284
+ /**
285
+ * Creates and configures a WebGPU context for the given canvas.
286
+ * @param ctx
287
+ * @param canvas
288
+ * @param opts
289
+ */
290
+ MakeGPUCanvasContext(ctx: WebGPUDeviceContext, canvas: HTMLCanvasElement,
291
+ opts?: WebGPUCanvasOptions): WebGPUCanvasContext | null;
292
+
293
+ /**
294
+ * Creates a Surface backed by the next available texture in the swapchain associated with the
295
+ * given WebGPU canvas context. The context must have been already successfully configured using
296
+ * the same GPUDevice associated with `ctx`.
297
+ * @param canvasContext - WebGPU context associated with the canvas. The canvas can either be an
298
+ * on-screen HTMLCanvasElement or an OffscreenCanvas.
299
+ * @param colorSpace
300
+ * @param width - width of the visible region. If not present, the canvas width from `canvasContext`
301
+ * is used.
302
+ * @param height - height of the visible region. If not present, the canvas width from `canvasContext`
303
+ * is used.
304
+ */
305
+ MakeGPUCanvasSurface(canvasContext: WebGPUCanvasContext, colorSpace: ColorSpace,
306
+ width?: number, height?: number): Surface | null;
307
+
308
+ /**
309
+ * Returns a (non-visible) Surface on the GPU. It has the given dimensions and uses 8888
310
+ * color depth and premultiplied alpha. See Surface.h for more details.
311
+ * @param ctx
312
+ * @param width
313
+ * @param height
314
+ */
315
+ MakeRenderTarget(ctx: GrDirectContext, width: number, height: number): Surface | null;
316
+
317
+ /**
318
+ * Returns a (non-visible) Surface on the GPU. It has the settings provided by image info.
319
+ * See Surface.h for more details.
320
+ * @param ctx
321
+ * @param info
322
+ */
323
+ MakeRenderTarget(ctx: GrDirectContext, info: ImageInfo): Surface | null;
324
+
325
+ /**
326
+ * Returns a texture-backed image based on the content in src. It assumes the image is
327
+ * RGBA_8888, unpremul and SRGB. This image can be re-used across multiple surfaces.
328
+ *
329
+ * Not available for software-backed surfaces.
330
+ * @param src - CanvasKit will take ownership of the TextureSource and clean it up when
331
+ * the image is destroyed.
332
+ * @param info - If provided, will be used to determine the width/height/format of the
333
+ * source image. If not, sensible defaults will be used.
334
+ * @param srcIsPremul - set to true if the src data has premultiplied alpha. Otherwise, it will
335
+ * be assumed to be Unpremultiplied. Note: if this is true and info specifies
336
+ * Unpremul, Skia will not convert the src pixels first.
337
+ */
338
+ MakeLazyImageFromTextureSource(src: TextureSource, info?: ImageInfo | PartialImageInfo,
339
+ srcIsPremul?: boolean): Image;
340
+
341
+ /**
342
+ * Deletes the associated WebGLContext. Function not available on the CPU version.
343
+ * @param ctx
344
+ */
345
+ deleteContext(ctx: WebGLContextHandle): void;
346
+
347
+ /**
348
+ * Returns the max size of the global cache for bitmaps used by CanvasKit.
349
+ */
350
+ getDecodeCacheLimitBytes(): number;
351
+ /**
352
+ * Returns the current size of the global cache for bitmaps used by CanvasKit.
353
+ */
354
+ getDecodeCacheUsedBytes(): number;
355
+
356
+ /**
357
+ * Sets the max size of the global cache for bitmaps used by CanvasKit.
358
+ * @param size - number of bytes that can be used to cache bitmaps.
359
+ */
360
+ setDecodeCacheLimitBytes(size: number): void;
361
+
362
+ /**
363
+ * Decodes the given bytes into an animated image. Returns null if the bytes were invalid.
364
+ * The passed in bytes will be copied into the WASM heap, so the caller can dispose of them.
365
+ *
366
+ * The returned AnimatedImage will be "pointing to" the first frame, i.e. currentFrameDuration
367
+ * and makeImageAtCurrentFrame will be referring to the first frame.
368
+ * @param bytes
369
+ */
370
+ MakeAnimatedImageFromEncoded(bytes: Uint8Array | ArrayBuffer): AnimatedImage | null;
371
+
372
+ /**
373
+ * Returns an emulated Canvas2D of the given size.
374
+ * @param width
375
+ * @param height
376
+ */
377
+ MakeCanvas(width: number, height: number): EmulatedCanvas2D;
378
+
379
+ /**
380
+ * Returns an image with the given pixel data and format.
381
+ * Note that we will always make a copy of the pixel data, because of inconsistencies in
382
+ * behavior between GPU and CPU (i.e. the pixel data will be turned into a GPU texture and
383
+ * not modifiable after creation).
384
+ *
385
+ * @param info
386
+ * @param bytes - bytes representing the pixel data.
387
+ * @param bytesPerRow
388
+ */
389
+ MakeImage(info: ImageInfo, bytes: number[] | Uint8Array | Uint8ClampedArray,
390
+ bytesPerRow: number): Image | null;
391
+
392
+ /**
393
+ * Return an Image backed by the encoded data, but attempt to defer decoding until the image
394
+ * is actually used/drawn. This deferral allows the system to cache the result, either on the
395
+ * CPU or on the GPU, depending on where the image is drawn.
396
+ * This decoding uses the codecs that have been compiled into CanvasKit. If the bytes are
397
+ * invalid (or an unrecognized codec), null will be returned. See Image.h for more details.
398
+ * @param bytes
399
+ */
400
+ MakeImageFromEncoded(bytes: Uint8Array | ArrayBuffer): Image | null;
401
+
402
+ /**
403
+ * Returns an Image with the data from the provided CanvasImageSource (e.g. <img>). This will
404
+ * use the browser's built in codecs, in that src will be drawn to a canvas and then readback
405
+ * and placed into an Image.
406
+ * @param src
407
+ */
408
+ MakeImageFromCanvasImageSource(src: CanvasImageSource): Image;
409
+
410
+ /**
411
+ * Returns an SkPicture which has been serialized previously to the given bytes.
412
+ * @param bytes
413
+ */
414
+ MakePicture(bytes: Uint8Array | ArrayBuffer): SkPicture | null;
415
+
416
+ /**
417
+ * Returns an Vertices based on the given positions and optional parameters.
418
+ * See SkVertices.h (especially the Builder) for more details.
419
+ * @param mode
420
+ * @param positions
421
+ * @param textureCoordinates
422
+ * @param colors - either a list of int colors or a flattened color array.
423
+ * @param indices
424
+ * @param isVolatile
425
+ */
426
+ MakeVertices(mode: VertexMode, positions: InputFlattenedPointArray,
427
+ textureCoordinates?: InputFlattenedPointArray | null,
428
+ colors?: Float32Array | ColorIntArray | null, indices?: number[] | null,
429
+ isVolatile?: boolean): Vertices;
430
+
431
+ /**
432
+ * Returns a Skottie animation built from the provided json string.
433
+ * Requires that Skottie be compiled into CanvasKit.
434
+ * @param json
435
+ */
436
+ MakeAnimation(json: string): SkottieAnimation;
437
+
438
+ /**
439
+ * Returns a managed Skottie animation built from the provided json string and assets.
440
+ * Requires that Skottie be compiled into CanvasKit.
441
+ * @param json
442
+ * @param assets - a dictionary of named blobs: { key: ArrayBuffer, ... }
443
+ * @param filterPrefix - an optional string acting as a name filter for selecting "interesting"
444
+ * Lottie properties (surfaced in the embedded player controls)
445
+ * @param soundMap - an optional mapping of sound identifiers (strings) to AudioPlayers.
446
+ * Only needed if the animation supports sound.
447
+ */
448
+ MakeManagedAnimation(json: string, assets?: Record<string, ArrayBuffer>,
449
+ filterPrefix?: string, soundMap?: SoundMap): ManagedSkottieAnimation;
450
+
451
+ // Constructors, i.e. things made with `new CanvasKit.Foo()`;
452
+ readonly ImageData: ImageDataConstructor;
453
+ readonly ParagraphStyle: ParagraphStyleConstructor;
454
+ readonly ContourMeasureIter: ContourMeasureIterConstructor;
455
+ readonly Font: FontConstructor;
456
+ readonly Paint: DefaultConstructor<Paint>;
457
+ readonly Path: PathConstructorAndFactory;
458
+ readonly PictureRecorder: DefaultConstructor<PictureRecorder>;
459
+ readonly TextStyle: TextStyleConstructor;
460
+ readonly SlottableTextProperty: SlottableTextPropertyConstructor;
461
+
462
+ // Factories, i.e. things made with CanvasKit.Foo.MakeTurboEncabulator()
463
+ readonly ParagraphBuilder: ParagraphBuilderFactory;
464
+ readonly Blender: BlenderFactory;
465
+ readonly ColorFilter: ColorFilterFactory;
466
+ readonly FontCollection: FontCollectionFactory;
467
+ readonly FontMgr: FontMgrFactory;
468
+ readonly ImageFilter: ImageFilterFactory;
469
+ readonly MaskFilter: MaskFilterFactory;
470
+ readonly PathEffect: PathEffectFactory;
471
+ readonly RuntimeEffect: RuntimeEffectFactory;
472
+ readonly Shader: ShaderFactory;
473
+ readonly TextBlob: TextBlobFactory;
474
+ readonly Typeface: TypefaceFactory;
475
+ readonly TypefaceFontProvider: TypefaceFontProviderFactory;
476
+
477
+ // Misc
478
+ readonly ColorMatrix: ColorMatrixHelpers;
479
+ readonly Matrix: Matrix3x3Helpers;
480
+ readonly M44: Matrix4x4Helpers;
481
+ readonly Vector: VectorHelpers;
482
+
483
+ // Core Enums
484
+ readonly AlphaType: AlphaTypeEnumValues;
485
+ readonly BlendMode: BlendModeEnumValues;
486
+ readonly BlurStyle: BlurStyleEnumValues;
487
+ readonly ClipOp: ClipOpEnumValues;
488
+ readonly ColorChannel: ColorChannelEnumValues;
489
+ readonly ColorType: ColorTypeEnumValues;
490
+ readonly FillType: FillTypeEnumValues;
491
+ readonly FilterMode: FilterModeEnumValues;
492
+ readonly FontEdging: FontEdgingEnumValues;
493
+ readonly FontHinting: FontHintingEnumValues;
494
+ readonly GlyphRunFlags: GlyphRunFlagValues;
495
+ readonly ImageFormat: ImageFormatEnumValues;
496
+ readonly MipmapMode: MipmapModeEnumValues;
497
+ readonly PaintStyle: PaintStyleEnumValues;
498
+ readonly Path1DEffect: Path1DEffectStyleEnumValues;
499
+ readonly PathOp: PathOpEnumValues;
500
+ readonly PointMode: PointModeEnumValues;
501
+ readonly ColorSpace: ColorSpaceEnumValues;
502
+ readonly StrokeCap: StrokeCapEnumValues;
503
+ readonly StrokeJoin: StrokeJoinEnumValues;
504
+ readonly TileMode: TileModeEnumValues;
505
+ readonly VertexMode: VertexModeEnumValues;
506
+ readonly InputState: InputStateEnumValues;
507
+ readonly ModifierKey: ModifierKeyEnumValues;
508
+
509
+ // Core Constants
510
+ readonly TRANSPARENT: Color;
511
+ readonly BLACK: Color;
512
+ readonly WHITE: Color;
513
+ readonly RED: Color;
514
+ readonly GREEN: Color;
515
+ readonly BLUE: Color;
516
+ readonly YELLOW: Color;
517
+ readonly CYAN: Color;
518
+ readonly MAGENTA: Color;
519
+
520
+ readonly MOVE_VERB: number;
521
+ readonly LINE_VERB: number;
522
+ readonly QUAD_VERB: number;
523
+ readonly CONIC_VERB: number;
524
+ readonly CUBIC_VERB: number;
525
+ readonly CLOSE_VERB: number;
526
+
527
+ readonly SaveLayerInitWithPrevious: SaveLayerFlag;
528
+ readonly SaveLayerF16ColorType: SaveLayerFlag;
529
+
530
+ /**
531
+ * Use this shadow flag to indicate the occluding object is not opaque. Knowing that the
532
+ * occluder is opaque allows us to cull shadow geometry behind it and improve performance.
533
+ */
534
+ readonly ShadowTransparentOccluder: number;
535
+ /**
536
+ * Use this shadow flag to not use analytic shadows.
537
+ */
538
+ readonly ShadowGeometricOnly: number;
539
+ /**
540
+ * Use this shadow flag to indicate the light position represents a direction and light radius
541
+ * is blur radius at elevation 1.
542
+ */
543
+ readonly ShadowDirectionalLight: number;
544
+
545
+ readonly gpu?: boolean; // true if GPU code was compiled in
546
+ readonly managed_skottie?: boolean; // true if advanced (managed) Skottie code was compiled in
547
+ readonly rt_effect?: boolean; // true if RuntimeEffect was compiled in
548
+ readonly skottie?: boolean; // true if base Skottie code was compiled in
549
+
550
+ // Paragraph Enums
551
+ readonly Affinity: AffinityEnumValues;
552
+ readonly DecorationStyle: DecorationStyleEnumValues;
553
+ readonly FontSlant: FontSlantEnumValues;
554
+ readonly FontWeight: FontWeightEnumValues;
555
+ readonly FontWidth: FontWidthEnumValues;
556
+ readonly PlaceholderAlignment: PlaceholderAlignmentEnumValues;
557
+ readonly RectHeightStyle: RectHeightStyleEnumValues;
558
+ readonly RectWidthStyle: RectWidthStyleEnumValues;
559
+ readonly TextAlign: TextAlignEnumValues;
560
+ readonly TextBaseline: TextBaselineEnumValues;
561
+ readonly TextDirection: TextDirectionEnumValues;
562
+ readonly TextHeightBehavior: TextHeightBehaviorEnumValues;
563
+
564
+ // other enums
565
+ readonly VerticalTextAlign: VerticalTextAlignEnumValues;
566
+ readonly ResizePolicy: ResizePolicyEnumValues;
567
+
568
+ // Paragraph Constants
569
+ readonly NoDecoration: number;
570
+ readonly UnderlineDecoration: number;
571
+ readonly OverlineDecoration: number;
572
+ readonly LineThroughDecoration: number;
573
+ }
574
+
575
+ export interface Camera {
576
+ /** a 3d point locating the camera. */
577
+ eye: Vector3;
578
+ /** center of attention - the 3d point the camera is looking at. */
579
+ coa: Vector3;
580
+ /**
581
+ * A unit vector pointing the cameras up direction. Note that using only eye and coa
582
+ * would leave the roll of the camera unspecified.
583
+ */
584
+ up: Vector3;
585
+ /** near clipping plane distance */
586
+ near: number;
587
+ /** far clipping plane distance */
588
+ far: number;
589
+ /** field of view in radians */
590
+ angle: AngleInRadians;
591
+ }
592
+
593
+ /**
594
+ * CanvasKit is built with Emscripten and Embind. Embind adds the following methods to all objects
595
+ * that are exposed with it.
596
+ * This _type field is necessary for the TypeScript compiler to differentiate
597
+ * between opaque types such as Shader and ColorFilter. It doesn't exist at runtime.
598
+ */
599
+ export interface EmbindObject<T extends string> {
600
+ _type: T;
601
+ delete(): void;
602
+ deleteLater(): void;
603
+ isAliasOf(other: any): boolean;
604
+ isDeleted(): boolean;
605
+ }
606
+
607
+ /**
608
+ * Represents the set of enum values.
609
+ */
610
+ export interface EmbindEnum {
611
+ readonly values: number[];
612
+ }
613
+
614
+ /**
615
+ * Represents a single member of an enum.
616
+ */
617
+ export interface EmbindEnumEntity {
618
+ readonly value: number;
619
+ }
620
+
621
+ export interface EmulatedCanvas2D {
622
+ /**
623
+ * Cleans up all resources associated with this emulated canvas.
624
+ */
625
+ dispose(): void;
626
+ /**
627
+ * Decodes an image with the given bytes.
628
+ * @param bytes
629
+ */
630
+ decodeImage(bytes: ArrayBuffer | Uint8Array): Image;
631
+
632
+ /**
633
+ * Returns an emulated canvas2d context if type == '2d', null otherwise.
634
+ * @param type
635
+ */
636
+ getContext(type: string): EmulatedCanvas2DContext | null;
637
+
638
+ /**
639
+ * Loads the given font with the given descriptors. Emulates new FontFace().
640
+ * @param bytes
641
+ * @param descriptors
642
+ */
643
+ loadFont(bytes: ArrayBuffer | Uint8Array, descriptors: Record<string, string>): void;
644
+
645
+ /**
646
+ * Returns an new emulated Path2D object.
647
+ * @param str - an SVG string representing a path.
648
+ */
649
+ makePath2D(str?: string): EmulatedPath2D;
650
+
651
+ /**
652
+ * Returns the current canvas as a base64 encoded image string.
653
+ * @param codec - image/png by default; image/jpeg also supported.
654
+ * @param quality
655
+ */
656
+ toDataURL(codec?: string, quality?: number): string;
657
+ }
658
+
659
+ /** Part of the Canvas2D emulation code */
660
+ export type EmulatedCanvas2DContext = CanvasRenderingContext2D;
661
+ export type EmulatedImageData = ImageData;
662
+ export type EmulatedPath2D = Path2D;
663
+
664
+ export interface FontStyle {
665
+ weight?: FontWeight;
666
+ width?: FontWidth;
667
+ slant?: FontSlant;
668
+ }
669
+
670
+ /**
671
+ * See GrDirectContext.h for more on this class.
672
+ */
673
+ export interface GrDirectContext extends EmbindObject<"GrDirectContext"> {
674
+ getResourceCacheLimitBytes(): number;
675
+ getResourceCacheUsageBytes(): number;
676
+ releaseResourcesAndAbandonContext(): void;
677
+ setResourceCacheLimitBytes(bytes: number): void;
678
+ }
679
+
680
+ /**
681
+ * Represents the context backed by a WebGPU device instance.
682
+ */
683
+ export type WebGPUDeviceContext = GrDirectContext;
684
+
685
+ /**
686
+ * Represents the canvas context and swapchain backed by a WebGPU device.
687
+ */
688
+ export interface WebGPUCanvasContext {
689
+ /**
690
+ * A convenient way to draw multiple frames over the swapchain texture sequence associated with
691
+ * a canvas element. Each call internally constructs a new Surface that targets the current
692
+ * GPUTexture in swapchain.
693
+ *
694
+ * This requires an environment where a global function called requestAnimationFrame is
695
+ * available (e.g. on the web, not on Node). The internally created surface is flushed and
696
+ * destroyed automatically by this wrapper once the `drawFrame` callback returns.
697
+ *
698
+ * Users can call canvasContext.requestAnimationFrame in the callback function to
699
+ * draw multiple frames, e.g. of an animation.
700
+ */
701
+ requestAnimationFrame(drawFrame: (_: Canvas) => void): void;
702
+ }
703
+
704
+ /**
705
+ * The glyph and grapheme cluster information associated with a code point within
706
+ * a paragraph.
707
+ */
708
+ export interface GlyphInfo {
709
+ /**
710
+ * The layout bounds of the grapheme cluster the code point belongs to, in
711
+ * the paragraph's coordinates.
712
+ *
713
+ * This width of the rect is horizontal advance of the grapheme cluster,
714
+ * the height of the rect is the line height when the grapheme cluster
715
+ * occupies a full line.
716
+ */
717
+ graphemeLayoutBounds: Rect;
718
+ /**
719
+ * The left-closed-right-open UTF-16 range of the grapheme cluster the code
720
+ * point belongs to.
721
+ */
722
+ graphemeClusterTextRange: URange;
723
+ /** The writing direction of the grapheme cluster. */
724
+ dir: TextDirection;
725
+ /**
726
+ * Whether the associated glyph points to an ellipsis added by the text
727
+ * layout library.
728
+ *
729
+ * The text layout library truncates the lines that exceed the specified
730
+ * max line number, and may add an ellipsis to replace the last few code
731
+ * points near the logical end of the last visible line. If True, this object
732
+ * marks the logical end of the list of GlyphInfo objects that are
733
+ * retrievable from the text layout library.
734
+ */
735
+ isEllipsis: boolean;
736
+ }
737
+
738
+ /**
739
+ * See Metrics.h for more on this struct.
740
+ */
741
+ export interface LineMetrics {
742
+ /** The index in the text buffer the line begins. */
743
+ startIndex: number;
744
+ /** The index in the text buffer the line ends. */
745
+ endIndex: number;
746
+ endExcludingWhitespaces: number;
747
+ endIncludingNewline: number;
748
+ /** True if the line ends in a hard break (e.g. newline) */
749
+ isHardBreak: boolean;
750
+ /**
751
+ * The final computed ascent for the line. This can be impacted by
752
+ * the strut, height, scaling, as well as outlying runs that are very tall.
753
+ */
754
+ ascent: number;
755
+ /**
756
+ * The final computed descent for the line. This can be impacted by
757
+ * the strut, height, scaling, as well as outlying runs that are very tall.
758
+ */
759
+ descent: number;
760
+ /** round(ascent + descent) */
761
+ height: number;
762
+ /** width of the line */
763
+ width: number;
764
+ /** The left edge of the line. The right edge can be obtained with `left + width` */
765
+ left: number;
766
+ /** The y position of the baseline for this line from the top of the paragraph. */
767
+ baseline: number;
768
+ /** Zero indexed line number. */
769
+ lineNumber: number;
770
+ }
771
+
772
+ export interface Range {
773
+ first: number;
774
+ last: number;
775
+ }
776
+
777
+ /**
778
+ * Information for a run of shaped text. See Paragraph.getShapedLines()
779
+ *
780
+ * Notes:
781
+ * positions is documented as Float32, but it holds twice as many as you expect, and they
782
+ * are treated logically as pairs of floats: {x0, y0}, {x1, y1}, ... for each glyph.
783
+ *
784
+ * positions and offsets arrays have 1 extra slot (actually 2 for positions)
785
+ * to describe the location "after" the last glyph in the glyphs array.
786
+ */
787
+ export interface GlyphRun {
788
+ typeface: Typeface; // currently set to null (temporary)
789
+ size: number;
790
+ fakeBold: boolean;
791
+ fakeItalic: boolean;
792
+
793
+ glyphs: Uint16Array;
794
+ positions: Float32Array; // alternating x0, y0, x1, y1, ...
795
+ offsets: Uint32Array;
796
+ flags: number; // see GlyphRunFlags
797
+ }
798
+
799
+ /**
800
+ * Information for a paragraph of text. See Paragraph.getShapedLines()
801
+ */
802
+ export interface ShapedLine {
803
+ textRange: Range; // first and last character offsets for the line (derived from runs[])
804
+ top: number; // top y-coordinate for the line
805
+ bottom: number; // bottom y-coordinate for the line
806
+ baseline: number; // baseline y-coordinate for the line
807
+ runs: GlyphRun[]; // array of GlyphRun objects for the line
808
+ }
809
+
810
+ /**
811
+ * Input to ShapeText(..., FontBlock[], ...);
812
+ */
813
+ export interface FontBlock {
814
+ length: number; // number of text codepoints this block is applied to
815
+
816
+ typeface: Typeface;
817
+ size: number;
818
+ fakeBold: boolean;
819
+ fakeItalic: boolean;
820
+ }
821
+
822
+ /**
823
+ * This object is a wrapper around a pointer to some memory on the WASM heap. The type of the
824
+ * pointer was determined at creation time.
825
+ */
826
+ export interface MallocObj {
827
+ /**
828
+ * The number of objects this pointer refers to.
829
+ */
830
+ readonly length: number;
831
+ /**
832
+ * The "pointer" into the WASM memory. Should be fixed over the lifetime of the object.
833
+ */
834
+ readonly byteOffset: number;
835
+ /**
836
+ * Return a read/write view into a subset of the memory. Do not cache the TypedArray this
837
+ * returns, it may be invalidated if the WASM heap is resized. This is the same as calling
838
+ * .toTypedArray().subarray() except the returned TypedArray can also be passed into an API
839
+ * and not cause an additional copy.
840
+ */
841
+ subarray(start: number, end: number): TypedArray;
842
+ /**
843
+ * Return a read/write view of the memory. Do not cache the TypedArray this returns, it may be
844
+ * invalidated if the WASM heap is resized. If this TypedArray is passed into a CanvasKit API,
845
+ * it will not be copied again, only the pointer will be re-used.
846
+ */
847
+ toTypedArray(): TypedArray;
848
+ }
849
+
850
+ /**
851
+ * This represents a subset of an animation's duration.
852
+ */
853
+ export interface AnimationMarker {
854
+ name: string;
855
+ t0: number; // 0.0 to 1.0
856
+ t1: number; // 0.0 to 1.0
857
+ }
858
+
859
+ /**
860
+ * This object maintains a single audio layer during skottie playback
861
+ */
862
+ export interface AudioPlayer {
863
+ /**
864
+ * Playback control callback, emitted for each corresponding Animation::seek().
865
+ *
866
+ * Will seek to time t (seconds) relative to the layer's timeline origin.
867
+ * Negative t values are used to signal off state (stop playback outside layer span).
868
+ */
869
+ seek(t: number): void;
870
+ }
871
+
872
+ /**
873
+ * Mapping of sound names (strings) to AudioPlayers
874
+ */
875
+ export interface SoundMap {
876
+ /**
877
+ * Returns AudioPlayer for a certain audio layer
878
+ * @param key string identifier, name of audio file the desired AudioPlayer manages
879
+ */
880
+ getPlayer(key: string): AudioPlayer;
881
+ }
882
+
883
+ /**
884
+ * Named color property.
885
+ */
886
+ export interface ColorProperty {
887
+ /**
888
+ * Property identifier, usually the node name.
889
+ */
890
+ key: string;
891
+ /**
892
+ * Property value (RGBA, 255-based).
893
+ */
894
+ value: ColorInt;
895
+ }
896
+
897
+ /**
898
+ * Named opacity property.
899
+ */
900
+ export interface OpacityProperty {
901
+ /**
902
+ * Property identifier, usually the node name.
903
+ */
904
+ key: string;
905
+ /**
906
+ * Property value (0..100).
907
+ */
908
+ value: number;
909
+ }
910
+
911
+ /**
912
+ * Text property value.
913
+ */
914
+ export interface TextValue {
915
+ /**
916
+ * The text string payload.
917
+ */
918
+ text: string;
919
+ /**
920
+ * Font size.
921
+ */
922
+ size: number;
923
+ }
924
+
925
+ /**
926
+ * Named text property.
927
+ */
928
+ export interface TextProperty {
929
+ /**
930
+ * Property identifier, usually the node name.
931
+ */
932
+ key: string;
933
+ /**
934
+ * Property value.
935
+ */
936
+ value: TextValue;
937
+ }
938
+
939
+ /**
940
+ * Transform property value. Maps to AE styled transform.
941
+ */
942
+ export interface TransformValue {
943
+ /**
944
+ * Anchor point for transform. x and y value.
945
+ */
946
+ anchor: Point;
947
+ /**
948
+ * Position of transform. x and y value.
949
+ */
950
+ position: Point;
951
+ /**
952
+ * Scale of transform. x and y value.
953
+ */
954
+ scale: Vector2;
955
+ /**
956
+ * Rotation of transform in degrees.
957
+ */
958
+ rotation: number;
959
+ /**
960
+ * Skew to apply during transform.
961
+ */
962
+ skew: number;
963
+ /**
964
+ * Direction of skew in degrees.
965
+ */
966
+ skew_axis: number;
967
+ }
968
+
969
+ /**
970
+ * Named transform property for Skottie property observer.
971
+ */
972
+ export interface TransformProperty {
973
+ /**
974
+ * Property identifier, usually the node name.
975
+ */
976
+ key: string;
977
+ /**
978
+ * Property value.
979
+ */
980
+ value: TransformValue;
981
+ }
982
+
983
+ /**
984
+ * Collection of slot IDs sorted by value type
985
+ */
986
+ export interface SlotInfo {
987
+ colorSlotIDs: string[];
988
+ scalarSlotIDs: string[];
989
+ vec2SlotIDs: string[];
990
+ imageSlotIDs: string[];
991
+ textSlotIDs: string[];
992
+ }
993
+
994
+ /**
995
+ * Text property for ManagedAnimation's slot support
996
+ */
997
+ export interface SlottableTextProperty {
998
+ typeface?: Typeface
999
+ text?: string;
1000
+
1001
+ textSize?: number;
1002
+ minTextSize?: number;
1003
+ maxTextSize?: number;
1004
+ strokeWidth?: number;
1005
+ lineHeight?: number;
1006
+ lineShift?: number;
1007
+ ascent?: number;
1008
+ maxLines?: number;
1009
+
1010
+ horizAlign?: TextAlignEnumValues;
1011
+ vertAlign?: VerticalTextAlignEnumValues;
1012
+ strokeJoin?: StrokeJoinEnumValues;
1013
+ direction?: TextDirectionEnumValues;
1014
+ linebreak?: LineBreakTypeEnumValues;
1015
+ resize?: ResizePolicyEnumValues;
1016
+
1017
+ boundingBox?: InputRect;
1018
+ fillColor?: InputColor;
1019
+ strokeColor?: InputColor;
1020
+ }
1021
+
1022
+ export interface ManagedSkottieAnimation extends SkottieAnimation {
1023
+ setColor(key: string, color: InputColor): boolean;
1024
+ setOpacity(key: string, opacity: number): boolean;
1025
+ setText(key: string, text: string, size: number): boolean;
1026
+ setTransform(key: string, anchor: InputPoint, position: InputPoint, scale: InputVector2,
1027
+ rotation: number, skew: number, skew_axis: number): boolean;
1028
+ getMarkers(): AnimationMarker[];
1029
+ getColorProps(): ColorProperty[];
1030
+ getOpacityProps(): OpacityProperty[];
1031
+ getTextProps(): TextProperty[];
1032
+ getTransformProps(): TransformProperty[];
1033
+
1034
+ // Slots in Lottie were exposed with bodymovin version 5.11.0
1035
+ // Properties tracked under the Essential Graphics window in AE will be "slotted". These slots
1036
+ // can be observed and editted live like with the other get/set tools. The slot id passed in
1037
+ // must match the name of the property in the Essential Graphics window. Property Groups support
1038
+ // one-to-many relationships.
1039
+ getSlotInfo() : SlotInfo;
1040
+
1041
+ setColorSlot(key: string, color: InputColor): boolean;
1042
+ setScalarSlot(key: string, scalar: number): boolean;
1043
+ setVec2Slot(key: string, vec2: InputVector2): boolean;
1044
+ setTextSlot(key: string, text: SlottableTextProperty): boolean;
1045
+ setImageSlot(key: string, assetName: string): boolean;
1046
+
1047
+ getColorSlot(key: string): Color | null;
1048
+ getScalarSlot(key: string): number | null;
1049
+ getVec2Slot(key: string): Vector2 | null;
1050
+ getTextSlot(key: string): SlottableTextProperty | null;
1051
+
1052
+ // Attach a WYSIWYG editor to the text layer identified by 'id' and 'index' (multiple layers
1053
+ // can be grouped with the same ID).
1054
+ // Other layers with the same ID are attached as dependents, and updated on the fly as the
1055
+ // edited layer changes.
1056
+ attachEditor(id: string, index: number): boolean;
1057
+
1058
+ // Enable/disable the current editor.
1059
+ enableEditor(enable: boolean): void;
1060
+
1061
+ // Send key events to the active editor.
1062
+ dispatchEditorKey(key: string): boolean;
1063
+
1064
+ // Send pointer events to the active editor, in canvas coordinates.
1065
+ dispatchEditorPointer(x: number, y: number, state: InputState, modifier: ModifierKey): boolean;
1066
+ }
1067
+
1068
+ /**
1069
+ * See Paragraph.h for more information on this class. This is only available if Paragraph has
1070
+ * been compiled in.
1071
+ */
1072
+ export interface Paragraph extends EmbindObject<"Paragraph"> {
1073
+ didExceedMaxLines(): boolean;
1074
+ getAlphabeticBaseline(): number;
1075
+
1076
+ /**
1077
+ * Returns the index of the glyph that corresponds to the provided coordinate,
1078
+ * with the top left corner as the origin, and +y direction as down.
1079
+ */
1080
+ getGlyphPositionAtCoordinate(dx: number, dy: number): PositionWithAffinity;
1081
+ /**
1082
+ * Returns the information associated with the closest glyph at the specified
1083
+ * paragraph coordinate, or null if the paragraph is empty.
1084
+ */
1085
+ getClosestGlyphInfoAtCoordinate(dx: number, dy: number): GlyphInfo | null;
1086
+ /**
1087
+ * Returns the information associated with the glyph at the specified UTF-16
1088
+ * offset within the paragraph's visible lines, or null if the index is out
1089
+ * of bounds, or points to a codepoint that is logically after the last
1090
+ * visible codepoint.
1091
+ */
1092
+ getGlyphInfoAt(index: number): GlyphInfo | null;
1093
+
1094
+ getHeight(): number;
1095
+ getIdeographicBaseline(): number;
1096
+ /**
1097
+ * Returns the line number of the line that contains the specified UTF-16
1098
+ * offset within the paragraph, or -1 if the index is out of bounds, or
1099
+ * points to a codepoint that is logically after the last visible codepoint.
1100
+ */
1101
+ getLineNumberAt(index: number): number;
1102
+ getLineMetrics(): LineMetrics[];
1103
+ /**
1104
+ * Returns the LineMetrics of the line at the specified line number, or null
1105
+ * if the line number is out of bounds, or is larger than or equal to the
1106
+ * specified max line number.
1107
+ */
1108
+ getLineMetricsAt(lineNumber: number): LineMetrics | null;
1109
+ getLongestLine(): number;
1110
+ getMaxIntrinsicWidth(): number;
1111
+ getMaxWidth(): number;
1112
+ getMinIntrinsicWidth(): number;
1113
+ /**
1114
+ * Returns the total number of visible lines in the paragraph.
1115
+ */
1116
+ getNumberOfLines(): number;
1117
+ getRectsForPlaceholders(): RectWithDirection[];
1118
+
1119
+ /**
1120
+ * Returns bounding boxes that enclose all text in the range of glpyh indexes [start, end).
1121
+ * @param start
1122
+ * @param end
1123
+ * @param hStyle
1124
+ * @param wStyle
1125
+ */
1126
+ getRectsForRange(start: number, end: number, hStyle: RectHeightStyle,
1127
+ wStyle: RectWidthStyle): RectWithDirection[];
1128
+
1129
+ /**
1130
+ * Finds the first and last glyphs that define a word containing the glyph at index offset.
1131
+ * @param offset
1132
+ */
1133
+ getWordBoundary(offset: number): URange;
1134
+
1135
+ /**
1136
+ * Returns an array of ShapedLine objects, describing the paragraph.
1137
+ */
1138
+ getShapedLines(): ShapedLine[];
1139
+
1140
+ /**
1141
+ * Lays out the text in the paragraph so it is wrapped to the given width.
1142
+ * @param width
1143
+ */
1144
+ layout(width: number): void;
1145
+
1146
+ /**
1147
+ * When called after shaping, returns the glyph IDs which were not matched
1148
+ * by any of the provided fonts.
1149
+ */
1150
+ unresolvedCodepoints(): number[];
1151
+ }
1152
+
1153
+ export interface ParagraphBuilder extends EmbindObject<"ParagraphBuilder"> {
1154
+ /**
1155
+ * Pushes the information required to leave an open space.
1156
+ * @param width
1157
+ * @param height
1158
+ * @param alignment
1159
+ * @param baseline
1160
+ * @param offset
1161
+ */
1162
+ addPlaceholder(width?: number, height?: number, alignment?: PlaceholderAlignment,
1163
+ baseline?: TextBaseline, offset?: number): void;
1164
+
1165
+ /**
1166
+ * Adds text to the builder. Forms the proper runs to use the upper-most style
1167
+ * on the style_stack.
1168
+ * @param str
1169
+ */
1170
+ addText(str: string): void;
1171
+
1172
+ /**
1173
+ * Returns a Paragraph object that can be used to be layout and paint the text to an
1174
+ * Canvas.
1175
+ */
1176
+ build(): Paragraph;
1177
+
1178
+ /**
1179
+ * @param words is an array of word edges (starting or ending). You can
1180
+ * pass 2 elements (0 as a start of the entire text and text.size as the
1181
+ * end). This information is only needed for a specific API method getWords.
1182
+ *
1183
+ * The indices are expected to be relative to the UTF-8 representation of
1184
+ * the text.
1185
+ */
1186
+ setWordsUtf8(words: InputWords): void;
1187
+ /**
1188
+ * @param words is an array of word edges (starting or ending). You can
1189
+ * pass 2 elements (0 as a start of the entire text and text.size as the
1190
+ * end). This information is only needed for a specific API method getWords.
1191
+ *
1192
+ * The indices are expected to be relative to the UTF-16 representation of
1193
+ * the text.
1194
+ *
1195
+ * The `Intl.Segmenter` API can be used as a source for this data.
1196
+ */
1197
+ setWordsUtf16(words: InputWords): void;
1198
+
1199
+ /**
1200
+ * @param graphemes is an array of indexes in the input text that point
1201
+ * to the start of each grapheme.
1202
+ *
1203
+ * The indices are expected to be relative to the UTF-8 representation of
1204
+ * the text.
1205
+ */
1206
+ setGraphemeBreaksUtf8(graphemes: InputGraphemes): void;
1207
+ /**
1208
+ * @param graphemes is an array of indexes in the input text that point
1209
+ * to the start of each grapheme.
1210
+ *
1211
+ * The indices are expected to be relative to the UTF-16 representation of
1212
+ * the text.
1213
+ *
1214
+ * The `Intl.Segmenter` API can be used as a source for this data.
1215
+ */
1216
+ setGraphemeBreaksUtf16(graphemes: InputGraphemes): void;
1217
+
1218
+ /**
1219
+ * @param lineBreaks is an array of unsigned integers that should be
1220
+ * treated as pairs (index, break type) that point to the places of possible
1221
+ * line breaking if needed. It should include 0 as the first element.
1222
+ * Break type == 0 means soft break, break type == 1 is a hard break.
1223
+ *
1224
+ * The indices are expected to be relative to the UTF-8 representation of
1225
+ * the text.
1226
+ */
1227
+ setLineBreaksUtf8(lineBreaks: InputLineBreaks): void;
1228
+ /**
1229
+ * @param lineBreaks is an array of unsigned integers that should be
1230
+ * treated as pairs (index, break type) that point to the places of possible
1231
+ * line breaking if needed. It should include 0 as the first element.
1232
+ * Break type == 0 means soft break, break type == 1 is a hard break.
1233
+ *
1234
+ * The indices are expected to be relative to the UTF-16 representation of
1235
+ * the text.
1236
+ *
1237
+ * Chrome's `v8BreakIterator` API can be used as a source for this data.
1238
+ */
1239
+ setLineBreaksUtf16(lineBreaks: InputLineBreaks): void;
1240
+
1241
+ /**
1242
+ * Returns the entire Paragraph text (which is useful in case that text
1243
+ * was produced as a set of addText calls).
1244
+ */
1245
+ getText(): string;
1246
+
1247
+ /**
1248
+ * Remove a style from the stack. Useful to apply different styles to chunks
1249
+ * of text such as bolding.
1250
+ */
1251
+ pop(): void;
1252
+
1253
+ /**
1254
+ * Push a style to the stack. The corresponding text added with addText will
1255
+ * use the top-most style.
1256
+ * @param text
1257
+ */
1258
+ pushStyle(text: TextStyle): void;
1259
+
1260
+ /**
1261
+ * Pushes a TextStyle using paints instead of colors for foreground and background.
1262
+ * @param textStyle
1263
+ * @param fg
1264
+ * @param bg
1265
+ */
1266
+ pushPaintStyle(textStyle: TextStyle, fg: Paint, bg: Paint): void;
1267
+
1268
+ /**
1269
+ * Resets this builder to its initial state, discarding any text, styles, placeholders that have
1270
+ * been added, but keeping the initial ParagraphStyle.
1271
+ */
1272
+ reset(): void;
1273
+ }
1274
+
1275
+ export interface ParagraphStyle {
1276
+ disableHinting?: boolean;
1277
+ ellipsis?: string;
1278
+ heightMultiplier?: number;
1279
+ maxLines?: number;
1280
+ replaceTabCharacters?: boolean;
1281
+ strutStyle?: StrutStyle;
1282
+ textAlign?: TextAlign;
1283
+ textDirection?: TextDirection;
1284
+ textHeightBehavior?: TextHeightBehavior;
1285
+ textStyle?: TextStyle;
1286
+ applyRoundingHack?: boolean;
1287
+ }
1288
+
1289
+ export interface PositionWithAffinity {
1290
+ pos: number;
1291
+ affinity: Affinity;
1292
+ }
1293
+
1294
+ export interface SkSLUniform {
1295
+ columns: number;
1296
+ rows: number;
1297
+ /** The index into the uniforms array that this uniform begins. */
1298
+ slot: number;
1299
+ isInteger: boolean;
1300
+ }
1301
+
1302
+ /**
1303
+ * See SkAnimatedImage.h for more information on this class.
1304
+ */
1305
+ export interface AnimatedImage extends EmbindObject<"AnimatedImage"> {
1306
+ /**
1307
+ * Returns the length of the current frame in ms.
1308
+ */
1309
+ currentFrameDuration(): number;
1310
+ /**
1311
+ * Decodes the next frame. Returns the length of that new frame in ms.
1312
+ * Returns -1 when the animation is on the last frame.
1313
+ */
1314
+ decodeNextFrame(): number;
1315
+
1316
+ /**
1317
+ * Return the total number of frames in the animation.
1318
+ */
1319
+ getFrameCount(): number;
1320
+
1321
+ /**
1322
+ * Return the repetition count for this animation.
1323
+ */
1324
+ getRepetitionCount(): number;
1325
+
1326
+ /**
1327
+ * Returns the possibly scaled height of the image.
1328
+ */
1329
+ height(): number;
1330
+
1331
+ /**
1332
+ * Returns a still image of the current frame or null if there is no current frame.
1333
+ */
1334
+ makeImageAtCurrentFrame(): Image | null;
1335
+
1336
+ /**
1337
+ * Reset the animation to the beginning.
1338
+ */
1339
+ reset(): void;
1340
+
1341
+ /**
1342
+ * Returns the possibly scaled width of the image.
1343
+ */
1344
+ width(): number;
1345
+ }
1346
+
1347
+ /**
1348
+ * See SkBlender.h for more on this class. The objects are opaque.
1349
+ */
1350
+ export type Blender = EmbindObject<"Blender">;
1351
+
1352
+ /**
1353
+ * See SkCanvas.h for more information on this class.
1354
+ */
1355
+ export interface Canvas extends EmbindObject<"Canvas"> {
1356
+ /**
1357
+ * Fills the current clip with the given color using Src BlendMode.
1358
+ * This has the effect of replacing all pixels contained by clip with color.
1359
+ * @param color
1360
+ */
1361
+ clear(color: InputColor): void;
1362
+
1363
+ /**
1364
+ * Replaces clip with the intersection or difference of the current clip and path,
1365
+ * with an aliased or anti-aliased clip edge.
1366
+ * @param path
1367
+ * @param op
1368
+ * @param doAntiAlias
1369
+ */
1370
+ clipPath(path: Path, op: ClipOp, doAntiAlias: boolean): void;
1371
+
1372
+ /**
1373
+ * Replaces clip with the intersection or difference of the current clip and rect,
1374
+ * with an aliased or anti-aliased clip edge.
1375
+ * @param rect
1376
+ * @param op
1377
+ * @param doAntiAlias
1378
+ */
1379
+ clipRect(rect: InputRect, op: ClipOp, doAntiAlias: boolean): void;
1380
+
1381
+ /**
1382
+ * Replaces clip with the intersection or difference of the current clip and rrect,
1383
+ * with an aliased or anti-aliased clip edge.
1384
+ * @param rrect
1385
+ * @param op
1386
+ * @param doAntiAlias
1387
+ */
1388
+ clipRRect(rrect: InputRRect, op: ClipOp, doAntiAlias: boolean): void;
1389
+
1390
+ /**
1391
+ * Replaces current matrix with m premultiplied with the existing matrix.
1392
+ * @param m
1393
+ */
1394
+ concat(m: InputMatrix): void;
1395
+
1396
+ /**
1397
+ * Draws arc using clip, Matrix, and Paint paint.
1398
+ *
1399
+ * Arc is part of oval bounded by oval, sweeping from startAngle to startAngle plus
1400
+ * sweepAngle. startAngle and sweepAngle are in degrees.
1401
+ * @param oval - bounds of oval containing arc to draw
1402
+ * @param startAngle - angle in degrees where arc begins
1403
+ * @param sweepAngle - sweep angle in degrees; positive is clockwise
1404
+ * @param useCenter - if true, include the center of the oval
1405
+ * @param paint
1406
+ */
1407
+ drawArc(oval: InputRect, startAngle: AngleInDegrees, sweepAngle: AngleInDegrees,
1408
+ useCenter: boolean, paint: Paint): void;
1409
+
1410
+ /**
1411
+ * Draws a set of sprites from atlas, using clip, Matrix, and optional Paint paint.
1412
+ * @param atlas - Image containing sprites
1413
+ * @param srcRects - Rect locations of sprites in atlas
1414
+ * @param dstXforms - RSXform mappings for sprites in atlas
1415
+ * @param paint
1416
+ * @param blendMode - BlendMode combining colors and sprites
1417
+ * @param colors - If provided, will be blended with sprite using blendMode.
1418
+ * @param sampling - Specifies sampling options. If null, bilinear is used.
1419
+ */
1420
+ drawAtlas(atlas: Image, srcRects: InputFlattenedRectangleArray,
1421
+ dstXforms: InputFlattenedRSXFormArray, paint: Paint,
1422
+ blendMode?: BlendMode | null, colors?: ColorIntArray | null,
1423
+ sampling?: CubicResampler | FilterOptions): void;
1424
+
1425
+ /**
1426
+ * Draws a circle at (cx, cy) with the given radius.
1427
+ * @param cx
1428
+ * @param cy
1429
+ * @param radius
1430
+ * @param paint
1431
+ */
1432
+ drawCircle(cx: number, cy: number, radius: number, paint: Paint): void;
1433
+
1434
+ /**
1435
+ * Fills clip with the given color.
1436
+ * @param color
1437
+ * @param blendMode - defaults to SrcOver.
1438
+ */
1439
+ drawColor(color: InputColor, blendMode?: BlendMode): void;
1440
+
1441
+ /**
1442
+ * Fills clip with the given color.
1443
+ * @param r - red value (typically from 0 to 1.0).
1444
+ * @param g - green value (typically from 0 to 1.0).
1445
+ * @param b - blue value (typically from 0 to 1.0).
1446
+ * @param a - alpha value, range 0 to 1.0 (1.0 is opaque).
1447
+ * @param blendMode - defaults to SrcOver.
1448
+ */
1449
+ drawColorComponents(r: number, g: number, b: number, a: number, blendMode?: BlendMode): void;
1450
+
1451
+ /**
1452
+ * Fills clip with the given color.
1453
+ * @param color
1454
+ * @param blendMode - defaults to SrcOver.
1455
+ */
1456
+ drawColorInt(color: ColorInt, blendMode?: BlendMode): void;
1457
+
1458
+ /**
1459
+ * Draws RRect outer and inner using clip, Matrix, and Paint paint.
1460
+ * outer must contain inner or the drawing is undefined.
1461
+ * @param outer
1462
+ * @param inner
1463
+ * @param paint
1464
+ */
1465
+ drawDRRect(outer: InputRRect, inner: InputRRect, paint: Paint): void;
1466
+
1467
+ /**
1468
+ * Draws a run of glyphs, at corresponding positions, in a given font.
1469
+ * @param glyphs the array of glyph IDs (Uint16TypedArray)
1470
+ * @param positions the array of x,y floats to position each glyph
1471
+ * @param x x-coordinate of the origin of the entire run
1472
+ * @param y y-coordinate of the origin of the entire run
1473
+ * @param font the font that contains the glyphs
1474
+ * @param paint
1475
+ */
1476
+ drawGlyphs(glyphs: InputGlyphIDArray,
1477
+ positions: InputFlattenedPointArray,
1478
+ x: number, y: number,
1479
+ font: Font, paint: Paint): void;
1480
+
1481
+ /**
1482
+ * Draws the given image with its top-left corner at (left, top) using the current clip,
1483
+ * the current matrix, and optionally-provided paint.
1484
+ * @param img
1485
+ * @param left
1486
+ * @param top
1487
+ * @param paint
1488
+ */
1489
+ drawImage(img: Image, left: number, top: number, paint?: Paint | null): void;
1490
+
1491
+ /**
1492
+ * Draws the given image with its top-left corner at (left, top) using the current clip,
1493
+ * the current matrix. It will use the cubic sampling options B and C if necessary.
1494
+ * @param img
1495
+ * @param left
1496
+ * @param top
1497
+ * @param B - See CubicResampler in SkSamplingOptions.h for more information
1498
+ * @param C - See CubicResampler in SkSamplingOptions.h for more information
1499
+ * @param paint
1500
+ */
1501
+ drawImageCubic(img: Image, left: number, top: number, B: number, C: number,
1502
+ paint?: Paint | null): void;
1503
+
1504
+ /**
1505
+ * Draws the given image with its top-left corner at (left, top) using the current clip,
1506
+ * the current matrix. It will use the provided sampling options if necessary.
1507
+ * @param img
1508
+ * @param left
1509
+ * @param top
1510
+ * @param fm - The filter mode.
1511
+ * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps
1512
+ * calculated with makeCopyWithDefaultMipmaps;
1513
+ * @param paint
1514
+ */
1515
+ drawImageOptions(img: Image, left: number, top: number, fm: FilterMode,
1516
+ mm: MipmapMode, paint?: Paint | null): void;
1517
+
1518
+ /**
1519
+ * Draws the provided image stretched proportionally to fit into dst rectangle.
1520
+ * The center rectangle divides the image into nine sections: four sides, four corners, and
1521
+ * the center.
1522
+ * @param img
1523
+ * @param center
1524
+ * @param dest
1525
+ * @param filter - what technique to use when sampling the image
1526
+ * @param paint
1527
+ */
1528
+ drawImageNine(img: Image, center: InputIRect, dest: InputRect, filter: FilterMode,
1529
+ paint?: Paint | null): void;
1530
+
1531
+ /**
1532
+ * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.
1533
+ * @param img
1534
+ * @param src
1535
+ * @param dest
1536
+ * @param paint
1537
+ * @param fastSample - if false, will filter strictly within src.
1538
+ */
1539
+ drawImageRect(img: Image, src: InputRect, dest: InputRect, paint: Paint,
1540
+ fastSample?: boolean): void;
1541
+
1542
+ /**
1543
+ * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.
1544
+ * It will use the cubic sampling options B and C if necessary.
1545
+ * @param img
1546
+ * @param src
1547
+ * @param dest
1548
+ * @param B - See CubicResampler in SkSamplingOptions.h for more information
1549
+ * @param C - See CubicResampler in SkSamplingOptions.h for more information
1550
+ * @param paint
1551
+ */
1552
+ drawImageRectCubic(img: Image, src: InputRect, dest: InputRect,
1553
+ B: number, C: number, paint?: Paint | null): void;
1554
+
1555
+ /**
1556
+ * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.
1557
+ * It will use the provided sampling options if necessary.
1558
+ * @param img
1559
+ * @param src
1560
+ * @param dest
1561
+ * @param fm - The filter mode.
1562
+ * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps
1563
+ * calculated with makeCopyWithDefaultMipmaps;
1564
+ * @param paint
1565
+ */
1566
+ drawImageRectOptions(img: Image, src: InputRect, dest: InputRect, fm: FilterMode,
1567
+ mm: MipmapMode, paint?: Paint | null): void;
1568
+
1569
+ /**
1570
+ * Draws line segment from (x0, y0) to (x1, y1) using the current clip, current matrix,
1571
+ * and the provided paint.
1572
+ * @param x0
1573
+ * @param y0
1574
+ * @param x1
1575
+ * @param y1
1576
+ * @param paint
1577
+ */
1578
+ drawLine(x0: number, y0: number, x1: number, y1: number, paint: Paint): void;
1579
+
1580
+ /**
1581
+ * Draws an oval bounded by the given rectangle using the current clip, current matrix,
1582
+ * and the provided paint.
1583
+ * @param oval
1584
+ * @param paint
1585
+ */
1586
+ drawOval(oval: InputRect, paint: Paint): void;
1587
+
1588
+ /**
1589
+ * Fills clip with the given paint.
1590
+ * @param paint
1591
+ */
1592
+ drawPaint(paint: Paint): void;
1593
+
1594
+ /**
1595
+ * Draws the given Paragraph at the provided coordinates.
1596
+ * Requires the Paragraph code to be compiled in.
1597
+ * @param p
1598
+ * @param x
1599
+ * @param y
1600
+ */
1601
+ drawParagraph(p: Paragraph, x: number, y: number): void;
1602
+
1603
+ /**
1604
+ * Draws the given path using the current clip, current matrix, and the provided paint.
1605
+ * @param path
1606
+ * @param paint
1607
+ */
1608
+ drawPath(path: Path, paint: Paint): void;
1609
+
1610
+ /**
1611
+ * Draws a cubic patch defined by 12 control points [top, right, bottom, left] with optional
1612
+ * colors and shader-coordinates [4] specifed for each corner [top-left, top-right, bottom-right, bottom-left]
1613
+ * @param cubics 12 points : 4 connected cubics specifying the boundary of the patch
1614
+ * @param colors optional colors interpolated across the patch
1615
+ * @param texs optional shader coordinates interpolated across the patch
1616
+ * @param mode Specifies how shader and colors blend (if both are specified)
1617
+ * @param paint
1618
+ */
1619
+ drawPatch(cubics: InputFlattenedPointArray,
1620
+ colors?: ColorIntArray | Color[] | null,
1621
+ texs?: InputFlattenedPointArray | null,
1622
+ mode?: BlendMode | null,
1623
+ paint?: Paint): void;
1624
+
1625
+ /**
1626
+ * Draws the given picture using the current clip, current matrix, and the provided paint.
1627
+ * @param skp
1628
+ */
1629
+ drawPicture(skp: SkPicture): void;
1630
+
1631
+ /**
1632
+ * Draws the given points using the current clip, current matrix, and the provided paint.
1633
+ *
1634
+ * See Canvas.h for more on the mode and its interaction with paint.
1635
+ * @param mode
1636
+ * @param points
1637
+ * @param paint
1638
+ */
1639
+ drawPoints(mode: PointMode, points: InputFlattenedPointArray, paint: Paint): void;
1640
+
1641
+ /**
1642
+ * Draws the given rectangle using the current clip, current matrix, and the provided paint.
1643
+ * @param rect
1644
+ * @param paint
1645
+ */
1646
+ drawRect(rect: InputRect, paint: Paint): void;
1647
+
1648
+ /**
1649
+ * Draws the given rectangle using the current clip, current matrix, and the provided paint.
1650
+ * @param left
1651
+ * @param top
1652
+ * @param right
1653
+ * @param bottom
1654
+ * @param paint
1655
+ */
1656
+ drawRect4f(left: number, top: number, right: number, bottom: number, paint: Paint): void;
1657
+
1658
+ /**
1659
+ * Draws the given rectangle with rounded corners using the current clip, current matrix,
1660
+ * and the provided paint.
1661
+ * @param rrect
1662
+ * @param paint
1663
+ */
1664
+ drawRRect(rrect: InputRRect, paint: Paint): void;
1665
+
1666
+ /**
1667
+ * Draw an offset spot shadow and outlining ambient shadow for the given path using a disc
1668
+ * light. See SkShadowUtils.h for more details
1669
+ * @param path - The occluder used to generate the shadows.
1670
+ * @param zPlaneParams - Values for the plane function which returns the Z offset of the
1671
+ * occluder from the canvas based on local x and y values (the current
1672
+ * matrix is not applied).
1673
+ * @param lightPos - The 3D position of the light relative to the canvas plane. This is
1674
+ * independent of the canvas's current matrix.
1675
+ * @param lightRadius - The radius of the disc light.
1676
+ * @param ambientColor - The color of the ambient shadow.
1677
+ * @param spotColor - The color of the spot shadow.
1678
+ * @param flags - See SkShadowUtils.h; 0 means use default options.
1679
+ */
1680
+ drawShadow(path: Path, zPlaneParams: InputVector3, lightPos: InputVector3, lightRadius: number,
1681
+ ambientColor: InputColor, spotColor: InputColor, flags: number): void;
1682
+
1683
+ /**
1684
+ * Draw the given text at the location (x, y) using the provided paint and font. The text will
1685
+ * be drawn as is; no shaping, left-to-right, etc.
1686
+ * @param str
1687
+ * @param x
1688
+ * @param y
1689
+ * @param paint
1690
+ * @param font
1691
+ */
1692
+ drawText(str: string, x: number, y: number, paint: Paint, font: Font): void;
1693
+
1694
+ /**
1695
+ * Draws the given TextBlob at (x, y) using the current clip, current matrix, and the
1696
+ * provided paint. Reminder that the fonts used to draw TextBlob are part of the blob.
1697
+ * @param blob
1698
+ * @param x
1699
+ * @param y
1700
+ * @param paint
1701
+ */
1702
+ drawTextBlob(blob: TextBlob, x: number, y: number, paint: Paint): void;
1703
+
1704
+ /**
1705
+ * Draws the given vertices (a triangle mesh) using the current clip, current matrix, and the
1706
+ * provided paint.
1707
+ * If paint contains an Shader and vertices does not contain texCoords, the shader
1708
+ * is mapped using the vertices' positions.
1709
+ * If vertices colors are defined in vertices, and Paint paint contains Shader,
1710
+ * BlendMode mode combines vertices colors with Shader.
1711
+ * @param verts
1712
+ * @param mode
1713
+ * @param paint
1714
+ */
1715
+ drawVertices(verts: Vertices, mode: BlendMode, paint: Paint): void;
1716
+
1717
+ /**
1718
+ * Returns the bounds of clip, unaffected by the canvas's matrix.
1719
+ * If the clip is empty, all four integers in the returned rectangle will equal zero.
1720
+ *
1721
+ * @param output - if provided, the results will be copied into the given array instead of
1722
+ * allocating a new one.
1723
+ */
1724
+ getDeviceClipBounds(output?: IRect): IRect;
1725
+
1726
+ /**
1727
+ * Returns the current transform from local coordinates to the 'device', which for most
1728
+ * purposes means pixels.
1729
+ */
1730
+ getLocalToDevice(): Matrix4x4;
1731
+
1732
+ /**
1733
+ * Returns the number of saved states, each containing: Matrix and clip.
1734
+ * Equals the number of save() calls less the number of restore() calls plus one.
1735
+ * The save count of a new canvas is one.
1736
+ */
1737
+ getSaveCount(): number;
1738
+
1739
+ /**
1740
+ * Legacy version of getLocalToDevice(), which strips away any Z information, and
1741
+ * just returns a 3x3 version.
1742
+ */
1743
+ getTotalMatrix(): number[];
1744
+
1745
+ /**
1746
+ * Creates Surface matching info and props, and associates it with Canvas.
1747
+ * Returns null if no match found.
1748
+ * @param info
1749
+ */
1750
+ makeSurface(info: ImageInfo): Surface | null;
1751
+
1752
+ /**
1753
+ * Returns a TypedArray containing the pixels reading starting at (srcX, srcY) and does not
1754
+ * exceed the size indicated by imageInfo. See SkCanvas.h for more on the caveats.
1755
+ *
1756
+ * If dest is not provided, we allocate memory equal to the provided height * the provided
1757
+ * bytesPerRow to fill the data with.
1758
+ *
1759
+ * This is generally a very expensive call for the GPU backend.
1760
+ *
1761
+ * @param srcX
1762
+ * @param srcY
1763
+ * @param imageInfo - describes the destination format of the pixels.
1764
+ * @param dest - If provided, the pixels will be copied into the allocated buffer allowing
1765
+ * access to the pixels without allocating a new TypedArray.
1766
+ * @param bytesPerRow - number of bytes per row. Must be provided if dest is set. This
1767
+ * depends on destination ColorType. For example, it must be at least 4 * width for
1768
+ * the 8888 color type.
1769
+ * @returns a TypedArray appropriate for the specified ColorType. Note that 16 bit floats are
1770
+ * not supported in JS, so that colorType corresponds to raw bytes Uint8Array.
1771
+ */
1772
+ readPixels(srcX: number, srcY: number, imageInfo: ImageInfo, dest?: MallocObj,
1773
+ bytesPerRow?: number): Float32Array | Uint8Array | null;
1774
+
1775
+ /**
1776
+ * Removes changes to the current matrix and clip since Canvas state was
1777
+ * last saved. The state is removed from the stack.
1778
+ * Does nothing if the stack is empty.
1779
+ */
1780
+ restore(): void;
1781
+
1782
+ /**
1783
+ * Restores state to a previous stack value.
1784
+ * @param saveCount
1785
+ */
1786
+ restoreToCount(saveCount: number): void;
1787
+
1788
+ /**
1789
+ * Rotates the current matrix by the number of degrees.
1790
+ * @param rot - angle of rotation in degrees.
1791
+ * @param rx
1792
+ * @param ry
1793
+ */
1794
+ rotate(rot: AngleInDegrees, rx: number, ry: number): void;
1795
+
1796
+ /**
1797
+ * Saves the current matrix and clip and returns current height of the stack.
1798
+ */
1799
+ save(): number;
1800
+
1801
+ /**
1802
+ * Saves Matrix and clip, and allocates a SkBitmap for subsequent drawing.
1803
+ * Calling restore() discards changes to Matrix and clip, and draws the SkBitmap.
1804
+ * It returns the height of the stack.
1805
+ * See Canvas.h for more.
1806
+ * @param paint
1807
+ * @param bounds
1808
+ * @param backdrop
1809
+ * @param flags
1810
+ */
1811
+ saveLayer(paint?: Paint, bounds?: InputRect | null, backdrop?: ImageFilter | null,
1812
+ flags?: SaveLayerFlag): number;
1813
+
1814
+ /**
1815
+ * Scales the current matrix by sx on the x-axis and sy on the y-axis.
1816
+ * @param sx
1817
+ * @param sy
1818
+ */
1819
+ scale(sx: number, sy: number): void;
1820
+
1821
+ /**
1822
+ * Skews Matrix by sx on the x-axis and sy on the y-axis. A positive value of sx
1823
+ * skews the drawing right as y-axis values increase; a positive value of sy skews
1824
+ * the drawing down as x-axis values increase.
1825
+ * @param sx
1826
+ * @param sy
1827
+ */
1828
+ skew(sx: number, sy: number): void;
1829
+
1830
+ /**
1831
+ * Translates Matrix by dx along the x-axis and dy along the y-axis.
1832
+ * @param dx
1833
+ * @param dy
1834
+ */
1835
+ translate(dx: number, dy: number): void;
1836
+
1837
+ /**
1838
+ * Writes the given rectangle of pixels to the provided coordinates. The source pixels
1839
+ * will be converted to the canvas's alphaType and colorType if they do not match.
1840
+ * @param pixels
1841
+ * @param srcWidth
1842
+ * @param srcHeight
1843
+ * @param destX
1844
+ * @param destY
1845
+ * @param alphaType - defaults to Unpremul
1846
+ * @param colorType - defaults to RGBA_8888
1847
+ * @param colorSpace - defaults to SRGB
1848
+ */
1849
+ writePixels(pixels: Uint8Array | number[], srcWidth: number, srcHeight: number,
1850
+ destX: number, destY: number, alphaType?: AlphaType, colorType?: ColorType,
1851
+ colorSpace?: ColorSpace): boolean;
1852
+ }
1853
+
1854
+ /**
1855
+ * See SkColorFilter.h for more on this class. The objects are opaque.
1856
+ */
1857
+ export type ColorFilter = EmbindObject<"ColorFilter">;
1858
+
1859
+ export interface ContourMeasureIter extends EmbindObject<"ContourMeasureIter"> {
1860
+ /**
1861
+ * Iterates through contours in path, returning a contour-measure object for each contour
1862
+ * in the path. Returns null when it is done.
1863
+ *
1864
+ * See SkContourMeasure.h for more details.
1865
+ */
1866
+ next(): ContourMeasure | null;
1867
+ }
1868
+
1869
+ export interface ContourMeasure extends EmbindObject<"ContourMeasure"> {
1870
+ /**
1871
+ * Returns the given position and tangent line for the distance on the given contour.
1872
+ * The return value is 4 floats in this order: posX, posY, vecX, vecY.
1873
+ * @param distance - will be pinned between 0 and length().
1874
+ * @param output - if provided, the four floats of the PosTan will be copied into this array
1875
+ * instead of allocating a new one.
1876
+ */
1877
+ getPosTan(distance: number, output?: PosTan): PosTan;
1878
+
1879
+ /**
1880
+ * Returns an Path representing the segement of this contour.
1881
+ * @param startD - will be pinned between 0 and length()
1882
+ * @param stopD - will be pinned between 0 and length()
1883
+ * @param startWithMoveTo
1884
+ */
1885
+ getSegment(startD: number, stopD: number, startWithMoveTo: boolean): Path;
1886
+
1887
+ /**
1888
+ * Returns true if the contour is closed.
1889
+ */
1890
+ isClosed(): boolean;
1891
+
1892
+ /**
1893
+ * Returns the length of this contour.
1894
+ */
1895
+ length(): number;
1896
+ }
1897
+
1898
+ export interface FontMetrics {
1899
+ ascent: number; // suggested space above the baseline. < 0
1900
+ descent: number; // suggested space below the baseline. > 0
1901
+ leading: number; // suggested spacing between descent of previous line and ascent of next line.
1902
+ bounds?: Rect; // smallest rect containing all glyphs (relative to 0,0)
1903
+ }
1904
+
1905
+ /**
1906
+ * See SkFont.h for more on this class.
1907
+ */
1908
+ export interface Font extends EmbindObject<"Font"> {
1909
+ /**
1910
+ * Returns the FontMetrics for this font.
1911
+ */
1912
+ getMetrics(): FontMetrics;
1913
+
1914
+ /**
1915
+ * Retrieves the bounds for each glyph in glyphs.
1916
+ * If paint is not null, its stroking, PathEffect, and MaskFilter fields are respected.
1917
+ * These are returned as flattened rectangles. For each glyph, there will be 4 floats for
1918
+ * left, top, right, bottom (relative to 0, 0) for that glyph.
1919
+ * @param glyphs
1920
+ * @param paint
1921
+ * @param output - if provided, the results will be copied into this array.
1922
+ */
1923
+ getGlyphBounds(glyphs: InputGlyphIDArray, paint?: Paint | null,
1924
+ output?: Float32Array): Float32Array;
1925
+
1926
+ /**
1927
+ * Retrieves the glyph ids for each code point in the provided string. This call is passed to
1928
+ * the typeface of this font. Note that glyph IDs are typeface-dependent; different faces
1929
+ * may have different ids for the same code point.
1930
+ * @param str
1931
+ * @param numCodePoints - the number of code points in the string. Defaults to str.length.
1932
+ * @param output - if provided, the results will be copied into this array.
1933
+ */
1934
+ getGlyphIDs(str: string, numCodePoints?: number,
1935
+ output?: GlyphIDArray): GlyphIDArray;
1936
+
1937
+ /**
1938
+ * Retrieves the advanceX measurements for each glyph.
1939
+ * If paint is not null, its stroking, PathEffect, and MaskFilter fields are respected.
1940
+ * One width per glyph is returned in the returned array.
1941
+ * @param glyphs
1942
+ * @param paint
1943
+ * @param output - if provided, the results will be copied into this array.
1944
+ */
1945
+ getGlyphWidths(glyphs: InputGlyphIDArray, paint?: Paint | null,
1946
+ output?: Float32Array): Float32Array;
1947
+
1948
+ /**
1949
+ * Computes any intersections of a thick "line" and a run of positionsed glyphs.
1950
+ * The thick line is represented as a top and bottom coordinate (positive for
1951
+ * below the baseline, negative for above). If there are no intersections
1952
+ * (e.g. if this is intended as an underline, and there are no "collisions")
1953
+ * then the returned array will be empty. If there are intersections, the array
1954
+ * will contain pairs of X coordinates [start, end] for each segment that
1955
+ * intersected with a glyph.
1956
+ *
1957
+ * @param glyphs the glyphs to intersect with
1958
+ * @param positions x,y coordinates (2 per glyph) for each glyph
1959
+ * @param top top of the thick "line" to use for intersection testing
1960
+ * @param bottom bottom of the thick "line" to use for intersection testing
1961
+ * @return array of [start, end] x-coordinate pairs. Maybe be empty.
1962
+ */
1963
+ getGlyphIntercepts(glyphs: InputGlyphIDArray, positions: Float32Array | number[],
1964
+ top: number, bottom: number): Float32Array;
1965
+
1966
+ /**
1967
+ * Returns text scale on x-axis. Default value is 1.
1968
+ */
1969
+ getScaleX(): number;
1970
+
1971
+ /**
1972
+ * Returns text size in points.
1973
+ */
1974
+ getSize(): number;
1975
+
1976
+ /**
1977
+ * Returns text skew on x-axis. Default value is zero.
1978
+ */
1979
+ getSkewX(): number;
1980
+
1981
+ /**
1982
+ * Returns embolden effect for this font. Default value is false.
1983
+ */
1984
+ isEmbolden(): boolean;
1985
+
1986
+ /**
1987
+ * Returns the Typeface set for this font.
1988
+ */
1989
+ getTypeface(): Typeface | null;
1990
+
1991
+ /**
1992
+ * Requests, but does not require, that edge pixels draw opaque or with partial transparency.
1993
+ * @param edging
1994
+ */
1995
+ setEdging(edging: FontEdging): void;
1996
+
1997
+ /**
1998
+ * Requests, but does not require, to use bitmaps in fonts instead of outlines.
1999
+ * @param embeddedBitmaps
2000
+ */
2001
+ setEmbeddedBitmaps(embeddedBitmaps: boolean): void;
2002
+
2003
+ /**
2004
+ * Sets level of glyph outline adjustment.
2005
+ * @param hinting
2006
+ */
2007
+ setHinting(hinting: FontHinting): void;
2008
+
2009
+ /**
2010
+ * Requests, but does not require, linearly scalable font and glyph metrics.
2011
+ *
2012
+ * For outline fonts 'true' means font and glyph metrics should ignore hinting and rounding.
2013
+ * Note that some bitmap formats may not be able to scale linearly and will ignore this flag.
2014
+ * @param linearMetrics
2015
+ */
2016
+ setLinearMetrics(linearMetrics: boolean): void;
2017
+
2018
+ /**
2019
+ * Sets the text scale on the x-axis.
2020
+ * @param sx
2021
+ */
2022
+ setScaleX(sx: number): void;
2023
+
2024
+ /**
2025
+ * Sets the text size in points on this font.
2026
+ * @param points
2027
+ */
2028
+ setSize(points: number): void;
2029
+
2030
+ /**
2031
+ * Sets the text-skew on the x axis for this font.
2032
+ * @param sx
2033
+ */
2034
+ setSkewX(sx: number): void;
2035
+
2036
+ /**
2037
+ * Set embolden effect for this font.
2038
+ * @param embolden
2039
+ */
2040
+ setEmbolden(embolden: boolean): void;
2041
+
2042
+ /**
2043
+ * Requests, but does not require, that glyphs respect sub-pixel positioning.
2044
+ * @param subpixel
2045
+ */
2046
+ setSubpixel(subpixel: boolean): void;
2047
+
2048
+ /**
2049
+ * Sets the typeface to use with this font. null means to clear the typeface and use the
2050
+ * default one.
2051
+ * @param face
2052
+ */
2053
+ setTypeface(face: Typeface | null): void;
2054
+ }
2055
+
2056
+ /**
2057
+ * See SkFontMgr.h for more details
2058
+ */
2059
+ export interface FontMgr extends EmbindObject<"FontMgr"> {
2060
+ /**
2061
+ * Return the number of font families loaded in this manager. Useful for debugging.
2062
+ */
2063
+ countFamilies(): number;
2064
+
2065
+ /**
2066
+ * Return the nth family name. Useful for debugging.
2067
+ * @param index
2068
+ */
2069
+ getFamilyName(index: number): string;
2070
+
2071
+ /**
2072
+ * Find the closest matching typeface to the specified familyName and style.
2073
+ */
2074
+ matchFamilyStyle(name: string, style: FontStyle): Typeface;
2075
+ }
2076
+
2077
+ /**
2078
+ * See SkImage.h for more information on this class.
2079
+ */
2080
+ export interface Image extends EmbindObject<"Image"> {
2081
+ /**
2082
+ * Encodes this image's pixels to the specified format and returns them. Must be built with
2083
+ * the specified codec. If the options are unspecified, sensible defaults will be
2084
+ * chosen.
2085
+ * @param fmt - PNG is the default value.
2086
+ * @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.
2087
+ */
2088
+ encodeToBytes(fmt?: EncodedImageFormat, quality?: number): Uint8Array | null;
2089
+
2090
+ /**
2091
+ * Returns the color space associated with this object.
2092
+ * It is the user's responsibility to call delete() on this after it has been used.
2093
+ */
2094
+ getColorSpace(): ColorSpace;
2095
+
2096
+ /**
2097
+ * Returns the width, height, colorType and alphaType associated with this image.
2098
+ * Colorspace is separate so as to not accidentally leak that memory.
2099
+ */
2100
+ getImageInfo(): PartialImageInfo;
2101
+
2102
+ /**
2103
+ * Return the height in pixels of the image.
2104
+ */
2105
+ height(): number;
2106
+
2107
+ /**
2108
+ * Returns an Image with the same "base" pixels as the this image, but with mipmap levels
2109
+ * automatically generated and attached.
2110
+ */
2111
+ makeCopyWithDefaultMipmaps(): Image;
2112
+
2113
+ /**
2114
+ * Returns this image as a shader with the specified tiling. It will use cubic sampling.
2115
+ * @param tx - tile mode in the x direction.
2116
+ * @param ty - tile mode in the y direction.
2117
+ * @param B - See CubicResampler in SkSamplingOptions.h for more information
2118
+ * @param C - See CubicResampler in SkSamplingOptions.h for more information
2119
+ * @param localMatrix
2120
+ */
2121
+ makeShaderCubic(tx: TileMode, ty: TileMode, B: number, C: number,
2122
+ localMatrix?: InputMatrix): Shader;
2123
+
2124
+ /**
2125
+ * Returns this image as a shader with the specified tiling. It will use cubic sampling.
2126
+ * @param tx - tile mode in the x direction.
2127
+ * @param ty - tile mode in the y direction.
2128
+ * @param fm - The filter mode.
2129
+ * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps
2130
+ * calculated with makeCopyWithDefaultMipmaps;
2131
+ * @param localMatrix
2132
+ */
2133
+ makeShaderOptions(tx: TileMode, ty: TileMode, fm: FilterMode, mm: MipmapMode,
2134
+ localMatrix?: InputMatrix): Shader;
2135
+
2136
+ /**
2137
+ * Returns a TypedArray containing the pixels reading starting at (srcX, srcY) and does not
2138
+ * exceed the size indicated by imageInfo. See SkImage.h for more on the caveats.
2139
+ *
2140
+ * If dest is not provided, we allocate memory equal to the provided height * the provided
2141
+ * bytesPerRow to fill the data with.
2142
+ *
2143
+ * @param srcX
2144
+ * @param srcY
2145
+ * @param imageInfo - describes the destination format of the pixels.
2146
+ * @param dest - If provided, the pixels will be copied into the allocated buffer allowing
2147
+ * access to the pixels without allocating a new TypedArray.
2148
+ * @param bytesPerRow - number of bytes per row. Must be provided if dest is set. This
2149
+ * depends on destination ColorType. For example, it must be at least 4 * width for
2150
+ * the 8888 color type.
2151
+ * @returns a TypedArray appropriate for the specified ColorType. Note that 16 bit floats are
2152
+ * not supported in JS, so that colorType corresponds to raw bytes Uint8Array.
2153
+ */
2154
+ readPixels(srcX: number, srcY: number, imageInfo: ImageInfo, dest?: MallocObj,
2155
+ bytesPerRow?: number): Float32Array | Uint8Array | null;
2156
+
2157
+ /**
2158
+ * Return the width in pixels of the image.
2159
+ */
2160
+ width(): number;
2161
+ }
2162
+
2163
+ /**
2164
+ * See ImageFilter.h for more on this class. The objects are opaque.
2165
+ */
2166
+ export interface ImageFilter extends EmbindObject<"ImageFilter"> {
2167
+ /**
2168
+ * Returns an IRect that is the updated bounds of inputRect after this
2169
+ * filter has been applied.
2170
+ *
2171
+ * @param drawBounds - The local (pre-transformed) bounding box of the
2172
+ * geometry being drawn _before_ the filter is applied.
2173
+ * @param ctm - If provided, the current transform at the time the filter
2174
+ * would be used.
2175
+ * @param outputRect - If provided, the result will be output to this array
2176
+ * rather than allocating a new one.
2177
+ * @returns an IRect describing the updated bounds.
2178
+ */
2179
+ getOutputBounds(drawBounds: Rect, ctm?: InputMatrix, outputRect?: IRect): IRect;
2180
+ }
2181
+
2182
+ export interface ImageInfo {
2183
+ alphaType: AlphaType;
2184
+ colorSpace: ColorSpace;
2185
+ colorType: ColorType;
2186
+ height: number;
2187
+ width: number;
2188
+ }
2189
+
2190
+ export interface PartialImageInfo {
2191
+ alphaType: AlphaType;
2192
+ colorType: ColorType;
2193
+ height: number;
2194
+ width: number;
2195
+ }
2196
+
2197
+ /*
2198
+ * Specifies sampling with bicubic coefficients
2199
+ */
2200
+ export interface CubicResampler {
2201
+ B: number; // 0..1
2202
+ C: number; // 0..1
2203
+ }
2204
+
2205
+ /**
2206
+ * Specifies sampling using filter and mipmap options
2207
+ */
2208
+ export interface FilterOptions {
2209
+ filter: FilterMode;
2210
+ mipmap?: MipmapMode; // defaults to None if not specified
2211
+ }
2212
+
2213
+ /**
2214
+ * See SkMaskFilter.h for more on this class. The objects are opaque.
2215
+ */
2216
+ export type MaskFilter = EmbindObject<"MaskFilter">;
2217
+
2218
+ /**
2219
+ * See SkPaint.h for more information on this class.
2220
+ */
2221
+ export interface Paint extends EmbindObject<"Paint"> {
2222
+ /**
2223
+ * Returns a copy of this paint.
2224
+ */
2225
+ copy(): Paint;
2226
+
2227
+ /**
2228
+ * Retrieves the alpha and RGB unpremultiplied. RGB are extended sRGB values
2229
+ * (sRGB gamut, and encoded with the sRGB transfer function).
2230
+ */
2231
+ getColor(): Color;
2232
+
2233
+ /**
2234
+ * Returns the geometry drawn at the beginning and end of strokes.
2235
+ */
2236
+ getStrokeCap(): StrokeCap;
2237
+
2238
+ /**
2239
+ * Returns the geometry drawn at the corners of strokes.
2240
+ */
2241
+ getStrokeJoin(): StrokeJoin;
2242
+
2243
+ /**
2244
+ * Returns the limit at which a sharp corner is drawn beveled.
2245
+ */
2246
+ getStrokeMiter(): number;
2247
+
2248
+ /**
2249
+ * Returns the thickness of the pen used to outline the shape.
2250
+ */
2251
+ getStrokeWidth(): number;
2252
+
2253
+ /**
2254
+ * Replaces alpha, leaving RGBA unchanged. 0 means fully transparent, 1.0 means opaque.
2255
+ * @param alpha
2256
+ */
2257
+ setAlphaf(alpha: number): void;
2258
+
2259
+ /**
2260
+ * Requests, but does not require, that edge pixels draw opaque or with
2261
+ * partial transparency.
2262
+ * @param aa
2263
+ */
2264
+ setAntiAlias(aa: boolean): void;
2265
+
2266
+ /**
2267
+ * Sets the blend mode that is, the mode used to combine source color
2268
+ * with destination color.
2269
+ * @param mode
2270
+ */
2271
+ setBlendMode(mode: BlendMode): void;
2272
+
2273
+ /**
2274
+ * Sets the current blender, increasing its refcnt, and if a blender is already
2275
+ * present, decreasing that object's refcnt.
2276
+ *
2277
+ * * A nullptr blender signifies the default SrcOver behavior.
2278
+ *
2279
+ * * For convenience, you can call setBlendMode() if the blend effect can be expressed
2280
+ * as one of those values.
2281
+ * @param blender
2282
+ */
2283
+ setBlender(blender: Blender): void;
2284
+
2285
+ /**
2286
+ * Sets alpha and RGB used when stroking and filling. The color is four floating
2287
+ * point values, unpremultiplied. The color values are interpreted as being in
2288
+ * the provided colorSpace.
2289
+ * @param color
2290
+ * @param colorSpace - defaults to sRGB
2291
+ */
2292
+ setColor(color: InputColor, colorSpace?: ColorSpace): void;
2293
+
2294
+ /**
2295
+ * Sets alpha and RGB used when stroking and filling. The color is four floating
2296
+ * point values, unpremultiplied. The color values are interpreted as being in
2297
+ * the provided colorSpace.
2298
+ * @param r
2299
+ * @param g
2300
+ * @param b
2301
+ * @param a
2302
+ * @param colorSpace - defaults to sRGB
2303
+ */
2304
+ setColorComponents(r: number, g: number, b: number, a: number, colorSpace?: ColorSpace): void;
2305
+
2306
+ /**
2307
+ * Sets the current color filter, replacing the existing one if there was one.
2308
+ * @param filter
2309
+ */
2310
+ setColorFilter(filter: ColorFilter | null): void;
2311
+
2312
+ /**
2313
+ * Sets the color used when stroking and filling. The color values are interpreted as being in
2314
+ * the provided colorSpace.
2315
+ * @param color
2316
+ * @param colorSpace - defaults to sRGB.
2317
+ */
2318
+ setColorInt(color: ColorInt, colorSpace?: ColorSpace): void;
2319
+
2320
+ /**
2321
+ * Requests, but does not require, to distribute color error.
2322
+ * @param shouldDither
2323
+ */
2324
+ setDither(shouldDither: boolean): void;
2325
+
2326
+ /**
2327
+ * Sets the current image filter, replacing the existing one if there was one.
2328
+ * @param filter
2329
+ */
2330
+ setImageFilter(filter: ImageFilter | null): void;
2331
+
2332
+ /**
2333
+ * Sets the current mask filter, replacing the existing one if there was one.
2334
+ * @param filter
2335
+ */
2336
+ setMaskFilter(filter: MaskFilter | null): void;
2337
+
2338
+ /**
2339
+ * Sets the current path effect, replacing the existing one if there was one.
2340
+ * @param effect
2341
+ */
2342
+ setPathEffect(effect: PathEffect | null): void;
2343
+
2344
+ /**
2345
+ * Sets the current shader, replacing the existing one if there was one.
2346
+ * @param shader
2347
+ */
2348
+ setShader(shader: Shader | null): void;
2349
+
2350
+ /**
2351
+ * Sets the geometry drawn at the beginning and end of strokes.
2352
+ * @param cap
2353
+ */
2354
+ setStrokeCap(cap: StrokeCap): void;
2355
+
2356
+ /**
2357
+ * Sets the geometry drawn at the corners of strokes.
2358
+ * @param join
2359
+ */
2360
+ setStrokeJoin(join: StrokeJoin): void;
2361
+
2362
+ /**
2363
+ * Sets the limit at which a sharp corner is drawn beveled.
2364
+ * @param limit
2365
+ */
2366
+ setStrokeMiter(limit: number): void;
2367
+
2368
+ /**
2369
+ * Sets the thickness of the pen used to outline the shape.
2370
+ * @param width
2371
+ */
2372
+ setStrokeWidth(width: number): void;
2373
+
2374
+ /**
2375
+ * Sets whether the geometry is filled or stroked.
2376
+ * @param style
2377
+ */
2378
+ setStyle(style: PaintStyle): void;
2379
+ }
2380
+
2381
+ /**
2382
+ * See SkPath.h for more information on this class.
2383
+ */
2384
+ export interface Path extends EmbindObject<"Path"> {
2385
+ /**
2386
+ * Appends arc to Path, as the start of new contour. Arc added is part of ellipse
2387
+ * bounded by oval, from startAngle through sweepAngle. Both startAngle and
2388
+ * sweepAngle are measured in degrees, where zero degrees is aligned with the
2389
+ * positive x-axis, and positive sweeps extends arc clockwise.
2390
+ * Returns the modified path for easier chaining.
2391
+ * @param oval
2392
+ * @param startAngle
2393
+ * @param sweepAngle
2394
+ */
2395
+ addArc(oval: InputRect, startAngle: AngleInDegrees, sweepAngle: AngleInDegrees): Path;
2396
+
2397
+ /**
2398
+ * Adds circle centered at (x, y) of size radius to the path.
2399
+ * Has no effect if radius is zero or negative.
2400
+ *
2401
+ * @param x center of circle
2402
+ * @param y center of circle
2403
+ * @param radius distance from center to edge
2404
+ * @param isCCW - if the path should be drawn counter-clockwise or not
2405
+ * @return reference to SkPath
2406
+ */
2407
+ addCircle(x: number, y: number, r: number, isCCW?: boolean): Path;
2408
+
2409
+ /**
2410
+ * Adds oval to Path, appending kMove_Verb, four kConic_Verb, and kClose_Verb.
2411
+ * Oval is upright ellipse bounded by Rect oval with radii equal to half oval width
2412
+ * and half oval height. Oval begins at start and continues clockwise by default.
2413
+ * Returns the modified path for easier chaining.
2414
+ * @param oval
2415
+ * @param isCCW - if the path should be drawn counter-clockwise or not
2416
+ * @param startIndex - index of initial point of ellipse
2417
+ */
2418
+ addOval(oval: InputRect, isCCW?: boolean, startIndex?: number): Path;
2419
+
2420
+ /**
2421
+ * Takes 1, 2, 7, or 10 required args, where the first arg is always the path.
2422
+ * The last arg is an optional boolean and chooses between add or extend mode.
2423
+ * The options for the remaining args are:
2424
+ * - an array of 6 or 9 parameters (perspective is optional)
2425
+ * - the 9 parameters of a full matrix or
2426
+ * the 6 non-perspective params of a matrix.
2427
+ * Returns the modified path for easier chaining (or null if params were incorrect).
2428
+ * @param args
2429
+ */
2430
+ addPath(...args: any[]): Path | null;
2431
+
2432
+ /**
2433
+ * Adds contour created from array of n points, adding (count - 1) line segments.
2434
+ * Contour added starts at pts[0], then adds a line for every additional point
2435
+ * in pts array. If close is true, appends kClose_Verb to Path, connecting
2436
+ * pts[count - 1] and pts[0].
2437
+ * Returns the modified path for easier chaining.
2438
+ * @param points
2439
+ * @param close - if true, will add a line connecting last point to the first point.
2440
+ */
2441
+ addPoly(points: InputFlattenedPointArray, close: boolean): Path;
2442
+
2443
+ /**
2444
+ * Adds Rect to Path, appending kMove_Verb, three kLine_Verb, and kClose_Verb,
2445
+ * starting with top-left corner of Rect; followed by top-right, bottom-right,
2446
+ * and bottom-left if isCCW is false; or followed by bottom-left,
2447
+ * bottom-right, and top-right if isCCW is true.
2448
+ * Returns the modified path for easier chaining.
2449
+ * @param rect
2450
+ * @param isCCW
2451
+ */
2452
+ addRect(rect: InputRect, isCCW?: boolean): Path;
2453
+
2454
+ /**
2455
+ * Adds rrect to Path, creating a new closed contour.
2456
+ * Returns the modified path for easier chaining.
2457
+ * @param rrect
2458
+ * @param isCCW
2459
+ */
2460
+ addRRect(rrect: InputRRect, isCCW?: boolean): Path;
2461
+
2462
+ /**
2463
+ * Adds the given verbs and associated points/weights to the path. The process
2464
+ * reads the first verb from verbs and then the appropriate number of points from the
2465
+ * FlattenedPointArray (e.g. 2 points for moveTo, 4 points for quadTo, etc). If the verb is
2466
+ * a conic, a weight will be read from the WeightList.
2467
+ * Returns the modified path for easier chaining
2468
+ * @param verbs - the verbs that create this path, in the order of being drawn.
2469
+ * @param points - represents n points with 2n floats.
2470
+ * @param weights - used if any of the verbs are conics, can be omitted otherwise.
2471
+ */
2472
+ addVerbsPointsWeights(verbs: VerbList, points: InputFlattenedPointArray,
2473
+ weights?: WeightList): Path;
2474
+
2475
+ /**
2476
+ * Adds an arc to this path, emulating the Canvas2D behavior.
2477
+ * Returns the modified path for easier chaining.
2478
+ * @param x
2479
+ * @param y
2480
+ * @param radius
2481
+ * @param startAngle
2482
+ * @param endAngle
2483
+ * @param isCCW
2484
+ */
2485
+ arc(x: number, y: number, radius: number, startAngle: AngleInRadians, endAngle: AngleInRadians,
2486
+ isCCW?: boolean): Path;
2487
+
2488
+ /**
2489
+ * Appends arc to Path. Arc added is part of ellipse
2490
+ * bounded by oval, from startAngle through sweepAngle. Both startAngle and
2491
+ * sweepAngle are measured in degrees, where zero degrees is aligned with the
2492
+ * positive x-axis, and positive sweeps extends arc clockwise.
2493
+ * Returns the modified path for easier chaining.
2494
+ * @param oval
2495
+ * @param startAngle
2496
+ * @param endAngle
2497
+ * @param forceMoveTo
2498
+ */
2499
+ arcToOval(oval: InputRect, startAngle: AngleInDegrees, endAngle: AngleInDegrees,
2500
+ forceMoveTo: boolean): Path;
2501
+
2502
+ /**
2503
+ * Appends arc to Path. Arc is implemented by one or more conics weighted to
2504
+ * describe part of oval with radii (rx, ry) rotated by xAxisRotate degrees. Arc
2505
+ * curves from last Path Point to (x, y), choosing one of four possible routes:
2506
+ * clockwise or counterclockwise, and smaller or larger. See SkPath.h for more details.
2507
+ * Returns the modified path for easier chaining.
2508
+ * @param rx
2509
+ * @param ry
2510
+ * @param xAxisRotate
2511
+ * @param useSmallArc
2512
+ * @param isCCW
2513
+ * @param x
2514
+ * @param y
2515
+ */
2516
+ arcToRotated(rx: number, ry: number, xAxisRotate: AngleInDegrees, useSmallArc: boolean,
2517
+ isCCW: boolean, x: number, y: number): Path;
2518
+
2519
+ /**
2520
+ * Appends arc to Path, after appending line if needed. Arc is implemented by conic
2521
+ * weighted to describe part of circle. Arc is contained by tangent from
2522
+ * last Path point to (x1, y1), and tangent from (x1, y1) to (x2, y2). Arc
2523
+ * is part of circle sized to radius, positioned so it touches both tangent lines.
2524
+ * Returns the modified path for easier chaining.
2525
+ * @param x1
2526
+ * @param y1
2527
+ * @param x2
2528
+ * @param y2
2529
+ * @param radius
2530
+ */
2531
+ arcToTangent(x1: number, y1: number, x2: number, y2: number, radius: number): Path;
2532
+
2533
+ /**
2534
+ * Appends CLOSE_VERB to Path. A closed contour connects the first and last point
2535
+ * with a line, forming a continuous loop.
2536
+ * Returns the modified path for easier chaining.
2537
+ */
2538
+ close(): Path;
2539
+
2540
+ /**
2541
+ * Returns minimum and maximum axes values of the lines and curves in Path.
2542
+ * Returns (0, 0, 0, 0) if Path contains no points.
2543
+ * Returned bounds width and height may be larger or smaller than area affected
2544
+ * when Path is drawn.
2545
+ *
2546
+ * Behaves identically to getBounds() when Path contains
2547
+ * only lines. If Path contains curves, computed bounds includes
2548
+ * the maximum extent of the quad, conic, or cubic; is slower than getBounds();
2549
+ * and unlike getBounds(), does not cache the result.
2550
+ * @param outputArray - if provided, the bounding box will be copied into this array instead of
2551
+ * allocating a new one.
2552
+ */
2553
+ computeTightBounds(outputArray?: Rect): Rect;
2554
+
2555
+ /**
2556
+ * Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.
2557
+ * If Path is empty, or path is closed, the last point is set to (0, 0)
2558
+ * before adding conic.
2559
+ * Returns the modified path for easier chaining.
2560
+ * @param x1
2561
+ * @param y1
2562
+ * @param x2
2563
+ * @param y2
2564
+ * @param w
2565
+ */
2566
+ conicTo(x1: number, y1: number, x2: number, y2: number, w: number): Path;
2567
+
2568
+ /**
2569
+ * Returns true if the point (x, y) is contained by Path, taking into
2570
+ * account FillType.
2571
+ * @param x
2572
+ * @param y
2573
+ */
2574
+ contains(x: number, y: number): boolean;
2575
+
2576
+ /**
2577
+ * Returns a copy of this Path.
2578
+ */
2579
+ copy(): Path;
2580
+
2581
+ /**
2582
+ * Returns the number of points in this path. Initially zero.
2583
+ */
2584
+ countPoints(): number;
2585
+
2586
+ /**
2587
+ * Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at
2588
+ * (x3, y3). If Path is empty, or path is closed, the last point is set to
2589
+ * (0, 0) before adding cubic.
2590
+ * @param cpx1
2591
+ * @param cpy1
2592
+ * @param cpx2
2593
+ * @param cpy2
2594
+ * @param x
2595
+ * @param y
2596
+ */
2597
+ cubicTo(cpx1: number, cpy1: number, cpx2: number, cpy2: number, x: number, y: number): Path;
2598
+
2599
+ /**
2600
+ * Changes this path to be the dashed version of itself. This is the same effect as creating
2601
+ * a DashPathEffect and calling filterPath on this path.
2602
+ * @param on
2603
+ * @param off
2604
+ * @param phase
2605
+ */
2606
+ dash(on: number, off: number, phase: number): boolean;
2607
+
2608
+ /**
2609
+ * Returns true if other path is equal to this path.
2610
+ * @param other
2611
+ */
2612
+ equals(other: Path): boolean;
2613
+
2614
+ /**
2615
+ * Returns minimum and maximum axes values of Point array.
2616
+ * Returns (0, 0, 0, 0) if Path contains no points. Returned bounds width and height may
2617
+ * be larger or smaller than area affected when Path is drawn.
2618
+ * @param outputArray - if provided, the bounding box will be copied into this array instead of
2619
+ * allocating a new one.
2620
+ */
2621
+ getBounds(outputArray?: Rect): Rect;
2622
+
2623
+ /**
2624
+ * Return the FillType for this path.
2625
+ */
2626
+ getFillType(): FillType;
2627
+
2628
+ /**
2629
+ * Returns the Point at index in Point array. Valid range for index is
2630
+ * 0 to countPoints() - 1.
2631
+ * @param index
2632
+ * @param outputArray - if provided, the point will be copied into this array instead of
2633
+ * allocating a new one.
2634
+ */
2635
+ getPoint(index: number, outputArray?: Point): Point;
2636
+
2637
+ /**
2638
+ * Returns true if there are no verbs in the path.
2639
+ */
2640
+ isEmpty(): boolean;
2641
+
2642
+ /**
2643
+ * Returns true if the path is volatile; it will not be altered or discarded
2644
+ * by the caller after it is drawn. Path by default have volatile set false, allowing
2645
+ * Surface to attach a cache of data which speeds repeated drawing. If true, Surface
2646
+ * may not speed repeated drawing.
2647
+ */
2648
+ isVolatile(): boolean;
2649
+
2650
+ /**
2651
+ * Adds line from last point to (x, y). If Path is empty, or last path is closed,
2652
+ * last point is set to (0, 0) before adding line.
2653
+ * Returns the modified path for easier chaining.
2654
+ * @param x
2655
+ * @param y
2656
+ */
2657
+ lineTo(x: number, y: number): Path;
2658
+
2659
+ /**
2660
+ * Returns a new path that covers the same area as the original path, but with the
2661
+ * Winding FillType. This may re-draw some contours in the path as counter-clockwise
2662
+ * instead of clockwise to achieve that effect. If such a transformation cannot
2663
+ * be done, null is returned.
2664
+ */
2665
+ makeAsWinding(): Path | null;
2666
+
2667
+ /**
2668
+ * Adds beginning of contour at the given point.
2669
+ * Returns the modified path for easier chaining.
2670
+ * @param x
2671
+ * @param y
2672
+ */
2673
+ moveTo(x: number, y: number): Path;
2674
+
2675
+ /**
2676
+ * Translates all the points in the path by dx, dy.
2677
+ * Returns the modified path for easier chaining.
2678
+ * @param dx
2679
+ * @param dy
2680
+ */
2681
+ offset(dx: number, dy: number): Path;
2682
+
2683
+ /**
2684
+ * Combines this path with the other path using the given PathOp. Returns false if the operation
2685
+ * fails.
2686
+ * @param other
2687
+ * @param op
2688
+ */
2689
+ op(other: Path, op: PathOp): boolean;
2690
+
2691
+ /**
2692
+ * Adds quad from last point towards (x1, y1), to (x2, y2).
2693
+ * If Path is empty, or path is closed, last point is set to (0, 0) before adding quad.
2694
+ * Returns the modified path for easier chaining.
2695
+ * @param x1
2696
+ * @param y1
2697
+ * @param x2
2698
+ * @param y2
2699
+ */
2700
+ quadTo(x1: number, y1: number, x2: number, y2: number): Path;
2701
+
2702
+ /**
2703
+ * Relative version of arcToRotated.
2704
+ * @param rx
2705
+ * @param ry
2706
+ * @param xAxisRotate
2707
+ * @param useSmallArc
2708
+ * @param isCCW
2709
+ * @param dx
2710
+ * @param dy
2711
+ */
2712
+ rArcTo(rx: number, ry: number, xAxisRotate: AngleInDegrees, useSmallArc: boolean,
2713
+ isCCW: boolean, dx: number, dy: number): Path;
2714
+
2715
+ /**
2716
+ * Relative version of conicTo.
2717
+ * @param dx1
2718
+ * @param dy1
2719
+ * @param dx2
2720
+ * @param dy2
2721
+ * @param w
2722
+ */
2723
+ rConicTo(dx1: number, dy1: number, dx2: number, dy2: number, w: number): Path;
2724
+
2725
+ /**
2726
+ * Relative version of cubicTo.
2727
+ * @param cpx1
2728
+ * @param cpy1
2729
+ * @param cpx2
2730
+ * @param cpy2
2731
+ * @param x
2732
+ * @param y
2733
+ */
2734
+ rCubicTo(cpx1: number, cpy1: number, cpx2: number, cpy2: number, x: number, y: number): Path;
2735
+
2736
+ /**
2737
+ * Sets Path to its initial state.
2738
+ * Removes verb array, point array, and weights, and sets FillType to Winding.
2739
+ * Internal storage associated with Path is released
2740
+ */
2741
+ reset(): void;
2742
+
2743
+ /**
2744
+ * Sets Path to its initial state.
2745
+ * Removes verb array, point array, and weights, and sets FillType to Winding.
2746
+ * Internal storage associated with Path is *not* released.
2747
+ * Use rewind() instead of reset() if Path storage will be reused and performance
2748
+ * is critical.
2749
+ */
2750
+ rewind(): void;
2751
+
2752
+ /**
2753
+ * Relative version of lineTo.
2754
+ * @param x
2755
+ * @param y
2756
+ */
2757
+ rLineTo(x: number, y: number): Path;
2758
+
2759
+ /**
2760
+ * Relative version of moveTo.
2761
+ * @param x
2762
+ * @param y
2763
+ */
2764
+ rMoveTo(x: number, y: number): Path;
2765
+
2766
+ /**
2767
+ * Relative version of quadTo.
2768
+ * @param x1
2769
+ * @param y1
2770
+ * @param x2
2771
+ * @param y2
2772
+ */
2773
+ rQuadTo(x1: number, y1: number, x2: number, y2: number): Path;
2774
+
2775
+ /**
2776
+ * Sets FillType, the rule used to fill Path.
2777
+ * @param fill
2778
+ */
2779
+ setFillType(fill: FillType): void;
2780
+
2781
+ /**
2782
+ * Specifies whether Path is volatile; whether it will be altered or discarded
2783
+ * by the caller after it is drawn. Path by default have volatile set false.
2784
+ *
2785
+ * Mark animating or temporary paths as volatile to improve performance.
2786
+ * Mark unchanging Path non-volatile to improve repeated rendering.
2787
+ * @param volatile
2788
+ */
2789
+ setIsVolatile(volatile: boolean): void;
2790
+
2791
+ /**
2792
+ * Set this path to a set of non-overlapping contours that describe the
2793
+ * same area as the original path.
2794
+ * The curve order is reduced where possible so that cubics may
2795
+ * be turned into quadratics, and quadratics maybe turned into lines.
2796
+ *
2797
+ * Returns true if operation was able to produce a result.
2798
+ */
2799
+ simplify(): boolean;
2800
+
2801
+ /**
2802
+ * Turns this path into the filled equivalent of the stroked path. Returns null if the operation
2803
+ * fails (e.g. the path is a hairline).
2804
+ * @param opts - describe how stroked path should look.
2805
+ */
2806
+ stroke(opts?: StrokeOpts): Path | null;
2807
+
2808
+ /**
2809
+ * Serializes the contents of this path as a series of commands.
2810
+ * The first item will be a verb, followed by any number of arguments needed. Then it will
2811
+ * be followed by another verb, more arguments and so on.
2812
+ */
2813
+ toCmds(): Float32Array;
2814
+
2815
+ /**
2816
+ * Returns this path as an SVG string.
2817
+ */
2818
+ toSVGString(): string;
2819
+
2820
+ /**
2821
+ * Takes a 3x3 matrix as either an array or as 9 individual params.
2822
+ * @param args
2823
+ */
2824
+ transform(...args: any[]): Path;
2825
+
2826
+ /**
2827
+ * Take start and stop "t" values (values between 0...1), and modify this path such that
2828
+ * it is a subset of the original path.
2829
+ * The trim values apply to the entire path, so if it contains several contours, all of them
2830
+ * are including in the calculation.
2831
+ * Null is returned if either input value is NaN.
2832
+ * @param startT - a value in the range [0.0, 1.0]. 0.0 is the beginning of the path.
2833
+ * @param stopT - a value in the range [0.0, 1.0]. 1.0 is the end of the path.
2834
+ * @param isComplement
2835
+ */
2836
+ trim(startT: number, stopT: number, isComplement: boolean): Path | null;
2837
+ }
2838
+
2839
+ /**
2840
+ * See SkPathEffect.h for more on this class. The objects are opaque.
2841
+ */
2842
+ export type PathEffect = EmbindObject<"PathEffect">;
2843
+
2844
+ /**
2845
+ * See SkPicture.h for more information on this class.
2846
+ *
2847
+ * Of note, SkPicture is *not* what is colloquially thought of as a "picture" (what we
2848
+ * call a bitmap). An SkPicture is a series of draw commands.
2849
+ */
2850
+ export interface SkPicture extends EmbindObject<"SkPicture"> {
2851
+ /**
2852
+ * Returns a new shader that will draw with this picture.
2853
+ *
2854
+ * @param tmx The tiling mode to use when sampling in the x-direction.
2855
+ * @param tmy The tiling mode to use when sampling in the y-direction.
2856
+ * @param mode How to filter the tiles
2857
+ * @param localMatrix Optional matrix used when sampling
2858
+ * @param tileRect The tile rectangle in picture coordinates: this represents the subset
2859
+ * (or superset) of the picture used when building a tile. It is not
2860
+ * affected by localMatrix and does not imply scaling (only translation
2861
+ * and cropping). If null, the tile rect is considered equal to the picture
2862
+ * bounds.
2863
+ */
2864
+ makeShader(tmx: TileMode, tmy: TileMode, mode: FilterMode,
2865
+ localMatrix?: InputMatrix, tileRect?: InputRect): Shader;
2866
+
2867
+ /**
2868
+ * Return the bounding area for the Picture.
2869
+ * @param outputArray - if provided, the bounding box will be copied into this array instead of
2870
+ * allocating a new one.
2871
+ */
2872
+ cullRect(outputArray?: Rect): Rect;
2873
+
2874
+ /**
2875
+ * Returns the approximate byte size. Does not include large objects.
2876
+ */
2877
+ approximateBytesUsed(): number;
2878
+
2879
+ /**
2880
+ * Returns the serialized format of this SkPicture. The format may change at anytime and
2881
+ * no promises are made for backwards or forward compatibility.
2882
+ */
2883
+ serialize(): Uint8Array | null;
2884
+ }
2885
+
2886
+ export interface PictureRecorder extends EmbindObject<"PictureRecorder"> {
2887
+ /**
2888
+ * Returns a canvas on which to draw. When done drawing, call finishRecordingAsPicture()
2889
+ *
2890
+ * @param bounds - a rect to cull the results.
2891
+ * @param computeBounds - Optional boolean (default false) which tells the
2892
+ * recorder to compute a more accurate bounds for the
2893
+ * cullRect of the picture.
2894
+ */
2895
+ beginRecording(bounds: InputRect, computeBounds?: boolean): Canvas;
2896
+
2897
+ /**
2898
+ * Returns the captured draw commands as a picture and invalidates the canvas returned earlier.
2899
+ */
2900
+ finishRecordingAsPicture(): SkPicture;
2901
+ }
2902
+
2903
+ /**
2904
+ * See SkRuntimeEffect.h for more details.
2905
+ */
2906
+ export interface RuntimeEffect extends EmbindObject<"RuntimeEffect"> {
2907
+ /**
2908
+ * Returns a shader executed using the given uniform data.
2909
+ * @param uniforms
2910
+ */
2911
+ makeBlender(uniforms: Float32Array | number[] | MallocObj): Blender;
2912
+
2913
+ /**
2914
+ * Returns a shader executed using the given uniform data.
2915
+ * @param uniforms
2916
+ * @param localMatrix
2917
+ */
2918
+ makeShader(uniforms: Float32Array | number[] | MallocObj,
2919
+ localMatrix?: InputMatrix): Shader;
2920
+
2921
+ /**
2922
+ * Returns a shader executed using the given uniform data and the children as inputs.
2923
+ * @param uniforms
2924
+ * @param children
2925
+ * @param localMatrix
2926
+ */
2927
+ makeShaderWithChildren(uniforms: Float32Array | number[] | MallocObj,
2928
+ children?: Shader[], localMatrix?: InputMatrix): Shader;
2929
+
2930
+ /**
2931
+ * Returns the nth uniform from the effect.
2932
+ * @param index
2933
+ */
2934
+ getUniform(index: number): SkSLUniform;
2935
+
2936
+ /**
2937
+ * Returns the number of uniforms on the effect.
2938
+ */
2939
+ getUniformCount(): number;
2940
+
2941
+ /**
2942
+ * Returns the total number of floats across all uniforms on the effect. This is the length
2943
+ * of the uniforms array expected by makeShader. For example, an effect with a single float3
2944
+ * uniform, would return 1 from `getUniformCount()`, but 3 from `getUniformFloatCount()`.
2945
+ */
2946
+ getUniformFloatCount(): number;
2947
+
2948
+ /**
2949
+ * Returns the name of the nth effect uniform.
2950
+ * @param index
2951
+ */
2952
+ getUniformName(index: number): string;
2953
+ }
2954
+
2955
+ /**
2956
+ * See SkShader.h for more on this class. The objects are opaque.
2957
+ */
2958
+ export type Shader = EmbindObject<"Shader">;
2959
+
2960
+ export interface Surface extends EmbindObject<"Surface"> {
2961
+ /**
2962
+ * A convenient way to draw exactly once on the canvas associated with this surface.
2963
+ * This requires an environment where a global function called requestAnimationFrame is
2964
+ * available (e.g. on the web, not on Node). Users do not need to flush the surface,
2965
+ * or delete/dispose of it as that is taken care of automatically with this wrapper.
2966
+ *
2967
+ * Node users should call getCanvas() and work with that canvas directly.
2968
+ */
2969
+ drawOnce(drawFrame: (_: Canvas) => void): void;
2970
+
2971
+ /**
2972
+ * Clean up the surface and any extra memory.
2973
+ * [Deprecated]: In the future, calls to delete() will be sufficient to clean up the memory.
2974
+ */
2975
+ dispose(): void;
2976
+
2977
+ /**
2978
+ * Make sure any queued draws are sent to the screen or the GPU.
2979
+ */
2980
+ flush(): void;
2981
+
2982
+ /**
2983
+ * Return a canvas that is backed by this surface. Any draws to the canvas will (eventually)
2984
+ * show up on the surface. The returned canvas is owned by the surface and does NOT need to
2985
+ * be cleaned up by the client.
2986
+ */
2987
+ getCanvas(): Canvas;
2988
+
2989
+ /**
2990
+ * Returns the height of this surface in pixels.
2991
+ */
2992
+ height(): number;
2993
+
2994
+ /**
2995
+ * Returns the ImageInfo associated with this surface.
2996
+ */
2997
+ imageInfo(): ImageInfo;
2998
+
2999
+ /**
3000
+ * Creates an Image from the provided texture and info. The Image will own the texture;
3001
+ * when the image is deleted, the texture will be cleaned up.
3002
+ * @param tex
3003
+ * @param info - describes the content of the texture.
3004
+ */
3005
+ makeImageFromTexture(tex: WebGLTexture, info: ImageInfo): Image | null;
3006
+
3007
+ /**
3008
+ * Returns a texture-backed image based on the content in src. It uses RGBA_8888, unpremul
3009
+ * and SRGB - for more control, use makeImageFromTexture.
3010
+ *
3011
+ * The underlying texture for this image will be created immediately from src, so
3012
+ * it can be disposed of after this call. This image will *only* be usable for this
3013
+ * surface (because WebGL textures are not transferable to other WebGL contexts).
3014
+ * For an image that can be used across multiple surfaces, at the cost of being lazily
3015
+ * loaded, see MakeLazyImageFromTextureSource.
3016
+ *
3017
+ * Not available for software-backed surfaces.
3018
+ * @param src
3019
+ * @param info - If provided, will be used to determine the width/height/format of the
3020
+ * source image. If not, sensible defaults will be used.
3021
+ * @param srcIsPremul - set to true if the src data has premultiplied alpha. Otherwise, it will
3022
+ * be assumed to be Unpremultiplied. Note: if this is true and info specifies
3023
+ * Unpremul, Skia will not convert the src pixels first.
3024
+ */
3025
+ makeImageFromTextureSource(src: TextureSource, info?: ImageInfo | PartialImageInfo,
3026
+ srcIsPremul?: boolean): Image | null;
3027
+
3028
+ /**
3029
+ * Returns current contents of the surface as an Image. This image will be optimized to be
3030
+ * drawn to another surface of the same type. For example, if this surface is backed by the
3031
+ * GPU, the returned Image will be backed by a GPU texture.
3032
+ */
3033
+ makeImageSnapshot(bounds?: InputIRect): Image;
3034
+
3035
+ /**
3036
+ * Returns a compatible Surface, haring the same raster or GPU properties of the original.
3037
+ * The pixels are not shared.
3038
+ * @param info - width, height, etc of the Surface.
3039
+ */
3040
+ makeSurface(info: ImageInfo): Surface;
3041
+
3042
+ /**
3043
+ * Returns if this Surface is a GPU-backed surface or not.
3044
+ */
3045
+ reportBackendTypeIsGPU(): boolean;
3046
+
3047
+ /**
3048
+ * A convenient way to draw multiple frames on the canvas associated with this surface.
3049
+ * This requires an environment where a global function called requestAnimationFrame is
3050
+ * available (e.g. on the web, not on Node). Users do not need to flush the surface,
3051
+ * as that is taken care of automatically with this wrapper.
3052
+ *
3053
+ * Users should probably call surface.requestAnimationFrame in the callback function to
3054
+ * draw multiple frames, e.g. of an animation.
3055
+ *
3056
+ * Node users should call getCanvas() and work with that canvas directly.
3057
+ *
3058
+ * Returns the animation id.
3059
+ */
3060
+ requestAnimationFrame(drawFrame: (_: Canvas) => void): number;
3061
+
3062
+ /**
3063
+ * If this surface is GPU-backed, return the sample count of the surface.
3064
+ */
3065
+ sampleCnt(): number;
3066
+
3067
+ /**
3068
+ * Updates the underlying GPU texture of the image to be the contents of the provided
3069
+ * TextureSource. Has no effect on CPU backend or if img was not created with either
3070
+ * makeImageFromTextureSource or makeImageFromTexture.
3071
+ * If the provided TextureSource is of different dimensions than the Image, the contents
3072
+ * will be deformed (e.g. squished). The ColorType, AlphaType, and ColorSpace of src should
3073
+ * match the original settings used to create the Image or it may draw strange.
3074
+ *
3075
+ * @param img - A texture-backed Image.
3076
+ * @param src - A valid texture source of any dimensions.
3077
+ * @param srcIsPremul - set to true if the src data has premultiplied alpha. Otherwise, it will
3078
+ * be assumed to be Unpremultiplied. Note: if this is true and the image was
3079
+ * created with Unpremul, Skia will not convert.
3080
+ */
3081
+ updateTextureFromSource(img: Image, src: TextureSource, srcIsPremul?: boolean): void;
3082
+
3083
+ /**
3084
+ * Returns the width of this surface in pixels.
3085
+ */
3086
+ width(): number;
3087
+ }
3088
+
3089
+ /**
3090
+ * See SkTextBlob.h for more on this class. The objects are opaque.
3091
+ */
3092
+ export type TextBlob = EmbindObject<"TextBlob">;
3093
+
3094
+ /**
3095
+ * See SkTypeface.h for more on this class. The objects are opaque.
3096
+ */
3097
+ export interface Typeface extends EmbindObject<"Typeface"> {
3098
+ /**
3099
+ * Retrieves the glyph ids for each code point in the provided string. Note that glyph IDs
3100
+ * are typeface-dependent; different faces may have different ids for the same code point.
3101
+ * @param str
3102
+ * @param numCodePoints - the number of code points in the string. Defaults to str.length.
3103
+ * @param output - if provided, the results will be copied into this array.
3104
+ */
3105
+ getGlyphIDs(str: string, numCodePoints?: number,
3106
+ output?: GlyphIDArray): GlyphIDArray;
3107
+ }
3108
+
3109
+ /**
3110
+ * See SkVertices.h for more on this class.
3111
+ */
3112
+ export interface Vertices extends EmbindObject<"Vertices"> {
3113
+ /**
3114
+ * Return the bounding area for the vertices.
3115
+ * @param outputArray - if provided, the bounding box will be copied into this array instead of
3116
+ * allocating a new one.
3117
+ */
3118
+ bounds(outputArray?: Rect): Rect;
3119
+
3120
+ /**
3121
+ * Return a unique ID for this vertices object.
3122
+ */
3123
+ uniqueID(): number;
3124
+ }
3125
+
3126
+ export interface SkottieAnimation extends EmbindObject<"SkottieAnimation"> {
3127
+ /**
3128
+ * Returns the animation duration in seconds.
3129
+ */
3130
+ duration(): number;
3131
+ /**
3132
+ * Returns the animation frame rate (frames / second).
3133
+ */
3134
+ fps(): number;
3135
+
3136
+ /**
3137
+ * Draws current animation frame. Must call seek or seekFrame first.
3138
+ * @param canvas
3139
+ * @param dstRect
3140
+ */
3141
+ render(canvas: Canvas, dstRect?: InputRect): void;
3142
+
3143
+ /**
3144
+ * [deprecated] - use seekFrame
3145
+ * @param t - value from [0.0, 1.0]; 0 is first frame, 1 is final frame.
3146
+ * @param damageRect - will copy damage frame into this if provided.
3147
+ */
3148
+ seek(t: number, damageRect?: Rect): Rect;
3149
+
3150
+ /**
3151
+ * Update the animation state to match |t|, specified as a frame index
3152
+ * i.e. relative to duration() * fps().
3153
+ *
3154
+ * Returns the rectangle that was affected by this animation.
3155
+ *
3156
+ * @param frame - Fractional values are allowed and meaningful - e.g.
3157
+ * 0.0 -> first frame
3158
+ * 1.0 -> second frame
3159
+ * 0.5 -> halfway between first and second frame
3160
+ * @param damageRect - will copy damage frame into this if provided.
3161
+ */
3162
+ seekFrame(frame: number, damageRect?: Rect): Rect;
3163
+
3164
+ /**
3165
+ * Return the size of this animation.
3166
+ * @param outputSize - If provided, the size will be copied into here as width, height.
3167
+ */
3168
+ size(outputSize?: Point): Point;
3169
+ version(): string;
3170
+ }
3171
+
3172
+ /**
3173
+ * Options used for Path.stroke(). If an option is omitted, a sensible default will be used.
3174
+ */
3175
+ export interface StrokeOpts {
3176
+ /** The width of the stroked lines. */
3177
+ width?: number;
3178
+ miter_limit?: number;
3179
+ /**
3180
+ * if > 1, increase precision, else if (0 < resScale < 1) reduce precision to
3181
+ * favor speed and size
3182
+ */
3183
+ precision?: number;
3184
+ join?: StrokeJoin;
3185
+ cap?: StrokeCap;
3186
+ }
3187
+
3188
+ export interface StrutStyle {
3189
+ strutEnabled?: boolean;
3190
+ fontFamilies?: string[];
3191
+ fontStyle?: FontStyle;
3192
+ fontSize?: number;
3193
+ heightMultiplier?: number;
3194
+ halfLeading?: boolean;
3195
+ leading?: number;
3196
+ forceStrutHeight?: boolean;
3197
+ }
3198
+
3199
+ export interface TextFontFeatures {
3200
+ name: string;
3201
+ value: number;
3202
+ }
3203
+
3204
+ export interface TextFontVariations {
3205
+ axis: string;
3206
+ value: number;
3207
+ }
3208
+
3209
+ export interface TextShadow {
3210
+ color?: InputColor;
3211
+ /**
3212
+ * 2d array for x and y offset. Defaults to [0, 0]
3213
+ */
3214
+ offset?: number[];
3215
+ blurRadius?: number;
3216
+ }
3217
+
3218
+ export interface TextStyle {
3219
+ backgroundColor?: InputColor;
3220
+ color?: InputColor;
3221
+ decoration?: number;
3222
+ decorationColor?: InputColor;
3223
+ decorationThickness?: number;
3224
+ decorationStyle?: DecorationStyle;
3225
+ fontFamilies?: string[];
3226
+ fontFeatures?: TextFontFeatures[];
3227
+ fontSize?: number;
3228
+ fontStyle?: FontStyle;
3229
+ fontVariations?: TextFontVariations[];
3230
+ foregroundColor?: InputColor;
3231
+ heightMultiplier?: number;
3232
+ halfLeading?: boolean;
3233
+ letterSpacing?: number;
3234
+ locale?: string;
3235
+ shadows?: TextShadow[];
3236
+ textBaseline?: TextBaseline;
3237
+ wordSpacing?: number;
3238
+ }
3239
+
3240
+ export interface TonalColorsInput {
3241
+ ambient: InputColor;
3242
+ spot: InputColor;
3243
+ }
3244
+
3245
+ export interface TonalColorsOutput {
3246
+ ambient: Color;
3247
+ spot: Color;
3248
+ }
3249
+
3250
+ export interface TypefaceFontProvider extends FontMgr {
3251
+ /**
3252
+ * Registers a given typeface with the given family name (ignoring whatever name the
3253
+ * typface has for itself).
3254
+ * @param bytes - the raw bytes for a typeface.
3255
+ * @param family
3256
+ */
3257
+ registerFont(bytes: ArrayBuffer | Uint8Array, family: string): void;
3258
+ }
3259
+
3260
+ /**
3261
+ * See FontCollection.h in SkParagraph for more details
3262
+ */
3263
+ export interface FontCollection extends EmbindObject<"FontCollection"> {
3264
+ /**
3265
+ * Enable fallback to dynamically discovered fonts for characters that are not handled
3266
+ * by the text style's fonts.
3267
+ */
3268
+ enableFontFallback(): void;
3269
+
3270
+ /**
3271
+ * Set the default provider used to locate fonts.
3272
+ */
3273
+ setDefaultFontManager(fontManager: TypefaceFontProvider | null): void;
3274
+ }
3275
+
3276
+ export interface URange {
3277
+ start: number;
3278
+ end: number;
3279
+ }
3280
+
3281
+ /**
3282
+ * Options for configuring a WebGL context. If an option is omitted, a sensible default will
3283
+ * be used. These are defined by the WebGL standards.
3284
+ */
3285
+ export interface WebGLOptions {
3286
+ alpha?: number;
3287
+ antialias?: number;
3288
+ depth?: number;
3289
+ enableExtensionsByDefault?: number;
3290
+ explicitSwapControl?: number;
3291
+ failIfMajorPerformanceCaveat?: number;
3292
+ majorVersion?: number;
3293
+ minorVersion?: number;
3294
+ preferLowPowerToHighPerformance?: number;
3295
+ premultipliedAlpha?: number;
3296
+ preserveDrawingBuffer?: number;
3297
+ renderViaOffscreenBackBuffer?: number;
3298
+ stencil?: number;
3299
+ }
3300
+
3301
+ /**
3302
+ * Options for configuring a canvas WebGPU context. If an option is omitted, a default specified by
3303
+ * the WebGPU standard will be used.
3304
+ */
3305
+ export interface WebGPUCanvasOptions {
3306
+ format?: GPUTextureFormat;
3307
+ alphaMode?: GPUCanvasAlphaMode;
3308
+ }
3309
+
3310
+ export interface DefaultConstructor<T> {
3311
+ new (): T;
3312
+ }
3313
+
3314
+ export interface ColorMatrixHelpers {
3315
+ /**
3316
+ * Returns a new ColorMatrix that is the result of multiplying outer*inner
3317
+ * @param outer
3318
+ * @param inner
3319
+ */
3320
+ concat(outer: ColorMatrix, inner: ColorMatrix): ColorMatrix;
3321
+
3322
+ /**
3323
+ * Returns an identity ColorMatrix.
3324
+ */
3325
+ identity(): ColorMatrix;
3326
+
3327
+ /**
3328
+ * Sets the 4 "special" params that will translate the colors after they are multiplied
3329
+ * by the 4x4 matrix.
3330
+ * @param m
3331
+ * @param dr - delta red
3332
+ * @param dg - delta green
3333
+ * @param db - delta blue
3334
+ * @param da - delta alpha
3335
+ */
3336
+ postTranslate(m: ColorMatrix, dr: number, dg: number, db: number, da: number): ColorMatrix;
3337
+
3338
+ /**
3339
+ * Returns a new ColorMatrix that is rotated around a given axis.
3340
+ * @param axis - 0 for red, 1 for green, 2 for blue
3341
+ * @param sine - sin(angle)
3342
+ * @param cosine - cos(angle)
3343
+ */
3344
+ rotated(axis: number, sine: number, cosine: number): ColorMatrix;
3345
+
3346
+ /**
3347
+ * Returns a new ColorMatrix that scales the colors as specified.
3348
+ * @param redScale
3349
+ * @param greenScale
3350
+ * @param blueScale
3351
+ * @param alphaScale
3352
+ */
3353
+ scaled(redScale: number, greenScale: number, blueScale: number,
3354
+ alphaScale: number): ColorMatrix;
3355
+ }
3356
+
3357
+ /**
3358
+ * A constructor for making an ImageData that is compatible with the Canvas2D emulation code.
3359
+ */
3360
+ export interface ImageDataConstructor {
3361
+ new (width: number, height: number): EmulatedImageData;
3362
+ new (pixels: Uint8ClampedArray, width: number, height: number): EmulatedImageData;
3363
+ }
3364
+
3365
+ /**
3366
+ * TODO(kjlubick) Make this API return Float32Arrays
3367
+ */
3368
+ export interface Matrix3x3Helpers {
3369
+ /**
3370
+ * Returns a new identity 3x3 matrix.
3371
+ */
3372
+ identity(): number[];
3373
+
3374
+ /**
3375
+ * Returns the inverse of the given 3x3 matrix or null if it is not invertible.
3376
+ * @param m
3377
+ */
3378
+ invert(m: Matrix3x3 | number[]): number[] | null;
3379
+
3380
+ /**
3381
+ * Maps the given 2d points according to the given 3x3 matrix.
3382
+ * @param m
3383
+ * @param points - the flattened points to map; the results are computed in place on this array.
3384
+ */
3385
+ mapPoints(m: Matrix3x3 | number[], points: number[]): number[];
3386
+
3387
+ /**
3388
+ * Multiplies the provided 3x3 matrices together from left to right.
3389
+ * @param matrices
3390
+ */
3391
+ multiply(...matrices: Array<(Matrix3x3 | number[])>): number[];
3392
+
3393
+ /**
3394
+ * Returns a new 3x3 matrix representing a rotation by n radians.
3395
+ * @param radians
3396
+ * @param px - the X value to rotate around, defaults to 0.
3397
+ * @param py - the Y value to rotate around, defaults to 0.
3398
+ */
3399
+ rotated(radians: AngleInRadians, px?: number, py?: number): number[];
3400
+
3401
+ /**
3402
+ * Returns a new 3x3 matrix representing a scale in the x and y directions.
3403
+ * @param sx - the scale in the X direction.
3404
+ * @param sy - the scale in the Y direction.
3405
+ * @param px - the X value to scale from, defaults to 0.
3406
+ * @param py - the Y value to scale from, defaults to 0.
3407
+ */
3408
+ scaled(sx: number, sy: number, px?: number, py?: number): number[];
3409
+
3410
+ /**
3411
+ * Returns a new 3x3 matrix representing a scale in the x and y directions.
3412
+ * @param kx - the kurtosis in the X direction.
3413
+ * @param ky - the kurtosis in the Y direction.
3414
+ * @param px - the X value to skew from, defaults to 0.
3415
+ * @param py - the Y value to skew from, defaults to 0.
3416
+ */
3417
+ skewed(kx: number, ky: number, px?: number, py?: number): number[];
3418
+
3419
+ /**
3420
+ * Returns a new 3x3 matrix representing a translation in the x and y directions.
3421
+ * @param dx
3422
+ * @param dy
3423
+ */
3424
+ translated(dx: number, dy: number): number[];
3425
+ }
3426
+
3427
+ /**
3428
+ * See SkM44.h for more details.
3429
+ */
3430
+ export interface Matrix4x4Helpers {
3431
+ /**
3432
+ * Returns a new identity 4x4 matrix.
3433
+ */
3434
+ identity(): number[];
3435
+
3436
+ /**
3437
+ * Returns the inverse of the given 4x4 matrix or null if it is not invertible.
3438
+ * @param matrix
3439
+ */
3440
+ invert(matrix: Matrix4x4 | number[]): number[] | null;
3441
+
3442
+ /**
3443
+ * Return a new 4x4 matrix representing a camera at eyeVec, pointed at centerVec.
3444
+ * @param eyeVec
3445
+ * @param centerVec
3446
+ * @param upVec
3447
+ */
3448
+ lookat(eyeVec: Vector3, centerVec: Vector3, upVec: Vector3): number[];
3449
+
3450
+ /**
3451
+ * Multiplies the provided 4x4 matrices together from left to right.
3452
+ * @param matrices
3453
+ */
3454
+ multiply(...matrices: Array<(Matrix4x4 | number[])>): number[];
3455
+
3456
+ /**
3457
+ * Returns the inverse of the given 4x4 matrix or throws if it is not invertible.
3458
+ * @param matrix
3459
+ */
3460
+ mustInvert(matrix: Matrix4x4 | number[]): number[];
3461
+
3462
+ /**
3463
+ * Returns a new 4x4 matrix representing a perspective.
3464
+ * @param near
3465
+ * @param far
3466
+ * @param radians
3467
+ */
3468
+ perspective(near: number, far: number, radians: AngleInRadians): number[];
3469
+
3470
+ /**
3471
+ * Returns the value at the specified row and column of the given 4x4 matrix.
3472
+ * @param matrix
3473
+ * @param row
3474
+ * @param col
3475
+ */
3476
+ rc(matrix: Matrix4x4 | number[], row: number, col: number): number;
3477
+
3478
+ /**
3479
+ * Returns a new 4x4 matrix representing a rotation around the provided vector.
3480
+ * @param axis
3481
+ * @param radians
3482
+ */
3483
+ rotated(axis: Vector3, radians: AngleInRadians): number[];
3484
+
3485
+ /**
3486
+ * Returns a new 4x4 matrix representing a rotation around the provided vector.
3487
+ * Rotation is provided redundantly as both sin and cos values.
3488
+ * This rotate can be used when you already have the cosAngle and sinAngle values
3489
+ * so you don't have to atan(cos/sin) to call roatated() which expects an angle in radians.
3490
+ * This does no checking! Behavior for invalid sin or cos values or non-normalized axis vectors
3491
+ * is incorrect. Prefer rotated().
3492
+ * @param axis
3493
+ * @param sinAngle
3494
+ * @param cosAngle
3495
+ */
3496
+ rotatedUnitSinCos(axis: Vector3, sinAngle: number, cosAngle: number): number[];
3497
+
3498
+ /**
3499
+ * Returns a new 4x4 matrix representing a scale by the provided vector.
3500
+ * @param vec
3501
+ */
3502
+ scaled(vec: Vector3): number[];
3503
+
3504
+ /**
3505
+ * Returns a new 4x4 matrix that sets up a 3D perspective view from a given camera.
3506
+ * @param area - describes the viewport. (0, 0, canvas_width, canvas_height) suggested.
3507
+ * @param zScale - describes the scale of the z axis. min(width, height)/2 suggested
3508
+ * @param cam
3509
+ */
3510
+ setupCamera(area: InputRect, zScale: number, cam: Camera): number[];
3511
+
3512
+ /**
3513
+ * Returns a new 4x4 matrix representing a translation by the provided vector.
3514
+ * @param vec
3515
+ */
3516
+ translated(vec: Vector3): number[];
3517
+
3518
+ /**
3519
+ * Returns a new 4x4 matrix that is the transpose of this 4x4 matrix.
3520
+ * @param matrix
3521
+ */
3522
+ transpose(matrix: Matrix4x4 | number[]): number[];
3523
+ }
3524
+
3525
+ /**
3526
+ * For more information, see SkBlender.h.
3527
+ */
3528
+ export interface BlenderFactory {
3529
+ /**
3530
+ * Create a blender that implements the specified BlendMode.
3531
+ * @param mode
3532
+ */
3533
+ Mode(mode: BlendMode): Blender;
3534
+ }
3535
+
3536
+ export interface ParagraphBuilderFactory {
3537
+ /**
3538
+ * Creates a ParagraphBuilder using the fonts available from the given font manager.
3539
+ * @param style
3540
+ * @param fontManager
3541
+ */
3542
+ Make(style: ParagraphStyle, fontManager: FontMgr): ParagraphBuilder;
3543
+
3544
+ /**
3545
+ * Creates a ParagraphBuilder using the fonts available from the given font provider.
3546
+ * @param style
3547
+ * @param fontSrc
3548
+ */
3549
+ MakeFromFontProvider(style: ParagraphStyle, fontSrc: TypefaceFontProvider): ParagraphBuilder;
3550
+
3551
+ /**
3552
+ * Creates a ParagraphBuilder using the given font collection.
3553
+ * @param style
3554
+ * @param fontCollection
3555
+ */
3556
+ MakeFromFontCollection(style: ParagraphStyle, fontCollection: FontCollection): ParagraphBuilder;
3557
+
3558
+ /**
3559
+ * Return a shaped array of lines
3560
+ */
3561
+ ShapeText(text: string, runs: FontBlock[], width?: number): ShapedLine[];
3562
+
3563
+ /**
3564
+ * Whether the paragraph builder requires ICU data to be provided by the
3565
+ * client.
3566
+ */
3567
+ RequiresClientICU(): boolean;
3568
+ }
3569
+
3570
+ export interface ParagraphStyleConstructor {
3571
+ /**
3572
+ * Fills out all optional fields with defaults. The emscripten bindings complain if there
3573
+ * is a field undefined and it was expecting a float (for example).
3574
+ * @param ps
3575
+ */
3576
+ new(ps: ParagraphStyle): ParagraphStyle;
3577
+ }
3578
+
3579
+ /**
3580
+ * See SkColorFilter.h for more.
3581
+ */
3582
+ export interface ColorFilterFactory {
3583
+ /**
3584
+ * Makes a color filter with the given color, blend mode, and colorSpace.
3585
+ * @param color
3586
+ * @param mode
3587
+ * @param colorSpace - If omitted, will use SRGB
3588
+ */
3589
+ MakeBlend(color: InputColor, mode: BlendMode, colorSpace?: ColorSpace): ColorFilter;
3590
+
3591
+ /**
3592
+ * Makes a color filter composing two color filters.
3593
+ * @param outer
3594
+ * @param inner
3595
+ */
3596
+ MakeCompose(outer: ColorFilter, inner: ColorFilter): ColorFilter;
3597
+
3598
+ /**
3599
+ * Makes a color filter that is linearly interpolated between two other color filters.
3600
+ * @param t - a float in the range of 0.0 to 1.0.
3601
+ * @param dst
3602
+ * @param src
3603
+ */
3604
+ MakeLerp(t: number, dst: ColorFilter, src: ColorFilter): ColorFilter;
3605
+
3606
+ /**
3607
+ * Makes a color filter that converts between linear colors and sRGB colors.
3608
+ */
3609
+ MakeLinearToSRGBGamma(): ColorFilter;
3610
+
3611
+ /**
3612
+ * Creates a color filter using the provided color matrix.
3613
+ * @param cMatrix
3614
+ */
3615
+ MakeMatrix(cMatrix: InputColorMatrix): ColorFilter;
3616
+
3617
+ /**
3618
+ * Makes a color filter that converts between sRGB colors and linear colors.
3619
+ */
3620
+ MakeSRGBToLinearGamma(): ColorFilter;
3621
+
3622
+ /**
3623
+ * Makes a color filter that multiplies the luma of its input into the alpha channel,
3624
+ * and sets the red, green, and blue channels to zero.
3625
+ */
3626
+ MakeLuma(): ColorFilter;
3627
+ }
3628
+
3629
+ export interface ContourMeasureIterConstructor {
3630
+ /**
3631
+ * Creates an ContourMeasureIter with the given path.
3632
+ * @param path
3633
+ * @param forceClosed - if path should be forced close before measuring it.
3634
+ * @param resScale - controls the precision of the measure. values > 1 increase the
3635
+ * precision (and possibly slow down the computation).
3636
+ */
3637
+ new (path: Path, forceClosed: boolean, resScale: number): ContourMeasureIter;
3638
+ }
3639
+
3640
+ /**
3641
+ * See SkFont.h for more.
3642
+ */
3643
+ export interface FontConstructor extends DefaultConstructor<Font> {
3644
+ /**
3645
+ * Constructs Font with default values with Typeface.
3646
+ * @param face
3647
+ * @param size - font size in points. If not specified, uses a default value.
3648
+ */
3649
+ new (face: Typeface | null, size?: number): Font;
3650
+
3651
+ /**
3652
+ * Constructs Font with default values with Typeface and size in points,
3653
+ * horizontal scale, and horizontal skew. Horizontal scale emulates condensed
3654
+ * and expanded fonts. Horizontal skew emulates oblique fonts.
3655
+ * @param face
3656
+ * @param size
3657
+ * @param scaleX
3658
+ * @param skewX
3659
+ */
3660
+ new (face: Typeface | null, size: number, scaleX: number, skewX: number): Font;
3661
+ }
3662
+
3663
+ export interface FontMgrFactory {
3664
+ /**
3665
+ * Create an FontMgr with the created font data. Returns null if buffers was empty.
3666
+ * @param buffers
3667
+ */
3668
+ FromData(...buffers: ArrayBuffer[]): FontMgr | null;
3669
+ }
3670
+
3671
+ /**
3672
+ * See //include/effects/SkImageFilters.h for more.
3673
+ */
3674
+ export interface ImageFilterFactory {
3675
+ /**
3676
+ * Create a filter that takes a BlendMode and uses it to composite the two filters together.
3677
+ *
3678
+ * At least one of background and foreground should be non-null in nearly all circumstances.
3679
+ *
3680
+ * @param blend The blend mode that defines the compositing operation
3681
+ * @param background The Dst pixels used in blending; if null, use the dynamic source image
3682
+ * (e.g. a saved layer).
3683
+ * @param foreground The Src pixels used in blending; if null, use the dynamic source image.
3684
+ */
3685
+ MakeBlend(blend: BlendMode, background: ImageFilter | null,
3686
+ foreground: ImageFilter | null): ImageFilter;
3687
+
3688
+ /**
3689
+ * Create a filter that blurs its input by the separate X and Y sigmas. The provided tile mode
3690
+ * is used when the blur kernel goes outside the input image.
3691
+ *
3692
+ * @param sigmaX - The Gaussian sigma value for blurring along the X axis.
3693
+ * @param sigmaY - The Gaussian sigma value for blurring along the Y axis.
3694
+ * @param mode
3695
+ * @param input - if null, it will use the dynamic source image (e.g. a saved layer)
3696
+ */
3697
+ MakeBlur(sigmaX: number, sigmaY: number, mode: TileMode,
3698
+ input: ImageFilter | null): ImageFilter;
3699
+
3700
+ /**
3701
+ * Create a filter that applies the color filter to the input filter results.
3702
+ * @param cf
3703
+ * @param input - if null, it will use the dynamic source image (e.g. a saved layer)
3704
+ */
3705
+ MakeColorFilter(cf: ColorFilter, input: ImageFilter | null): ImageFilter;
3706
+
3707
+ /**
3708
+ * Create a filter that composes 'inner' with 'outer', such that the results of 'inner' are
3709
+ * treated as the source bitmap passed to 'outer'.
3710
+ * If either param is null, the other param will be returned.
3711
+ * @param outer
3712
+ * @param inner - if null, it will use the dynamic source image (e.g. a saved layer)
3713
+ */
3714
+ MakeCompose(outer: ImageFilter | null, inner: ImageFilter | null): ImageFilter;
3715
+
3716
+ /**
3717
+ * Create a filter that dilates each input pixel's channel values to the max value within the
3718
+ * given radii along the x and y axes.
3719
+ * @param radiusX The distance to dilate along the x axis to either side of each pixel.
3720
+ * @param radiusY The distance to dilate along the y axis to either side of each pixel.
3721
+ * @param input if null, it will use the dynamic source image (e.g. a saved layer).
3722
+ */
3723
+ MakeDilate(radiusX: number, radiusY: number, input: ImageFilter | null): ImageFilter;
3724
+
3725
+ /**
3726
+ * Create a filter that moves each pixel in its color input based on an (x,y) vector encoded
3727
+ * in its displacement input filter. Two color components of the displacement image are
3728
+ * mapped into a vector as scale * (color[xChannel], color[yChannel]), where the channel
3729
+ * selectors are one of R, G, B, or A.
3730
+ * The mapping takes the 0-255 RGBA values of the image and scales them to be [-0.5 to 0.5],
3731
+ * in a similar fashion to https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDisplacementMap
3732
+ *
3733
+ * At least one of displacement and color should be non-null in nearly all circumstances.
3734
+ *
3735
+ * @param xChannel RGBA channel that encodes the x displacement per pixel.
3736
+ * @param yChannel RGBA channel that encodes the y displacement per pixel.
3737
+ * @param scale Scale applied to displacement extracted from image.
3738
+ * @param displacement The filter defining the displacement image, or null to use source.
3739
+ * @param color The filter providing the color pixels to be displaced, or null to use source.
3740
+ */
3741
+ MakeDisplacementMap(xChannel: ColorChannel, yChannel: ColorChannel, scale: number,
3742
+ displacement: ImageFilter | null, color: ImageFilter | null): ImageFilter;
3743
+ /**
3744
+ * Create a filter that draws a drop shadow under the input content. This filter produces an
3745
+ * image that includes the inputs' content.
3746
+ * @param dx The X offset of the shadow.
3747
+ * @param dy The Y offset of the shadow.
3748
+ * @param sigmaX The blur radius for the shadow, along the X axis.
3749
+ * @param sigmaY The blur radius for the shadow, along the Y axis.
3750
+ * @param color The color of the drop shadow.
3751
+ * @param input The input filter; if null, it will use the dynamic source image.
3752
+ */
3753
+ MakeDropShadow(dx: number, dy: number, sigmaX: number, sigmaY: number, color: Color,
3754
+ input: ImageFilter | null): ImageFilter;
3755
+
3756
+ /**
3757
+ * Just like MakeDropShadow, except the input content is not in the resulting image.
3758
+ * @param dx The X offset of the shadow.
3759
+ * @param dy The Y offset of the shadow.
3760
+ * @param sigmaX The blur radius for the shadow, along the X axis.
3761
+ * @param sigmaY The blur radius for the shadow, along the Y axis.
3762
+ * @param color The color of the drop shadow.
3763
+ * @param input The input filter; if null, it will use the dynamic source image.
3764
+ */
3765
+ MakeDropShadowOnly(dx: number, dy: number, sigmaX: number, sigmaY: number, color: Color,
3766
+ input: ImageFilter | null): ImageFilter;
3767
+
3768
+ /**
3769
+ * Create a filter that erodes each input pixel's channel values to the minimum channel value
3770
+ * within the given radii along the x and y axes.
3771
+ * @param radiusX The distance to erode along the x axis to either side of each pixel.
3772
+ * @param radiusY The distance to erode along the y axis to either side of each pixel.
3773
+ * @param input if null, it will use the dynamic source image (e.g. a saved layer).
3774
+ */
3775
+ MakeErode(radiusX: number, radiusY: number, input: ImageFilter | null): ImageFilter;
3776
+
3777
+ /**
3778
+ * Create a filter using the given image as a source. Returns null if 'image' is null.
3779
+ *
3780
+ * @param img The image that is output by the filter, subset by 'srcRect'.
3781
+ * @param sampling The sampling to use when drawing the image.
3782
+ */
3783
+ MakeImage(img: Image, sampling: FilterOptions | CubicResampler): ImageFilter | null;
3784
+
3785
+ /**
3786
+ * Create a filter that draws the 'srcRect' portion of image into 'dstRect' using the given
3787
+ * filter quality. Similar to Canvas.drawImageRect. Returns null if 'image' is null.
3788
+ *
3789
+ * @param img The image that is output by the filter, subset by 'srcRect'.
3790
+ * @param sampling The sampling to use when drawing the image.
3791
+ * @param srcRect The source pixels sampled into 'dstRect'.
3792
+ * @param dstRect The local rectangle to draw the image into.
3793
+ */
3794
+ MakeImage(img: Image, sampling: FilterOptions | CubicResampler,
3795
+ srcRect: InputRect, dstRect: InputRect): ImageFilter | null;
3796
+
3797
+ /**
3798
+ * Create a filter that transforms the input image by 'matrix'. This matrix transforms the
3799
+ * local space, which means it effectively happens prior to any transformation coming from the
3800
+ * Canvas initiating the filtering.
3801
+ * @param matr
3802
+ * @param sampling
3803
+ * @param input - if null, it will use the dynamic source image (e.g. a saved layer)
3804
+ */
3805
+ MakeMatrixTransform(matr: InputMatrix, sampling: FilterOptions | CubicResampler,
3806
+ input: ImageFilter | null): ImageFilter;
3807
+
3808
+ /**
3809
+ * Create a filter that offsets the input filter by the given vector.
3810
+ * @param dx The x offset in local space that the image is shifted.
3811
+ * @param dy The y offset in local space that the image is shifted.
3812
+ * @param input The input that will be moved, if null, will use the dynamic source image.
3813
+ */
3814
+ MakeOffset(dx: number, dy: number, input: ImageFilter | null): ImageFilter;
3815
+
3816
+ /**
3817
+ * Transforms a shader into an image filter
3818
+ *
3819
+ * @param shader - The Shader to be transformed
3820
+ */
3821
+ MakeShader(shader: Shader): ImageFilter;
3822
+ }
3823
+
3824
+ /**
3825
+ * See SkMaskFilter.h for more details.
3826
+ */
3827
+ export interface MaskFilterFactory {
3828
+ /**
3829
+ * Create a blur maskfilter
3830
+ * @param style
3831
+ * @param sigma - Standard deviation of the Gaussian blur to apply. Must be > 0.
3832
+ * @param respectCTM - if true the blur's sigma is modified by the CTM.
3833
+ */
3834
+ MakeBlur(style: BlurStyle, sigma: number, respectCTM: boolean): MaskFilter;
3835
+ }
3836
+
3837
+ /**
3838
+ * Contains the ways to create a Path.
3839
+ */
3840
+ export interface PathConstructorAndFactory extends DefaultConstructor<Path> {
3841
+ /**
3842
+ * Returns true if the two paths contain equal verbs and equal weights.
3843
+ * @param path1 first path to compate
3844
+ * @param path2 second path to compare
3845
+ * @return true if Path can be interpolated equivalent
3846
+ */
3847
+ CanInterpolate(path1: Path, path2: Path): boolean;
3848
+
3849
+ /**
3850
+ * Creates a new path from the given list of path commands. If this fails, null will be
3851
+ * returned instead.
3852
+ * @param cmds
3853
+ */
3854
+ MakeFromCmds(cmds: InputCommands): Path | null;
3855
+
3856
+ /**
3857
+ * Creates a new path by combining the given paths according to op. If this fails, null will
3858
+ * be returned instead.
3859
+ * @param one
3860
+ * @param two
3861
+ * @param op
3862
+ */
3863
+ MakeFromOp(one: Path, two: Path, op: PathOp): Path | null;
3864
+
3865
+ /**
3866
+ * Interpolates between Path with point array of equal size.
3867
+ * Copy verb array and weights to result, and set result path to a weighted
3868
+ * average of this path array and ending path.
3869
+ *
3870
+ * weight is most useful when between zero (ending path) and
3871
+ * one (this path); will work with values outside of this
3872
+ * range.
3873
+ *
3874
+ * interpolate() returns undefined if path is not
3875
+ * the same size as ending path. Call isInterpolatable() to check Path
3876
+ * compatibility prior to calling interpolate().
3877
+ *
3878
+ * @param start path to interpolate from
3879
+ * @param end path to interpolate with
3880
+ * @param weight contribution of this path, and
3881
+ * one minus contribution of ending path
3882
+ * @return Path replaced by interpolated averages or null if
3883
+ * not interpolatable
3884
+ */
3885
+ MakeFromPathInterpolation(start: Path, end: Path, weight: number): Path | null;
3886
+
3887
+ /**
3888
+ * Creates a new path from the provided SVG string. If this fails, null will be
3889
+ * returned instead.
3890
+ * @param str
3891
+ */
3892
+ MakeFromSVGString(str: string): Path | null;
3893
+
3894
+ /**
3895
+ * Creates a new path using the provided verbs and associated points and weights. The process
3896
+ * reads the first verb from verbs and then the appropriate number of points from the
3897
+ * FlattenedPointArray (e.g. 2 points for moveTo, 4 points for quadTo, etc). If the verb is
3898
+ * a conic, a weight will be read from the WeightList.
3899
+ * If the data is malformed (e.g. not enough points), the resulting path will be incomplete.
3900
+ * @param verbs - the verbs that create this path, in the order of being drawn.
3901
+ * @param points - represents n points with 2n floats.
3902
+ * @param weights - used if any of the verbs are conics, can be omitted otherwise.
3903
+ */
3904
+ MakeFromVerbsPointsWeights(verbs: VerbList, points: InputFlattenedPointArray,
3905
+ weights?: WeightList): Path;
3906
+ }
3907
+
3908
+ /**
3909
+ * See SkPathEffect.h for more details.
3910
+ */
3911
+ export interface PathEffectFactory {
3912
+ /**
3913
+ * Returns a PathEffect that can turn sharp corners into rounded corners.
3914
+ * @param radius - if <=0, returns null
3915
+ */
3916
+ MakeCorner(radius: number): PathEffect | null;
3917
+
3918
+ /**
3919
+ * Returns a PathEffect that add dashes to the path.
3920
+ *
3921
+ * See SkDashPathEffect.h for more details.
3922
+ *
3923
+ * @param intervals - even number of entries with even indicies specifying the length of
3924
+ * the "on" intervals, and the odd indices specifying the length of "off".
3925
+ * @param phase - offset length into the intervals array. Defaults to 0.
3926
+ */
3927
+ MakeDash(intervals: number[], phase?: number): PathEffect;
3928
+
3929
+ /**
3930
+ * Returns a PathEffect that breaks path into segments of segLength length, and randomly move
3931
+ * the endpoints away from the original path by a maximum of deviation.
3932
+ * @param segLength - length of the subsegments.
3933
+ * @param dev - limit of the movement of the endpoints.
3934
+ * @param seedAssist - modifies the randomness. See SkDiscretePathEffect.h for more.
3935
+ */
3936
+ MakeDiscrete(segLength: number, dev: number, seedAssist: number): PathEffect;
3937
+
3938
+ /**
3939
+ * Returns a PathEffect that will fill the drawing path with a pattern made by applying
3940
+ * the given matrix to a repeating set of infinitely long lines of the given width.
3941
+ * For example, the scale of the provided matrix will determine how far apart the lines
3942
+ * should be drawn its rotation affects the lines' orientation.
3943
+ * @param width - must be >= 0
3944
+ * @param matrix
3945
+ */
3946
+ MakeLine2D(width: number, matrix: InputMatrix): PathEffect | null;
3947
+
3948
+ /**
3949
+ * Returns a PathEffect which implements dashing by replicating the specified path.
3950
+ * @param path The path to replicate (dash)
3951
+ * @param advance The space between instances of path
3952
+ * @param phase distance (mod advance) along path for its initial position
3953
+ * @param style how to transform path at each point (based on the current
3954
+ * position and tangent)
3955
+ */
3956
+ MakePath1D(path: Path, advance: number, phase: number, style: Path1DEffectStyle):
3957
+ PathEffect | null;
3958
+
3959
+ /**
3960
+ * Returns a PathEffect that will fill the drawing path with a pattern by repeating the
3961
+ * given path according to the provided matrix. For example, the scale of the matrix
3962
+ * determines how far apart the path instances should be drawn.
3963
+ * @param matrix
3964
+ * @param path
3965
+ */
3966
+ MakePath2D(matrix: InputMatrix, path: Path): PathEffect | null;
3967
+ }
3968
+
3969
+ /**
3970
+ * See RuntimeEffect.h for more details.
3971
+ */
3972
+ export interface DebugTrace extends EmbindObject<"DebugTrace"> {
3973
+ writeTrace(): string;
3974
+ }
3975
+
3976
+ export interface TracedShader {
3977
+ shader: Shader;
3978
+ debugTrace: DebugTrace;
3979
+ }
3980
+
3981
+ export interface RuntimeEffectFactory {
3982
+ /**
3983
+ * Compiles a RuntimeEffect from the given shader code.
3984
+ * @param sksl - Source code for a shader written in SkSL
3985
+ * @param callback - will be called with any compilation error. If not provided, errors will
3986
+ * be printed to console.log().
3987
+ */
3988
+ Make(sksl: string, callback?: (err: string) => void): RuntimeEffect | null;
3989
+
3990
+ /**
3991
+ * Compiles a RuntimeEffect from the given blender code.
3992
+ * @param sksl - Source code for a blender written in SkSL
3993
+ * @param callback - will be called with any compilation error. If not provided, errors will
3994
+ * be printed to console.log().
3995
+ */
3996
+ MakeForBlender(sksl: string, callback?: (err: string) => void): RuntimeEffect | null;
3997
+
3998
+ /**
3999
+ * Adds debug tracing to an existing RuntimeEffect.
4000
+ * @param shader - An already-assembled shader, created with RuntimeEffect.makeShader.
4001
+ * @param traceCoordX - the X coordinate of the device-space pixel to trace
4002
+ * @param traceCoordY - the Y coordinate of the device-space pixel to trace
4003
+ */
4004
+ MakeTraced(shader: Shader, traceCoordX: number, traceCoordY: number): TracedShader;
4005
+ }
4006
+
4007
+ /**
4008
+ * For more information, see SkShaders.h.
4009
+ */
4010
+ export interface ShaderFactory {
4011
+ /**
4012
+ * Returns a shader that combines the given shaders with a BlendMode.
4013
+ * @param mode
4014
+ * @param one
4015
+ * @param two
4016
+ */
4017
+ MakeBlend(mode: BlendMode, one: Shader, two: Shader): Shader;
4018
+
4019
+ /**
4020
+ * Returns a shader with a given color and colorspace.
4021
+ * @param color
4022
+ * @param space
4023
+ */
4024
+ MakeColor(color: InputColor, space: ColorSpace): Shader;
4025
+
4026
+ /**
4027
+ * Returns a shader with Perlin Fractal Noise.
4028
+ * See SkPerlinNoiseShader.h for more details
4029
+ * @param baseFreqX - base frequency in the X direction; range [0.0, 1.0]
4030
+ * @param baseFreqY - base frequency in the Y direction; range [0.0, 1.0]
4031
+ * @param octaves
4032
+ * @param seed
4033
+ * @param tileW - if this and tileH are non-zero, the frequencies will be modified so that the
4034
+ * noise will be tileable for the given size.
4035
+ * @param tileH - if this and tileW are non-zero, the frequencies will be modified so that the
4036
+ * noise will be tileable for the given size.
4037
+ */
4038
+ MakeFractalNoise(baseFreqX: number, baseFreqY: number, octaves: number, seed: number,
4039
+ tileW: number, tileH: number): Shader;
4040
+
4041
+ /**
4042
+ * Returns a shader that generates a linear gradient between the two specified points.
4043
+ * See SkGradientShader.h for more.
4044
+ * @param start
4045
+ * @param end
4046
+ * @param colors - colors to be distributed between start and end.
4047
+ * @param pos - May be null. The relative positions of colors. If supplied must be same length
4048
+ * as colors.
4049
+ * @param mode
4050
+ * @param localMatrix
4051
+ * @param flags - By default gradients will interpolate their colors in unpremul space
4052
+ * and then premultiply each of the results. By setting this to 1, the
4053
+ * gradients will premultiply their colors first, and then interpolate
4054
+ * between them.
4055
+ * @param colorSpace
4056
+ */
4057
+ MakeLinearGradient(start: InputPoint, end: InputPoint, colors: InputFlexibleColorArray,
4058
+ pos: number[] | null, mode: TileMode, localMatrix?: InputMatrix,
4059
+ flags?: number, colorSpace?: ColorSpace): Shader;
4060
+
4061
+ /**
4062
+ * Returns a shader that generates a radial gradient given the center and radius.
4063
+ * See SkGradientShader.h for more.
4064
+ * @param center
4065
+ * @param radius
4066
+ * @param colors - colors to be distributed between the center and edge.
4067
+ * @param pos - May be null. The relative positions of colors. If supplied must be same length
4068
+ * as colors. Range [0.0, 1.0]
4069
+ * @param mode
4070
+ * @param localMatrix
4071
+ * @param flags - 0 to interpolate colors in unpremul, 1 to interpolate colors in premul.
4072
+ * @param colorSpace
4073
+ */
4074
+ MakeRadialGradient(center: InputPoint, radius: number, colors: InputFlexibleColorArray,
4075
+ pos: number[] | null, mode: TileMode, localMatrix?: InputMatrix,
4076
+ flags?: number, colorSpace?: ColorSpace): Shader;
4077
+
4078
+ /**
4079
+ * Returns a shader that generates a sweep gradient given a center.
4080
+ * See SkGradientShader.h for more.
4081
+ * @param cx
4082
+ * @param cy
4083
+ * @param colors - colors to be distributed around the center, within the provided angles.
4084
+ * @param pos - May be null. The relative positions of colors. If supplied must be same length
4085
+ * as colors. Range [0.0, 1.0]
4086
+ * @param mode
4087
+ * @param localMatrix
4088
+ * @param flags - 0 to interpolate colors in unpremul, 1 to interpolate colors in premul.
4089
+ * @param startAngle - angle corresponding to 0.0. Defaults to 0 degrees.
4090
+ * @param endAngle - angle corresponding to 1.0. Defaults to 360 degrees.
4091
+ * @param colorSpace
4092
+ */
4093
+ MakeSweepGradient(cx: number, cy: number, colors: InputFlexibleColorArray,
4094
+ pos: number[] | null, mode: TileMode, localMatrix?: InputMatrix | null,
4095
+ flags?: number, startAngle?: AngleInDegrees, endAngle?: AngleInDegrees,
4096
+ colorSpace?: ColorSpace): Shader;
4097
+
4098
+ /**
4099
+ * Returns a shader with Perlin Turbulence.
4100
+ * See SkPerlinNoiseShader.h for more details
4101
+ * @param baseFreqX - base frequency in the X direction; range [0.0, 1.0]
4102
+ * @param baseFreqY - base frequency in the Y direction; range [0.0, 1.0]
4103
+ * @param octaves
4104
+ * @param seed
4105
+ * @param tileW - if this and tileH are non-zero, the frequencies will be modified so that the
4106
+ * noise will be tileable for the given size.
4107
+ * @param tileH - if this and tileW are non-zero, the frequencies will be modified so that the
4108
+ * noise will be tileable for the given size.
4109
+ */
4110
+ MakeTurbulence(baseFreqX: number, baseFreqY: number, octaves: number, seed: number,
4111
+ tileW: number, tileH: number): Shader;
4112
+
4113
+ /**
4114
+ * Returns a shader that generates a conical gradient given two circles.
4115
+ * See SkGradientShader.h for more.
4116
+ * @param start
4117
+ * @param startRadius
4118
+ * @param end
4119
+ * @param endRadius
4120
+ * @param colors
4121
+ * @param pos
4122
+ * @param mode
4123
+ * @param localMatrix
4124
+ * @param flags
4125
+ * @param colorSpace
4126
+ */
4127
+ MakeTwoPointConicalGradient(start: InputPoint, startRadius: number, end: InputPoint,
4128
+ endRadius: number, colors: InputFlexibleColorArray,
4129
+ pos: number[] | null, mode: TileMode, localMatrix?: InputMatrix,
4130
+ flags?: number, colorSpace?: ColorSpace): Shader;
4131
+ }
4132
+
4133
+ /**
4134
+ * See SkTextBlob.h for more details.
4135
+ */
4136
+ export interface TextBlobFactory {
4137
+ /**
4138
+ * Return a TextBlob with a single run of text.
4139
+ *
4140
+ * It does not perform typeface fallback for characters not found in the Typeface.
4141
+ * It does not perform kerning or other complex shaping; glyphs are positioned based on their
4142
+ * default advances.
4143
+ * @param glyphs - if using Malloc'd array, be sure to use CanvasKit.MallocGlyphIDs().
4144
+ * @param font
4145
+ */
4146
+ MakeFromGlyphs(glyphs: InputGlyphIDArray, font: Font): TextBlob;
4147
+
4148
+ /**
4149
+ * Returns a TextBlob built from a single run of text with rotation, scale, and translations.
4150
+ *
4151
+ * It uses the default character-to-glyph mapping from the typeface in the font.
4152
+ * @param str
4153
+ * @param rsxforms
4154
+ * @param font
4155
+ */
4156
+ MakeFromRSXform(str: string, rsxforms: InputFlattenedRSXFormArray, font: Font): TextBlob;
4157
+
4158
+ /**
4159
+ * Returns a TextBlob built from a single run of text with rotation, scale, and translations.
4160
+ *
4161
+ * @param glyphs - if using Malloc'd array, be sure to use CanvasKit.MallocGlyphIDs().
4162
+ * @param rsxforms
4163
+ * @param font
4164
+ */
4165
+ MakeFromRSXformGlyphs(glyphs: InputGlyphIDArray, rsxforms: InputFlattenedRSXFormArray,
4166
+ font: Font): TextBlob;
4167
+
4168
+ /**
4169
+ * Return a TextBlob with a single run of text.
4170
+ *
4171
+ * It uses the default character-to-glyph mapping from the typeface in the font.
4172
+ * It does not perform typeface fallback for characters not found in the Typeface.
4173
+ * It does not perform kerning or other complex shaping; glyphs are positioned based on their
4174
+ * default advances.
4175
+ * @param str
4176
+ * @param font
4177
+ */
4178
+ MakeFromText(str: string, font: Font): TextBlob;
4179
+
4180
+ /**
4181
+ * Returns a TextBlob that has the glyphs following the contours of the given path.
4182
+ *
4183
+ * It is a convenience wrapper around MakeFromRSXform and ContourMeasureIter.
4184
+ * @param str
4185
+ * @param path
4186
+ * @param font
4187
+ * @param initialOffset - the length in pixels to start along the path.
4188
+ */
4189
+ MakeOnPath(str: string, path: Path, font: Font, initialOffset?: number): TextBlob;
4190
+ }
4191
+
4192
+ export interface TextStyleConstructor {
4193
+ /**
4194
+ * Fills out all optional fields with defaults. The emscripten bindings complain if there
4195
+ * is a field undefined and it was expecting a float (for example).
4196
+ * @param ts
4197
+ */
4198
+ new(ts: TextStyle): TextStyle;
4199
+ }
4200
+
4201
+ export interface SlottableTextPropertyConstructor {
4202
+ /**
4203
+ * Fills out all optional fields with defaults. The emscripten bindings complain if there
4204
+ * is a field undefined and it was expecting a float (for example).
4205
+ * @param text
4206
+ */
4207
+ new(text: SlottableTextProperty): SlottableTextProperty;
4208
+ }
4209
+
4210
+ export interface TypefaceFactory {
4211
+ /**
4212
+ * Create a typeface using Freetype from the specified bytes and return it. CanvasKit supports
4213
+ * .ttf, .woff and .woff2 fonts. It returns null if the bytes cannot be decoded.
4214
+ * @param fontData
4215
+ */
4216
+ MakeFreeTypeFaceFromData(fontData: ArrayBuffer): Typeface | null;
4217
+ }
4218
+
4219
+ export interface TypefaceFontProviderFactory {
4220
+ /**
4221
+ * Return an empty TypefaceFontProvider
4222
+ */
4223
+ Make(): TypefaceFontProvider;
4224
+ }
4225
+
4226
+ export interface FontCollectionFactory {
4227
+ /**
4228
+ * Return an empty FontCollection
4229
+ */
4230
+ Make(): FontCollection;
4231
+ }
4232
+
4233
+ /**
4234
+ * Functions for manipulating vectors. It is Loosely based off of SkV3 in SkM44.h but Skia
4235
+ * also has SkVec2 and Skv4. This combines them and works on vectors of any length.
4236
+ */
4237
+ export interface VectorHelpers {
4238
+ /**
4239
+ * Adds 2 vectors together, term by term, returning a new Vector.
4240
+ * @param a
4241
+ * @param b
4242
+ */
4243
+ add(a: VectorN, b: VectorN): VectorN;
4244
+
4245
+ /**
4246
+ * Returns the cross product of the two vectors. Only works for length 3.
4247
+ * @param a
4248
+ * @param b
4249
+ */
4250
+ cross(a: Vector3, b: Vector3): Vector3;
4251
+
4252
+ /**
4253
+ * Returns the length(sub(a, b))
4254
+ * @param a
4255
+ * @param b
4256
+ */
4257
+ dist(a: VectorN, b: VectorN): number;
4258
+
4259
+ /**
4260
+ * Returns the dot product of the two vectors.
4261
+ * @param a
4262
+ * @param b
4263
+ */
4264
+ dot(a: VectorN, b: VectorN): number;
4265
+
4266
+ /**
4267
+ * Returns the length of this vector, which is always positive.
4268
+ * @param v
4269
+ */
4270
+ length(v: VectorN): number;
4271
+
4272
+ /**
4273
+ * Returns the length squared of this vector.
4274
+ * @param v
4275
+ */
4276
+ lengthSquared(v: VectorN): number;
4277
+
4278
+ /**
4279
+ * Returns a new vector which is v multiplied by the scalar s.
4280
+ * @param v
4281
+ * @param s
4282
+ */
4283
+ mulScalar(v: VectorN, s: number): VectorN;
4284
+
4285
+ /**
4286
+ * Returns a normalized vector.
4287
+ * @param v
4288
+ */
4289
+ normalize(v: VectorN): VectorN;
4290
+
4291
+ /**
4292
+ * Subtracts vector b from vector a (termwise).
4293
+ * @param a
4294
+ * @param b
4295
+ */
4296
+ sub(a: VectorN, b: VectorN): VectorN;
4297
+ }
4298
+
4299
+ /**
4300
+ * A PosTan is a Float32Array of length 4, representing a position and a tangent vector. In order,
4301
+ * the values are [px, py, tx, ty].
4302
+ */
4303
+ export type PosTan = Float32Array;
4304
+ /**
4305
+ * An Color is represented by 4 floats, typically with values between 0 and 1.0. In order,
4306
+ * the floats correspond to red, green, blue, alpha.
4307
+ */
4308
+ export type Color = Float32Array;
4309
+ export type ColorInt = number; // deprecated, prefer Color
4310
+ /**
4311
+ * An ColorMatrix is a 4x4 color matrix that transforms the 4 color channels
4312
+ * with a 1x4 matrix that post-translates those 4 channels.
4313
+ * For example, the following is the layout with the scale (S) and post-transform
4314
+ * (PT) items indicated.
4315
+ * RS, 0, 0, 0 | RPT
4316
+ * 0, GS, 0, 0 | GPT
4317
+ * 0, 0, BS, 0 | BPT
4318
+ * 0, 0, 0, AS | APT
4319
+ */
4320
+ export type ColorMatrix = Float32Array;
4321
+ /**
4322
+ * An IRect is represented by 4 ints. In order, the ints correspond to left, top,
4323
+ * right, bottom. See Rect.h for more
4324
+ */
4325
+ export type IRect = Int32Array;
4326
+ /**
4327
+ * A Point is represented by 2 floats: (x, y).
4328
+ */
4329
+ export type Point = Float32Array;
4330
+ /**
4331
+ * A Rect is represented by 4 floats. In order, the floats correspond to left, top,
4332
+ * right, bottom. See Rect.h for more
4333
+ */
4334
+ export type Rect = Float32Array;
4335
+
4336
+ export interface RectWithDirection {
4337
+ rect: Rect;
4338
+ dir: TextDirection;
4339
+ }
4340
+
4341
+ /**
4342
+ * An RRect (rectangle with rounded corners) is represented by 12 floats. In order, the floats
4343
+ * correspond to left, top, right, bottom and then in pairs, the radiusX, radiusY for upper-left,
4344
+ * upper-right, lower-right, lower-left. See RRect.h for more.
4345
+ */
4346
+ export type RRect = Float32Array;
4347
+
4348
+ export type WebGLContextHandle = number;
4349
+ export type AngleInDegrees = number;
4350
+ export type AngleInRadians = number;
4351
+ export type SaveLayerFlag = number;
4352
+
4353
+ export type TypedArrayConstructor = Float32ArrayConstructor | Int32ArrayConstructor |
4354
+ Int16ArrayConstructor | Int8ArrayConstructor | Uint32ArrayConstructor |
4355
+ Uint16ArrayConstructor | Uint8ArrayConstructor;
4356
+ export type TypedArray = Float32Array | Int32Array | Int16Array | Int8Array | Uint32Array |
4357
+ Uint16Array | Uint8Array;
4358
+
4359
+ export type ColorIntArray = MallocObj | Uint32Array | number[];
4360
+ /**
4361
+ * FlattenedPointArray represents n points by 2*n float values. In order, the values should
4362
+ * be the x, y for each point.
4363
+ */
4364
+ export type FlattenedPointArray = Float32Array;
4365
+ /**
4366
+ * FlattenedRectangleArray represents n rectangles by 4*n float values. In order, the values should
4367
+ * be the top, left, right, bottom point for each rectangle.
4368
+ */
4369
+ export type FlattenedRectangleArray = Float32Array;
4370
+
4371
+ export type GlyphIDArray = Uint16Array;
4372
+ /**
4373
+ * A command is a verb and then any arguments needed to fulfill that path verb.
4374
+ * InputCommands is a flattened structure of one or more of these.
4375
+ * Examples:
4376
+ * [CanvasKit.MOVE_VERB, 0, 10,
4377
+ * CanvasKit.QUAD_VERB, 20, 50, 45, 60,
4378
+ * CanvasKit.LINE_VERB, 30, 40]
4379
+ */
4380
+ export type InputCommands = MallocObj | Float32Array | number[];
4381
+ /**
4382
+ * VerbList holds verb constants like CanvasKit.MOVE_VERB, CanvasKit.CUBIC_VERB.
4383
+ */
4384
+ export type VerbList = MallocObj | Uint8Array | number[];
4385
+ /**
4386
+ * WeightList holds weights for conics when making paths.
4387
+ */
4388
+ export type WeightList = MallocObj | Float32Array | number[];
4389
+
4390
+ export type Matrix4x4 = Float32Array;
4391
+ export type Matrix3x3 = Float32Array;
4392
+ export type Matrix3x2 = Float32Array;
4393
+
4394
+ /**
4395
+ * Vector2 represents an x, y coordinate or vector. It has length 2.
4396
+ */
4397
+ export type Vector2 = Point;
4398
+
4399
+ /**
4400
+ * Vector3 represents an x, y, z coordinate or vector. It has length 3.
4401
+ */
4402
+ export type Vector3 = number[];
4403
+
4404
+ /**
4405
+ * VectorN represents a vector of length n.
4406
+ */
4407
+ export type VectorN = number[];
4408
+
4409
+ /**
4410
+ * CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory as colors.
4411
+ * Length 4.
4412
+ */
4413
+ export type InputColor = MallocObj | Color | number[];
4414
+ /**
4415
+ * CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory as color matrices.
4416
+ * Length 20.
4417
+ */
4418
+ export type InputColorMatrix = MallocObj | ColorMatrix | number[];
4419
+ /**
4420
+ * CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory as glyph IDs.
4421
+ * Length n for n glyph IDs.
4422
+ */
4423
+ export type InputGlyphIDArray = MallocObj | GlyphIDArray | number[];
4424
+ /**
4425
+ * CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory as flattened points.
4426
+ * Length 2 * n for n points.
4427
+ */
4428
+ export type InputFlattenedPointArray = MallocObj | FlattenedPointArray | number[];
4429
+ /**
4430
+ * CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory as flattened rectangles.
4431
+ * Length 4 * n for n rectangles.
4432
+ */
4433
+ export type InputFlattenedRectangleArray = MallocObj | FlattenedRectangleArray | number[];
4434
+ /**
4435
+ * Some APIs accept a flattened array of colors in one of two ways - groups of 4 float values for
4436
+ * r, g, b, a or just integers that have 8 bits for each these. CanvasKit will detect which one
4437
+ * it is and act accordingly. Additionally, this can be an array of Float32Arrays of length 4
4438
+ * (e.g. Color). This is convenient for things like gradients when matching up colors to stops.
4439
+ */
4440
+ export type InputFlexibleColorArray = Float32Array | Uint32Array | Float32Array[];
4441
+ /**
4442
+ * CanvasKit APIs accept a Float32Array or a normal array (of length 2) as a Point.
4443
+ */
4444
+ export type InputPoint = Point | number[];
4445
+ /**
4446
+ * CanvasKit APIs accept all of these matrix types. Under the hood, we generally use 4x4 matrices.
4447
+ */
4448
+ export type InputMatrix = MallocObj | Matrix4x4 | Matrix3x3 | Matrix3x2 | DOMMatrix | number[];
4449
+ /**
4450
+ * CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory as rectangles.
4451
+ * Length 4.
4452
+ */
4453
+ export type InputRect = MallocObj | Rect | number[];
4454
+ /**
4455
+ * CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory as (int) rectangles.
4456
+ * Length 4.
4457
+ */
4458
+ export type InputIRect = MallocObj | IRect | number[];
4459
+ /**
4460
+ * CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory as rectangles with
4461
+ * rounded corners. Length 12.
4462
+ */
4463
+ export type InputRRect = MallocObj | RRect | number[];
4464
+ /**
4465
+ * This represents n RSXforms by 4*n float values. In order, the values should
4466
+ * be scos, ssin, tx, ty for each RSXForm. See RSXForm.h for more details.
4467
+ */
4468
+ export type InputFlattenedRSXFormArray = MallocObj | Float32Array | number[];
4469
+
4470
+ /**
4471
+ * InputVector2 maps to InputPoint, the alias is to not use the word "Point" when not accurate, but
4472
+ * they are in practice the same, a representation of x and y.
4473
+ */
4474
+ export type InputVector2 = InputPoint;
4475
+ /**
4476
+ * CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory as a vector of 3 floats.
4477
+ * For example, this is the x, y, z coordinates.
4478
+ */
4479
+ export type InputVector3 = MallocObj | Vector3 | Float32Array;
4480
+
4481
+ /**
4482
+ * CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory
4483
+ * for bidi regions. Regions are triples of integers
4484
+ * [startIdx, stopIdx, bidiLevel]
4485
+ * where startIdx is inclusive and stopIdx is exclusive.
4486
+ * Length 3 * n where n is the number of regions.
4487
+ */
4488
+ export type InputBidiRegions = MallocObj | Uint32Array | number[];
4489
+
4490
+ /**
4491
+ * CanvasKit APIs accept normal arrays, typed arrays, or Malloc'd memory for
4492
+ * words, graphemes or line breaks.
4493
+ */
4494
+ export type InputWords = MallocObj | Uint32Array | number[];
4495
+ export type InputGraphemes = MallocObj | Uint32Array | number[];
4496
+ export type InputLineBreaks = MallocObj | Uint32Array | number[];
4497
+
4498
+ /**
4499
+ * These are the types that webGL's texImage2D supports as a way to get data from as a texture.
4500
+ * Not listed, but also supported are https://developer.mozilla.org/en-US/docs/Web/API/VideoFrame
4501
+ */
4502
+ export type TextureSource = TypedArray | HTMLImageElement | HTMLVideoElement | ImageData | ImageBitmap;
4503
+
4504
+ export type AlphaType = EmbindEnumEntity;
4505
+ export type BlendMode = EmbindEnumEntity;
4506
+ export type BlurStyle = EmbindEnumEntity;
4507
+ export type ClipOp = EmbindEnumEntity;
4508
+ export type ColorChannel = EmbindEnumEntity;
4509
+ export type ColorSpace = EmbindObject<"ColorSpace">;
4510
+ export type ColorType = EmbindEnumEntity;
4511
+ export type EncodedImageFormat = EmbindEnumEntity;
4512
+ export type FillType = EmbindEnumEntity;
4513
+ export type FilterMode = EmbindEnumEntity;
4514
+ export type FontEdging = EmbindEnumEntity;
4515
+ export type FontHinting = EmbindEnumEntity;
4516
+ export type MipmapMode = EmbindEnumEntity;
4517
+ export type PaintStyle = EmbindEnumEntity;
4518
+ export type Path1DEffectStyle = EmbindEnumEntity;
4519
+ export type PathOp = EmbindEnumEntity;
4520
+ export type PointMode = EmbindEnumEntity;
4521
+ export type StrokeCap = EmbindEnumEntity;
4522
+ export type StrokeJoin = EmbindEnumEntity;
4523
+ export type TileMode = EmbindEnumEntity;
4524
+ export type VertexMode = EmbindEnumEntity;
4525
+ export type InputState = EmbindEnumEntity;
4526
+ export type ModifierKey = EmbindEnumEntity;
4527
+
4528
+ export type Affinity = EmbindEnumEntity;
4529
+ export type DecorationStyle = EmbindEnumEntity;
4530
+ export type FontSlant = EmbindEnumEntity;
4531
+ export type FontWeight = EmbindEnumEntity;
4532
+ export type FontWidth = EmbindEnumEntity;
4533
+ export type PlaceholderAlignment = EmbindEnumEntity;
4534
+ export type RectHeightStyle = EmbindEnumEntity;
4535
+ export type RectWidthStyle = EmbindEnumEntity;
4536
+ export type TextAlign = EmbindEnumEntity;
4537
+ export type TextBaseline = EmbindEnumEntity;
4538
+ export type TextDirection = EmbindEnumEntity;
4539
+ export type LineBreakType = EmbindEnumEntity;
4540
+ export type TextHeightBehavior = EmbindEnumEntity;
4541
+
4542
+ export interface AffinityEnumValues extends EmbindEnum {
4543
+ Upstream: Affinity;
4544
+ Downstream: Affinity;
4545
+ }
4546
+
4547
+ export interface AlphaTypeEnumValues extends EmbindEnum {
4548
+ Opaque: AlphaType;
4549
+ Premul: AlphaType;
4550
+ Unpremul: AlphaType;
4551
+ }
4552
+
4553
+ export interface BlendModeEnumValues extends EmbindEnum {
4554
+ Clear: BlendMode;
4555
+ Src: BlendMode;
4556
+ Dst: BlendMode;
4557
+ SrcOver: BlendMode;
4558
+ DstOver: BlendMode;
4559
+ SrcIn: BlendMode;
4560
+ DstIn: BlendMode;
4561
+ SrcOut: BlendMode;
4562
+ DstOut: BlendMode;
4563
+ SrcATop: BlendMode;
4564
+ DstATop: BlendMode;
4565
+ Xor: BlendMode;
4566
+ Plus: BlendMode;
4567
+ Modulate: BlendMode;
4568
+ Screen: BlendMode;
4569
+ Overlay: BlendMode;
4570
+ Darken: BlendMode;
4571
+ Lighten: BlendMode;
4572
+ ColorDodge: BlendMode;
4573
+ ColorBurn: BlendMode;
4574
+ HardLight: BlendMode;
4575
+ SoftLight: BlendMode;
4576
+ Difference: BlendMode;
4577
+ Exclusion: BlendMode;
4578
+ Multiply: BlendMode;
4579
+ Hue: BlendMode;
4580
+ Saturation: BlendMode;
4581
+ Color: BlendMode;
4582
+ Luminosity: BlendMode;
4583
+ }
4584
+
4585
+ export interface BlurStyleEnumValues extends EmbindEnum {
4586
+ Normal: BlurStyle;
4587
+ Solid: BlurStyle;
4588
+ Outer: BlurStyle;
4589
+ Inner: BlurStyle;
4590
+ }
4591
+
4592
+ export interface ClipOpEnumValues extends EmbindEnum {
4593
+ Difference: ClipOp;
4594
+ Intersect: ClipOp;
4595
+ }
4596
+
4597
+ /**
4598
+ * The currently supported color spaces. These are all singleton values.
4599
+ */
4600
+ export interface ColorSpaceEnumValues { // not a typical enum, but effectively like one.
4601
+ // These are all singleton values - don't call delete on them.
4602
+ readonly SRGB: ColorSpace;
4603
+ readonly DISPLAY_P3: ColorSpace;
4604
+ readonly ADOBE_RGB: ColorSpace;
4605
+
4606
+ /**
4607
+ * Returns true if the two color spaces are equal.
4608
+ * @param a
4609
+ * @param b
4610
+ */
4611
+ Equals(a: ColorSpace, b: ColorSpace): boolean;
4612
+ }
4613
+
4614
+ export interface ColorChannelEnumValues extends EmbindEnum {
4615
+ Red: ColorChannel;
4616
+ Green: ColorChannel;
4617
+ Blue: ColorChannel;
4618
+ Alpha: ColorChannel;
4619
+ }
4620
+
4621
+ export interface ColorTypeEnumValues extends EmbindEnum {
4622
+ Alpha_8: ColorType;
4623
+ RGB_565: ColorType;
4624
+ RGBA_8888: ColorType;
4625
+ BGRA_8888: ColorType;
4626
+ RGBA_1010102: ColorType;
4627
+ RGB_101010x: ColorType;
4628
+ Gray_8: ColorType;
4629
+ RGBA_F16: ColorType;
4630
+ RGBA_F32: ColorType;
4631
+ }
4632
+
4633
+ export interface DecorationStyleEnumValues extends EmbindEnum {
4634
+ Solid: DecorationStyle;
4635
+ Double: DecorationStyle;
4636
+ Dotted: DecorationStyle;
4637
+ Dashed: DecorationStyle;
4638
+ Wavy: DecorationStyle;
4639
+ }
4640
+
4641
+ export interface FillTypeEnumValues extends EmbindEnum {
4642
+ Winding: FillType;
4643
+ EvenOdd: FillType;
4644
+ }
4645
+
4646
+ export interface FilterModeEnumValues extends EmbindEnum {
4647
+ Linear: FilterMode;
4648
+ Nearest: FilterMode;
4649
+ }
4650
+
4651
+ export interface FontEdgingEnumValues extends EmbindEnum {
4652
+ Alias: FontEdging;
4653
+ AntiAlias: FontEdging;
4654
+ SubpixelAntiAlias: FontEdging;
4655
+ }
4656
+
4657
+ export interface FontHintingEnumValues extends EmbindEnum {
4658
+ None: FontHinting;
4659
+ Slight: FontHinting;
4660
+ Normal: FontHinting;
4661
+ Full: FontHinting;
4662
+ }
4663
+
4664
+ export interface FontSlantEnumValues extends EmbindEnum {
4665
+ Upright: FontSlant;
4666
+ Italic: FontSlant;
4667
+ Oblique: FontSlant;
4668
+ }
4669
+
4670
+ export interface FontWeightEnumValues extends EmbindEnum {
4671
+ Invisible: FontWeight;
4672
+ Thin: FontWeight;
4673
+ ExtraLight: FontWeight;
4674
+ Light: FontWeight;
4675
+ Normal: FontWeight;
4676
+ Medium: FontWeight;
4677
+ SemiBold: FontWeight;
4678
+ Bold: FontWeight;
4679
+ ExtraBold: FontWeight;
4680
+ Black: FontWeight;
4681
+ ExtraBlack: FontWeight;
4682
+ }
4683
+
4684
+ export interface FontWidthEnumValues extends EmbindEnum {
4685
+ UltraCondensed: FontWidth;
4686
+ ExtraCondensed: FontWidth;
4687
+ Condensed: FontWidth;
4688
+ SemiCondensed: FontWidth;
4689
+ Normal: FontWidth;
4690
+ SemiExpanded: FontWidth;
4691
+ Expanded: FontWidth;
4692
+ ExtraExpanded: FontWidth;
4693
+ UltraExpanded: FontWidth;
4694
+ }
4695
+
4696
+ /*
4697
+ * These values can be OR'd together
4698
+ */
4699
+ export interface GlyphRunFlagValues {
4700
+ IsWhiteSpace: number;
4701
+ }
4702
+
4703
+ export interface ImageFormatEnumValues extends EmbindEnum {
4704
+ // TODO(kjlubick) When these are compiled in depending on the availability of the codecs,
4705
+ // be sure to make these nullable.
4706
+ PNG: EncodedImageFormat;
4707
+ JPEG: EncodedImageFormat;
4708
+ WEBP: EncodedImageFormat;
4709
+ }
4710
+
4711
+ export interface MipmapModeEnumValues extends EmbindEnum {
4712
+ None: MipmapMode;
4713
+ Nearest: MipmapMode;
4714
+ Linear: MipmapMode;
4715
+ }
4716
+
4717
+ export interface PaintStyleEnumValues extends EmbindEnum {
4718
+ Fill: PaintStyle;
4719
+ Stroke: PaintStyle;
4720
+ }
4721
+
4722
+ export interface Path1DEffectStyleEnumValues extends EmbindEnum {
4723
+ // Translate the shape to each position
4724
+ Translate: Path1DEffectStyle;
4725
+ // Rotate the shape about its center
4726
+ Rotate: Path1DEffectStyle;
4727
+ // Transform each point and turn lines into curves
4728
+ Morph: Path1DEffectStyle;
4729
+ }
4730
+
4731
+ export interface PathOpEnumValues extends EmbindEnum {
4732
+ Difference: PathOp;
4733
+ Intersect: PathOp;
4734
+ Union: PathOp;
4735
+ XOR: PathOp;
4736
+ ReverseDifference: PathOp;
4737
+ }
4738
+
4739
+ export interface PlaceholderAlignmentEnumValues extends EmbindEnum {
4740
+ Baseline: PlaceholderAlignment;
4741
+ AboveBaseline: PlaceholderAlignment;
4742
+ BelowBaseline: PlaceholderAlignment;
4743
+ Top: PlaceholderAlignment;
4744
+ Bottom: PlaceholderAlignment;
4745
+ Middle: PlaceholderAlignment;
4746
+ }
4747
+
4748
+ export interface PointModeEnumValues extends EmbindEnum {
4749
+ Points: PointMode;
4750
+ Lines: PointMode;
4751
+ Polygon: PointMode;
4752
+ }
4753
+
4754
+ export interface RectHeightStyleEnumValues extends EmbindEnum {
4755
+ Tight: RectHeightStyle;
4756
+ Max: RectHeightStyle;
4757
+ IncludeLineSpacingMiddle: RectHeightStyle;
4758
+ IncludeLineSpacingTop: RectHeightStyle;
4759
+ IncludeLineSpacingBottom: RectHeightStyle;
4760
+ Strut: RectHeightStyle;
4761
+ }
4762
+
4763
+ export interface RectWidthStyleEnumValues extends EmbindEnum {
4764
+ Tight: RectWidthStyle;
4765
+ Max: RectWidthStyle;
4766
+ }
4767
+
4768
+ export interface StrokeCapEnumValues extends EmbindEnum {
4769
+ Butt: StrokeCap;
4770
+ Round: StrokeCap;
4771
+ Square: StrokeCap;
4772
+ }
4773
+
4774
+ export interface StrokeJoinEnumValues extends EmbindEnum {
4775
+ Bevel: StrokeJoin;
4776
+ Miter: StrokeJoin;
4777
+ Round: StrokeJoin;
4778
+ }
4779
+
4780
+ export interface TextAlignEnumValues extends EmbindEnum {
4781
+ Left: TextAlign;
4782
+ Right: TextAlign;
4783
+ Center: TextAlign;
4784
+ Justify: TextAlign;
4785
+ Start: TextAlign;
4786
+ End: TextAlign;
4787
+ }
4788
+
4789
+ export interface TextBaselineEnumValues extends EmbindEnum {
4790
+ Alphabetic: TextBaseline;
4791
+ Ideographic: TextBaseline;
4792
+ }
4793
+
4794
+ export interface TextDirectionEnumValues extends EmbindEnum {
4795
+ LTR: TextDirection;
4796
+ RTL: TextDirection;
4797
+ }
4798
+
4799
+ export interface LineBreakTypeEnumValues extends EmbindEnum {
4800
+ SoftLineBreak: LineBreakType;
4801
+ HardtLineBreak: LineBreakType;
4802
+ }
4803
+
4804
+ export interface TextHeightBehaviorEnumValues extends EmbindEnum {
4805
+ All: TextHeightBehavior;
4806
+ DisableFirstAscent: TextHeightBehavior;
4807
+ DisableLastDescent: TextHeightBehavior;
4808
+ DisableAll: TextHeightBehavior;
4809
+ }
4810
+
4811
+ export interface TileModeEnumValues extends EmbindEnum {
4812
+ Clamp: TileMode;
4813
+ Decal: TileMode;
4814
+ Mirror: TileMode;
4815
+ Repeat: TileMode;
4816
+ }
4817
+
4818
+ export interface VertexModeEnumValues extends EmbindEnum {
4819
+ Triangles: VertexMode;
4820
+ TrianglesStrip: VertexMode;
4821
+ TriangleFan: VertexMode;
4822
+ }
4823
+
4824
+ export interface InputStateEnumValues extends EmbindEnum {
4825
+ Down: InputState;
4826
+ Up: InputState;
4827
+ Move: InputState;
4828
+ Right: InputState; // fling only
4829
+ Left: InputState; // fling only
4830
+ }
4831
+
4832
+ export interface ModifierKeyEnumValues extends EmbindEnum {
4833
+ None: ModifierKey;
4834
+ Shift: ModifierKey;
4835
+ Control: ModifierKey;
4836
+ Option: ModifierKey;
4837
+ Command: ModifierKey;
4838
+ FirstPress: ModifierKey;
4839
+ }
4840
+
4841
+ export type VerticalAlign = EmbindEnumEntity;
4842
+
4843
+ export interface VerticalTextAlignEnumValues extends EmbindEnum {
4844
+ Top: VerticalAlign;
4845
+ TopBaseline: VerticalAlign;
4846
+
4847
+ // Skottie vertical alignment extensions
4848
+ // Visual alignement modes -- these are using tight visual bounds for the paragraph.
4849
+ VisualTop: VerticalAlign; // visual top -> text box top
4850
+ VisualCenter: VerticalAlign; // visual center -> text box center
4851
+ VisualBottom: VerticalAlign; // visual bottom -> text box bottom
4852
+ }
4853
+
4854
+ export type ResizePolicy = EmbindEnumEntity;
4855
+
4856
+ export interface ResizePolicyEnumValues extends EmbindEnum {
4857
+ // Use the specified text size.
4858
+ None: ResizePolicy;
4859
+ // Resize the text such that the extent box fits (snuggly) in the text box,
4860
+ // both horizontally and vertically.
4861
+ ScaleToFit: ResizePolicy;
4862
+ // Same kScaleToFit if the text doesn't fit at the specified font size.
4863
+ // Otherwise, same as kNone.
4864
+ DownscaleToFit: ResizePolicy;
4865
+ }