HTML canvas lineTo() Method
Example
let c = document.getElementById("myCanvas");
let ctx = c.getContext("2d");
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(150, 150);
ctx.stroke();
Meaning
The lineTo() method adds a new point and creates a line to that point from the last specified point in the canvas.
Standard Syntax
JavaScript syntax:
context.lineTo(x,y);
Advertisement
Parameter Values
| Parameter | Description |
|---|---|
| x | Specifies the x-coordinate of where to create the line to. |
| y | Specifies the y-coordinate of where to create the line to. |