Skip to content

Commit 9d661b2

Browse files
committed
make sure bounce=False isn't ignored
1 parent fc752db commit 9d661b2

File tree

1 file changed

+8
-4
lines changed
  • adafruit_led_animation/animation

1 file changed

+8
-4
lines changed

adafruit_led_animation/animation/comet.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,21 @@ def _comet_recompute_color(self, color):
104104
self._computed_color = color
105105

106106
def draw(self):
107-
for pixel_no in range(self._tail_length + 1):
107+
colors = self._comet_colors
108+
if self.reverse:
109+
colors = reversed(colors)
110+
for pixel_no, color in enumerate(colors):
108111
draw_at = self._tail_start + pixel_no
109112
if draw_at < 0 or draw_at >= self._num_pixels:
110113
continue
111-
self.pixel_object[draw_at] = self._comet_colors[pixel_no * self._direction]
114+
self.pixel_object[draw_at] = color
112115

113116
self._tail_start += self._direction
114117

115118
if self._tail_start < self._left_side or self._tail_start >= self._right_side:
116-
self.reverse = not self.reverse
117-
self._direction = -self._direction
119+
if self.bounce:
120+
self.reverse = not self.reverse
121+
self._direction = -self._direction
118122
if self.reverse == self._initial_reverse:
119123
self.cycle_complete = True
120124

0 commit comments

Comments
 (0)