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)

Observes source for Canvas at the next owner-thread frame cutoff.

Retain caller-owned sources and editing state outside reevaluation. See Observe for shared snapshots, equal-value suppression, and cleanup; literal arguments follow Canvas. Modifiers and parent data apply to the actual component, while the binding owns its sibling key.