-
-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE]: Add "Oklch" colourspace. #1183
Comments
@KelSolaar Oklch is different from Okhsl or Okhsv. So it's not a duplicate. |
Ah yes sorry, my bad! I misread the space name... We probably won't implement this one because it is a simple polar representation that we can perform on any "Jab" like spaces: https://github.com/colour-science/colour/blob/develop/colour/models/common.py#L163 my_oklch = colour.models.Jab_to_JCh(my_oklab) |
@KelSolaar Anyway, providing 'Oklch' would be nice for convenience. |
This is a good discussion. If we do it for Oklab or JzAzBz, we might as well do it for IPT, ICtCp, ICaCb, ProLab, etc... we have so much opponent-based spaces that it becomes quite a maintenance burden as we ideally need to write tests, docs, etc.., this is why I rolled the |
i agree that there is value in doing this. But I wonder if it can be done by decoration with a "metaclass" or some other meta programming. (please forgive the reference to a very specific C++ concept in a much more general meaning) |
Something along those lines would work for example but it gets close to a steam factory rapidly: import colour
import sys
from colour.models import Jab_to_JCh, JCh_to_Jab
from colour.utilities import copy_definition
__all__ = []
CALLABLES_LCH = {
"Oklab_to_Oklch": (Jab_to_JCh, "The docstring..."),
"Oklch_to_Oklab": (JCh_to_Jab, "The docstring..."),
}
for name, (callable_, docstring) in CALLABLES_LCH.items():
callable_.__doc__ = docstring
_module = sys.modules["colour.models"]
setattr(_module, name, copy_definition(callable_, name))
print(colour.models.JCh_to_Jab)
print(colour.models.JCh_to_Jab.__name__)
print(colour.models.Oklch_to_Oklab)
print(colour.models.Oklch_to_Oklab.__name__)
We have something magic like that here actually: https://github.com/colour-science/colour-datasets/blob/develop/colour_datasets/loaders/kuopio.py#L498 |
I think there is something you could do in the oklab module to automatically define the variable names too. Something like
|
i use oklch quite regularly, and if i was provided a full list of spaces that fall under this category i would be willing to add them to the graph manually |
This was implemented! :) |
Great, can this be expected to appear on the README graph and on PyPi? |
The graph is generated here: https://github.com/colour-science/colour/blob/develop/utilities/generate_plots.py#L166 That being said, I can see that the last build failed on RtD. I will check what is going on. |
Note that I will refine some names in a future commit, |
Description
Oklab and Oklch has been added to CSS Color Module Level 4. But, only Oklab is available for Colour.
Adding Oklch will be great for convenience.
The text was updated successfully, but these errors were encountered: