Python RGB Matrix games and animations https://www.xythobuz.de/ledmatrix_v2.html
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

mapper.py 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. # Does nothing. Take this as an example for new Mappers.
  9. class MapperNull:
  10. def __init__(self, g):
  11. self.gui = g
  12. self.width = self.gui.width
  13. self.height = self.gui.height
  14. self.multiplier = self.gui.multiplier
  15. self.panelW = self.gui.panelW
  16. self.panelH = self.gui.panelH
  17. def loop_start(self):
  18. return self.gui.loop_start()
  19. def loop_end(self):
  20. self.gui.loop_end()
  21. def loop(self, func = None):
  22. self.gui.loop(func)
  23. def set_pixel(self, x, y, color):
  24. self.gui.set_pixel(x, y, color)
  25. # For some reason the red and green LEDs on newer Pimoroni panels
  26. # are far brighter than on older panels.
  27. # Adjust this by multiplying rg channels with 0.75, depending
  28. # on hard-corded coordinate ranges.
  29. class MapperColorAdjust(MapperNull):
  30. def set_pixel(self, x, y, color):
  31. # right-most panel, with maximum x coordinates,
  32. # is "new" type with brighter LEDs.
  33. # rest of panels to the left are less bright.
  34. # so adjust brightness of right panel rg channels down.
  35. if x < self.gui.panelW:
  36. color = (int(color[0] * 0.75), int(color[1] * 0.75), color[2])
  37. self.gui.set_pixel(x, y, color)