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

## CanvasContext.fillRect

> [VERSION] Base Library >= 2.21.8

### Description

Fill a rectangle

### 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

#### Fill the rectangle

```ts
const ctx = ty.createCanvasContext('myCanvas');
ctx.setFillStyle('#ff0000');
ctx.fillRect(10, 10, 150, 75);
ctx.draw();
```
