@@ -84,8 +84,8 @@ def __init__(
84
84
self ._computed_color = color
85
85
self ._num_pixels = len (pixel_object )
86
86
self ._direction = - 1 if reverse else 1
87
- self ._left_side = - self ._tail_length - 1
88
- self ._right_side = self ._num_pixels + self . _tail_length + 1
87
+ self ._left_side = - self ._tail_length
88
+ self ._right_side = self ._num_pixels
89
89
self ._tail_start = 0
90
90
self .reset ()
91
91
super ().__init__ (pixel_object , speed , color , name = name )
@@ -105,17 +105,16 @@ def _comet_recompute_color(self, color):
105
105
106
106
def draw (self ):
107
107
for pixel_no in range (self ._tail_length + 1 ):
108
- draw_at = self ._tail_start + ( self . _direction * pixel_no )
108
+ draw_at = self ._tail_start + pixel_no
109
109
if draw_at < 0 or draw_at >= self ._num_pixels :
110
110
continue
111
- self .pixel_object [draw_at ] = self ._comet_colors [pixel_no ]
111
+ self .pixel_object [draw_at ] = self ._comet_colors [pixel_no * self . _direction ]
112
112
113
113
self ._tail_start += self ._direction
114
114
115
- if self ._tail_start < self ._left_side or self ._tail_start > self ._right_side :
115
+ if self ._tail_start < self ._left_side or self ._tail_start >= self ._right_side :
116
116
self .reverse = not self .reverse
117
117
self ._direction = - self ._direction
118
- self ._tail_start += self ._direction
119
118
if self .reverse == self ._initial_reverse :
120
119
self .cycle_complete = True
121
120
0 commit comments