Skip to main content
Version: 3.x

Canvas

The canvas instance, which can be obtained via SelectorQuery.

Reference

Methods

cancelAnimationFrame

Cancels the animation frame request added to the plan by requestAnimationFrame (only supported in WebGL).

Reference

(requestID: number) => void
PropertyType
requestIDnumber

API Support

APIWeChat Mini-ProgramH5React Native
Canvas.cancelAnimationFrame✔️

createImageData

Creates an ImageData object. Only supported for use in 2D Canvas.

Reference

() => ImageData

API Support

APIWeChat Mini-ProgramH5React Native
Canvas.createImageData✔️

createImage

Creates an image object. Supports use in 2D Canvas and WebGL Canvas, but does not support mixing 2D and WebGL methods.

Reference

() => Image

API Support

APIWeChat Mini-ProgramH5React Native
Canvas.createImage✔️

getContext

Returns the Canvas drawing context.

Reference

(contextType: string) => RenderingContext
PropertyType
contextTypestring

API Support

APIWeChat Mini-ProgramH5React Native
Canvas.getContext✔️

requestAnimationFrame

Executed upon the next redrawing (only supported in WebGL).

Reference

(callback: (...args: any[]) => any) => number
PropertyTypeDescription
callback(...args: any[]) => any执行的 callback

API Support

APIWeChat Mini-ProgramH5React Native
Canvas.requestAnimationFrame✔️

API Support

APIWeChat Mini-ProgramH5React Native
Canvas.cancelAnimationFrame✔️
Canvas.createImageData✔️
Canvas.createImage✔️
Canvas.getContext✔️
Canvas.requestAnimationFrame✔️