- From: Daniel Buchner <daniel@mozilla.com>
- Date: Wed, 22 Sep 2010 14:49:53 -0700
Hello whatwg! Many developers, js libraries, and frameworks interact with colors in a variety ways in their pages and apps. One common action they perform in many of these interactions is to convert colors between RGB and HEX. A fair amount of js is needed to do this type of thing, see the following examples: converting hex to rgb in js<http://www.google.com/search?q=convert+hex+to+rgb+javascript&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:unofficial&client=firefox-a#sclient=psy&num=10&hl=en&client=firefox-a&hs=pqr&rls=org.mozilla%3Aen-US%3Aunofficial&q=javascript+convert+hex+to+rgb&aq=f&aqi=g1&aql=&oq=javascript+convert+hex+to+rgb&gs_rfai=&pbx=1&fp=7b3e9e0669ddb0a1> I propose that we provide a way for developers to get all color equivalents of a valid color string - red, #ff0, rgb(255, 0, 0). Currently to derive RGB or HEX values from a named css color there is even more craziness required. You must create a dummy element, inject it into the DOM, set styles, get the computed styles, and finally perform various validity checks to ensure the correct output: Here is an implementation I put together to convert named colors to RGB or HEX: named colors to hex and rgb<http://people.mozilla.com/%7Edbuchner/demos/web/colordiscovery/index.html>- try typing in 'red', 'magenta', etc. The very fact that the colors can be converted via the implementation I use, indicates the look-up is already present in browsers, there is just nothing exposed to developers to take advantage of it. Thoughts? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100922/9938a079/attachment.htm>
Received on Wednesday, 22 September 2010 14:49:53 UTC