pushpng.py 604 B

12345678910111213141516171819202122232425262728
  1. from PIL import Image
  2. import socket
  3. import sys
  4. import random
  5. import time
  6. i = Image.open(sys.argv[1])
  7. pix = i.load()
  8. n = 45000
  9. p = 15485867
  10. xo = 0
  11. yo = 0
  12. lasttime = 0
  13. while True:
  14. t = int(time.time())
  15. if int(t/120) != int(lasttime/120):
  16. lasttime = t
  17. random.seed(int(t/120))
  18. xo = random.randint(0,800-i.size[0])
  19. yo = random.randint(0,576-i.size[1])
  20. n = (n+p)%(i.size[0]*i.size[1])
  21. x = n % i.size[0]
  22. y = int (n / i.size[0])
  23. if pix[x,y] == (0,0,0):
  24. continue
  25. print "px %d %d %02x%02x%02x\n"%(x+xo,y+yo,pix[x,y][0],pix[x,y][1],pix[x,y][2])