HTML canvas strokeText() နည်းလမ်း
ဥပမာ
"Hello world!" ဟုရေးပါ။ နှင့် "အပြုံးကြီး!" strokeText():
JavaScript-
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.font = "20px Georgia";
ctx.strokeText("Hello World!", 10, 50);
ctx.font = "30px Verdana";
// Create gradient
var gradient = ctx.createLinearGradient(0, 0, c.width, 0);
gradient.addColorStop("0", "magenta");
gradient.addColorStop("0.5", "blue");
gradient.addColorStop("1.0", "red");
// Fill with gradient
ctx.strokeStyle = gradient;
ctx.strokeText("Big smile!", 10, 90);
Browser ပံ့ပိုးမှု
ဇယားရှိ နံပါတ်များသည် နည်းလမ်းကို အပြည့်အဝထောက်ခံသည့် ပထမဆုံးဘရောက်ဆာဗားရှင်းကို သတ်မှတ်ပေးသည်။
Method | |||||
---|---|---|---|---|---|
strokeText() | Yes | 9.0 | Yes | Yes | Yes |
မှတ်ချက်- maxWidth ကန့်သတ်ဘောင်ကို Safari 5.1 နှင့် အစောပိုင်းဗားရှင်းများတွင် ပံ့ပိုးမထားပါ။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
strokeText() နည်းလမ်းသည် ကင်းဗတ်ပေါ်တွင် စာသား (ဖြည့်စွက်ခြင်းမရှိဘဲ) ဆွဲသည်။ စာသား၏ မူရင်းအရောင်မှာ အနက်ရောင်ဖြစ်သည်။
အကြံပြုချက်- ဖောင့်နှင့် ဖောင့်အရွယ်အစားကို သတ်မှတ်ရန် ဖောင့်ပိုင်ဆိုင်မှုကို အသုံးပြုပြီး စာသားကို အခြား အရောင်/အရောင်ပြောင်းရန် strokeStyle ပိုင်ဆိုင်မှုကို အသုံးပြုပါ။
JavaScript syntax- | စကား စပ် .strokeText( စာသား၊x၊y၊maxWidth ); |
---|
ကန့်သတ်တန်ဖိုးများ
Parameter | Description | Play it |
---|---|---|
text | Specifies the text that will be written on the canvas | |
x | The x coordinate where to start painting the text (relative to the canvas) | |
y | The y coordinate where to start painting the text (relative to the canvas) | |
maxWidth | Optional. The maximum allowed width of the text, in pixels |
❮ HTML Canvas အကိုးအကား