Created
September 2, 2016 19:12
-
-
Save robbi5/dca97c5800438c463861c8819015f33d to your computer and use it in GitHub Desktop.
cyber for pixelflut
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import socket | |
import random | |
#░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ | |
#░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ | |
#░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ | |
#░░░░░░░░░░░▓▓▓▓▓▓▓▓░░▐▓▓▌░░░░░▓▓▌░▐▓▓▓▓▓▓▓▓▓▄░░░▓▓▓▓▓▓▓▓▓▓▌░░▓▓▓▓▓▓▓▓▓▓░░░░░░░░░ | |
#░░░░░░░░░░▓▓▓█░░░░░░░░▓▓▓▄░░▄▓▓▓░░▐▓▓▓░░░░▓▓▓▌░░▓▓▓░░░░░░░░░░▓▓▓░░░░▐▓▓▌░░░░░░░░ | |
#░░░░░░░░░▓▓▓▀░░░░░░░░░░█▓▓▓▓▓▓█░░░▐▓▓▓░░░░▓▓▓▌░░▓▓▓░░░░░░░░░░▓▓▓▓▓▓▓▓▓▓▌░░░░░░░░ | |
#░░░░░░░░░▓▓▌░░░░░░░░░░░░░▓▓▓▓░░░░░▐▓▓▓▓▓▓▓▓▓▓░░░▓▓▓▓▓▓▌░░░░░░▓▓▓▀▓▓▓▓▀░░░░░░░░░░ | |
#░░░░░░░░░▓▓▓▄░░░░░░░░░░░░░▓▓▌░░░░░▐▓▓▓░░░░▓▓▓▌░░▓▓▓░░░░░░░░░░▓▓▓░░▓▓▓▄░░░░░░░░░░ | |
#░░░░░░░░░░▓▓▓▄░░░░░░░░░░░░▓▓▌░░░░░▐▓▓▓░░░░▓▓▓▌░░▓▓▓░░░░░░░░░░▓▓▓░░░▓▓▓▓░░░░░░░░░ | |
#░░░░░░░░░░░█▓▓▓▓▓▓▓░░░░░░░▓▓▌░░░░░▐▓▓▓▓▓▓▓▓▓▀░░░▓▓▓▓▓▓▓▓▓▓▌░░▓▓▓░░░░█▓▓▌░░░░░░░░ | |
#░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ | |
#░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ | |
#░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ | |
# for pixelflut (https://cccgoe.de/wiki/Pixelflut) - happened on #mrmcd16 | |
HOST = '185.55.125.36' | |
PORT = 1234 | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
sock.connect((HOST, PORT)) | |
send = sock.send | |
def pixel(x,y,r,g,b,a=255): | |
if a == 255: | |
send(('PX %d %d %02x%02x%02x\n' % (x,y,r,g,b)).encode()) | |
else: | |
send(('PX %d %d %02x%02x%02x%02x\n' % (x,y,r,g,b,a)).encode()) | |
# source: https://cyber.equipment/cyber_plain.png | |
im = Image.open('/tmp/cyber.png').convert('RGBA') | |
im.thumbnail((200,72), Image.ANTIALIAS) | |
z = 0 | |
while z < 250: | |
cyber = im.copy() | |
deg = random.randint(1,75) | |
im = cyber.rotate(deg, expand=1) | |
basex = random.randint(100,600) | |
basey = random.randint(100,600) | |
_,_,w,h = cyber.getbbox() | |
for x in range(w): | |
for y in range(h): | |
r,g,b,a = cyber.getpixel((x,y)) | |
pixel(x+basex,y+basey,r,g,b,a) | |
z = z + 1 | |
sock.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment