direction Property
direction property သည် fillText method သို့မဟုတ်
strokeText method အသုံးပြု၍ ရေးဆွဲထားသော စာသား၏ ဦးတည်ရာကို
သတ်မှတ်ပေးသည်။ ဖြစ်နိုင်သော တန်ဖိုးများထဲမှ တစ်ခုကို လက်ခံသည်- ltr (ဘယ်မှ ညာ),
rtl (ညာမှ ဘယ်), inherit (အမွေဆက်ခံသည်)။ ပုံသေအားဖြင့် တန်ဖိုးသည် inherit ဖြစ်သည်
(အာရပ်ဘာသာစကားနှင့် ဟီဘရူးဘာသာစကားအတွက် rtl ဖြစ်မည်၊ ထိုဘာသာစကားများတွင် ညာမှဘယ်သို့ ရေးသားသောကြောင့်၊
ကျန်သောဘာသာစကားအားလုံးအတွက် - ltr ဖြစ်သည်)။
Syntax
context.direction = ltr or rtl or inherit;
ဥပမာ
စာသားတစ်ခုကို ရေးပြီး direction property ကို အသုံးပြု၍
မတူညီသော ဦးတည်ရာများကို သတ်မှတ်ကြည့်ရအောင်-
<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
ctx.font = "16px arial";
ctx.fillText("text1", 150, 50);
ctx.direction = "rtl";
ctx.fillText("text1", 50, 120);
:
ဆက်လက် ကြည့်ရှုရန်
-
textBaselineproperty,
အလျားလိုက် စာသားညှိခြင်း -
textAlignproperty,
ဒေါင်လိုက် စာသားညှိခြင်း