Sunday, August 11, 2019

multiplayer - How can I find an optimum set of colors for 10 players?


I want to give each of 10 players a unique identifying color. Is there an optimum set of colors for this? How do I create one?


Every set I've come up with contains colors that are too similar.


Update: I was asked below what this is for (fair question). Now I can tell you - Windwardopolis and the colors worked great.



Answer



You could generate equidistant hue values in the HSV space:


for (int i = 0; i < 10; i++)
colors[i] = HSV(0.1 * i, 0.5, 1.0);


try 1


However, it’s possible that you will not always have 10 players. In that case, the palette would not be very efficient unless you re-generated a different palette for another number of players. Instead, some authors recommend generating a palette using the golden ratio, taking advantage of a property resulting from the equidistribution theorem:


for (int i = 0; i < 10; i++)
colors[i] = HSV(fmod(i * 0.618033988749895, 1.0), 0.5, 1.0);

try 2


That way, even if you stop at 3 or 4 or 7 players, you get a very good hue spread.


Many irrational numbers will do, but the golden ratio will work best (it has been proven).


Finally, you can use two different generating sequences in order to tweak S or V, too. For instance (edit: I added the sqrt call for better equidistribution):



for (int i = 0; i < 10; i++)
colors[i] = HSV(fmod(i * 0.618033988749895, 1.0),
0.5,
sqrt(1.0 - fmod(i * 0.618033988749895, 0.5)));

try 3


Update: the above results can be improved by using a correction curve for H (similar to the gamma curve for RGB components) that takes the human visual system into account. This is the hue correction curve that I computed using the CIEDE2000 metric:


hue correction curve


The results for equidistant hue values are as follows:


try 4



And for the golden ratio generation sequences (with and without tweaks on V):


try 5 try 6


I will publish an approximation of the curve formula for use in programs as soon as I find a reasonably good one.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...