[ Leksykon ] [ JavaScript ] [ Metody ] [ Właściwości ] [ canvas ] [ CanvasRenderingContext2D ]
CanvasRenderingContext2D.beginPath()
[_] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z]
Przykłady:
<script>
window.onload = () => {
const szer = 600;
const wys = 300;
const canvas = document.getElementById("canvas");
canvas.width = szer;
canvas.height = wys;
const ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.strokeStyle = "brown";
ctx.moveTo(50, 50);
ctx.lineTo(200, 50);
ctx.stroke();
ctx.beginPath();
ctx.strokeStyle = "blue";
ctx.moveTo(200, 50);
ctx.lineTo(20, 200);
ctx.stroke();
ctx.beginPath();
ctx.strokeStyle = "green";
ctx.moveTo(20, 200);
ctx.lineTo(50, 50);
ctx.stroke();
};
</script>
<canvas id="canvas" width="1" height="1"></canvas>
Opis:
Metoda CanvasRenderingContext2D.beginPath() rozpoczyna nową ścieżkę poprzez opróżnienie listy ścieżek podrzędnych. Wywołaj tę metodę, jeśli chcesz utworzyć nową ścieżkę. Aby utworzyć nową podścieżkę, czyli pasującą do bieżącego stanu obszaru roboczego, możesz użyć CanvasRenderingContext2D.moveTo().
Zobacz też:
moveTo() -