mcfonts.utils.colors

ANSI color escapes. The global variable USE_COLORS controls whether these will be used in outputs.

Module Contents

Functions

color_number(number)

Given number, return a colorized and pretty-print version of that number.

Attributes

BLACK_BACK

BLACK_FORE

BLUE_BACK

BLUE_FORE

BRIGHT

CYAN_BACK

CYAN_FORE

DIM

GREEN_BACK

GREEN_FORE

MAGENTA_BACK

MAGENTA_FORE

RED_BACK

RED_FORE

RESET_ALL

RESET_BACK

RESET_FORE

USE_COLORS

Whether to include ANSI color escapes in some prints.

WHITE_BACK

WHITE_FORE

YELLOW_BACK

YELLOW_FORE

mcfonts.utils.colors.BLACK_BACK
mcfonts.utils.colors.BLACK_FORE
mcfonts.utils.colors.BLUE_BACK
mcfonts.utils.colors.BLUE_FORE
mcfonts.utils.colors.BRIGHT
mcfonts.utils.colors.CYAN_BACK
mcfonts.utils.colors.CYAN_FORE
mcfonts.utils.colors.DIM
mcfonts.utils.colors.GREEN_BACK
mcfonts.utils.colors.GREEN_FORE
mcfonts.utils.colors.MAGENTA_BACK
mcfonts.utils.colors.MAGENTA_FORE
mcfonts.utils.colors.RED_BACK
mcfonts.utils.colors.RED_FORE
mcfonts.utils.colors.RESET_ALL
mcfonts.utils.colors.RESET_BACK
mcfonts.utils.colors.RESET_FORE
mcfonts.utils.colors.USE_COLORS = True

Whether to include ANSI color escapes in some prints. Set this to False if your console/terminal does not support ANSI color escapes.

mcfonts.utils.colors.WHITE_BACK
mcfonts.utils.colors.WHITE_FORE
mcfonts.utils.colors.YELLOW_BACK
mcfonts.utils.colors.YELLOW_FORE
mcfonts.utils.colors.color_number(number)

Given number, return a colorized and pretty-print version of that number.

Note

If mcfonts.colors.USE_COLORS is False, color won't be applied.

If number is negative, it will be in red. If number is positive, it will be in green. If number is zero, it will have no colors.

>>> color_number(4)
'\x1b[32m+4\x1b[39m'
>>> color_number(-4)
'\x1b[31m-4\x1b[39m'
>>> color_number(-39924)
'\x1b[31m-39,924\x1b[39m'
Parameters:
number : float | int

The number, positive or negative.

Returns:

A string representing number with ANSI color codes.

Return type:

str


Last update: 2023 November 30