1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-19 05:32:55 +00:00

Convert to block comments

And remove empty line between block and definition
This commit is contained in:
Jonathan Coates 2023-05-17 22:21:38 +01:00
parent 952674a161
commit 90177c9f8b
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06

View File

@ -351,39 +351,40 @@ for i = 0, 15 do
color_hex_lookup[2 ^ i] = string.format("%x", i)
end
--- Converts the given color to a paint/blit hex character (0-9a-f).
--
-- This is equivalent to converting floor(log_2(color)) to hexadecimal.
--
-- @tparam number color The color to convert.
-- @treturn string The blit hex code of the color.
-- @usage
-- ```lua
-- colors.toBlit(colors.red)
-- -- => "c"
-- ```
-- @see colors.fromBlit
-- @since 1.94.0
--[[- Converts the given color to a paint/blit hex character (0-9a-f).
This is equivalent to converting floor(log_2(color)) to hexadecimal.
@tparam number color The color to convert.
@treturn string The blit hex code of the color.
@usage
```lua
colors.toBlit(colors.red)
-- => "c"
```
@see colors.fromBlit
@since 1.94.0
]]
function toBlit(color)
expect(1, color, "number")
return color_hex_lookup[color] or
string.format("%x", math.floor(math.log(color) / math.log(2)))
end
--- Converts the given paint/blit hex character (0-9a-f) to a color.
--
-- This is equivalent to converting the hex character to a number and then 2 ^ decimal
--
-- @tparam string hex The paint/blit hex character to convert
-- @treturn number The color
-- @usage
-- ```lua
-- colors.fromBlit("e")
-- -- => 16384
-- ```
-- @see colors.toBlit
-- @since 1.105.0
--[[- Converts the given paint/blit hex character (0-9a-f) to a color.
This is equivalent to converting the hex character to a number and then 2 ^ decimal
@tparam string hex The paint/blit hex character to convert
@treturn number The color
@usage
```lua
colors.fromBlit("e")
-- => 16384
```
@see colors.toBlit
@since 1.105.0
]]
function fromBlit(hex)
expect(1, hex, "string")