English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Referenzhandbuch

HTML-Tagverzeichnis

HTML canvas moveTo() Methode

moveTo() ist eine Canvas 2D API verschiebt den Startpunkt eines neuen Unterpfades auf die Koordinaten (x, y).

HTML canvas Reference Manual

Online-Beispiel

Beginnen Sie einen Pfad, bewegen Sie sich in Position 0,0. Erstellen Sie eine Position 300,150 einer Linie:

Ihr Browser unterstützt keine HTML5 canvas-Tag.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Verwendung der HTML canvas moveTo() Methode-Grundtutorials(oldtoolbag.com)</<title>
</<head>
<body>
<canvas id="myCanvas" width="300" height="150" style="Border:1px festes #d3d3d3">
Ihr Browser unterstützt keine 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 ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

Internet Explorer 9Firefox, Opera, Chrome and Safari support moveTo() Method.

Note:Internet Explorer 8 And earlier versions do not support the <canvas> element.

Definition and Usage

The moveTo() method moves the path to the 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 value

ParameterDescription
xThe x-coordinate of the target location of the path.
yThe y-coordinate of the target location of the path.
HTML canvas Reference Manual