# HG changeset patch # User David McClosky # Date 1276990833 0 # Node ID ff36ce3038bef5cedf6b15edf6f724b50735c650 # Parent a4b1e51d816953852c8e44ab288308ee4d6c70a7 Effects: chase can now randomize with random kw, add stack (untested!) Ignore-this: 977a062ab00c40b629b568f72c70562f diff -r a4b1e51d8169 -r ff36ce3038be light9/Effects.py --- a/light9/Effects.py Sat Jun 19 23:40:24 2010 +0000 +++ b/light9/Effects.py Sat Jun 19 23:40:33 2010 +0000 @@ -1,5 +1,5 @@ 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.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 @@ 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 = {}