Advertisement
evenjc

Untitled

Oct 23rd, 2020
1,969
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Fri Oct 23 21:01:39 2020
  4.  
  5. @author: Bruker
  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("blocks.png")
  14.  
  15. pix = im.load()
  16.  
  17. block_size = 8
  18.  
  19. blocks_per_line = im.size[0]/block_size
  20.  
  21. xcursor = 0
  22. ycursor = 0
  23.  
  24. while True:
  25.     for ypixel in range(0, block_size):
  26.         for xpixel in range(0, block_size):
  27.             print(pix[xpixel, ypixel])
  28.             senseHat.set_pixel(xpixel, ypixel, (pix[xpixel + (xcursor*block_size), ypixel + (ycursor*block_size)]))
  29.  
  30.     if xcursor < 15:
  31.         xcursor = xcursor + 1
  32.     else:
  33.         xcursor = 0
  34.         ycursor = ycursor + 1
  35.  
  36.     sleep(1)
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement