Canvas

fun UiScope.Canvas(source: CanvasSource, size: IntSize, modifier: Modifier = Modifier.Empty, key: ElementKey<*>? = null)(source)

Emits one input-passive rectangular region displaying an externally owned source.

The whole source image stretches to the explicit positive logical size using nearest sampling. Source image extent changes update painting without changing that destination. Pointer and keyboard forwarding are composed through ordinary modifiers; the canvas acquires no input or focus implicitly. The source is opened only when a retained node attaches, never during declaration or measurement. Every attachment owns a separate binding, and declaration does not transfer ownership of the source itself.

Parameters

source

externally owned CPU image, revisioned image stream, or version-runtime native source.

size

exact positive logical destination size, which must be admitted by the parent constraints.

modifier

active layout, paint, and optional input behavior around the canvas.

key

optional stable sibling identity.

Throws

when either requested dimension is zero.

when this callback-lifetime scope is used after its callback or on another thread.


@JvmName(name = "CanvasState7047d39d3483_1")
fun UiScope.Canvas(source: StateSource<CanvasSource>, size: IntSize, modifier: Modifier = Modifier.Empty, key: ElementKey<*>? = null)(source)

Source-backed Canvas observing source at the next frame cutoff. Sources remain caller-owned; compatible nodes retain editing, focus, and scrolling state. Literal arguments keep their existing contracts. Equal source values do not re-evaluate this component. The complete modifier chain stays on the actual component; the wrapper delegates parent data and owns the sibling key. Keep sources and dedicated editing states outside observed callbacks. Evaluation and input failures follow ordinary runtime cleanup.