HexTerm
Module: terminaltexteffects.utils.hexterm
This module contains a list of all XTerm-256 color codes and functions to convert between RGB Hex color strings and XTerm-256 color codes.
Functions:
Name | Description |
---|---|
hex_to_xterm |
Convert RGB Hex colors to their closest XTerm-256 color. |
xterm_to_hex |
Convert XTerm-256 color codes to RGB Hex colors. |
is_valid_color |
Check if the input is a valid RGB Hex color code. |
hex_to_xterm(hex_color)
Convert RGB Hex colors to their closest XTerm-256 color.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hex_color |
str
|
RGB Hex color code, '#' is optional |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
(0-255) XTerm-256 color code |
Source code in terminaltexteffects/utils/hexterm.py
is_valid_color(color)
Check if the input is a valid RGB Hex color code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
color |
int | str
|
X-Term 256 color code or RGB Hex color code, '#' is optional |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the input is a valid color code |
Source code in terminaltexteffects/utils/hexterm.py
xterm_to_hex(xterm_color)
Convert XTerm-256 color code to RGB Hex color code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xterm_color |
int
|
(0-255) XTerm-256 color code |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
str
|
RGB Hex color code |
Raises:
Type | Description |
---|---|
ValueError
|
The input is not a valid XTerm-256 color code (0-255). |