Window screen.colorDepth
ဥပမာ
အရောင် palette ၏ အတိမ်အနက်ကို ရယူပါ
let depth = screen.colorDepth;
အောက်တွင် နောက်ထပ် "စမ်းသုံးကြည့်ပါ" ဥပမာများ။
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
colorDepth
ပိုင်ဆိုင်မှုသည် မျက်နှာပြင်၏ အရောင်အတိမ်အနက်ကို ပြန်ပေးသည် ။
ပိုင်ဆိုင်မှုသည် pixel တစ်ခုလျှင် အ colorDepth
တိမ်အနက်ကို bits ဖြင့် ပြန်ပေးသည်။
colorDepth
ပိုင်ဆိုင်မှုသည် ဖတ်ရန်သာဖြစ်သည် ။
အထားအသို
screen.colorDepth
တန်ဖိုးကို ပြန်ပေးသည်။
ရိုက်ပါ။ | ဖော်ပြချက် |
နံပါတ်တစ်ခု | မျက်နှာပြင်၏ အရောင်အသွေး အပိုင်း၏ အတိမ်အနက်သည် pixel တစ်ခုလျှင် bits ဖြင့်- 1၊ 4၊ 8၊ 15၊ 16၊ 24၊ 32 သို့မဟုတ် 48။ |
နောက်ထပ် ဥပမာများ
8 ဘစ်စခရင်များအတွက် နောက်ခံအရောင်ကို ပြသပါ (ခေတ်မီအရောင်ကို မပံ့ပိုးသော အဆိုပါ 8 ဘစ်စခရင်များကို ရှောင်ရှားရန်၊ ထိုအစား ရုပ်ဆိုးသော အစားထိုးအရောင်ကို အသုံးပြုသည်)
if (screen.colorDepth <= 8)
//simple blue background color for 8 bit screens
document.body.style.background = "#0000FF"
else
//fancy blue background color for modern screens
document.body.style.background = "#87CEFA"
မျက်နှာပြင် ဂုဏ်သတ္တိအားလုံး-
let text = "Total width/height: " + screen.width + "*" + screen.height + "<br>" +
"Available width/height: " + screen.availWidth + "*" + screen.availHeight + "<br>" +
"Color depth: " + screen.colorDepth + "<br>" +
"Color resolution: " + screen.pixelDepth;
Browser ပံ့ပိုးမှု
screen.colorDepth
ဘရောက်ဆာအားလုံးတွင် ထောက်ခံသည်-
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |