Skip to content

ICanvas.getContext method

ICanvas › getContext

Unofficial

Returns a 2D rendering context.

Signature:

getContext(contextId: "2d", options?: CanvasRenderingContext2DSettings | undefined): CanvasRenderingContext2D | null

Parameters:

Parameter Type Description
contextId "2d" Context identifier.
options? CanvasRenderingContext2DSettings | undefined Context attributes.

Returns: CanvasRenderingContext2D | nullThe 2D rendering context, or null.


Unofficial

Returns a WebGL rendering context.

Signature:

getContext(contextId: "experimental-webgl" | "webgl", options?: WebGLContextAttributes | undefined): null | WebGLRenderingContext

Parameters:

Parameter Type Description
contextId "experimental-webgl" | "webgl" Context identifier.
options? WebGLContextAttributes | undefined Context attributes.

Returns: null | WebGLRenderingContextThe WebGL rendering context, or null.


Unofficial

Returns a WebGL2 rendering context.

Signature:

getContext(contextId: "experimental-webgl2" | "webgl2", options?: WebGLContextAttributes | undefined): null | WebGL2RenderingContext

Parameters:

Parameter Type Description
contextId "experimental-webgl2" | "webgl2" Context identifier.
options? WebGLContextAttributes | undefined Context attributes.

Returns: null | WebGL2RenderingContextThe WebGL2 rendering context, or null.