Added simple effect system

This commit is contained in:
2015-08-28 19:43:07 +02:00
committed by Giovanni Harting
parent 4ad8b85019
commit 43c956c61d
5 changed files with 112 additions and 5 deletions

View File

@@ -13,3 +13,11 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
class BaseEffect(object):
"""
This class only defines default meta-data for effects.
"""
name = "BaseEffect"
version = "0.1"
author = "LeDD-Freaks"

View File

@@ -0,0 +1,18 @@
from ledd.effects.generatoreffect import GeneratorEffect
import spectra
class FadeEffect(GeneratorEffect):
author = "LeDD-Freaks"
version = "0.1"
name = "Fade Effect"
description = "Fades through the HSV color wheel"
def execute(self):
scale = spectra.scale([spectra.hsv(0.0, 1.0, 1.0), spectra.hsv(360, 1.0, 1.0)]).domain([0, 20000])
i = 0
while True:
yield scale(i)
i = (i + 1) % 20000

View File

@@ -0,0 +1,30 @@
from ledd.effects.baseeffect import BaseEffect
from spectra import Color
class GeneratorEffect(BaseEffect):
"""
This is a base class for simple effects.
It should yield a new color on each execution.
"""
def __init__(self):
"""
Do not override, use setup instead.
"""
self.generator = self.execute()
def setup(self):
pass
def execute_internal(self):
c = next(self.generator)
assert isinstance(c, Color)
return c
def execute(self):
pass
def tear_down(self):
pass