tencent cloud

All product documents
Tencent Cloud Super App as a Service
Last updated: 2025-03-25 18:15:55
Canvas
Last updated: 2025-03-25 18:15:55

Attributes

Canvas Width: The breadth of the canvas.
Canvas Height: The vertical extent of the canvas.

Method Set

cancelAnimationFrame

The method is utilized as follows: Canvas.cancelAnimationFrame(number requestID)
Function Description: Cancels the animation frame request scheduled by requestAnimationFrame. It is compatible with both 2D Canvas and WebGL Canvas, however, it does not support the concurrent use of 2D and WebGL methods.
Parameters and Description: Number requestID.

createImageData

The method is utilized as follows: Image Canvas.createImage()
Function Description: Creates an ImageData object. Only supported in 2D Canvas.
Parameters and Description: Image.

createImage

The method is utilized as follows: ImageData Canvas.createImageData()
Function Description: Creates an image object. Supports use under 2D Canvas and WebGL Canvas, but does not support mixing 2D and WebGL methods.
Parameters and Description: ImageData.

createPath2D

The method is utilized as follows: Path2D Canvas.createPath2D(Path2D path)
Function Description: Creates a Path2D object.
Parameters and Description: Path2D path.
Return Value: Path2D.

getContext

The method is utilized as follows: RenderingContext Canvas.getContext(string contextType)
Function Description: This method returns the drawing context of the Canvas.
Parameters and Description: string contextType, the context type.
Value
Note
2d
2D drawing context
webgl
WebGL drawing context
webgl2
WebGL2 drawing context
Return Value:RenderingContext, facilitating the acquisition of 2D and WebGL drawing contexts.

requestAnimationFrame

The method is utilized as follows: number Canvas.requestAnimationFrame(function callback)
Function Description: Executes upon the next redraw. Compatible with both 2D Canvas and WebGL Canvas, however, the methods of 2D and WebGL cannot be used interchangeably.
Parameters and Description: function callback, the callback to be executed.
Return Value: number, the request ID.

toDataURL

The method is employed as follows: string Canvas.toDataURL(string type, number encoderOptions)
Function Description: Returns a data URI that displays the image. The type parameter can be used to specify its format, with PNG as the default.
Parameters and Descriptions:
string type: The image format, default is image/png.
number encoderOptions: When the image format is specified as image/jpeg or image/webp, the image quality can be selected within the range of 0 to 1. If it exceeds the value range, the default value of 0.92 will be used. Other parameters will be disregarded.
Return Value: string.


Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon