Metoda HTML canvas beginPath ()
HTML Instrukcja płótno referencyjny
Przykłady
Narysuj dwie ścieżki na płótnie, zielone i fioletowe:
JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.lineWidth="5";
ctx.strokeStyle="green"; // Green path
ctx.moveTo(0,75);
ctx.lineTo(250,75);
ctx.stroke(); // Draw it
ctx.beginPath();
ctx.strokeStyle="purple"; // Purple path
ctx.moveTo(50,0);
ctx.lineTo(150,130);
ctx.stroke(); // Draw it
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.lineWidth="5";
ctx.strokeStyle="green"; // Green path
ctx.moveTo(0,75);
ctx.lineTo(250,75);
ctx.stroke(); // Draw it
ctx.beginPath();
ctx.strokeStyle="purple"; // Purple path
ctx.moveTo(50,0);
ctx.lineTo(150,130);
ctx.stroke(); // Draw it
Spróbuj »
Pomoc Browser
Internet Explorer 9, Firefox, Opera, Chrome i Safari wsparcie beginPath metoda ().
Uwaga: 8 i wcześniejsze wersje programu Internet Explorer nie obsługuje <canvas> elementu.
Definicja i Wykorzystanie
Metoda beginPath (), aby rozpocząć drogę, lub zresetować bieżącą ścieżkę.
Wskazówka: Za pomocą tych metod do tworzenia ścieżek moveTo (), lineTo (), quadricCurveTo (), bezierCurveTo (), arcTo () oraz (ARC).
Wskazówka: Użyj udar () metody, aby zwrócić dokładną ścieżkę na płótnie.
Składnia JavaScript: | Kontekst .beginPath (); |
---|
HTML Instrukcja płótno referencyjny