Algorithm For Generating Unique Colors

algorithmcolorslanguage-agnostic

I am looking for an algorithm that will generate a series of colors so that the colors will be as widely distributed as possible (so they won't easily be mixed up).

I have a series of objects that have IDs that count up from 1. I would like to represent each of these with a different, aesthetically pleasing, color that won't get easily confused with its neighbors. The colors should not necessarily be random though. I would like to get the same color each time I input the same ID.

Best Answer

I've checked all the ways to do it, solving more than a few ways. And finally brute force with CIEde2000 and really, your best bet is just a static list. You can't get more than about 30 colors with good distinctness no matter what you do. Factor in color blindness and the lines of confusion, and you're really making something that is a hindrance. Use a lookup table and modify the data points with some other characteristics than just color.

max difference color palette

#000000
#00FF00
#0000FF
#FF0000
#01FFFE
#FFA6FE
#FFDB66
#006401
#010067
#95003A
#007DB5
#FF00F6
#FFEEE8
#774D00
#90FB92
#0076FF
#D5FF00
#FF937E
#6A826C
#FF029D
#FE8900
#7A4782
#7E2DD2
#85A900
#FF0056
#A42400
#00AE7E
#683D3B
#BDC6FF
#263400
#BDD393
#00B917
#9E008E
#001544
#C28C9F
#FF74A3
#01D0FF
#004754
#E56FFE
#788231
#0E4CA1
#91D0CB
#BE9970
#968AE8
#BB8800
#43002C
#DEFF74
#00FFC6
#FFE502
#620E00
#008F9C
#98FF52
#7544B1
#B500FF
#00FF78
#FF6E41
#005F39
#6B6882
#5FAD4E
#A75740
#A5FFD2
#FFB167
#009BFF
#E85EBE