Resource question : web safe / best colour contrast generators

An unusual question today. About colours. I have an app tha draws graphs, a bit like Windows Perfmon. Every time you add a pen to the graph it automatically chooses a new colour (incidentally perfmon tries to but in many cases chooses the same colour as last time anyway). I suddenly thought if you wanted an arbitrarily long list of colours with highest possible visual contrast and knew the length or range of colours beforehand, where would you go to build a list that starts out brilliantly and slowly gets less and less distinct. So where the list of colours tries to stay as clearly unique as possible.

I’m guessing you would want to synthesize this kind of colour list using RGB or better yet using a visual colour palette. Has anyone ever done this before? On a white background, Black is a valid colour, on a black background that would also impact what nearby colours you can choose. It’s easy enough to hard code 2 good lists, but I wonder if anyone has every tried to synthesize this kind of thing for a web-page design for example?

I’m not sure I’ve seen exactly what you’re looking for but this site might help

It actually does help. Because as you move down, the colours in these hand-picked charts get more and more alike. For my purposes all I need is a reasonably long chart for 20 colours, so I’m going with an Empirical set. But anyone who might be doing this for larger sets of data or keys might want to get more clever about choosing colours using raw data about colour perception.

Just a thought experiment in an age where computers are doing more and more of the thinking for us, always good to be one step ahead if possible in our vision.

One approach I’ve seen work well is to generate the next colour by maximizing its perceptual distance from all previously selected colours rather than simply cycling through RGB values. Using a perceptual colour space like CIELAB or OKLCH generally produces much better visual separation than RGB, especially as the list grows. You could even reserve high-contrast colours first and progressively fill the gaps.

Always amazed when we have someone in the community who knows the good stuff. CIELAB color space - Wikipedia . This looks like an engine for perceptual colour for humans, and that the thing to do is write a converter from the CIELAB gamut into an RGB colour space. That’s the theory at least. CEILAB is not the only place to start, but in keeping with learning about colour perception, we know that the eye is able to perceive brightness changes more readily in certain areas of the spectrum. A nice thought experiment for one day.