IntRect


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

Summary

Public companion properties

IntRect

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

Cmn

Public constructors

IntRect(left: Int, top: Int, right: Int, bottom: Int)
Cmn

Public functions

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.

Cmn
IntRect
deflate(delta: Int)

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

Cmn
IntRect
inflate(delta: Int)

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

Cmn
IntRect

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

Cmn
Boolean
overlaps(other: IntRect)

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

Cmn
open String
Cmn
IntRect

Returns a new rectangle translated by the given offset.

Cmn
IntRect
translate(translateX: Int, translateY: Int)

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

Cmn

Public properties

Int

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

Cmn
IntOffset

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

Cmn
IntOffset

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

Cmn
IntOffset

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

Cmn
IntOffset

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

Cmn
IntOffset

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

Cmn
IntOffset

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

Cmn
Int

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

Cmn
Boolean

Whether this rectangle encloses a non-zero area.

Cmn
Int

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

Cmn
Int

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

Cmn
Int

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

Cmn
Int

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

Cmn
IntSize

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

Cmn
Int

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

Cmn
IntOffset

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

Cmn
IntOffset

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

Cmn
IntOffset

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

Cmn
Int

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

Cmn

Extension functions

Rect

Converts an IntRect to a Rect

Cmn
Rect

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

android

Public companion properties

Zero

val ZeroIntRect

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

Public constructors

IntRect

IntRect(left: Int, top: Int, right: Int, bottom: Int)

Public functions

contains

fun contains(offset: IntOffset): 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: Int): IntRect

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

inflate

fun inflate(delta: Int): IntRect

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

intersect

fun intersect(other: IntRect): IntRect

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 IntRect will have a negative width or height.

overlaps

fun overlaps(other: IntRect): Boolean

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

toString

open fun toString(): String

translate

fun translate(offset: IntOffset): IntRect

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: Int, translateY: Int): IntRect

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

Public properties

bottom

val bottomInt

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

bottomCenter

val bottomCenterIntOffset

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

bottomLeft

val bottomLeftIntOffset

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

bottomRight

val bottomRightIntOffset

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

center

val centerIntOffset

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

See also IntSize.center.

centerLeft

val centerLeftIntOffset

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

centerRight

val centerRightIntOffset

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

height

val heightInt

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.

left

val leftInt

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

maxDimension

val maxDimensionInt

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

minDimension

val minDimensionInt

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

right

val rightInt

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

size

val sizeIntSize

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

top

val topInt

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

topCenter

val topCenterIntOffset

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

topLeft

val topLeftIntOffset

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

topRight

val topRightIntOffset

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

width

val widthInt

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

Extension functions

fun IntRect.toRect(): Rect

Converts an IntRect to a Rect

toAndroidRect

fun IntRect.toAndroidRect(): Rect

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