#!/usr/bin/env python3.7 # Draws image at ipv6tree.bitnet.be (was jinglepings.com) using an image file! # Needs sudo to run... # sudo ./ipv6_image.py # Image file should be in the current directory! # Note that normal screen/image conventions are followed... # y increasing moves DOWN the TV! # (0,0) is the pixel at upper left of the screen imageName = "smiley.png" # adjust the following to start in desired region of the screen xMin = 50 yMin = 300 pausee = 0.0001 # minimum time between pings in seconds ip_base = '2a05:9b81:2021:' import socket import time from PIL import Image im = Image.open(imageName).convert('RGB') xSize,ySize = im.size # xxx and yyy give the pixel (0 <= xxx < 1920, 0 <= yyy < 1080 ) # rgb are colors between 0 and 255 def send_ping(xxx,yyy,r,g,b): addr = ip_base + '%i:%i:%.2x:%.2x:%.2x' % (xxx,yyy,r,g,b) #print(addr) try: send_socket.sendto(b'\x80\0\0\0\0\0\0\0', (addr, 0, 0, 0)) except: pass time.sleep(pausee) send_socket = socket.socket(socket.AF_INET6, socket.SOCK_RAW, socket.getprotobyname('ipv6-icmp')) x = 0 y = 0 while True: r,g,b = im.getpixel((x,y)) # returns rgb colors from 0 to 255 # to override the above image #r = 1 #g = 1 #b = 1 #b = int(x*255/1920) if r!=0 or g!=0 or b!=0: # don't send anything if black! if g == 0: # nothing is drawn if g=0 for some reason g = 1 if r == 0: # do the rest to be safe in future r = 1 if b == 0: b = 1 send_ping(x+xMin,y+yMin,r,g,b) x += 1 if x == xSize: x = 0 y = (y+1)%ySize