diff --git a/projects/core/src/main/resources/data/computercraft/lua/rom/apis/colors.lua b/projects/core/src/main/resources/data/computercraft/lua/rom/apis/colors.lua index f582ff10e..5494cc1ac 100644 --- a/projects/core/src/main/resources/data/computercraft/lua/rom/apis/colors.lua +++ b/projects/core/src/main/resources/data/computercraft/lua/rom/apis/colors.lua @@ -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")