WoW:USERAPI RGBToHex: Difference between revisions

m
Move page script moved page USERAPI RGBToHex to WoW:USERAPI RGBToHex without leaving a redirect
m (Imp RGBToHex)
m (Move page script moved page USERAPI RGBToHex to WoW:USERAPI RGBToHex without leaving a redirect)
 
(One intermediate revision by one other user not shown)
Line 5: Line 5:


  local function RGBToHex(r, g, b)
  local function RGBToHex(r, g, b)
    if r > 255 or r < 0 then
r = r <= 255 and r >= 0 and r or 0
        r = 0
g = g <= 255 and g >= 0 and g or 0
    end
b = b <= 255 and b >= 0 and b or 0
    if g > 255 or g < 0 then
return string.format("%02x%02x%02x", r, g, b)
        g = 0
    end
    if b > 255 or b < 0 then
        b = 0
    end
    return string.format("%02x%02x%02x", r, g, b)
  end
  end
Anonymous user