@@ -212,6 +212,7 @@ class ColorCycle(Animation):
212
212
:param colors: A list of colors to cycle through in ``(r, g, b)`` tuple, or ``0x000000`` hex
213
213
format. Defaults to a rainbow color cycle.
214
214
"""
215
+
215
216
def __init__ (self , pixel_object , speed , colors = RAINBOW , name = None ):
216
217
self .colors = colors
217
218
super ().__init__ (pixel_object , speed , colors [0 ], name = name )
@@ -386,24 +387,37 @@ class RainbowComet(Comet):
386
387
"""
387
388
388
389
# pylint: disable=too-many-arguments
389
- def __init__ (self , pixel_object , speed , tail_length = 10 , reverse = False , bounce = False ,
390
- colorwheel_offset = 0 , name = None ):
390
+ def __init__ (
391
+ self ,
392
+ pixel_object ,
393
+ speed ,
394
+ tail_length = 10 ,
395
+ reverse = False ,
396
+ bounce = False ,
397
+ colorwheel_offset = 0 ,
398
+ name = None ,
399
+ ):
391
400
self ._colorwheel_is_tuple = isinstance (colorwheel (0 ), tuple )
392
401
self ._colorwheel_offset = colorwheel_offset
393
402
394
403
super ().__init__ (pixel_object , speed , 0 , tail_length , reverse , bounce , name )
395
404
396
405
def _calc_brightness (self , n , color ):
397
- brightness = (( n * self ._color_step ) + self ._color_offset )
406
+ brightness = (n * self ._color_step ) + self ._color_offset
398
407
if not self ._colorwheel_is_tuple :
399
- color = (color & 0xff , ((color & 0xff00 ) >> 8 ), (color >> 16 ))
408
+ color = (color & 0xFF , ((color & 0xFF00 ) >> 8 ), (color >> 16 ))
400
409
return [int (i * brightness ) for i in color ]
401
410
402
411
def __recompute_color (self , color ):
403
412
factor = int (256 / self ._tail_length )
404
413
self ._comet_colors = [BLACK ] + [
405
- self ._calc_brightness (n , colorwheel (int (
406
- (n * factor ) + self ._color_offset + self ._colorwheel_offset ) % 256 ))
414
+ self ._calc_brightness (
415
+ n ,
416
+ colorwheel (
417
+ int ((n * factor ) + self ._color_offset + self ._colorwheel_offset )
418
+ % 256
419
+ ),
420
+ )
407
421
for n in range (self ._tail_length - 1 )
408
422
]
409
423
self ._reverse_comet_colors = list (reversed (self ._comet_colors ))
@@ -652,7 +666,6 @@ def reverse(self, value):
652
666
self ._direction = - 1 if self ._reverse else 1
653
667
654
668
def draw (self ):
655
-
656
669
def bar_colors ():
657
670
bar_no = 0
658
671
for i in range (self ._offset , 0 , - 1 ):
@@ -713,9 +726,18 @@ class RainbowChase(Chase):
713
726
:param reverse: Reverse direction of movement.
714
727
:param wheel_step: How many colors to skip in `colorwheel` per bar (default 8)
715
728
"""
729
+
716
730
# pylint: disable=too-many-arguments
717
- def __init__ (self , pixel_object , speed , size = 2 , spacing = 3 , reverse = False , name = None ,
718
- wheel_step = 8 ):
731
+ def __init__ (
732
+ self ,
733
+ pixel_object ,
734
+ speed ,
735
+ size = 2 ,
736
+ spacing = 3 ,
737
+ reverse = False ,
738
+ name = None ,
739
+ wheel_step = 8 ,
740
+ ):
719
741
self ._num_colors = 256 // wheel_step
720
742
self ._colors = [colorwheel (n % 256 ) for n in range (0 , 512 , wheel_step )]
721
743
self ._color_idx = 0
0 commit comments