Canvas
- Properties
- number width: Canvas width.
- number height : Canvas height.
Method set
cancelAnimationFrame
TIP
The API usage is as follows: Canvas.cancelAnimationFrame(number requestID)
- Functional description: Cancels the animation frame request added to the schedule by requestAnimationFrame. Supports use in 2D Canvas and WebGL Canvas, but does not support mixed 2D and WebGL methods.
- Parameters and descriptions: number requestID。
createImageData
TIP
The API usage is as follows: Image Canvas.createImage()
- Functional description: Creates an ImageData object. Supports use in 2D Canvas only.
- Parameters and descriptions: ImageData
createImage
TIP
The API usage is as follows: ImageData Canvas.createImageData()
- Functional description: Creates an image object. Supports use in 2D Canvas and WebGL Canvas, but does not support mixed 2D and WebGL methods.
- Parameters and descriptions: Image
createPath2D
TIP
The API usage is as follows: Path2D Canvas.createPath2D(Path2D path)
- Functional description: Creates a Path2D object.
- Parameters and descriptions: Path2D path。
- Return value: Path2D。
getContext
TIP
The API usage is as follows: RenderingContext Canvas.getContext(string contextType)
Functional description: This method returns the drawing context of the Canvas.
Parameters and descriptions: string contextType, Context type.
Legal value Description 2d 2d drawing context webgl webgl drawing context webgl2 webgl2 drawing context Return value: RenderingContext, , supports getting 2D and WebGL drawing contexts.
requestAnimationFrame
TIP
The API usage is as follows: number Canvas.requestAnimationFrame(function callback)
- Functional description: Executed at the next redraw. Supports use in 2D Canvas and WebGL Canvas, but does not support mixed 2D and WebGL methods.
- Parameters and descriptions: function callback, Executed callback.
- Return value: number, Request ID.
toDataURL
TIP
The API usage is as follows: string Canvas.toDataURL(string type, number encoderOptions)
- Functional description: Returns a data URI containing the image display. You can use the type parameter to specify its type, which defaults to PNG format.
- Parameters and descriptions:
- string type: Image format, defaults to image/png.
- number encoderOptions: When the image format is specified as image/jpeg or image/webp, the image quality can be selected from the range of 0 to 1. If the value is out of range, the default value of 0.92 will be used. Other parameters will be ignored.
- Return value: string。