0

I'm willing to generate random Colors in Java (using any constructor), but I need them to be not too close to another visually speaking. A variable influencing how close is acceptable would be perfect.

RGB comparison doesn't seem to be quite efficient, according to how our eyes work. I don't want a fixed list either.

Would HSV or HSB work great there ?

Thanks for helping !

Edit : More specifically, I need to display a certain amount of Squares (1 to ~20+) which all need to have distinct Colors that couldn't be confused. I don't want a List (even a big one) because this is what I'm already using, despite having better.

Zoyd
  • 3,449
  • 1
  • 18
  • 27
Zwyk
  • 1
  • 1
  • 1
    If all you're after is 20 "different looking" colours, without having them on a long list, can't you just do something like choose 12 colours with full saturation, and hues evenly spaced between 0 and 1; then 6 colours with half saturation, and hues evenly spaced between 0 and 1; then black and white? Is there any need for anything more complicated? Although honestly, I don't understand why you dislike the idea of a long list. – Dawood ibn Kareem May 26 '14 at 08:14
  • OlegEstekhin : The "best" answer of the post seems to end up with the Kelly's and Boynton's Lists, which are quite good but not really what I'd like to end up with. DavidWallace : Well the long list is quite good but it's not as "dynamic" as I would like, since the subjects will always end up on the same colors after X tries, and if I end up with willing more that the N colors on the List, I can't. The idea of evenly spaced hues with full/half saturation is quite good though, I'll give it a try too ! – Zwyk May 26 '14 at 08:46
  • OK, but if you're going to cater for the case of a really big N, this will get hard. I'm not sure how many "full saturation" hues your eye will be able to distinguish, but I suspect it would be about 25. So this general method will stop working at around 40 colours. You might want to vary the brightness as well, so maybe have some colours at half-brightness or 3/4-brightness; as well as varying saturation in the same kind of way. – Dawood ibn Kareem May 26 '14 at 09:09

1 Answers1

0

Well the solution is obviously not technically possible, since there are only a finite amount if distinct colors we can see. However to change a color to a different color, you can shift it's hue, or it's saturation. Hue is the one that makes the color distinct from others, and saturation determines how vibrant it is. So the short answer to your question is that HSB would work well, but the actual model you store the data in is less important than how you change it.

If you just need a high contrast color, consider using the complimentary color. It kind of depends on what problem you're trying to solve.

Mikkel Løkke
  • 3,710
  • 23
  • 37
  • The more variables or parameters I could have, the better it would be, as soon as I can get random Colors that wouldn't potentially be confused ! I could use only high contrast colors, but if I could use others it would be even better – Zwyk May 26 '14 at 07:52