home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 56 / CDPowerplay56Disc2.iso / demos / blade / data1.cab / Program_Executable_Files / Lib / Interpolator.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-10-27  |  5.5 KB  |  129 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import Bladex
  5. import ObjStore
  6.  
  7. class LinearInt:
  8.     
  9.     def __init__(self, init_value, end_value):
  10.         self.init_value = init_value
  11.         self.end_value = end_value
  12.         self.period = end_value - init_value
  13.  
  14.     
  15.     def Execute(self, value):
  16.         return self.init_value + self.period * value
  17.  
  18.     
  19.     def EndExecute(self):
  20.         print 'Ended LinearInt'
  21.  
  22.  
  23.  
  24. class RGBInt:
  25.     
  26.     def __init__(self, init_value, end_value):
  27.         self.init_value = init_value
  28.         self.end_value = end_value
  29.         self.periodR = end_value[0] - init_value[0]
  30.         self.periodG = end_value[1] - init_value[1]
  31.         self.periodB = end_value[2] - init_value[2]
  32.  
  33.     
  34.     def Execute(self, value):
  35.         return (self.init_value[0] + self.periodR * value, self.init_value[1] + self.periodG * value, self.init_value[2] + self.periodB * value)
  36.  
  37.     
  38.     def EndExecute(self):
  39.         print 'Ended RGBInt'
  40.  
  41.  
  42.  
  43. class PositionInt:
  44.     
  45.     def __init__(self, init_value, end_value):
  46.         self.init_value = init_value
  47.         self.end_value = end_value
  48.         self.periodX = end_value[0] - init_value[0]
  49.         self.periodY = end_value[1] - init_value[1]
  50.  
  51.     
  52.     def Execute(self, value):
  53.         return (self.init_value[0] + self.periodX * value, self.init_value[1] + self.periodY * value)
  54.  
  55.     
  56.     def EndExecute(self):
  57.         print 'Ended RGBInt'
  58.  
  59.  
  60.  
  61. class Interp:
  62.     
  63.     def AddAction(self, init_time, end_time, interp_class):
  64.         action = (init_time, end_time, interp_class, end_time - init_time)
  65.         self.Actions.append(action)
  66.         return action
  67.  
  68.     
  69.     def RemoveAction(self, action):
  70.         print 'Trying to remove action:', action
  71.         self.Actions.remove(action)
  72.  
  73.     
  74.     def ExecuteActions(self, time):
  75.         for i in self.Actions:
  76.             end_time = i[1]
  77.             init_time = i[0]
  78.             if time > end_time:
  79.                 i[2].EndExecute()
  80.                 self.Actions.remove(i)
  81.             elif time > init_time:
  82.                 interval_time = i[3]
  83.                 value = (time - init_time) / interval_time
  84.                 i[2].Execute(value)
  85.             
  86.         
  87.  
  88.     
  89.     def Kill(self):
  90.         Bladex.RemoveAfterFrameFunc('Interp' + self.name)
  91.  
  92.     
  93.     def __init__(self, name):
  94.         self.Actions = []
  95.         self.name = name
  96.         Bladex.SetAfterFrameFunc('Interp' + name, self.ExecuteActions)
  97.         self.ObjId = ObjStore.GetNewId()
  98.         ObjStore.ObjectsStore[self.ObjId] = self
  99.  
  100.     
  101.     def __del__(self):
  102.         self.Kill()
  103.         del ObjStore.ObjectsStore[self.ObjId]
  104.  
  105.     
  106.     def persistent_id(self):
  107.         return self.ObjId
  108.  
  109.     
  110.     def __getstate__(self):
  111.         return (1, self.ObjId, self.Actions, self.name)
  112.  
  113.     
  114.     def __setstate__(self, parm):
  115.         if parm[0] == 1:
  116.             self.ObjId = parm[1]
  117.             ObjStore.ObjectsStore[self.ObjId] = self
  118.             self.Actions = parm[2]
  119.             self.name = parm[3]
  120.         else:
  121.             print 'Warning -> Version mismatch in Interp.__setstate__()'
  122.             self.Actions = []
  123.             self.name = 'UnNamed'
  124.             Bladex.SetAfterFrameFunc('Interp' + name, self.ExecuteActions)
  125.             self.ObjId = ObjStore.GetNewId()
  126.             ObjStore.ObjectsStore[self.ObjId] = self
  127.  
  128.  
  129.