annotate light9/Effects.py @ 1394:0bfaeaa40cfe

debug effects Ignore-this: 74e4b63b84eb58d37d1402400d77e8b4
author drewp@bigasterisk.com
date Sun, 14 Jun 2015 20:05:18 +0000
parents da8a4696227f
children b6ba0e7d126b
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"""
1254
da8a4696227f make the rgb strip work more like the neo ones
drewp@bigasterisk.com
parents: 1198
diff changeset
21 which = 'L' # LR means both. W is the wide one
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 = []
1394
0bfaeaa40cfe debug effects
drewp@bigasterisk.com
parents: 1254
diff changeset
23
0bfaeaa40cfe debug effects
drewp@bigasterisk.com
parents: 1254
diff changeset
24 def __repr__(self):
0bfaeaa40cfe debug effects
drewp@bigasterisk.com
parents: 1254
diff changeset
25 return '<Strip which=%r px0=%r>' % (self.which, self.pixels[0,:])
0bfaeaa40cfe debug effects
drewp@bigasterisk.com
parents: 1254
diff changeset
26
1124
4eb7dc40797f just called Strip now
Drew Perttula <drewp@bigasterisk.com>
parents: 1121
diff changeset
27 @classmethod
1198
c98a239e0d0b new effects
drewp@bigasterisk.com
parents: 1152
diff changeset
28 def solid(cls, which='L', color=(1,1,1), hsv=None):
c98a239e0d0b new effects
drewp@bigasterisk.com
parents: 1152
diff changeset
29 """hsv overrides color"""
c98a239e0d0b new effects
drewp@bigasterisk.com
parents: 1152
diff changeset
30 if hsv is not None:
c98a239e0d0b new effects
drewp@bigasterisk.com
parents: 1152
diff changeset
31 color = colorsys.hsv_to_rgb(hsv[0] % 1.0, hsv[1], hsv[2])
1124
4eb7dc40797f just called Strip now
Drew Perttula <drewp@bigasterisk.com>
parents: 1121
diff changeset
32 x = cls()
4eb7dc40797f just called Strip now
Drew Perttula <drewp@bigasterisk.com>
parents: 1121
diff changeset
33 x.which = which
4eb7dc40797f just called Strip now
Drew Perttula <drewp@bigasterisk.com>
parents: 1121
diff changeset
34 x.pixels = [tuple(color)] * 50
4eb7dc40797f just called Strip now
Drew Perttula <drewp@bigasterisk.com>
parents: 1121
diff changeset
35 return x
4eb7dc40797f just called Strip now
Drew Perttula <drewp@bigasterisk.com>
parents: 1121
diff changeset
36
1136
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
37 def __mul__(self, f):
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
38 if not isinstance(f, (int, float)):
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
39 raise TypeError
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
40
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
41 s = Strip()
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
42 s.which = self.which
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
43 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
44 return s
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
45
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
46 __rmul__ = __mul__
f48be3d18387 Strip can be scaled.
drewp@bigasterisk.com
parents: 1124
diff changeset
47
1124
4eb7dc40797f just called Strip now
Drew Perttula <drewp@bigasterisk.com>
parents: 1121
diff changeset
48 @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
49 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
50 """a level for the blacklight PWM output"""
1137
05f272019697 Blacklight can multiply and keep its type
drewp@bigasterisk.com
parents: 1136
diff changeset
51 def __mul__(self, f):
1138
a073565e826e ..without recursion
drewp@bigasterisk.com
parents: 1137
diff changeset
52 return Blacklight(float(self) * f)
1137
05f272019697 Blacklight can multiply and keep its type
drewp@bigasterisk.com
parents: 1136
diff changeset
53 __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
54
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
55 @register
324
f913fc297b2d add back_colors and zips light lists for chases
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
56 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
57 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
58 """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
59 the inputs"""
579
ff36ce3038be Effects: chase can now randomize with random kw, add stack (untested!)
David McClosky <dmcc@bigasterisk.com>
parents: 447
diff changeset
60 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
61 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
62 names = names[:]
ff36ce3038be Effects: chase can now randomize with random kw, add stack (untested!)
David McClosky <dmcc@bigasterisk.com>
parents: 447
diff changeset
63 r.shuffle(names)
ff36ce3038be Effects: chase can now randomize with random kw, add stack (untested!)
David McClosky <dmcc@bigasterisk.com>
parents: 447
diff changeset
64
324
f913fc297b2d add back_colors and zips light lists for chases
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
65 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
66 lev = {}
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
67 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
68 try:
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
69 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
70 except KeyError:
790
690c837f8842 logging
drewp@bigasterisk.com
parents: 606
diff changeset
71 log.info(("chase includes %r, which doesn't resolve to a dmx chan" %
690c837f8842 logging
drewp@bigasterisk.com
parents: 606
diff changeset
72 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
73 continue
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
74 lev[dmx] = value
324
f913fc297b2d add back_colors and zips light lists for chases
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
75
914
092c00f6ba25 fixes for Submaster init method
drewp@bigasterisk.com
parents: 790
diff changeset
76 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
77
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
78 @register
989
d91015a384fb new hsv effect for controlling some leds. channels not configurable yet
drewp@bigasterisk.com
parents: 914
diff changeset
79 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
80 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
81 lev = {}
d91015a384fb new hsv effect for controlling some leds. channels not configurable yet
drewp@bigasterisk.com
parents: 914
diff changeset
82 if light in ['left', 'all']:
d91015a384fb new hsv effect for controlling some leds. channels not configurable yet
drewp@bigasterisk.com
parents: 914
diff changeset
83 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
84 if light in ['right', 'all']:
d91015a384fb new hsv effect for controlling some leds. channels not configurable yet
drewp@bigasterisk.com
parents: 914
diff changeset
85 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
86 if light in ['center', 'all']:
d91015a384fb new hsv effect for controlling some leds. channels not configurable yet
drewp@bigasterisk.com
parents: 914
diff changeset
87 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
88 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
89
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
90 @register
606
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
91 def stack(t, names=None, fade=0):
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
92 """names is list of URIs. returns a submaster that stacks the the inputs
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
93
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
94 fade=0 makes steps, fade=1 means each one gets its full fraction
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
95 of the time to fade in. Fades never...
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
96 """
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
97 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
98
ff36ce3038be Effects: chase can now randomize with random kw, add stack (untested!)
David McClosky <dmcc@bigasterisk.com>
parents: 447
diff changeset
99 lev = {}
606
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
100 for i, uri in enumerate(names):
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
101 if t >= (i + 1) * frac:
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
102 try:
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
103 dmx = Patch.dmx_from_uri(uri)
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
104 except KeyError:
790
690c837f8842 logging
drewp@bigasterisk.com
parents: 606
diff changeset
105 log.info(("stack includes %r, which doesn't resolve to a dmx chan"%
690c837f8842 logging
drewp@bigasterisk.com
parents: 606
diff changeset
106 uri))
606
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
107 continue
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
108 lev[dmx] = 1
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
109 else:
579
ff36ce3038be Effects: chase can now randomize with random kw, add stack (untested!)
David McClosky <dmcc@bigasterisk.com>
parents: 447
diff changeset
110 break
606
3ed6a6b39f39 rewrite stack()
drewp@bigasterisk.com
parents: 594
diff changeset
111
914
092c00f6ba25 fixes for Submaster init method
drewp@bigasterisk.com
parents: 790
diff changeset
112 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
113
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
114 @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
115 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
116 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
117
399
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
118 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
119 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
120 ret = {}
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
121
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
122 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
123 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
124 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
125 ret[shortName] = list(graph.items(chans))
447
fecb60bfc532 curvecalc prints chase names
drewp@bigasterisk.com
parents: 400
diff changeset
126 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
127
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
128 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
129 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
130
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 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
132 ret['ncos'] = lambda x: (math.cos(x * (2 * math.pi)) + 1) / 2
1198
c98a239e0d0b new effects
drewp@bigasterisk.com
parents: 1152
diff changeset
133 def nsquare(t, on=.5):
c98a239e0d0b new effects
drewp@bigasterisk.com
parents: 1152
diff changeset
134 return (t % 1.0) < on
c98a239e0d0b new effects
drewp@bigasterisk.com
parents: 1152
diff changeset
135 ret['nsquare'] = nsquare
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
136
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 _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
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 # 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
140 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
141 """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
142 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
143 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
144 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
145 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
146 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
147 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
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 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
150 """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
151 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
152 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
153 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
154 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
155
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
156 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
157 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
158
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
159
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
160
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
161
399
40b6a06bd090 rework Effects.py to fix chase(). now uses chase lists from config.n3
Drew Perttula <drewp@bigasterisk.com>
parents: 324
diff changeset
162 return ret