def __getitem__(self, i): if (isinstance(i, slice)): return [ ws.ws2811_led_get(self.ch, n) for n in range(*i.indices(self.sz[0] * self.sz[1])) ] if (isinstance(i, tuple)): i = _map_pos(i[0], i[1], self.sz) return ws.ws2811_led_get(self.ch, i + self.sz[0] * self.sz[1])
def __getitem__(self, pos): """Return the 24-bit RGB color value at the provided position or slice of positions. """ # Handle if a slice of positions are passed in by grabbing all the values # and returning them in a list. if isinstance(pos, slice): return [ws.ws2811_led_get(self.channel, n) for n in range(*pos.indices(self.size))] # Else assume the passed in value is a number to the position. else: return ws.ws2811_led_get(self.channel, pos)