I'm trying to use the compose Color class for HSV,...
# compose
z
I'm trying to use the compose Color class for HSV, however internally it uses an ARGB int. The problem is when all the RGB components are the same, then the hue is effectively lost, or undefined. I'm really trying to avoid introducing another Color class, to keep usage of my library simple. I'm wondering if someone else may have some idea or if its just not possible to do this. This is for my color picker library, specifically the square color picker component
m
The german version of the Wiki page says: Diese Formeln spiegeln einige Eigenheiten der HSV-Werte wider: • Wenn R = G = B, dann ist H ohne Bedeutung und es wird per Definition H = 0 gesetzt. • Das ist offensichtlich. Denn wenn S = 0 ist (ungesättigte Farbe), dann liegt der Farbort auf der zentralen Grau-Linie (obige Kegelform), der Farbton ist so ohne Bedeutung und kann nicht sinnvoll angegeben werden. • Wenn R = G = B = 0, dann ist S ohne Bedeutung und per Definition wird S = 0 gesetzt. • Denn wenn alle drei RGB-Werte „Null” sind, geht es um Schwarz und die Sättigung der Farbe verliert ihre Bedeutung. Dasselbe gilt allerdings nicht im Fall MAX = MIN = 1, d. h. Weiß: der Wert 0 ist von elementarer Bedeutung, wie an der obigen Kegelform erkennbar ist. Couldn’t find that in the english version of the Wiki page.
r
It's not using an ARGB int internally, it's a bit more complicated. It only uses that encoding for sRGB colors. Compose could introduce a new HSV color model/space to make this work. That would be the only way to retain the hue information without introducing a new type.
Note that proper HSV support would need to ensure it works with gamuts other than sRGB.
(btw I don't know why the HSV accessors were added to the color class, it's not how it should have worked)
z
Interesting Wikipedia page. I do wish compose just had this functionality built in, it would make this a lot easier to work with. I'm wondering if it would be worth going ahead and requesting better support for HSV colors