Package SmootLight :: Package operationscore :: Module PixelEvent
[hide private]
[frames] | no frames]

Source Code for Module SmootLight.operationscore.PixelEvent

 1  """PixelEvent is a class defining a light response.  Inheriting classes should define state, 
 2  which should return a color, or None if the response is complete.  Consider 
 3  requiring a generate event.""" 
 4  from operationscore.SmootCoreObject import * 
 5  from pixelevents.StepEvent import * 
 6  import util.ColorOps as color 
7 -class PixelEvent(SmootCoreObject):
8 - def init(self):
9 self.validateArgs('PixelEvent.params') 10 self.initEvent()
11 - def initEvent(self):
12 pass
13 #Returns a new PixelEvent, but with a response scaled by c.
14 - def scale(self,c):
15 if c == 1: 16 return self 17 newDict = dict(self.argDict) 18 newDict['Color'] = color.multiplyColor(newDict['Color'], c) 19 return self.__class__(newDict)
20 - def state(self,timeDelay):
21 pass
22 @staticmethod
23 - def addPixelEventIfMissing(responseDict):
24 if not 'PixelEvent' in responseDict: 25 if 'Color' in responseDict: 26 color = responseDict['Color'] 27 else: 28 raise Exception('Need Color. Probably') 29 responseDict['PixelEvent'] = StepEvent.generate(300, color)
30