/
TwilightPrincessWii.py
51 lines (51 loc) · 1.46 KB
/
TwilightPrincessWii.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from PIL import ImageDraw, Image
import glob, os, sys, re
def convert(a):
if(a==" "):
return "space"
if(a=="."):
return "period"
if(a==","):
return "comma"
if(a==";"):
return "semicolon"
if(a==":"):
return "colon"
if(a=="!"):
return "exclamation"
a = re.sub("[^a-zA-Z]",'',a)
if(a==""):
return "null"
return a
def translate(name,text):
path = sys.path[0]+"\TP\\"
im = Image.open(path+"space.bmp")
line = text.split("@")
length = 0
for i in line:
if len(i) > length:
length = len(i)
height = len(line)
length *= 42
height *= 40
diagram = Image.new("RGBA",(length,height),(255,255,255))
longest = 0
for i in range(0,len(line)):
letters = []
pos = 0
for j in range(0,len(line[i])):
temp = convert(line[i][j])
if(temp != "null"):
letters.append(temp)
for j in range(0,len(letters)):
k = len(letters)-j-1
im = Image.open(path+letters[k]+".bmp")
(le,up,ri,bo) = im.getbbox()
diagram.paste(im,(pos,i*40,pos+ri,(i+1)*40))
pos+=ri+1
if(pos > longest):
longest = pos
diagram = diagram.crop((0,0,longest-1,len(line)*40))
diagram.save(path+name+".png")
diagram.show()
translate("lol","if you can read this, then you are@a massive nerd, and i love you.@long live the twilight princess!")