fix sparklepulse to use _set_color

This commit is contained in:
Roy Hooper 2020-06-22 18:15:08 -04:00
parent 7b5ba8222e
commit beaa41f0cb
2 changed files with 5 additions and 2 deletions

View file

@ -185,6 +185,8 @@ class Animation:
def color(self, color):
if self._color == color:
return
if isinstance(color, int):
color = (color >> 16 & 0xFF, color >> 8 & 0xFF, color & 0xFF)
self._set_color(color)
def _set_color(self, color):
@ -192,8 +194,6 @@ class Animation:
Called after the color is changed, which includes at initialization.
Override as needed.
"""
if isinstance(color, int):
color = (color >> 16 & 0xFF, color >> 8 & 0xFF, color & 0xFF)
self._color = color
@property

View file

@ -80,6 +80,9 @@ class SparklePulse(Sparkle):
)
self._generator = pulse_generator(self._period, self, dotstar_pwm=dotstar)
def _set_color(self, color):
self._color = color
def draw(self):
self._sparkle_color = next(self._generator)
super().draw()