html2pdf-accessible 0.0.0-stage → 0.1.5

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