From e0d1e23ef81ba63dc92b675163f28807d60e6ba4 Mon Sep 17 00:00:00 2001 From: Patrick Moessler Date: Fri, 24 Feb 2023 18:59:24 +0100 Subject: [PATCH] Add oscillating spot row, strobe lines --- effects/effect.py | 2 -- effects/line.py | 2 +- effects/presets.py | 55 ++++++++++++++++++++++++++++++++--------- effects/rotatingpoly.py | 4 +-- 4 files changed, 46 insertions(+), 17 deletions(-) diff --git a/effects/effect.py b/effects/effect.py index fc03e27..a597d80 100644 --- a/effects/effect.py +++ b/effects/effect.py @@ -37,8 +37,6 @@ square square two color -line falling - line scan vh starfield spawn chance diff --git a/effects/line.py b/effects/line.py index 263367a..aa16300 100644 --- a/effects/line.py +++ b/effects/line.py @@ -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 diff --git a/effects/presets.py b/effects/presets.py index 2c13477..b1b32a2 100644 --- a/effects/presets.py +++ b/effects/presets.py @@ -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) + ] diff --git a/effects/rotatingpoly.py b/effects/rotatingpoly.py index f2324cf..e50ae6e 100644 --- a/effects/rotatingpoly.py +++ b/effects/rotatingpoly.py @@ -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