useCanvasContext
import { useCanvasContext } from "@pibbl/core";useCanvasContext() returns RenderingContext2D and is render-only: call it synchronously
from a Pibbl component while it is rendering, never from pure measurement or an
event callback. Pibbl isolates Canvas state around component traversal; do not
retain the context for later work.
function Marker() { const context = useCanvasContext(); context.fillRect(0, 0, 8, 8);}Use a public drawing component where possible; custom Canvas work belongs in a custom component or primitive.
API details from source
Section titled “API details from source”
Returns the current component’s isolated Canvas 2D context.
useCanvasContext: () => RenderingContext2DRelated API: useCanvasContext, RenderingContext2D.
Returns
Section titled “Returns”The active Canvas 2D rendering context for this component evaluation. See RenderingContext2D .
See also
Section titled “See also”View source — packages/core/src/lib/hooks/use-canvas-context.ts:16
Implementation guidance for agents
Section titled “Implementation guidance for agents”Read the Drawing, layout, and effects companion for ownership, adaptation, failure modes, and verification. Agent start provides the version-selection workflow.
Complete minimal examples
Section titled “Complete minimal examples”- Define a Canvas primitive: Supply synchronous drawing, style normalization, resolution, and opt-in measurement. Plain source
Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision 380919b. ALPHA — NOT FOR PRODUCTION USE.