Re:All of the available CSS color names
by simonsarris on Saturday July 21, 2012 @08:38PM
(#4276120)
Well I found at least one good use for them.
I'm writing a book and I use nothing but the CSS color names in all of the examples. I think it makes the code snippets easier to parse and visualize as a human when you're reading through the text. For example:
// Create a vertical gradient going from the top of the canvas to the bottom
var gradient = ctx.createLinearGradient(0, 0, 0, can.height);
gradient.addColorStop(0, 'Black');
gradient.addColorStop(0.15, 'Black');
gradient.addColorStop(0.2, 'DarkSeaGreen');
gradient.addColorStop(0.4, 'DarkSeaGreen');
gradient.addColorStop(0.7, 'Goldenrod');
gradient.addColorStop(0.8, 'DarkOrange');
gradient.addColorStop(1, 'GhostWhite');
Then, as I spend a paragraph talking about color stops, I can refer to real color names and not #00000, #8FBC8F, etc. I think the humans reading the text will appreciate it, but we'll see!If you’re referring to these by strings, wouldn’t you be just as well off spending a few lines of code somewhere above setting up some variables for hex colors? This seems like a pretty trivial kind of advantage.
Re:All of the available CSS color names
by primatology on Saturday July 21, 2012 @11:20PM
(#4276348)
What if he were writing straight CSS, though? No possibility for variables there. (Not yet, at least.)
Re:All of the available CSS color names
by lazerwalker on Saturday July 21, 2012 @08:42PM
(#4276125)
This is especially true when you're using a CSS preprocessor like LESS or SASS. It's easier to remember a name like "skyBlue" or "tomato" than a hex value, sure, but being able to declare your own variable names is just as good (if not better).
Gotta love dodgerBlue, aqua, fuschia and teal for miscellaneous debugging and demoing.
I use the names regularly. I use colors sparingly for fuzzy (but consistent) connotations/highlights. The named subset is good enough for that purpose, and easier to remember than every shade that might be cooked up in another tool.
After all, the remaining 145 colors only account for 0.00086% of colors a designer might pick in Photoshop.
It's like winning the lottery :)