added other random scripts and functions

This commit is contained in:
KS_HTK 2025-08-21 10:41:54 +02:00
parent ef148dbbb6
commit 3f1207a5cd
Signed by: KS_HTK
GPG key ID: A12528D4094FF70C
8 changed files with 1929 additions and 11 deletions

View file

@ -4,12 +4,13 @@ When running this file it will randomly select a transition and a frame to trans
"""
# requires: python-fluepdot, python-dotenv
import os
from math import sqrt
from dotenv import load_dotenv
from fluepdot import Fluepdot, Mode
from random import choice, sample
from itertools import product
from time import sleep
from typing import List
from typing import Generator
DELAY = 5 # hold time for completed animations/frames
ANIMATION_DELAY = 0.1 # delay between frames of animations
@ -34,7 +35,7 @@ flipdot_logo = [
]
def checkerboard(len_x: int, len_y: int, invert: bool = False) -> List[List[bool]]:
def checkerboard(len_x: int, len_y: int, invert: bool = False) -> list[list[bool]]:
return [[(j + i + invert) % 2 == 0 for i in range(len_x)] for j in range(len_y)]
@ -70,7 +71,7 @@ def droplet(fd: Fluepdot):
fd.post_frame(frame)
def fd_logo(fd: Fluepdot) -> List[List[bool]]:
def fd_logo(fd: Fluepdot) -> list[list[bool]]:
fd.post_text("flipdot e.V.", x=7, y=0, font="fixed_7x14")
original_frame = fd.get_frame()
frame = []
@ -80,7 +81,7 @@ def fd_logo(fd: Fluepdot) -> List[List[bool]]:
return [[c == "X" for c in row] for row in frame]
def kurhacken(fd: Fluepdot) -> List[List[bool]]:
def kurhacken(fd: Fluepdot) -> list[list[bool]]:
fd.post_text("Kurhecken", x=14, y=-2, font="fixed_10x20")
frame = [[c == "X" for c in row] for row in fd.get_frame()]
fd.set_mode(Mode.DIFFERENTIAL)
@ -89,25 +90,48 @@ def kurhacken(fd: Fluepdot) -> List[List[bool]]:
return frame
def event37c3(fd: Fluepdot) -> List[List[bool]]:
def event37c3(fd: Fluepdot) -> list[list[bool]]:
fd.post_text("37c3Unlocked", x=-1, y=-1, font="DejaVuSerif16")
frame = [[c == "X" for c in row] for row in fd.get_frame()]
return frame
def event38c3(fd: Fluepdot) -> List[List[bool]]:
def event38c3(fd: Fluepdot) -> list[list[bool]]:
fd.post_text("38C3 Illegal Instructions", font="DejaVuSerif16")
frame = [[c == "X" for c in row] for row in fd.get_frame()]
return frame
def hackumenta(fd: Fluepdot) -> List[List[bool]]:
def hackumenta(fd: Fluepdot) -> list[list[bool]]:
fd.post_text("Hackumenta", x=3, y=-1, font="DejaVuSerif16")
frame = [[c == "X" for c in row] for row in fd.get_frame()]
return frame
def wipe_to(fd: Fluepdot, frame: List[List[bool]]):
def wave(len_x: int, len_y: int) -> Generator[list[list[bool]], None, None]:
center_x = len_x // 2
center_y = len_y // 2
for r in range(max(len_x, len_y)+5):
arr = [[False for _ in range(len_x)] for _ in range(len_y)]
for y in range(len_y):
for x in range(len_x):
for i in [j for j in range(r, 0, -4)][:5]:
dist = sqrt((x - center_x) ** 2 + (y - center_y) ** 2)
adist = int(dist)
if adist == i or adist == i+1:
arr[y][x] = True
yield arr
def propagate_wave(fd: Fluepdot, delay: float = ANIMATION_DELAY) -> None:
x, y = fd.get_size()
wave_func = wave(x, y)
for w in wave_func:
fd.post_frame(w)
sleep(delay)
def wipe_to(fd: Fluepdot, frame: list[list[bool]]):
fd.set_mode(Mode.DIFFERENTIAL)
current = [[c == "X" for c in row] for row in fd.get_frame()]
for i in range(0, len(current[0])):
@ -119,7 +143,7 @@ def wipe_to(fd: Fluepdot, frame: List[List[bool]]):
fd.post_frame(current)
def dither_to(fd: Fluepdot, frame: List[List[bool]]):
def dither_to(fd: Fluepdot, frame: list[list[bool]]):
fd.set_mode(Mode.DIFFERENTIAL)
max_x, max_y = fd.get_size()
current = [[c == "X" for c in row] for row in fd.get_frame()]
@ -138,7 +162,7 @@ def dither_to(fd: Fluepdot, frame: List[List[bool]]):
print(r.text)
def push_to(fd: Fluepdot, frame: List[List[bool]]):
def push_to(fd: Fluepdot, frame: list[list[bool]]):
fd.set_mode(Mode.DIFFERENTIAL)
current = [[c == "X" for c in row] for row in fd.get_frame()]
while True:
@ -157,7 +181,7 @@ def push_to(fd: Fluepdot, frame: List[List[bool]]):
break
def roll_to(fd: Fluepdot, frame: List[List[bool]]):
def roll_to(fd: Fluepdot, frame: list[list[bool]]):
fd.set_mode(Mode.DIFFERENTIAL)
current = [[c == "X" for c in row] for row in fd.get_frame()]
while frame:
@ -174,6 +198,7 @@ if __name__ == "__main__":
fd.clear()
animations = [
droplet,
propagate_wave
]
transitions = [
wipe_to,