diff --git a/scripts/anim_eight.py b/scripts/anim_eight.py new file mode 100644 index 0000000..3015a9a --- /dev/null +++ b/scripts/anim_eight.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +"""Figure-of-8 on the two Small Eye movers. + +Dry run (prints DMX samples, sends nothing): + + python3 scripts/anim_eight.py + python3 -m showfile run scripts/anim_eight.py --seconds 1 + +Send Art-Net, for example at the stage simulator: + + python3 scripts/anim_eight.py --ip 127.0.0.1 --seconds 8 +""" + +from __future__ import annotations + +import sys +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +if str(ROOT) not in sys.path: + sys.path.insert(0, str(ROOT)) + +from showfile import Show +from showfile.play import script_main + + +def build() -> Show: + show = Show(author="Jimmy") + m1 = show.patch( + "Small Eye 7", "Mover", "43 Channel", name="Small Eye 7 #1", address=0, key="m1" + ) + m2 = show.patch( + "Small Eye 7", "Mover", "43 Channel", name="Small Eye 7 #2", address=44, key="m2" + ) + show.efx( + "Figure of 8", + [m1, m2], + algorithm="Eight", + width=40, + height=30, + x_offset=128, + y_offset=140, + duration_ms=8000, + key="eight", + ) + show.run("eight") + return show + + +if __name__ == "__main__": + script_main(build) diff --git a/scripts/anim_stage.py b/scripts/anim_stage.py new file mode 100644 index 0000000..9f046e3 --- /dev/null +++ b/scripts/anim_stage.py @@ -0,0 +1,115 @@ +#!/usr/bin/env python3 +"""The whole stage: a colour chase on the cans and a figure-8 on every mover. + +The patch, positions, and channel names come from stage/map.json. + +Dry run (prints DMX samples, sends nothing): + + python3 scripts/anim_stage.py + python3 -m showfile run scripts/anim_stage.py --seconds 1 + +Send Art-Net at the stage simulator: + + python3 scripts/anim_stage.py --ip 127.0.0.1 --seconds 12 +""" + +from __future__ import annotations + +import sys +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +if str(ROOT) not in sys.path: + sys.path.insert(0, str(ROOT)) + +from showfile import Show +from showfile.play import script_main + + +def build() -> Show: + show = Show(author="Jimmy") + rig = show.patch_stage(ROOT / "stage" / "map.json") + red, green, blue = (rig.cans[0].channel(name) for name in ("Red", "Green", "Blue")) + dimmers = { + can.key: {can.channel("Dimmer"): 255, can.channel("Strobe"): 0} + for can in rig.cans + } + show.scene("Can dimmers", dimmers, key="dim") + frames = [] + count = len(rig.cans) + for head in range(count): + frame = [] + for index in range(count): + colour = _hsv(index / count) + distance = min((index - head) % count, (head - index) % count) + if distance == 0: + frame.append(colour) + elif distance == 1: + frame.append(tuple(channel // 3 for channel in colour)) + else: + frame.append((0, 0, 0)) + frames.append(frame) + show.colour_chase( + "Can chase", + rig.cans, + {"r": red, "g": green, "b": blue}, + frames, + fade_ms=80, + hold_ms=140, + key="chase", + ) + look = {} + movers = [] + for index, mover in enumerate(rig.movers): + colour = (255, 40, 0) if index % 2 == 0 else (40, 80, 255) + values = { + mover.channel("Zoom"): 40, + mover.channel("Dynamic Effect"): 30 if index % 2 == 0 else 160, + mover.channel("Lens Rotate"): 210 if index % 2 == 0 else 40, + } + for channel in mover.named("White"): + values[channel] = 0 + for red_ch, green_ch, blue_ch in zip(mover.named("Red"), mover.named("Green"), mover.named("Blue")): + values[red_ch] = colour[0] + values[green_ch] = colour[1] + values[blue_ch] = colour[2] + look[mover.key] = values + movers.append({"fixture": mover, "start_offset": index * 90}) + show.scene("Mover look", look, key="look") + show.efx( + "Movers", + movers, + algorithm="Eight", + width=36, + height=22, + x_offset=128, + y_offset=140, + duration_ms=12000, + key="movers", + ) + show.collection("Stage", ["dim", "chase", "look", "movers"], key="stage") + show.run("stage") + return show + + +def _hsv(hue: float) -> tuple[int, int, int]: + hue = hue % 1.0 + segment = int(hue * 6) % 6 + frac = hue * 6 - int(hue * 6) + fade = int(255 * (1 - frac)) + rise = int(255 * frac) + if segment == 0: + return 255, rise, 0 + if segment == 1: + return fade, 255, 0 + if segment == 2: + return 0, 255, rise + if segment == 3: + return 0, fade, 255 + if segment == 4: + return rise, 0, 255 + return 255, 0, fade + + +if __name__ == "__main__": + script_main(build)