mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-26 01:03:46 +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
|
if not number then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
alpha = tonumber(alpha_text, 16)
|
alpha = tonumber(alpha_text, 0x10)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if number then
|
if number then
|
||||||
@ -220,7 +220,7 @@ function colorspec.from_string(string)
|
|||||||
if not hex_text then
|
if not hex_text then
|
||||||
return
|
return
|
||||||
end
|
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
|
if len == 8 then
|
||||||
return colorspec.from_number_rgba(num)
|
return colorspec.from_number_rgba(num)
|
||||||
end
|
end
|
||||||
@ -229,17 +229,17 @@ function colorspec.from_string(string)
|
|||||||
end
|
end
|
||||||
if len == 4 then
|
if len == 4 then
|
||||||
return colorspec.from_table{
|
return colorspec.from_table{
|
||||||
a = (num % 16) * 17,
|
a = (num % 0x10) * 0x11,
|
||||||
b = (floor(num / 16) % 16) * 17,
|
b = (floor(num / 0x10) % 0x10) * 0x11,
|
||||||
g = (floor(num / (16 ^ 2)) % 16) * 17,
|
g = (floor(num / (0x100)) % 0x10) * 0x11,
|
||||||
r = (floor(num / (16 ^ 3)) % 16) * 17
|
r = (floor(num / (0x1000)) % 0x10) * 0x11
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
if len == 3 then
|
if len == 3 then
|
||||||
return colorspec.from_table{
|
return colorspec.from_table{
|
||||||
b = (num % 16) * 17,
|
b = (num % 0x10) * 0x11,
|
||||||
g = (floor(num / 16) % 16) * 17,
|
g = (floor(num / 0x10) % 0x10) * 0x11,
|
||||||
r = (floor(num / (16 ^ 2)) % 16) * 17
|
r = (floor(num / (0x100)) % 0x10) * 0x11
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user