Advertisement
Arc13

drone hsl et rgb>int

Jul 19th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. function HSL(h, s, l)
  2. if s == 0 then return l,l,l end
  3. h, s, l = h/256*6, s/255, l/255
  4. local c = (1-math.abs(2*l-1))*s
  5. local x = (1-math.abs(h%2-1))*c
  6. local m,r,g,b = (l-.5*c), 0,0,0
  7. if h < 1 then r,g,b = c,x,0
  8. elseif h < 2 then r,g,b = x,c,0
  9. elseif h < 3 then r,g,b = 0,c,x
  10. elseif h < 4 then r,g,b = 0,x,c
  11. elseif h < 5 then r,g,b = x,0,c
  12. else r,g,b = c,0,x
  13. end
  14. return math.ceil((r+m)*256),math.ceil((g+m)*256),math.ceil((b+m)*256)
  15. end
  16.  
  17. function rgbToInt(r, g, b)
  18. return 256*256*r+256*g+b
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement