HTML canvas beginPath() နည်းလမ်း
ဥပမာ
ကင်းဗတ်ပေါ်တွင် လမ်းနှစ်ကြောင်းဆွဲပါ။ အစိမ်းရောင်တစ်ခုနှင့် ခရမ်းရောင်တစ်ခု
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
Browser ပံ့ပိုးမှု
ဇယားရှိ နံပါတ်များသည် နည်းလမ်းကို အပြည့်အဝထောက်ခံသည့် ပထမဆုံးဘရောက်ဆာဗားရှင်းကို သတ်မှတ်ပေးသည်။
Method | |||||
---|---|---|---|---|---|
beginPath() | Yes | 9.0 | Yes | Yes | Yes |
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
beginPath() နည်းလမ်းသည် လမ်းကြောင်းတစ်ခု စတင်သည်၊ သို့မဟုတ် လက်ရှိလမ်းကြောင်းကို ပြန်လည်သတ်မှတ်သည်။
အကြံပြုချက်- လမ်းကြောင်းများဖန်တီးရန် moveTo(), lineTo(), quadricCurveTo(), bezierCurveTo(), arcTo(), နှင့် arc(), ကိုသုံးပါ။
အကြံပြုချက်- ကင်းဗတ်စ်ပေါ်တွင် လမ်းကြောင်းအမှန်တကယ်ဆွဲရန် stroke() နည်းလမ်းကို အသုံးပြု ပါ။
JavaScript syntax- | ဆက်စပ်အကြောင်းအရာ .beginPath(); |
---|
❮ HTML Canvas အကိုးအကား