facelessuser / coloraide

A library to aid in using colors
https://facelessuser.github.io/coloraide
MIT License
194 stars 12 forks source link

Unable to convert colors? #411

Closed Roger-Breton closed 6 months ago

Roger-Breton commented 6 months ago

BTW, Coloraide is not for the faint of heart.

I managed to get to this point:

rom coloraide import cat from coloraide import Color lab_D65 = Color("lab", [30, 26, -27], illuminant="D65")

xyz_d65 = lab_D65.convert("xyz-d65").coords()

xyz_d50 = Color.chromatic_adaptation(cat.WHITES['2deg']["D50"], cat.WHITES['2deg']["D65"], xyz_d65, method='bradford')

But I can't figure how to convert xyz_d50 to Lab_d50?

Lab_d50 = xyz_d50 ???

facelessuser commented 6 months ago

I think you are greatly overthinking things. ColorAide generally tries to dumb things down a lot for the average user.

>>> Color("lab", [30, 26, -27]).convert('xyz-d65')
color(xyz-d65 0.08955 0.06312 0.16465 / 1)

ColorAide exposes xyz-d65 and xyz-d50. lab uses D50, lab-d65 uses D65 illuminant. If I could go back, I'd probably use the ID lab-d50 for lab even if it serializes to lab for CSS.

Yes, you can subclass the existing XYZ spaces and add more XYZ space with different illuminates, but we added the ones that average user would need to use.

facelessuser commented 6 months ago

If it helps, each supported color space has their name mentioned in their properties description in the documentation: https://facelessuser.github.io/coloraide/colors/xyz_d50/#xyz-d50.

facelessuser commented 6 months ago

I will also state that most people will not need to use chromatic_adaptation directly. It's there, and we use it internally during conversions and such, but the hope is that the average user will not need to touch it. If you are doing advanced stuff, there are times when that may be handy. I don't expect everything that ColorAide exposes to be used by the majority of people, but some of it has to exist so we can provide the easy stuff, like a simple .convert().

Our goal isn't to necessarily be a colour science library, which is a great library, but to appeal to people that just want to use colors.

It is possible that maybe sometimes I delve a little too deep into topics in the documentation 😅. There's a lot to know about colors, so I think it is interesting to help people understand some of it, but the average user is going to just be converting, filtering, mixing, etc. We wanted to make that fairly easy to do.

facelessuser commented 6 months ago

Lastly, the documentation covers color object generally (how to create colors, convert colors, clone colors, etc.) https://facelessuser.github.io/coloraide/color/#converting.

The documentation also covers color manipulation: https://facelessuser.github.io/coloraide/manipulation/.