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

MutableRect

public final class MutableRect


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

Summary

Public constructors

MutableRect(float left, float top, float right, float bottom)

Public methods

final boolean

Whether the point specified by the given offset (which is assumed to be relative to the origin) lies between the left and right and the top and bottom edges of this rectangle.

final float

The offset of the bottom edge of this rectangle from the y axis.

final float

The distance between the top and bottom edges of this rectangle.

final float

The offset of the left edge of this rectangle from the x axis.

final float

The offset of the right edge of this rectangle from the x axis.

final @NonNull Size

The distance between the upper-left corner and the lower-right corner of this rectangle.

final float

The offset of the top edge of this rectangle from the y axis.

final float

The distance between the left and right edges of this rectangle.

final void
intersect(float left, float top, float right, float bottom)

Modifies this to be the intersection of this and the rect formed by left, top, right, and bottom.

final boolean

Whether this rectangle encloses a non-zero area.

final void
set(float left, float top, float right, float bottom)

Sets new bounds to (left, top, right, bottom)

final void
setBottom(float bottom)
final void
setLeft(float left)
final void
setRight(float right)
final void
setTop(float top)
@NonNull String

Extension functions

final @NonNull Rect

Public constructors

MutableRect

public MutableRect(float left, float top, float right, float bottom)
Parameters
float left

The offset of the left edge of this rectangle from the x axis.

float top

The offset of the top edge of this rectangle from the y axis.

float right

The offset of the right edge of this rectangle from the x axis.

float bottom

The offset of the bottom edge of this rectangle from the y axis.

Public methods

contains

public final boolean contains(@NonNull Offset offset)

Whether the point specified by the given offset (which is assumed to be relative to the origin) lies between the left and right and the top and bottom edges of this rectangle.

Rectangles include their top and left edges but exclude their bottom and right edges.

getBottom

public final float getBottom()

The offset of the bottom edge of this rectangle from the y axis.

getHeight

public final float getHeight()

The distance between the top and bottom edges of this rectangle.

getLeft

public final float getLeft()

The offset of the left edge of this rectangle from the x axis.

getRight

public final float getRight()

The offset of the right edge of this rectangle from the x axis.

getSize

public final @NonNull Size getSize()

The distance between the upper-left corner and the lower-right corner of this rectangle.

getTop

public final float getTop()

The offset of the top edge of this rectangle from the y axis.

getWidth

public final float getWidth()

The distance between the left and right edges of this rectangle.

intersect

public final void intersect(float left, float top, float right, float bottom)

Modifies this to be the intersection of this and the rect formed by left, top, right, and bottom.

isEmpty

public final boolean isEmpty()

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

set

public final void set(float left, float top, float right, float bottom)

Sets new bounds to (left, top, right, bottom)

setBottom

public final void setBottom(float bottom)
Parameters
float bottom

The offset of the bottom edge of this rectangle from the y axis.

setLeft

public final void setLeft(float left)
Parameters
float left

The offset of the left edge of this rectangle from the x axis.

setRight

public final void setRight(float right)
Parameters
float right

The offset of the right edge of this rectangle from the x axis.

setTop

public final void setTop(float top)
Parameters
float top

The offset of the top edge of this rectangle from the y axis.

toString

public @NonNull String toString()

Extension functions

MutableRectKt.toRect

public final @NonNull Rect MutableRectKt.toRect(@NonNull MutableRect receiver)