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

RoundRectKt

public final class RoundRectKt


Summary

Public methods

static final @NonNull RoundRect
RoundRect(@NonNull Rect rect, @NonNull CornerRadius cornerRadius)

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

static final @NonNull RoundRect
RoundRect(@NonNull Rect rect, float radiusX, float radiusY)

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

static final @NonNull RoundRect
RoundRect(
    float left,
    float top,
    float right,
    float bottom,
    @NonNull CornerRadius cornerRadius
)

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

static final @NonNull RoundRect
RoundRect(
    @NonNull Rect rect,
    @NonNull CornerRadius topLeft,
    @NonNull CornerRadius topRight,
    @NonNull CornerRadius bottomRight,
    @NonNull CornerRadius bottomLeft
)

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

static final @NonNull RoundRect
RoundRect(
    float left,
    float top,
    float right,
    float bottom,
    float radiusX,
    float radiusY
)

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

static final @NonNull Rect

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

static final @NonNull Offset

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

static final float
static final float

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

static final @NonNull 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.

static final boolean

Whether this rounded rectangle would draw as a circle.

static final boolean

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

static final boolean

Whether this rounded rectangle encloses a non-zero area.

static final boolean

Whether all coordinates of this rounded rectangle are finite.

static final boolean

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

static final boolean

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

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

Linearly interpolate between two rounded rectangles.

static final @NonNull RoundRect
translate(@NonNull RoundRect receiver, @NonNull Offset offset)

Returns a new RoundRect translated by the given offset.

Public methods

RoundRect

public static final @NonNull RoundRect RoundRect(@NonNull Rect rect, @NonNull CornerRadius cornerRadius)

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

RoundRect

public static final @NonNull RoundRect RoundRect(@NonNull Rect rect, float radiusX, float radiusY)

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

RoundRect

public static final @NonNull RoundRect RoundRect(
    float left,
    float top,
    float right,
    float bottom,
    @NonNull CornerRadius cornerRadius
)

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

RoundRect

public static final @NonNull RoundRect RoundRect(
    @NonNull Rect rect,
    @NonNull CornerRadius topLeft,
    @NonNull CornerRadius topRight,
    @NonNull CornerRadius bottomRight,
    @NonNull CornerRadius bottomLeft
)

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

public static final @NonNull RoundRect RoundRect(
    float left,
    float top,
    float right,
    float bottom,
    float radiusX,
    float radiusY
)

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

getBoundingRect

public static final @NonNull Rect getBoundingRect(@NonNull RoundRect receiver)

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

getCenter

public static final @NonNull Offset getCenter(@NonNull RoundRect receiver)

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

getMaxDimension

public static final float getMaxDimension(@NonNull RoundRect receiver)

getMinDimension

public static final float getMinDimension(@NonNull RoundRect receiver)

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

getSafeInnerRect

public static final @NonNull Rect getSafeInnerRect(@NonNull RoundRect receiver)

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.

isCircle

public static final boolean isCircle(@NonNull RoundRect receiver)

Whether this rounded rectangle would draw as a circle.

isEllipse

public static final boolean isEllipse(@NonNull RoundRect receiver)

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

isEmpty

public static final boolean isEmpty(@NonNull RoundRect receiver)

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

isFinite

public static final boolean isFinite(@NonNull RoundRect receiver)

Whether all coordinates of this rounded rectangle are finite.

isRect

public static final boolean isRect(@NonNull RoundRect receiver)

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

isSimple

public static final boolean isSimple(@NonNull RoundRect receiver)

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

lerp

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

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.

translate

public static final @NonNull RoundRect translate(@NonNull RoundRect receiver, @NonNull Offset offset)

Returns a new RoundRect translated by the given offset.