From d2b61644f32050238ed1641127ff4965f7a581e8 Mon Sep 17 00:00:00 2001 From: Kyzentun Date: Wed, 29 Oct 2014 00:14:13 -0600 Subject: [PATCH] Changed ColorToHex to just use string.format instead of useless number to hexstring to number to hexstring conversion. --- Themes/_fallback/Scripts/02 Colors.lua | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/Themes/_fallback/Scripts/02 Colors.lua b/Themes/_fallback/Scripts/02 Colors.lua index 3fe7335e3d..31b2036ba6 100644 --- a/Themes/_fallback/Scripts/02 Colors.lua +++ b/Themes/_fallback/Scripts/02 Colors.lua @@ -191,8 +191,6 @@ end -- ColorToHex(c) -- Takes in a normal color("") and returns the hex representation. --- Adapted from code in LuaBit (http://luaforge.net/projects/bit/), --- which is MIT licensed and copyright (C) 2006~2007 hanzhao. function ColorToHex(c) local r = c[1] local g = c[2] @@ -200,27 +198,7 @@ function ColorToHex(c) local a = HasAlpha(c) local function hex(value) - value = math.ceil(value) - - local hexVals = { 'A', 'B', 'C', 'D', 'E', 'F' } - local out = "" - local last = 0 - - while(value ~= 0) do - last = math.mod(value, 16) - if(last < 10) then - out = tostring(last) .. out - else - out = hexVals[(last-10)+1] .. out - end - value = math.floor(value/16) - end - - if(out == "") then - return "00" - end - - return string.format( "%02X", tonumber(out,16) ) + return ("%02X"):format(value) end local rX = hex( scale(r, 0, 1, 0, 255) )