{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

RectKt

public final class RectKt


Summary

Public methods

static final @NonNull Rect
Rect(@NonNull Offset center, float radius)

Construct a rectangle that bounds the given circle

static final @NonNull Rect
Rect(@NonNull Offset offset, @NonNull Size size)

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

static final @NonNull Rect
Rect(@NonNull Offset topLeft, @NonNull Offset bottomRight)

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

static final @NonNull Rect
lerp(@NonNull Rect start, @NonNull Rect stop, float fraction)

Linearly interpolate between two rectangles.

Public methods

Rect

public static final @NonNull Rect Rect(@NonNull Offset center, float radius)

Construct a rectangle that bounds the given circle

Parameters
@NonNull Offset center

Offset that represents the center of the circle

float radius

Radius of the circle to enclose

Rect

public static final @NonNull Rect Rect(@NonNull Offset offset, @NonNull Size size)

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

Parameters
@NonNull Offset offset

Offset to represent the top and left parameters of the Rect

@NonNull Size size

Size to determine the width and height of this Rect.

Returns
@NonNull 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

Rect

public static final @NonNull Rect Rect(@NonNull Offset topLeft, @NonNull Offset bottomRight)

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

Parameters
@NonNull Offset topLeft

Offset representing the left and top edges of the rectangle

@NonNull Offset bottomRight

Offset representing the bottom and right edges of the rectangle

lerp

public static final @NonNull Rect lerp(@NonNull Rect start, @NonNull Rect stop, float fraction)

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.