diff --git a/lit/effects/chase.py b/lit/effects/chase.py index 5760944..e06e685 100644 --- a/lit/effects/chase.py +++ b/lit/effects/chase.py @@ -1,12 +1,55 @@ +import colorsys +import random + name = "Chase" start_message = name + " started!" -description = "The string is sequentially covered by different colors" +description = ( + "The string is sequentially covered by random colors" +) + + +def create_heads(lights, args): + num_heads = int(args["number"]) + colors = [random.random() for _ in range(0, num_heads)] + head_locations = [i * (-lights.size // num_heads) for i in range(0, num_heads)] + return [head_locations, colors] + -schema = {} +schema = { + "number": { + "value": { + "type": "number", # TODO integer type (or step) + "min": 1, + "max": 20, + "default": 3, + }, + "user_input": True, + "required": False, + "index": 0, + }, + "color": { + "value": { + "type": "color", # TODO integer type (or step) + "default": {"type": "Random Colors"}, + }, + "user_input": True, + "required": False, + }, + "heads": { + "value": {"type": "tuple list", "default_gen": create_heads}, + "user_input": False, + }, +} def update(lights, step, state): - hue = (0.2 * (step // lights.size)) % 1 - lights.set_pixel_hsv(step % lights.size, hue, 1, 1) + heads = state["heads"] + for i in range(len(heads[0])): + if heads[0][i] >= 0: + lights.set_pixel_hsv(heads[0][i], heads[1][i], 1, 1) + heads[0][i] += 1 + if heads[0][i] >= lights.size: + heads[0][i] = 0 + heads[1][i] = colorsys.rgb_to_hsv(state["color"].get_color(step)) diff --git a/lit/effects/multiChase.py b/lit/effects/multiChase.py deleted file mode 100644 index 8af6496..0000000 --- a/lit/effects/multiChase.py +++ /dev/null @@ -1,54 +0,0 @@ -import random - -name = "Multi-Chase" - -start_message = name + " started!" - -description = ( - "The string is sequentially covered by random colors with multiple at the same time" -) - - -def create_heads(lights, args): - num_heads = int(args["number"]) - colors = [random.random() for _ in range(0, num_heads)] - head_locations = [i * (-lights.size // num_heads) for i in range(0, num_heads)] - return [head_locations, colors] - - -schema = { - "number": { - "value": { - "type": "number", # TODO integer type (or step) - "min": 1, - "max": 20, - "default": 3, - }, - "user_input": True, - "required": False, - "index": 0, - }, - "color": { - "value": { - "type": "color", # TODO integer type (or step) - "default": {"type": "Random Colors"}, - }, - "user_input": True, - "required": False, - }, - "heads": { - "value": {"type": "tuple list", "default_gen": create_heads}, - "user_input": False, - }, -} - - -def update(lights, step, state): - heads = state["heads"] - for i in range(len(heads[0])): - if heads[0][i] >= 0: - lights.set_pixel_hsv(heads[0][i], heads[1][i], 1, 1) - heads[0][i] += 1 - if heads[0][i] >= lights.size: - heads[0][i] = 0 - heads[1][i] = state["color"].get_color(step)