Browse Source

added image scrolling support

feature/balanceutils
Fr3deric 8 years ago committed by Frederic
parent
commit
b4fd412675
  1. 31
      scrolltext.py

31
scrolltext.py

@ -19,8 +19,7 @@ def create_image(text):
return img return img
def create_scrolltext(text, delay, color): def scroll_image(img, delay, color):
img = create_image(text)
w, h = img.size w, h = img.size
@ -39,23 +38,37 @@ def create_scrolltext(text, delay, color):
return anim return anim
def create_scrolltext(text, delay, color):
img = create_image(text)
return scroll_image(img, delay, color)
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Generate scrolltext BML files') parser = argparse.ArgumentParser(description='Generate scrolltext BML files')
parser.add_argument('-d', '--delay', type=int, default=100) parser.add_argument('-d', '--delay', type=int, default=100)
parser.add_argument('-c', '--color', default='#ffffff') parser.add_argument('-c', '--color', default='#ffffff')
parser.add_argument('-i', '--image', type=str)
parser.add_argument('-t', '--text', type=str)
parser.add_argument('output_file') parser.add_argument('output_file')
parser.add_argument('text')
args = parser.parse_args() args = parser.parse_args()
if args.image is not None and args.text is not None:
print('--image and --text are exclusive', file=sys.stderr)
sys.exit(1)
if args.color.startswith('#'): if args.color.startswith('#'):
args.color = args.color[1:] args.color = args.color[1:]
r = int(args.color[0:2], 16)/255 r = int(args.color[0:2], 16)//255
g = int(args.color[2:4], 16)/255 g = int(args.color[2:4], 16)//255
b = int(args.color[4:6], 16)/255 b = int(args.color[4:6], 16)//255
col = (r, g, b) col = (r, g, b)
anim = create_scrolltext(args.text, args.delay, col) if args.text:
writebml.writeBml(anim, 'scrolltext.bml') anim = create_scrolltext(args.text, args.delay, col)
elif args.image:
img = Image.open(args.image)
img.convert(mode='RGB')
anim = scroll_image(img, args.delay, col)
writebml.writeBml(anim, args.output_file)
''' '''
num = 10 num = 10

Loading…
Cancel
Save