If you had a form where you in put hex colour codes
FFFFFF
how would you determine their hue? Like Cyan, Orange, etc...?
So if someone typed in
#FF8000
The hue would be printed on the page saying Orange.
If possible, could you also explain how this works? Or link me to something that explains it?
Would it be plausible to enter this code inside of my main python script to be able to convert to HSV?
#RGB to HSV start
ONE_THIRD = 1.0/3.0
ONE_SIXTH = 1.0/6.0
TWO_THIRD = 2.0/3.0
def rgb_to_hsv(r, g, b):
maxc = max(r, g, b)
minc = min(r, g, b)
v = maxc
if minc == maxc:
return 0.0, 0.0, v
s = (maxc-minc) / maxc
rc = (maxc-r) / (maxc-minc)
gc = (maxc-g) / (maxc-minc)
bc = (maxc-b) / (maxc-minc)
if r == maxc:
h = bc-gc
elif g == maxc:
h = 2.0+rc-bc
else:
h = 4.0+gc-rc
h = (h/6.0) % 1.0
return h, s, v
#RGB to HSV end