Hello all! I'm looking for a function to convert a...
# compose
g
Hello all! I'm looking for a function to convert a rgb
Color
to a HSL representation but I can only find a HSL to RGB function in the
Color
class. Someone can confirm me that the RGB to HSL function doesn't exist?
z
I think something like this should do it:
val (h, s, l) = color.convertTo(ColorSpaces.HSL)
The component/rgb accessors on
Color
are really just whatever components the color space defines. They’re just called “rgb” because it’s the most common, presumably
r
HSL
is not a color space, so you won’t find it in
ColorSpaces
(it’s a color model)
g
I hoped so much when I read your message Zach but yes, HSL isn't in
ColorSpaces
. In french, we call this an emotional elevator. Don't know if this expression is valid in English. ^^
r
And there’s no
toHsl()
but if you are ok with HSV instead of HSL you can use android.graphics.Color
Oh wait 1 sec
I just remembered there’s something in
androidx.core.graphics
g
Oh super cool! Thanks Romain!
z
My bad, i could have sworn i saw hsl in the list but clearly was thinking of something else
r
@Zach Klippenstein (he/him) [MOD] I’ll give you a course on color management and bore you to death :))
😂 1
1
z
sounds pretty great actually 😛