Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions adafruit_led_animation/animation/sparkle.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def __init__(self, pixel_object, speed, color, num_sparkles=1, name=None):
self._dim_color = color
self._sparkle_color = color
self._num_sparkles = num_sparkles
self._num_pixels = len(pixel_object)
self._pixels = []
super().__init__(pixel_object, speed, color, name=name)

Expand All @@ -85,7 +86,7 @@ def _recompute_color(self, color):

def draw(self):
self._pixels = [
random.randint(0, (len(self.pixel_object) - 2))
random.randint(0, (len(self.pixel_object) - 1))
for _ in range(self._num_sparkles)
]
for pixel in self._pixels:
Expand All @@ -94,5 +95,5 @@ def draw(self):
def after_draw(self):
self.show()
for pixel in self._pixels:
self.pixel_object[pixel] = self._half_color
self.pixel_object[pixel + 1] = self._dim_color
self.pixel_object[pixel % self._num_pixels] = self._half_color
self.pixel_object[(pixel + 1) % self._num_pixels] = self._dim_color