HCL color to RGB and backward

后端 未结 5 1565
天涯浪人
天涯浪人 2020-12-28 19:51

I need an algorithm to convert the HCL color to RGB and backward RGB to HCL keeping in mind that these color spaces have different gamuts (I need to constrain the HCL colors

5条回答
  •  醉话见心
    2020-12-28 20:20

    As mentioned in other answers, there are a lot of ways to implement an HCL colorspace and map that into RGB.

    HSLuv ended up being what I used, and has MIT-licensed implementations in C, C#, Go, Java, PHP, and several other languages. It's similar to CIELUV LCh but fully maps to RGB. The implementations are available on GitHub.

    Here's a short graphic from the website describing the HSLuv color space, with the implementation output in the right two panels:

提交回复
热议问题