Latest web development tutorials

HTML canvas moveTo () method

HTML canvas Reference Manual HTML canvas Reference Manual

Examples

Start a path, to the position 0,0. 300, 150 reaches a position to create a line:

YourbrowserdoesnotsupporttheHTML5canvastag.

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 ExplorerFirefoxOperaGoogle ChromeSafari

Internet Explorer 9, Firefox, Opera, Chrome and Safari support moveTo () method.

Note: 8 and earlier versions of Internet Explorer do not support the <canvas> element.


Definition and Usage

moveTo () method to move to the path specified point to the canvas, the lines are not created.

Tip: Use the stroke () method to draw the exact path on the canvas.

JavaScript syntax: context.moveTo (x, y);

Parameter Value

参数 描述
x 路径的目标位置的 x 坐标。
y 路径的目标位置的 y 坐标。


HTML canvas Reference Manual HTML canvas Reference Manual