diff --git a/hyphae_pixelflut.py b/hyphae_pixelflut.py index 07d82f1..3b7f542 100644 --- a/hyphae_pixelflut.py +++ b/hyphae_pixelflut.py @@ -6,6 +6,7 @@ import random import threading import time import socket +import colorsys from utils import circle_fill from utils import random_color #from pixelflut import surface_to_pixelflut @@ -20,6 +21,8 @@ hitmap = list() DRAW_MAP = None +start_hue = random.uniform(0, 1) + SERVER_IP = '192.168.178.75' #SERVER_IP = '127.0.0.1' SERVER_PORT = 1234 @@ -35,23 +38,24 @@ def surface_to_pixelflut(): pixels = data.hex() x, y = 0, 0 #to_send = list() - pxstr = '' - for hexpx in chunker(pixels, 8): - if x > 1919: - x = 0 - y += 1 - x += 1 - if hexpx[6:8] == '00': - continue - pxstr += f'PX {x} {y} {hexpx[:6]}\n' - #to_send.append(pxstr) with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: - s.connect((SERVER_IP, SERVER_PORT)) +# for chunk in chunker(pixels, 65536): + pxstr = '' + for hexpx in chunker(pixels, 8): + if x > 1919: + x = 0 + y += 1 + x += 1 + if hexpx[6:8] == '00': + continue + pxstr += f'PX {x} {y} {hexpx[:6]}\n' + #to_send.append(pxstr) + #for px in to_send: + # s.sendall(px.encode()) print('!! socket opened !!') - #for px in to_send: - # s.sendall(px.encode()) + s.connect((SERVER_IP, SERVER_PORT)) s.sendall(pxstr.encode()) - #print(f'sent {pxstr}') + #print(f'sent {pxstr}') print('!! transmission to pixelflut finished !!') @@ -185,6 +189,9 @@ def main(): # start_x = random.uniform(0.2, 0.8) # start_y = random.uniform(0.2, 0.8) start_r = 0.01 + r, g, b = colorsys.hsv_to_rgb(start_hue, 1.0, 1.0) + #r, g, b = random_color() + ctx.set_source_rgb(r, g, b) # start_angle = random.randint(0, 360) # branches.append(Branch(b, ctx, start_x, start_y, start_r, start_angle)) branches.append(Branch(0, ctx, 0.5, 0.4, start_r, 180)) @@ -206,7 +213,8 @@ def main(): for x in range(8): if subs == None: return - r, g, b = random_color() + r, g, b = colorsys.hsv_to_rgb(start_hue + x * 0.05, 1.0, 1.0) + #r, g, b = random_color() ctx.set_source_rgb(r, g, b) subs = grow_subs(ctx, subs, branches)