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