Re: Color names and the 10 elementary colors?
- To: mathgroup at smc.vnet.net
- Subject: [mg67603] Re: Color names and the 10 elementary colors?
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Sat, 1 Jul 2006 05:13:41 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 6/30/06 at 4:13 AM, siegman at stanford.edu (AES) wrote: >When I recently inquired about using the names of Mathematica colors >("CinnabarGreen", etc.) as label strings in a series of test plots, >several responses proposed that I needed to manually input the names >in quotes. Brian Higgins suggested, however, a terse but somewhat >arcane way to get color names as strings together with the >corresponding RGB values with the Input line >allColorNames = ({#1, ToColor[ ToExpression[#1], RGBColor]}&) /@ >AllColors; >so that the Input >allColorNames[[4]] >produces the Output >{ Apricot, RGBColor[1., 0.340007, 0.129994] } >(although his Output showed quotes around "Apricot" and mine >doesn't.) Most likely, the difference is simply the output formating. If you select your output and convert it to InputForm, I am sure you will see the quotes. That is probably what Brian did when posting. >Since my objective was to test all varieties of Green, I added to >this a more crudely programmed statement to generate a list of all >the green color names and color values, viz. > allGreens={ }; > Do[ > If[ StringMatchQ[ allColorNames[[k,1]], "*Green*" ], > AppendTo[ allGreens, allColorNames[[k]] ] ], > {k, 1, Length[ allColorNames ]} ]; IMO, simpler and more efficient is Cases[allColorNames, {_?(StringPosition[#,"Green"]!={}&),__}] But this doesn't address your observation below >This works fine -- until you notice that just plain "Green" itself >is not in the resulting list. In fact, Green (along with Red, Blue, >Brown, Orange, and 4 or 5 other "elementary colors") is not in >AllColors. >I believe in earlier versions of Mathematica one had to use >Graphics`Colors` to access even these elementary colors, and so they >were presumably once included in AllColors (?); and I think I've >learned somewhere that 10 or so of these elementary colors are now >included within "plain Mathematica" and no long require calling the >Graphics`Colors` package. But: >1) I'd sure like to understand the logic of not continuing to use >these colors in AllColors nonetheless. Removing them seems a >confusing and less than helpful choice to me at any rate. And, Someone from Wolfram would have to comment here. I can only speculate. I would speculate this was done for a small number of common colors to avoid the need to load the package. That is these colors would be used far more often than others even when the other functions in the older package are not needed. >2) Where -- or more important, how -- can the nonexpert user get at >the list of these elementary colors? >As a challenge, try invoking online Help on "Color" or "Colors" or >any one of the elementary color names, and see if, using no more >than 5 subsequent mouse clicks within the Help screen, no typing, >and no pre-existing expert knowledge, just "common sense", you can >find your way to the list of those colors. I don't quite understand the difficulty here. If I bring up the help browser and start typing green into the search window, I am immediately taken to the definition of Green and I see a list of other colors in the window above. From the definition (notably the lack of any reference to a package) it seems clear these are built-in colors. And if you insist on not typing anything (a rather overly restrictive requirement IMHO) when you bring up the Help Browser, the first category Built-In Functions should be highlighted. Scroll down and select Graphics and Sound. Scroll down in the next panel and select Graphics Primitives. Finally scroll down in that list and select Colors. There you will find the same list of colors I mentioned above. And given this started by selecting Built-In Functions it should be very clear this is a list of built-in colors. Another approach to getting this same information using the function SymbolsInContext described in Roman Madeder's book The Mathematica Programmer would be: In[41]:= Select[SymbolsInContext@"System`",Head@# == RGBColor || Head@# == GrayLevel&] Out[41]= {Black,Blue,Brown,Cyan,Gray,Green,Magenta,Orange,Pink,Purple,Red,White,Yellow} Which is the same list of colors you will find using the Help Browser as described above. Arguably, this alternative cannot be claimed to be a non-expert method since the function SymbolsInContext is neither built-in nor a part of a standard package and uses reasonably sophisticated methods to achieve its results. But it is a very handy function for getting information about any context. And once added to your toolbox, it is very simple to use. -- To reply via email subtract one hundred and four