I want to make up to 100 different and distinguishable random colors in my winforms project. The method will executes in a loop as my desired times. I know how to make just random colors, but is there any Idea how to make different and distinguishable random colors, that a user by looking it could easily see the differences and recognize them?
My code:
private System.Drawing.Color RandomColor()
{
Random rand = new Random();
int max = byte.MaxValue + 1; // 256
int r = rand.Next(max);
int g = rand.Next(max);
int b = rand.Next(max);
System.Drawing.Color color = System.Drawing.Color.FromArgb(r, g, b);
return color;
}
for(int i=0; i<100 or lesss; i++)
{
var randomColor = RandomColor();
//I use randomColor to draw a thin line on my form.
}
Aucun commentaire:
Enregistrer un commentaire