textBaseline ဂုဏ်သတ္တိ
textBaseline ဂုဏ်သတ္တိသည်
fillText သို့မဟုတ်
strokeText method များဖြင့်
ရေးဆွဲထားသော စာသား၏ ဒေါင်လိုက် ညှိခြင်းကို သတ်မှတ်ပေးသည်။
ဖြစ်နိုင်သော တန်ဖိုးတစ်ခုခုကို လက်ခံသည်။ top,
hanging, middle, alphabetic (ပုံသေ),
ideographic, bottom (တန်ဖိုးများကို နားလည်ရန်
www.w3schools.com/tags/canvas_textbaseline.asp ကို ကြည့်ပါ။)
Syntax
context.textBaseline = value;
ဥပမာ
စာသားအား အပေါ်ဆုံး မျဉ်းကြောင်းနှင့် ဒေါင်လိုက် ညှိရန် သတ်မှတ်ကြပါစို့။
<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
ctx.strokeStyle = 'red';
ctx.moveTo(0, 100);
ctx.lineTo(400, 100);
ctx.stroke();
ctx.font="14px Arial";
ctx.textBaseline = 'top';
ctx.fillText('text', 80, 100);
:
ဥပမာ
ယခု စာသားအား အောက်ဆုံး မျဉ်းကြောင်းနှင့် ဒေါင်လိုက် ညှိရန် သတ်မှတ်ကြပါစို့။
<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
ctx.strokeStyle = 'red';
ctx.moveTo(0, 100);
ctx.lineTo(400, 100);
ctx.stroke();
ctx.font="14px Arial";
ctx.textBaseline="bottom";
ctx.fillText('text', 80, 100);
: