@@ -38,12 +38,13 @@ class ColorCycle(Animation):
38
38
:param float speed: Animation speed in seconds, e.g. ``0.1``.
39
39
:param colors: A list of colors to cycle through in ``(r, g, b)`` tuple, or ``0x000000`` hex
40
40
format. Defaults to a rainbow color cycle.
41
+ :param start_color: An index (from 0) for which color to start from. Default 0 (first color given).
41
42
"""
42
43
43
- def __init__ (self , pixel_object , speed , colors = RAINBOW , name = None ):
44
+ def __init__ (self , pixel_object , speed , colors = RAINBOW , start_color = 0 , name = None ):
44
45
self .colors = colors
45
- super ().__init__ (pixel_object , speed , colors [0 ], name = name )
46
- self ._generator = self ._color_generator ()
46
+ super ().__init__ (pixel_object , speed , colors [start_color ], name = name )
47
+ self ._generator = self ._color_generator (start_color )
47
48
next (self ._generator )
48
49
49
50
on_cycle_complete_supported = True
@@ -52,8 +53,8 @@ def draw(self):
52
53
self .pixel_object .fill (self .color )
53
54
next (self ._generator )
54
55
55
- def _color_generator (self ):
56
- index = 0
56
+ def _color_generator (self , start_color ):
57
+ index = start_color
57
58
while True :
58
59
self ._color = self .colors [index ]
59
60
yield
0 commit comments