-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpresentation.html
More file actions
514 lines (470 loc) · 21.6 KB
/
Copy pathpresentation.html
File metadata and controls
514 lines (470 loc) · 21.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LNP</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@200;300;400;600;700;800;900&display=swap');
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', sans-serif; background: #020208; color: #fff; overflow: hidden; height: 100vh; }
canvas#bg { position: fixed; inset: 0; z-index: 0; }
.slide {
position: absolute; inset: 0;
display: flex; flex-direction: column; align-items: center; justify-content: center;
padding: 40px 80px; opacity: 0; transition: opacity 1s ease;
pointer-events: none; z-index: 1;
}
.slide.active { opacity: 1; pointer-events: all; }
.progress { position: fixed; bottom: 0; left: 0; height: 1px; background: rgba(79,195,247,0.3); transition: width 0.6s; z-index: 50; }
/* Minimal text — the visuals speak */
.whisper {
font-size: 1.6rem; font-weight: 200; color: rgba(255,255,255,0.25);
text-align: center; max-width: 700px; line-height: 1.8; letter-spacing: 0.5px;
}
.speak {
font-size: 2.8rem; font-weight: 700; color: rgba(255,255,255,0.9);
text-align: center; max-width: 800px; line-height: 1.3; letter-spacing: -0.5px;
}
.speak .a { color: #4fc3f7; }
.speak .w { color: #ffd28c; }
.speak .r { color: #ff6b6b; }
.speak .g { color: #64dc96; }
.speak .d { color: rgba(255,255,255,0.2); font-weight: 300; }
.float-text {
font-size: 1.1rem; font-weight: 300; color: rgba(255,255,255,0.15);
text-align: center; max-width: 600px; line-height: 1.8; margin-top: 20px;
}
/* Vitals overlay */
.vitals-overlay {
display: flex; gap: 24px; margin-top: 20px;
}
.vital {
text-align: center; padding: 12px 20px; border-radius: 12px;
background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.04);
min-width: 90px;
}
.vital-label { font-size: 0.55rem; text-transform: uppercase; letter-spacing: 2px; color: rgba(255,255,255,0.2); }
.vital-num { font-size: 1.8rem; font-weight: 800; margin: 2px 0; }
.vital-num.red { color: #ff6b6b; }
.vital-num.green { color: #64dc96; }
.vital-unit { font-size: 0.6rem; color: rgba(255,255,255,0.15); }
/* Bird grid */
.bird-row {
display: flex; gap: 16px; margin-top: 16px; flex-wrap: wrap; justify-content: center;
}
.bird-pill {
display: flex; align-items: center; gap: 8px;
padding: 8px 16px; border-radius: 30px;
background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.05);
}
.bird-pill-emoji { font-size: 1.4rem; }
.bird-pill-name { font-size: 0.7rem; color: rgba(255,255,255,0.3); font-weight: 500; }
/* Tech footer */
.tech-strip {
position: absolute; bottom: 40px; left: 0; right: 0;
text-align: center; font-size: 0.65rem; color: rgba(255,255,255,0.08);
letter-spacing: 2px;
}
/* Quote */
.ai-quote {
margin-top: 16px; padding: 16px 24px; border-radius: 14px;
background: rgba(79,195,247,0.02); border: 1px solid rgba(79,195,247,0.06);
max-width: 550px;
}
.ai-quote-text { font-size: 0.9rem; color: rgba(79,195,247,0.4); font-style: italic; line-height: 1.7; }
.ai-quote-who { font-size: 0.65rem; color: rgba(255,255,255,0.1); margin-top: 4px; }
/* Impact list */
.prevent-list {
list-style: none; margin-top: 16px; max-width: 500px;
}
.prevent-list li {
padding: 8px 0; font-size: 1rem; color: rgba(255,255,255,0.3);
border-bottom: 1px solid rgba(255,255,255,0.03); font-weight: 300;
}
.prevent-list li span { margin-right: 10px; }
/* Two column */
.two-col { display: flex; gap: 20px; margin-top: 16px; max-width: 800px; width: 100%; }
.col {
flex: 1; padding: 20px; border-radius: 14px;
background: rgba(255,255,255,0.015); border: 1px solid rgba(255,255,255,0.04);
}
.col-t { font-size: 0.6rem; letter-spacing: 3px; text-transform: uppercase; margin-bottom: 10px; font-weight: 600; color: rgba(79,195,247,0.4); }
.col-i { font-size: 0.78rem; color: rgba(255,255,255,0.3); padding: 3px 0; line-height: 1.5; }
.col.warm { background: rgba(255,210,140,0.015); border-color: rgba(255,210,140,0.06); }
.col.warm .col-t { color: rgba(255,210,140,0.4); }
</style>
</head>
<body>
<canvas id="bg"></canvas>
<div class="progress" id="progress"></div>
<!-- 1. BIRTH — single string in the void -->
<div class="slide active" id="s0">
<div class="speak">What is a <span class="a">thought?</span></div>
<div class="whisper" style="margin-top: 24px;">
Before it has a name. Before it has a shape.<br>
Just a pulse of energy in infinite dark.
</div>
</div>
<!-- 2. CONNECTION — strings linking -->
<div class="slide" id="s1">
<div class="speak">It <span class="a">connects.</span></div>
<div class="whisper" style="margin-top: 24px;">
One thought touches a memory.<br>
That memory touches a fear.<br>
That fear touches a truth you weren't ready for.
</div>
</div>
<!-- 3. LOOP — strings looping back -->
<div class="slide" id="s2">
<div class="speak">It <span class="w">loops.</span></div>
<div class="whisper" style="margin-top: 24px;">
The same thought. Again. And again.<br>
Each time deeper. Each time from a different angle.<br>
You sleep. You wake up. It's still there.
</div>
</div>
<!-- 4. ENTANGLED — chaos, violent vibrations -->
<div class="slide" id="s3">
<div class="speak"><span class="r">Entangled.</span></div>
<div class="float-text">
The strings knot. The vibrations clash.<br>
You question reality. Existence. Humanity. Truth.<br>
You see what others look past. You feel what others numb.<br>
Your body screams — heart racing, hands shaking, breath gone.
</div>
</div>
<!-- 5. THE WATCH SEES — vitals appear over chaos -->
<div class="slide" id="s4">
<div class="speak" style="font-size: 2rem;">But your <span class="a">watch</span> sees the storm.</div>
<div class="vitals-overlay">
<div class="vital"><div class="vital-label">Heart Rate</div><div class="vital-num red">138</div><div class="vital-unit">BPM</div></div>
<div class="vital"><div class="vital-label">HRV</div><div class="vital-num red">8</div><div class="vital-unit">ms</div></div>
<div class="vital"><div class="vital-label">EDA</div><div class="vital-num red">18.0</div><div class="vital-unit">μS</div></div>
<div class="vital"><div class="vital-label">Resp Rate</div><div class="vital-num red">36</div><div class="vital-unit">/min</div></div>
<div class="vital"><div class="vital-label">Skin Temp</div><div class="vital-num red">34.8</div><div class="vital-unit">°C</div></div>
</div>
<div class="float-text" style="margin-top: 14px;">
Your body knows before your mind does.<br>
HRV drops minutes before panic peaks. We just listen.
</div>
</div>
<!-- 6. THE BIRD ARRIVES — new energy enters -->
<div class="slide" id="s5">
<div class="speak" style="font-size: 2.4rem;">A <span class="a">friend</span> arrives.</div>
<div class="bird-row">
<div class="bird-pill"><span class="bird-pill-emoji">🐧</span><span class="bird-pill-name">Pingu</span></div>
<div class="bird-pill"><span class="bird-pill-emoji">🦉</span><span class="bird-pill-name">Owl</span></div>
<div class="bird-pill"><span class="bird-pill-emoji">🐦</span><span class="bird-pill-name">Robin</span></div>
<div class="bird-pill"><span class="bird-pill-emoji">🕊️</span><span class="bird-pill-name">Dove</span></div>
<div class="bird-pill"><span class="bird-pill-emoji">🦩</span><span class="bird-pill-name">Flamingo</span></div>
<div class="bird-pill"><span class="bird-pill-emoji">🦅</span><span class="bird-pill-name">Eagle</span></div>
<div class="bird-pill"><span class="bird-pill-emoji">🦜</span><span class="bird-pill-name">Parrot</span></div>
<div class="bird-pill"><span class="bird-pill-emoji">🦢</span><span class="bird-pill-name">Swan</span></div>
<div class="bird-pill"><span class="bird-pill-emoji">🪶</span><span class="bird-pill-name">Feather</span></div>
<div class="bird-pill"><span class="bird-pill-emoji">🐦⬛</span><span class="bird-pill-name">Crow</span></div>
</div>
<div class="ai-quote">
<div class="ai-quote-text">"Hey. Your heart's racing but you're safe. I'm here.<br>Tell me — if you could live inside any painting, which one would it be?"</div>
<div class="ai-quote-who">— Pingu, redirecting your thoughts to the safe zone</div>
</div>
</div>
<!-- 7. UNTANGLING — strings smoothing, thoughts shifting -->
<div class="slide" id="s6">
<div class="speak">The strings <span class="g">untangle.</span></div>
<div class="vitals-overlay">
<div class="vital"><div class="vital-label">Heart Rate</div><div class="vital-num green">72</div><div class="vital-unit">BPM</div></div>
<div class="vital"><div class="vital-label">HRV</div><div class="vital-num green">60</div><div class="vital-unit">ms</div></div>
<div class="vital"><div class="vital-label">EDA</div><div class="vital-num green">2.0</div><div class="vital-unit">μS</div></div>
<div class="vital"><div class="vital-label">Resp Rate</div><div class="vital-num green">14</div><div class="vital-unit">/min</div></div>
<div class="vital"><div class="vital-label">Skin Temp</div><div class="vital-num green">36.6</div><div class="vital-unit">°C</div></div>
</div>
<div class="whisper" style="margin-top: 20px;">
The thought is still there.<br>
But it's no longer the only thing in the room.<br>
The mind found its way back.
</div>
</div>
<!-- 8. WHAT WE PREVENT — the real impact -->
<div class="slide" id="s7">
<div class="speak" style="font-size: 2.2rem;">What we <span class="a">prevent.</span></div>
<div class="float-text" style="margin-bottom: 10px;">
When a mind is trapped in the storm with no voice to guide it,<br>
the consequences are real.
</div>
<ul class="prevent-list">
<li><span>🌀</span> Panic attacks that spiral into hours of suffering</li>
<li><span>🚪</span> Isolation — withdrawing from the world that feels too loud</li>
<li><span>💊</span> Self-medication — numbing what could be redirected</li>
<li><span>🖤</span> The darkest moments — when the thought loop has no exit</li>
<li><span>🔁</span> Chronic anxiety becoming a way of life</li>
</ul>
<div class="whisper" style="margin-top: 16px; font-size: 1.2rem; color: rgba(79,195,247,0.4); font-weight: 600;">
One conversation at the right moment<br>can change the direction of a life.
</div>
</div>
<!-- 9. THE TECH (brief, credible) -->
<div class="slide" id="s8">
<div class="speak" style="font-size: 2rem;">How it's <span class="a">built.</span></div>
<div class="two-col">
<div class="col">
<div class="col-t">Detection</div>
<div class="col-i">Apple Watch + HealthKit — real-time HR, HRV, SpO2, temperature, respiratory rate, EDA</div>
<div class="col-i">Panic score algorithm combining all 8 vitals</div>
<div class="col-i">3-5 minute early warning before conscious panic</div>
<div class="col-i" style="color: #ffd28c; font-weight: 600; margin-top: 6px;">99% correlation with medical ECG</div>
</div>
<div class="col">
<div class="col-t">Response</div>
<div class="col-i">Gemini AI — vitals-aware, adaptive conversation</div>
<div class="col-i">10 bird companions with unique personalities and voices</div>
<div class="col-i">Nature bird call sounds before speaking</div>
<div class="col-i">Zero cloud. All data on-device. Zero login.</div>
<div class="col-i" style="color: #ffd28c; font-weight: 600; margin-top: 6px;">Your storms stay private</div>
</div>
</div>
<div class="tech-strip">REACT NATIVE · EXPO · HEALTHKIT · GEMINI AI · ON-DEVICE STORAGE</div>
</div>
<!-- 10. CHALLENGES -->
<div class="slide" id="s9">
<div class="speak" style="font-size: 2rem;">What's <span class="w">hard.</span> What's <span class="a">next.</span></div>
<div class="two-col">
<div class="col warm">
<div class="col-t" style="color: rgba(255,210,140,0.4);">Challenges</div>
<div class="col-i">Every nervous system is different — model must personalize</div>
<div class="col-i">Consumer watches ≠ lab equipment</div>
<div class="col-i">Being a friend without becoming a doctor</div>
<div class="col-i">Making AI feel genuinely human</div>
</div>
<div class="col">
<div class="col-t">What's next</div>
<div class="col-i">Voice input — talk back to your bird</div>
<div class="col-i">Real-time Apple Watch HRV streaming</div>
<div class="col-i">Ocean & forest companions — whales, wolves</div>
<div class="col-i">Therapist dashboard for session review</div>
<div class="col-i">Multilingual — Nepali, Hindi, Spanish</div>
</div>
</div>
</div>
<!-- 11. DEMO -->
<div class="slide" id="s10">
<div class="speak" style="font-size: 3rem;"><span class="a">Demo.</span></div>
<div class="whisper" style="margin-top: 16px;">A storm is building. Watch what happens.</div>
</div>
<!-- 12. CLOSING -->
<div class="slide" id="s11">
<div class="speak" style="font-size: 2.4rem; line-height: 1.4;">
<span class="d">Mental health was never a disease.</span><br>
It's a mind that sees <span class="a">too much,</span><br>
with no one to hold the <span class="w">weight.</span>
</div>
<div class="whisper" style="margin-top: 30px; font-size: 1.3rem; color: rgba(79,195,247,0.5); font-weight: 600;">
Every thought is a string of energy.<br>
Some just need a friend to help them find the light.
</div>
<div style="margin-top: 40px; text-align: center;">
<div style="font-size: 0.7rem; color: rgba(255,255,255,0.12); letter-spacing: 3px; text-transform: uppercase;">Built by</div>
<div style="font-size: 1.3rem; font-weight: 700; color: rgba(255,255,255,0.5); margin-top: 4px;">Bishwanath Bastola</div>
<div style="font-size: 0.7rem; color: rgba(255,255,255,0.15); margin-top: 2px;">LNP — Life Navigation through the Power of Nature</div>
</div>
</div>
<script>
// ── Navigation ──
let cur = 0;
const slides = document.querySelectorAll('.slide');
const total = slides.length;
function go(n) {
if (n < 0 || n >= total) return;
slides[cur].classList.remove('active');
cur = n;
slides[cur].classList.add('active');
document.getElementById('progress').style.width = ((cur+1)/total*100)+'%';
}
document.addEventListener('keydown', e => {
if (e.key==='ArrowRight'||e.key===' ') { e.preventDefault(); go(cur+1); }
if (e.key==='ArrowLeft') go(cur-1);
});
document.addEventListener('click', e => {
e.clientX > window.innerWidth/2 ? go(cur+1) : go(cur-1);
});
go(0);
// ── ENERGY STRING SYSTEM ──
const canvas = document.getElementById('bg');
const ctx = canvas.getContext('2d');
let W, H;
function resize() { W = canvas.width = window.innerWidth; H = canvas.height = window.innerHeight; }
resize();
window.addEventListener('resize', resize);
// Slide states define the energy behavior
const STATES = [
// 0: birth — one clear string, slow, visible
{ count: 4, chaos: 0.3, speed: 0.25, glow: 18, alpha: 0.25, loops: false, color: [200,80,60] },
// 1: connects — strings linking, brighter
{ count: 8, chaos: 0.45, speed: 0.35, glow: 20, alpha: 0.22, loops: false, color: [200,80,62] },
// 2: loops — strings curling back
{ count: 12, chaos: 0.7, speed: 0.5, glow: 22, alpha: 0.20, loops: true, color: [35,75,60] },
// 3: entangled — violent chaos
{ count: 28, chaos: 2.8, speed: 1.3, glow: 28, alpha: 0.22, loops: true, color: [0,85,55] },
// 4: watch sees — chaos with red tint
{ count: 22, chaos: 2.2, speed: 1.1, glow: 25, alpha: 0.20, loops: true, color: [350,80,55] },
// 5: bird arrives — new calming energy enters
{ count: 16, chaos: 1.2, speed: 0.7, glow: 20, alpha: 0.18, loops: true, color: [195,75,62] },
// 6: untangling — smooth, calm
{ count: 8, chaos: 0.3, speed: 0.3, glow: 18, alpha: 0.18, loops: false, color: [150,75,62] },
// 7: prevent — gentle presence
{ count: 6, chaos: 0.25, speed: 0.25, glow: 14, alpha: 0.15, loops: false, color: [200,65,58] },
// 8: tech — minimal but visible
{ count: 5, chaos: 0.2, speed: 0.2, glow: 12, alpha: 0.12, loops: false, color: [200,75,58] },
// 9: challenges — minimal
{ count: 5, chaos: 0.2, speed: 0.2, glow: 12, alpha: 0.12, loops: false, color: [200,75,58] },
// 10: demo — calm
{ count: 4, chaos: 0.15, speed: 0.2, glow: 14, alpha: 0.14, loops: false, color: [200,75,62] },
// 11: close — beautiful resolved string, glowing
{ count: 5, chaos: 0.15, speed: 0.15, glow: 22, alpha: 0.20, loops: false, color: [200,85,68] },
];
// Interpolation helper
function lerp(a, b, t) { return a + (b - a) * t; }
let currentState = { ...STATES[0] };
let targetState = { ...STATES[0] };
class Strand {
constructor(id) {
this.id = id;
this.reset();
}
reset() {
this.nodes = [];
const n = 8 + Math.floor(Math.random() * 10);
let x = Math.random() * W * 0.1 - W * 0.05;
let y = H * 0.15 + Math.random() * H * 0.7;
for (let i = 0; i < n; i++) {
this.nodes.push({
x, y,
baseX: x, baseY: y,
vx: 0, vy: 0,
phase: Math.random() * Math.PI * 2,
freq: 0.3 + Math.random() * 0.7,
amp: 20 + Math.random() * 40,
});
x += (W * 1.1) / n + (Math.random() - 0.5) * 80;
y += (Math.random() - 0.5) * H * 0.25;
y = Math.max(H * 0.08, Math.min(H * 0.92, y));
}
this.width = 1.0 + Math.random() * 2.0;
this.alphaOffset = Math.random() * 0.5;
this.hueOffset = (Math.random() - 0.5) * 30;
this.life = Math.random() * 500;
this.maxLife = 400 + Math.random() * 600;
this.alive = true;
}
update(t, state) {
this.life++;
if (this.life > this.maxLife) {
this.reset();
}
const fadeIn = Math.min(1, this.life / 80);
const fadeOut = Math.min(1, (this.maxLife - this.life) / 80);
this.fade = fadeIn * fadeOut;
for (const node of this.nodes) {
const wobbleX = Math.sin(t * node.freq * state.speed + node.phase) * node.amp * state.chaos * 0.3;
const wobbleY = Math.sin(t * node.freq * state.speed * 0.7 + node.phase + 1.5) * node.amp * state.chaos;
node.x = node.baseX + wobbleX;
node.y = node.baseY + wobbleY;
}
}
draw(ctx, state) {
if (this.fade < 0.01) return;
const nodes = this.nodes;
const alpha = state.alpha * this.fade * (1 - this.alphaOffset * 0.5);
const hue = state.color[0] + this.hueOffset;
const sat = state.color[1];
const lit = state.color[2];
// Main string
ctx.beginPath();
ctx.moveTo(nodes[0].x, nodes[0].y);
for (let i = 1; i < nodes.length; i++) {
const xc = (nodes[i].x + nodes[i-1].x) / 2;
const yc = (nodes[i].y + nodes[i-1].y) / 2;
ctx.quadraticCurveTo(nodes[i-1].x, nodes[i-1].y, xc, yc);
}
ctx.lineTo(nodes[nodes.length-1].x, nodes[nodes.length-1].y);
ctx.strokeStyle = `hsla(${hue},${sat}%,${lit}%,${alpha})`;
ctx.lineWidth = this.width;
ctx.shadowColor = `hsla(${hue},${sat}%,${lit+10}%,${alpha * 0.6})`;
ctx.shadowBlur = state.glow;
ctx.stroke();
ctx.shadowBlur = 0;
// Loops at nodes (when state has loops)
if (state.loops) {
for (let i = 2; i < nodes.length - 2; i += 3) {
const n = nodes[i];
const loopR = 12 + state.chaos * 8;
ctx.beginPath();
ctx.arc(n.x, n.y, loopR, 0, Math.PI * 2);
ctx.strokeStyle = `hsla(${hue},${sat}%,${lit}%,${alpha * 0.3})`;
ctx.lineWidth = this.width * 0.5;
ctx.stroke();
}
}
// Glow nodes at key points
for (let i = 1; i < nodes.length; i += 2) {
const n = nodes[i];
const r = this.width + 0.5 + state.chaos * 0.5;
ctx.beginPath();
ctx.arc(n.x, n.y, r, 0, Math.PI * 2);
ctx.fillStyle = `hsla(${hue},${sat}%,${lit+15}%,${alpha * 1.2})`;
ctx.shadowColor = `hsla(${hue},${sat}%,${lit+15}%,${alpha * 0.8})`;
ctx.shadowBlur = r * 5;
ctx.fill();
ctx.shadowBlur = 0;
}
}
}
// Create strand pool
const MAX_STRANDS = 30;
const strands = [];
for (let i = 0; i < MAX_STRANDS; i++) {
strands.push(new Strand(i));
}
let t = 0;
let transitionProgress = 1;
let prevSlide = 0;
function animate() {
t += 0.016;
ctx.clearRect(0, 0, W, H);
// Smoothly transition state
const tgt = STATES[Math.min(cur, STATES.length - 1)];
if (cur !== prevSlide) {
prevSlide = cur;
transitionProgress = 0;
}
transitionProgress = Math.min(1, transitionProgress + 0.008);
const ease = transitionProgress * transitionProgress * (3 - 2 * transitionProgress); // smoothstep
currentState.chaos = lerp(currentState.chaos, tgt.chaos, ease * 0.05);
currentState.speed = lerp(currentState.speed, tgt.speed, ease * 0.05);
currentState.glow = lerp(currentState.glow, tgt.glow, ease * 0.05);
currentState.alpha = lerp(currentState.alpha, tgt.alpha, ease * 0.05);
currentState.color = [
lerp(currentState.color[0], tgt.color[0], ease * 0.03),
lerp(currentState.color[1], tgt.color[1], ease * 0.03),
lerp(currentState.color[2], tgt.color[2], ease * 0.03),
];
currentState.loops = tgt.loops;
// Background glow
const bgAlpha = 0.01 + currentState.chaos * 0.01;
const grd = ctx.createRadialGradient(W/2, H/2, 0, W/2, H/2, W * 0.7);
grd.addColorStop(0, `hsla(${currentState.color[0]},${currentState.color[1]}%,15%,${bgAlpha})`);
grd.addColorStop(1, 'rgba(2,2,8,0)');
ctx.fillStyle = grd;
ctx.fillRect(0, 0, W, H);
// Only draw up to target count
const activeCount = Math.min(tgt.count, MAX_STRANDS);
for (let i = 0; i < activeCount; i++) {
strands[i].update(t, currentState);
strands[i].draw(ctx, currentState);
}
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>