from effects.effect import MovingEffect from typing import Any, Iterable, Optional, Tuple from util import XYCoord from util.color import Colors, ColorGenerator from util.transform import PositionGenerator import pygame as pg class Lines(MovingEffect): def __init__( self, bounds: pg.Rect, vectors: Iterable[Tuple[XYCoord, XYCoord, ColorGenerator]], thickness: int, mover: Optional[PositionGenerator] = None, *groups: pg.sprite.Group, ) -> None: self.vectors = vectors self.thickness = thickness image = pg.Surface(bounds.size) image.fill(Colors.Black) image.set_colorkey(Colors.Black) super().__init__( image, pg.Rect(bounds), mover, *groups, ) self.bounds = bounds self.update(is_beat=False) def update(self, *args: Any, **kwargs: Any) -> None: self.rect.topleft = self.mover.send((self.rect.size, kwargs["is_beat"])) self.image.fill(Colors.Black) for line in self.vectors: pg.draw.line( self.image, next(line[2]), line[0], line[1], width=self.thickness, )