pybeamshow/effects/effect.py

27 lines
625 B
Python
Raw Normal View History

2023-02-15 21:08:47 +01:00
import pygame as pg
from abc import abstractmethod
2023-02-16 00:17:10 +01:00
def color_wheel(hue=0, increase=1):
2023-02-15 22:37:45 +01:00
color = pg.Color(255, 0, 0)
h, s, l, a = color.hsla
color.hsla = hue, s, l, a
while True:
yield color
h, s, l, a = color.hsla
h = (h + increase) % 360
color.hsla = h, s, l, a
2023-02-15 21:08:47 +01:00
class Effect(pg.sprite.Sprite):
def __init__(
self, image: pg.Surface, rect: pg.Rect, *groups: pg.sprite.Group
) -> None:
super().__init__(*groups)
self.rect = rect
self.image = image
def draw(self, surface: pg.Surface):
surface.blit(self.image, self.rect)