Package SmootLight :: Package pixelevents :: Module DecayEvent
[hide private]
[frames] | no frames]

Source Code for Module SmootLight.pixelevents.DecayEvent

 1  from operationscore.PixelEvent import * 
 2  import math 
 3  from util.ColorOps import *  
 4  import util.Geo as Geo 
5 -class DecayEvent(PixelEvent):
6 """DecayEvent is a pixel event that can decay either Exponentially or Proportionally. Specify: 7 <DecayType> -- Exponential or Proportional 8 <Coefficient> -- Controls the speed of decay.""" 9
10 - def initEvent(self):
11 self.coefficient = float(abs(self.Coefficient)) 12 if self.DecayType == 'Exponential': 13 self.decayType = 1 14 else: 15 self.decayType = 2 16 self.color = self.Color
17 18 #SUBVERTING DESIGN FOR THE SAKE OF EFFICIENCY -- RUSSELL COHEN (2011-01-03-23:18)
19 - def state(self,timeDelay):
20 if self.decayType == 1: 21 decay = Geo.approxexp(timeDelay*-1*self.coefficient) 22 if self.decayType == 2: 23 decay = self.coefficient / timeDelay 24 color = multiplyColor(self.color, decay) 25 return color if (color[0] + color[1] + color[2]) > 5 else None
26 27 @staticmethod
28 - def generate(decayType, coefficient, color):
29 args = {'DecayType': decayType, 'Coefficient':coefficient, 'Color':color} 30 return DecayEvent(args)
31