[Pharo-project] Proposal: adding 261 named colors
bschwab at anest.ufl.edu
Sat Oct 23 17:46:57 EDT 2010
I don't like the idea of instantiating red if the name is not recognized. Since you don't have selectors (900+ might be a bit much), the compiler/Shout won't catch mistakes, and it will be an ongoing source of silent failures.
From: pharo-project-bounces at lists.gforge.inria.fr [pharo-project-bounces at lists.gforge.inria.fr] On Behalf Of Johan Fabry [jfabry at dcc.uchile.cl]
Sent: Saturday, October 23, 2010 5:29 PM
To: Pharo Development
Subject: [Pharo-project] Proposal: adding 261 named colors
in the work of AspectMaps I was a bit let down by the named colors Pharo provides (Color red et cetera). Now I am happy to say that thanks to the XKCD color survey I was able to improve on this. I can now use 261 named colors thanks to a XKCDColor class, and I'd like to share the code, ideally to be included into Pharo. The code is available in bugreport http://code.google.com/p/pharo/issues/detail?id=3148
Here is the class comment fo XKCDColor:
A color named according to the XKCD color survey, as published in http://blog.xkcd.com/2010/05/03/color-survey-results/ ("Over five million colors were named across 222,500 user sessions.")
Of the full table of 954 colors that is published only those were selected that did not have a space in their name, ignoring e.g. electric lime, nasty green, macaroni and cheese, pinkish tan, but also light light blue, strong blue. This results in a table of 261 named colors, but with duplicates such as ochre and ocre. These were left in since as they are common misspellings it is more convenient for the user.
To instantiate: XCDColor named: aString where aString is one of the 261 named colors. If the name is not known, the color red is instantiated. Instances of XKCDColor know their XKCD color name, returned by the name accessor.
Thanks to Randall Monroe of http://xkcd.com for providing the data.
And here is a picture of all the colors (Generated with Mondrian :-) )
More information about the Pharo-dev