def printline(input): debug(2, "Writing line '" + input + "'") writeraw("[-]") glob.bitcounter = 0 for x in range(0, len(input)): printchar(input[x]) printchar('\n')
def portrait(imagepath): debug(3, "Writing portrait image at '"+imagepath+"'") if not os.path.exists(imagepath): print("ERROR: file not found: "+imagepath) image=asciify.runner(imagepath) writeraw("[-]") glob.bitcounter=0 writeraw(">") storechar(chr(27)) writeraw(">") storechar('[') writeraw(">") storechar('1') writeraw(">") storechar('C') writeraw("<<<<") printtext(chr(27)+"[f") for x in range(0,len(image)): if (image[x]=='@'): writeraw(">.>.>.>.<<<<") else: printchar(image[x]) if (x==138): printtext(chr(27)+"E") writeraw(">[-]>[-]>[-]>[-]<<<<") flushcode()
def image(image): debug(3, "Writing image at '" + image + "'") if not os.path.exists(image): print("ERROR: file not found: " + image) printtext(chr(27) + "[f") printtext(asciify.runner(image)) skipline(6) flushcode()
def preimage(path): debug(3, "Writing prerendered image at '" + path + "'") if not os.path.exists(path): print("ERROR: file not found: " + path) f = open(path, "r") printtext(chr(27) + "[f") printtext(f.read()) f.close flushcode()
def dialogue(speaking, text): debug(3, "Writing dialogue for " + speaking + ": '" + text + "'") cleardialogue() printtext(chr(27) + "[43;0H") if not (speaking == ""): printline('+' + ('-' * (len(speaking) + 2)) + '+') printline("| " + speaking + " |") else: skipline(2) printline('+' + ('-' * 148) + '+') printtext(linecorrect(text)) writeraw(">,[-]<")
def printchar(input): try: if sys.argv[2] == "--char": debug(1, "Writing character '"+input+"'") except: '' while (ord(input) != glob.bitcounter): if (ord(input)>glob.bitcounter): writeraw("+") glob.bitcounter+=1 else: writeraw("-") glob.bitcounter-=1 writeraw(".")
def printframe(path): debug(3, "Writing prerendered image at '" + path + "'") if not os.path.exists(path): print("ERROR: file not found: " + path) f = open(path, "r") printtext(chr(27) + "[f") writeraw("[-]") for c in f.read(): if c == 'b': writeraw("<.>") writeraw("++++++[-]") #Idle elif c == 'w': writeraw(">[.>]<[<]") else: glob.bitcounter = 0 printchar(c) writeraw("[-]") f.close flushcode()
def flushcode(): debug(1, "Flushing code...") glob.f.write(glob.output) glob.output=""
def printtext(input): debug(2, "Writing text '"+input+"'") writeraw("[-]") glob.bitcounter=0 for x in range(0,len(input)): printchar(input[x])
def storechar(input): debug(1, "Storing character '"+input+"'") glob.output+="[-]"+('+'*ord(input))