All,
Are there any nice algorithms out there to generate a unique colour based on index in an array?
This is of course going to be used in a UI, to set the background colour of a number of dynamic buttons.
Now with .Net (and Java off top of my head), the following methods are supported:
Color.FromArgb
Color.FromName
FromArgb can take an 32-bit integer containing the argb color.
However, the algorithmic approach might cause some colours to be too similar in order, depending upon how many items were in the array. And also, where the foreground colour is similar to the background.
The only way I can think of is to create some kind of Color array, with a set of predefined colours in. Off course, this is manual code effort, but this way you can get a different set of colours in a small range that can be visually different from each other, before repeating sequence towards the end.
The other way could be to use the following to generate the array of colours:
Enum.GetValues(typeof(KnownColor)
Any suggestions?
Cheers