فهرست منبع

refactor FX-color, some BUG !

micha 1 سال پیش
والد
کامیت
d7d8f8a461
2فایلهای تغییر یافته به همراه79 افزوده شده و 88 حذف شده
  1. 58 41
      _LibreLightDesk.py
  2. 21 47
      _console.py

+ 58 - 41
_LibreLightDesk.py

@@ -785,11 +785,11 @@ DELAY.val(0.2)
 
 fx_prm_move = {"SIZE":40,"SPEED":8,"OFFSET":100,"BASE":"0","START":0,"MODE":0,"MO":0,"DIR":1,"INVERT":0,"WING":2,"WIDTH":100}
 
-fx_prm      = {"SIZE":255,"SPEED":10,"OFFSET":100,"BASE":"-","START":0,"MODE":0,"MO":0,"DIR":1,"INVERT":1,"SHUFFLE":0,"WING":2,"WIDTH":25,"2D-X":1,"2D:MODE":0}
-fx_x_modes    = ["spiral","left","right","up","down","left_right","up_down"]
+fx_prm = {"SIZE":255,"SPEED":10,"OFFSET":100,"BASE":"-","START":0,"MODE":0,"MO":0,"DIR":1,"INVERT":1,"SHUFFLE":0,"WING":2,"WIDTH":25,"2D-X":1,"2D:MODE":0}
+fx_x_modes = ["spiral","left","right","up","down","left_right","up_down"]
 
-fx_modes    = ["RED","GREEN","BLUE","MAG","YELLOW","CYAN"]
-fx_mo       = ["fade","on","rnd","ramp","ramp2","cosinus","sinus","static"]
+fx_modes = ["RED","GREEN","BLUE","MAG","YELLOW","CYAN"]
+fx_mo    = ["fade","on","rnd","ramp","ramp2","cosinus","sinus","static"]
 
 class FX_handler():
     def __init__():
@@ -997,7 +997,7 @@ def process_effect(wing_buffer,fx_name=""):
                     if ":DIM" in fx_name:
                         base=""
                         ffxb=fx_mo[fx_prm["MO"]] 
-                        #ffxb= "cosinus" 
+
                         if attr == "DIM":
                             if fx_prm["SPEED"] < 0:
                                 fx = "off"
@@ -1034,67 +1034,84 @@ def process_effect(wing_buffer,fx_name=""):
                                 fx = "off"
                             else:
                                 fx = "sinus"
-                    elif ":RED" in fx_name:
 
-                        ffxb= fx_mo[fx_prm["MO"]] 
-                        ffx= "off" #fx_mo[fx_prm["MO"]] 
-                        if "RED" in fx_modes[fx_prm["MODE"]]:#
+                    elif ":RED" in fx_name:
+                        fxon  = "on" #"sinus"  #fx_mo[fx_prm["MO"]] 
+                        fxoff = "static" #"off" 
+                        MODE = fx_modes[fx_prm["MODE"]]
+                        
+                        if "RED" in MODE: #fx_modes[fx_prm["MODE"]]:#
                             base="-"
                             if attr == "RED":
-                                fx=ffx
+                                fx = fxon
+                                csize *=-1
                             if attr == "GREEN":
-                                fx = ffxb# "off"
+                                fx = "static"
+                                csize = 0
+                                fx = fxon
+                                #csize *=-1
                             if attr == "BLUE":
-                                fx =  ffxb#"off"
-                        elif "GREEN" in fx_modes[fx_prm["MODE"]]:#fx_prm["MODE"]:#in fx_name:
+                                fx = "static"
+                                csize = 0
+                        elif "GREEN" in MODE: #fx_modes[fx_prm["MODE"]]:
                             base="-"
                             if attr == "RED":
-                                fx =  ffxb#"off" 
-                        elif "GREEN" in fx_modes[fx_prm["MODE"]]:#fx_prm["MODE"]:#in fx_name:
+                                fx = "static"
+                                csize = 0
                             if attr == "GREEN":
-                                fx = ffxb# "off"
-                                fx=ffx
+                                fx = fxon
+                                csize *=-1
                             if attr == "BLUE":
-                                fx =  ffxb#"off"
-                        elif "BLUE" in  fx_modes[fx_prm["MODE"]]:#fx_prm["MODE"]:#fx_name:
+                                fx = "static"
+                                csize = 0
+                        elif "BLUE" in MODE: # fx_modes[fx_prm["MODE"]]:
                             base="-"
                             if attr == "RED":
-                                fx = ffxb# "off" 
+                                fx = "static"
+                                csize = 0
                             if attr == "GREEN":
-                                fx = ffxb# "off"
+                                fx = "static"
+                                csize = 0
                             if attr == "BLUE":
-                                fx = ffxb# "off"
-                                fx=ffx
-                        elif "YELLOW" in  fx_modes[fx_prm["MODE"]]:#fx_prm["MODE"]:#fx_name:
+                                fx = fxon
+                                csize *=-1
+                        elif "YELLOW" in MODE: # fx_modes[fx_prm["MODE"]]:
                             base="-"
                             if attr == "RED":
-                                fx = ffxb# "off" 
-                                fx=ffx
+                                fx = fxon
+                                csize *=-1
                             if attr == "GREEN":
-                                fx = ffxb# "off"
-                                fx=ffx
+                                fx = fxon
+                                csize *=-1
                             if attr == "BLUE":
-                                fx = "off"
-                        elif "CYAN" in  fx_modes[fx_prm["MODE"]]:#fx_prm["MODE"]:#fx_name:
+                                fx = "static"
+                                csize = 0
+                        elif "CYAN" in MODE: # fx_modes[fx_prm["MODE"]]:
                             base="-"
                             if attr == "RED":
-                                fx = ffxb# "off" 
+                                fx = fxoff
+                                invert *= -1
+                                csize = 0
+                                fx = fxon
                             if attr == "GREEN":
-                                fx = ffxb# "off"
-                                fx=ffx
+                                fx = fxon
+                                csize=0
                             if attr == "BLUE":
-                                fx = ffxb# "off"
-                                fx=ffx
-                        elif "MAG" in  fx_modes[fx_prm["MODE"]]:#fx_prm["MODE"]:#fx_name:
+                                fx = fxon
+                                csize=0
+                        elif "MAG" in MODE: # fx_modes[fx_prm["MODE"]]:
                             base="-"
                             if attr == "RED":
-                                fx = ffxb# "off" 
-                                fx=ffx
+                                fx = fxon
+                                csize=0
                             if attr == "GREEN":
-                                fx = ffxb# "off"
+                                fx = fxoff
+                                invert *= -1
+                                csize = 0
+                                fx = fxon
                             if attr == "BLUE":
-                                fx = ffxb# "off"
-                                fx=ffx
+                                fx = fxon
+                                csize=0
                         else:
                             cprint("FX: unbekant",fx_modes[fx_prm["MODE"]],color="red")
 

+ 21 - 47
_console.py

@@ -199,15 +199,10 @@ class Fade():
         current = (self.__clock - self.__clock_curr) / self.__ftime
         length = self.__start - self.__target
         self.__last = self.__start+ length*current 
-        #if self.__last < 0:
-        #    self.__last = 0
-        #if self.__last > 255:
-        #    self.__last = 255
         self.run = 1
         return self.__last
 
     def ctl(self,cmd="",value=None): # if x-fade cmd="%" value=50
-        # start,stop,fwd,bwd,revers
         pass
 
 class _MASTER():
@@ -248,8 +243,6 @@ exe_master.append({"SIZE":100,"SPEED":100,"id":12,"link-ids":[2]})
 
 class MASTER_FX():
     def __init__(self):
-        #cprint(self,"MASTER_FX INIT !",color="green")
-
         self.__data = []
         self.__ok = []
         self.i=0
@@ -257,12 +250,11 @@ class MASTER_FX():
         self.offsets = []
         self.count = -1
         self.init = 10
+
     def add(self,fx):
         if fx not in self.__data:
-            #cprint(self,"ADD TO MASTER !",color="green")
             self.__data.append(fx)
             info = fx._get_info()
-            #cprint(self,"ADD" ,info,color="green")
             offset = 0
             if "offset" in info:
                 offset = info["offset"]
@@ -271,19 +263,13 @@ class MASTER_FX():
             if "xtype" in info:
                 if info["xtype"] == "rnd":
                     self._shuffle()
-                    #self.init += 1
             
     def _shuffle(self):
