HTML-Leinwand moveTo () -Methode
Beispiele
Starten Sie einen Pfad, auf die Position 0,0. 300, erreicht 150 eine Position um eine Linie zu erstellen:
JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.moveTo(0,0);
ctx.lineTo(300,150);
ctx.stroke();
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.moveTo(0,0);
ctx.lineTo(300,150);
ctx.stroke();
Versuchen »
Browser-Unterstützung
Internet Explorer 9, Firefox, Opera, Chrome und Safari Unterstützung moveTo () -Methode.
Hinweis: 8 und frühere Versionen von Internet Explorer unterstützt nicht das <canvas> -Element.
Definition und Verwendung
moveTo () -Methode auf den Pfad angegebenen Punkt auf die Leinwand zu bewegen, werden die Linien nicht erstellt.
Tipp: Verwenden Sie den Hub () Methode , um den genauen Pfad auf der Leinwand zu zeichnen.
JavaScript-Syntax: | Kontext.moveTo (x, y); |
---|
Parameter Wert
参数 | 描述 |
---|---|
x | 路径的目标位置的 x 坐标。 |
y | 路径的目标位置的 y 坐标。 |