mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-06-03 07:04:11 +00:00
Convert to block comments
And remove empty line between block and definition
This commit is contained in:
parent
952674a161
commit
90177c9f8b
@ -351,39 +351,40 @@ for i = 0, 15 do
|
|||||||
color_hex_lookup[2 ^ i] = string.format("%x", i)
|
color_hex_lookup[2 ^ i] = string.format("%x", i)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Converts the given color to a paint/blit hex character (0-9a-f).
|
--[[- Converts the given color to a paint/blit hex character (0-9a-f).
|
||||||
--
|
|
||||||
-- This is equivalent to converting floor(log_2(color)) to hexadecimal.
|
This is equivalent to converting floor(log_2(color)) to hexadecimal.
|
||||||
--
|
|
||||||
-- @tparam number color The color to convert.
|
@tparam number color The color to convert.
|
||||||
-- @treturn string The blit hex code of the color.
|
@treturn string The blit hex code of the color.
|
||||||
-- @usage
|
@usage
|
||||||
-- ```lua
|
```lua
|
||||||
-- colors.toBlit(colors.red)
|
colors.toBlit(colors.red)
|
||||||
-- -- => "c"
|
-- => "c"
|
||||||
-- ```
|
```
|
||||||
-- @see colors.fromBlit
|
@see colors.fromBlit
|
||||||
-- @since 1.94.0
|
@since 1.94.0
|
||||||
|
]]
|
||||||
function toBlit(color)
|
function toBlit(color)
|
||||||
expect(1, color, "number")
|
expect(1, color, "number")
|
||||||
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.
|
--[[- 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
|
|
||||||
|
|
||||||
|
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)
|
function fromBlit(hex)
|
||||||
expect(1, hex, "string")
|
expect(1, hex, "string")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user