From 192e9d22ebb3a544fb37cd94bae8e1e38d441f28 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 15 Feb 2023 22:37:45 +0100 Subject: [PATCH] add color_fader --- effects/effect.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/effects/effect.py b/effects/effect.py index 940efa4..d23fb1e 100644 --- a/effects/effect.py +++ b/effects/effect.py @@ -2,6 +2,18 @@ import pygame as pg from abc import abstractmethod +def color_fader(hue=0, increase=1): + 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 + + class Effect(pg.sprite.Sprite): def __init__( self, image: pg.Surface, rect: pg.Rect, *groups: pg.sprite.Group