SpatialRect

A 2D rectangle bound to a specific CoordinateSpace inside a CoordinateSystem.

Like SpatialOffset, SpatialRect ensures that geometric data remains contextualized, preventing miscalculations across incompatible coordinate spaces (e.g., viewport vs. image space).

For reading the bounds or its size in a given space, use SpatialRect.rectIn or SpatialRect.sizeIn with a CoordinateSystem receiver:

val boundsInViewport = SpatialRect(
rect = Rect(Offset.Zero, Size(200f, 300f)),
space = CoordinateSpace.Viewport,
)

val boundsInImage: Rect = with(zoomableState.coordinateSystem) {
boundsInViewport.rectIn(CoordinateSpace.ZoomableContent)
}

Constructors

Link copied to clipboard
constructor(rect: Rect, space: CoordinateSpace)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard