def TextGenerator(text,startTime,endTime,startX,endX,yPos,scale,opacity,red,green,blue,typeE):
delay = 0
offsetX = 0
letterX = 0
for index in text:
if (index != " "):
letter = index
if (letter.isupper() == True):
letter = letter.title() + "1"
if (letter == "'"):
letter = "ap"
elif (letter == "-"):
letter = "da"
Text = osbject("11t-fonts\\" + letter + ".png","Foreground","Centre",320,240)
baseWidth,baseHeight = get_image_size("D:\\osu\\Songs\\i_touch_myself\\11t-fonts\\" + letter + ".png")
letterX = offsetX + (baseWidth * 0.5)
if (typeE == "Random"):
randX = random.randint(-100,750)
randY = random.randint(-50,500)
Text.fade(0,(startTime - 500) + delay,startTime + delay,0,opacity)
Text.move(1,(startTime - 500) + delay,startTime + delay,randX,randY,round(letterX) + startX,yPos)
Text.move(1,startTime + delay,startTime + delay + abs((startTime - endTime)),round(letterX) + startX,yPos,round(letterX) + endX,yPos)
elif (typeE == ""):
Text.fade(0,startTime + delay,startTime + delay + abs((startTime - (endTime - 500))),0,opacity)
Text.move(1,startTime + delay,startTime + delay + abs((startTime - endTime)),round(letterX) + startX,yPos,round(letterX) + endX,yPos)
Text.para(0,startTime + delay,startTime + delay,"A")
Text.scale(0,startTime + delay,startTime + delay,scale,scale)
Text.fade(0,startTime + delay + abs((startTime - (endTime - 500))),startTime + delay + abs((startTime - endTime)),opacity,0)
Text.colour(0,startTime + delay,startTime + delay,red,green,blue,red,green,blue)
delay += 25
offsetX += baseWidth
elif (index == " "):
offsetX += 50 * scale
return;
function for get_image_size
def get_image_size(fname):
'''Determine the image type of fhandle and return its size.
from draco'''
with open(fname, 'rb') as fhandle:
head = fhandle.read(24)
if len(head) != 24:
return
if imghdr.what(fname) == 'png':
check = struct.unpack('>i', head[4:8])[0]
if check != 0x0d0a1a0a:
return
width, height = struct.unpack('>ii', head[16:24])
elif imghdr.what(fname) == 'gif':
width, height = struct.unpack('<HH', head[6:10])
elif imghdr.what(fname) == 'jpeg':
try:
fhandle.seek(0) # Read 0xff next
size = 2
ftype = 0
while not 0xc0 <= ftype <= 0xcf:
fhandle.seek(size, 1)
byte = fhandle.read(1)
while ord(byte) == 0xff:
byte = fhandle.read(1)
ftype = ord(byte)
size = struct.unpack('>H', fhandle.read(2))[0] - 2
# We are at a SOFn block
fhandle.seek(1, 1) # Skip `precision' byte.
height, width = struct.unpack('>HH', fhandle.read(4))
except Exception: #IGNORE:W0703
return
else:
return
return width, height
Example function call
TextGenerator("I Love Myself",967,2376,50,100,200,0.3,1,0,128,255,"Random")
TextGenerator("I want you to love me",2376,3608,50,100,200,0.3,1,0,128,255,"Random")
TextGenerator("When i'm feeling down",3784,5017,50,100,200,0.3,1,0,128,255,"Random")
TextGenerator("I want you above me",5193,6425,50,100,200,0.3,1,0,128,255,"Random")
TextGenerator("I searched myself",6601,7834,50,100,200,0.3,1,0,128,255,"Random")
TextGenerator("I want you to find me",8010,9242,50,100,200,0.3,1,0,128,255,"Random")
TextGenerator("I forget myself",9242,12411,50,100,200,0.3,1,0,128,255,"Random")
TextGenerator("I want you to remind me",10474,12411,50,100,300,0.3,1,0,128,255,"Random")