evenjc

Untitled

Oct 24th, 2020
564
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Fri Oct 23 21:01:39 2020
  4.  
  5. @author: evenjc
  6. """
  7. from PIL import Image
  8. from time import sleep
  9. from sense_hat import SenseHat
  10.  
  11. senseHat = SenseHat()
  12.  
  13. im = Image.open("toons.jpg")
  14.  
  15. pix = im.load()
  16.  
  17. block_size = 8
  18.  
  19.  
  20. blocks_per_line = im.size[0]/block_size
  21.  
  22. xcursor = 0
  23. ycursor = 0
  24.  
  25. #sleep(5)
  26.  
  27. while True:
  28.     for ypixel in range(0, block_size):
  29.         for xpixel in range(0, block_size):
  30.             senseHat.set_pixel(xpixel, ypixel, pix[xpixel + (xcursor*block_size), ypixel + (ycursor*block_size)])
  31.  
  32.     sleep(2)
  33.  
  34.     if xcursor < 9:
  35.         xcursor = xcursor + 1
  36.     else:
  37.         xcursor = 0
  38.         ycursor = ycursor + 1
  39.  
  40.     if ycursor > 9:
  41.         ycursor = 0
  42.  
  43.  
RAW Paste Data