firmament: add a vertical wipe example
Assisted-by: Claude Opus 5.5 via Claude Code
change vqpzslswpunxqpxnsluwtsotwvnsrqxq
commit ab60211a05d1fe327dde8118b6fa73f9b28e1b65
author Alpha Chen <alpha@kejadlen.dev>
date
parent xnulpvyo
diff --git a/firmament/examples/wipe.py b/firmament/examples/wipe.py
new file mode 100644
index 0000000..a4de7f5
--- /dev/null
+++ b/firmament/examples/wipe.py
@@ -0,0 +1,15 @@
+"""A vertical wipe: a line rises from BOTTOM to TOP, painting a new color over the last one."""
+
+# Heights in meters, in the map's frame; the first strand's map spans about -0.08 to 0.74.
+BOTTOM = -0.1
+TOP = 0.8
+SECONDS_PER_PASS = 3.0
+COLORS = [(255, 0, 0), (0, 255, 0), (0, 0, 255)]
+
+
+def color(led, t):
+    passes, progress = divmod(t / SECONDS_PER_PASS, 1)
+    line = BOTTOM + progress * (TOP - BOTTOM)
+    new = COLORS[int(passes) % len(COLORS)]
+    old = COLORS[int(passes - 1) % len(COLORS)]
+    return new if led.y <= line else old