/// <summary> /// Creates color from HSB color space with random hue and saturation and brighness equal to 1. /// </summary> /// <returns></returns> public static Color CreateColorWithRandomHue() { double hue = random.NextDouble() * 360; HsbColor hsbColor = new HsbColor(hue, 1, 1); return(hsbColor.ToArgbColor()); }
public static SolidColorBrush ChangeSaturation(this SolidColorBrush brush, double saturationFactor) { Color color = brush.Color; HsbColor hsbColor = HsbColor.FromArgbColor(color); hsbColor.Saturation *= saturationFactor; if (hsbColor.Saturation > 1.0) { hsbColor.Saturation = 1.0; } SolidColorBrush result = new SolidColorBrush(hsbColor.ToArgbColor()); return(result); }
public static SolidColorBrush ChangeLightness(this SolidColorBrush brush, double lightnessFactor) { Color color = brush.Color; HsbColor hsbColor = HsbColor.FromArgbColor(color); hsbColor.Brightness *= lightnessFactor; if (hsbColor.Brightness > 1.0) { hsbColor.Brightness = 1.0; } SolidColorBrush result = new SolidColorBrush(hsbColor.ToArgbColor()); return(result); }