Last active
August 29, 2015 14:06
-
-
Save nyango/863a8e02a3c912e412f8 to your computer and use it in GitHub Desktop.
A easy script which converts a char-array to a pixel art on shell(ANSI color code).
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
#!/usr/bin/python | |
# coding: utf-8 | |
import sys | |
argvs = sys.argv | |
f = open(argvs[1]) | |
line = f.readline() | |
dict = {"A":"^[[30;7m ", | |
"B":"^[[31;7m ", | |
"C":"^[[32;7m ", | |
"D":"^[[33;7m ", | |
"E":"^[[34;7m ", | |
"F":"^[[35;7m ", | |
"G":"^[[36;7m ", | |
"H":"^[[37;7m ", | |
"\n":"^[[0m"} | |
while line: | |
chars = list(line) | |
line = f.readline() | |
print "".join(map(lambda x: dict[x], chars)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The character
^[
might not be expressed correctly.So, generate it in this way
$ echo "\033[30;7m " > hoge