using System; using System.Drawing; /* * Helper class for color calculations. */ static class ColorUtil { static public float GetLuminance(Color c) { return ((c.R * 0.2126f) + (c.G * 0.7152f) + (c.B * 0.0722f)) / 255.0f; } static public string ToHex(Color c) { return "#" + c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2"); } static public Color TimeToColor(DateTime time) { int r, g, b; r = time.Hour * (255 / 24); g = time.Minute * (255 / 60); b = time.Second * (255 / 60); return Color.FromArgb(r, g, b); } }