Canvas moveTo() Method
Definition and Usage
moveTo()
This method moves the path to the specified point on the canvas without creating a line.
Hint:Please use stroke() method to draw an exact path on the canvas.
instance
Start a path, 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();
syntax
context.moveTo(x,y;
parameter value
parameter | description |
---|---|
x | The x-coordinate of the target location of the path |
y | The y-coordinate of the target location of the path |
Browser Support
The numbers in the table indicate the first browser version that fully supports this property.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
4.0 | 9.0 | 3.6 | 4.0 | 10.1 |
Note:Internet Explorer 8 and earlier versions do not support the <canvas> element.