---
name: "CanvasContext.rect"
mode: "api"
versionRequirements:
  - { name: "Base Library", version: "2.21.8" }
title: "rect"
---

## CanvasContext.rect

> [VERSION] Base Library >= 2.21.8

### Description

Create a rectangular path

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `x` | `number` | Yes | x-coordinate of the rectangle's top-left corner |
| `y` | `number` | Yes | y-coordinate of the rectangle's top-left corner |
| `width` | `number` | Yes | Width of the rectangle |
| `height` | `number` | Yes | Height of the rectangle |

### Return Value

None


### Examples

#### Create a rectangular path

```ts
const ctx = ty.createCanvasContext('myCanvas');
ctx.beginPath();
ctx.rect(10, 10, 150, 100);
ctx.stroke();
ctx.draw();
```
