فهرست منبع

added .clear()

cc 4 سال پیش
والد
کامیت
198dd00684
1فایلهای تغییر یافته به همراه8 افزوده شده و 1 حذف شده
  1. 8 1
      jlab/matrix_ft.py

+ 8 - 1
jlab/matrix_ft.py

@@ -47,7 +47,9 @@ class Matrix(object):
         '''
         if x >= self.width or y >= self.height or x < 0 or y < 0:
             return
-        if color == (0, 0, 0) and not self.transparent:
+
+        # [dr]: inverted logic
+        if color == (0, 0, 0) and self.transparent:
             color = (1, 1, 1)
 
         offset = (x + y * self.width) * 3 + self._header_len
@@ -64,6 +66,11 @@ class Matrix(object):
         '''Send the updated pixels to the display.'''
         self._sock.send(self._data)
 
+    def clear(self):
+        '''clear pane with black (reinit self._data)
+        '''
+        self._init_data()
+
 if __name__ == '__main__':
     f = Matrix('192.168.178.144', 50, 50)
     import time