Skip to content

Instantly share code, notes, and snippets.

@sakapon
Created March 29, 2015 08:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakapon/85029a4bf8551820fd15 to your computer and use it in GitHub Desktop.
Save sakapon/85029a4bf8551820fd15 to your computer and use it in GitHub Desktop.
AzureMLSample / ColorDataConsole
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
namespace ColorDataConsole
{
static class Program
{
static void Main(string[] args)
{
var columnNames = "RGB,Name,R,G,B,Hue,Saturation,Brightness";
var colorData = typeof(Color).GetProperties(BindingFlags.Public | BindingFlags.Static)
.Where(p => p.PropertyType == typeof(Color))
.Select(p => (Color)p.GetValue(null))
.Where(c => c.A == 255) // Exclude Transparent.
.Select(c => string.Join(",", string.Format("#{0:X2}{1:X2}{2:X2}", c.R, c.G, c.B), c.Name, c.R, c.G, c.B, c.GetHue().ToString("N6"), c.GetSaturation().ToString("N6"), c.GetBrightness().ToString("N6")));
File.WriteAllLines("ColorData.csv", new[] { columnNames }.Concat(colorData));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment