Skip to content

Update comet.py to include a background color #107

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

Merged
merged 2 commits into from
Jan 6, 2023
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
4 changes: 3 additions & 1 deletion adafruit_led_animation/animation/comet.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(
pixel_object,
speed,
color,
background_color=BLACK,
tail_length=0,
reverse=False,
bounce=False,
Expand All @@ -68,6 +69,7 @@ def __init__(
self._color_step = 0.95 / tail_length
self._comet_colors = None
self._computed_color = color
self._background_color = background_color
self._num_pixels = len(pixel_object)
self._direction = -1 if reverse else 1
self._left_side = -self._tail_length
Expand All @@ -82,7 +84,7 @@ def __init__(
on_cycle_complete_supported = True

def _set_color(self, color):
self._comet_colors = [BLACK]
self._comet_colors = [self._background_color]
for n in range(self._tail_length):
self._comet_colors.append(
calculate_intensity(color, n * self._color_step + 0.05)
Expand Down