Skip to content

arc.color

bg

Background colors

Source code in arc/color.py
class bg:
    """Background colors"""
    BLACK          = "\033[40m"
    """Ansi escape code: `\\033[40m`"""
    RED            = "\033[41m"
    """Ansi escape code: `\\033[41m`"""
    GREEN          = "\033[42m"
    """Ansi escape code: `\\033[42m`"""
    YELLOW         = "\033[43m"
    """Ansi escape code: `\\033[43m`"""
    BLUE           = "\033[44m"
    """Ansi escape code: `\\033[44m`"""
    MAGENTA        = "\033[45m"
    """Ansi escape code: `\\033[45m`"""
    CYAN           = "\033[46m"
    """Ansi escape code: `\\033[46m`"""
    WHITE          = "\033[47m"
    """Ansi escape code: `\\033[47m`"""
    GREY           = "\033[100m"
    """Ansi escape code: `\\033[100m`"""
    BRIGHT_RED     = "\033[101m"
    """Ansi escape code: `\\033[101m`"""
    BRIGHT_GREEN   = "\033[102m"
    """Ansi escape code: `\\033[102m`"""
    BRIGHT_YELLOW  = "\033[103m"
    """Ansi escape code: `\\033[103m`"""
    BRIGHT_BLUE    = "\033[104m"
    """Ansi escape code: `\\033[104m`"""
    BRIGHT_MAGENTA = "\033[105m"
    """Ansi escape code: `\\033[105m`"""
    BRIGHT_CYAN    = "\033[106m"
    """Ansi escape code: `\\033[106m`"""
    BRIGHT_WHITE   = "\033[107m"
    """Ansi escape code: `\\033[107m`"""
    ARC_BLUE       = "\033[48;2;59;192;240m"
    """The blue used in arc branding"""

    @staticmethod
    def rgb(red: int = 0, green: int = 0, blue: int = 0):
        """Returns the **background** escape
        sequence for the provided rgb values"""
        return _rgb(48, red, green, blue)

    @staticmethod
    def hex(hex_code: Union[str, int]):
        """Returns the **background** escape
        sequence for the provided hex value"""
        return _rgb(48, *_hex_to_rgb(hex_code))

ARC_BLUE = '\x1b[48;2;59;192;240m' class-attribute

The blue used in arc branding

BLACK = '\x1b[40m' class-attribute

