Documentation / @ripl/canvas / createContext
Function: createContext()
createContext(
target,options?):CanvasContext
Defined in: canvas/src/context.ts:458
Creates a Canvas 2D rendering context (a concrete Context) attached to the given DOM target.
Parameters
| Parameter | Type | Description |
|---|---|---|
target | string | HTMLElement | A DOM element or CSS selector identifying the element to mount the canvas into. |
options? | ContextOptions<Record<string, unknown>> | Optional context configuration such as interactivity and metadata. |
Returns
The constructed CanvasContext.
Example
ts
const context = createContext(target);