HTML canvas moveTo() methode

Definitie en gebruik

moveTo() De methode verplaatst het pad naar de specifieke locatie op het canvas zonder een lijn te maken.

Tip:Gebruik stroke() De methode tekent de exacte pad op het canvas.

Voorbeeld

Begin een pad, verplaats naar positie 0,0. Maak een lijn naar positie 300,150:

Uw browser ondersteunt de HTML5 canvas tag niet.

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 yourself

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 to fully support 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.