aboutsummaryrefslogtreecommitdiff
path: root/pixelevents/DecayEvent.py
blob: c1166d619c4a5b9d14c8954b83d726ea5c58f804 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from operationscore.PixelEvent import *
import math
from util.ColorOps import * 
class DecayEvent(PixelEvent):
    def initEvent(self):
        self.coefficient = float(abs(self['Coefficient']))
        if self['DecayType'] == 'Exponential':
            self.decayType = 1
        else:
            self.decayType = 2
        self.color = self['Color']   
        
    #SUBVERTING DESIGN FOR THE SAKE OF EFFICIENCY -- RUSSELL COHEN (2011-01-03-23:18)    
    def state(self,timeDelay):
        if self.decayType == 1:
            decay = math.exp(timeDelay*-1*self.coefficient)
        if self.decayType == 2:
            decay = self.coefficient / timeDelay
        color = multiplyColor(self.color, decay)
        return color if (color[0] + color[1] + color[2]) > 5 else None
        
    @staticmethod
    def generate(decayType, coefficient, color):
        args = {'DecayType': decayType, 'Coefficient':coefficient, 'Color':color}
        return DecayEvent(args)