androidx.compose.ui.geometry

Classes

CornerRadius

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

Cmn
MutableRect

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

Cmn
Offset

An immutable 2D floating-point offset.

Cmn
Rect

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

Cmn
RoundRect

An immutable rounded rectangle with custom radii for all four corners.

Cmn
Size

Holds a 2D floating-point size.

Cmn

Objects

Top-level functions summary

inline CornerRadius

Constructs a Radius with the given x and y parameters for the size of the radius along the x and y axis respectively.

Cmn
MutableRect
MutableRect(center: Offset, radius: Float)

Construct a rectangle that bounds the given circle

Cmn
MutableRect
MutableRect(offset: Offset, size: Size)

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

Cmn
MutableRect
MutableRect(topLeft: Offset, bottomRight: Offset)

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

Cmn
inline Offset
Offset(x: Float, y: Float)

Constructs an Offset from the given relative x and y offsets

Cmn
Rect
Rect(center: Offset, radius: Float)

Construct a rectangle that bounds the given circle

Cmn
Rect
Rect(offset: Offset, size: Size)

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

Cmn
Rect
Rect(topLeft: Offset, bottomRight: Offset)

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

Cmn
RoundRect
RoundRect(rect: Rect, cornerRadius: CornerRadius)

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

Cmn
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.

Cmn
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.

Cmn
RoundRect
RoundRect(
    rect: Rect,
    topLeft: CornerRadius,
    topRight: CornerRadius,
    bottomRight: CornerRadius,
    bottomLeft: CornerRadius
)

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

Cmn
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.

Cmn
inline Size
Size(width: Float, height: Float)

Constructs a Size from the given width and height

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

Linearly interpolate between two radii.

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

Linearly interpolate between two offsets.

Cmn
Rect
lerp(start: Rect, stop: Rect, fraction: Float)

Linearly interpolate between two rectangles.

Cmn
RoundRect
lerp(start: RoundRect, stop: RoundRect, fraction: Float)

Linearly interpolate between two rounded rectangles.

Cmn
Size
lerp(start: Size, stop: Size, fraction: Float)

Linearly interpolate between two sizes

Cmn

Extension functions summary

inline Offset
Offset.takeOrElse(block: () -> Offset)

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

Cmn
inline Size
Size.takeOrElse(block: () -> Size)

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

Cmn
inline operator Size
Int.times(size: Size)

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

Cmn
inline operator Size
Double.times(size: Size)

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

Cmn
inline operator Size
Float.times(size: Size)

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

Cmn
Rect
Cmn
Rect

Convert a Size to a Rect.

Cmn
RoundRect

Returns a new RoundRect translated by the given offset.

Cmn

Extension properties summary

Rect

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

Cmn
Offset

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

Cmn
Offset

Returns the Offset of the center of the rect from the point of 0, 0 with this Size.

Cmn
Boolean

Whether this rounded rectangle would draw as a circle.

Cmn
Boolean

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

Cmn
Boolean

Whether this rounded rectangle encloses a non-zero area.

Cmn
Boolean

True if both x and y values of the Offset are finite.

Cmn
Boolean

Whether all coordinates of this rounded rectangle are finite.

Cmn
Boolean

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

Cmn
Boolean

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

Cmn
Boolean

false when this is Offset.Unspecified.

Cmn
Boolean

false when this is Size.Unspecified.

Cmn
Boolean

true when this is Offset.Unspecified.

Cmn
Boolean

true when this is Size.Unspecified.

Cmn
Float
Cmn
Float

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

Cmn
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.

Cmn

Top-level functions

CornerRadius

inline fun CornerRadius(x: Float, y: Float = x): CornerRadius

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. Negative radii values are clamped to 0.

MutableRect

fun MutableRect(center: Offset, radius: Float): MutableRect

Construct a rectangle that bounds the given circle

Parameters
center: Offset

Offset that represents the center of the circle

radius: Float

Radius of the circle to enclose

MutableRect

fun MutableRect(offset: Offset, size: Size): MutableRect

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.

Returns
MutableRect

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

MutableRect

fun MutableRect(topLeft: Offset, bottomRight: Offset): MutableRect

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

Offset

inline fun Offset(x: Float, y: Float): Offset

Constructs an Offset from the given relative x and y offsets

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

radius: Float

Radius of the circle to enclose

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.

Returns
Rect

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

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

fun RoundRect(rect: Rect, cornerRadius: CornerRadius): RoundRect

Construct a rounded rectangle from its bounding box and a radius that is the same 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.

fun RoundRect(
    left: Float,
    top: Float,
    right: Float,
    bottom: Float,
    cornerRadius: CornerRadius
): RoundRect

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

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

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

The corner radii default to CornerRadius.Zero, i.e. right-angled corners

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.

Size

inline fun Size(width: Float, height: Float): Size

Constructs a Size from the given width and height

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

Linearly interpolate between two radii.

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.

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

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.

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

takeOrElse

inline fun Offset.takeOrElse(block: () -> Offset): Offset

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

takeOrElse

inline fun Size.takeOrElse(block: () -> Size): Size

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

inline operator fun Int.times(size: Size): Size

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

inline operator fun Double.times(size: Size): Size

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

inline operator fun Float.times(size: Size): Size

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

toRect

fun MutableRect.toRect(): Rect
fun Size.toRect(): Rect

Convert a Size to a Rect.

fun RoundRect.translate(offset: Offset): RoundRect

Returns a new RoundRect translated by the given offset.

Extension properties

boundingRect

val RoundRect.boundingRectRect

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

center

val RoundRect.centerOffset

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

val Size.centerOffset

Returns the Offset of the center of the rect from the point of 0, 0 with this Size.

isCircle

val RoundRect.isCircleBoolean

Whether this rounded rectangle would draw as a circle.

isEllipse

val RoundRect.isEllipseBoolean

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

isEmpty

val RoundRect.isEmptyBoolean

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

val Offset.isFiniteBoolean

True if both x and y values of the Offset are finite. NaN values are not considered finite.

isFinite

val RoundRect.isFiniteBoolean

Whether all coordinates of this rounded rectangle are finite.

isRect

val RoundRect.isRectBoolean

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

isSimple

val RoundRect.isSimpleBoolean

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

isSpecified

val Offset.isSpecifiedBoolean

false when this is Offset.Unspecified.

isSpecified

val Size.isSpecifiedBoolean

false when this is Size.Unspecified.

isUnspecified

val Offset.isUnspecifiedBoolean

true when this is Offset.Unspecified.

isUnspecified

val Size.isUnspecifiedBoolean

true when this is Size.Unspecified.

maxDimension

val RoundRect.maxDimensionFloat

minDimension

val RoundRect.minDimensionFloat

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

safeInnerRect

val RoundRect.safeInnerRectRect

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.