HTML canvas createPattern() နည်းလမ်း
အသုံးပြုရန်ပုံ-
ဥပမာ
ပုံတစ်ပုံကို အလျားလိုက်ရော ဒေါင်လိုက်ရော ပြန်လုပ်ပါ-
JavaScript-
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var img = document.getElementById("lamp");
var pat = ctx.createPattern(img, "repeat");
ctx.rect(0, 0, 150, 100);
ctx.fillStyle = pat;
ctx.fill();
Browser ပံ့ပိုးမှု
ဇယားရှိ နံပါတ်များသည် နည်းလမ်းကို အပြည့်အဝထောက်ခံသည့် ပထမဆုံးဘရောက်ဆာဗားရှင်းကို သတ်မှတ်ပေးသည်။
Method | |||||
---|---|---|---|---|---|
createPattern() | Yes | 9.0 | Yes | Yes | Yes |
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
createPattern() method သည် သတ်မှတ်ထားသော ဦးတည်ချက်တွင် သတ်မှတ်ထားသော element ကို ပြန်လုပ်သည်။
ဒြပ်စင်သည် ရုပ်ပုံ၊ ဗီဒီယို သို့မဟုတ် အခြား <canvas> ဒြပ်စင် ဖြစ်နိုင်သည်။
ထပ်ခါတလဲလဲ ဒြပ်စင်ကို ထောင့်မှန်စတုဂံများ၊ စက်ဝိုင်းများ၊ မျဉ်းကြောင်းများ စသည်တို့ကို ဆွဲရန်/ဖြည့်စွက်ရန် အသုံးပြုနိုင်သည်။
JavaScript syntax- | context .createPattern( ပုံ , "repeat|repeat-x|repeat-y|no-repeat"); |
---|
ကန့်သတ်တန်ဖိုးများ
Parameter | Description | Play it |
---|---|---|
image | Specifies the image, canvas, or video element of the pattern to use | |
repeat | Default. The pattern repeats both horizontally and vertically | |
repeat-x | The pattern repeats only horizontally | |
repeat-y | The pattern repeats only vertically | |
no-repeat | The pattern will be displayed only once (no repeat) |
❮ HTML Canvas အကိုးအကား