From ec4bd8547711c86d92cf1eafaf108d3feaad7d6c Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Wed, 8 Mar 2023 02:00:19 -0500 Subject: [PATCH] [+] Add padding and color options to print_ascii --- tngame/telnet.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tngame/telnet.py b/tngame/telnet.py index a36b363..f72e3d1 100644 --- a/tngame/telnet.py +++ b/tngame/telnet.py @@ -167,12 +167,19 @@ async def shell(reader: TelnetReaderUnicode, writer: TelnetWriterUnicode): return height, width # Print ascii art - def print_ascii(asc: str, x: int, y: int): + def print_ascii(asc: str | AsciiArt, x: int, y: int, color: RGB | None = None, pad: int = 0): + if isinstance(asc, AsciiArt): + asc = asc.art asc = asc.strip('\n') # Write ascii line by line for i, line in enumerate(asc.splitlines()): writer.write(f'\x1b[{y + i};{x}H') + writer.write(' ' * pad) + if color is not None: + writer.write(color.to_ansi_rgb()) writer.write(line) + writer.write(' ' * pad) + writer.write('\x1b[0m') # Clear the screen def clear():