• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * Filling style algorithm, which determines whether a point is within or outside the path. The following
18 *    two configurations are supported:
19 * "evenodd": odd and even round rule
20 * "nonzero": (Default) Non-zero Wrap Rules
21 * @since 8
22 */
23declare type CanvasFillRule = "evenodd" | "nonzero";
24
25/**
26 * Specifies the attribute of drawing the end of each line segment. The following configurations are supported:
27 * "butt": (Default) Segment Ends in Square
28 * "round": Segment ends in a circle
29 * "square": The end of the segment ends in a square, but a rectangular area is added that is the same width
30 *    as the segment and is half the thickness of the segment.
31 * @since 8
32 */
33declare type CanvasLineCap = "butt" | "round" | "square";
34
35/**
36 * Sets the attribute of how two connected parts (line segments, arcs, and curves) whose length is not 0
37 *    are connected together. The following three configurations are supported:
38 * "bevel": Fill the ends of the connected sections with an additional triangle-base area,
39 *    each with its own independent rectangular corner.
40 * "miter": (Default) An additional diamond region is formed by extending the outer edges of the connected portions
41 *    so that they intersect at a point.
42 * "round": Draw the shape of the corner by filling in an additional sector with the center at the end of the
43 *    connected section. The radius of the fillet is the width of the segment.
44 * @since 8
45 */
46declare type CanvasLineJoin = "bevel" | "miter" | "round";
47
48/**
49 * Indicates the attribute of the current text direction. The options are as follows:
50 * "inherit": (Default) Inherit current Canvas component settings
51 * "ltr": The text direction is left to right.
52 * "rtl": The text direction is from right to left.
53 * @since 8
54 */
55declare type CanvasDirection = "inherit" | "ltr" | "rtl";
56
57/**
58 * Describes the alignment mode for drawing text. The options are as follows:
59 * "center": The text is centered.
60 * "end": Where text aligns lines end (Left alignment refers to the local from left to right,
61 *    and right alignment refers to the local from right to left)
62 * "left": The text is left-aligned.
63 * "right": The text is right-aligned.
64 * "start": (Default) Where the text snap line begins (Left alignment refers to the local from left to right,
65 *    and right alignment refers to the local from right to left)
66 * @since 8
67 */
68declare type CanvasTextAlign = "center" | "end" | "left" | "right" | "start";
69
70/**
71 * Text baseline, which supports the following configurations:
72 * "alphabetic": (Default) The text baseline is the standard letter baseline.
73 * "bottom": The text baseline is at the bottom of the text block. The difference between the ideographic baseline
74 *    and the ideographic baseline is that the ideographic baseline does not need to consider downlink letters.
75 * "hanging": The text baseline is a hanging baseline.
76 * "ideographic": The text baseline is the ideographic baseline; If the character itself exceeds the alphabetic
77 *    baseline, the ideograhpic baseline is at the bottom of the character itself.
78 * "middle": The text baseline is in the middle of the text block.
79 * "top": The text baseline is at the top of the text block.
80 * @since 8
81 */
82declare type CanvasTextBaseline = "alphabetic" | "bottom" | "hanging" | "ideographic" | "middle" | "top";
83
84/**
85 * Sets the image smoothness attribute. The options are as follows:
86 * "high": height
87 * "low": (default)low
88 * "medium": medium
89 * @since 8
90 */
91declare type ImageSmoothingQuality = "high" | "low" | "medium";
92
93/**
94 * Opaque objects that describe gradients, created by createLinearGradient() or createRadialGradient()
95 * @since 8
96 */
97declare class CanvasGradient {
98  /**
99   * Add a breakpoint defined by offset and color to the gradient
100   * @param number Value between 0 and 1, out of range throws INDEX_SIZE_ERR error
101   * @param string CSS color value <color>. If the color value cannot be resolved to a valid CSS color value <color>
102   *    a SYNTAX_ERR error is thrown.
103   * @since 8
104   */
105  addColorStop(offset: number, color: string): void;
106}
107
108/**
109 * Path object, which provides basic methods for drawing paths.
110 * @since 8
111 */
112declare class CanvasPath {
113  /**
114   * Draw an arc path
115   * @param x The x-axis coordinate of the center (center of the circle) of the arc.
116   * @param y The y-axis coordinate of the center (center of the circle) of the arc.
117   * @param radius Radius of the arc.
118   * @param startAngle Start point of an arc, which starts to be calculated in the x-axis direction. The unit is radian.
119   * @param endAngle The end point of the arc, in radians.
120   * @param counterclockwise If the value is true, the arc is drawn counterclockwise. Otherwise,
121   *    the arc is drawn clockwise. The default value is false.
122   * @since 8
123   */
124  arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
125
126  /**
127   * Draw arc paths based on control points and radius
128   * @param x1 The x-axis coordinate of the first control point.
129   * @param y1 The y-axis coordinate of the first control point.
130   * @param x2 The x-axis coordinate of the second control point.
131   * @param y2 The y-axis coordinate of the second control point.
132   * @param radius Radius of the arc.
133   * @since 8
134   */
135  arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
136
137  /**
138   * Drawing Cubic Bessel Curve Paths
139   * @param cp1x The x-axis coordinate of the first control point.
140   * @param cp1y The y-axis coordinate of the first control point.
141   * @param cp2x The x-axis coordinate of the second control point.
142   * @param cp2y The y-axis coordinate of the second control point.
143   * @param x x-axis coordinate of the end point.
144   * @param y y-axis coordinate of the end point.
145   * @since 8
146   */
147  bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
148
149  /**
150   * Returns the pen point to the start point of the current subpath
151   * @since 8
152   */
153  closePath(): void;
154
155  /**
156   * Draw an Elliptic Path
157   * @param x x-axis coordinate of the center of the ellipse.
158   * @param y y-axis coordinate of the center of the ellipse.
159   * @param radiusX Radius of the major axis of the ellipse.
160   * @param radiusY Radius of the minor axis of the ellipse.
161   * @param rotation The rotation angle of the ellipse, in radians (not angular degrees).
162   * @param startAngle The angle of the starting point to be drawn, measured from the x-axis in radians
163   *    (not angular degrees).
164   * @param endAngle The angle, in radians, at which the ellipse is to be drawn (not angular degrees).
165   * @param counterclockwise If the value is true, the ellipse is drawn counterclockwise. Otherwise,
166   *    the ellipse is drawn clockwise. The default value is false.
167   * @since 8
168   */
169  ellipse(
170    x: number,
171    y: number,
172    radiusX: number,
173    radiusY: number,
174    rotation: number,
175    startAngle: number,
176    endAngle: number,
177    counterclockwise?: boolean,
178  ): void;
179
180  /**
181   * Connect subpaths using straight lines
182   * @param x The x-axis coordinate of the end point of the line.
183   * @param y The y-axis coordinate of the end point of the line.
184   * @since 8
185   */
186  lineTo(x: number, y: number): void;
187
188  /**
189   * Moves the start point of a new subpath to the (x, y) coordinate.
190   * @param x The x-axis coordinate of the point.
191   * @param y The y-axis coordinate of the point.
192   * @since 8
193   */
194  moveTo(x: number, y: number): void;
195
196  /**
197   * Draw quadratic Bezier curve paths
198   * @param cpx The x-axis coordinate of the control point.
199   * @param cpy The y-axis coordinate of the control point.
200   * @param x x-axis coordinate of the end point.
201   * @param y y-axis coordinate of the end point.
202   * @since 8
203   */
204  quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
205
206  /**
207   * Draw Rectangular Paths
208   * @param x The x-axis coordinate of the start point of the rectangle.
209   * @param y The y-axis coordinate of the start point of the rectangle.
210   * @param w Width of the rectangle.
211   * @param h Height of the rectangle.
212   * @since 8
213   */
214  rect(x: number, y: number, w: number, h: number): void;
215}
216
217/**
218 * 2D path object for path drawing
219 * @since 8
220 */
221declare class Path2D extends CanvasPath {
222  /**
223   * Adds a path according to the specified path variable.
224   * @param path Indicates the path object to be added.
225   * @param transform Transformation matrix of the new trail
226   * @since 8
227   */
228  addPath(path: Path2D, transform?: Matrix2D): void;
229
230  /**
231   * Create an empty path object.
232   * @since 8
233   */
234  constructor();
235
236  /**
237   * Create a copy of a path object
238   * @param path Path object to be copied
239   * @since 8
240   */
241  constructor(path: Path2D);
242
243  /**
244   * Create a new path according to the description.
245   * @param d Indicates the path string that compiles with the SVG path description specifications.
246   * @since 8
247   */
248  constructor(d: string);
249}
250
251/**
252 * Describes an opaque object of a template, which is created using the createPattern() method.
253 * @since 8
254 */
255declare type CanvasPattern = import('../api/@internal/full/canvaspattern').CanvasPattern;
256
257/**
258 * Size information of the text
259 * @since 8
260 */
261declare interface TextMetrics {
262  /**
263   * Double, the distance from the horizontal line indicated by the textBaseline property to the top of
264   *    the rectangular boundary of the rendered text.
265   * @since 8
266   */
267  readonly actualBoundingBoxAscent: number;
268
269  /**
270   * Double, the distance from the horizontal line indicated by the textBaseline property to the bottom of
271   *    the rectangular boundary of the rendered text.
272   * @since 8
273   */
274  readonly actualBoundingBoxDescent: number;
275
276  /**
277   * Double, parallel to the baseline, distance from the alignment point determined by the textAlign property to
278   *    the left of the text rectangle boundary.
279   * @since 8
280   */
281  readonly actualBoundingBoxLeft: number;
282
283  /**
284   * Double, parallel to the baseline, distance from the alignment point determined by the textAlign property to
285   *    the right of the text rectangle boundary.
286   * @since 8
287   */
288  readonly actualBoundingBoxRight: number;
289
290  /**
291   * Double, the distance from the horizontal line indicated by the textBaseline property to the alphabetic baseline of
292   *    the wireframe.
293   * @since 8
294   */
295  readonly alphabeticBaseline: number;
296
297  /**
298   * Double, the distance from the horizontal line indicated by the textBaseline property to the top of the
299   *    em square in the wireframe.
300   * @since 8
301   */
302  readonly emHeightAscent: number;
303
304  /**
305   * Double, distance from the horizontal line indicated by the textBaseline property to the bottom of the
306   *    em box in the wireframe.
307   * @since 8
308   */
309  readonly emHeightDescent: number;
310
311  /**
312   * Double, distance from the horizontal line indicated by the textBaseline property to the top of the
313   *    highest rectangle boundary of all fonts rendering text.
314   * @since 8
315   */
316  readonly fontBoundingBoxAscent: number;
317
318  /**
319   * Double, distance from the horizontal line indicated by the textBaseline property to the bottom of the
320   *   rectangular boundary of all fonts rendering text.
321   * @since 8
322   */
323  readonly fontBoundingBoxDescent: number;
324
325  /**
326   * Double, distance from the horizontal line indicated by the textBaseline property to
327   *    the hanging baseline of the wireframe.
328   * @since 8
329   */
330  readonly hangingBaseline: number;
331
332  /**
333   * Double, distance from the horizontal line indicated by the textBaseline property to
334   *    the ideographic baseline of the wireframe.
335   * @since 8
336   */
337  readonly ideographicBaseline: number;
338
339  /**
340   * Indicates the width of a character string. The value is of the double type.
341   * @since 8
342   */
343  readonly width: number;
344
345  /**
346   * Indicates the height of a character string. The value is of the double type.
347   * @since 8
348   */
349  readonly height: number;
350}
351
352/**
353 * Bitmap image object that can be drawn onto the current Canvas
354 * @since 8
355 */
356declare class ImageBitmap {
357  /**
358   * Indicates the height of the CSS pixel unit of ImageData.
359   * @since 8
360   */
361  readonly height: number;
362
363  /**
364   * Indicates the width of the CSS pixel unit of ImageData.
365   * @since 8
366   */
367  readonly width: number;
368
369  /**
370   * Releases all graphics resources associated with an ImageBitmap.
371   * @since 8
372   */
373  close(): void;
374
375  /**
376   * Create an ImageBitmap object based on the transferred image path.
377   * @param src Path of the image object.
378   * @since 8
379   */
380  constructor(src: string);
381
382  /**
383   * Transfer a PixelMap object to construct an ImageBitmap object.
384   * @param data PixelMap object
385   * @since 8
386   */
387  constructor(data: PixelMap);
388}
389
390/**
391 * Image data object
392 * @since 8
393 */
394declare class ImageData {
395  /**
396   * Array containing image pixel data
397   * @since 8
398   */
399  readonly data: Uint8ClampedArray;
400
401  /**
402   * Width of the image.
403   * @since 8
404   */
405  readonly height: number;
406
407  /**
408   * Height of the image.
409   * @since 8
410   */
411  readonly width: number;
412
413  /**
414   * Create an ImageData object based on the input parameters.
415   * @param width Width of the image.
416   * @param height Height of the image.
417   * @param data Data of the image. If this parameter is not specified, the default value is a black rectangular image.
418   * @since 8
419   */
420  constructor(width: number, height: number, data?: Uint8ClampedArray);
421}
422
423/**
424 * This object allows you to set properties when creating a rendering context
425 * @since 8
426 */
427declare class RenderingContextSettings {
428  /**
429   * Indicates whether anti-aliasing is enabled for canvas. The default value is false.
430   * @since 8
431   */
432  antialias?: boolean;
433
434  /**
435   * Create an RenderingContextSettings object based on the antialias and alpha.
436   * @param antialias Indicates whether anti-aliasing is enabled for canvas
437   * @since 8
438   */
439  constructor(antialias?: boolean);
440}
441
442/**
443 * Canvas renderer for drawing shapes, text, images and other objects
444 * @since 8
445 */
446declare class CanvasRenderer extends CanvasPath {
447  /**
448   * Transparency. The value ranges from 0.0 (completely transparent) to 1.0 (completely opaque).
449   *    The default value is 1.0. If the value is out of range, the assignment is invalid.
450   * @since 8
451   */
452  globalAlpha: number;
453
454  /**
455   * Type of composition operation applied when drawing a new shape. The following types are supported:
456   * source-over: (Default) Draws a new drawing on top of an existing canvas context.
457   * source-in: The new drawing is drawn only where the new drawing overlaps the target canvas.
458   *    Everything else is transparent.
459   * source-out: Draws a new drawing where it does not overlap with the existing canvas content.
460   * source-atop: The new drawing is drawn only where it overlaps the content of the existing canvas.
461   * destination-over: Draws a new graphic behind the existing canvas content.
462   * destination-in: Existing canvas content remains where the new drawing overlaps the existing canvas content.
463   *    Everything else is transparent.
464   * destination-out: Existing content remains where the new drawing does not overlap.
465   * destination-atop: The existing canvas retains only the part that overlaps with the new drawing,
466   *    which is drawn behind the canvas content.
467   * lighter: The color of two overlapping shapes is determined by adding the color values.
468   * copy: Only new graphics are displayed.
469   * xor: In the image, those overlaps and other places outside of the normal drawing are transparent.
470   * multiply: Multiply the top pixel by the bottom pixel, and the result is a darker picture.
471   * screen: The pixels are inverted, multiplied, and inverted again, and the result is a brighter picture.
472   * overlay: The combination of multiply and screen enables dark places to be darker and bright places to be brighter.
473   * darken: Keeps the darkest pixel in both layers.
474   * lighten: Keeps the brightest pixel in both layers.
475   * color-dodge: The inverse of dividing the bottom layer by the top layer.
476   * color-burn: Divide the inverted bottom layer by the top layer, and reverse the result.
477   * hard-light: A combination of multiplication and screen is similar to overlay, but the layers are interchanged.
478   * soft-light: Subtract the bottom from the top or vice versa to get a positive value.
479   * difference: A softer version of hard-light. Pure black or pure white does not result in pure black or pure white.
480   * exclusion: Similar to difference, but with lower contrast.
481   * hue: The luminance and chroma of the bottom layer are retained while the hue of the top layer is employed.
482   * saturation: The luminance (luma) and hue (hue) of the bottom layer are retained while the chroma (chroma) of
483   *    the top layer is used.
484   * color: The luminance (luma) of the bottom layer is retained while the hue (hue) and chroma (chroma) of
485   *    the top layer are used.
486   * luminosity: The hue and chroma of the bottom layer are maintained while the luminance of the top layer is used.
487   * @since 8
488   */
489  globalCompositeOperation: string;
490
491  /**
492   * Draw an image on a canvas
493   * @param image Picture objects drawn to the canvas.
494   * @param dx x-axis coordinate of the upper left corner of the image on the target canvas.
495   * @param dy y-axis coordinate of the upper left corner of the image on the target canvas.
496   * @since 8
497   */
498  drawImage(image: ImageBitmap | PixelMap, dx: number, dy: number): void;
499
500  /**
501   * Draw an image on a canvas
502   * @param image Picture objects drawn to the canvas.
503   * @param dx x-axis coordinate of the upper left corner of the image on the target canvas.
504   * @param dy y-axis coordinate of the upper left corner of the image on the target canvas.
505   * @param dw Specifies the drawing width of the image on the target canvas. The width of the drawn image will be scaled.
506   * @param dh Specifies the drawing height of the image on the target canvas. The height of the drawn image will be scaled.
507   * @since 8
508   */
509  drawImage(image: ImageBitmap | PixelMap, dx: number, dy: number, dw: number, dh: number): void;
510
511  /**
512   *Draw an image on a canvas
513   * @param image Picture objects drawn to the canvas.
514   * @param sx x coordinate of the upper left corner of the rectangle (cropping) selection box of the image.
515   * @param sy y coordinate of the upper left corner of the rectangle (cropping) selection box of the image.
516   * @param sw Width of the rectangle (cropping) selection box of the image.
517   * @param sh Height of the rectangle (cropping) selection box of the image.
518   * @param dx x-axis coordinate of the upper left corner of the image on the target canvas.
519   * @param dy y-axis coordinate of the upper left corner of the image on the target canvas.
520   * @param dw Specifies the drawing width of the image on the target canvas. The width of the drawn image will be scaled.
521   * @param dh Specifies the drawing height of the image on the target canvas. The height of the drawn image will be scaled.
522   * @since 8
523   */
524  drawImage(
525    image: ImageBitmap | PixelMap,
526    sx: number,
527    sy: number,
528    sw: number,
529    sh: number,
530    dx: number,
531    dy: number,
532    dw: number,
533    dh: number,
534  ): void;
535
536  /**
537   * Clear the sub-path list and start a new path.
538   * @since 8
539   */
540  beginPath(): void;
541
542  /**
543   * Sets the currently created path as the current clipping path
544   * @param fillRule Algorithm rule. For details, see {@link CanvasFillRule}.
545   * @since 8
546   */
547  clip(fillRule?: CanvasFillRule): void;
548
549  /**
550   * Tailoring according to the specified path
551   * @param path Path to be cut.
552   * @param fillRule Algorithm rule. For details, see {@link CanvasFillRule}.
553   * @since 8
554   */
555  clip(path: Path2D, fillRule?: CanvasFillRule): void;
556
557  /**
558   * Fills existing paths according to the current fill style.
559   * @param fillRule Algorithm rule. For details, see {@link CanvasFillRule}.
560   * @since 8
561   */
562  fill(fillRule?: CanvasFillRule): void;
563
564  /**
565   * Fills the specified path according to the current fill style
566   * @param path Path to be filled.
567   * @param fillRule Algorithm rule. For details, see {@link CanvasFillRule}.
568   * @since 8
569   */
570  fill(path: Path2D, fillRule?: CanvasFillRule): void;
571
572  /**
573   * Draws an existing path according to the current stroke style.
574   * @since 8
575   */
576  stroke(): void;
577
578  /**
579   * Draws the specified path according to the current stroke style
580   * @param path Specified stroke path object
581   * @since 8
582   */
583  stroke(path: Path2D): void;
584
585  /**
586   * Attributes that describe the fill color and style. The default value is # 000 (black). The options are as follows:
587   * color: Color String
588   * CanvasGradient: Color gradient object. For details, see {@link CanvasGradient}.
589   * CanvasPattern: Template object. For details, see {@link CanvasPattern}.
590   * @param path Specified stroke path object
591   * @since 8
592   */
593  fillStyle: string | CanvasGradient | CanvasPattern;
594
595  /**
596   * Attributes of the stroke color and style. The default value is # 000 (black). The options are as follows:
597   * color: Color String
598   * CanvasGradient: Color gradient object. For details, see {@link CanvasGradient}.
599   * CanvasPattern: Template object. For details, see {@link CanvasPattern}.
600   * @param path Specified stroke path object
601   * @since 8
602   */
603  strokeStyle: string | CanvasGradient | CanvasPattern;
604
605  /**
606   * Creates a linear gradient object that is specified along the parameter coordinates
607   * @param x0 The x-axis coordinate of the start point.
608   * @param y0 The y-axis coordinate of the start point.
609   * @param x1 x-axis coordinate of the end point.
610   * @param y1 y-axis coordinate of the end point.
611   * @since 8
612   */
613  createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient;
614
615  /**
616   * Creates a template object using the specified image
617   * @param image Objects as duplicate image sources
618   * @param repetition Specifies how to repeat images. The following four modes are supported:
619   * "repeat": Repeated images in both X and Y directions
620   * "repeat-x": Repeated images in the X-axis direction but not in the Y-axis direction
621   * "repeat-y": The image is repeated in the Y axis direction, and the image is not repeated in the X axis direction.
622   * "no-repeat": Non-repeating images in both X and Y directions
623   * @since 8
624   */
625  createPattern(image: ImageBitmap, repetition: string | null): CanvasPattern | null;
626
627  /**
628   * Creates a radioactive gradient object based on parameters that determine the coordinates of two circles
629   * @param x0 The x-axis coordinate of the start circle.
630   * @param y0 The y-axis coordinate of the start circle.
631   * @param r0 Radius of the starting circle.
632   * @param x1 The x-axis coordinate of the end circle.
633   * @param y1 The y-axis coordinate of the end circle.
634   * @param r1 Radius of the end circle.
635   * @since 8
636   */
637  createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient;
638
639  /**
640   * Provides filter effects such as blur and grayscale. You can set the following filter effects:
641   * blur(<length>): Adds a Gaussian blur effect to the drawing
642   * brightness(<percentage>): Provides a linear multiplication for the drawing and adjusts the brightness level.
643   * contrast(<percentage>): Adjusts the contrast of the image. When the value is 0%, the image is completely blacked out.
644   *    When the value is 100%, there is no change in the image.
645   * drop-shadow(<offset-x>, <offset-y>, <blur-radius>, <spread-radius>, <color>): Shading Drawings
646   *           --- <offset-x>: Describes the horizontal distance of the shadow.
647   *           --- <offset-y>: Describes the vertical distance of the shadow.
648   *           --- <blur-radius>: Blur radius. The larger the value, the greater the blur. The value cannot be a negative number.
649   *           --- <spread-radius>: Positive numbers make the shadow expand larger, negative numbers make the shadow shrink.
650   *           --- <color>: Shadow Color
651   * grayscale(<percentage>):Converts the image to a gray image. When the value is 100%, the image is completely grayed out.
652   *    When the value is 0%, there is no change in the image.
653   * hue-rotate(<degree>):Perform color rotation on an image. When the value is 0 degrees, there is no change in the image.
654   * invert(<percentage>):Inverted image (representing the effect of a photographic negative). When the value is 100%,
655   *    the image is completely inverted. When the value is 0%, there is no change in the image.
656   * opacity(<percentage>):Transparency of the image. At 0%, the image is completely transparent.
657   *    When the value is 100%, there is no change in the image.
658   * saturate(<percentage>):Perform saturation processing on the image. At 0%, the image is completely unsaturated.
659   *    When the value is 100%, there is no change in the image.
660   * sepia(<percentage>):The image is sepia (nostalgic style). At 100%, the image turns completely sepia.
661   *    When the value is 0%, there is no change in the image.
662   * none:Turn off filter effects
663   * @since 8
664   */
665  filter(filter: string): void;
666
667  /**
668   * Creates a new, empty ImageData object of the specified size
669   * @param sw Width of the ImageData object.
670   * @param sh Height of the ImageData object.
671   * @since 8
672   */
673  createImageData(sw: number, sh: number): ImageData;
674
675  /**
676   * From an existing ImageData object, copy an object with the same width and height as the image.
677   *    The image content is not copied.
678   * @param imagedata ImageData object to be copied.
679   * @since 8
680   */
681  createImageData(imagedata: ImageData): ImageData;
682
683  /**
684   * Obtains the pixel data of a specified area on the current canvas.
685   * @param sx x coordinate of the upper left corner of the rectangular area of the image data to be extracted.
686   * @param sy y coordinate of the upper left corner of the rectangular area of the image data to be extracted.
687   * @param sw The width of the rectangular area of the image data to be extracted.
688   * @param sh The height of the rectangular area of the image data to be extracted.
689   * @since 8
690   */
691  getImageData(sx: number, sy: number, sw: number, sh: number): ImageData;
692
693  /**
694   * Obtains the PixelMap of a specified area on the current canvas.
695   * @param sx x coordinate of the upper left corner of the rectangular area of the PixelMap to be extracted.
696   * @param sy y coordinate of the upper left corner of the rectangular area of the PixelMap to be extracted.
697   * @param sw The width of the rectangular area of the PixelMap to be extracted.
698   * @param sh The height of the rectangular area of the PixelMap to be extracted.
699   * @since 8
700   */
701  getPixelMap(sx: number, sy: number, sw: number, sh: number): PixelMap;
702
703  /**
704   * Draws the specified ImageData object onto the canvas
705   * @param imagedata ImageData object to be drawn.
706   * @param dx Position offset of the source image data in the target canvas (the offset in the x-axis direction).
707   * @param dy Position offset of the source image data in the target canvas (the offset in the y-axis direction).
708   * @since 8
709   */
710  putImageData(imagedata: ImageData, dx: number, dy: number): void;
711
712  /**
713   * Draws the specified ImageData object onto the canvas
714   * @param imagedata ImageData object to be drawn.
715   * @param dx Position offset of the source image data in the target canvas (the offset in the x-axis direction).
716   * @param dy Position offset of the source image data in the target canvas (the offset in the y-axis direction).
717   * @param dirtyX Position of the upper left corner of the rectangular area in the source image data.
718   *    The default is the upper left corner (x coordinate) of the entire image data.
719   * @param dirtyY Position of the upper left corner of the rectangular area in the source image data.
720   *    The default is the upper left corner (y coordinate) of the entire image data.
721   * @param dirtyWidth Width of the rectangular area in the source image data.
722   *    The default is the width of the image data.
723   * @param dirtyHeight Height of the rectangular area in the source image data.
724   *    The default is the height of the image data.
725   * @since 8
726   */
727  putImageData(
728    imagedata: ImageData,
729    dx: number,
730    dy: number,
731    dirtyX: number,
732    dirtyY: number,
733    dirtyWidth: number,
734    dirtyHeight: number,
735  ): void;
736
737  /**
738   * Specifies whether to smooth the image. The value true indicates that the image is smooth (default value).
739   *    The value false indicates that the image is not smooth.
740   * @since 8
741   */
742  imageSmoothingEnabled: boolean;
743
744  /**
745   * Smoothness level of the current image. For details, see {@link ImageSmoothingQuality}.
746   * @since 8
747   */
748  imageSmoothingQuality(quality: ImageSmoothingQuality): void;
749
750  /**
751   * Line segment endpoint attribute. For details, see {@link CanvasLineCap}.
752   * @since 8
753   */
754  lineCap: CanvasLineCap;
755
756  /**
757   * Dotted line offset attribute. The default value is 0.0.
758   * @since 8
759   */
760  lineDashOffset: number;
761
762  /**
763   * Line segment connection point attribute. For details, see {@link CanvasLineJoin}.
764   * @since 8
765   */
766  lineJoin: CanvasLineJoin;
767
768  /**
769   * Line thickness attribute. The value cannot be 0 or a negative number.
770   * @since 8
771   */
772  lineWidth: number;
773
774  /**
775   * The value of this parameter cannot be 0 or a negative number.
776   * @since 8
777   */
778  miterLimit: number;
779
780  /**
781   * Gets the current segment style.
782   * @since 8
783   */
784  getLineDash(): number[];
785
786  /**
787   * Sets the dashed line mode for line drawing.
788   * @param segments A set of numbers that describe the length of alternating drawn line segments and
789   *    spacing (coordinate space units).
790   * @since 8
791   */
792  setLineDash(segments: number[]): void;
793
794  /**
795   * Clears the drawing content of a rectangular area.
796   * @param x The x-axis coordinate of the start point of the rectangle.
797   * @param y The y-axis coordinate of the start point of the rectangle.
798   * @param w Width of the rectangle.
799   * @param h Height of the rectangle.
800   * @since 8
801   */
802  clearRect(x: number, y: number, w: number, h: number): void;
803
804  /**
805   * Fills a specified rectangular area
806   * @param x The x-axis coordinate of the start point of the rectangle.
807   * @param y The y-axis coordinate of the start point of the rectangle.
808   * @param w Width of the rectangle.
809   * @param h Height of the rectangle.
810   * @since 8
811   */
812  fillRect(x: number, y: number, w: number, h: number): void;
813
814  /**
815   * Stroke Specify Rectangular Area
816   * @param x The x-axis coordinate of the start point of the rectangle.
817   * @param y The y-axis coordinate of the start point of the rectangle.
818   * @param w Width of the rectangle.
819   * @param h Height of the rectangle.
820   * @since 8
821   */
822  strokeRect(x: number, y: number, w: number, h: number): void;
823
824  /**
825   * Shadow blur radius. The default value is 0. The value cannot be a negative number.
826   * @since 8
827   */
828  shadowBlur: number;
829
830  /**
831   * Shadow color. The default value is transparent black.
832   * @since 8
833   */
834  shadowColor: string;
835
836  /**
837   * Horizontal offset distance of the shadow. The default value is 0.
838   * @since 8
839   */
840  shadowOffsetX: number;
841
842  /**
843   * Vertical offset distance of the shadow. The default value is 0.
844   * @since 8
845   */
846  shadowOffsetY: number;
847
848  /**
849   * Top of the stack pop-up state in the drawing state stack
850   * @since 8
851   */
852  restore(): void;
853
854  /**
855   * Saves the current drawing state to the drawing state stack
856   * @since 8
857   */
858  save(): void;
859
860  /**
861   * Fills the specified text at the specified location
862   * @param text Text string to be drawn.
863   * @param x The x-axis coordinate of the start point of the text.
864   * @param y The y-axis coordinate of the start point of the text.
865   * @param maxWidth Maximum width of the drawing.
866   * @since 8
867   */
868  fillText(text: string, x: number, y: number, maxWidth?: number): void;
869
870  /**
871   * Measure the size of a specified text. For details about the return value, see {@link TextMetrics}.
872   * @param text Text string to be measured.
873   * @since 8
874   */
875  measureText(text: string): TextMetrics;
876
877  /**
878   * Stroke specified text at specified position
879   * @param text Text string to be stroked.
880   * @param x The x-axis coordinate of the start point of the text.
881   * @param y The y-axis-axis coordinate of the start point of the text.
882   * @param maxWidth Maximum width of the stroke.
883   * @since 8
884   */
885  strokeText(text: string, x: number, y: number, maxWidth?: number): void;
886
887  /**
888   * Text drawing direction. For details, see {@link CanvasDirection}.
889   * @since 8
890   */
891  direction(direction: CanvasDirection): void;
892
893  /**
894   * Font style. The default value is 10px sans-serif.
895   * @since 8
896   */
897  font: string;
898
899  /**
900   * Text alignment mode. For details, see {@link CanvasTextAlign}.
901   * @since 8
902   */
903  textAlign: CanvasTextAlign;
904
905  /**
906   * Text baseline. For details, see {@link CanvasTextBaseline}.
907   * @since 8
908   */
909  textBaseline: CanvasTextBaseline;
910
911  /**
912   * Obtains the currently applied transformation matrix.
913   * @since 8
914   */
915  getTransform(): Matrix2D;
916
917  /**
918   * Resets the current transformation matrix using the identity matrix
919   * @since 8
920   */
921  resetTransform(): void;
922
923  /**
924   * Adds the effect of a rotation
925   * @param angle The radian of clockwise rotation, which can be converted to an angle value using the formula:
926   *    degree * Math.PI / 180
927   * @since 8
928   */
929  rotate(angle: number): void;
930
931  /**
932   * Increases the scaling effect of the X and Y axes.
933   * @param x Horizontal scaling factor
934   * @param y Vertical scaling factor
935   * @since 8
936   */
937  scale(x: number, y: number): void;
938
939  /**
940   * Adds 2D transformation effects, including rotation, translation, and scaling.
941   *    The current transformation matrix will not be overwritten. Multiple transformations will be superimposed.
942   * @param a Horizontal Zoom
943   * @param b Vertical Tilt
944   * @param c Horizontal Tilt
945   * @param d Vertical Zoom
946   * @param e Horizontal movement
947   * @param f Vertical movement
948   * @since 8
949   */
950  setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
951
952  /**
953   * The 2D transformation effect is added. The current transformation matrix is not overwritten and
954   *    the transformations are superimposed for multiple times.
955   * @param transform 2D transformation matrix. For details, see {@link Matrix2D}.
956   * @since 8
957   */
958  setTransform(transform?: Matrix2D): void;
959
960  /**
961   * Adds the 2D transformation effect, including rotation, translation, and scaling,
962   *    and overwrites the current transformation matrix.
963   * @param a Horizontal Zoom
964   * @param b Vertical Tilt
965   * @param c Horizontal Tilt
966   * @param d Vertical Zoom
967   * @param e Horizontal movement
968   * @param f Vertical movement
969   * @since 8
970   */
971  transform(a: number, b: number, c: number, d: number, e: number, f: number): void;
972
973  /**
974   * Increases the translation effect of the X and Y axes
975   * @param x Horizontal movement distance
976   * @param y Vertical travel distance
977   * @since 8
978   */
979  translate(x: number, y: number): void;
980
981  /**
982   * Set a PixelMap to the current context. The drawing content is synchronized to the PixelMap.
983   * @param value PixelMap object
984   * @since 8
985   */
986  setPixelMap(value?: PixelMap): void;
987
988  /**
989   * transfer ImageBitmap to content.
990   * @param ImageBitmap
991   * @since 8
992   */
993  transferFromImageBitmap(bitmap: ImageBitmap): void;
994}
995
996/**
997 * Draw context object for the Canvas component.
998 * @since 8
999 */
1000declare class CanvasRenderingContext2D extends CanvasRenderer {
1001  /**
1002   * The default value is 0, which is bound to the height of the specified canvas. The value is read-only.
1003   * @since 8
1004   */
1005  readonly height: number;
1006
1007  /**
1008   * The default value is 0, which is bound to the width of the specified canvas. The value is read-only.
1009   * @since 8
1010   */
1011  readonly width: number;
1012
1013  /**
1014   * Generate a character string in the data url format.
1015   * @param type Image format. The default value is image/png.
1016   * @param quality If the image format is image/jpeg or image/webp, you can select the image quality from 0 to 1.
1017   *    If the value is out of the range, the default value 0.92 is used.
1018   * @since 8
1019   */
1020  toDataURL(type?: string, quality?: any): string;
1021
1022  /**
1023   * Constructor of the canvas drawing context object, which is used to create a drawing context object.
1024   * @param settings Drawing attribute. For details, see {@link RenderingContextSettings}.
1025   * @since 8
1026   */
1027  constructor(settings?: RenderingContextSettings);
1028}
1029
1030/**
1031 * Draw context object for the OffscreenCanvas component.
1032 * @since 8
1033 */
1034declare class OffscreenCanvasRenderingContext2D extends CanvasRenderer {
1035  /**
1036   * Generate a character string in the data url format.
1037   * @param type Image format. The default value is image/png.
1038   * @param quality If the image format is image/jpeg or image/webp, you can select the image quality from 0 to 1.
1039   *    If the value is out of the range, the default value 0.92 is used.
1040   * @since 8
1041   */
1042  toDataURL(type?: string, quality?: any): string;
1043
1044  /**
1045   * transfer the content to ImageBitmap
1046   * @since 8
1047   */
1048  transferToImageBitmap(): ImageBitmap;
1049
1050  /**
1051   * Constructor of the canvas drawing context object, which is used to create a drawing context object.
1052   * @param width the width of the OffscreenCanvas
1053   * @param height the height of the OffscreenCanvas
1054   * @param settings Drawing attribute. For details, see {@link RenderingContextSettings}.
1055   * @since 8
1056   */
1057  constructor(width: number, height: number, settings?: RenderingContextSettings);
1058}
1059
1060/**
1061 * Draw an object off the screen. The drawing content is not directly displayed on the screen.
1062 * @since 8
1063 */
1064declare class OffscreenCanvas extends CanvasRenderer {
1065  /**
1066   * Height of the off-screen canvas.
1067   * @since 8
1068   */
1069  height: number;
1070
1071  /**
1072   * Width of the off-screen canvas.
1073   * @since 8
1074   */
1075  width: number;
1076
1077  /**
1078   * Exports rendered content as an ImageBitmap object
1079   * @since 8
1080   */
1081  transferToImageBitmap(): ImageBitmap;
1082
1083  /**
1084   * Constructor of the off-screen canvas, which is used to create an off-screen canvas object.
1085   * @param width Width of the off-screen canvas.
1086   * @param height Height of the off-screen canvas.
1087   * @since 8
1088   */
1089  constructor(width: number, height: number);
1090}
1091
1092/**
1093 *TextTimer component, which provides the text timer capability.
1094 * @since 8
1095 */
1096interface CanvasInterface {
1097  /**
1098   * Construct a canvas component.
1099   * @param context Canvas context object. For details, see {@link CanvasRenderingContext2D}.
1100   * @since 8
1101   */
1102  (context?: CanvasRenderingContext2D): CanvasAttribute;
1103}
1104
1105declare class CanvasAttribute extends CommonMethod<CanvasAttribute> {
1106  /**
1107   * Event notification after the canvas component is constructed. You can draw the canvas at this time.
1108   * @since 8
1109   */
1110  onReady(event: () => void): CanvasAttribute;
1111}
1112
1113declare const Canvas: CanvasInterface;
1114declare const CanvasInstance: CanvasAttribute;
1115