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

## CanvasContext.setLineDash

> [VERSION] Base Library >= 2.21.8

### Description

Set dash pattern

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `pattern` | `number[]` | Yes | An array of numbers describing the lengths of alternating dashes and gaps |
| `offset` | `number` | Yes | Dash offset |

### Return Value

None


### Examples

#### Set dashed line

```ts
const ctx = ty.createCanvasContext('myCanvas');
ctx.setLineDash([10, 5], 0);
ctx.beginPath();
ctx.moveTo(10, 50);
ctx.lineTo(190, 50);
ctx.stroke();
ctx.draw();
```
