Add oscillating spot row, strobe lines

This commit is contained in:
Patrick Moessler 2023-02-24 18:59:24 +01:00
parent bb29fcac7b
commit e0d1e23ef8
4 changed files with 46 additions and 17 deletions

View file

@ -37,8 +37,6 @@ square
square two color
line falling
line scan vh
starfield spawn chance

View file

@ -12,7 +12,7 @@ class Lines(MovingEffect):
bounds: pg.Rect,
vectors: Iterable[Tuple[XYCoord, XYCoord, ColorGenerator]],
thickness: int,
mover: Optional[PositionGenerator],
mover: Optional[PositionGenerator] = None,
*groups: pg.sprite.Group,
) -> None:
self.vectors = vectors

View file

@ -40,7 +40,7 @@ class Presets:
self.beat_reactive = beat_reactive
def default(self) -> List[Effect]:
return self.SpotRow()
return self.StrobeLine()
def __getitem__(self, idx: str) -> List[Effect]:
return getattr(self, idx)()
@ -382,25 +382,32 @@ class Presets:
]
def StrobeLine(self) -> List[Effect]:
bounds = pg.rect.Rect(0, 0, self.bounds.width, 30)
thickness = 50
bounds = pg.rect.Rect(0, 0, self.bounds.width, thickness)
return [
Lines(
bounds=bounds,
vectors=(
(
(0, 15),
(self.bounds.width, 15),
color_strobe(color=color_wheel(), rate=(2, 8)),
(0, thickness // 2),
(self.bounds.width, thickness // 2),
color_strobe(color=color_wheel(), rate=(4, 60)),
),
),
thickness=30,
mover=transform_falling(
bounds,
acceleration=0.8,
initial_pos=(0, 0),
initial_velocity=0.01,
on_beat_reset=True,
thickness=thickness,
mover=transform_static((0, 0)),
),
Lines(
bounds=bounds,
vectors=(
(
(0, thickness // 2),
(self.bounds.width, thickness // 2),
color_strobe(color=color_wheel(), rate=(4, 10)),
),
),
thickness=thickness,
mover=transform_static((0, self.bounds.height - thickness)),
),
]
@ -450,3 +457,27 @@ class Presets:
)
for i in range(count)
]
def OscillateSpotRow(self) -> List[Effect]:
count = 4
size = self.bounds.width // (count * 2)
return [
BouncingSpot(
bounds=self.bounds,
color=color_wheel(hue=180 * i, increase=120),
sizes=(size * 1.5, size * 1.5),
velocity=(1, 1),
on_beat_color=True,
mover=transform_oscillate(
bounds=pg.Rect(
size + size * 2 * i,
size * 1.5 // 2,
size * 1.5,
self.bounds.height,
),
period=120,
auto_period=4,
),
)
for i in range(count)
]

View file

@ -1,8 +1,8 @@
from typing import Any, Optional, Tuple
from typing import Any, Optional
import pygame as pg
from effects.effect import MovingEffect
from util.color import Colors, ColorGenerator
from util.transform import PositionGenerator, transform_bounce
from util.transform import PositionGenerator
import math
from typing import Generator