getContext

fun <T : OffscreenRenderingContext, O : JsAny> getContext(contextId: RenderingContextId<T, O>, options: O? = definedExternally): T?(source)

The OffscreenCanvas.getContext() method returns a drawing context for an offscreen canvas, or null if the context identifier is not supported, or the offscreen canvas has already been set to a different context mode.

MDN Reference