-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathplasma.py
56 lines (51 loc) · 1.51 KB
/
plasma.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
Demoscene plasma effect for Adafruit NeoPixel BFF 5x5 LED Grid
(c)2023/07 Krzysztof Krystian Jankowski
Homepage: https://smol.p1x.in/os/
"""
import machine
import utime
import _thread
import time
import neopixel
import math
import random
class Plasma():
def __init__(self):
self.pixels = neopixel.NeoPixel(machine.Pin(29),5*5)
self.pixels.fill((0,0,0))
self.pixels.write()
self.hearth_bitmap = [
0,1,1,0,0,
1,1,1,1,0,
0,1,1,1,1,
1,1,1,1,0,
0,1,1,0,0,
]
print("Plasma initialized.")
def plasma(self,zoom):
time=0
pow=0.1
print("Press Ctrl+C to quit.\n")
while True:
try:
for p in range(25):
x=p%5-2
y=p/5-2
c=math.sin(math.sin(x*zoom+math.cos(time*0.3)*13) + math.cos(y*zoom+math.sin(time*.2)*17))
c=(128+int(c*128))*pow
if self.hearth_bitmap[24-p]==0:
c=c*0.025
self.pixels[p]=(
int(c+5+math.sin(time*0.21)*5),
int(c+5+math.cos(1+time*0.33)*5),
int(c+5+math.sin(1+time*0.47)*5))
self.pixels.write()
time+=0.05
except KeyboardInterrupt:
break
def run(self, argument=0.33):
self.plasma(argument)
if __name__ == '__main__':
plasma = Plasma()
plasma.run()