I've just spent a frustrating hour and a half trying to figure out how rainbowio.colorwheel returns color values. I was trying to split the int returned into 3 bytes for standard (R,B,G) palette shading. I managed to get it to work after realizing that it didn't return leading 0s (as in (0,255,255) returned as 0xFFFF instead of 0x00FFFF). The main reason this was frustrating is that I couldn't find documentation for rainbowio *anywhere* not in the lib downloads, not on git, not on your 'Learn' page, nowhere. It would be a huge help to have the 'built-in' libraries somewhere accessible if for no other reason than to grok what they do.
For anyone interested in how I solved my issue:
Code: Select all
def rgb_from_hex(h):
hexa = hex(colorwheel(h))[2:]
while len(hexa) < 6:
hexa = '0' + hexa
r = int(hexa[0:2], 16)
g = int(hexa[2:4], 16)
b = int(hexa[4:6], 16)
return (r, g, b)