hudak.codes

Generating random LCH colors

2023-02-23

After my previous post about generating random color I remembered I had read about many new color spaces and CSS color features that have been landing in browsers recently. One of them is LCH, which is a cylindrical color space that is perceptually uniform. It is also the color space used by the HSLuv color space, which is a perceptually uniform color space that is designed to be more human-friendly than HSL.

I asked Chat GPT to adapt my previous code to generate random colors in the LCH color space. It is the most amazing version by far. I felt compelled to add a refresh button. It's almost meditative to refresh and enjoy these colors. It does require d3. I haven't bothered to look into whether its possible without yet.

Links to learn more about LCH, color spaces and new CSS color properties.