Update
This commit is contained in:
parent
6c8d2048e2
commit
5f25fb511f
8 changed files with 334 additions and 60 deletions
27
util.lua
Normal file
27
util.lua
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
local util = {}
|
||||
|
||||
function util.hexTorgb(str)
|
||||
if str:sub(1, 1) == "#" then
|
||||
str = str:sub(2, -1)
|
||||
end
|
||||
local r = tonumber(str:sub(1, 2), 16)
|
||||
local g = tonumber(str:sub(3, 4), 16)
|
||||
local b = tonumber(str:sub(5, 6), 16)
|
||||
return r, g, b
|
||||
end
|
||||
|
||||
function util.rgbToHex(r, g, b)
|
||||
return ("#%02x%02x%02x"):format(r, g, b)
|
||||
end
|
||||
|
||||
function util.lightenColour(c, n)
|
||||
local r, g, b = util.hexTorgb(c)
|
||||
r = math.min(math.max(r, n*1.1), 0xff)
|
||||
g = math.max(g, n)
|
||||
b = math.max(b, n*0.9)
|
||||
return util.rgbToHex(r, g, b)
|
||||
end
|
||||
|
||||
return util
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue