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

## CanvasContext.strokeRect

> [VERSION] Base Library >= 2.21.8

### Description

Draw a rectangle (not filled)

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

#### Stroke the rectangle

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