Is there a way to convert HSV color arguments to RGB type color arguments using pygame modules in python? I tried the following code, but it returns ridiculous values.
I have prepared a vectorized version, it is cca 10x faster
def hsv_to_rgb(h, s, v):
shape = h.shape
i = int_(h*6.)
f = h*6.-i
q = f
t = 1.-f
i = ravel(i)
f = ravel(f)
i%=6
t = ravel(t)
q = ravel(q)
clist = (1-s*vstack([zeros_like(f),ones_like(f),q,t]))*v
#0:v 1:p 2:q 3:t
order = array([[0,3,1],[2,0,1],[1,0,3],[1,2,0],[3,1,0],[0,1,2]])
rgb = clist[order[i], arange(prod(shape))[:,None]]
return rgb.reshape(shape+(3,))