evennia.utils.hex_colors¶
Truecolor 24bit hex color support, on the form |#00FF00, |[00FF00 or |#0F0 or **|[#0F0
-
class
evennia.utils.hex_colors.
HexColors
[source]¶ Bases:
object
This houses a method for converting hex codes to xterm truecolor codes or falls back to evennia xterm256 codes to be handled by sub_xterm256
Based on code from @InspectorCaracal
-
TRUECOLOR_FG
= '\\x1b\\[38;2;[0-2]?[0-9]?[0-9];[0-2]?[0-9]?[0-9];[0-2]?[0-9]?[0-9]m'¶
-
TRUECOLOR_BG
= '\\x1b\\[48;2;[0-2]?[0-9]?[0-9];[0-2]?[0-9]?[0-9];[0-2]?[0-9]?[0-9]m'¶
-
hex_sub
= re.compile('(\\|\\[?#)([0-9a-fA-F]{6}|[0-9a-fA-F]{3})', re.DOTALL)¶
-
sub_truecolor
(match: re.Match, truecolor=False) → str[source]¶ Converts a hex string to xterm truecolor code, greyscale, or falls back to evennia xterm256 to be handled by sub_xterm256
- Parameters
match (re.match) – first group is the leading indicator, second is the tag
truecolor (bool) – return xterm truecolor or fallback
- Returns
Newly formatted indicator and tag (str)
-