Using the XKCD color survey for something useful

4. mai 2010

Update:

I just installed Moonlight Preview 7 in Ubuntu and the color picker almost works. :-) You can browse the colors and select some, but searching doesn't work properly.

 

XKCD just published the results of a survey where people would try to name a bunch of colors. The result, published here, is fun to read and for me it was really inspiring.

One of the data sets that were published was a list of popular color names along with their equivalent HTML color values. Since playing with colors is fun, I decided to take this list and turn it into .Net color constants. In .Net you have lots of defined color constants like Color.Blue and Color.Cornsilk, but even the creative ones are not as interesting as the colors Vomit (brown/green), Dark Periwinkle (a bluish color), Battleship Grey (grey like a battleship) or BabyShitBrown (don't ask). 

Interesting colors

The result is the XKCDColors class. I made two versions, one that returns System.Drawing.Color values and one that returns System.Windows.Media.Color values. The first is used with the System.Drawing namespace and WinForms applications, while the second is used for WPF and Silverlight applications.

To visualize the colors I created a tiny Silverlight 4 application that lists them all. Open it here.

And if you want to download the color files you can find them here:

XKCDColors.zip (20.47 kb)

 

Update:

After a suggestion from Randall Munroe himself I added a search box to the application. Now you can enter the hex notation for a color and get out the closest named color.

kick it on DotNetKicks.com

.NET, Silverlight, WPF , ,