diff --git a/8x13-ISO8859-1.pil b/8x13-ISO8859-1.pil new file mode 100644 index 0000000..6d201d5 Binary files /dev/null and b/8x13-ISO8859-1.pil differ diff --git a/scrolltext.py b/scrolltext.py new file mode 100644 index 0000000..4ea5040 --- /dev/null +++ b/scrolltext.py @@ -0,0 +1,83 @@ +#!/usr/bin/python3 + +import sys +import colorsys +import blup.animation +import blup.frame +import writebml +import random +import argparse +from PIL import Image, ImageDraw, ImageFont + +def create_image(text): + font = ImageFont.load('8x13-ISO8859-1.pil') + w, h = font.getsize(text) + + img = Image.new('RGB', (w+2*22, 16)) + draw = ImageDraw.Draw(img) + draw.text((22, (16-h)//2), text, font=font) + + return img + +def create_scrolltext(text, delay, color): + img = create_image(text) + + w, h = img.size + + dim = blup.frame.FrameDimension(22, 16, 256, 3) + anim = blup.animation.Animation(dim) + for c in range(w-dim.size()[0]): + frame = blup.animation.AnimationFrame(dim, delay) + for x in range(dim.size()[0]): + for y in range(dim.size()[1]): + pixcol = img.getpixel((x+c, y)) + pixcol = (pixcol[0]*color[0], + pixcol[1]*color[1], + pixcol[2]*color[2]) + frame.setPixel(x, y, pixcol) + anim.addFrame(frame) + + return anim + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Generate scrolltext BML files') + parser.add_argument('-d', '--delay', type=int, default=100) + parser.add_argument('-c', '--color', default='#ffffff') + parser.add_argument('output_file') + parser.add_argument('text') + + args = parser.parse_args() + if args.color.startswith('#'): + args.color = args.color[1:] + r = int(args.color[0:2], 16)/255 + g = int(args.color[2:4], 16)/255 + b = int(args.color[4:6], 16)/255 + col = (r, g, b) + + anim = create_scrolltext(args.text, args.delay, col) + writebml.writeBml(anim, 'scrolltext.bml') + +''' +num = 10 +horiz = True +delay = 100 +for i in range(num): + newcolor = getRandomColor(dim.depth - 1) + horiz = not horiz + if horiz: + for x in range(dim.size()[0]): + newframe = blup.animation.AnimationFrame(dim, delay) + for y in range(dim.size()[1]): + newframe.setPixel(x, y, newcolor) + newanim.addFrame(newframe) + else: + for y in range(dim.size()[1]): + newframe = blup.animation.AnimationFrame(dim, delay) + for x in range(dim.size()[0]): + newframe.setPixel(x, y, newcolor) + newanim.addFrame(newframe) + + + +writebml.writeBml(newanim, '/tmp/colorwischer.bml') +'''