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