---
title: "MutableRect"
description: "An mutable, 2D, axis-aligned, floating-point 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
class MutableRect(var left: Float, var top: Float, var right: Float, var bottom: Float)
```


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

#### Parameters

| | |
| --- | --- |
| left | The offset of the left edge of this rectangle from the x axis. |
| top | The offset of the top edge of this rectangle from the y axis. |
| right | The offset of the right edge of this rectangle from the x axis. |
| bottom | The offset of the bottom edge of this rectangle from the y axis. |



## Properties

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


```kotlin
inline val width: Float
```


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



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


```kotlin
inline val height: Float
```


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



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


```kotlin
val size: Size
```


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



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


```kotlin
val isInfinite: Boolean
```


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



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


```kotlin
val isFinite: Boolean
```


Whether all coordinates of this rectangle are finite.



<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: Float
```


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



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


```kotlin
val maxDimension: Float
```


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



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


```kotlin
val topLeft: Offset
```


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



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


```kotlin
val topCenter: Offset
```


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



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


```kotlin
val topRight: Offset
```


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



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


```kotlin
val centerLeft: Offset
```


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



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


```kotlin
val center: Offset
```


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

See also `Size.center`.



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


```kotlin
val centerRight: Offset
```


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



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


```kotlin
val bottomLeft: Offset
```


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



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


```kotlin
val bottomCenter: Offset
```


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



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


```kotlin
val bottomRight: Offset
```


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



## Functions

```kotlin
fun translate(offset: Offset) = translate(offset.x, offset.y)
```


Translates the rect by the provided `Offset`.


```kotlin
fun translate(translateX: Float, translateY: Float)
```


Updates this rectangle with translateX added to the x components and translateY added to the
y components.


```kotlin
fun inflate(delta: Float)
```


Moves edges outwards by the given delta.


```kotlin
fun deflate(delta: Float) = inflate(-delta)
```


Moves edges inwards by the given delta.


```kotlin
fun intersect(left: Float, top: Float, right: Float, bottom: Float)
```


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


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


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


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


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


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


```kotlin
fun set(left: Float, top: Float, right: Float, bottom: Float)
```


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



