mirror of
https://github.com/appgurueu/modlib.git
synced 2024-12-22 21:32:27 +01:00
Colorspec: Use hex numbers to improve readability
This commit is contained in:
parent
b00c0f0d51
commit
5dd5e50704
@ -210,7 +210,7 @@ function colorspec.from_string(string)
|
||||
if not number then
|
||||
return
|
||||
end
|
||||
alpha = tonumber(alpha_text, 16)
|
||||
alpha = tonumber(alpha_text, 0x10)
|
||||
end
|
||||
end
|
||||
if number then
|
||||
@ -220,7 +220,7 @@ function colorspec.from_string(string)
|
||||
if not hex_text then
|
||||
return
|
||||
end
|
||||
local len, num = hex_text:len(), tonumber(hex_text, 16)
|
||||
local len, num = hex_text:len(), tonumber(hex_text, 0x10)
|
||||
if len == 8 then
|
||||
return colorspec.from_number_rgba(num)
|
||||
end
|
||||
@ -229,17 +229,17 @@ function colorspec.from_string(string)
|
||||
end
|
||||
if len == 4 then
|
||||
return colorspec.from_table{
|
||||
a = (num % 16) * 17,
|
||||
b = (floor(num / 16) % 16) * 17,
|
||||
g = (floor(num / (16 ^ 2)) % 16) * 17,
|
||||
r = (floor(num / (16 ^ 3)) % 16) * 17
|
||||
a = (num % 0x10) * 0x11,
|
||||
b = (floor(num / 0x10) % 0x10) * 0x11,
|
||||
g = (floor(num / (0x100)) % 0x10) * 0x11,
|
||||
r = (floor(num / (0x1000)) % 0x10) * 0x11
|
||||
}
|
||||
end
|
||||
if len == 3 then
|
||||
return colorspec.from_table{
|
||||
b = (num % 16) * 17,
|
||||
g = (floor(num / 16) % 16) * 17,
|
||||
r = (floor(num / (16 ^ 2)) % 16) * 17
|
||||
b = (num % 0x10) * 0x11,
|
||||
g = (floor(num / 0x10) % 0x10) * 0x11,
|
||||
r = (floor(num / (0x100)) % 0x10) * 0x11
|
||||
}
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user