-        #cprint(self,"REORDER RANDOM !",color="green")
-        #self.init = 0
-
-        #cprint(self.old_offsets)
         random.seed(1000)
         random.shuffle(self.old_offsets)
-        #cprint(self.old_offsets)
+
     def _init(self):
         self._shuffle()
-        #self.offsets = []
         for i,v in enumerate(self.old_offsets):
             offset = self.old_offsets[i]
             self.offsets[i] =  offset
@@ -293,13 +279,8 @@ class MASTER_FX():
         offset = self.old_offsets[i]
         self.offsets[i] =  offset
         return offset
-        #for i,v in enumerate(self.old_offsets):
-        #    offset = self.old_offsets[i]
-        #    self.offsets[i] =  offset
-
 
     def get(self,child,count):
-
         offset = 0
 
         if child not in self.__data:
@@ -312,7 +293,6 @@ class MASTER_FX():
         if (self.count != count and idx == 0 ) or  self.init == 0:
             self.init = 1
             self._shuffle()
-            #print( count)
             self.count=count
             
         idx = self.__data.index(child) 
@@ -381,7 +361,6 @@ class FX():
                     self.next(), self.__xtype, self.__size, self.__speed, self.__angel
                     , self.__base, self.__clock_curr, self.run, self._exec_id,ABS )
 
-    #def _calc_fx(self):
     def _calc_fx(self,v,t,size,base):
         base = 0
         if self.__base == "-": # sub
@@ -394,6 +373,7 @@ class FX():
                 v = v-1
         else:
             v = (t%1-0.5)
+        return v
 
     def next(self,clock=None):
         if type(clock) is float or type(clock) is int:#not None:
@@ -461,43 +441,31 @@ class FX():
                  self.__master.next(self)#,count)
             self.__offset = self.__master.get(self,count)
                 
-            self._calc_fx(v,t,size,base)
+            v = self._calc_fx(v,t,size,base)
 
         elif self.__xtype == "on":
             if self.__angel > 90 and self.__angel <=270:
                 v=1
             else:
                 v=0
-            self._calc_fx(v,t,size,base)
+            v = self._calc_fx(v,t,size,base)
 
-        elif self.__xtype == "ramp" or self.__xtype == "ramp":
+        elif self.__xtype == "ramp" or self.__xtype == "bump":
             v = (t%1) 
-            base = 0
-            if self.__base == "-": # sub
-                if self.__invert:
-                    v = 1-v
-                    size *=-1
-                v *=-1
-            elif self.__base == "+": # sub
-                if self.__invert:
-                    v = v-1
-            else:
-                v = (t%1-0.5)
-            self._calc_fx(v,t,size,base)
-
-
-        elif self.__xtype == "static":
-            self.abs = 1
-            base = size #100
-            v=0
-            size=0
+            v = self._calc_fx(v,t,size,base)
             
         elif self.__xtype == "ramp2" or self.__xtype == "bump2":
             v = (t%1) 
             v = 1-v  
             if v == 1:
                 v=0
-            self._calc_fx(v,t,size,base)
+            v = self._calc_fx(v,t,size,base)
+
+        elif self.__xtype == "static":
+            self.abs = 1
+            base = size #100
+            v=0
+            size=0
 
         elif self.__xtype == "fade":
             x = t * 2 
@@ -535,6 +503,7 @@ class DMXCH(object):
 
         self._fix_id = 0 
         self._v_master_id=0
+        self._last_val_raw=0
 
         self._flash    = None
         self._flash_fx = None
@@ -557,7 +526,10 @@ class DMXCH(object):
             fx_value = self._fx_value
             if fx_value != 0:
                 cprint("???????______ FX OFF AS FADE",fx_value,0,255)
-                self._fx[1] = Fade(fx_value,0,ftime=0.5,clock=clock) 
+                if self._fx[1].abs:
+                    self._fx[1] = Fade(self._last_val_raw,0,ftime=0.5,clock=clock) 
+                else:
+                    self._fx[1] = Fade(fx_value,0,ftime=0.5,clock=clock) 
             else:
                 self._fx[1] = None
                 self._fx_value = 0 
@@ -669,6 +641,8 @@ class DMXCH(object):
             self._last_val = fx_value
         else:
             self._last_val = value + fx_value
+        
+        self._last_val_raw = self._last_val 
 
 
         if self._v_master_id in V_MASTER: