pybeamshow/effects/presets.py

77 lines
2.2 KiB
Python
Raw Normal View History

2023-02-19 22:54:40 +01:00
import pygame as pg
2023-02-17 02:08:21 +01:00
from typing import List
2023-02-19 22:54:40 +01:00
from random import choice
2023-02-18 23:17:03 +01:00
from effects.effect import Effect, color_wheel, Colors
2023-02-17 02:08:21 +01:00
from effects.bouncingspot import BouncingSpot
from effects.doublespot import DoubleSpot
2023-02-19 22:54:40 +01:00
from effects.movingwave import MovingWave
2023-02-17 02:08:21 +01:00
class Presets:
def __init__(self, bounds: pg.Rect) -> None:
self.bounds = bounds
def randomize(self) -> List[Effect]:
return getattr(
self,
choice(
[
func
for func in dir(self)
if callable(getattr(self, func)) and not func.startswith("__")
]
),
)()
def DoubleSpotRandomColor(self) -> List[Effect]:
return [
DoubleSpot(
bounds=self.bounds,
color=color_wheel(increase=30),
radius=100,
fade_out=True,
fade_in=True,
hold=60,
)
]
def DoubleBouncingSpotsColorWheel(self) -> List[Effect]:
return [
BouncingSpot(bounds=self.bounds, color=color_wheel()),
BouncingSpot(bounds=self.bounds, color=color_wheel(hue=180)),
]
2023-02-19 22:54:40 +01:00
def CollidingWaves(self) -> List[Effect]:
return [
MovingWave(
bounds=pg.rect.Rect(0, 0, self.bounds.width, self.bounds.height),
wave_count=5,
wave_height=self.bounds.height // 6,
thickness=20,
),
MovingWave(
bounds=pg.rect.Rect(0, 0, self.bounds.width, self.bounds.height),
hue=180,
wave_count=5,
wave_height=self.bounds.height // 6,
start_phase=120,
start_pos=(0, self.bounds.height * 5 // 6),
thickness=20,
),
]
2023-02-17 02:08:21 +01:00
def BouncingSpotWhite(self) -> List[Effect]:
return [
BouncingSpot(
bounds=self.bounds,
color=Colors.White,
# color=color_wheel(),
sizes=(self.bounds.height / 8, self.bounds.height / 8),
velocity=(1, 1),
x_factor=(1, 1),
y_factor=(2.2, 2.2),
),
]