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

## CanvasContext.clearRect

> [VERSION] Base Library >= 2.21.8

### Description

Clear the contents of the canvas within this rectangle

### Parameters

`Params`

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

### Return Value

None


### Examples

#### Clear the rectangle area

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