Google is committed to advancing racial equity for Black communities. See how.

# androidx.compose.ui.geometry

## Classes

 MutableRect An mutable, 2D, axis-aligned, floating-point rectangle whose coordinates are relative to a given origin. Offset An immutable 2D floating-point offset. Radius A radius for either circular or elliptical shapes. Rect An immutable, 2D, axis-aligned, floating-point rectangle whose coordinates are relative to a given origin. RoundRect An immutable rounded rectangle with custom radii for all four corners. Size Holds a 2D floating-point size.

## Top-level functions summary

 Offset `Offset(x: Float, y: Float)` Constructs an Offset from the given relative x and y offsets RoundRect `RRect(left: Float, top: Float, right: Float, bottom: Float, topLeftRadiusX: Float, topLeftRadiusY: Float, topRightRadiusX: Float, topRightRadiusY: Float, bottomRightRadiusX: Float, bottomRightRadiusY: Float, bottomLeftRadiusX: Float, bottomLeftRadiusY: Float)` RoundRect `RRect(left: Float, top: Float, right: Float, bottom: Float, radiusX: Float, radiusY: Float)` Construct a rounded rectangle from its left, top, right, and bottom edges, and the same radii along its horizontal axis and its vertical axis. RoundRect `RRect(left: Float, top: Float, right: Float, bottom: Float, radius: Radius)` Construct a rounded rectangle from its left, top, right, and bottom edges, and the same radius in each corner. RoundRect `RRect(rect: Rect, radiusX: Float, radiusY: Float)` Construct a rounded rectangle from its bounding box and the same radii along its horizontal axis and its vertical axis. RoundRect `RRect(rect: Rect, radius: Radius)` Construct a rounded rectangle from its bounding box and a radius that is the same in each corner. RoundRect `RRect(left: Float, top: Float, right: Float, bottom: Float, topLeft: Radius = Radius.Zero, topRight: Radius = Radius.Zero, bottomRight: Radius = Radius.Zero, bottomLeft: Radius = Radius.Zero)` Construct a rounded rectangle from its left, top, right, and bottom edges, and topLeft, topRight, bottomRight, and bottomLeft radii. RoundRect `RRect(rect: Rect, topLeft: Radius = Radius.Zero, topRight: Radius = Radius.Zero, bottomRight: Radius = Radius.Zero, bottomLeft: Radius = Radius.Zero)` Construct a rounded rectangle from its bounding box and and topLeft, topRight, bottomRight, and bottomLeft radii. Radius `Radius(x: Float, y: Float = x)` Constructs a Radius with the given x and y parameters for the size of the radius along the x and y axis respectively. Rect `Rect(offset: Offset, size: Size)` Construct a rectangle from its left and top edges as well as its width and height. Rect `Rect(topLeft: Offset, bottomRight: Offset)` Construct the smallest rectangle that encloses the given offsets, treating them as vectors from the origin. Rect `Rect(center: Offset, radius: Float)` Construct a rectangle that bounds the given circle RoundRect `RoundRect(left: Float, top: Float, right: Float, bottom: Float, radiusX: Float, radiusY: Float)` Construct a rounded rectangle from its left, top, right, and bottom edges, and the same radii along its horizontal axis and its vertical axis. RoundRect `RoundRect(left: Float, top: Float, right: Float, bottom: Float, radius: Radius)` Construct a rounded rectangle from its left, top, right, and bottom edges, and the same radius in each corner. RoundRect `RoundRect(rect: Rect, radiusX: Float, radiusY: Float)` Construct a rounded rectangle from its bounding box and the same radii along its horizontal axis and its vertical axis. RoundRect `RoundRect(rect: Rect, radius: Radius)` Construct a rounded rectangle from its bounding box and a radius that is the same in each corner. RoundRect `RoundRect(left: Float, top: Float, right: Float, bottom: Float, topLeft: Radius = Radius.Zero, topRight: Radius = Radius.Zero, bottomRight: Radius = Radius.Zero, bottomLeft: Radius = Radius.Zero)` Construct a rounded rectangle from its left, top, right, and bottom edges, and topLeft, topRight, bottomRight, and bottomLeft radii. RoundRect `RoundRect(rect: Rect, topLeft: Radius = Radius.Zero, topRight: Radius = Radius.Zero, bottomRight: Radius = Radius.Zero, bottomLeft: Radius = Radius.Zero)` Construct a rounded rectangle from its bounding box and topLeft, topRight, bottomRight, and bottomLeft radii. Size `Size(width: Float, height: Float)` Constructs a Size from the given width and height Offset `lerp(start: Offset, stop: Offset, fraction: Float)` Linearly interpolate between two offsets. Radius `lerp(start: Radius, stop: Radius, fraction: Float)` Linearly interpolate between two radii. Rect `lerp(start: Rect, stop: Rect, fraction: Float)` Linearly interpolate between two rectangles. RoundRect `lerp(start: RoundRect, stop: RoundRect, fraction: Float)` Linearly interpolate between two rounded rectangles. Size? `lerp(start: Size, stop: Size, fraction: Float)` Linearly interpolate between two sizes

