Skip to content

Animations using after_draw() don't work properly #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion adafruit_led_animation/animation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def animate(self, show=True):
for anim in self._peers:
anim.draw_count += 1
anim.draw()
anim.after_draw()

if show:
for anim in self._peers:
Expand Down
4 changes: 2 additions & 2 deletions adafruit_led_animation/animation/rainbowsparkle.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def generate_rainbow(self):
int(self._background_brightness * color[2]),
)

def after_draw(self):
self.show()
def draw(self):
super().draw()
pixels = [
random.randint(0, len(self.pixel_object) - 1)
for n in range(self._num_sparkles)
Expand Down
9 changes: 3 additions & 6 deletions adafruit_led_animation/animation/sparkle.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,10 @@ def _random_in_mask(self):
return self._mask[random.randint(0, (len(self._mask) - 1))]

def draw(self):
self._pixels = [self._random_in_mask() for _ in range(self._num_sparkles)]
for pixel in self._pixels:
self.pixel_object[pixel] = self._sparkle_color

def after_draw(self):
self.show()
for pixel in self._pixels:
self.pixel_object[pixel % self._num_pixels] = self._half_color
if (pixel + 1) % self._num_pixels in self._mask:
self.pixel_object[(pixel + 1) % self._num_pixels] = self._dim_color
self._pixels = [self._random_in_mask() for _ in range(self._num_sparkles)]
for pixel in self._pixels:
self.pixel_object[pixel] = self._sparkle_color
4 changes: 1 addition & 3 deletions adafruit_led_animation/animation/sparklepulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ def __init__(

def _set_color(self, color):
self._color = color
super()._set_color(color)

def draw(self):
self._sparkle_color = next(self._generator)
super().draw()

def after_draw(self):
self.show()