English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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.
In der Leinwand werden zwei Pfade gezeichnet; grün und lila:
<!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 ‹/›
IEFirefoxOperaChromeSafari
Internet Explorer 9Firefox, Opera, Chrome and Safari support beginPath(). Methods.
Note:Internet Explorer 8 And earlier versions do not support the <canvas> element.
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(); |
---|