WoW:USERAPI RGBPercToHex: Difference between revisions

m
Move page script moved page USERAPI RGBPercToHex to WoW:USERAPI RGBPercToHex without leaving a redirect
(use r*255 or r*255+.5)
m (Move page script moved page USERAPI RGBPercToHex to WoW:USERAPI RGBPercToHex without leaving a redirect)
 
(2 intermediate revisions by 2 users not shown)
Line 3: Line 3:


Takes a RGB percent set (0.0-1.0) and converts it to a hex string.
Takes a RGB percent set (0.0-1.0) and converts it to a hex string.
 
<pre>
  local function RGBPercToHex(r, g, b)
  local function RGBPercToHex(r, g, b)
  r = r <= 1 and r >= 0 and r or 0
  r = r <= 1 and r >= 0 and r or 0
Line 10: Line 10:
  return string.format("%02x%02x%02x", r*255, g*255, b*255)
  return string.format("%02x%02x%02x", r*255, g*255, b*255)
  end
  end
 
</pre>
the data i get from GetTextColor() i need to use r*255'''+.5'''  to get the tru result :)
return string.format("%02x%02x%02x", r*255+.5, g*255+.5, b*255+.5)
Anonymous user