When generating graphs and showing different sets of data it usually a good idea to difference the sets by color. So one line is red and the next is green and so on. The pro
In case someone needs to generate random medium to high dark color for white foreground in C#, here is the code.
[DllImport("shlwapi.dll")]
public static extern int ColorHLSToRGB(int H, int L, int S);
public static string GetRandomDarkColor()
{
int h = 0, s = 0, l = 0;
h = (RandomObject.Next(1, 2) % 2 == 0) ? RandomObject.Next(0, 180) : iApp.RandomObject.Next(181, 360);
s = RandomObject.Next(90, 160);
l = RandomObject.Next(80, 130);
return System.Drawing.ColorTranslator.FromWin32(ColorHLSToRGB(h, l, s)).ToHex();
}
private static string ToHex(this System.Drawing.Color c)
{
return "#" + c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2");
}
You can replace RandomObject with your own Random class object.