## Extension functions summary

 For kotlin.Double operator Size `Double.times(size: Size)` Returns a Size with size's Size.width and Size.height multiplied by this
 For kotlin.Float operator Size `Float.times(size: Size)` Returns a Size with size's Size.width and Size.height multiplied by this
 For kotlin.Int operator Size `Int.times(size: Size)` Returns a Size with size's Size.width and Size.height multiplied by this
 For RoundRect Radius `RoundRect.bottomLeftRadius()` The bottom-left Radius. Radius `RoundRect.bottomRightRadius()` The bottom-right Radius. Offset `RoundRect.center()` The offset to the point halfway between the left and right and the top and bottom edges of this rectangle. RoundRect `RoundRect.grow(delta: Float)` Returns a new RoundRect with edges and radii moved outwards by the given delta. Rect `RoundRect.middleRect()` The rectangle that would be formed using the axis-aligned intersection of the sides of the rectangle, i. Rect `RoundRect.outerRect()` The bounding box of this rounded rectangle (the rectangle with no rounded corners). Rect `RoundRect.safeInnerRect()` The non-rounded rectangle that is constrained by the smaller of the two diagonals, with each diagonal traveling through the middle of the curve corners. RoundRect `RoundRect.shift(offset: Offset)` Returns a new RoundRect translated by the given offset. RoundRect `RoundRect.shrink(delta: Float)` Returns a new RoundRect with edges and radii moved inwards by the given delta. Rect `RoundRect.tallMiddleRect()` The biggest rectangle that is entirely inside the rounded rectangle and has the full height of the rounded rectangle. Radius `RoundRect.topLeftRadius()` The top-left Radius. Radius `RoundRect.topRightRadius()` The top-right Radius. Rect `RoundRect.wideMiddleRect()` The biggest rectangle that is entirely inside the rounded rectangle and has the full width of the rounded rectangle. RoundRect `RoundRect.withRadius(radius: Radius)`
 For MutableRect Rect `MutableRect.toRect()`
 For Size Rect `Size.toRect()` Convert a Size to a Rect.

## Extension properties summary

 For RoundRect Boolean `RoundRect.isCircle()` Whether this rounded rectangle would draw as a circle. Boolean `RoundRect.isEllipse()` Whether this rounded rectangle has no side with a straight section. Boolean `RoundRect.isEmpty()` Whether this rounded rectangle encloses a non-zero area. Boolean `RoundRect.isFinite()` Whether all coordinates of this rounded rectangle are finite. Boolean `RoundRect.isRect()` Whether this rounded rectangle is a simple rectangle with zero corner radii. Boolean `RoundRect.isSimple()` Returns `true` if the rounded rectangle have the same radii in both the horizontal and vertical direction for all corners. Boolean `RoundRect.isStadium()` Whether this rounded rectangle has a side with no straight section. Float `RoundRect.longestSide()` The greater of the magnitudes of the RoundRect.width and the RoundRect.height of this rounded rectangle. Float `RoundRect.shortestSide()` The lesser of the magnitudes of the RoundRect.width and the RoundRect.height of this rounded rectangle.

## Top-level functions

### Offset

`@Stable inline fun Offset(    x: Float,     y: Float): Offset`

Constructs an Offset from the given relative x and y offsets

### RRect

`fun RRect(    left: Float,     top: Float,     right: Float,     bottom: Float,     topLeftRadiusX: Float,     topLeftRadiusY: Float,     topRightRadiusX: Float,     topRightRadiusY: Float,     bottomRightRadiusX: Float,     bottomRightRadiusY: Float,     bottomLeftRadiusX: Float,     bottomLeftRadiusY: Float): RoundRect`

Deprecated.

### RRect

`fun RRect(    left: Float,     top: Float,     right: Float,     bottom: Float,     radiusX: Float,     radiusY: Float): RoundRect`

Deprecated.

Construct a rounded rectangle from its left, top, right, and bottom edges, and the same radii along its horizontal axis and its vertical axis.

### RRect

`fun RRect(    left: Float,     top: Float,     right: Float,     bottom: Float,     radius: Radius): RoundRect`

Deprecated.

Construct a rounded rectangle from its left, top, right, and bottom edges, and the same radius in each corner.

### RRect

`fun RRect(    rect: Rect,     radiusX: Float,     radiusY: Float): RoundRect`

Deprecated.

