Created
April 4, 2019 08:12
-
-
Save rawlik/7323e9c244af08f4b64a66b421fe8703 to your computer and use it in GitHub Desktop.
Colouring ASCII art in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# use color ANSI escape sequences on windows | |
if os.name == "nt": | |
import colorama | |
colorama.init() | |
def welcome(): | |
BLACK = "\033[0;30m" | |
RED = "\033[0;31m" | |
GREEN = "\033[0;32m" | |
YELLOW = "\033[0;33m" | |
BLUE = "\033[0;34m" | |
MAGENTA = "\033[0;35m" | |
CYAN = "\033[0;36m" | |
WHITE = "\033[0;37m" | |
RESET = "\033[0;0m" | |
BOLD = "\033[;1m" | |
def bold(c): | |
return c.replace("[0", "[1") | |
# http://patorjk.com/software/taag/#p=display&h=3&v=0&f=Graffiti&t=Bunker5%0A | |
# modified manually | |
b5art = r""" | |
__________ __ ________ ________ ___ ______________________________ | |
\______ \__ __ ____ | | __ ___________| ____/ / _____/| | \______ \_ ____\__ ___/ | |
| | _/ | \/ \| |/ // __ \_ __ \____ \ / \ ___| | ______ | | _/ \ | | | |
| | \ | / | \ <\ ___/| | \/ \ \ \_\ | | /_____/ | | \ \____| | | |
|________/____/|___|__/__|__\\____\|__| /________/ \________|___| |________/\________/|____| | |
""" | |
b5art_color = r""" | |
C__________ __ G ________ M ________ ___ M______________________________ | |
C\______ \__ __ ____ | | __ __________G| ____/ M / _____/| | M\______ \_ ____\__ ___/ | |
C | | _/ | \/ \| |/ // __ \_ __G\____ \ M/ \ ___| |C ______M| | _/ \ | | | |
C | | \ | / | \ <\ ___/| | G/ \ M\ \_\ | |C/_____/M| | \ \____| | | |
C |________/____/|___|__/__|__\\____\|__|G/________/ M \________|___| M|________/\________/|____| | |
""" | |
for line, cline in zip(b5art, b5art_color): | |
for c, colour in zip(line, cline): | |
print(c, end="") | |
cd = {"C": CYAN, "M": MAGENTA, "G": GREEN, "Y": YELLOW} | |
if colour in cd.keys(): | |
print(bold(cd[colour]), end="") | |
print(RESET) | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment