-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheffect_default.py
More file actions
27 lines (21 loc) · 808 Bytes
/
effect_default.py
File metadata and controls
27 lines (21 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from typing import Any
from math import sqrt
import colorsys
def frame_max() -> int:
return 72
def frame_time(frame: int) -> float:
_ = frame
return 1/30
def run(positions: list[dict], frame: int, storage: Any) -> (list[dict], Any):
rgb = []
for led in positions:
# get distance from origin to led
distance_percent = sqrt(led['x']**2 + led['y']**2 + led['z']**2)
# scale down to preference
distance_percent /= 3.3
# add some offset based on current frame
hue = (distance_percent + frame / frame_max())
# hsv_to_hue expects normalized values so mod 1 (only keep the decimals)
r, g, b = colorsys.hsv_to_rgb(hue % 1, 1, 0.8)
rgb.append({'r': r, 'g': g, 'b': b})
return rgb, storage