Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #14652

Re: Detect user graphics card?

Message-ID <4454122.7EdHYbU6jS@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2012-06-25 05:14 +0200
Subject Re: Detect user graphics card?
Newsgroups comp.lang.javascript
References <e297bfd5-2f14-4f87-b6b4-92dc73c8b83d@r3g2000yqh.googlegroups.com> <js719u$7j2$1@dont-email.me>
Followup-To comp.lang.javascript

Followups directed to: comp.lang.javascript

Show all headers | View raw


Gregor Kofler wrote:

> Am 2012-06-24 13:31, justaguy meinte:
>> I have an iframe which uses the #BDD3FF background color to make it
>> more appealing, however, recently I realize on some low end laptops
>> this background color looks deep blue (bad), so, I wonder if there's
>> a way to detect the user's graphics card via a web browser (since it's
>> a web app) so as to provide appropriate background color.
> 
> No. And it wouldn't help, since the user could still use a custom color
> profile or have changed the default settings of his display.

There is the host object referred to by the host-defined `screen' property 
of the Global Object or window host object, which has a `pixelDepth' 
property in more recent DOM implementations to indicate the number of bits 
available for the color value of a pixel.  It can be used to work around 
this issue, but it may not be reliable:

<https://developer.mozilla.org/en/DOM/window.screen.pixelDepth>

The best solution – if the CD allows it – is to use what I call True Web-
safe Colors (`#000', `#003', …, `#00f`, …, `#030`, …, `#03f`, …, `#fff').  
See also: <http://www.w3.org/TR/css3-color/#numerical>.

JSX:color.js [1] defines jsx.dom.css.Color.prototype.getWebSafe() which 
computes the nearest Web-safe color for a given color.  It can be used as 
follows:

  /* Include a `script' element for color.js and dependencies */

  var myColor = new jsx.dom.css.Color("#BDD3FF");
  var mySafeColor = myColor.getWebSafe();
  console.log(mySafeColor);

jsx.dom.css.Color instances inherit a toString() method (equivalent to the 
toRGBAString() method) that returns the CSS3 RGBA notation for the color 
value.  Therefore, references can be used verbatim in CSS scripting:

  element.style.color = mySafeColor;  

However, they also inherit toHex(), toRGBString(), and toJSON() methods, for 
less advanced CSS implementations and other purposes.  
jsx.dom.css.Color.prototype.toHex() returns the short notation if all quads 
of each color value component are equal to the other quad (as recommended by 
the CSS Specifications); it requires jsx.string.leadingZero() which we have 
discussed yesterday.


PointedEars
___________
[1] 
<http://PointedEars.de/websvn/filedetails.php?repname=JSX&path=%2Ftrunk%2Fdom%2Fcss%2Fcolor.js>
-- 
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
  -- Richard Cornford, cljs, <cife6q$253$1$8300dec7@news.demon.co.uk> (2004)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Detect user graphics card? justaguy <lichunshen84@gmail.com> - 2012-06-24 04:31 -0700
  Re: Detect user graphics card? Gregor Kofler <usenet@gregorkofler.com> - 2012-06-24 14:30 +0200
    Re: Detect user graphics card? justaguy <lichunshen84@gmail.com> - 2012-06-24 07:43 -0700
    Re: Detect user graphics card? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-25 05:14 +0200
      Re: Detect user graphics card? justaguy <lichunshen84@gmail.com> - 2012-06-24 21:01 -0700
      Re: Detect user graphics card? Stefan Weiss <krewecherl@gmail.com> - 2012-06-26 13:27 +0200
        Re: Detect user graphics card? justaguy <lichunshen84@gmail.com> - 2012-06-26 12:54 -0700
        Re: Detect user graphics card? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-26 22:38 +0200
          Re: Detect user graphics card? Stefan Weiss <krewecherl@gmail.com> - 2012-06-27 01:05 +0200
            Re: Detect user graphics card? Scott Sauyet <scott.sauyet@gmail.com> - 2012-06-27 07:07 -0700
          Re: Detect user graphics card? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-06-29 16:41 -0700
            Compute web-safe colors (was: Detect user graphics card?) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-30 10:40 +0200
        Re: Detect user graphics card? Dr J R Stockton <reply1226@merlyn.demon.co.uk.not.invalid> - 2012-06-27 19:44 +0100
  Re: Detect user graphics card? Arno Welzel <usenet@arnowelzel.de> - 2012-06-27 17:57 +0200

csiph-web