Ansi escape code: \033[40m

BLUE = '\x1b[44m' class-attribute

Ansi escape code: \033[44m

BRIGHT_BLUE = '\x1b[104m' class-attribute

Ansi escape code: \033[104m

BRIGHT_CYAN = '\x1b[106m' class-attribute

Ansi escape code: \033[106m

BRIGHT_GREEN = '\x1b[102m' class-attribute

Ansi escape code: \033[102m

BRIGHT_MAGENTA = '\x1b[105m' class-attribute

Ansi escape code: \033[105m

BRIGHT_RED = '\x1b[101m' class-attribute

Ansi escape code: \033[101m

BRIGHT_WHITE = '\x1b[107m' class-attribute

Ansi escape code: \033[107m

BRIGHT_YELLOW = '\x1b[103m' class-attribute

Ansi escape code: \033[103m

CYAN = '\x1b[46m' class-attribute

Ansi escape code: \033[46m

GREEN = '\x1b[42m' class-attribute

Ansi escape code: \033[42m

GREY = '\x1b[100m' class-attribute

Ansi escape code: \033[100m

MAGENTA = '\x1b[45m' class-attribute

Ansi escape code: \033[45m

RED = '\x1b[41m' class-attribute

Ansi escape code: \033[41m

WHITE = '\x1b[47m' class-attribute

Ansi escape code: \033[47m

YELLOW = '\x1b[43m' class-attribute

Ansi escape code: \033[43m

hex(hex_code) staticmethod

Returns the background escape sequence for the provided hex value

Source code in arc/color.py
@staticmethod
def hex(hex_code: Union[str, int]):
    """Returns the **background** escape
    sequence for the provided hex value"""
    return _rgb(48, *_hex_to_rgb(hex_code))

rgb(red=0, green=0, blue=0) staticmethod

Returns the background escape sequence for the provided rgb values

Source code in arc/color.py
@staticmethod
def rgb(red: int = 0, green: int = 0, blue: int = 0):
    """Returns the **background** escape
    sequence for the provided rgb values"""
    return _rgb(48, red, green, blue)

effects

Other effects. Support from terminal to terminal may vary

Source code in arc/color.py
class effects:
    """Other effects. Support from terminal to terminal may vary"""
    CLEAR         = "\033[0m"
    """Remove any effects applied with escape codes"""
    BOLD          = "\033[1m"
    """Bold the text"""
    ITALIC        = "\033[3m"
    """Italicize the text"""
    UNDERLINE     = "\033[4m"
    """Underline the text"""
    STRIKETHROUGH = "\033[9m"
    """Strikethrough the text"""

BOLD = '\x1b[1m' class-attribute

Bold the text

CLEAR = '\x1b[0m' class-attribute

Remove any effects applied with escape codes

ITALIC = '\x1b[3m' class-attribute

Italicize the text

STRIKETHROUGH = '\x1b[9m' class-attribute

Strikethrough the text

UNDERLINE = '\x1b[4m' class-attribute

Underline the text

fg

Foreground colors

Source code in arc/color.py
class fg:
    """Foreground colors"""
    BLACK          = "\033[30m"
    """Ansi escape code: `\\033[30m`"""
    RED            = "\033[31m"
    """Ansi escape code: `\\033[31m`"""
    GREEN          = "\033[32m"
    """Ansi escape code: `\\033[32m`"""
    YELLOW         = "\033[33m"
    """Ansi escape code: `\\033[33m`"""
    BLUE           = "\033[34m"
    """Ansi escape code: `\\033[34m`"""
    MAGENTA        = "\033[35m"
    """Ansi escape code: `\\033[35m`"""
    CYAN           = "\033[36m"
    """Ansi escape code: `\\033[36m`"""
    WHITE          = "\033[37m"
    """Ansi escape code: `\\033[37m`"""
    GREY           = "\033[90m"
    """Ansi escape code: `\\033[90m`"""
    BRIGHT_RED     = "\033[91m"
    """Ansi escape code: `\\033[91m`"""
    BRIGHT_GREEN   = "\033[92m"
    """Ansi escape code: `\\033[92m`"""
    BRIGHT_YELLOW  = "\033[93m"
    """Ansi escape code: `\\033[93m`"""
    BRIGHT_BLUE    = "\033[94m"
    """Ansi escape code: `\\033[94m`"""
    BRIGHT_MAGENTA = "\033[95m"
    """Ansi escape code: `\\033[95m`"""
    BRIGHT_CYAN    = "\033[96m"
    """Ansi escape code: `\\033[96m`"""
    BRIGHT_WHITE   = "\033[97m"
    """Ansi escape code: `\\033[97m`"""
    ARC_BLUE       = "\033[38;2;59;192;240m"
    """The blue used in arc branding"""

    @staticmethod
    def rgb(red: int = 0, green: int = 0, blue: int = 0):
        """Returns the **foreground** escape
        sequence for the provided rgb values"""
        return _rgb(38, red, green, blue)

    @staticmethod
    def hex(hex_code: Union[str, int]):
        """Returns the **foreground** escape
        sequence for the provided hex values"""
        return _rgb(38, *_hex_to_rgb(hex_code))

ARC_BLUE = '\x1b[38;2;59;192;240m' class-attribute

The blue used in arc branding

BLACK = '\x1b[30m' class-attribute

Ansi escape code: \033[30m

BLUE = '\x1b[34m' class-attribute

Ansi escape code: \033[34m

BRIGHT_BLUE = '\x1b[94m' class-attribute

Ansi escape code: \033[94m

BRIGHT_CYAN = '\x1b[96m' class-attribute

Ansi escape code: \033[96m

BRIGHT_GREEN = '\x1b[92m' class-attribute

Ansi escape code: \033[92m

BRIGHT_MAGENTA = '\x1b[95m' class-attribute

Ansi escape code: \033[95m

BRIGHT_RED = '\x1b[91m' class-attribute

Ansi escape code: \033[91m

BRIGHT_WHITE = '\x1b[97m' class-attribute

Ansi escape code: \033[97m

BRIGHT_YELLOW = '\x1b[93m' class-attribute

Ansi escape code: \033[93m

CYAN = '\x1b[36m' class-attribute

Ansi escape code: \033[36m

GREEN = '\x1b[32m' class-attribute

Ansi escape code: \033[32m

GREY = '\x1b[90m' class-attribute

Ansi escape code: \033[90m

MAGENTA = '\x1b[35m' class-attribute

Ansi escape code: \033[35m

RED = '\x1b[31m' class-attribute

Ansi escape code: \033[31m

WHITE = '\x1b[37m' class-attribute

Ansi escape code: \033[37m

YELLOW = '\x1b[33m' class-attribute

Ansi escape code: \033[33m

hex(hex_code) staticmethod

Returns the foreground escape sequence for the provided hex values

Source code in arc/color.py
@staticmethod
def hex(hex_code: Union[str, int]):
    """Returns the **foreground** escape
    sequence for the provided hex values"""
    return _rgb(38, *_hex_to_rgb(hex_code))

rgb(red=0, green=0, blue=0) staticmethod

Returns the foreground escape sequence for the provided rgb values

Source code in arc/color.py
@staticmethod
def rgb(red: int = 0, green: int = 0, blue: int = 0):
    """Returns the **foreground** escape
    sequence for the provided rgb values"""
    return _rgb(38, red, green, blue)

colorize(string, *codes, clear=True)

Applies colors / effects to an entire string

Parameters:

Name Type Description Default
string str

String to colorize

required
*codes str

colors / effects to apply to the strin

()
clear bool

Whether or not to append effects.CLEAR to the end of the string which will prevent any subsequent strings from recieving the styles. Defaults to True

True

Returns:

Name Type Description
str

The colorized string

Source code in arc/color.py
def colorize(string: str, *codes: str, clear: bool = True):
    """Applies colors / effects to an entire string

    Args:
        string (str): String to colorize
        *codes (str): colors / effects to apply to the strin
        clear (bool): Whether or not to append `effects.CLEAR`
            to the end of the string which will prevent any
            subsequent strings from recieving the styles. Defaults
            to True

    Returns:
        str: The colorized string
    """
    return f"{''.join(str(code) for code in codes)}{string}{effects.CLEAR if clear else ''}"