Construct a rounded rectangle from its bounding box and the same radii along its horizontal axis and its vertical axis.

### RRect

`fun RRect(    rect: Rect,     radius: Radius): RoundRect`

Deprecated.

Construct a rounded rectangle from its bounding box and a radius that is the same in each corner.

### RRect

`fun RRect(    left: Float,     top: Float,     right: Float,     bottom: Float,     topLeft: Radius = Radius.Zero,     topRight: Radius = Radius.Zero,     bottomRight: Radius = Radius.Zero,     bottomLeft: Radius = Radius.Zero): RoundRect`

Deprecated.

Construct a rounded rectangle from its left, top, right, and bottom edges, and topLeft, topRight, bottomRight, and bottomLeft radii.

### RRect

`fun RRect(    rect: Rect,     topLeft: Radius = Radius.Zero,     topRight: Radius = Radius.Zero,     bottomRight: Radius = Radius.Zero,     bottomLeft: Radius = Radius.Zero): RoundRect`

Deprecated.

Construct a rounded rectangle from its bounding box and and topLeft, topRight, bottomRight, and bottomLeft radii.

`@Stable inline fun Radius(    x: Float,     y: Float = x): Radius`

Constructs a Radius with the given x and y parameters for the size of the radius along the x and y axis respectively. By default the radius along the Y axis matches that of the given x-axis unless otherwise specified

### Rect

`@Stable fun Rect(    offset: Offset,     size: Size): Rect`

Construct a rectangle from its left and top edges as well as its width and height.

Parameters
offset: Offset Offset to represent the top and left parameters of the Rect
size: Size Size to determine the width and height of this Rect.
Return
Rect with Rect.left and Rect.top configured to Offset.x and Offset.y as Rect.right and Rect.bottom to Offset.x + Size.width and Offset.y + Size.height respectively

### Rect

`@Stable fun Rect(    topLeft: Offset,     bottomRight: Offset): Rect`

Construct the smallest rectangle that encloses the given offsets, treating them as vectors from the origin.

Parameters
topLeft: Offset Offset representing the left and top edges of the rectangle
bottomRight: Offset Offset representing the bottom and right edges of the rectangle

### Rect

`@Stable fun Rect(    center: Offset,     radius: Float): Rect`

Construct a rectangle that bounds the given circle

Parameters
center: Offset Offset that represents the center of the circle

### RoundRect

`fun RoundRect(    left: Float,     top: Float,     right: Float,     bottom: Float,     radiusX: Float,     radiusY: Float): RoundRect`

Construct a rounded rectangle from its left, top, right, and bottom edges, and the same radii along its horizontal axis and its vertical axis.

### RoundRect

`fun RoundRect(    left: Float,     top: Float,     right: Float,     bottom: Float,     radius: Radius): RoundRect`

Construct a rounded rectangle from its left, top, right, and bottom edges, and the same radius in each corner.

### RoundRect

`fun RoundRect(    rect: Rect,     radiusX: Float,     radiusY: Float): RoundRect`

Construct a rounded rectangle from its bounding box and the same radii along its horizontal axis and its vertical axis.

### RoundRect

`fun RoundRect(    rect: Rect,     radius: Radius): RoundRect`

Construct a rounded rectangle from its bounding box and a radius that is the same in each corner.

### RoundRect

`fun RoundRect(    left: Float,     top: Float,     right: Float,     bottom: Float,     topLeft: Radius = Radius.Zero,     topRight: Radius = Radius.Zero,     bottomRight: Radius = Radius.Zero,     bottomLeft: Radius = Radius.Zero): RoundRect`

Construct a rounded rectangle from its left, top, right, and bottom edges, and topLeft, topRight, bottomRight, and bottomLeft radii.

### RoundRect

`fun RoundRect(    rect: Rect,     topLeft: Radius = Radius.Zero,     topRight: Radius = Radius.Zero,     bottomRight: Radius = Radius.Zero,     bottomLeft: Radius = Radius.Zero): RoundRect`

Construct a rounded rectangle from its bounding box and topLeft, topRight, bottomRight, and bottomLeft radii.

### Size

`@Stable fun Size(    width: Float,     height: Float): Size`

Constructs a Size from the given width and height

### lerp

`@Stable fun lerp(    start: Offset,     stop: Offset,     fraction: Float): Offset`

Linearly interpolate between two offsets.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid (and can easily be generated by curves).

Values for fraction are usually obtained from an Animation, such as an `AnimationController`.

### lerp

`@Stable fun lerp(    start: Radius,     stop: Radius,     fraction: Float): Radius`

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid (and can easily be generated by curves).

Values for fraction are usually obtained from an Animation, such as an `AnimationController`.

### lerp

`@Stable fun lerp(    start: Rect,     stop: Rect,     fraction: Float): Rect`

