English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
moveTo() is a Canvas 2The D API method that moves the starting point of a new subpath to the (x, y) coordinates.
Start a path, move to position 0,0. Create a path to position 300,150 line:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML canvas moveTo() method usage-Basic Tutorial(oldtoolbag.com)</<title> </<head> <body> <canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3> Your browser does not support HTML5 canvas tag. </canvas> <script> var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.beginPath(); ctx.moveTo(0,0); ctx.lineTo(300,150); ctx.stroke(); </script> </body> </html>Test See «/›
IEFirefoxOperaChromeSafari
Internet Explorer 9Firefox, Opera, Chrome, and Safari support moveTo(). Method.
Note:Internet Explorer 8 And earlier versions do not support the <canvas> element.
The moveTo() method moves the path to a specified point on the canvas without creating a line.
Tip:Please use stroke() Method to draw an exact path on the canvas.
JavaScript Syntax: | context.moveTo(x,y); |
---|
Parameter | Description |
---|---|
x | The x-coordinate of the target location of the path. |
y | The y-coordinate of the target location of the path. |