@@ -108,6 +108,7 @@ def draw(self):
108
108
"""
109
109
Animation subclasses must implement draw() to render the animation sequence.
110
110
"""
111
+ raise NotImplementedError ()
111
112
112
113
def show (self ):
113
114
"""
@@ -165,12 +166,6 @@ def speed(self, seconds):
165
166
def _recompute_color (self , color ):
166
167
pass
167
168
168
- def change_color (self , color ):
169
- """
170
- By default changing color uses the color property.
171
- """
172
- self .color = color
173
-
174
169
175
170
class ColorCycle (Animation ):
176
171
"""
@@ -198,11 +193,6 @@ def _color_generator(self):
198
193
yield
199
194
index = (index + 1 ) % len (self .colors )
200
195
201
- def change_color (self , color ):
202
- """
203
- ColorCycle doesn't support change_color.
204
- """
205
-
206
196
207
197
class Blink (ColorCycle ):
208
198
"""
@@ -218,12 +208,6 @@ def __init__(self, pixel_object, speed, color):
218
208
def _recompute_color (self , color ):
219
209
self .colors = [color , BLACK ]
220
210
221
- def change_color (self , color ):
222
- """
223
- Change the color.
224
- """
225
- self .colors [0 ] = color
226
-
227
211
228
212
class Solid (ColorCycle ):
229
213
"""
@@ -238,12 +222,6 @@ def __init__(self, pixel_object, color):
238
222
def _recompute_color (self , color ):
239
223
self .colors = [color ]
240
224
241
- def change_color (self , color ):
242
- """
243
- Change the color.
244
- """
245
- self .colors [0 ] = color
246
-
247
225
248
226
class Comet (Animation ):
249
227
"""
@@ -372,7 +350,7 @@ def draw(self):
372
350
intensity = self .min_intensity + (
373
351
sin (self ._radians_per_second * self ._cycle_position ) * self ._intensity_delta )
374
352
375
- color = [int (self ._color [n ] * intensity ) for n in range (self ._bpp )]
353
+ color = [int (self .color [n ] * intensity ) for n in range (self ._bpp )]
376
354
self .fill (color )
377
355
self .show ()
378
356
@@ -502,13 +480,17 @@ def current_animation(self):
502
480
"""
503
481
return self ._members [self ._current ]
504
482
505
- def change_color (self , color ):
483
+ @property
484
+ def color (self ):
506
485
"""
507
- Change the color of all members that support setting the color with ``change_color``.
508
- Ignored by animations that do not support it.
486
+ Use this property to change the color of all members of the animation.
509
487
"""
488
+ return None
489
+
490
+ @color .setter
491
+ def color (self , color ):
510
492
for item in self ._members :
511
- item .change_color ( color )
493
+ item .color = color
512
494
513
495
def fill (self , color ):
514
496
"""
@@ -573,12 +555,17 @@ def _for_all(self, method, *args, **kwargs):
573
555
for item in self ._members :
574
556
getattr (item , method )(* args , ** kwargs )
575
557
576
- def change_color (self , color ):
558
+ @property
559
+ def color (self ):
577
560
"""
578
- Change the color of all members that support setting the color with change_color.
579
- Ignored by animations that do not support it.
561
+ Use this property to change the color of all members of the animation group.
580
562
"""
581
- self ._for_all ('change_color' , color )
563
+ return None
564
+
565
+ @color .setter
566
+ def color (self , color ):
567
+ for item in self ._members :
568
+ item .color = color
582
569
583
570
def fill (self , color ):
584
571
"""
0 commit comments