feat(patterns): reverse animation direction via preset n8

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jimmyandCursor committed 2026-05-17 18:32:01 +12:00
1 parent 55a97ac51c
commit 94266d5a7c
11 files changed
+131 -62

No files matched your search

+10 -7
View File
@@ -12,7 +12,7 @@ class Particles:
def _run_snowfall(self, preset, colors, flakes, last):
density = max(1, int(preset.n1) if int(preset.n1) > 0 else 20)
speed = max(1, int(preset.n2) if int(preset.n2) > 0 else 1)
speed = max(1, abs(self.driver.signed(preset, int(preset.n2) if int(preset.n2) > 0 else 1)))
d = max(1, int(preset.d))
now = utime.ticks_ms()
if utime.ticks_diff(now, last) < d:
@@ -25,8 +25,10 @@ class Particles:
nf = []
for pos, ci in flakes:
if 0 <= pos < self.driver.num_leds:
self.driver.n[pos] = self.driver.apply_brightness(colors[ci], preset.b)
pos -= speed
self.driver.n[self.driver.led_i(preset, pos)] = self.driver.apply_brightness(
colors[ci], preset.b
)
pos -= self.driver.signed(preset, speed)
if pos >= -1:
nf.append([pos, ci])
self.driver.n.write()
@@ -34,7 +36,7 @@ class Particles:
def _run_starfall(self, preset, colors, stars, last):
rate = max(1, min(255, int(preset.n1) if int(preset.n1) > 0 else 14))
speed = max(1, int(preset.n2) if int(preset.n2) > 0 else 2)
speed = max(1, abs(self.driver.signed(preset, int(preset.n2) if int(preset.n2) > 0 else 2)))
tail = max(2, int(preset.n3) if int(preset.n3) > 0 else 10)
max_stars = 4
d = max(1, int(preset.d))
@@ -65,13 +67,14 @@ class Particles:
(base[2] * fade) // 255,
)
lit = self.driver.apply_brightness(lit, preset.b)
o = self.driver.n[idx]
self.driver.n[idx] = (
pix = self.driver.led_i(preset, idx)
o = self.driver.n[pix]
self.driver.n[pix] = (
max(o[0], lit[0]),
max(o[1], lit[1]),
max(o[2], lit[2]),
)
h -= speed
h -= self.driver.signed(preset, speed)
if h >= -tail:
s["h"] = h
ns.append(s)