Created
December 27, 2015 07:57
-
-
Save prinsss/689a1da4b515aa682d4b to your computer and use it in GitHub Desktop.
ascii_art.py
This file contains 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
#!/usr/bin/env python | |
# -*- coding=utf-8 -*- | |
art_dict = {} | |
def getArtLines(ascii): | |
lineNumberStart = (ascii - 64 - 1)*3 + 1 | |
result = [] | |
lines = ['┌─┐', '├─┤', '┴ ┴', '┬┐ ', '├┴┐', '┴─┘', '┌─┐', '│ ', '└─┘', '┬─┐', '│ │', '┴─┘', '┌─┐', '├┤ ', '└─┘', '┬─┐', '├┤ ', '┴ ', '┌─┐', '│ ┐', '└─┘', '┬ ┬', '├─┤', '┴ ┴', ' ┬ ', ' │ ', ' ┴ ', ' ┬ ', ' │ ', '└┘ ', '┐┌ ', '├┴┐', '┴ ┴', '┬ ', '│ ', '┴─┘', '┌┬┐', '│││', '┴ ┴', '┌┐┌', '│││', '┘└┘', '┌─┐', '│ │', '└─┘', '┬─┐', '├─┘', '┴ ', '┌─┐', '│ │', '└─┴', '┬─┐', '├┬┘', '┴└─', '┌─┐', '└─┐', '└─┘', '┌┬┐', ' │ ', ' ┴ ', '┐ ┌', '│ │', '└─┘', '┐ ┌', '└┐│', ' └┘', '┬ ┬', '│││', '└┴┘', '┬ ┬', '└┬┘', '┴ ┴', '┬ ┬', '└─┤', '└─┘', '┌─┐', '┌─┘', '└─┘'] | |
for i in range(3): | |
result.append(lines[lineNumberStart+i-1]) | |
return result | |
# Init dictionary to store ascii art | |
for ascii in range(65,91): | |
char = chr(ascii) | |
art_dict[char] = getArtLines(ascii) | |
art_dict[" "] = [' ', ' ', ' '] # for space | |
str = input("Type what you want to generate character ascii art:").upper() | |
artLines = ["", "", ""] | |
# parse user input | |
for s in str: | |
# combine each lines | |
artLines[0] += (art_dict[s][0]) | |
artLines[1] += (art_dict[s][1]) | |
artLines[2] += (art_dict[s][2]) | |
# echo combined each line | |
for i in range(3): | |
print(artLines[i]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment