diff --git a/pyjecteur/common.py b/pyjecteur/common.py index 31fa9a2..7db35fa 100644 --- a/pyjecteur/common.py +++ b/pyjecteur/common.py @@ -87,4 +87,21 @@ def blendLedBar(colors: List[Color], top_gap = gap - bot_gap return (([deduped[0]] * top_gap) + reduplicate(deduped, rep_nb) + ([deduped[-1]] * bot_gap)) + else: + # make the longest sequences longer + + # sorted_indices is a list of indices in [0, len(rep_nb)) with + # increasing rep_nb[i] + sorted_indices = sorted(range(len(rep_nb)), key = lambda n: rep_nb[n]) + # TODO: make this less ugly + while True: + for i in reversed(range(len(rep_nb))): + rep_nb[sorted_indices[i]] += 1 + gap -= 1 + if gap == 0: + return reduplicate(deduped, rep_nb) + + + +