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

## CanvasContext.lineTo

> [VERSION] Base Library >= 2.21.8

### Description

Add a new point, then create a line from the last specified point to the target point

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `x` | `number` | Yes | Target x coordinate |
| `y` | `number` | Yes | Target y coordinate |

### Return Value

None


### Examples

#### Draw a line

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