HTML canvas textBaseline Property
ဥပမာ
y=100 တွင် အနီရောင်မျဉ်းတစ်ကြောင်းဆွဲပါ၊ ထို့နောက် မတူညီသော textBaseline တန်ဖိုးများဖြင့် စကားလုံးတစ်ခုစီကို y=100 တွင်ထည့်ပါ။
JavaScript-
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
//Draw a red line at y = 100
ctx.strokeStyle = "red";
ctx.moveTo(5, 100);
ctx.lineTo(395, 100);
ctx.stroke();
ctx.font = "20px Arial"
//Place each word at y = 100 with different textBaseline values
ctx.textBaseline = "top";
ctx.fillText("Top", 5, 100);
ctx.textBaseline = "bottom";
ctx.fillText("Bottom", 50, 100);
ctx.textBaseline = "middle";
ctx.fillText("Middle", 120, 100);
ctx.textBaseline = "alphabetic";
ctx.fillText("Alphabetic", 190, 100);
ctx.textBaseline = "hanging";
ctx.fillText("Hanging", 290, 100);
Browser ပံ့ပိုးမှု
ဇယားရှိ နံပါတ်များသည် ပိုင်ဆိုင်မှုကို အပြည့်အဝထောက်ခံသည့် ပထမဆုံးဘရောက်ဆာဗားရှင်းကို သတ်မှတ်ပေးသည်။
Property | |||||
---|---|---|---|---|---|
textBaseline | Yes | 9.0 | Yes | Yes | Yes |
မှတ်ချက်- textBaseline ပိုင်ဆိုင်မှုသည် အထူးသဖြင့် "hanging" သို့မဟုတ် "ideographic" ကိုအသုံးပြုသည့်အခါ မတူညီသောဘရောက်ဆာများတွင် ကွဲပြားစွာအလုပ်လုပ်ပါသည်။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
TextBaseline ပိုင်ဆိုင်မှုသည် စာသားဆွဲရာတွင် အသုံးပြုသည့် လက်ရှိစာသားအခြေခံလိုင်းကို သတ်မှတ်ပေးသည် သို့မဟုတ် ပြန်ပေးသည်။
အောက်ဖော်ပြပါပုံဥပမာသည် textBaseline ရည်ညွှန်းချက်ဖြင့် ပံ့ပိုးထားသော အမျိုးမျိုးသောအခြေခံအချက်များကို သရုပ်ပြသည်-
မှတ်ချက်- fillText () နှင့် strokeText() နည်းလမ်းများသည် ကင်းဗတ်ပေါ်တွင် စာသားကို နေရာချထားသည့်အခါ သတ်မှတ်ထားသော textBaseline တန်ဖိုးကို အသုံးပြုပါမည်။
မူလတန်ဖိုး: | အက္ခရာစဉ် |
---|---|
JavaScript syntax- | စကား စပ် .textBaseline="အက္ခရာ|ထိပ်|တွဲ|အလယ်|သရုပ်ဖော်ပုံ|အောက်ခြေ"; |
အိမ်ခြံမြေတန်ဖိုးများ
Values | Description | Play it |
---|---|---|
alphabetic | Default. The text baseline is the normal alphabetic baseline | |
top | The text baseline is the top of the em square | |
hanging | The text baseline is the hanging baseline | |
middle | The text baseline is the middle of the em square | |
ideographic | The text baseline is the ideographic baseline | |
bottom | The text baseline is the bottom of the bounding box |
❮ HTML Canvas အကိုးအကား