HTML canvas ဖန်တီးRadialGradient() နည်းလမ်း
ဥပမာ
ထောင့်မှန်စတုဂံတစ်ခုဆွဲပြီး အချင်း/အဝိုင်း gradient ဖြင့်ဖြည့်ပါ-
JavaScript-
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var grd = ctx.createRadialGradient(75, 50, 5, 90, 60, 100);
grd.addColorStop(0, "red");
grd.addColorStop(1, "white");
// Fill with gradient
ctx.fillStyle = grd;
ctx.fillRect(10, 10, 150, 100);
Browser ပံ့ပိုးမှု
ဇယားရှိ နံပါတ်များသည် နည်းလမ်းကို အပြည့်အဝထောက်ခံသည့် ပထမဆုံးဘရောက်ဆာဗားရှင်းကို သတ်မှတ်ပေးသည်။
Method | |||||
---|---|---|---|---|---|
createRadialGradient() | Yes | 9.0 | Yes | Yes | Yes |
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
createRadialGradient() method သည် radial/circular gradient object တစ်ခုကို ဖန်တီးသည်။
gradient ကို ထောင့်မှန်စတုဂံများ၊ စက်ဝိုင်းများ၊ မျဉ်းကြောင်းများ၊ စာသား စသည်တို့ကို ဖြည့်စွက်ရန် အသုံးပြုနိုင်သည်။
အကြံပြုချက်- ဤအရာအား strokeStyle သို့မဟုတ် fillStyle ဂုဏ်သတ္တိများအတွက် တန်ဖိုးအဖြစ် အသုံးပြုပါ။
အကြံပြုချက်- မတူညီသောအရောင်များကို သတ်မှတ်ရန် addColorStop() နည်းလမ်းကို အသုံးပြု ပါ၊ နှင့် gradient အရာဝတ္တုတွင် အရောင်များကို နေရာချရမည့်နေရာ။
JavaScript syntax- | စကား စပ် .createRadialGradient( x0,y0,r0,x1,y1,r1 ); |
---|
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
x0 | The x-coordinate of the starting circle of the gradient |
y0 | The y-coordinate of the starting circle of the gradient |
r0 | The radius of the starting circle |
x1 | The x-coordinate of the ending circle of the gradient |
y1 | The y-coordinate of the ending circle of the gradient |
r1 | The radius of the ending circle |
❮ HTML Canvas အကိုးအကား