Python RGB Matrix games and animations https://www.xythobuz.de/ledmatrix_v2.html
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/usr/bin/env python3
  2. # Uses the Python BDF format bitmap font parser:
  3. # https://github.com/tomchen/bdfparser
  4. #
  5. # And the pillow Python Imaging Library:
  6. # https://github.com/python-pillow/Pillow
  7. #
  8. # ----------------------------------------------------------------------------
  9. # "THE BEER-WARE LICENSE" (Revision 42):
  10. # <xythobuz@xythobuz.de> wrote this file. As long as you retain this notice
  11. # you can do whatever you want with this stuff. If we meet some day, and you
  12. # think this stuff is worth it, you can buy me a beer in return. Thomas Buck
  13. # ----------------------------------------------------------------------------
  14. from PIL import Image
  15. import os
  16. import time
  17. import util
  18. class ScrollText:
  19. def __init__(self, g, t, f, i = 1, s = 75, fg = (255, 255, 255), bg = (0, 0, 0)):
  20. DrawText = util.getTextDrawer()
  21. self.gui = g
  22. self.drawer = DrawText(self.gui, fg, bg)
  23. self.iterations = i
  24. self.speed = 1.0 / s
  25. self.setText(t, f)
  26. self.restart()
  27. def setText(self, t, f):
  28. self.text = t
  29. self.font = f
  30. self.width = self.drawer.text(self.text, self.font, 0, False)
  31. def restart(self):
  32. self.offset = -self.gui.width
  33. self.last = time.time()
  34. self.count = 0
  35. def finished(self):
  36. return (self.count >= self.iterations)
  37. def draw(self):
  38. if (time.time() - self.last) > self.speed:
  39. off = (time.time() - self.last) / self.speed
  40. self.offset += int(off)
  41. self.last = time.time()
  42. if self.offset >= self.width:
  43. self.offset = -self.gui.width
  44. self.count += 1
  45. self.drawer.text(self.text, self.font, self.offset, True)
  46. if __name__ == "__main__":
  47. import util
  48. t = util.getTarget()
  49. # show splash screen while initializing
  50. from splash import SplashScreen
  51. splash = SplashScreen(t)
  52. t.loop_start()
  53. splash.draw()
  54. t.loop_end()
  55. from manager import Manager
  56. m = Manager(t)
  57. scriptDir = os.path.dirname(os.path.realpath(__file__))
  58. fontDir = os.path.join(scriptDir, "fonts")
  59. for f in os.listdir(os.fsencode(fontDir)):
  60. filename = os.fsdecode(f)
  61. if not filename.endswith(".bdf"):
  62. continue
  63. fontName = filename[:-4]
  64. s = fontName + " Abcdefgh " + fontName
  65. m.add(ScrollText(t, s, fontName, 1, 75, (0, 255, 0), (0, 0, 25)))
  66. m.restart()
  67. t.loop(m.draw)