pybeamshow/effects/presets.py

210 lines
6.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
2023-02-20 02:01:16 +01:00
from random import choice, randint
2023-02-22 22:55:11 +01:00
from effects.effect import Effect
from util.color import color_darken, color_randomize, color_wheel, Colors
2023-02-22 03:43:50 +01:00
from effects.crazypolys import CrazyPolys
2023-02-20 02:01:16 +01:00
from effects.drops import Drops
2023-02-17 02:08:21 +01:00
from effects.bouncingspot import BouncingSpot
from effects.doublespot import DoubleSpot
2023-02-20 02:01:16 +01:00
from effects.moonflower import Moonflower
2023-02-19 22:54:40 +01:00
from effects.movingwave import MovingWave
2023-02-20 02:01:16 +01:00
from effects.rotatingpoly import RotatingPoly
from effects.scanreticle import ScanReticle
2023-02-22 03:43:50 +01:00
from effects.spiro import Spiro
2023-02-20 02:01:16 +01:00
from effects.starfield import Starfield
2023-02-23 00:19:20 +01:00
from util.transform import transform_bounce
2023-02-17 02:08:21 +01:00
class Presets:
2023-02-20 02:01:16 +01:00
def __init__(self, bounds: pg.Rect, beat_reactive: bool = False) -> None:
2023-02-17 02:08:21 +01:00
self.bounds = bounds
2023-02-20 02:01:16 +01:00
self.beat_reactive = beat_reactive
def default(self) -> List[Effect]:
return self.Moonflower()
2023-02-17 02:08:21 +01:00
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),
2023-02-20 02:01:16 +01:00
beat_adapt=self.beat_reactive,
2023-02-17 02:08:21 +01:00
radius=100,
fade_out=True,
fade_in=True,
hold=60,
)
]
def DoubleBouncingSpotsColorWheel(self) -> List[Effect]:
return [
2023-02-20 02:01:16 +01:00
BouncingSpot(
bounds=self.bounds,
color=color_wheel(),
sizes=(self.bounds.height / 12, self.bounds.height / 10),
),
BouncingSpot(
bounds=self.bounds,
color=color_wheel(hue=180),
sizes=(self.bounds.height / 12, self.bounds.height / 10),
),
2023-02-17 02:08:21 +01:00
]
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),
),
]
2023-02-20 02:01:16 +01:00
def RotatingPoly(self) -> List[Effect]:
return [
RotatingPoly(
bounds=self.bounds,
color=color_wheel(increase=(75 if self.beat_reactive else 0)),
beat_color=self.beat_reactive,
size=int(self.bounds.height * 0.8),
outer=randint(3, 8),
velocity=(0.5, 0.5),
rot_speed=1,
x_factor=(0.5, 1.5),
y_factor=(0.5, 3),
)
]
def Moonflower(self) -> List[Effect]:
return [
Moonflower(
bounds=self.bounds,
colors=(
color_wheel(increase=(75 if self.beat_reactive else 0)),
color_wheel(hue=180, increase=(75 if self.beat_reactive else 0)),
),
beat_color=self.beat_reactive,
size=self.bounds.height // 4,
outer=5,
rot_speed=1.5,
2023-02-23 00:19:20 +01:00
mover=transform_bounce(
bounds=self.bounds,
velocity=(0.5, 1.5),
x_factor=(0.5, 1.5),
y_factor=(0.5, 1.5),
),
2023-02-20 02:01:16 +01:00
)
]
def WhiteStarfield(self) -> List[Effect]:
return [
Starfield(
bounds=self.bounds,
color=Colors.White,
# color=color_randomize(),
fade_in=True,
fade_out=True,
# radius=30,
star_factor=1,
hold=60 * 2,
# beat_adapt=True,
)
]
def ColorStarfield(self) -> List[Effect]:
return [
Starfield(
bounds=self.bounds,
color=color_randomize(),
fade_in=True,
fade_out=True,
# radius=30,
star_factor=1,
hold=60 * 2,
beat_adapt=True,
)
]
def GreenBlueDrops(self) -> List[Effect]:
return [
Drops(
bounds=self.bounds,
colors=(Colors.Green, color_darken(Colors.Blue, 0.2)),
sizes=(self.bounds.width // 40, self.bounds.width // 35),
drop_rate=0.1,
drop_acceleration=0.3,
)
]
def ScanReticle(self) -> List[Effect]:
return [
ScanReticle(
self.bounds,
(Colors.Red, Colors.White),
velocity=(1, 1),
x_factor=(0.4, 1),
y_factor=(0.2, 1),
)
]
2023-02-22 03:43:50 +01:00
def Spiro(self) -> List[Effect]:
return [
Spiro(
bounds=self.bounds,
color=color_wheel(increase=2),
sizes=(self.bounds.height, self.bounds.height),
velocity=(0.1, 0.4),
y_factor=(0.5, 1.5),
),
]
def CrazyPolys(self) -> List[Effect]:
return [
CrazyPolys(
bounds=self.bounds,
color=color_wheel(increase=2),
sizes=(self.bounds.height, self.bounds.height),
velocity=(0.1, 0.4),
y_factor=(0.5, 1.5),
),
]