---
name: Rect
last_updated: 2026-06-11T17:05:17Z
type: datatype
summary: "A value that represents a two-dimensional rectangle."
---

# Rect

A value that represents a two-dimensional rectangle.

**Type:** datatype

## Description

**Rect** describes a rectangle on a 2D plane. It is constructed using two
corners, either two [Vector2](/docs/reference/engine/datatypes/Vector2.md) positions or four numbers:

```lua
local rect1 = Rect.new(Vector2.new(10, 10), Vector2.new(80, 80))
local rect2 = Rect.new(10, 10, 80, 80)
```

This data type is used in the [ImageLabel.SliceCenter](/docs/reference/engine/classes/ImageLabel.md) property which
determines the center area of a scaled image.

## Constructors

### Rect.new

**Signature:** `Rect.new()`

Constructs a new **Rect** with two zero [Vector2](/docs/reference/engine/datatypes/Vector2.md) positions.

### Rect.new

**Signature:** `Rect.new(min: Vector2, max: Vector2)`

Constructs a new **Rect** given two [Vector2](/docs/reference/engine/datatypes/Vector2.md) positions: `min` as
the top-left corner and `max` as the bottom-right corner.

**Parameters:**

| Name | Type | Default | Description |
|------|------|---------|-------------|
| `min` | `Vector2` |  |  |
| `max` | `Vector2` |  |  |

### Rect.new

**Signature:** `Rect.new(minX: number, minY: number, maxX: number, maxY: number)`

Constructs a new **Rect** using `minX` and `minY` as coordinates for the
top-left corner, and `maxX` and `maxY` as coordinates for the bottom-right
corner.

**Parameters:**

| Name | Type | Default | Description |
|------|------|---------|-------------|
| `minX` | `number` |  |  |
| `minY` | `number` |  |  |
| `maxX` | `number` |  |  |
| `maxY` | `number` |  |  |

## Properties

### Rect.Width

**Type:** `number`

The width of the **Rect** in pixels.

### Rect.Height

**Type:** `number`

The height of the **Rect** in pixels.

### Rect.Min

**Type:** `Vector2`

The top-left corner.

### Rect.Max

**Type:** `Vector2`

The bottom-right corner.