Created
November 4, 2018 05:26
-
-
Save oskay/f038d774c4b49867872c286665ee3a04 to your computer and use it in GitHub Desktop.
A python program to generate a basic program that can display your name on your 2018 supercon badge.
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/env python | |
# -*- encoding: utf-8 -#- | |
''' | |
Process ASCII art and generate basic program to draw it as | |
ascii art for hackaday 2018 superconference badge | |
Exports a basic program that you can upload to the badge. | |
License: Public domain!!! | |
By Windell Oskay, Evil Mad Scientist Laboratories | |
www.evilmadscientist.com | |
''' | |
from random import shuffle | |
def do_the_thing(): | |
# Put your text below. | |
# Should be within 40 chars wide by 20 chars tall. | |
# Use the number "8" for anything that will be a pixel. | |
# Your name may vary! | |
the_string = ''' | |
8 8 888 8 8 8888 8888 8 8 | |
8 8 8 8 88 8 8 8 8 8 8 | |
8 8 8 8 8 8 8 8 8 8 888 8 8 | |
88 88 8 8 88 8 8 8 8 8 | |
8 8 888 8 8 8888 8888 8888 8888 | |
888 8888 8 8 888 8 8 | |
8 8 8 8 8 8 8 8 8 | |
8 8 888 888 88888 8 8 | |
8 8 8 8 8 8 8 8 | |
888 8888 8 8 8 8 8''' | |
print "10 clrscr" | |
print "20 let x = rnd 14" | |
print "25 x = x + 1" | |
print "30 let y = 0" | |
print "40 color x,y" | |
print "110 gosub 500" | |
print "120 wait 2000" | |
print "400 goto 20" | |
coord_list = [] | |
i = 500 | |
print str(i) + " termt 1" | |
i = i + 2 | |
for lineNum, line in enumerate(the_string.splitlines()): | |
for charNum, char in enumerate(line): | |
if char == "8": | |
coord = [charNum, lineNum] | |
coord_list.append(coord) | |
clen = len(coord_list) | |
rand_list = [rand_index for rand_index in range(clen)] | |
shuffle(rand_list) | |
for index in rand_list: | |
the_coord = coord_list[index] | |
print str(i) + " setxy " + str(the_coord[0]) + ", " + str(the_coord[1]) | |
i = i + 2 | |
print str(i) + " chr 219" | |
i = i + 2 | |
print str(i) + " wait 5" | |
i = i + 2 | |
print str(i) + " setxy " + str(0) + ", " + str(0) | |
i = i + 2 | |
print str(i) + " termt 0" | |
i = i + 2 | |
print str(i) + " wait 500" | |
i = i + 2 | |
print str(i) + " return" | |
if __name__ == '__main__': | |
do_the_thing() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment