#!/usr/bin/env python3.7 # Draws moving dot at ipv6tree.bitnet.be (was jinglepings.com)! # Needs sudo to run... # sudo ./ipv6_image4.py # 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 pausee = 0.0002 # minimum time between pings in seconds ip_base = '2a05:9b81:2021:' import socket import time # screen size xMax = 1920 yMax = 1080 # initialize x = 0 y = 0 xIncreasing = True # xxx and yyy give the pixel # rgb are 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')) r = 0 while True: r = (r + 1) % 256 g = int(y*255/yMax) b = int(x*255/xMax) send_ping(x,y,r,g,b) if xIncreasing: x += 1 if x == xMax-1: xIncreasing = False else: x += -1 if x == 0: xIncreasing = True y = (y+1) % yMax # If you cycle x (not bouncing), then you fall into a pattern because # 1080*16 = 1920*9 # If you don't cycle x, then you fall into a larger pattern... # 1080*32 = (1920*2)*9 # # Actually, since the first pixel doesn't draw, bouncing in either direction prevents patterns because 1079 = 13*83 and 1919 = 19*101 have no common factors with anything.