RichFiglet reference¶
The RichFiglet class is designed to be fully automatic - the only method you need to use is the constructor. Its not dynamic and cannot be modified after the fact - if you want to change the settings, you must create a new RichFiglet object.
There are 3 internal utility methods that are exposed for convenience. There's no reason you should need to use them, but they are available if you want to.
__init__(text, font='standard', width=None, colors=None, horizontal=False, quality=None, animation=None, fps=None, remove_blank_lines=False, border=None, border_padding=(1, 2), border_color=None, dev_mode=False)
¶
Create a RichFiglet object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The text to render. |
required |
font
|
ALL_FONTS
|
The font to use. Defaults to 'standard'. |
'standard'
|
width
|
int | None
|
The width of the rendered text. If None, will use the terminal width. |
None
|
colors
|
list[str] | None
|
A list of colors to use for gradients or animations. Each color can be a name, hex code, or RGB triplet. If None, no gradient or animation will be applied. For available named colors, see: https://rich.readthedocs.io/en/stable/appendix/colors.html |
None
|
horizontal
|
bool
|
Make the gradient render horizontally . This will be ignored if |
False
|
quality
|
int | None
|
The number of steps to blend between two colors. Defaults to None, which enables
auto mode. Auto mode sets the quality based on the width or height of the rendered banner.
One exception: if |
None
|
animation
|
ANIMATION_TYPE | None
|
|
None
|
fps
|
float | None
|
Frames per second for the animation. This is a float so that you can set it to values such as 0.5 if you desire. |
None
|
remove_blank_lines
|
bool
|
When True, all blank lines from the inside of the rendered ASCII art will be removed. Some fonts have gaps between the lines- this will remove them and compress the banner down to the minimum size. |
False
|
border
|
BOX_STYLES | None
|
The box style to use for the border. Can be any of the box styles from Rich. Note that border is an argument because it is necessary for the RichFiglet to take the border and padding into account when rendering. It is recommended to use the border argument in the constructor, rather than adding a border afterwards. |
None
|
border_padding
|
tuple[int, int]
|
The padding to use for the border. Defaults to (1, 2) which is (top/bottom, left/right). |
(1, 2)
|
border_color
|
str | None
|
The color of the border. Can be a name, hex code, or RGB triplet. |
None
|
dev_mode
|
bool
|
When True, will print debug information to the console. |
False
|
get_terminal_width()
¶
Get the terminal size.
Returns:
Type | Description |
---|---|
int | None
|
The width of the terminal in characters, or None if it cannot be determined. |
make_gradient(color1, color2, steps)
¶
Generate a smooth gradient between two colors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
color1
|
Color
|
Starting color (can be name, hex, rgb) |
required |
color2
|
Color
|
Ending color (can be name, hex, rgb) |
required |
steps
|
int
|
Number of colors in the gradient |
required |
Returns:
Type | Description |
---|---|
list[Color]
|
A list of Rich Color objects representing the gradient. |
parse_color(color)
¶
Parse a color string into a Color object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
color
|
str
|
The color string to parse. Can be a name, hex code, or RGB triplet. |
required |
Returns:
Type | Description |
---|---|
Color
|
A Rich Color object representing the parsed color. |