Skip to content

ICanvas.getContext method

ICanvas › getContext

Unofficial

Returns a 2D rendering context.

Signature:

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

Parameters:

ParameterTypeDescription
contextId"2d"Context identifier.
options?CanvasRenderingContext2DSettings | undefinedContext 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:

ParameterTypeDescription
contextId"experimental-webgl" | "webgl"Context identifier.
options?WebGLContextAttributes | undefinedContext 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:

ParameterTypeDescription
contextId"experimental-webgl2" | "webgl2"Context identifier.
options?WebGLContextAttributes | undefinedContext attributes.

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