annotate light9/Effects.py @ 1152:eb8c4352798c

LR support in EE Ignore-this: 55d3491da3979e323c465b32b2b304a4
author drewp@bigasterisk.com
date Sat, 14 Jun 2014 23:03:46 +0000
parents a073565e826e
children c98a239e0d0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
400
b2858c2d4a4d aft() has smooth arg; workaround for CC writing poor subterms
Drew Perttula <drewp@bigasterisk.com>
parents: 399
diff changeset
1 from __future__ import division
1107
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
2 import random as random_mod
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
3 import math
989
d91015a384fb new hsv effect for controlling some leds. channels not configurable yet
drewp@bigasterisk.com
parents: 914
diff changeset
4 import logging, colorsys
324
f913fc297b2d add back_colors and zips light lists for chases
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
5 import light9.Submaster as Submaster
f913fc297b2d add back_colors and zips light lists for chases
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
6 from chase import chase as chase_logic
399
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
7 import showconfig
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
8 from rdflib import RDF
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
9 from light9 import Patch
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
10 from light9.namespaces import L9
790
690c837f8842 logging
drewp@bigasterisk.com
parents: 606
diff changeset
11 log = logging.getLogger()
324
f913fc297b2d add back_colors and zips light lists for chases
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
12
1107
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
13 registered = []
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
14 def register(f):
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
15 registered.append(f)
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
16 return f
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
17
1124
4eb7dc40797f just called Strip now
Drew Perttula <drewp@bigasterisk.com>
parents: 1121
diff changeset
18 @register
4eb7dc40797f just called Strip now
Drew Perttula <drewp@bigasterisk.com>
parents: 1121
diff changeset
19 class Strip(object):
1115
818275850003 effecteval screens for only the kinds of outputs that it can send, so i can run a second instance just for LEDs
Drew Perttula <drewp@bigasterisk.com>
parents: 1107
diff changeset
20 """list of r,g,b tuples for sending to an LED strip"""
1152
eb8c4352798c LR support in EE
drewp@bigasterisk.com
parents: 1138
diff changeset
21 which = 'L' # LR means both
1115
818275850003 effecteval screens for only the kinds of outputs that it can send, so i can run a second instance just for LEDs
Drew Perttula <drewp@bigasterisk.com>
parents: 1107
diff changeset
22 pixels = []
1124
4eb7dc40797f just called Strip now
Drew Perttula <drewp@bigasterisk.com>
parents: 1121
diff changeset
23 @classmethod
4eb7dc40797f just called Strip now
Drew Perttula <drewp@bigasterisk.com>
parents: 1121
diff changeset
24 def solid(cls, which='L', color=(1,1,1)):
4eb7dc40797f just called Strip now
Drew Perttula <drewp@bigasterisk.com>
parents: 1121
diff changeset
25 x = cls()
4eb7dc40797f just called Strip now
Drew Perttula <drewp@bigasterisk.com>
parents: 1121
diff changeset
26 x.which = which
4eb7dc40797f just called Strip now
Drew Perttula <drewp@bigasterisk.com>
parents: 1121
diff changeset
27 x.pixels = [tuple(color)] * 50
4eb7dc40797f just called Strip now
Drew Perttula <drewp@bigasterisk.com>
parents: 1121
diff changeset
28 return x
4eb7dc40797f just called Strip now
Drew Perttula <drewp@bigasterisk.com>
parents: 1121
diff changeset
29
1136
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
30 def __mul__(self, f):
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
31 if not isinstance(f, (int, float)):
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
32 raise TypeError
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
33
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
34 s = Strip()
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
35 s.which = self.which
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
36 s.pixels = [(r*f, g*f, b*f) for r,g,b in self.pixels]
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
37 return s
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
38
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
39 __rmul__ = __mul__
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
40
1124
4eb7dc40797f just called Strip now
Drew Perttula <drewp@bigasterisk.com>
parents: 1121
diff changeset
41 @register
1115
818275850003 effecteval screens for only the kinds of outputs that it can send, so i can run a second instance just for LEDs
Drew Perttula <drewp@bigasterisk.com>
parents: 1107
diff changeset
42 class Blacklight(float):
818275850003 effecteval screens for only the kinds of outputs that it can send, so i can run a second instance just for LEDs
Drew Perttula <drewp@bigasterisk.com>
parents: 1107
diff changeset
43 """a level for the blacklight PWM output"""
1137
05f272019697 Blacklight can multiply and keep its type
drewp@bigasterisk.com
parents: 1136
diff changeset
44 def __mul__(self, f):
1138
a073565e826e ..without recursion
drewp@bigasterisk.com
parents: 1137
diff changeset
45 return Blacklight(float(self) * f)
1137
05f272019697 Blacklight can multiply and keep its type
drewp@bigasterisk.com
parents: 1136
diff changeset
46 __rmul__ = __mul__
1115
818275850003 effecteval screens for only the kinds of outputs that it can send, so i can run a second instance just for LEDs
Drew Perttula <drewp@bigasterisk.com>
parents: 1107
diff changeset
47
1107
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
48 @register
324
f913fc297b2d add back_colors and zips light lists for chases
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
49 def chase(t, ontime=0.5, offset=0.2, onval=1.0,
579
ff36ce3038be Effects: chase can now randomize with random kw, add stack (untested!)
David McClosky <dmcc@bigasterisk.com>
parents: 447
diff changeset
50 offval=0.0, names=None, combiner=max, random=False):
399
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
51 """names is list of URIs. returns a submaster that chases through
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
52 the inputs"""
579
ff36ce3038be Effects: chase can now randomize with random kw, add stack (untested!)
David McClosky <dmcc@bigasterisk.com>
parents: 447
diff changeset
53 if random:
1107
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
54 r = random_mod.Random(random)
579
ff36ce3038be Effects: chase can now randomize with random kw, add stack (untested!)
David McClosky <dmcc@bigasterisk.com>
parents: 447
diff changeset
55 names = names[:]
ff36ce3038be Effects: chase can now randomize with random kw, add stack (untested!)
David McClosky <dmcc@bigasterisk.com>
parents: 447
diff changeset
56 r.shuffle(names)
ff36ce3038be Effects: chase can now randomize with random kw, add stack (untested!)
David McClosky <dmcc@bigasterisk.com>
parents: 447
diff changeset
57
324
f913fc297b2d add back_colors and zips light lists for chases
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
58 chase_vals = chase_logic(t, ontime, offset, onval, offval, names, combiner)
399
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
59 lev = {}
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
60 for uri, value in chase_vals.items():
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
61 try:
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
62 dmx = Patch.dmx_from_uri(uri)
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
63 except KeyError:
790
690c837f8842 logging
drewp@bigasterisk.com
parents: 606
diff changeset
64 log.info(("chase includes %r, which doesn't resolve to a dmx chan" %
690c837f8842 logging
drewp@bigasterisk.com
parents: 606
diff changeset
65 uri))
399
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
66 continue
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
67 lev[dmx] = value
324
f913fc297b2d add back_colors and zips light lists for chases
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
68
914
092c00f6ba25 fixes for Submaster init method
drewp@bigasterisk.com
parents: 790
diff changeset
69 return Submaster.Submaster(name="chase" ,levels=lev)
399
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
70
1107
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
71 @register
989
d91015a384fb new hsv effect for controlling some leds. channels not configurable yet
drewp@bigasterisk.com
parents: 914
diff changeset
72 def hsv(h, s, v, light='all', centerScale=.5):
d91015a384fb new hsv effect for controlling some leds. channels not configurable yet
drewp@bigasterisk.com
parents: 914
diff changeset
73 r,g,b = colorsys.hsv_to_rgb(h % 1.0, s, v)
d91015a384fb new hsv effect for controlling some leds. channels not configurable yet
drewp@bigasterisk.com
parents: 914
diff changeset
74 lev = {}
d91015a384fb new hsv effect for controlling some leds. channels not configurable yet
drewp@bigasterisk.com
parents: 914
diff changeset
75 if light in ['left', 'all']:
d91015a384fb new hsv effect for controlling some leds. channels not configurable yet
drewp@bigasterisk.com
parents: 914
diff changeset
76 lev[73], lev[74], lev[75] = r,g,b
d91015a384fb new hsv effect for controlling some leds. channels not configurable yet
drewp@bigasterisk.com
parents: 914
diff changeset
77 if light in ['right', 'all']:
d91015a384fb new hsv effect for controlling some leds. channels not configurable yet
drewp@bigasterisk.com
parents: 914
diff changeset
78 lev[80], lev[81], lev[82] = r,g,b
d91015a384fb new hsv effect for controlling some leds. channels not configurable yet
drewp@bigasterisk.com
parents: 914
diff changeset
79 if light in ['center', 'all']:
d91015a384fb new hsv effect for controlling some leds. channels not configurable yet
drewp@bigasterisk.com
parents: 914
diff changeset
80 lev[88], lev[89], lev[90] = r*centerScale,g*centerScale,b*centerScale
d91015a384fb new hsv effect for controlling some leds. channels not configurable yet
drewp@bigasterisk.com
parents: 914
diff changeset
81 return Submaster.Submaster(name='hsv', levels=lev)
1115
818275850003 effecteval screens for only the kinds of outputs that it can send, so i can run a second instance just for LEDs
Drew Perttula <drewp@bigasterisk.com>
parents: 1107
diff changeset
82
818275850003 effecteval screens for only the kinds of outputs that it can send, so i can run a second instance just for LEDs
Drew Perttula <drewp@bigasterisk.com>
parents: 1107
diff changeset
83 @register
606
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
84 def stack(t, names=None, fade=0):
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
85 """names is list of URIs. returns a submaster that stacks the the inputs
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
86
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
87 fade=0 makes steps, fade=1 means each one gets its full fraction
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
88 of the time to fade in. Fades never...
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
89 """
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
90 frac = 1.0 / len(names)
579
ff36ce3038be Effects: chase can now randomize with random kw, add stack (untested!)
David McClosky <dmcc@bigasterisk.com>
parents: 447
diff changeset
91
ff36ce3038be Effects: chase can now randomize with random kw, add stack (untested!)
David McClosky <dmcc@bigasterisk.com>
parents: 447
diff changeset
92 lev = {}
606
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
93 for i, uri in enumerate(names):
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
94 if t >= (i + 1) * frac:
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
95 try:
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
96 dmx = Patch.dmx_from_uri(uri)
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
97 except KeyError:
790
690c837f8842 logging
drewp@bigasterisk.com
parents: 606
diff changeset
98 log.info(("stack includes %r, which doesn't resolve to a dmx chan"%
690c837f8842 logging
drewp@bigasterisk.com
parents: 606
diff changeset
99 uri))
606
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
100 continue
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
101 lev[dmx] = 1
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
102 else:
579
ff36ce3038be Effects: chase can now randomize with random kw, add stack (untested!)
David McClosky <dmcc@bigasterisk.com>
parents: 447
diff changeset
103 break
606
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
104
914
092c00f6ba25 fixes for Submaster init method
drewp@bigasterisk.com
parents: 790
diff changeset
105 return Submaster.Submaster(name="stack", levels=lev)
579
ff36ce3038be Effects: chase can now randomize with random kw, add stack (untested!)
David McClosky <dmcc@bigasterisk.com>
parents: 447
diff changeset
106
1107
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
107 @register
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
108 def smoove(x):
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
109 return -2 * (x ** 3) + 3 * (x ** 2)
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
110
399
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
111 def configExprGlobals():
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
112 graph = showconfig.getGraph()
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
113 ret = {}
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
114
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
115 for chaseUri in graph.subjects(RDF.type, L9['Chase']):
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
116 shortName = chaseUri.rsplit('/')[-1]
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
117 chans = graph.value(chaseUri, L9['channels'])
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
118 ret[shortName] = list(graph.items(chans))
447
fecb60bfc532 curvecalc prints chase names
drewp@bigasterisk.com
parents: 400
diff changeset
119 print "%r is a chase" % shortName
399
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
120
1107
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
121 for f in registered:
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
122 ret[f.__name__] = f
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
123
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
124 ret['nsin'] = lambda x: (math.sin(x * (2 * math.pi)) + 1) / 2
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
125 ret['ncos'] = lambda x: (math.cos(x * (2 * math.pi)) + 1) / 2
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
126
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
127 _smooth_random_items = [random_mod.random() for x in range(100)]
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
128
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
129 # suffix '2' to keep backcompat with the versions that magically knew time
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
130 def smooth_random2(t, speed=1):
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
131 """1 = new stuff each second, <1 is slower, fade-ier"""
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
132 x = (t * speed) % len(_smooth_random_items)
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
133 x1 = int(x)
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
134 x2 = (int(x) + 1) % len(_smooth_random_items)
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
135 y1 = _smooth_random_items[x1]
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
136 y2 = _smooth_random_items[x2]
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
137 return y1 + (y2 - y1) * ((x - x1))
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
138
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
139 def notch_random2(t, speed=1):
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
140 """1 = new stuff each second, <1 is slower, notch-ier"""
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
141 x = (t * speed) % len(_smooth_random_items)
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
142 x1 = int(x)
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
143 y1 = _smooth_random_items[x1]
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
144 return y1
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
145
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
146 ret['noise2'] = smooth_random2
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
147 ret['notch2'] = notch_random2
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
148
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
149
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
150
512381de45bd effectclasss in subserver. multiline code suppport (except for evaulation). add some old effect funcs to the new evaluator
Drew Perttula <drewp@bigasterisk.com>
parents: 989
diff changeset
151
399
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
152 return ret