Screen colorDepth Property
Clash Royale CLAN TAG#URR8PPP
<!--
main_leaderboard, all: [728,90][970,90][320,50][468,60]-->
Screen colorDepth Property
❮ Screen Object
Example
Get the bit depth of the color palette:
var x = "Color Depth: " + screen.colorDepth;
<!--
The result of x will be:
document.write("Color Depth: " + screen.colorDepth);
-->Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The colorDepth property returns the bit depth of the color palette for
displaying images (in bits per pixel).
Browser Support
Property | |||||
---|---|---|---|---|---|
colorDepth | Yes | Yes | Yes | Yes | Yes |
Syntax
screen.colorDepth
<!--
mid_content, all: [300,250][336,280][728,90][970,250][970,90][320,50][468,60]-->
Technical Details
Return Value: | A Number, representing the bit depth of the color palette for displaying images, in bits per pixel. Possible values:
|
---|
More Examples
Example
Display an alternate background color for 8 bit screens (to avoid that 8 bit
screens, which do not support the modern color, uses an ugly substitute color
instead):
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"
Try it Yourself »
Example
All screen properties in one example:
var txt = "";
txt += "<p>Total width/height: " + screen.width + "*" + screen.height + "</p>";
txt += "<p>Available width/height: " + screen.availWidth + "*" + screen.availHeight + "</p>";
txt += "<p>Color depth: " + screen.colorDepth + "</p>";
txt += "<p>Color resolution: " + screen.pixelDepth + "</p>";
Try it Yourself »
❮ Screen Object