state
This commit is contained in:
22
pixelflut.py
22
pixelflut.py
@@ -4,11 +4,11 @@ import PIL
|
||||
from PIL import Image, ImageColor
|
||||
import argparse
|
||||
import threading
|
||||
from sys import exit
|
||||
|
||||
sizex = 800
|
||||
sizey = 600
|
||||
|
||||
|
||||
XSPLIT = 5
|
||||
YSPLIT = 5
|
||||
|
||||
@@ -22,13 +22,19 @@ framebuffer = Image.new("RGBA", (sizex, sizey), (0,0,0,0))
|
||||
parser = argparse.ArgumentParser()
|
||||
mode = parser.add_mutually_exclusive_group(required=True)
|
||||
mode.add_argument("--color")
|
||||
mode.add_argument("--image")
|
||||
mode.add_argument("--image", metavar="FILENAME")
|
||||
parser.add_argument("--host", default="fsi-hase.fsmi.uni-karlsruhe.de")
|
||||
parser.add_argument("--port", "-p", type=int, default="3141")
|
||||
parser.add_argument("--dumb", action="store_true")
|
||||
parser.add_argument("--yoffset", default=19, type=int)
|
||||
parser.add_argument("--repeat", action="store_true")
|
||||
parser.add_argument("--animate", action="store_true")
|
||||
parser.add_argument("--xoffset", default=0, type=int)
|
||||
effect = parser.add_mutually_exclusive_group(required=False)
|
||||
effect.add_argument("--repeat", action="store_true")
|
||||
effect.add_argument("--animate", type=int, const=5, nargs='?', metavar="STEPSIZE")
|
||||
parser.add_argument("--bounce", action="store_true")
|
||||
|
||||
if args.bounce and not args.animate:
|
||||
print("--bounce requires --animate")
|
||||
exit(1)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -39,8 +45,6 @@ class DrawThread(threading.Thread):
|
||||
xto = self._kwargs["xto"]
|
||||
yto = self._kwargs["yto"]
|
||||
|
||||
#print(xfrom, xto, yfrom, yto)
|
||||
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.connect((args.host, args.port))
|
||||
buf = bytearray()
|
||||
@@ -50,7 +54,7 @@ class DrawThread(threading.Thread):
|
||||
for y in range(yfrom,yto):
|
||||
if framebuffer.getpixel((x,y))[3] != 0:
|
||||
value = b"%02X%02X%02X%02X"%framebuffer.getpixel((x,y))
|
||||
buf += b"PX %d %d %b\n"%(x,y,value)
|
||||
buf += b"PX %d %d %b\n"%(x+args.xoffset,y+args.yoffset,value)
|
||||
|
||||
s.send(buf)
|
||||
while args.repeat:
|
||||
@@ -123,7 +127,7 @@ elif args.image:
|
||||
dirtybox = (0,0,min(image.size[0], sizex),min(image.size[1], sizey))
|
||||
draw()
|
||||
while args.animate:
|
||||
coordinates = (coordinates[0] + 5, coordinates[1] + 5)
|
||||
coordinates = (coordinates[0] + args.animate, coordinates[1] + args.animate)
|
||||
if coordinates[0] >= sizex or coordinates[1] >= sizey:
|
||||
break
|
||||
dirtybox = (*coordinates, min(image.size[0]+coordinates[0], sizex), min(image.size[1]+coordinates[1], sizey))
|
||||
|
||||
Reference in New Issue
Block a user