Skip to content

Black reformatting with Python 3 target. #17

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 1 commit into from
Apr 10, 2020
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
14 changes: 11 additions & 3 deletions adafruit_led_animation/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ def draw(self):
self.fill(color)
self.show()


class SparklePulse(Animation):
"""
Combination of the Spark and Pulse animations.
Expand All @@ -399,7 +400,9 @@ class SparklePulse(Animation):
"""

# pylint: disable=too-many-arguments
def __init__(self, pixel_object, speed, color, period=5, max_intensity=1, min_intensity=0):
def __init__(
self, pixel_object, speed, color, period=5, max_intensity=1, min_intensity=0
):
if len(pixel_object) < 2:
raise ValueError("Sparkle needs at least 2 pixels")
self.max_intensity = max_intensity
Expand Down Expand Up @@ -432,14 +435,19 @@ def draw(self):
now = monotonic_ns()
time_since_last_draw = (now - self._last_update) / NANOS_PER_SECOND
self._last_update = now
pos = self._cycle_position = (self._cycle_position + time_since_last_draw) % self._period
pos = self._cycle_position = (
self._cycle_position + time_since_last_draw
) % self._period
if pos > self._half_period:
pos = self._period - pos
intensity = self.min_intensity + (pos * self._intensity_delta * self._position_factor)
intensity = self.min_intensity + (
pos * self._intensity_delta * self._position_factor
)
color = [int(self.color[n] * intensity) for n in range(self._bpp)]
self.pixel_object[pixel] = color
self.show()


class Chase(Animation):
"""
Chase pixels in one direction in a single color, like a theater marquee sign.
Expand Down