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

androidx.compose.ui.geometry

Classes

CornerRadius

A radius for either circular or elliptical (oval) shapes.

MutableRect

An mutable, 2D, axis-aligned, floating-point rectangle whose coordinates are relative to a given origin.

Offset

An immutable 2D floating-point offset.

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

CornerRadius
CornerRadius(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.

Offset
Offset(x: Float, y: Float)

Constructs an Offset from the given relative x and y offsets

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, cornerRadius: CornerRadius)

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, cornerRadius: CornerRadius)

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

RoundRect
RoundRect(rect: Rect, topLeft: CornerRadius = CornerRadius.Zero, topRight: CornerRadius = CornerRadius.Zero, bottomRight: CornerRadius = CornerRadius.Zero, bottomLeft: CornerRadius = CornerRadius.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

CornerRadius
lerp(start: CornerRadius, stop: CornerRadius, fraction: Float)

Linearly interpolate between two radii.

Offset
lerp(start: Offset, stop: Offset, fraction: Float)

Linearly interpolate between two offsets.

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 Offset
Offset
Offset.takeOrElse(block: () -> Offset)

If this Offset then this is returned, otherwise block is executed and its result is returned.

For Size
Size
Size.takeOrElse(block: () -> Size)

If this Size then this is returned, otherwise block is executed and its result is returned.

Rect

Convert a Size to a Rect.

For MutableRect
Rect

For RoundRect
RoundRect

Returns a new RoundRect translated by the given offset.

Extension properties summary

For RoundRect
Rect

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

Offset

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

Boolean

Whether this rounded rectangle would draw as a circle.

Boolean

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

Boolean

Whether this rounded rectangle encloses a non-zero area.

Boolean

Whether all coordinates of this rounded rectangle are finite.

Boolean

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

Boolean

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

Float

Float

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

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.

For Size
Offset