37ab5878 |
1 | class JackieSquares extends SCPattern { |
2 | private BasicParameter rateParameter = new BasicParameter("RATE", 0.25); |
37ab5878 |
3 | private BasicParameter attackParameter = new BasicParameter("ATTK", 0.3); |
4 | private BasicParameter decayParameter = new BasicParameter("DECAY", 0.2); |
5 | private BasicParameter saturationParameter = new BasicParameter("SAT", 0.7); |
6 | |
7 | SinLFO hueMod = new SinLFO(0, 360, 4000); |
8 | SinLFO spreadMod = new SinLFO(1, 10, 8000); |
9 | |
10 | |
11 | class FaceFlash { |
12 | Face f; |
13 | float value; |
14 | float hue; |
15 | boolean hasPeaked; |
16 | |
17 | FaceFlash(int n) { |
18 | f = model.faces.get(n % model.faces.size()); |
19 | hue = random(360); |
20 | boolean infiniteAttack = (attackParameter.getValuef() > 0.999); |
21 | hasPeaked = infiniteAttack; |
22 | value = (infiniteAttack ? 1 : 0); |
23 | } |
24 | |
25 | // returns TRUE if this should die |
26 | boolean age(double ms) { |
27 | if (!hasPeaked) { |
28 | value = value + (float) (ms / 1000.0f * ((attackParameter.getValuef() + 0.01) * 5)); |
29 | if (value >= 1.0) { |
30 | value = 1.0; |
31 | hasPeaked = true; |
32 | } |
33 | return false; |
34 | } else { |
35 | value = value - (float) (ms / 1000.0f * ((decayParameter.getValuef() + 0.01) * 10)); |
36 | return value <= 0; |
37 | } |
38 | } |
39 | } |
40 | |
41 | private float leftoverMs = 0; |
42 | private List<FaceFlash> flashes; |
43 | private int faceNum = 0; |
44 | |
45 | public JackieSquares(GLucose glucose) { |
46 | super(glucose); |
47 | addParameter(rateParameter); |
48 | addParameter(attackParameter); |
49 | addParameter(decayParameter); |
50 | addParameter(saturationParameter); |
51 | addModulator(hueMod).trigger(); |
52 | addModulator(spreadMod).trigger(); |
53 | |
54 | flashes = new LinkedList<FaceFlash>(); |
55 | } |
56 | |
57 | public void run(double deltaMs) { |
58 | leftoverMs += deltaMs; |
59 | float msPerFlash = 1000 / ((rateParameter.getValuef() + .01) * 100); |
60 | while (leftoverMs > msPerFlash) { |
61 | leftoverMs -= msPerFlash; |
62 | faceNum += int(spreadMod.getValuef()); |
63 | flashes.add(new FaceFlash(faceNum)); |
64 | } |
65 | |
66 | for (LXPoint p : model.points) { |
67 | colors[p.index] = 0; |
68 | } |
69 | |
70 | for (FaceFlash flash : flashes) { |
71 | float hue = (hueMod.getValuef() + flash.hue) % 360.0; |
72 | color c = lx.hsb(hue, saturationParameter.getValuef() * 100, (flash.value) * 100); |
73 | for (LXPoint p : flash.f.points) { |
74 | colors[p.index] = c; |
75 | } |
76 | } |
77 | |
78 | Iterator<FaceFlash> i = flashes.iterator(); |
79 | while (i.hasNext()) { |
80 | FaceFlash flash = i.next(); |
81 | boolean dead = flash.age(deltaMs); |
82 | if (dead) { |
83 | i.remove(); |
84 | } |
85 | } |
86 | } |
87 | } |
88 | |
4a60ba58 |
89 | |
90 | class JackieLines extends SCPattern { |
91 | private BasicParameter rateParameter = new BasicParameter("RATE", 0.25); |
92 | private BasicParameter attackParameter = new BasicParameter("ATTK", 0.3); |
93 | private BasicParameter decayParameter = new BasicParameter("DECAY", 0.2); |
94 | private BasicParameter saturationParameter = new BasicParameter("SAT", 0.7); |
95 | |
96 | SinLFO hueMod = new SinLFO(0, 360, 4000); |
97 | SinLFO spreadMod = new SinLFO(1, 10, 8000); |
98 | |
99 | |
100 | class StripFlash { |
101 | Strip f; |
102 | float value; |
103 | float hue; |
104 | boolean hasPeaked; |
105 | |
106 | StripFlash(int n) { |
107 | f = model.strips.get(n % model.strips.size()); |
108 | hue = random(360); |
109 | boolean infiniteAttack = (attackParameter.getValuef() > 0.999); |
110 | hasPeaked = infiniteAttack; |
111 | value = (infiniteAttack ? 1 : 0); |
112 | } |
113 | |
114 | // returns TRUE if this should die |
115 | boolean age(double ms) { |
116 | if (!hasPeaked) { |
117 | value = value + (float) (ms / 1000.0f * ((attackParameter.getValuef() + 0.01) * 5)); |
118 | if (value >= 1.0) { |
119 | value = 1.0; |
120 | hasPeaked = true; |
121 | } |
122 | return false; |
123 | } else { |
124 | value = value - (float) (ms / 1000.0f * ((decayParameter.getValuef() + 0.01) * 10)); |
125 | return value <= 0; |
126 | } |
127 | } |
128 | } |
129 | |
130 | private float leftoverMs = 0; |
131 | private List<StripFlash> flashes; |
132 | private int stripNum = 0; |
133 | |
134 | public JackieLines(GLucose glucose) { |
135 | super(glucose); |
136 | addParameter(rateParameter); |
137 | addParameter(attackParameter); |
138 | addParameter(decayParameter); |
139 | addParameter(saturationParameter); |
140 | addModulator(hueMod).trigger(); |
141 | addModulator(spreadMod).trigger(); |
142 | |
143 | flashes = new LinkedList<StripFlash>(); |
144 | } |
145 | |
146 | public void run(double deltaMs) { |
147 | leftoverMs += deltaMs; |
148 | float msPerFlash = 1000 / ((rateParameter.getValuef() + .01) * 100); |
149 | while (leftoverMs > msPerFlash) { |
150 | leftoverMs -= msPerFlash; |
151 | stripNum += int(spreadMod.getValuef()); |
152 | flashes.add(new StripFlash(stripNum)); |
153 | } |
154 | |
155 | for (LXPoint p : model.points) { |
156 | colors[p.index] = 0; |
157 | } |
158 | |
159 | for (StripFlash flash : flashes) { |
160 | float hue = (hueMod.getValuef() + flash.hue) % 360.0; |
161 | color c = lx.hsb(hue, saturationParameter.getValuef() * 100, (flash.value) * 100); |
162 | for (LXPoint p : flash.f.points) { |
163 | colors[p.index] = c; |
164 | } |
165 | } |
166 | |
167 | Iterator<StripFlash> i = flashes.iterator(); |
168 | while (i.hasNext()) { |
169 | StripFlash flash = i.next(); |
170 | boolean dead = flash.age(deltaMs); |
171 | if (dead) { |
172 | i.remove(); |
173 | } |
174 | } |
175 | } |
176 | } |
177 | |
178 | |
179 | |
180 | class JackieDots extends SCPattern { |
181 | private BasicParameter rateParameter = new BasicParameter("RATE", 0.15); |
182 | private BasicParameter attackParameter = new BasicParameter("ATTK", 0.3); |
183 | private BasicParameter decayParameter = new BasicParameter("DECAY", 0.2); |
184 | private BasicParameter saturationParameter = new BasicParameter("SAT", 0.7); |
185 | |
186 | SinLFO hueMod = new SinLFO(0, 360, 4000); |
187 | SinLFO spreadMod = new SinLFO(1, 10, 16000); |
188 | |
189 | |
190 | class PointFlash { |
191 | LXPoint f; |
192 | float value; |
193 | float hue; |
194 | boolean hasPeaked; |
195 | |
196 | PointFlash(int n) { |
197 | f = model.points.get(n % model.points.size()); |
198 | hue = random(360); |
199 | boolean infiniteAttack = (attackParameter.getValuef() > 0.999); |
200 | hasPeaked = infiniteAttack; |
201 | value = (infiniteAttack ? 1 : 0); |
202 | } |
203 | |
204 | // returns TRUE if this should die |
205 | boolean age(double ms) { |
206 | if (!hasPeaked) { |
207 | value = value + (float) (ms / 1000.0f * ((attackParameter.getValuef() + 0.01) * 5)); |
208 | if (value >= 1.0) { |
209 | value = 1.0; |
210 | hasPeaked = true; |
211 | } |
212 | return false; |
213 | } else { |
214 | value = value - (float) (ms / 1000.0f * ((decayParameter.getValuef() + 0.01) * 10)); |
215 | return value <= 0; |
216 | } |
217 | } |
218 | } |
219 | |
220 | private float leftoverMs = 0; |
221 | private List<PointFlash> flashes; |
222 | private int pointNum = 0; |
223 | |
224 | public JackieDots(GLucose glucose) { |
225 | super(glucose); |
226 | addParameter(rateParameter); |
227 | addParameter(attackParameter); |
228 | addParameter(decayParameter); |
229 | addParameter(saturationParameter); |
230 | addModulator(hueMod).trigger(); |
231 | addModulator(spreadMod).trigger(); |
232 | |
233 | flashes = new LinkedList<PointFlash>(); |
234 | } |
235 | |
236 | public void run(double deltaMs) { |
237 | leftoverMs += deltaMs; |
238 | float msPerFlash = 1000 / ((rateParameter.getValuef() + .01) * 5000); |
239 | while (leftoverMs > msPerFlash) { |
240 | leftoverMs -= msPerFlash; |
241 | pointNum += int(spreadMod.getValuef()); |
242 | flashes.add(new PointFlash(pointNum)); |
243 | } |
244 | |
245 | for (LXPoint p : model.points) { |
246 | colors[p.index] = 0; |
247 | } |
248 | |
249 | for (PointFlash flash : flashes) { |
250 | float hue = (hueMod.getValuef() + flash.hue) % 360.0; |
251 | color c = lx.hsb(hue, saturationParameter.getValuef() * 100, (flash.value) * 100); |
252 | colors[flash.f.index] = c; |
253 | } |
254 | |
255 | Iterator<PointFlash> i = flashes.iterator(); |
256 | while (i.hasNext()) { |
257 | PointFlash flash = i.next(); |
258 | boolean dead = flash.age(deltaMs); |
259 | if (dead) { |
260 | i.remove(); |
261 | } |
262 | } |
263 | } |
264 | } |
265 | |