HTML canvas moveTo() method
Example
Begin a path and move to position 0,0. Create a line to position 300,150:
JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.moveTo(0,0);
ctx.lineTo(300,150);
ctx.stroke();
Try it »
Browser support





Internet Explorer 9, Firefox, Opera, Chrome and Safari support the moveTo() method.
**Note:** Internet Explorer 8 and earlier versions do not support
Definition and Usage
The moveTo() method moves the path to a specified point in the canvas without creating a line.
**Tip:** Please use stroke() The method draws the exact path on the canvas.
| JavaScript syntax: | context.moveTo(x,y); |
|---|
Parameter value
| Parameters | Description |
|---|---|
| x | The x-coordinate of the path's target position. |
| y | The y-coordinate of the path's target position. |
Canvas object