base#
This module defines an abstract base formatter.
Formats
Refer to the Formats documentation to learn about the supported output formats.
BaseFormatter #
An abstract base formatter.
Attributes:
| Name | Type | Description |
|---|---|---|
colorize | bool | Whether to color the text. |
vcolor | Callable | The vectorized implementation of the |
__call__(self, text_matrix, image, resample) special #
Applies formatting and colorization on the text_matrix and returns a single string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text_matrix | numpy.ndarray | The subject text matrix, with | required |
image | PIL.Image.Image | The subject image. | required |
resample | int | The resampling filter. | required |
Returns:
| Type | Description |
|---|---|
str | The formatted string of text with color (if specified). |
Source code in picharsso/format/base.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
__init__(self, colorize=False) special #
Initialization method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colorize | Option[bool] | Whether to color the text. | False |
Source code in picharsso/format/base.py
31 32 33 34 35 36 37 38 39 40 | |
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 | required |
Returns:
| Type | Description |
|---|---|
str | The colored text. |
Source code in picharsso/format/base.py
79 80 81 82 83 84 85 86 87 88 89 90 | |
set(self, colorize=None) #
Sets attributes of the formatter instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colorize | Optional[bool] | Sets | None |
Source code in picharsso/format/base.py
120 121 122 123 124 125 126 127 | |
translate(text_matrix) staticmethod #
Applies translatations to text_matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text_matrix | numpy.ndarray | The subject text matrix, with | required |
Returns:
| Type | Description |
|---|---|
numpy.ndarray | The translated text_matrix. |
Source code in picharsso/format/base.py
92 93 94 95 96 97 98 99 100 101 102 103 104 | |
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 | required |
Returns:
| Type | Description |
|---|---|
str | The formatted string of text art. |
Source code in picharsso/format/base.py
106 107 108 109 110 111 112 113 114 115 116 117 118 | |