-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add Oklab perceptual color space #271
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know much about color spaces so can't give detailed feedback here.
They're a list of traits in https://github.com/JuliaGraphics/ColorTypes.jl#traits-utility-functions-for-instances-and-types. Maybe you can check and implement all of them that make sense for Oklab
and LCHOklab
? Conversions between Oklab/LCHklab from/to other color spaces might also need to be supported.
Tests are needed to ensure things work as expected.
chroma(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Luv} = sqrt(c.u^2 + c.v^2) | ||
chroma(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{LCHab,LCHuv}} = c.c | ||
chroma(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{LCHab,LCHuv, LCHOklab}} = c.c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chroma(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{LCHab,LCHuv, LCHOklab}} = c.c | |
chroma(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{LCHab,LCHuv,LCHOklab}} = c.c |
|
||
""" | ||
`hue(c)` returns the hue in degrees. This function does not guarantee that the | ||
return value is in [0, 360]. | ||
""" | ||
hue(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{HSV,HSL,HSI,LCHab,LCHuv}} = c.h | ||
hue(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{Lab,DIN99,DIN99o,DIN99d}} = | ||
hue(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{HSV,HSL,HSI,LCHab,LCHuv, LCHOklab}} = c.h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hue(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{HSV,HSL,HSI,LCHab,LCHuv, LCHOklab}} = c.h | |
hue(c::Union{C,AlphaColor{C},ColorAlpha{C}}) where {C<:Union{HSV,HSL,HSI,LCHab,LCHuv,LCHOklab}} = c.h |
@nealmckee is there a reason why this is still a draft PR? |
Superseded by #291 |
Implements the Oklab color space as described here: https://bottosson.github.io/posts/oklab/
Adds and exports the type.
Adds Oklab and LCHOklab to the chroma and hue trait accessor functions.
Adds description to the readme.
This is my first contribution to Julia, or any software package for that matter, so help with any oversights would be greatly appreciated. (Am I missing tests for example? They weren’t mentioned in the guidelines on how to extend color types.)
See also JuliaGraphics/Colors.jl#518