Linearly interpolate between two rectangles.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid (and can easily be generated by curves).

Values for fraction are usually obtained from an Animation, such as an `AnimationController`.

### lerp

`fun lerp(    start: RoundRect,     stop: RoundRect,     fraction: Float): RoundRect`

Linearly interpolate between two rounded rectangles.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid (and can easily be generated by curves).

Values for fraction are usually obtained from an Animation, such as an `AnimationController`.

### lerp

`@Stable fun lerp(    start: Size,     stop: Size,     fraction: Float): Size?`

Linearly interpolate between two sizes

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid (and can easily be generated by curves).

Values for fraction are usually obtained from an Animation, such as an `AnimationController`.

## Extension functions

`fun RoundRect.bottomLeftRadius(): Radius`

`fun RoundRect.bottomRightRadius(): Radius`

### center

`fun RoundRect.center(): Offset`

The offset to the point halfway between the left and right and the top and bottom edges of this rectangle.

### grow

`fun RoundRect.grow(delta: Float): RoundRect`

Returns a new RoundRect with edges and radii moved outwards by the given delta.

### middleRect

`fun RoundRect.middleRect(): Rect`

The rectangle that would be formed using the axis-aligned intersection of the sides of the rectangle, i.e., the rectangle formed from the inner-most centers of the ellipses that form the corners. This is the intersection of the wideMiddleRect and the tallMiddleRect. If any of the intersections are void, the resulting Rect will have negative width or height.

### outerRect

`fun RoundRect.outerRect(): Rect`

The bounding box of this rounded rectangle (the rectangle with no rounded corners).

### safeInnerRect

`fun RoundRect.safeInnerRect(): Rect`

The non-rounded rectangle that is constrained by the smaller of the two diagonals, with each diagonal traveling through the middle of the curve corners. The middle of a corner is the intersection of the curve with its respective quadrant bisector.

### shift

`fun RoundRect.shift(offset: Offset): RoundRect`

Returns a new RoundRect translated by the given offset.

### shrink

`fun RoundRect.shrink(delta: Float): RoundRect`

Returns a new RoundRect with edges and radii moved inwards by the given delta.

### tallMiddleRect

`fun RoundRect.tallMiddleRect(): Rect`

The biggest rectangle that is entirely inside the rounded rectangle and has the full height of the rounded rectangle. If the rounded rectangle does not have an axis-aligned intersection of its top and bottom side, the resulting Rect will have negative width or height.

### times

`@Stable inline operator fun Double.times(size: Size): Size`

Returns a Size with size's Size.width and Size.height multiplied by this

### times

`@Stable inline operator fun Float.times(size: Size): Size`

Returns a Size with size's Size.width and Size.height multiplied by this

### times

`@Stable inline operator fun Int.times(size: Size): Size`

Returns a Size with size's Size.width and Size.height multiplied by this

### toRect

`fun MutableRect.toRect(): Rect`

### toRect

`@Stable fun Size.toRect(): Rect`

Convert a Size to a Rect.

`fun RoundRect.topLeftRadius(): Radius`

`fun RoundRect.topRightRadius(): Radius`

### wideMiddleRect

`fun RoundRect.wideMiddleRect(): Rect`

The biggest rectangle that is entirely inside the rounded rectangle and has the full width of the rounded rectangle. If the rounded rectangle does not have an axis-aligned intersection of its left and right side, the resulting Rect will have negative width or height.

`fun RoundRect.withRadius(radius: Radius): RoundRect`

## Extension properties

### isCircle

`val RoundRect.isCircle: Boolean`

Whether this rounded rectangle would draw as a circle.

### isEllipse

`val RoundRect.isEllipse: Boolean`

Whether this rounded rectangle has no side with a straight section.

### isEmpty

`val RoundRect.isEmpty: Boolean`

Whether this rounded rectangle encloses a non-zero area. Negative areas are considered empty.

### isFinite

`val RoundRect.isFinite: Boolean`

Whether all coordinates of this rounded rectangle are finite.

### isRect

`val RoundRect.isRect: Boolean`

Whether this rounded rectangle is a simple rectangle with zero corner radii.

### isSimple

`val RoundRect.isSimple: Boolean`

Returns `true` if the rounded rectangle have the same radii in both the horizontal and vertical direction for all corners.

`val RoundRect.isStadium: Boolean`

Whether this rounded rectangle has a side with no straight section.

### longestSide

`val RoundRect.longestSide: Float`

The greater of the magnitudes of the RoundRect.width and the RoundRect.height of this rounded rectangle.

### shortestSide

`val RoundRect.shortestSide: Float`

The lesser of the magnitudes of the RoundRect.width and the RoundRect.height of this rounded rectangle.