aboutsummaryrefslogtreecommitdiff
path: root/pixelevents/DecayEvent.py
blob: 01255be49737357b97b65e46a34793326bfac764 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from operationscore.PixelEvent import *
import Util, math
class DecayEvent(PixelEvent):
    def initEvent(self):
        self.validateArgs('DecayEvent.params')
        self['Coefficient'] = abs(self['Coefficient'])
    def state(self,timeDelay):
        if self['DecayType'] == 'Exponential':
            decay = math.exp(timeDelay*-1*self['Coefficient'])
        if self['DecayType'] == 'Proportional':
            decay = float(self['Coefficient']) / timeDelay
        color = Util.multiplyColor(self['Color'], decay)
        return color if sum(color) > 5 else None
    @staticmethod
    def generate(decayType, coefficient, color):
        args = {'DecayType': decayType, 'Coefficient':coefficient, 'Color':color}
        return DecayEvent(args)