• Cmn
    data class Rect

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

Summary

Nested types

Public companion properties

Rect

A rectangle with left, top, right, and bottom edges all at zero.

Cmn

Public constructors

Rect(left: Float, top: Float, right: Float, bottom: Float)
Cmn

Public functions

operator Boolean
contains(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.

Cmn
Rect
deflate(delta: Float)

Returns a new rectangle with edges moved inwards by the given delta.

Cmn
Rect
inflate(delta: Float)

Returns a new rectangle with edges moved outwards by the given delta.

Cmn
Rect
intersect(other: Rect)

Returns a new rectangle that is the intersection of the given rectangle and this rectangle.

Cmn
Rect
intersect(
    otherLeft: Float,
    otherTop: Float,
    otherRight: Float,
    otherBottom: Float
)

Returns a new rectangle that is the intersection of the given rectangle and this rectangle.

Cmn
Boolean
overlaps(other: Rect)

Whether other has a nonzero area of overlap with this rectangle.

Cmn
open String
Cmn
Rect
translate(offset: Offset)

Returns a new rectangle translated by the given offset.

Cmn
Rect
translate(translateX: Float, translateY: Float)

Returns a new rectangle with translateX added to the x components and translateY added to the y components.

Cmn

Public properties

Float

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

Cmn
Offset

The offset to the center of the bottom edge of this rectangle.

Cmn
Offset

The offset to the intersection of the bottom and left edges of this rectangle.

Cmn
Offset

The offset to the intersection of the bottom and right edges of this rectangle.

Cmn
Offset

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

Cmn
Offset

The offset to the center of the left edge of this rectangle.

Cmn
Offset

The offset to the center of the right edge of this rectangle.

Cmn
Float

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

Cmn
Boolean

Whether this rectangle encloses a non-zero area.

Cmn
Boolean

Whether all coordinates of this rectangle are finite.

Cmn
Boolean

Whether any of the coordinates of this rectangle are equal to positive infinity.

Cmn
Float

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

Cmn
Float

The greater of the magnitudes of the width and the height of this rectangle.

Cmn
Float

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

Cmn
Float

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

Cmn
Size

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

Cmn
Float

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

Cmn
Offset

The offset to the center of the top edge of this rectangle.

Cmn
Offset

The offset to the intersection of the top and left edges of this rectangle.

Cmn
Offset

The offset to the intersection of the top and right edges of this rectangle.

Cmn
Float

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

Cmn

Extension functions

IntRect

Rounds a Rect to an IntRect

Cmn
Rect

This function is deprecated. Converting Rect to android.graphics.Rect is lossy, and requires rounding.

android
RectF

Creates a new instance of android.graphics.RectF with the same bounds specified in the given Rect

android

Public companion properties

Zero

val ZeroRect

A rectangle with left, top, right, and bottom edges all at zero.

Public constructors

Rect

Rect(left: Float, top: Float, right: Float, bottom: Float)

Public functions

contains

operator fun contains(offset: Offset): 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.

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

deflate

fun deflate(delta: Float): Rect

Returns a new rectangle with edges moved inwards by the given delta.

inflate

fun inflate(delta: Float): Rect

Returns a new rectangle with edges moved outwards by the given delta.

intersect

fun intersect(other: Rect): Rect

Returns a new rectangle that is the intersection of the given rectangle and this rectangle. The two rectangles must overlap for this to be meaningful. If the two rectangles do not overlap, then the resulting Rect will have a negative width or height.

intersect

fun intersect(
    otherLeft: Float,
    otherTop: Float,
    otherRight: Float,
    otherBottom: Float
): Rect

Returns a new rectangle that is the intersection of the given rectangle and this rectangle. The two rectangles must overlap for this to be meaningful. If the two rectangles do not overlap, then the resulting Rect will have a negative width or height.

overlaps

fun overlaps(other: Rect): Boolean

Whether other has a nonzero area of overlap with this rectangle.

toString

open fun toString(): String

translate

fun translate(offset: Offset): Rect

Returns a new rectangle translated by the given offset.

To translate a rectangle by separate x and y components rather than by an Offset, consider translate.

translate

fun translate(translateX: Float, translateY: Float): Rect

Returns a new rectangle with translateX added to the x components and translateY added to the y components.

Public properties

bottom

val bottomFloat

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

bottomCenter

val bottomCenterOffset

The offset to the center of the bottom edge of this rectangle.

bottomLeft

val bottomLeftOffset

The offset to the intersection of the bottom and left edges of this rectangle.

bottomRight

val bottomRightOffset

The offset to the intersection of the bottom and right edges of this rectangle.

center

val centerOffset

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

See also Size.center.

centerLeft

val centerLeftOffset

The offset to the center of the left edge of this rectangle.

centerRight

val centerRightOffset

The offset to the center of the right edge of this rectangle.

height

val heightFloat

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

isEmpty

val isEmptyBoolean

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

isFinite

val isFiniteBoolean

Whether all coordinates of this rectangle are finite.

isInfinite

val isInfiniteBoolean

Whether any of the coordinates of this rectangle are equal to positive infinity.

left

val leftFloat

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

maxDimension

val maxDimensionFloat

The greater of the magnitudes of the width and the height of this rectangle.

minDimension

val minDimensionFloat

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

right

val rightFloat

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

size

val sizeSize

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

top

val topFloat

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

topCenter

val topCenterOffset

The offset to the center of the top edge of this rectangle.

topLeft

val topLeftOffset

The offset to the intersection of the top and left edges of this rectangle.

topRight

val topRightOffset

The offset to the intersection of the top and right edges of this rectangle.

width

val widthFloat

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

Extension functions

roundToIntRect

fun Rect.roundToIntRect(): IntRect

Rounds a Rect to an IntRect

toAndroidRect

fun Rect.toAndroidRect(): Rect

Creates a new instance of android.graphics.Rect with the same bounds specified in the given Rect

toAndroidRectF

fun Rect.toAndroidRectF(): RectF

Creates a new instance of android.graphics.RectF with the same bounds specified in the given Rect