From 62c29157e14f26738b06e9a12929546f9625dcd9 Mon Sep 17 00:00:00 2001 From: klonfish Date: Tue, 27 Dec 2016 02:15:45 +0100 Subject: [PATCH] Added scrolltext generator --- 8x13-ISO8859-1.pil | Bin 0 -> 5143 bytes scrolltext.py | 83 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 8x13-ISO8859-1.pil create mode 100644 scrolltext.py diff --git a/8x13-ISO8859-1.pil b/8x13-ISO8859-1.pil new file mode 100644 index 0000000000000000000000000000000000000000..6d201d50617de26578b7886544744e529466dc2b GIT binary patch literal 5143 zcmeI#ArGWx6h>ioYbKjaf+VYOi=?R`sbP}}np7Yvkf;XLA}WwbBoc{4B9SAJBS(%L zIi|_D_Dn?+&M&Cg&%k|1UO{dym-6Rde*5G1KR^BW@A>|RA3y!{_1CYTf>Xfx`!B8^ z-*;Tk2YWvcWg!;HA}p50SRzZXRF-0yEW>hHjuo;3D`h2C$ttXt)mS5IuvXS$ovg!p zS&t2}0UKo_HpwPzmd)5ATd-BOVw-HkF0u=@%XaK4yJ9!l4ZF+k*hBWfp0X$QlD&f9 zLvS?e;KNCF!a`YyMY0HsWigh>5-gRaSSHJ`T$W>ntiVcHiB+-+t7SFT$QrDbwOA+X zuwK?RN>t#JQ$Odebjo2icuvs=^i)_JG*@|tl4ZFxL*e=_#tL%#1WH;VlUY%II~k8W*zmJ9rI`> zER=;RN>t#JQ$Odeb zjo2icuvs=^i)_JG*@|tl4ZFxL*e=_#tL%#1WH;X2(3*J3o@W^JCdNKanL^Doe3UmSMRp#|l}2 wm9i46WEED+YOIkpSSxF>PS#<)tj7k~fQ_;dn`9F<%VunmE!Zksu`T%W4~na>lK=n! literal 0 HcmV?d00001 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') +'''