void SetRandomBrushes(TestShape s, Random r) { int i = r.Next(0, 10); if (_strokeBrushes[i] == null) { Color color = Color.FromRgb((byte)r.Next(0, 255), (byte)r.Next(0, 255), (byte)r.Next(0, 255)); HlsColor hls = new HlsColor(color); Color c1 = hls.Darker(0.25f); Color c2 = hls.Lighter(0.25f); Brush fill = new LinearGradientBrush(Color.FromArgb(0x80, c1.R, c1.G, c1.B), Color.FromArgb(0x80, color.R, color.G, color.B), 45); Brush stroke = new LinearGradientBrush(Color.FromArgb(0x80, color.R, color.G, color.B), Color.FromArgb(0x80, c2.R, c2.G, c2.B), 45); _colorNames[i] = "#" + color.R.ToString("X2", CultureInfo.InvariantCulture) + color.G.ToString("X2", CultureInfo.InvariantCulture) + color.B.ToString("X2", CultureInfo.InvariantCulture); _strokeBrushes[i] = stroke; _fillBrushes[i] = fill; } s.Label = _colorNames[i]; s.Stroke = _strokeBrushes[i]; s.Fill = _fillBrushes[i]; }
public override bool Equals(object o) { if (!(o is HlsColor)) { return(false); } HlsColor c = (HlsColor)o; return(hue == c.hue && saturation == c.saturation && luminosity == c.luminosity); }