firmament: drive the examples by normalized height
Assisted-by: Claude Opus 5.5 via Claude Code
change wzxtwkuqkwwklostwlozwtqszwzsxtlw
commit e9df4aead7351677ea125b0ec8515df119e7d936
author Alpha Chen <alpha@kejadlen.dev>
date
parent xssrzvpv
diff --git a/firmament/examples/rainbow.py b/firmament/examples/rainbow.py
index 29b0547..f67ca3b 100644
--- a/firmament/examples/rainbow.py
+++ b/firmament/examples/rainbow.py
@@ -2,11 +2,11 @@
 
 import colorsys
 
-BANDS_PER_METER = 0.8
+BANDS = 1.5
 CYCLES_PER_SECOND = 0.2
 
 
 def color(led, t):
-    hue = (led.y * BANDS_PER_METER - t * CYCLES_PER_SECOND) % 1.0
+    hue = (led.h * BANDS - t * CYCLES_PER_SECOND) % 1.0
     r, g, b = colorsys.hsv_to_rgb(hue, 1.0, 1.0)
     return (r * 255, g * 255, b * 255)
diff --git a/firmament/examples/wipe.py b/firmament/examples/wipe.py
index a4de7f5..8352133 100644
--- a/firmament/examples/wipe.py
+++ b/firmament/examples/wipe.py
@@ -1,15 +1,11 @@
-"""A vertical wipe: a line rises from BOTTOM to TOP, painting a new color over the last one."""
+"""A vertical wipe: a line rises from the lowest LED to the highest, painting over the last color."""
 
-# 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)
+    passes, line = divmod(t / SECONDS_PER_PASS, 1)
     new = COLORS[int(passes) % len(COLORS)]
     old = COLORS[int(passes - 1) % len(COLORS)]
-    return new if led.y <= line else old
+    return new if led.h <= line else old