I have created a Javascript object named [name-rgb]. Your basics:
namedColors = { AliceBlue: [240, 248, 255], AntiqueWhite: [250, 235, 215], ...
Object. But I realized that I should be able to input a name string, say "AliceBlue", and have JavaScript find some sort of RGB representation of it (hex would work too). I know there are at least 140 hidden named colors in browsers, but I can't seem to find them.
Is there a CSS or "style=..." technique that allows me to find the RGB representation of a color name?
This is the solution I finally came up with. I realize that there are two types of colors: css strings and webgl type arrays (usually 4 floats or integers, depending on the situation).
Forget it, let the browser handle it: create a 1x1 canvas, fill it with any string color, get the pixels, and deconstruct it into an rgba array. Below are two utilities for creating 1x1 2d canvas ctx.
What I like about it is that the browser speaks for itself. Any legal string will work fine. The only downside is that if the string is illegal, you'll get black, so some checking needs to be done. The error checking isn't great, but I don't need it in my usage.
Utility functions:
The simplest JavaScript function: