Changeset - ff36ce3038be
[Not reviewed]
default
0 1 0
David McClosky - 15 years ago 2010-06-19 23:40:33
dmcc@bigasterisk.com
Effects: chase can now randomize with random kw, add stack (untested!)
Ignore-this: 977a062ab00c40b629b568f72c70562f
1 file changed with 29 insertions and 3 deletions:
0 comments (0 inline, 0 general)
light9/Effects.py
Show inline comments
 
from __future__ import division
 
import random
 
from random import Random
 
import light9.Submaster as Submaster
 
from chase import chase as chase_logic
 
import showconfig
 
@@ -8,10 +8,14 @@ from light9 import Patch
 
from light9.namespaces import L9
 

	
 
def chase(t, ontime=0.5, offset=0.2, onval=1.0, 
 
          offval=0.0, names=None, combiner=max):
 
          offval=0.0, names=None, combiner=max, random=False):
 
    """names is list of URIs. returns a submaster that chases through
 
    the inputs"""
 
    sub_vals = {}
 
    if random:
 
        r = Random(random)
 
        names = names[:]
 
        r.shuffle(names)
 

	
 
    chase_vals = chase_logic(t, ontime, offset, onval, offval, names, combiner)
 
    lev = {}
 
    for uri, value in chase_vals.items():
 
@@ -26,6 +30,28 @@ def chase(t, ontime=0.5, offset=0.2, onv
 
    ret = Submaster.Submaster(leveldict=lev, temporary=True)
 
    return ret
 

	
 
def stack(t, names=None):
 
    """names is list of URIs. returns a submaster that stacks the the inputs"""
 
    frac = 1.0 / (len(names) + 1)
 
    threshold = frac
 

	
 
    lev = {}
 
    for uri in names:
 
        try:
 
            dmx = Patch.dmx_from_uri(uri)
 
        except KeyError:
 
            print ("chase includes %r, which doesn't resolve to a dmx chan" %
 
                   uri)
 
            continue
 
        lev[dmx] = 1
 

	
 
        threshold += frac
 
        if threshold > t:
 
            break
 

	
 
    ret = Submaster.Submaster(leveldict=lev, temporary=True)
 
    return ret
 

	
 
def configExprGlobals():
 
    graph = showconfig.getGraph()
 
    ret = {}
0 comments (0 inline, 0 general)