rpi-rgb-led-matrix/python/samples/simple-square.py

29 lines
1 KiB
Python
Raw Normal View History

2015-06-28 10:41:40 +00:00
#!/usr/bin/env python
from samplebase import SampleBase
class SimpleSquare(SampleBase):
def __init__(self, *args, **kwargs):
super(SimpleSquare, self).__init__(*args, **kwargs)
def Run(self):
offsetCanvas = self.matrix.CreateFrameCanvas()
2015-06-28 10:41:40 +00:00
while True:
for x in range(0, self.matrix.width):
offsetCanvas.SetPixel(x, x, 255, 255, 255)
offsetCanvas.SetPixel(offsetCanvas.height - 1 - x, x, 255, 0, 255)
2015-06-28 10:41:40 +00:00
for x in range(0, offsetCanvas.width):
offsetCanvas.SetPixel(x, 0, 255, 0, 0)
offsetCanvas.SetPixel(x, offsetCanvas.height - 1, 255, 255, 0)
2015-06-28 10:41:40 +00:00
for y in range(0, offsetCanvas.height):
offsetCanvas.SetPixel(0, y, 0, 0, 255)
offsetCanvas.SetPixel(offsetCanvas.width - 1, y, 0, 255, 0)
offsetCanvas = self.matrix.SwapOnVSync(offsetCanvas)
2015-06-28 10:41:40 +00:00
# Main function
if __name__ == "__main__":
parser = SimpleSquare()
if (not parser.process()):
parser.print_help()