Spatial Rect
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)
}Content copied to clipboard
Properties
Link copied to clipboard
Link copied to clipboard
false when this is SpatialRect.Unspecified.
Link copied to clipboard
true when this is SpatialRect.Unspecified.
Link copied to clipboard