withClip

open fun withClip(localBounds: IntRect, content: () -> Unit)(source)

Clips commands emitted during content without changing their local geometry or sampling coordinates.

Clips intersect with enclosing clips and accept empty half-open rectangles. The callback runs exactly once, synchronously on the owning paint thread, and is never retained. The clip ends even when the callback throws; an exception escaping the owning paint callback still poisons the tree. This operation does not change size, coordinate origins, child layout, pointer hit testing, or later commands. The default implementation rejects the capability without invoking content, preserving existing paint-scope implementations.

Parameters

localBounds

local half-open clip rectangle, which may extend beyond the node's logical bounds.

content

synchronous drawing work using this same valid scope.

Throws

when called outside the owning callback lifetime or thread.

when a custom scope has not implemented explicit paint clipping.

when content fails; its original failure propagates after restoring the enclosing clip.