Commit | Line | Data |
---|---|---|
cc9e8c8b | 1 | import java.util.Stack; |
616d4f9e MS |
2 | class Cathedrals extends SCPattern { |
3 | ||
4 | private final BasicParameter xpos = new BasicParameter("XPOS", 0.5); | |
5 | private final BasicParameter wid = new BasicParameter("WID", 0.5); | |
6 | private final BasicParameter arms = new BasicParameter("ARMS", 0.5); | |
7 | private final BasicParameter sat = new BasicParameter("SAT", 0.5); | |
8 | private GraphicEQ eq; | |
9 | ||
10 | Cathedrals(GLucose glucose) { | |
11 | super(glucose); | |
12 | addParameter(xpos); | |
13 | addParameter(wid); | |
14 | addParameter(arms); | |
15 | addParameter(sat); | |
16 | } | |
17 | ||
18 | protected void onActive() { | |
19 | if (eq == null) { | |
20 | eq = new GraphicEQ(lx, 16); | |
21 | eq.slope.setValue(0.7); | |
22 | eq.range.setValue(0.4); | |
23 | eq.attack.setValue(0.4); | |
24 | eq.release.setValue(0.4); | |
25 | addParameter(eq.level); | |
26 | addParameter(eq.range); | |
27 | addParameter(eq.attack); | |
28 | addParameter(eq.release); | |
29 | addParameter(eq.slope); | |
30 | } | |
31 | } | |
32 | ||
33 | ||
34 | public void run(double deltaMs) { | |
35 | eq.run(deltaMs); | |
36 | float bassLevel = eq.getAverageLevel(0, 4); | |
37 | float trebleLevel = eq.getAverageLevel(8, 6); | |
38 | ||
39 | float falloff = 100 / (2 + 14*wid.getValuef()); | |
40 | float cx = model.xMin + (model.xMax-model.xMin) * xpos.getValuef(); | |
41 | float barm = 12 + 60*arms.getValuef()*max(0, 2*(bassLevel-0.1)); | |
42 | float tarm = 12 + 60*arms.getValuef()*max(0, 2*(trebleLevel-0.1)); | |
43 | ||
44 | float arm = 0; | |
45 | float middle = 0; | |
46 | ||
47 | float sf = 100. / (70 - 69.9*sat.getValuef()); | |
48 | ||
2bb56822 | 49 | for (LXPoint p : model.points) { |
616d4f9e MS |
50 | float d = MAX_FLOAT; |
51 | if (p.y > model.cy) { | |
52 | arm = tarm; | |
53 | middle = model.yMax * 3/5.; | |
54 | } else { | |
55 | arm = barm; | |
56 | middle = model.yMax * 1/5.; | |
57 | } | |
58 | if (abs(p.x - cx) < arm) { | |
59 | d = min(abs(p.x - cx), abs(p.y - middle)); | |
60 | } | |
67847b06 | 61 | colors[p.index] = lx.hsb( |
616d4f9e MS |
62 | (lx.getBaseHuef() + .2*abs(p.y - model.cy)) % 360, |
63 | min(100, sf*dist(abs(p.x - cx), p.y, arm, middle)), | |
67847b06 | 64 | constrain(120 - d*falloff, 0, 100)); |
616d4f9e MS |
65 | } |
66 | } | |
67 | } | |
68 | ||
4214e9a2 MS |
69 | class MidiMusic extends SCPattern { |
70 | ||
09068c4e | 71 | private final Stack<LXLayer> newLayers = new Stack<LXLayer>(); |
4214e9a2 | 72 | |
09068c4e MS |
73 | private final Map<Integer, LightUp> lightMap = new HashMap<Integer, LightUp>(); |
74 | private final List<LightUp> lights = new ArrayList<LightUp>(); | |
d93c968f | 75 | private final BasicParameter lightSize = new BasicParameter("SIZE", 0.5); |
cfb7de01 | 76 | |
09068c4e MS |
77 | private final List<Sweep> sweeps = new ArrayList<Sweep>(); |
78 | ||
d93c968f | 79 | private final LinearEnvelope sparkle = new LinearEnvelope(0, 1, 500); |
09068c4e | 80 | private boolean sparkleDirection = true; |
d93c968f | 81 | private float sparkleBright = 100; |
09068c4e MS |
82 | |
83 | private final BasicParameter wave = new BasicParameter("WAVE", 0); | |
4214e9a2 MS |
84 | |
85 | MidiMusic(GLucose glucose) { | |
86 | super(glucose); | |
d93c968f | 87 | addParameter(lightSize); |
09068c4e | 88 | addParameter(wave); |
d93c968f | 89 | addModulator(sparkle).setValue(1); |
09068c4e MS |
90 | } |
91 | ||
29d8acbb MS |
92 | void onReset() { |
93 | for (LightUp light : lights) { | |
94 | light.noteOff(null); | |
95 | } | |
96 | } | |
97 | ||
09068c4e MS |
98 | class Sweep extends LXLayer { |
99 | ||
100 | final LinearEnvelope position = new LinearEnvelope(0, 1, 1000); | |
101 | float bright = 100; | |
102 | float falloff = 10; | |
103 | ||
104 | Sweep() { | |
105 | addModulator(position); | |
106 | } | |
107 | ||
108 | public void run(double deltaMs, color[] colors) { | |
109 | if (!position.isRunning()) { | |
110 | return; | |
111 | } | |
112 | float posf = position.getValuef(); | |
2bb56822 | 113 | for (LXPoint p : model.points) { |
67847b06 | 114 | colors[p.index] = blendColor(colors[p.index], lx.hsb( |
09068c4e MS |
115 | (lx.getBaseHuef() + .2*abs(p.x - model.cx) + .2*abs(p.y - model.cy)) % 360, |
116 | 100, | |
117 | max(0, bright - posf*100 - falloff*abs(p.y - posf*model.yMax)) | |
118 | ), ADD); | |
119 | } | |
120 | } | |
4214e9a2 MS |
121 | } |
122 | ||
123 | class LightUp extends LXLayer { | |
124 | ||
09068c4e MS |
125 | private final LinearEnvelope brt = new LinearEnvelope(0, 0, 0); |
126 | private final Accelerator yPos = new Accelerator(0, 0, 0); | |
4214e9a2 MS |
127 | private float xPos; |
128 | ||
129 | LightUp() { | |
130 | addModulator(brt); | |
131 | addModulator(yPos); | |
132 | } | |
133 | ||
134 | boolean isAvailable() { | |
135 | return brt.getValuef() <= 0; | |
136 | } | |
137 | ||
138 | void noteOn(Note note) { | |
09068c4e MS |
139 | xPos = lerp(0, model.xMax, constrain(0.5 + (note.getPitch() - 60) / 28., 0, 1)); |
140 | yPos.setValue(lerp(20, model.yMax*.72, note.getVelocity() / 127.)).stop(); | |
4214e9a2 MS |
141 | brt.setRangeFromHereTo(lerp(40, 100, note.getVelocity() / 127.), 20).start(); |
142 | } | |
143 | ||
144 | void noteOff(Note note) { | |
145 | yPos.setVelocity(0).setAcceleration(-380).start(); | |
146 | brt.setRangeFromHereTo(0, 1000).start(); | |
147 | } | |
148 | ||
149 | public void run(double deltaMs, color[] colors) { | |
150 | float bVal = brt.getValuef(); | |
151 | if (bVal <= 0) { | |
152 | return; | |
153 | } | |
154 | float yVal = yPos.getValuef(); | |
2bb56822 | 155 | for (LXPoint p : model.points) { |
d93c968f MS |
156 | float falloff = 6 - 5*lightSize.getValuef(); |
157 | float b = max(0, bVal - falloff*dist(p.x, p.y, xPos, yVal)); | |
4214e9a2 | 158 | if (b > 0) { |
19d16a16 | 159 | colors[p.index] = blendColor(colors[p.index], lx.hsb( |
d93c968f | 160 | (lx.getBaseHuef() + .2*abs(p.x - model.cx) + .2*abs(p.y - model.cy)) % 360, |
4214e9a2 MS |
161 | 100, |
162 | b | |
163 | ), ADD); | |
164 | } | |
165 | } | |
166 | } | |
167 | } | |
168 | ||
09068c4e MS |
169 | private LightUp getLight() { |
170 | for (LightUp light : lights) { | |
171 | if (light.isAvailable()) { | |
172 | return light; | |
4214e9a2 | 173 | } |
09068c4e MS |
174 | } |
175 | LightUp newLight = new LightUp(); | |
176 | lights.add(newLight); | |
177 | synchronized(newLayers) { | |
178 | newLayers.push(newLight); | |
179 | } | |
180 | return newLight; | |
181 | } | |
182 | ||
183 | private Sweep getSweep() { | |
184 | for (Sweep s : sweeps) { | |
185 | if (!s.position.isRunning()) { | |
186 | return s; | |
4214e9a2 | 187 | } |
09068c4e MS |
188 | } |
189 | Sweep newSweep = new Sweep(); | |
190 | sweeps.add(newSweep); | |
191 | synchronized(newLayers) { | |
192 | newLayers.push(newSweep); | |
193 | } | |
194 | return newSweep; | |
195 | } | |
196 | ||
197 | public synchronized boolean noteOn(Note note) { | |
198 | if (note.getChannel() == 0) { | |
199 | LightUp light = getLight(); | |
200 | lightMap.put(note.getPitch(), light); | |
201 | light.noteOn(note); | |
4214e9a2 | 202 | } else if (note.getChannel() == 1) { |
d93c968f | 203 | } else if (note.getChannel() == 9) { |
cfb7de01 MS |
204 | if (note.getVelocity() > 0) { |
205 | switch (note.getPitch()) { | |
206 | case 36: | |
09068c4e MS |
207 | Sweep s = getSweep(); |
208 | s.bright = 50 + note.getVelocity() / 127. * 50; | |
209 | s.falloff = 20 - note.getVelocity() / 127. * 17; | |
210 | s.position.trigger(); | |
211 | break; | |
212 | case 37: | |
d93c968f | 213 | sparkleBright = note.getVelocity() / 127. * 100; |
09068c4e | 214 | sparkleDirection = true; |
cfb7de01 MS |
215 | sparkle.trigger(); |
216 | break; | |
09068c4e MS |
217 | case 38: |
218 | sparkleBright = note.getVelocity() / 127. * 100; | |
219 | sparkleDirection = false; | |
220 | sparkle.trigger(); | |
cfb7de01 | 221 | break; |
29d8acbb MS |
222 | case 39: |
223 | effects.boom.trigger(); | |
224 | break; | |
225 | case 40: | |
cc9e8c8b | 226 | //effects.flash.trigger(); |
29d8acbb | 227 | break; |
cfb7de01 | 228 | } |
d93c968f | 229 | } |
4214e9a2 MS |
230 | } |
231 | return true; | |
232 | } | |
233 | ||
242b19ad | 234 | public synchronized boolean noteOff(Note note) { |
4214e9a2 MS |
235 | if (note.getChannel() == 0) { |
236 | LightUp light = lightMap.get(note.getPitch()); | |
237 | if (light != null) { | |
238 | light.noteOff(note); | |
239 | } | |
240 | } | |
241 | return true; | |
242 | } | |
243 | ||
09068c4e MS |
244 | final float[] wval = new float[16]; |
245 | float wavoff = 0; | |
246 | ||
4214e9a2 | 247 | public synchronized void run(double deltaMs) { |
09068c4e MS |
248 | wavoff += deltaMs * .001; |
249 | for (int i = 0; i < wval.length; ++i) { | |
250 | wval[i] = model.cy + 0.2 * model.yMax/2. * sin(wavoff + i / 1.9); | |
251 | } | |
252 | float sparklePos = (sparkleDirection ? sparkle.getValuef() : (1 - sparkle.getValuef())) * (Cube.POINTS_PER_STRIP)/2.; | |
d93c968f MS |
253 | float maxBright = sparkleBright * (1 - sparkle.getValuef()); |
254 | for (Strip s : model.strips) { | |
255 | int i = 0; | |
2bb56822 | 256 | for (LXPoint p : s.points) { |
09068c4e MS |
257 | int wavi = (int) constrain(p.x / model.xMax * wval.length, 0, wval.length-1); |
258 | float wavb = max(0, wave.getValuef()*100. - 8.*abs(p.y - wval[wavi])); | |
67847b06 | 259 | colors[p.index] = lx.hsb( |
d93c968f MS |
260 | (lx.getBaseHuef() + .2*abs(p.x - model.cx) + .2*abs(p.y - model.cy)) % 360, |
261 | 100, | |
09068c4e | 262 | constrain(wavb + max(0, maxBright - 40.*abs(sparklePos - abs(i - (Cube.POINTS_PER_STRIP-1)/2.))), 0, 100) |
d93c968f MS |
263 | ); |
264 | ++i; | |
265 | } | |
266 | } | |
09068c4e | 267 | |
4214e9a2 MS |
268 | if (!newLayers.isEmpty()) { |
269 | synchronized(newLayers) { | |
270 | while (!newLayers.isEmpty()) { | |
271 | addLayer(newLayers.pop()); | |
272 | } | |
273 | } | |
274 | } | |
275 | } | |
276 | } | |
277 | ||
0137237d MS |
278 | class Pulley extends SCPattern { |
279 | ||
280 | final int NUM_DIVISIONS = 16; | |
281 | private final Accelerator[] gravity = new Accelerator[NUM_DIVISIONS]; | |
282 | private final Click[] delays = new Click[NUM_DIVISIONS]; | |
283 | ||
284 | private final Click reset = new Click(9000); | |
285 | private boolean isRising = false; | |
286 | ||
0e6f37cf | 287 | private BasicParameter sz = new BasicParameter("SIZE", 0.5); |
a41f334c | 288 | private BasicParameter beatAmount = new BasicParameter("BEAT", 0); |
eb0d5167 | 289 | |
0137237d MS |
290 | Pulley(GLucose glucose) { |
291 | super(glucose); | |
292 | for (int i = 0; i < NUM_DIVISIONS; ++i) { | |
293 | addModulator(gravity[i] = new Accelerator(0, 0, 0)); | |
294 | addModulator(delays[i] = new Click(0)); | |
295 | } | |
296 | addModulator(reset).start(); | |
0e6f37cf | 297 | addParameter(sz); |
eb0d5167 | 298 | addParameter(beatAmount); |
0137237d | 299 | trigger(); |
242b19ad | 300 | |
0137237d MS |
301 | } |
302 | ||
303 | private void trigger() { | |
304 | isRising = !isRising; | |
305 | int i = 0; | |
306 | for (Accelerator g : gravity) { | |
307 | if (isRising) { | |
a41f334c | 308 | g.setSpeed(random(20, 33), 0).start(); |
0137237d MS |
309 | } else { |
310 | g.setVelocity(0).setAcceleration(-420); | |
311 | delays[i].setDuration(random(0, 500)).trigger(); | |
312 | } | |
313 | ++i; | |
314 | } | |
315 | } | |
316 | ||
317 | public void run(double deltaMs) { | |
318 | if (reset.click()) { | |
319 | trigger(); | |
320 | } | |
242b19ad | 321 | |
a41f334c MS |
322 | if (isRising) { |
323 | // Fucking A, had to comment this all out because of that bizarre | |
324 | // Processing bug where some simple loop takes an absurd amount of | |
325 | // time, must be some pre-processor bug | |
326 | // for (Accelerator g : gravity) { | |
327 | // if (g.getValuef() > model.yMax) { | |
328 | // g.stop(); | |
329 | // } else if (g.getValuef() > model.yMax*.55) { | |
330 | // if (g.getVelocityf() > 10) { | |
331 | // g.setAcceleration(-16); | |
332 | // } else { | |
333 | // g.setAcceleration(0); | |
334 | // } | |
335 | // } | |
336 | // } | |
337 | } else { | |
338 | int j = 0; | |
339 | for (Click d : delays) { | |
340 | if (d.click()) { | |
341 | gravity[j].start(); | |
342 | d.stop(); | |
0137237d | 343 | } |
a41f334c MS |
344 | ++j; |
345 | } | |
346 | for (Accelerator g : gravity) { | |
0137237d MS |
347 | if (g.getValuef() < 0) { |
348 | g.setValue(-g.getValuef()); | |
349 | g.setVelocity(-g.getVelocityf() * random(0.74, 0.84)); | |
350 | } | |
351 | } | |
352 | } | |
242b19ad MS |
353 | |
354 | // A little silliness to test the grid API | |
66067e53 MS |
355 | if (midiEngine != null && midiEngine.getFocusedPattern() == this) { |
356 | for (int i = 0; i < 5; ++i) { | |
357 | for (int j = 0; j < 8; ++j) { | |
358 | int gi = (int) constrain(j * NUM_DIVISIONS / 8, 0, NUM_DIVISIONS-1); | |
359 | float b = 1 - 4.*abs((6-i)/6. - gravity[gi].getValuef() / model.yMax); | |
360 | midiEngine.grid.setState(i, j, (b < 0) ? 0 : 3); | |
361 | } | |
242b19ad MS |
362 | } |
363 | } | |
0137237d | 364 | |
eb0d5167 MS |
365 | float fPos = 1 - lx.tempo.rampf(); |
366 | if (fPos < .2) { | |
367 | fPos = .2 + 4 * (.2 - fPos); | |
368 | } | |
0e6f37cf | 369 | float falloff = 100. / (3 + sz.getValuef() * 36 + fPos * beatAmount.getValuef()*48); |
2bb56822 | 370 | for (LXPoint p : model.points) { |
a41f334c | 371 | int gi = (int) constrain((p.x - model.xMin) * NUM_DIVISIONS / (model.xMax - model.xMin), 0, NUM_DIVISIONS-1); |
19d16a16 | 372 | colors[p.index] = lx.hsb( |
0137237d MS |
373 | (lx.getBaseHuef() + abs(p.x - model.cx)*.8 + p.y*.4) % 360, |
374 | constrain(130 - p.y*.8, 0, 100), | |
a41f334c | 375 | max(0, 100 - abs(p.y - gravity[gi].getValuef())*falloff) |
0137237d MS |
376 | ); |
377 | } | |
378 | } | |
379 | } | |
380 | ||
4760e696 MS |
381 | class ViolinWave extends SCPattern { |
382 | ||
383 | BasicParameter level = new BasicParameter("LVL", 0.45); | |
384 | BasicParameter range = new BasicParameter("RNG", 0.5); | |
385 | BasicParameter edge = new BasicParameter("EDG", 0.5); | |
386 | BasicParameter release = new BasicParameter("RLS", 0.5); | |
387 | BasicParameter speed = new BasicParameter("SPD", 0.5); | |
388 | BasicParameter amp = new BasicParameter("AMP", 0.25); | |
389 | BasicParameter period = new BasicParameter("WAVE", 0.5); | |
390 | BasicParameter pSize = new BasicParameter("PSIZE", 0.5); | |
391 | BasicParameter pSpeed = new BasicParameter("PSPD", 0.5); | |
392 | BasicParameter pDensity = new BasicParameter("PDENS", 0.25); | |
393 | ||
394 | LinearEnvelope dbValue = new LinearEnvelope(0, 0, 10); | |
395 | ||
396 | ViolinWave(GLucose glucose) { | |
397 | super(glucose); | |
398 | addParameter(level); | |
399 | addParameter(edge); | |
400 | addParameter(range); | |
401 | addParameter(release); | |
402 | addParameter(speed); | |
403 | addParameter(amp); | |
404 | addParameter(period); | |
405 | addParameter(pSize); | |
406 | addParameter(pSpeed); | |
407 | addParameter(pDensity); | |
408 | ||
409 | addModulator(dbValue); | |
410 | } | |
411 | ||
412 | final List<Particle> particles = new ArrayList<Particle>(); | |
413 | ||
414 | class Particle { | |
415 | ||
416 | LinearEnvelope x = new LinearEnvelope(0, 0, 0); | |
417 | LinearEnvelope y = new LinearEnvelope(0, 0, 0); | |
418 | ||
419 | Particle() { | |
420 | addModulator(x); | |
421 | addModulator(y); | |
422 | } | |
423 | ||
424 | Particle trigger(boolean direction) { | |
425 | float xInit = random(model.xMin, model.xMax); | |
426 | float time = 3000 - 2500*pSpeed.getValuef(); | |
427 | x.setRange(xInit, xInit + random(-40, 40), time).trigger(); | |
428 | y.setRange(model.cy + 10, direction ? model.yMax + 50 : model.yMin - 50, time).trigger(); | |
429 | return this; | |
430 | } | |
431 | ||
432 | boolean isActive() { | |
433 | return x.isRunning() || y.isRunning(); | |
434 | } | |
435 | ||
436 | public void run(double deltaMs) { | |
437 | if (!isActive()) { | |
438 | return; | |
439 | } | |
440 | ||
441 | float pFalloff = (30 - 27*pSize.getValuef()); | |
2bb56822 | 442 | for (LXPoint p : model.points) { |
4760e696 MS |
443 | float b = 100 - pFalloff * (abs(p.x - x.getValuef()) + abs(p.y - y.getValuef())); |
444 | if (b > 0) { | |
343875e3 | 445 | colors[p.index] = blendColor(colors[p.index], lx.hsb( |
4760e696 MS |
446 | lx.getBaseHuef(), 20, b |
447 | ), ADD); | |
448 | } | |
449 | } | |
450 | } | |
451 | } | |
452 | ||
453 | float[] centers = new float[30]; | |
454 | double accum = 0; | |
455 | boolean rising = true; | |
456 | ||
457 | void fireParticle(boolean direction) { | |
458 | boolean gotOne = false; | |
459 | for (Particle p : particles) { | |
460 | if (!p.isActive()) { | |
461 | p.trigger(direction); | |
462 | return; | |
463 | } | |
464 | } | |
465 | particles.add(new Particle().trigger(direction)); | |
466 | } | |
467 | ||
468 | public void run(double deltaMs) { | |
469 | accum += deltaMs / (1000. - 900.*speed.getValuef()); | |
470 | for (int i = 0; i < centers.length; ++i) { | |
471 | centers[i] = model.cy + 30*amp.getValuef()*sin((float) (accum + (i-centers.length/2.)/(1. + 9.*period.getValuef()))); | |
472 | } | |
473 | ||
474 | float zeroDBReference = pow(10, (50 - 190*level.getValuef())/20.); | |
616d4f9e | 475 | float dB = 20*GraphicEQ.log10(lx.audioInput().mix.level() / zeroDBReference); |
4760e696 MS |
476 | if (dB > dbValue.getValuef()) { |
477 | rising = true; | |
478 | dbValue.setRangeFromHereTo(dB, 10).trigger(); | |
479 | } else { | |
480 | if (rising) { | |
481 | for (int j = 0; j < pDensity.getValuef()*3; ++j) { | |
482 | fireParticle(true); | |
483 | fireParticle(false); | |
484 | } | |
485 | } | |
486 | rising = false; | |
487 | dbValue.setRangeFromHereTo(max(dB, -96), 50 + 1000*release.getValuef()).trigger(); | |
488 | } | |
489 | float edg = 1 + edge.getValuef() * 40; | |
490 | float rng = (78 - 64 * range.getValuef()) / (model.yMax - model.cy); | |
491 | float val = max(2, dbValue.getValuef()); | |
492 | ||
2bb56822 | 493 | for (LXPoint p : model.points) { |
4760e696 MS |
494 | int ci = (int) lerp(0, centers.length-1, (p.x - model.xMin) / (model.xMax - model.xMin)); |
495 | float rFactor = 1.0 - 0.9 * abs(p.x - model.cx) / (model.xMax - model.cx); | |
343875e3 | 496 | colors[p.index] = lx.hsb( |
4760e696 MS |
497 | (lx.getBaseHuef() + abs(p.x - model.cx)) % 360, |
498 | min(100, 20 + 8*abs(p.y - centers[ci])), | |
499 | constrain(edg*(val*rFactor - rng * abs(p.y-centers[ci])), 0, 100) | |
500 | ); | |
501 | } | |
502 | ||
503 | for (Particle p : particles) { | |
504 | p.run(deltaMs); | |
505 | } | |
506 | } | |
507 | } | |
508 | ||
d1dcc4b5 | 509 | class BouncyBalls extends SCPattern { |
cc8b3f82 | 510 | |
d1dcc4b5 | 511 | static final int NUM_BALLS = 6; |
cc8b3f82 | 512 | |
d1dcc4b5 | 513 | class BouncyBall { |
cc8b3f82 MS |
514 | |
515 | Accelerator yPos; | |
516 | TriangleLFO xPos = new TriangleLFO(0, model.xMax, random(8000, 19000)); | |
d1dcc4b5 | 517 | float zPos; |
cc8b3f82 | 518 | |
d1dcc4b5 | 519 | BouncyBall(int i) { |
d12e46b6 | 520 | addModulator(xPos.setBasis(random(0, TWO_PI)).start()); |
cc8b3f82 | 521 | addModulator(yPos = new Accelerator(0, 0, 0)); |
d1dcc4b5 | 522 | zPos = lerp(model.zMin, model.zMax, (i+2.) / (NUM_BALLS + 4.)); |
cc8b3f82 MS |
523 | } |
524 | ||
525 | void bounce(float midiVel) { | |
526 | float v = 100 + 8*midiVel; | |
527 | yPos.setSpeed(v, getAccel(v, 60 / lx.tempo.bpmf())).start(); | |
528 | } | |
529 | ||
530 | float getAccel(float v, float oneBeat) { | |
531 | return -2*v / oneBeat; | |
532 | } | |
533 | ||
534 | void run(double deltaMs) { | |
535 | float flrLevel = flr.getValuef() * model.xMax/2.; | |
536 | if (yPos.getValuef() < flrLevel) { | |
537 | if (yPos.getVelocity() < -50) { | |
538 | yPos.setValue(2*flrLevel-yPos.getValuef()); | |
539 | float v = -yPos.getVelocityf() * bounce.getValuef(); | |
540 | yPos.setSpeed(v, getAccel(v, 60 / lx.tempo.bpmf())); | |
541 | } else { | |
542 | yPos.setValue(flrLevel).stop(); | |
543 | } | |
544 | } | |
545 | float falloff = 130.f / (12 + blobSize.getValuef() * 36); | |
d1dcc4b5 MS |
546 | float xv = xPos.getValuef(); |
547 | float yv = yPos.getValuef(); | |
548 | ||
2bb56822 | 549 | for (LXPoint p : model.points) { |
d1dcc4b5 | 550 | float d = sqrt((p.x-xv)*(p.x-xv) + (p.y-yv)*(p.y-yv) + .1*(p.z-zPos)*(p.z-zPos)); |
cc8b3f82 MS |
551 | float b = constrain(130 - falloff*d, 0, 100); |
552 | if (b > 0) { | |
19d16a16 | 553 | colors[p.index] = blendColor(colors[p.index], lx.hsb( |
cc8b3f82 MS |
554 | (lx.getBaseHuef() + p.y*.5 + abs(model.cx - p.x) * .5) % 360, |
555 | max(0, 100 - .45*(p.y - flrLevel)), | |
556 | b | |
557 | ), ADD); | |
558 | } | |
559 | } | |
560 | } | |
561 | } | |
562 | ||
d1dcc4b5 | 563 | final BouncyBall[] balls = new BouncyBall[NUM_BALLS]; |
cc8b3f82 MS |
564 | |
565 | final BasicParameter bounce = new BasicParameter("BNC", .8); | |
566 | final BasicParameter flr = new BasicParameter("FLR", 0); | |
567 | final BasicParameter blobSize = new BasicParameter("SIZE", 0.5); | |
568 | ||
d1dcc4b5 | 569 | BouncyBalls(GLucose glucose) { |
cc8b3f82 | 570 | super(glucose); |
d1dcc4b5 MS |
571 | for (int i = 0; i < balls.length; ++i) { |
572 | balls[i] = new BouncyBall(i); | |
cc8b3f82 MS |
573 | } |
574 | addParameter(bounce); | |
575 | addParameter(flr); | |
576 | addParameter(blobSize); | |
577 | } | |
578 | ||
579 | public void run(double deltaMs) { | |
580 | setColors(#000000); | |
d1dcc4b5 MS |
581 | for (BouncyBall b : balls) { |
582 | b.run(deltaMs); | |
cc8b3f82 MS |
583 | } |
584 | } | |
585 | ||
242b19ad | 586 | public boolean noteOn(Note note) { |
d1dcc4b5 MS |
587 | int pitch = (note.getPitch() + note.getChannel()) % NUM_BALLS; |
588 | balls[pitch].bounce(note.getVelocity()); | |
cc8b3f82 MS |
589 | return true; |
590 | } | |
591 | } | |
592 | ||
49815cc0 MS |
593 | class SpaceTime extends SCPattern { |
594 | ||
3e8e60d8 | 595 | SinLFO pos = new SinLFO(0, 1, 3000); |
49815cc0 MS |
596 | SinLFO rate = new SinLFO(1000, 9000, 13000); |
597 | SinLFO falloff = new SinLFO(10, 70, 5000); | |
3f8be614 MS |
598 | float angle = 0; |
599 | ||
600 | BasicParameter rateParameter = new BasicParameter("RATE", 0.5); | |
601 | BasicParameter sizeParameter = new BasicParameter("SIZE", 0.5); | |
49815cc0 | 602 | |
3e8e60d8 | 603 | |
49815cc0 MS |
604 | public SpaceTime(GLucose glucose) { |
605 | super(glucose); | |
3e8e60d8 | 606 | |
49815cc0 MS |
607 | addModulator(pos).trigger(); |
608 | addModulator(rate).trigger(); | |
609 | addModulator(falloff).trigger(); | |
610 | pos.modulateDurationBy(rate); | |
3f8be614 MS |
611 | addParameter(rateParameter); |
612 | addParameter(sizeParameter); | |
49815cc0 | 613 | } |
3f8be614 MS |
614 | |
615 | public void onParameterChanged(LXParameter parameter) { | |
616 | if (parameter == rateParameter) { | |
617 | rate.stop().setValue(9000 - 8000*parameter.getValuef()); | |
618 | } else if (parameter == sizeParameter) { | |
619 | falloff.stop().setValue(70 - 60*parameter.getValuef()); | |
49815cc0 MS |
620 | } |
621 | } | |
622 | ||
34327c96 | 623 | void run(double deltaMs) { |
3f8be614 | 624 | angle += deltaMs * 0.0007; |
87f6fa39 MS |
625 | float sVal1 = model.strips.size() * (0.5 + 0.5*sin(angle)); |
626 | float sVal2 = model.strips.size() * (0.5 + 0.5*cos(angle)); | |
49815cc0 MS |
627 | |
628 | float pVal = pos.getValuef(); | |
629 | float fVal = falloff.getValuef(); | |
630 | ||
631 | int s = 0; | |
cfc57fca | 632 | for (Strip strip : model.strips) { |
49815cc0 | 633 | int i = 0; |
2bb56822 | 634 | for (LXPoint p : strip.points) { |
19d16a16 | 635 | colors[p.index] = lx.hsb( |
190d91c2 | 636 | (lx.getBaseHuef() + 360 - p.x*.2 + p.y * .3) % 360, |
3e8e60d8 MS |
637 | constrain(.4 * min(abs(s - sVal1), abs(s - sVal2)), 20, 100), |
638 | max(0, 100 - fVal*abs(i - pVal*(strip.metrics.numPoints - 1))) | |
639 | ); | |
49815cc0 MS |
640 | ++i; |
641 | } | |
3f8be614 | 642 | ++s; |
49815cc0 MS |
643 | } |
644 | } | |
645 | } | |
646 | ||
647 | class Swarm extends SCPattern { | |
d12e46b6 | 648 | |
3e8e60d8 | 649 | SawLFO offset = new SawLFO(0, 1, 1000); |
49815cc0 MS |
650 | SinLFO rate = new SinLFO(350, 1200, 63000); |
651 | SinLFO falloff = new SinLFO(15, 50, 17000); | |
2bb56822 MS |
652 | SinLFO fX = new SinLFO(model.xMin, model.xMax, 19000); |
653 | SinLFO fY = new SinLFO(model.yMin, model.yMax, 11000); | |
654 | SinLFO hOffX = new SinLFO(model.xMin, model.xMax, 13000); | |
49815cc0 MS |
655 | |
656 | public Swarm(GLucose glucose) { | |
657 | super(glucose); | |
3e8e60d8 | 658 | |
49815cc0 MS |
659 | addModulator(offset).trigger(); |
660 | addModulator(rate).trigger(); | |
661 | addModulator(falloff).trigger(); | |
2b6688e8 | 662 | addModulator(fX).trigger(); |
49815cc0 | 663 | addModulator(fY).trigger(); |
2b6688e8 | 664 | addModulator(hOffX).trigger(); |
49815cc0 MS |
665 | offset.modulateDurationBy(rate); |
666 | } | |
667 | ||
668 | float modDist(float v1, float v2, float mod) { | |
669 | v1 = v1 % mod; | |
670 | v2 = v2 % mod; | |
671 | if (v2 > v1) { | |
672 | return min(v2-v1, v1+mod-v2); | |
673 | } | |
674 | else { | |
675 | return min(v1-v2, v2+mod-v1); | |
676 | } | |
677 | } | |
678 | ||
34327c96 | 679 | void run(double deltaMs) { |
49815cc0 | 680 | float s = 0; |
2bb56822 | 681 | for (Strip strip : model.strips) { |
49815cc0 | 682 | int i = 0; |
2bb56822 | 683 | for (LXPoint p : strip.points) { |
190d91c2 | 684 | float fV = max(-1, 1 - dist(p.x/2., p.y, fX.getValuef()/2., fY.getValuef()) / 64.); |
19d16a16 | 685 | colors[p.index] = lx.hsb( |
190d91c2 | 686 | (lx.getBaseHuef() + 0.3 * abs(p.x - hOffX.getValuef())) % 360, |
49815cc0 | 687 | constrain(80 + 40 * fV, 0, 100), |
1d414e45 AG |
688 | constrain(100 - |
689 | (30 - fV * falloff.getValuef()) * modDist(i + (s*63)%61, offset.getValuef() * strip.metrics.numPoints, strip.metrics.numPoints), 0, 100) | |
49815cc0 MS |
690 | ); |
691 | ++i; | |
1d414e45 | 692 | } |
49815cc0 MS |
693 | ++s; |
694 | } | |
695 | } | |
696 | } | |
697 | ||
698 | class SwipeTransition extends SCTransition { | |
3f8be614 MS |
699 | |
700 | final BasicParameter bleed = new BasicParameter("WIDTH", 0.5); | |
701 | ||
49815cc0 MS |
702 | SwipeTransition(GLucose glucose) { |
703 | super(glucose); | |
704 | setDuration(5000); | |
3f8be614 | 705 | addParameter(bleed); |
49815cc0 MS |
706 | } |
707 | ||
708 | void computeBlend(int[] c1, int[] c2, double progress) { | |
3f8be614 | 709 | float bleedf = 10 + bleed.getValuef() * 200.; |
c39f7a04 | 710 | float xPos = (float) (-bleedf + progress * (model.xMax + bleedf)); |
2bb56822 | 711 | for (LXPoint p : model.points) { |
190d91c2 | 712 | float d = (p.x - xPos) / bleedf; |
49815cc0 MS |
713 | if (d < 0) { |
714 | colors[p.index] = c2[p.index]; | |
2b6688e8 | 715 | } else if (d > 1) { |
49815cc0 | 716 | colors[p.index] = c1[p.index]; |
2b6688e8 | 717 | } else { |
49815cc0 MS |
718 | colors[p.index] = lerpColor(c2[p.index], c1[p.index], d, RGB); |
719 | } | |
720 | } | |
721 | } | |
722 | } | |
723 | ||
fe30b226 | 724 | abstract class BlendTransition extends SCTransition { |
ed149627 | 725 | |
fe30b226 MS |
726 | final int blendType; |
727 | ||
728 | BlendTransition(GLucose glucose, int blendType) { | |
ed149627 | 729 | super(glucose); |
fe30b226 | 730 | this.blendType = blendType; |
ed149627 MS |
731 | } |
732 | ||
733 | void computeBlend(int[] c1, int[] c2, double progress) { | |
734 | if (progress < 0.5) { | |
735 | for (int i = 0; i < c1.length; ++i) { | |
736 | colors[i] = lerpColor( | |
737 | c1[i], | |
fe30b226 | 738 | blendColor(c1[i], c2[i], blendType), |
ed149627 MS |
739 | (float) (2.*progress), |
740 | RGB); | |
741 | } | |
742 | } else { | |
743 | for (int i = 0; i < c1.length; ++i) { | |
744 | colors[i] = lerpColor( | |
745 | c2[i], | |
fe30b226 | 746 | blendColor(c1[i], c2[i], blendType), |
ed149627 MS |
747 | (float) (2.*(1. - progress)), |
748 | RGB); | |
749 | } | |
750 | } | |
751 | } | |
752 | } | |
753 | ||
fe30b226 MS |
754 | class MultiplyTransition extends BlendTransition { |
755 | MultiplyTransition(GLucose glucose) { | |
756 | super(glucose, MULTIPLY); | |
757 | } | |
758 | } | |
759 | ||
760 | class ScreenTransition extends BlendTransition { | |
761 | ScreenTransition(GLucose glucose) { | |
762 | super(glucose, SCREEN); | |
763 | } | |
764 | } | |
765 | ||
766 | class BurnTransition extends BlendTransition { | |
767 | BurnTransition(GLucose glucose) { | |
768 | super(glucose, BURN); | |
769 | } | |
770 | } | |
771 | ||
772 | class DodgeTransition extends BlendTransition { | |
773 | DodgeTransition(GLucose glucose) { | |
774 | super(glucose, DODGE); | |
775 | } | |
776 | } | |
777 | ||
778 | class OverlayTransition extends BlendTransition { | |
779 | OverlayTransition(GLucose glucose) { | |
780 | super(glucose, OVERLAY); | |
781 | } | |
782 | } | |
783 | ||
784 | class AddTransition extends BlendTransition { | |
785 | AddTransition(GLucose glucose) { | |
786 | super(glucose, ADD); | |
787 | } | |
788 | } | |
789 | ||
790 | class SubtractTransition extends BlendTransition { | |
791 | SubtractTransition(GLucose glucose) { | |
792 | super(glucose, SUBTRACT); | |
793 | } | |
794 | } | |
795 | ||
796 | class SoftLightTransition extends BlendTransition { | |
797 | SoftLightTransition(GLucose glucose) { | |
798 | super(glucose, SOFT_LIGHT); | |
799 | } | |
800 | } | |
ed149627 | 801 | |
4c006f7b MS |
802 | class BassPod extends SCPattern { |
803 | ||
804 | private GraphicEQ eq = null; | |
805 | ||
32467992 MS |
806 | private final BasicParameter clr = new BasicParameter("CLR", 0.5); |
807 | ||
4c006f7b MS |
808 | public BassPod(GLucose glucose) { |
809 | super(glucose); | |
32467992 | 810 | addParameter(clr); |
4c006f7b MS |
811 | } |
812 | ||
813 | protected void onActive() { | |
814 | if (eq == null) { | |
815 | eq = new GraphicEQ(lx, 16); | |
32467992 MS |
816 | eq.range.setValue(0.4); |
817 | eq.level.setValue(0.4); | |
4c006f7b MS |
818 | eq.slope.setValue(0.6); |
819 | addParameter(eq.level); | |
820 | addParameter(eq.range); | |
821 | addParameter(eq.attack); | |
822 | addParameter(eq.release); | |
823 | addParameter(eq.slope); | |
824 | } | |
825 | } | |
826 | ||
34327c96 | 827 | public void run(double deltaMs) { |
4c006f7b MS |
828 | eq.run(deltaMs); |
829 | ||
830 | float bassLevel = eq.getAverageLevel(0, 5); | |
831 | ||
32467992 MS |
832 | float satBase = bassLevel*480*clr.getValuef(); |
833 | ||
2bb56822 | 834 | for (LXPoint p : model.points) { |
32467992 | 835 | int avgIndex = (int) constrain(1 + abs(p.x-model.cx)/(model.cx)*(eq.numBands-5), 0, eq.numBands-5); |
4c006f7b MS |
836 | float value = 0; |
837 | for (int i = avgIndex; i < avgIndex + 5; ++i) { | |
838 | value += eq.getLevel(i); | |
839 | } | |
840 | value /= 5.; | |
841 | ||
190d91c2 | 842 | float b = constrain(8 * (value*model.yMax - abs(p.y-model.yMax/2.)), 0, 100); |
19d16a16 | 843 | colors[p.index] = lx.hsb( |
190d91c2 | 844 | (lx.getBaseHuef() + abs(p.y - model.cy) + abs(p.x - model.cx)) % 360, |
32467992 | 845 | constrain(satBase - .6*dist(p.x, p.y, model.cx, model.cy), 0, 100), |
4c006f7b MS |
846 | b |
847 | ); | |
848 | } | |
849 | } | |
850 | } | |
851 | ||
852 | ||
49815cc0 MS |
853 | class CubeEQ extends SCPattern { |
854 | ||
4c006f7b | 855 | private GraphicEQ eq = null; |
49815cc0 | 856 | |
3f8be614 | 857 | private final BasicParameter edge = new BasicParameter("EDGE", 0.5); |
3f8be614 | 858 | private final BasicParameter clr = new BasicParameter("CLR", 0.5); |
4c006f7b | 859 | private final BasicParameter blockiness = new BasicParameter("BLK", 0.5); |
49815cc0 MS |
860 | |
861 | public CubeEQ(GLucose glucose) { | |
862 | super(glucose); | |
49815cc0 | 863 | } |
3f8be614 | 864 | |
49815cc0 | 865 | protected void onActive() { |
4c006f7b MS |
866 | if (eq == null) { |
867 | eq = new GraphicEQ(lx, 16); | |
868 | addParameter(eq.level); | |
869 | addParameter(eq.range); | |
870 | addParameter(eq.attack); | |
871 | addParameter(eq.release); | |
872 | addParameter(eq.slope); | |
873 | addParameter(edge); | |
874 | addParameter(clr); | |
875 | addParameter(blockiness); | |
49815cc0 MS |
876 | } |
877 | } | |
878 | ||
34327c96 | 879 | public void run(double deltaMs) { |
4c006f7b | 880 | eq.run(deltaMs); |
3f8be614 | 881 | |
4c006f7b | 882 | float edgeConst = 2 + 30*edge.getValuef(); |
49815cc0 MS |
883 | float clrConst = 1.1 + clr.getValuef(); |
884 | ||
2bb56822 | 885 | for (LXPoint p : model.points) { |
190d91c2 | 886 | float avgIndex = constrain(2 + p.x / model.xMax * (eq.numBands-4), 0, eq.numBands-4); |
49815cc0 | 887 | int avgFloor = (int) avgIndex; |
3f8be614 | 888 | |
4c006f7b MS |
889 | float leftVal = eq.getLevel(avgFloor); |
890 | float rightVal = eq.getLevel(avgFloor+1); | |
891 | float smoothValue = lerp(leftVal, rightVal, avgIndex-avgFloor); | |
892 | ||
893 | float chunkyValue = ( | |
894 | eq.getLevel(avgFloor/4*4) + | |
895 | eq.getLevel(avgFloor/4*4 + 1) + | |
896 | eq.getLevel(avgFloor/4*4 + 2) + | |
897 | eq.getLevel(avgFloor/4*4 + 3) | |
898 | ) / 4.; | |
899 | ||
900 | float value = lerp(smoothValue, chunkyValue, blockiness.getValuef()); | |
901 | ||
190d91c2 | 902 | float b = constrain(edgeConst * (value*model.yMax - p.y), 0, 100); |
19d16a16 | 903 | colors[p.index] = lx.hsb( |
190d91c2 | 904 | (480 + lx.getBaseHuef() - min(clrConst*p.y, 120)) % 360, |
4c006f7b MS |
905 | 100, |
906 | b | |
907 | ); | |
3f8be614 MS |
908 | } |
909 | } | |
910 | } | |
911 | ||
912 | class BoomEffect extends SCEffect { | |
913 | ||
914 | final BasicParameter falloff = new BasicParameter("WIDTH", 0.5); | |
915 | final BasicParameter speed = new BasicParameter("SPD", 0.5); | |
916 | final BasicParameter bright = new BasicParameter("BRT", 1.0); | |
917 | final BasicParameter sat = new BasicParameter("SAT", 0.2); | |
918 | List<Layer> layers = new ArrayList<Layer>(); | |
c39f7a04 | 919 | final float maxr = sqrt(model.xMax*model.xMax + model.yMax*model.yMax + model.zMax*model.zMax) + 10; |
3f8be614 MS |
920 | |
921 | class Layer { | |
922 | LinearEnvelope boom = new LinearEnvelope(-40, 500, 1300); | |
923 | ||
924 | Layer() { | |
925 | addModulator(boom); | |
926 | trigger(); | |
927 | } | |
928 | ||
929 | void trigger() { | |
930 | float falloffv = falloffv(); | |
2b6688e8 | 931 | boom.setRange(-100 / falloffv, maxr + 100/falloffv, 4000 - speed.getValuef() * 3300); |
3f8be614 MS |
932 | boom.trigger(); |
933 | } | |
934 | ||
d12e46b6 | 935 | void apply(int[] colors) { |
3f8be614 MS |
936 | float brightv = 100 * bright.getValuef(); |
937 | float falloffv = falloffv(); | |
938 | float satv = sat.getValuef() * 100; | |
939 | float huev = lx.getBaseHuef(); | |
2bb56822 | 940 | for (LXPoint p : model.points) { |
3f8be614 MS |
941 | colors[p.index] = blendColor( |
942 | colors[p.index], | |
19d16a16 | 943 | lx.hsb(huev, satv, constrain(brightv - falloffv*abs(boom.getValuef() - dist(p.x, 2*p.y, 3*p.z, model.xMax/2, model.yMax, model.zMax*1.5)), 0, 100)), |
3f8be614 MS |
944 | ADD); |
945 | } | |
946 | } | |
947 | } | |
948 | ||
949 | BoomEffect(GLucose glucose) { | |
950 | super(glucose, true); | |
951 | addParameter(falloff); | |
952 | addParameter(speed); | |
953 | addParameter(bright); | |
954 | addParameter(sat); | |
955 | } | |
956 | ||
957 | public void onEnable() { | |
958 | for (Layer l : layers) { | |
959 | if (!l.boom.isRunning()) { | |
960 | l.trigger(); | |
961 | return; | |
962 | } | |
963 | } | |
964 | layers.add(new Layer()); | |
965 | } | |
966 | ||
967 | private float falloffv() { | |
968 | return 20 - 19 * falloff.getValuef(); | |
969 | } | |
970 | ||
971 | public void onTrigger() { | |
972 | onEnable(); | |
973 | } | |
974 | ||
d12e46b6 | 975 | public void apply(int[] colors) { |
3f8be614 MS |
976 | for (Layer l : layers) { |
977 | if (l.boom.isRunning()) { | |
d12e46b6 | 978 | l.apply(colors); |
3f8be614 | 979 | } |
49815cc0 MS |
980 | } |
981 | } | |
982 | } | |
983 | ||
5d70e4d7 MS |
984 | public class PianoKeyPattern extends SCPattern { |
985 | ||
986 | final LinearEnvelope[] cubeBrt; | |
987 | final SinLFO base[]; | |
988 | final BasicParameter attack = new BasicParameter("ATK", 0.1); | |
989 | final BasicParameter release = new BasicParameter("REL", 0.5); | |
990 | final BasicParameter level = new BasicParameter("AMB", 0.6); | |
991 | ||
992 | PianoKeyPattern(GLucose glucose) { | |
993 | super(glucose); | |
a8d55ade | 994 | |
5d70e4d7 MS |
995 | addParameter(attack); |
996 | addParameter(release); | |
997 | addParameter(level); | |
87f6fa39 | 998 | cubeBrt = new LinearEnvelope[model.cubes.size() / 4]; |
5d70e4d7 MS |
999 | for (int i = 0; i < cubeBrt.length; ++i) { |
1000 | addModulator(cubeBrt[i] = new LinearEnvelope(0, 0, 100)); | |
1001 | } | |
87f6fa39 | 1002 | base = new SinLFO[model.cubes.size() / 12]; |
5d70e4d7 MS |
1003 | for (int i = 0; i < base.length; ++i) { |
1004 | addModulator(base[i] = new SinLFO(0, 1, 7000 + 1000*i)).trigger(); | |
1005 | } | |
1006 | } | |
1007 | ||
1008 | private float getAttackTime() { | |
1009 | return 15 + attack.getValuef()*attack.getValuef() * 2000; | |
1010 | } | |
1011 | ||
1012 | private float getReleaseTime() { | |
1013 | return 15 + release.getValuef() * 3000; | |
1014 | } | |
1015 | ||
1016 | private LinearEnvelope getEnvelope(int index) { | |
1017 | return cubeBrt[index % cubeBrt.length]; | |
1018 | } | |
1019 | ||
1020 | private SinLFO getBase(int index) { | |
1021 | return base[index % base.length]; | |
1022 | } | |
1023 | ||
242b19ad | 1024 | public boolean noteOn(Note note) { |
5d70e4d7 MS |
1025 | LinearEnvelope env = getEnvelope(note.getPitch()); |
1026 | env.setEndVal(min(1, env.getValuef() + (note.getVelocity() / 127.)), getAttackTime()).start(); | |
d6ac1ee8 | 1027 | return true; |
5d70e4d7 MS |
1028 | } |
1029 | ||
242b19ad | 1030 | public boolean noteOff(Note note) { |
5d70e4d7 | 1031 | getEnvelope(note.getPitch()).setEndVal(0, getReleaseTime()).start(); |
d6ac1ee8 | 1032 | return true; |
5d70e4d7 MS |
1033 | } |
1034 | ||
34327c96 | 1035 | public void run(double deltaMs) { |
5d70e4d7 MS |
1036 | int i = 0; |
1037 | float huef = lx.getBaseHuef(); | |
1038 | float levelf = level.getValuef(); | |
87f6fa39 | 1039 | for (Cube c : model.cubes) { |
5d70e4d7 | 1040 | float v = max(getBase(i).getValuef() * levelf/4., getEnvelope(i++).getValuef()); |
19d16a16 | 1041 | setColor(c, lx.hsb( |
e0cea600 | 1042 | (huef + 20*v + abs(c.cx-model.xMax/2.)*.3 + c.cy) % 360, |
5d70e4d7 MS |
1043 | min(100, 120*v), |
1044 | 100*v | |
1045 | )); | |
1046 | } | |
1047 | } | |
1048 | } | |
1049 | ||
0106b29c MS |
1050 | class CrossSections extends SCPattern { |
1051 | ||
c39f7a04 MS |
1052 | final SinLFO x = new SinLFO(0, model.xMax, 5000); |
1053 | final SinLFO y = new SinLFO(0, model.yMax, 6000); | |
1054 | final SinLFO z = new SinLFO(0, model.zMax, 7000); | |
0106b29c MS |
1055 | |
1056 | final BasicParameter xw = new BasicParameter("XWID", 0.3); | |
1057 | final BasicParameter yw = new BasicParameter("YWID", 0.3); | |
1058 | final BasicParameter zw = new BasicParameter("ZWID", 0.3); | |
2b6688e8 | 1059 | final BasicParameter xr = new BasicParameter("XRAT", 0.7); |
0106b29c | 1060 | final BasicParameter yr = new BasicParameter("YRAT", 0.6); |
2b6688e8 MS |
1061 | final BasicParameter zr = new BasicParameter("ZRAT", 0.5); |
1062 | final BasicParameter xl = new BasicParameter("XLEV", 1); | |
0106b29c | 1063 | final BasicParameter yl = new BasicParameter("YLEV", 1); |
2b6688e8 | 1064 | final BasicParameter zl = new BasicParameter("ZLEV", 0.5); |
0106b29c MS |
1065 | |
1066 | ||
1067 | CrossSections(GLucose glucose) { | |
1068 | super(glucose); | |
1069 | addModulator(x).trigger(); | |
1070 | addModulator(y).trigger(); | |
1071 | addModulator(z).trigger(); | |
b12bca62 MS |
1072 | addParams(); |
1073 | } | |
1074 | ||
1075 | protected void addParams() { | |
0106b29c MS |
1076 | addParameter(xr); |
1077 | addParameter(yr); | |
1078 | addParameter(zr); | |
2b6688e8 | 1079 | addParameter(xw); |
0106b29c MS |
1080 | addParameter(xl); |
1081 | addParameter(yl); | |
1082 | addParameter(zl); | |
2b6688e8 MS |
1083 | addParameter(yw); |
1084 | addParameter(zw); | |
0106b29c | 1085 | } |
3e8e60d8 MS |
1086 | |
1087 | void onParameterChanged(LXParameter p) { | |
0106b29c | 1088 | if (p == xr) { |
2b6688e8 | 1089 | x.setDuration(10000 - 8800*p.getValuef()); |
0106b29c | 1090 | } else if (p == yr) { |
2b6688e8 | 1091 | y.setDuration(10000 - 9000*p.getValuef()); |
0106b29c MS |
1092 | } else if (p == zr) { |
1093 | z.setDuration(10000 - 9000*p.getValuef()); | |
1094 | } | |
0106b29c | 1095 | } |
b12bca62 MS |
1096 | |
1097 | float xv, yv, zv; | |
1098 | ||
1099 | protected void updateXYZVals() { | |
1100 | xv = x.getValuef(); | |
1101 | yv = y.getValuef(); | |
1102 | zv = z.getValuef(); | |
1103 | } | |
0106b29c | 1104 | |
34327c96 | 1105 | public void run(double deltaMs) { |
f1c74267 MS |
1106 | updateXYZVals(); |
1107 | ||
0106b29c MS |
1108 | float xlv = 100*xl.getValuef(); |
1109 | float ylv = 100*yl.getValuef(); | |
1110 | float zlv = 100*zl.getValuef(); | |
1111 | ||
1112 | float xwv = 100. / (10 + 40*xw.getValuef()); | |
1113 | float ywv = 100. / (10 + 40*yw.getValuef()); | |
1114 | float zwv = 100. / (10 + 40*zw.getValuef()); | |
1115 | ||
2bb56822 | 1116 | for (LXPoint p : model.points) { |
0106b29c | 1117 | color c = 0; |
19d16a16 | 1118 | c = blendColor(c, lx.hsb( |
190d91c2 MS |
1119 | (lx.getBaseHuef() + p.x/10 + p.y/3) % 360, |
1120 | constrain(140 - 1.1*abs(p.x - model.xMax/2.), 0, 100), | |
1121 | max(0, xlv - xwv*abs(p.x - xv)) | |
0106b29c | 1122 | ), ADD); |
19d16a16 | 1123 | c = blendColor(c, lx.hsb( |
190d91c2 MS |
1124 | (lx.getBaseHuef() + 80 + p.y/10) % 360, |
1125 | constrain(140 - 2.2*abs(p.y - model.yMax/2.), 0, 100), | |
1126 | max(0, ylv - ywv*abs(p.y - yv)) | |
0106b29c | 1127 | ), ADD); |
19d16a16 | 1128 | c = blendColor(c, lx.hsb( |
190d91c2 MS |
1129 | (lx.getBaseHuef() + 160 + p.z / 10 + p.y/2) % 360, |
1130 | constrain(140 - 2.2*abs(p.z - model.zMax/2.), 0, 100), | |
1131 | max(0, zlv - zwv*abs(p.z - zv)) | |
0106b29c MS |
1132 | ), ADD); |
1133 | colors[p.index] = c; | |
1134 | } | |
1135 | } | |
1136 | } | |
1137 | ||
1138 | class Blinders extends SCPattern { | |
1139 | ||
aa54c1ca | 1140 | final SinLFO[] m; |
0106b29c MS |
1141 | final TriangleLFO r; |
1142 | final SinLFO s; | |
1143 | final TriangleLFO hs; | |
1144 | ||
1145 | public Blinders(GLucose glucose) { | |
1146 | super(glucose); | |
aa54c1ca MS |
1147 | m = new SinLFO[12]; |
1148 | for (int i = 0; i < m.length; ++i) { | |
1149 | addModulator(m[i] = new SinLFO(0.5, 120, (120000. / (3+i)))).trigger(); | |
1150 | } | |
1151 | addModulator(r = new TriangleLFO(9000, 15000, 29000)).trigger(); | |
1152 | addModulator(s = new SinLFO(-20, 275, 11000)).trigger(); | |
0106b29c | 1153 | addModulator(hs = new TriangleLFO(0.1, 0.5, 15000)).trigger(); |
aa54c1ca | 1154 | s.modulateDurationBy(r); |
0106b29c MS |
1155 | } |
1156 | ||
34327c96 | 1157 | public void run(double deltaMs) { |
0106b29c | 1158 | float hv = lx.getBaseHuef(); |
aa54c1ca | 1159 | int si = 0; |
87f6fa39 | 1160 | for (Strip strip : model.strips) { |
0106b29c | 1161 | int i = 0; |
aa54c1ca | 1162 | float mv = m[si % m.length].getValuef(); |
2bb56822 | 1163 | for (LXPoint p : strip.points) { |
19d16a16 | 1164 | colors[p.index] = lx.hsb( |
190d91c2 MS |
1165 | (hv + p.z + p.y*hs.getValuef()) % 360, |
1166 | min(100, abs(p.x - s.getValuef())/2.), | |
254fbb68 | 1167 | max(0, 100 - mv/2. - mv * abs(i - (strip.metrics.length-1)/2.)) |
0106b29c MS |
1168 | ); |
1169 | ++i; | |
1170 | } | |
aa54c1ca | 1171 | ++si; |
0106b29c MS |
1172 | } |
1173 | } | |
1174 | } | |
1175 | ||
87f6fa39 MS |
1176 | class Psychedelia extends SCPattern { |
1177 | ||
1178 | final int NUM = 3; | |
1179 | SinLFO m = new SinLFO(-0.5, NUM-0.5, 9000); | |
1180 | SinLFO s = new SinLFO(-20, 147, 11000); | |
1181 | TriangleLFO h = new TriangleLFO(0, 240, 19000); | |
1182 | SinLFO c = new SinLFO(-.2, .8, 31000); | |
1183 | ||
1184 | Psychedelia(GLucose glucose) { | |
1185 | super(glucose); | |
1186 | addModulator(m).trigger(); | |
1187 | addModulator(s).trigger(); | |
1188 | addModulator(h).trigger(); | |
1189 | addModulator(c).trigger(); | |
1190 | } | |
0106b29c | 1191 | |
34327c96 | 1192 | void run(double deltaMs) { |
87f6fa39 MS |
1193 | float huev = h.getValuef(); |
1194 | float cv = c.getValuef(); | |
1195 | float sv = s.getValuef(); | |
1196 | float mv = m.getValuef(); | |
1197 | int i = 0; | |
1198 | for (Strip strip : model.strips) { | |
2bb56822 | 1199 | for (LXPoint p : strip.points) { |
19d16a16 | 1200 | colors[p.index] = lx.hsb( |
190d91c2 MS |
1201 | (huev + i*constrain(cv, 0, 2) + p.z/2. + p.x/4.) % 360, |
1202 | min(100, abs(p.y-sv)), | |
87f6fa39 MS |
1203 | max(0, 100 - 50*abs((i%NUM) - mv)) |
1204 | ); | |
1205 | } | |
1206 | ++i; | |
1207 | } | |
1208 | } | |
1209 | } | |
5129affb MS |
1210 | |
1211 | class AskewPlanes extends SCPattern { | |
1212 | ||
1213 | class Plane { | |
1214 | private final SinLFO a; | |
1215 | private final SinLFO b; | |
1216 | private final SinLFO c; | |
775d3394 MS |
1217 | float av = 1; |
1218 | float bv = 1; | |
1219 | float cv = 1; | |
1220 | float denom = 0.1; | |
5129affb MS |
1221 | |
1222 | Plane(int i) { | |
1223 | addModulator(a = new SinLFO(-1, 1, 4000 + 1029*i)).trigger(); | |
1224 | addModulator(b = new SinLFO(-1, 1, 11000 - 1104*i)).trigger(); | |
1225 | addModulator(c = new SinLFO(-50, 50, 4000 + 1000*i * ((i % 2 == 0) ? 1 : -1))).trigger(); | |
1226 | } | |
1227 | ||
34327c96 | 1228 | void run(double deltaMs) { |
5129affb MS |
1229 | av = a.getValuef(); |
1230 | bv = b.getValuef(); | |
1231 | cv = c.getValuef(); | |
1232 | denom = sqrt(av*av + bv*bv); | |
1233 | } | |
1234 | } | |
1235 | ||
1236 | final Plane[] planes; | |
1237 | final int NUM_PLANES = 3; | |
1238 | ||
1239 | AskewPlanes(GLucose glucose) { | |
1240 | super(glucose); | |
1241 | planes = new Plane[NUM_PLANES]; | |
1242 | for (int i = 0; i < planes.length; ++i) { | |
1243 | planes[i] = new Plane(i); | |
1244 | } | |
1245 | } | |
5129affb | 1246 | |
34327c96 | 1247 | public void run(double deltaMs) { |
5129affb | 1248 | float huev = lx.getBaseHuef(); |
775d3394 MS |
1249 | |
1250 | // This is super fucking bizarre. But if this is a for loop, the framerate | |
1251 | // tanks to like 30FPS, instead of 60. Call them manually and it works fine. | |
1252 | // Doesn't make ANY sense... there must be some weird side effect going on | |
1253 | // with the Processing internals perhaps? | |
1254 | // for (Plane plane : planes) { | |
1255 | // plane.run(deltaMs); | |
1256 | // } | |
1257 | planes[0].run(deltaMs); | |
1258 | planes[1].run(deltaMs); | |
1259 | planes[2].run(deltaMs); | |
1260 | ||
2bb56822 | 1261 | for (LXPoint p : model.points) { |
775d3394 MS |
1262 | float d = MAX_FLOAT; |
1263 | for (Plane plane : planes) { | |
1264 | if (plane.denom != 0) { | |
190d91c2 | 1265 | d = min(d, abs(plane.av*(p.x-model.cx) + plane.bv*(p.y-model.cy) + plane.cv) / plane.denom); |
775d3394 MS |
1266 | } |
1267 | } | |
19d16a16 | 1268 | colors[p.index] = lx.hsb( |
190d91c2 MS |
1269 | (huev + abs(p.x-model.cx)*.3 + p.y*.8) % 360, |
1270 | max(0, 100 - .8*abs(p.x - model.cx)), | |
775d3394 MS |
1271 | constrain(140 - 10.*d, 0, 100) |
1272 | ); | |
5129affb MS |
1273 | } |
1274 | } | |
1275 | } | |
1276 | ||
1277 | class ShiftingPlane extends SCPattern { | |
1278 | ||
1279 | final SinLFO a = new SinLFO(-.2, .2, 5300); | |
1280 | final SinLFO b = new SinLFO(1, -1, 13300); | |
1281 | final SinLFO c = new SinLFO(-1.4, 1.4, 5700); | |
1282 | final SinLFO d = new SinLFO(-10, 10, 9500); | |
1283 | ||
1284 | ShiftingPlane(GLucose glucose) { | |
1285 | super(glucose); | |
1286 | addModulator(a).trigger(); | |
1287 | addModulator(b).trigger(); | |
1288 | addModulator(c).trigger(); | |
1289 | addModulator(d).trigger(); | |
1290 | } | |
1291 | ||
34327c96 | 1292 | public void run(double deltaMs) { |
5129affb MS |
1293 | float hv = lx.getBaseHuef(); |
1294 | float av = a.getValuef(); | |
1295 | float bv = b.getValuef(); | |
1296 | float cv = c.getValuef(); | |
1297 | float dv = d.getValuef(); | |
1298 | float denom = sqrt(av*av + bv*bv + cv*cv); | |
2bb56822 | 1299 | for (LXPoint p : model.points) { |
190d91c2 | 1300 | float d = abs(av*(p.x-model.cx) + bv*(p.y-model.cy) + cv*(p.z-model.cz) + dv) / denom; |
19d16a16 | 1301 | colors[p.index] = lx.hsb( |
190d91c2 | 1302 | (hv + abs(p.x-model.cx)*.6 + abs(p.y-model.cy)*.9 + abs(p.z - model.cz)) % 360, |
5129affb MS |
1303 | constrain(110 - d*6, 0, 100), |
1304 | constrain(130 - 7*d, 0, 100) | |
1305 | ); | |
1306 | } | |
1307 | } | |
1308 | } | |
f3f5a876 | 1309 | |
4c006f7b MS |
1310 | class Traktor extends SCPattern { |
1311 | ||
1312 | final int FRAME_WIDTH = 60; | |
1313 | ||
1314 | final BasicParameter speed = new BasicParameter("SPD", 0.5); | |
1315 | ||
1316 | private float[] bass = new float[FRAME_WIDTH]; | |
1317 | private float[] treble = new float[FRAME_WIDTH]; | |
1318 | ||
1319 | private int index = 0; | |
1320 | private GraphicEQ eq = null; | |
1321 | ||
1322 | public Traktor(GLucose glucose) { | |
1323 | super(glucose); | |
1324 | for (int i = 0; i < FRAME_WIDTH; ++i) { | |
1325 | bass[i] = 0; | |
1326 | treble[i] = 0; | |
1327 | } | |
1328 | addParameter(speed); | |
1329 | } | |
1330 | ||
1331 | public void onActive() { | |
1332 | if (eq == null) { | |
1333 | eq = new GraphicEQ(lx, 16); | |
1334 | eq.slope.setValue(0.6); | |
1335 | eq.level.setValue(0.65); | |
1336 | eq.range.setValue(0.35); | |
1337 | eq.release.setValue(0.4); | |
1338 | addParameter(eq.level); | |
1339 | addParameter(eq.range); | |
1340 | addParameter(eq.attack); | |
1341 | addParameter(eq.release); | |
1342 | addParameter(eq.slope); | |
1343 | } | |
1344 | } | |
1345 | ||
1346 | int counter = 0; | |
1347 | ||
34327c96 | 1348 | public void run(double deltaMs) { |
4c006f7b MS |
1349 | eq.run(deltaMs); |
1350 | ||
1351 | int stepThresh = (int) (40 - 39*speed.getValuef()); | |
1352 | counter += deltaMs; | |
1353 | if (counter < stepThresh) { | |
1354 | return; | |
1355 | } | |
1356 | counter = counter % stepThresh; | |
1357 | ||
1358 | index = (index + 1) % FRAME_WIDTH; | |
1359 | ||
1360 | float rawBass = eq.getAverageLevel(0, 4); | |
1361 | float rawTreble = eq.getAverageLevel(eq.numBands-7, 7); | |
1362 | ||
1363 | bass[index] = rawBass * rawBass * rawBass * rawBass; | |
1364 | treble[index] = rawTreble * rawTreble; | |
1365 | ||
2bb56822 | 1366 | for (LXPoint p : model.points) { |
4c006f7b MS |
1367 | int i = (int) constrain((model.xMax - p.x) / model.xMax * FRAME_WIDTH, 0, FRAME_WIDTH-1); |
1368 | int pos = (index + FRAME_WIDTH - i) % FRAME_WIDTH; | |
1369 | ||
19d16a16 | 1370 | colors[p.index] = lx.hsb( |
4c006f7b MS |
1371 | (360 + lx.getBaseHuef() + .8*abs(p.x-model.cx)) % 360, |
1372 | 100, | |
29d8acbb | 1373 | constrain(9 * (bass[pos]*model.cy - abs(p.y - model.cy + 5)), 0, 100) |
4c006f7b | 1374 | ); |
19d16a16 | 1375 | colors[p.index] = blendColor(colors[p.index], lx.hsb( |
4c006f7b MS |
1376 | (400 + lx.getBaseHuef() + .5*abs(p.x-model.cx)) % 360, |
1377 | 60, | |
190d91c2 | 1378 | constrain(5 * (treble[pos]*.6*model.cy - abs(p.y - model.cy)), 0, 100) |
4c006f7b MS |
1379 | |
1380 | ), ADD); | |
1381 | } | |
1382 | } | |
1383 | } | |
6702151a MS |
1384 | |
1385 | class ColorFuckerEffect extends SCEffect { | |
1386 | ||
e5308763 | 1387 | final BasicParameter level = new BasicParameter("BRT", 1); |
1388 | final BasicParameter desat = new BasicParameter("DSAT", 0); | |
29d8acbb | 1389 | final BasicParameter hueShift = new BasicParameter("HSHFT", 0); |
e5308763 | 1390 | final BasicParameter sharp = new BasicParameter("SHARP", 0); |
1391 | final BasicParameter soft = new BasicParameter("SOFT", 0); | |
1392 | final BasicParameter mono = new BasicParameter("MONO", 0); | |
1393 | final BasicParameter invert = new BasicParameter("INVERT", 0); | |
29d8acbb | 1394 | |
e5308763 | 1395 | |
4214e9a2 | 1396 | float[] hsb = new float[3]; |
6702151a MS |
1397 | |
1398 | ColorFuckerEffect(GLucose glucose) { | |
1399 | super(glucose); | |
e5308763 | 1400 | addParameter(level); |
1401 | addParameter(desat); | |
1402 | addParameter(sharp); | |
29d8acbb | 1403 | addParameter(hueShift); |
e5308763 | 1404 | addParameter(soft); |
1405 | addParameter(mono); | |
1406 | addParameter(invert); | |
6702151a MS |
1407 | } |
1408 | ||
d12e46b6 | 1409 | public void apply(int[] colors) { |
d626bc9b MS |
1410 | if (!enabled) { |
1411 | return; | |
1412 | } | |
e5308763 | 1413 | float bMod = level.getValuef(); |
1414 | float sMod = 1 - desat.getValuef(); | |
6702151a | 1415 | float hMod = hueShift.getValuef(); |
ef7118ad | 1416 | float fSharp = sharp.getValuef(); |
e5308763 | 1417 | float fSoft = soft.getValuef(); |
1418 | boolean mon = mono.getValuef() > 0.5; | |
1419 | boolean ivt = invert.getValuef() > 0.5; | |
1420 | if (bMod < 1 || sMod < 1 || hMod > 0 || fSharp > 0 || ivt || mon || fSoft > 0) { | |
6702151a | 1421 | for (int i = 0; i < colors.length; ++i) { |
4214e9a2 | 1422 | lx.RGBtoHSB(colors[i], hsb); |
e5308763 | 1423 | if (mon) { |
1424 | hsb[0] = lx.getBaseHuef() / 360.; | |
1425 | } | |
1426 | if (ivt) { | |
1427 | hsb[2] = 1 - hsb[2]; | |
1428 | } | |
1429 | if (fSharp > 0) { | |
ef7118ad | 1430 | fSharp = 1/(1-fSharp); |
bae2197a MS |
1431 | if (hsb[2] < .5) { |
1432 | hsb[2] = pow(hsb[2],fSharp); | |
1433 | } else { | |
1434 | hsb[2] = 1-pow(1-hsb[2],fSharp); | |
1435 | } | |
e5308763 | 1436 | } |
1437 | if (fSoft > 0) { | |
1438 | if (hsb[2] > 0.5) { | |
1439 | hsb[2] = lerp(hsb[2], 0.5 + 2 * (hsb[2]-0.5)*(hsb[2]-0.5), fSoft); | |
1440 | } else { | |
1441 | hsb[2] = lerp(hsb[2], 0.5 * sqrt(2*hsb[2]), fSoft); | |
1442 | } | |
1443 | } | |
4214e9a2 | 1444 | colors[i] = lx.hsb( |
e5308763 | 1445 | (360. * hsb[0] + hMod*360.) % 360, |
1446 | 100. * hsb[1] * sMod, | |
1447 | 100. * hsb[2] * bMod | |
6702151a MS |
1448 | ); |
1449 | } | |
1450 | } | |
1451 | } | |
1452 | } | |
348fed66 | 1453 | |
e5308763 | 1454 | class QuantizeEffect extends SCEffect { |
1455 | ||
1456 | color[] quantizedFrame; | |
1457 | float lastQuant; | |
1458 | final BasicParameter amount = new BasicParameter("AMT", 0); | |
1459 | ||
1460 | QuantizeEffect(GLucose glucose) { | |
1461 | super(glucose); | |
1462 | quantizedFrame = new color[glucose.lx.total]; | |
1463 | lastQuant = 0; | |
1464 | } | |
1465 | ||
d12e46b6 | 1466 | public void apply(int[] colors) { |
e5308763 | 1467 | float fQuant = amount.getValuef(); |
1468 | if (fQuant > 0) { | |
1469 | float tRamp = (lx.tempo.rampf() % (1./pow(2,floor((1-fQuant) * 4)))); | |
1470 | float f = lastQuant; | |
1471 | lastQuant = tRamp; | |
1472 | if (tRamp > f) { | |
1473 | for (int i = 0; i < colors.length; ++i) { | |
1474 | colors[i] = quantizedFrame[i]; | |
1475 | } | |
1476 | return; | |
1477 | } | |
1478 | } | |
1479 | for (int i = 0; i < colors.length; ++i) { | |
1480 | quantizedFrame[i] = colors[i]; | |
1481 | } | |
1482 | } | |
1483 | } | |
1484 | ||
348fed66 MS |
1485 | class BlurEffect extends SCEffect { |
1486 | ||
05ebfd15 | 1487 | final BasicParameter amount = new BasicParameter("AMT", 0); |
348fed66 MS |
1488 | final int[] frame; |
1489 | final LinearEnvelope env = new LinearEnvelope(0, 1, 100); | |
1490 | ||
1491 | BlurEffect(GLucose glucose) { | |
1492 | super(glucose); | |
1493 | addParameter(amount); | |
1494 | addModulator(env); | |
1495 | frame = new int[lx.total]; | |
1496 | for (int i = 0; i < frame.length; ++i) { | |
1497 | frame[i] = #000000; | |
1498 | } | |
1499 | } | |
1500 | ||
1501 | public void onEnable() { | |
1502 | env.setRangeFromHereTo(1, 400).start(); | |
1503 | for (int i = 0; i < frame.length; ++i) { | |
1504 | frame[i] = #000000; | |
1505 | } | |
1506 | } | |
1507 | ||
1508 | public void onDisable() { | |
1509 | env.setRangeFromHereTo(0, 1000).start(); | |
1510 | } | |
1511 | ||
d12e46b6 | 1512 | public void apply(int[] colors) { |
348fed66 MS |
1513 | float amt = env.getValuef() * amount.getValuef(); |
1514 | if (amt > 0) { | |
1515 | amt = (1 - amt); | |
1516 | amt = 1 - (amt*amt*amt); | |
1517 | for (int i = 0; i < colors.length; ++i) { | |
1518 | // frame[i] = colors[i] = blendColor(colors[i], lerpColor(#000000, frame[i], amt, RGB), SCREEN); | |
1519 | frame[i] = colors[i] = lerpColor(colors[i], blendColor(colors[i], frame[i], SCREEN), amt, RGB); | |
1520 | } | |
1521 | } | |
1522 | ||
1523 | } | |
1524 | } | |
2bb56822 | 1525 |