Advertisement
Guest User

Untitled

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