Package SmootLight :: Package behaviors :: Module TouchOSC
[hide private]
[frames] | no frames]

Source Code for Module SmootLight.behaviors.TouchOSC

 1  from operationscore.Behavior import *  
 2  from logger import main_log 
 3  #import util.ColorOps as color  
 4  import colorsys 
 5  import pdb 
 6  import util.ComponentRegistry as compReg 
7 -class TouchOSC(Behavior):
8 - def behaviorInit(self):
9 self.h=0 10 self.s=0 11 self.v=0 12 self.xy = (-1,-1)
13 - def processResponse(self, sensorInputs, recursiveInputs):
14 ret = [] 15 if sensorInputs: 16 data = sensorInputs[-1]#for data in sensorInputs: 17 if data['Path'] == '/1/fader1': 18 try: 19 self.h = data['Value'][0] 20 except: 21 pdb.set_trace() 22 elif data['Path'] == '/1/fader2': 23 self.s = data['Value'][0] 24 elif data['Path'] == '/1/fader3': 25 self.v = data['Value'][0] 26 elif data['Path'] == '/1/xy': 27 val=data['Value'] 28 ssize = compReg.getComponent('Screen').getSize()[-2:] #896 x 310 29 self.xy = (val[1]*ssize[0], (1.0-val[0])*ssize[1]) 30 else: 31 main_log.error('Sensor Inputs: ' + str(sensorInputs)) 32 ret.append({'Color':[i*255 for i in colorsys.hsv_to_rgb(self.h,self.s,self.v)],'Location':self.xy}) 33 34 return (ret, [])
35