HTML canvas moveTo() 方法
实例
开始一条路径,移动到位置 0,0。创建到达位置 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.