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

HTML Referenzhandbuch

Komplettes Verzeichnis der HTML-Tags

HTML canvas beginPath() Methode

beginPath() ist eine Methode von Canvas 2D API beginnt mit dem Leeren der Liste der Unterpfade, um einen neuen Pfad zu starten. Wenn du einen neuen Pfad erstellen möchtest, rufe diese Methode auf.

HTML canvas Reference Manual

Online-Beispiel

In der Leinwand werden zwei Pfade gezeichnet; grün und lila:

Ihr Browser unterstützt keine HTML5 canvas-Tag.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Verwendung der Methode beginPath() für HTML canvas-Einführung (oldtoolbag.com)</<title>
</<head>
<body>
<canvas id="myCanvas" width="300" height="150" style="border:1px fest #d3d3d3>
Ihr Browser unterstützt keine HTML5 canvas-Tag.
</canvas>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();              
ctx.lineWidth="5";
ctx.strokeStyle="green";  // Grüner Pfad
ctx.moveTo(0,75);
ctx.lineTo(250,75);
ctx.stroke();  // draw 
ctx.beginPath();
ctx.strokeStyle="purple";  // Lilaer Pfad
ctx.moveTo(50,0);
ctx.lineTo(150,130);            
ctx.stroke();  // draw
</script>
</body>
</html>
Test to see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

Internet Explorer 9Firefox, Opera, Chrome and Safari support beginPath(). Methods.

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

Definition and Usage

The beginPath() method starts a new path or resets the current path.

Hint:Please use these methods to create paths moveTo(), lineTo(), quadricCurveTo(), bezierCurveTo(), arcTo() and arc().

Hint:Please use stroke() The method draws an exact path on the canvas.

JavaScript Syntax:context.beginPath();
HTML canvas Reference Manual