Notes on OKLCH and rainbows


Colours are tricky! OKLCH is a colour space. OKLCH is better than most colour spaces in that changing the values leads to natural sensible results. But sometimes, those sensible results are not achievable because of physics, biology (eyes), and technology (display devices).

Evil Martians have a very good blog post on OKLCH. In case that goes down, MDN has a somewhat drier explanation.

The problem with the other colour spaces is that changing one of the values a certain amount leads to strange results. In HSV, changing the hue by 30 sometimes shows almost the same colour, other times an entirely different one.

In OKLCH, changing one of the values gives you nice results. Also, sometimes it gives you an inexistent colour, or a colour which is theoretically displayable, but not by your device. Oops.

Here’s an OKLCH Color Picker & Converter, go play around with it! In case it goes down, source.

I like cyclical rainbow colour palettes. I like having them consist of existing and displayable colours.

Here’s a somewhat dark one. OKLCH with Lightness 50%, Chroma 0.08 and all them hues. Anything darker, and the chroma can’t go up because of the missing cyans (and yellows). The maximum chroma that has all the colours for Lightness 50% is 0.08 – all the chromas in this post will be the maximal possible ones for the given lightness so that all the hues are still available in rgb.

Increasing Lightness to 60%, Chroma can go up to 0.1, again hitting the cyans.

The maximum chroma (for preserving all the hues) is 0.12 for Lightness 71–76%.

At lightness 85%, the purples are becoming a problem, allowing chroma of only up to 0.07 – a light saturated purple doesn’t exist. I’m so sorry.

← Choosing a programming language in 2024

No thoughts on “Notes on OKLCH and rainbows”

Add your commentHow does this work?