Python RGB Matrix games and animations https://www.xythobuz.de/ledmatrix_v2.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

splash.py 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env python3
  2. # ----------------------------------------------------------------------------
  3. # "THE BEER-WARE LICENSE" (Revision 42):
  4. # <xythobuz@xythobuz.de> wrote this file. As long as you retain this notice
  5. # you can do whatever you want with this stuff. If we meet some day, and you
  6. # think this stuff is worth it, you can buy me a beer in return. Thomas Buck
  7. # ----------------------------------------------------------------------------
  8. class SplashScreen:
  9. def __init__(self, g):
  10. self.gui = g
  11. self.width = self.gui.panelW
  12. self.height = self.gui.panelH
  13. def draw(self):
  14. # repeat the image on each available panel
  15. for x in range(0, int(self.gui.width / self.width)):
  16. for y in range(0, int(self.gui.height / self.height)):
  17. self.drawOnce(x * self.width, y * self.height)
  18. def drawOnce(self, x, y):
  19. self.gui.set_pixel( x, y, (255, 255, 255))
  20. self.gui.set_pixel( x, self.height - 1 + y, ( 0, 0, 255))
  21. self.gui.set_pixel(self.width - 1 + x, y, (255, 0, 0))
  22. self.gui.set_pixel(self.width - 1 + x, self.height - 1 + y, ( 0, 255, 0))
  23. for i in range(0, int(min(self.width, self.height) / 3)):
  24. self.gui.set_pixel((self.width / 2) - 1 + i + x, (self.height / 2) - 1 + i + y, (255, 255, 255))
  25. self.gui.set_pixel((self.width / 2) - 1 - i + x, (self.height / 2) - 1 - i + y, (255, 255, 255))
  26. self.gui.set_pixel((self.width / 2) - 1 + i + x, (self.height / 2) - 1 - i + y, (255, 255, 255))
  27. self.gui.set_pixel((self.width / 2) - 1 - i + x, (self.height / 2) - 1 + i + y, (255, 255, 255))
  28. def finished(self):
  29. return True
  30. def restart(self):
  31. pass
  32. if __name__ == "__main__":
  33. import util
  34. t = util.getTarget()
  35. s = SplashScreen(t)
  36. util.loop(t, s.draw)