showtest changes

This commit is contained in:
Patrick Moessler 2023-02-24 17:23:22 +01:00
parent 54b825c7cb
commit a9c9582180
3 changed files with 46 additions and 27 deletions

View file

@ -5,9 +5,10 @@ from typing import Iterator, List
from random import choice, randint, randrange
from effects.effect import Effect
from util.color import color_darken, color_randomize, color_wheel, Colors
from effects.line import Lines
from util.color import color_darken, color_randomize, color_strobe, color_wheel, Colors
from effects.crazypolys import CrazyPolys
# from effects.crazypolys import CrazyPolys
from effects.drops import Drops
from effects.bouncingspot import BouncingSpot
from effects.doublespot import DoubleSpot
@ -15,7 +16,8 @@ from effects.moonflower import Moonflower
from effects.rainbowwave import RainbowWave
from effects.rotatingpoly import RotatingPoly
from effects.scanreticle import ScanReticle
from effects.spiro import Spiro
# from effects.spiro import Spiro
from effects.starfield import Starfield
from util.transform import (
transform_bounce,
@ -31,7 +33,7 @@ class Presets:
self.beat_reactive = beat_reactive
def default(self) -> List[Effect]:
return self.FallingWave()
return self.FallingLine()
def __getitem__(self, idx: str) -> List[Effect]:
return getattr(self, idx)()
@ -51,7 +53,8 @@ class Presets:
[
func
for func in dir(self)
if callable(getattr(self, func)) and not func.startswith("__")
if callable(getattr(self, func))
and not (func.startswith("__") or func == "randomize")
]
)
@ -73,7 +76,7 @@ class Presets:
BouncingSpot(
bounds=self.bounds,
color=color_wheel(),
sizes=(self.bounds.height / 12, self.bounds.height / 10),
sizes=(self.bounds.height / 8, self.bounds.height / 6),
mover=transform_bounce(
bounds=self.bounds,
velocity=(1, 1),
@ -85,7 +88,7 @@ class Presets:
BouncingSpot(
bounds=self.bounds,
color=color_wheel(hue=180),
sizes=(self.bounds.height / 12, self.bounds.height / 10),
sizes=(self.bounds.height / 8, self.bounds.height / 6),
mover=transform_bounce(
bounds=self.bounds,
velocity=(1, 1),
@ -102,12 +105,12 @@ class Presets:
bounds=pg.rect.Rect(0, 0, self.bounds.width, self.bounds.height),
wave_count=5,
wave_height=self.bounds.height // 6,
thickness=20,
thickness=30,
mover=transform_oscillate(self.bounds, 60, (0, 0)),
),
RainbowWave(
bounds=pg.rect.Rect(0, 0, self.bounds.width, self.bounds.height),
hue=180,
# hue=180,
wave_count=5,
wave_height=self.bounds.height // 6,
start_phase=120,
@ -118,14 +121,26 @@ class Presets:
),
]
def RainbowWave(self) -> List[Effect]:
return [
RainbowWave(
bounds=pg.rect.Rect(0, 0, self.bounds.width, self.bounds.height),
wave_count=1,
color_inc=2,
wave_height=self.bounds.height // 3,
thickness=30,
mover=transform_static(position=(0, 0)),
),
]
def FallingWave(self) -> List[Effect]:
bounds = pg.rect.Rect(0, 0, self.bounds.width, self.bounds.height // 3)
bounds = pg.rect.Rect(0, 0, self.bounds.width, self.bounds.height // 2)
return [
RainbowWave(
bounds=bounds,
wave_count=8,
wave_height=self.bounds.height // 8,
thickness=20,
thickness=25,
hue=30 * randrange(0, 12),
color_inc=0,
scroll_speed=0,
@ -144,14 +159,14 @@ class Presets:
BouncingSpot(
bounds=self.bounds,
color=Colors.White,
sizes=(self.bounds.height / 8, self.bounds.height / 8),
sizes=(self.bounds.height / 3, self.bounds.height / 3),
velocity=(1, 1),
mover=transform_bounce(
bounds=self.bounds,
velocity=(1, 1),
x_factor=(1, 1),
y_factor=(2.2, 2.2),
on_beat_random_phase=180,
on_beat_phase=180,
),
),
]
@ -180,8 +195,9 @@ class Presets:
color_wheel(hue=180, increase=(75 if self.beat_reactive else 0)),
),
beat_color=self.beat_reactive,
size=self.bounds.height // 4,
size=self.bounds.height // 2,
outer=5,
inner_factor=0.3,
rot_speed=1.5,
mover=transform_bounce(
bounds=self.bounds,
@ -236,18 +252,19 @@ class Presets:
]
def NestedMoonflower(self) -> List[Effect]:
hue_left = randrange(0, 360)
hue_right = randrange(0, 360)
hue_left = randrange(0, 12) * 30
hue_right = (hue_left + 180) % 360
# hue_right = randrange(0, 360)
size = int(self.bounds.height * 0.8)
return [
Moonflower(
bounds=self.bounds,
colors=(
color_wheel(
hue=hue_left, increase=(75 if self.beat_reactive else 0)
hue=hue_left, increase=(15 if self.beat_reactive else 0)
),
color_wheel(
hue=180 + hue_left, increase=(75 if self.beat_reactive else 0)
hue=180 + hue_left, increase=(15 if self.beat_reactive else 0)
),
),
beat_color=self.beat_reactive,
@ -263,16 +280,16 @@ class Presets:
bounds=self.bounds,
colors=(
color_wheel(
hue=hue_right, increase=(75 if self.beat_reactive else 0)
hue=hue_right, increase=(15 if self.beat_reactive else 0)
),
color_wheel(
hue=180 + hue_right, increase=(75 if self.beat_reactive else 0)
hue=180 + hue_right, increase=(15 if self.beat_reactive else 0)
),
),
beat_color=self.beat_reactive,
size=int(size * 0.7),
size=int(size * 0.6),
outer=7,
inner_factor=0.5,
inner_factor=0.3,
rot_speed=1,
mover=transform_static(
position=(self.bounds.width // 2, self.bounds.height // 2)

View file

@ -23,6 +23,7 @@ class RotatingPoly(Effect):
velocity: Tuple[float, float] = (1, 10),
rot_speed: float = 5,
outer: int = 5,
spot_factor: float = 0.5,
x_factor: Tuple[float, float] = (0.1, 1),
y_factor: Tuple[float, float] = (0.1, 1),
*groups: pg.sprite.Group
@ -36,6 +37,7 @@ class RotatingPoly(Effect):
self.color = color
self.beat_color = beat_color
self.o_count = outer
self.spot_factor = spot_factor
self.o_f = 1 / math.sin(math.pi / self.o_count)
@ -90,7 +92,7 @@ class RotatingPoly(Effect):
self.image,
Colors.White,
(pos_x, pos_y),
self.spot_radius,
self.spot_radius * self.spot_factor,
)
self.rotation += self.rot_speed

View file

@ -18,7 +18,7 @@ class ScanReticle(MovingEffect):
) -> None:
self.colors = colors
self.bounds = bounds
self.rect_size = min(self.bounds.width // 8, self.bounds.height // 8)
self.rect_size = min(self.bounds.width // 6, self.bounds.height // 6)
image = pg.Surface(self.bounds.size)
image.fill(Colors.Black)
@ -51,7 +51,7 @@ class ScanReticle(MovingEffect):
self.rect_size,
self.rect_size,
),
0 if kwargs["is_beat"] else 10,
0 if kwargs["is_beat"] else 20,
)
pg.draw.line(
@ -59,12 +59,12 @@ class ScanReticle(MovingEffect):
line_color,
(0, target[1]),
(self.bounds.width, target[1]),
10,
20,
)
pg.draw.line(
self.image,
line_color,
(target[0], 0),
(target[0], self.bounds.height),
10,
20,
)