HTML canvas beginPath() method
Definition and usage
beginPath()
Method starts a path or resets the current path.
Tip:Please use these methods to create paths: moveTo(), lineTo(), quadricCurveTo(), bezierCurveTo(), arcTo() and arc().
Tip:Please use stroke() Method to draw an exact path on the canvas.
Example
In the canvas draw two paths; red and blue:
JavaScript:
var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.beginPath(); ctx.lineWidth="5"; ctx.strokeStyle="red"; // مسار أحمر ctx.moveTo(0,75); ctx.lineTo(250,75); ctx.stroke(); // إجراء الرسم ctx.beginPath(); ctx.strokeStyle="blue"; // مسار أزرق ctx.moveTo(50,0); ctx.lineTo(150,130); ctx.stroke(); // إجراء الرسم
النصابة
خطوة البداية للسياق.beginPath();
دعم المتصفحات
الرقم في الجدول يشير إلى إصدار المتصفح الذي يدعم الخاصية لأول مرة.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
4.0 | 9.0 | 3.6 | 4.0 | 10.1 |
التعليقات:التصفحات الأقدم من Internet Explorer 8 لا تدعم عنصر <canvas>.