Initial commit

This commit is contained in:
m 2019-01-01 15:54:05 +01:00
commit 2621b90ed2
3 changed files with 78 additions and 0 deletions

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# Pixelthud
Animationen für die Decken-LED-Matrix im Chaospott. Kompatibel zu Pixelserver2

42
fading_pixel.py Executable file
View File

@ -0,0 +1,42 @@
#!/usr/bin/env python3
import sys
import os
import numpy as np
import pygame
Nx = int(sys.argv[1])
Ny = int(sys.argv[2])
try:
fps = float(sys.argv[3])
except (IndexError, ValueError):
fps = 1.0
def point2idx(x,y):
return 3*(x+Nx*y)
def set_pixel_max(buffer, x, y):
idx = point2idx(x,y)
for i in range(3):
buffer[idx+i] = max(0x00, buffer[idx+i]-1)
def set_pixel_rand(buffer, x, y):
idx = point2idx(x,y)
for i in range(3):
buffer[idx+i] = np.random.randint(0x00, 0xff)
clock = pygame.time.Clock()
buffer = bytearray(b"\x00"*(3*Nx*Ny))
i = 0
while True:
i = i + 1
for px in range(Nx):
for py in range(Ny):
set_pixel_max(buffer, px, py)
for j in range(10):
set_pixel_rand(buffer, np.random.randint(0, Nx), np.random.randint(0, Ny))
if i > 100:
os.write(1, buffer)
clock.tick_busy_loop(fps)

33
sine.py Executable file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env python3
import sys
import os
import numpy as np
import pygame
Nx = int(sys.argv[1])
Ny = int(sys.argv[2])
try:
frequency = float(sys.argv[3])
except (IndexError, ValueError):
frequency = 5
fps = 30
amplitude = 105
offset = 150
t = 0
x,y = np.meshgrid(np.linspace(0, 2*np.pi * min(1, Nx/Ny), Nx), np.linspace(0, 2*np.pi * min(1, Ny/Nx), Ny))
kx = x + y
clock = pygame.time.Clock()
while True:
t = t + 1e-3
R = amplitude * np.sin(kx - 2 * np.pi * frequency * t) + offset
G = amplitude * np.sin(kx - 2 * np.pi * frequency * t + 2*np.pi/3) + offset
B = amplitude * np.sin(kx - 2 * np.pi * frequency * t + 4*np.pi/3) + offset
out = np.dstack((R,G,B)).astype(np.uint8).tobytes()
os.write(1, out)
clock.tick_busy_loop(fps)