Skip to content

Instantly share code, notes, and snippets.

@MyNameIsKodos
Last active August 29, 2015 14:12
Show Gist options
  • Save MyNameIsKodos/008a9cf31b204ece34c7 to your computer and use it in GitHub Desktop.
Save MyNameIsKodos/008a9cf31b204ece34c7 to your computer and use it in GitHub Desktop.
RGB (0-31) to 15 bit (For use with Colorful Lamps)
function rgbto15(r,g,b) return (b%32)+((g%32)*32)+((r%32)*1024) end
function rgbToHex(r,g,b) return string.format("0x%02X%02X%02X",r,g,b) end
function hexToRGB(a) a=tonumber(a) return math.floor(a/65536)%256,math.floor(a/256)%256,a%256 end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment