private void Save(string colorName, System.Drawing.Color color) { float hue = color.GetHue(); float brightness = color.GetBrightness(); File.AppendAllText(@"c:\users\brush\desktop\" + colorName + ".csv", string.Format("{0},{1},{2},{3},{4}\r\n", color.R, color.G, color.B, hue, brightness)); }
internal static ColorHSL FromSystemDrawingColor(System.Drawing.Color color) { ColorHSL rv = new ColorHSL { Hue = color.GetHue() / 360.0, Saturation = color.GetSaturation(), Lightness = color.GetBrightness() }; return rv; }
private bool isColorClose(System.Drawing.Color color1, System.Drawing.Color color2, int tolerance) { if (Math.Abs(color1.GetHue() - color2.GetHue()) % (360 - tolerance) < tolerance) if (Math.Abs(color1.GetSaturation() - color2.GetSaturation()) % (360 - tolerance) < tolerance) if (Math.Abs(color1.GetBrightness() - color2.GetBrightness()) % (360 - tolerance) < tolerance) return true; return false; }