Skip to content

ansi#

This module defines a formatter for the ANSI coloring scheme.

AnsiFormatter #

A formatter for the ANSI coloring scheme.

Inherits BaseFormatter.

color(text, color) staticmethod #

Applies color to a string of text.

Parameters:

Name Type Description Default
text str

The subject text.

required
color Tuple[int, int, int]

The RGB value for the color.

required

Returns:

Type Description
str

The colored text.

Source code in picharsso/format/ansi.py
15
16
17
@staticmethod
def color(text, color):
    return f"{fg(*color)}{text}{fg.rs}"

translate(text_matrix) staticmethod #

Applies translatations to text_matrix.

Parameters:

Name Type Description Default
text_matrix numpy.ndarray

The subject text matrix, with shape = (<height>, <width>), and dtype = str.

required

Returns:

Type Description
numpy.ndarray

The translated text_matrix.

Source code in picharsso/format/ansi.py
19
20
21
@staticmethod
def translate(text_matrix):
    return text_matrix

unify(text_matrix) staticmethod #

Formats a text_matrix into a single string.

Parameters:

Name Type Description Default
text_matrix numpy.ndarray

The subject text matrix, with shape = (<height>, <width>), and dtype = str.

required

Returns:

Type Description
str

The formatted string of text art.

Source code in picharsso/format/ansi.py
23
24
25
@staticmethod
def unify(text_matrix):
    return "\n".join(["".join(row) for row in text_matrix])