---
title: "IntRect"
description: "An immutable, 2D, axis-aligned, integer bounds rectangle whose coordinates are relative to a
given origin."
type: "class"
---

<div class='type'>Class</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
data class IntRect(
    /** The offset of the left edge of this rectangle from the x axis. */
    @Stable val left: Int,

    /** The offset of the top edge of this rectangle from the y axis. */
    @Stable val top: Int,

    /** The offset of the right edge of this rectangle from the x axis. */
    @Stable val right: Int,

    /** The offset of the bottom edge of this rectangle from the y axis. */
    @Stable val bottom: Int,
)
```


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


## Properties

<div class='sourceset sourceset-common'>Common</div>


```kotlin
val width: Int
```


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



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val height: Int
```


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



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val size: IntSize
```


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



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val isEmpty: Boolean
```


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



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val minDimension: Int
```


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



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val maxDimension: Int
```


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



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val topLeft: IntOffset
```


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



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val topCenter: IntOffset
```


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



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val topRight: IntOffset
```


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



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val centerLeft: IntOffset
```


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



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val center: IntOffset
```


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

See also `IntSize.center`.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val centerRight: IntOffset
```


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



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val bottomLeft: IntOffset
```


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



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val bottomCenter: IntOffset
```


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



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val bottomRight: IntOffset
```


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



## Functions

```kotlin
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`.


```kotlin
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.


```kotlin
fun inflate(delta: Int): IntRect
```


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


```kotlin
fun deflate(delta: Int): IntRect
```


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


```kotlin
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.


```kotlin
fun overlaps(other: IntRect): Boolean
```


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


```kotlin
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.


## Companion Object

#### Properties

<div class='sourceset sourceset-common'>Common</div>


```kotlin
val Zero: IntRect
```


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





