beginPath() - beginPath()-The beginPath() method begins a path or resets the current path-Метод beginPath() начинает путь или сбрасывает текущий путь
Näide:
st canvas = document.getElementById("myCanvas");
const ctx = canvas.getContext("2d");
ctx.strokeStyle = "green";
ctx.lineWidth = 5
// Begin a Path
ctx.beginPath();
ctx.moveTo(0, 75);
ctx.lineTo(250, 75);
// Draw the Path
ctx.stroke();
// Begin a new Path
ctx.beginPath();
ctx.strokeStyle = "purple";
ctx.moveTo(50, 0);
ctx.lineTo(150, 130);
// Draw the Path
ctx.stroke();