Answer the question
In order to leave comments, you need to log in
How to generate colors dissimilar to each other?
In my game, balls of different colors are generated on the field.
The color of each ball is set using a simple function:
Color RandomColor()
{
float r = (float)mRandom.GetRandomNumber(0, 1f);
float g = (float)mRandom.GetRandomNumber(0, 1f);
float b = (float)mRandom.GetRandomNumber(0, 1f);
float a = (float)mRandom.GetRandomNumber(0.7, 1);
return new Color(r, g, b, a);
}
Answer the question
In order to leave comments, you need to log in
1) The most primitive - color presets. And choose from an array of presets.
2) Try using HSL instead of RGB. Firstly, it is easier to detect "similar" colors in it, secondly, it is easier to get more different colors - just generate the H parameter with some step, and not the entire range from 0 to 1.
Why do you randomize the alpha? )
IMHO, it's better to use HSV(hue, saturation, value) for generation, generating colors with very different Hue
Can make a list, somewhere ~ 30 colors, and a ball will be taken from it at random
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question