HTML canvas lineTo() နည်းလမ်း
ဥပမာ
လမ်းကြောင်းတစ်ခုစတင်ပါ၊ အနေအထား 0.0 သို့ရွှေ့ပါ။ 300,150 အနေအထားသို့ လိုင်းတစ်ခုဖန်တီးပါ
JavaScript-
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(300, 150);
ctx.stroke();
Browser ပံ့ပိုးမှု
ဇယားရှိ နံပါတ်များသည် နည်းလမ်းကို အပြည့်အဝထောက်ခံသည့် ပထမဆုံးဘရောက်ဆာဗားရှင်းကို သတ်မှတ်ပေးသည်။
Method | |||||
---|---|---|---|---|---|
lineTo() | Yes | 9.0 | Yes | Yes | Yes |
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
lineTo() နည်းလမ်းသည် အမှတ်အသစ်တစ်ခုကို ပေါင်းထည့်ကာ ကင်းဗတ်စ်ရှိ နောက်ဆုံးသတ်မှတ်ထားသော အမှတ်မှ ထိုအမှတ်ဆီသို့ မျဉ်းကြောင်းတစ်ခု ဖန်တီးပေးသည် (ဤနည်းလမ်းသည် မျဉ်းမဆွဲပါ)။
အကြံပြုချက်- ကင်းဗတ်စ်ပေါ်တွင် လမ်းကြောင်းအမှန်တကယ်ဆွဲရန် stroke() နည်းလမ်းကို အသုံးပြု ပါ။
JavaScript syntax- | စကား စပ် .lineTo( x,y ); |
---|
ကန့်သတ်တန်ဖိုးများ
Parameter | Description | Play it |
---|---|---|
x | The x-coordinate of where to create the line to | |
y | The y-coordinate of where to create the line to |
နောက်ထပ် ဥပမာများ
ဥပမာ
အက္ခရာ L အဖြစ်ပုံဖော်ပြီး လမ်းကြောင်းတစ်ခုဆွဲပါ။
JavaScript-
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.moveTo(20, 20);
ctx.lineTo(20, 100);
ctx.lineTo(70, 100);
ctx.stroke();
❮ HTML Canvas အကိုးအကား