Skip to content

Instantly share code, notes, and snippets.

@nyango
Last active August 29, 2015 14:06
Show Gist options
  • Save nyango/863a8e02a3c912e412f8 to your computer and use it in GitHub Desktop.
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).
#!/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))
@nyango
Copy link
Author

nyango commented Sep 15, 2014

The character ^[ might not be expressed correctly.
So, generate it in this way
$ echo "\033[30;7m " > hoge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment