Merge pull request #17 from adafruit/black-update

Black reformatting with Python 3 target.
This commit is contained in:
Dan Halbert 2020-04-09 21:29:08 -04:00 committed by GitHub
commit ba82d840ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -386,6 +386,7 @@ class Pulse(Animation):
self.fill(color)
self.show()
class SparklePulse(Animation):
"""
Combination of the Spark and Pulse animations.
@ -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
@ -432,14 +435,19 @@ class SparklePulse(Animation):
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.