Skip to content

Instantly share code, notes, and snippets.

@HerrSpace
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HerrSpace/1af514af76f112953558 to your computer and use it in GitHub Desktop.
Save HerrSpace/1af514af76f112953558 to your computer and use it in GitHub Desktop.
subraum spam
#!/usr/bin/env python
import socket
import time
import random
from PIL import Image
img = Image.open("/home/space/subraum_cube_medium.png")
s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
s.connect(("2001:67c:20a1:1:201:2eff:fe2b:3f3a", 1234))
print("connected")
def rgbToHex(r, g, b):
rHex = hex(r)[2:]
gHex = hex(g)[2:]
bHex = hex(b)[2:]
colour = ""
for subColour in [rHex,gHex,bHex]:
if len(subColour) < 2:
colour += "0" + subColour
else:
colour += subColour
return colour
#for idxX in range(640):
# for idxY in range(480):
# magix = "PX " + str(idxX) + " " + str(idxY) + " 000000\n"
# s.send(magix)
while True:
#rIdxX = 640 - img.size[0] -10
idxX = random.randint(0, img.size[0]-1)
idxY = random.randint(0, img.size[1]-1)
r, g, b, a = img.getpixel((idxX, idxY))
colour = rgbToHex(r,g,b)
if a == 255:
magix = "PX " + str(idxX) + " " + str(idxY) + " "+ colour +"\n"
#print(magix)
s.send(magix)
s.close()
print("done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment