beginPath विधि
beginPath विधि को कॉल किया जाना चाहिए
moveTo
और lineTo विधियों के संयोजन का उपयोग करके
लाइन ड्राइंग शुरू करते समय।
सिंटैक्स
context.beginPath();
उदाहरण
आइए एक रेखा बनाएं:
<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
let canvas = document.querySelector('#canvas');
let ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.moveTo(50, 50);
ctx.lineTo(150, 50);
ctx.stroke();
:
उदाहरण
आइए एक वर्ग बनाएं:
<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
let canvas = document.querySelector('#canvas');
let ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.moveTo(50, 50);
ctx.lineTo(150, 50);
ctx.lineTo(150, 150);
ctx.lineTo(50, 150);
ctx.closePath();
ctx.stroke();
: