Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML canvas moveTo() method

HTML canvas moveTo() method

HTML canvas Reference HTML canvas Reference Manual

Example

Begin a path and move to position 0,0. Create a line to position 300,150:

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 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.

HTML canvas Reference HTML canvas Reference Manual