Skip to content

Commit 3aa735a

Browse files
committed
Update to have min/max tail length automatically.
1 parent 4240a4b commit 3aa735a

File tree

1 file changed

+6
-6
lines changed
  • adafruit_led_animation/animation

1 file changed

+6
-6
lines changed

adafruit_led_animation/animation/comet.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ def __init__(
7373
pixel_object,
7474
speed,
7575
color,
76-
tail_length=10,
76+
tail_length=None,
7777
reverse=False,
7878
bounce=False,
7979
name=None,
8080
):
81-
if tail_length > len(pixel_object):
82-
raise ValueError(
83-
"Tail length must be less than the length of the pixel_object."
84-
)
85-
self._tail_length = tail_length + 1
81+
if tail_length is None:
82+
tail_length = int(len(pixel_object) / 4)
83+
else:
84+
tail_length = max(2, min(tail_length, len(pixel_object)))
85+
self._tail_length = tail_length
8686
self._color_step = 0.9 / tail_length
8787
self._color_offset = 0.1
8888
self._comet_colors = None

0 commit comments

Comments
 (0)