mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-08-04 21:03:58 +00:00
fix #1367: Add colors.fromBlit
This commit is contained in:
parent
f099b21f6f
commit
722b870f98
@ -363,3 +363,20 @@ function toBlit(color)
|
|||||||
return color_hex_lookup[color] or
|
return color_hex_lookup[color] or
|
||||||
string.format("%x", math.floor(math.log(color) / math.log(2)))
|
string.format("%x", math.floor(math.log(color) / math.log(2)))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Converts the given paint/blit hex character (0-9a-f) to a color.
|
||||||
|
--
|
||||||
|
-- This is equivalent to converting the hex character to decimal and then 2 ^ decimal
|
||||||
|
--
|
||||||
|
-- @tparam string hex The paint/blit hex character to convert
|
||||||
|
-- @treturn number The color
|
||||||
|
|
||||||
|
function fromBlit(hex)
|
||||||
|
expect(1, hex, "string")
|
||||||
|
|
||||||
|
if hex:find("[^0-9a-f]") or hex == "" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
return math.floor(2 ^ tonumber(hex, 16))
|
||||||
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user