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