-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
522 lines (477 loc) · 19.8 KB
/
Copy pathindex.html
File metadata and controls
522 lines (477 loc) · 19.8 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
515
516
517
518
519
520
521
522
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Glow</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600&family=Jost:wght@500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="glass-bg.css">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Fredoka', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
min-height: 100vh;
color: #fff;
overflow: hidden;
}
/* ---- Rotating 3D word ------------------------------------------------ */
.glow-stage {
position: fixed;
inset: 0;
z-index: 1;
display: flex;
align-items: center;
justify-content: center;
perspective: 700px;
pointer-events: none;
}
/* word wrapper — JS drives its transform in DVD-bounce mode */
.glow-word {
display: flex;
gap: 0.03em;
font-family: 'Jost', sans-serif;
font-weight: 500;
text-transform: uppercase;
font-size: clamp(3rem, 16vw, 11rem);
line-height: 1;
white-space: nowrap;
transform-style: preserve-3d;
will-change: transform;
}
.letter {
position: relative;
display: inline-block;
transform-style: preserve-3d;
animation: glow-spin var(--spin, 8s) linear infinite;
animation-delay: var(--d, 0s);
}
.letter:not(:first-child) { margin-left: -0.03em; }
/* invisible glyph that establishes each letter's box size */
.sizer { visibility: hidden; }
/* both faces overlay the sizer; backface-visibility hides whichever face
is turned away as the letter spins. NOTE: the drop-shadow lives here on
the leaf faces, never on .letter — a filter on a preserve-3d element
flattens it and breaks the backface culling. */
.face {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.28));
}
.face--front { color: #fff; }
.face--back {
color: #000;
transform: rotateY(180deg); /* pre-flip so the back reads correctly */
}
@keyframes glow-spin { to { transform: rotateY(360deg); } }
@media (prefers-reduced-motion: reduce) {
.letter { animation: none; }
}
/* control panel */
.panel {
position: fixed;
top: 16px;
right: 16px;
z-index: 10;
width: 290px;
max-height: calc(100vh - 32px);
overflow-y: auto;
padding: 16px 16px 18px;
border-radius: 16px;
background: rgba(20, 20, 26, 0.62);
-webkit-backdrop-filter: blur(24px) saturate(1.4);
backdrop-filter: blur(24px) saturate(1.4);
border: 1px solid rgba(255, 255, 255, 0.16);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
color: #fff;
font-size: 13px;
}
.panel h2 { font-size: 13px; font-weight: 600; letter-spacing: .04em;
text-transform: uppercase; opacity: .7; margin-bottom: 10px; }
.panel__toggle { position:absolute; top:14px; right:14px; cursor:pointer;
background:none; border:none; color:#fff; font-size:16px; opacity:.7; line-height:1; }
/* collapsed: shrink the whole panel to a round floating button */
.panel.collapsed { width:52px; height:52px; min-height:0; padding:0;
border-radius:50%; overflow:hidden; display:flex; align-items:center; justify-content:center; }
.panel.collapsed h2,
.panel.collapsed .panel__body { display:none; }
.panel.collapsed .panel__toggle { position:static; top:auto; right:auto;
width:52px; height:52px; font-size:26px; opacity:.9; }
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; }
.presets button {
font: inherit; font-size: 12px; color: #fff; cursor: pointer;
padding: 8px 6px; border-radius: 9px;
background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18);
transition: background .15s ease;
}
.presets button:hover { background: rgba(255,255,255,.18); }
.presets button.locked { border-color: #fff; background: rgba(255,255,255,.22); }
.presets button.locked:hover { background: rgba(255,255,255,.32); }
.ctrl { margin-bottom: 11px; }
.ctrl label { display: flex; justify-content: space-between; align-items: center;
margin-bottom: 4px; opacity: .85; }
.ctrl label span { font-variant-numeric: tabular-nums; opacity: .65; }
.ctrl input[type=range] { width: 100%; accent-color: #fff; }
.ctrl input[type=color] { width: 100%; height: 28px; border: none; border-radius: 7px;
background: none; cursor: pointer; padding: 0; }
.ctrl input[type=text],
.ctrl select { width: 100%; font: inherit; font-size: 12px; color: #fff;
background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2);
border-radius: 7px; padding: 5px 6px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; margin: 12px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: #fff; }
.btn { width: 100%; margin-top: 8px; font: inherit; font-size: 12px; cursor: pointer;
padding: 9px; border-radius: 9px; color: #fff; background: rgba(255,255,255,.1);
border: 1px solid rgba(255,255,255,.2); font-weight: 500; transition: background .15s ease; }
.btn:hover { background: rgba(255,255,255,.2); }
/* In bounce mode JS drives each orb's transform, so disable the keyframes. */
.glass-bg.bounce .orb { animation: none; }
</style>
</head>
<body>
<div class="glass-bg" data-glass-bg></div>
<main class="glow-stage">
<div class="glow-word" id="glowWord"></div>
</main>
<aside class="panel" id="panel">
<h2>Glow</h2>
<button class="panel__toggle" id="toggle" title="collapse">–</button>
<div class="panel__body">
<div class="presets">
<button data-preset="light" class="locked">☀︎ Light</button>
<button data-preset="dark" class="locked">☾ Dark</button>
</div>
<div class="ctrl">
<label>Text</label>
<input type="text" id="glowText" value="GLOW" autocomplete="off" spellcheck="false">
</div>
<div class="ctrl">
<label>Text rotation <span id="spinV">8.0</span>s</label>
<input type="range" id="spin" min="2" max="20" step="0.5" value="8">
</div>
<label class="check">
<input type="checkbox" id="textBounce">
Bounce text (DVD)
</label>
<div class="row">
<div class="ctrl">
<label>Canvas</label>
<input type="color" id="canvas" value="#ffffff">
</div>
<div class="ctrl">
<label>Frost tint</label>
<input type="color" id="tintColor" value="#ffffff">
</div>
</div>
<div class="ctrl">
<label>Tint opacity <span id="tintOpacityV">0.00</span></label>
<input type="range" id="tintOpacity" min="0" max="1" step="0.01" value="0">
</div>
<div class="ctrl">
<label>Blend mode</label>
<select id="blend">
<option value="multiply">multiply (light)</option>
<option value="screen">screen</option>
<option value="lighten">lighten</option>
<option value="overlay">overlay</option>
<option value="hard-light">hard-light (dark)</option>
<option value="soft-light">soft-light</option>
<option value="normal">normal</option>
</select>
</div>
<div class="ctrl">
<label>Orb opacity <span id="orbOpacityV">1.00</span></label>
<input type="range" id="orbOpacity" min="0" max="1" step="0.01" value="1">
</div>
<div class="ctrl">
<label>Orb edge blur <span id="orbBlurV">0</span>px</label>
<input type="range" id="orbBlur" min="0" max="80" step="1" value="0">
</div>
<div class="ctrl">
<label>Orb size <span id="orbScaleV">0.75</span>×</label>
<input type="range" id="orbScale" min="0.5" max="1.8" step="0.05" value="0.75">
</div>
<div class="ctrl">
<label>Frost blur <span id="frostBlurV">100</span>px</label>
<input type="range" id="frostBlur" min="0" max="160" step="1" value="100">
</div>
<div class="ctrl">
<label>Frost saturate <span id="frostSatV">1.50</span></label>
<input type="range" id="frostSat" min="0" max="3" step="0.05" value="1.5">
</div>
<div class="ctrl">
<label>Motion <span id="speedV">0.30</span>× <span style="opacity:.5">(lower = faster)</span></label>
<input type="range" id="speed" min="0.1" max="5" step="0.1" value="0.3">
</div>
<label class="check">
<input type="checkbox" id="bounce">
Bounce orbs (Pong)
</label>
<label class="check">
<input type="checkbox" id="refraction">
Experimental refraction
</label>
<button class="btn" id="fullscreen">Enter fullscreen</button>
</div>
</aside>
<script src="glass-bg.js"></script>
<script>
var bg = document.querySelector('.glass-bg');
var $ = function (id) { return document.getElementById(id); };
function hexToRgb(hex) {
var n = parseInt(hex.slice(1), 16);
return [(n >> 16) & 255, (n >> 8) & 255, n & 255];
}
function tintRgba() {
var c = hexToRgb($('tintColor').value);
return 'rgba(' + c[0] + ',' + c[1] + ',' + c[2] + ',' + $('tintOpacity').value + ')';
}
function apply() {
bg.style.setProperty('--canvas', $('canvas').value);
bg.style.setProperty('--tint', tintRgba());
bg.style.setProperty('--blend', $('blend').value);
bg.style.setProperty('--orb-opacity', $('orbOpacity').value);
bg.style.setProperty('--orb-blur', $('orbBlur').value + 'px');
bg.style.setProperty('--orb-scale', $('orbScale').value);
bg.style.setProperty('--frost-blur', $('frostBlur').value + 'px');
bg.style.setProperty('--frost-saturate', $('frostSat').value);
bg.style.setProperty('--speed', $('speed').value);
bg.classList.toggle('refraction', $('refraction').checked);
$('glowWord').style.setProperty('--spin', $('spin').value + 's');
// numeric read-outs
$('tintOpacityV').textContent = (+$('tintOpacity').value).toFixed(2);
$('orbOpacityV').textContent = (+$('orbOpacity').value).toFixed(2);
$('orbBlurV').textContent = $('orbBlur').value;
$('orbScaleV').textContent = (+$('orbScale').value).toFixed(2);
$('frostBlurV').textContent = $('frostBlur').value;
$('frostSatV').textContent = (+$('frostSat').value).toFixed(2);
$('speedV').textContent = (+$('speed').value).toFixed(2);
$('spinV').textContent = (+$('spin').value).toFixed(1);
}
/* ---- Rotating word --------------------------------------------------
Build each visible character as a flip-card: a white front face and a
black back face (pre-flipped so it reads correctly when it faces us).
A small per-letter delay makes the word ripple instead of spinning in
lockstep. */
function renderGlow() {
var text = $('glowText').value || ' ';
var word = $('glowWord');
word.textContent = '';
var visible = 0;
for (var i = 0; i < text.length; i++) {
var ch = text[i];
var letter = document.createElement('span');
letter.className = 'letter';
if (ch === ' ') {
letter.style.animation = 'none';
letter.innerHTML = '<span class="sizer"> </span>';
} else {
letter.style.setProperty('--d', (visible * 0.15) + 's');
var sizer = document.createElement('span');
sizer.className = 'sizer';
sizer.textContent = ch;
var front = document.createElement('span');
front.className = 'face face--front';
front.textContent = ch;
var back = document.createElement('span');
back.className = 'face face--back';
back.textContent = ch;
letter.appendChild(sizer);
letter.appendChild(front);
letter.appendChild(back);
visible++;
}
word.appendChild(letter);
}
}
var PRESETS = {
light: { canvas:'#ffffff', tintColor:'#ffffff', tintOpacity:0, blend:'multiply',
orbOpacity:1, orbBlur:0, orbScale:0.75, frostBlur:100, frostSat:1.5, speed:0.3, refraction:false },
dark: { canvas:'#000000', tintColor:'#000000', tintOpacity:0.25, blend:'hard-light',
orbOpacity:1, orbBlur:0, orbScale:0.75, frostBlur:100, frostSat:1.5, speed:0.3, refraction:false }
};
function loadPreset(name) {
var p = PRESETS[name];
$('canvas').value = p.canvas;
$('tintColor').value = p.tintColor;
$('tintOpacity').value = p.tintOpacity;
$('blend').value = p.blend;
$('orbOpacity').value = p.orbOpacity;
$('orbBlur').value = p.orbBlur;
$('orbScale').value = p.orbScale;
$('frostBlur').value = p.frostBlur;
$('frostSat').value = p.frostSat;
$('speed').value = p.speed;
$('refraction').checked = p.refraction;
apply();
}
// wire everything
['canvas','tintColor','tintOpacity','blend','orbOpacity','orbBlur','orbScale',
'frostBlur','frostSat','speed','spin','refraction'].forEach(function (id) {
$(id).addEventListener('input', apply);
});
$('glowText').addEventListener('input', function () {
renderGlow();
if ($('textBounce').checked) textBounce.remeasure();
});
document.querySelectorAll('.presets button').forEach(function (b) {
b.addEventListener('click', function () { loadPreset(b.dataset.preset); });
});
/* ---- Bounce (Pong) motion for the orbs ------------------------------
JS physics: each orb gets a random launch direction + speed jitter,
drifts in a straight line and bounces off the viewport edges. Collision
is tested against the orb's CENTRE, so large orbs sail partway off-screen
before turning. */
var bounce = (function () {
var raf = null, last = 0, orbs = [], active = false;
function measureBase() {
orbs.forEach(function (o) {
o.bx = o.el.offsetLeft + o.el.offsetWidth / 2;
o.by = o.el.offsetTop + o.el.offsetHeight / 2;
});
}
function setup() {
orbs = [];
document.querySelectorAll('.glass-bg .orb').forEach(function (el) {
var ang = Math.random() * Math.PI * 2;
orbs.push({ el: el, bx: 0, by: 0, tx: 0, ty: 0,
dx: Math.cos(ang), dy: Math.sin(ang),
sp: 0.7 + Math.random() * 0.6 });
});
measureBase();
}
function frame(t) {
if (!active) return;
if (!last) last = t;
var dt = Math.min((t - last) / 1000, 0.05);
last = t;
var vw = window.innerWidth, vh = window.innerHeight;
var mag = 90 / (parseFloat($('speed').value) || 1);
var scale = $('orbScale').value;
orbs.forEach(function (o) {
o.tx += o.dx * mag * o.sp * dt;
o.ty += o.dy * mag * o.sp * dt;
var cx = o.bx + o.tx, cy = o.by + o.ty;
if (cx < 0 && o.dx < 0) o.dx = Math.abs(o.dx);
else if (cx > vw && o.dx > 0) o.dx = -Math.abs(o.dx);
if (cy < 0 && o.dy < 0) o.dy = Math.abs(o.dy);
else if (cy > vh && o.dy > 0) o.dy = -Math.abs(o.dy);
o.el.style.transform = 'translate(' + o.tx + 'px,' + o.ty + 'px) scale(' + scale + ')';
});
raf = requestAnimationFrame(frame);
}
return {
start: function () {
active = true; last = 0;
document.querySelector('.glass-bg').classList.add('bounce');
setup();
window.addEventListener('resize', measureBase);
raf = requestAnimationFrame(frame);
},
stop: function () {
active = false;
if (raf) cancelAnimationFrame(raf);
window.removeEventListener('resize', measureBase);
document.querySelector('.glass-bg').classList.remove('bounce');
orbs.forEach(function (o) { o.el.style.transform = ''; });
}
};
})();
/* ---- DVD-logo bounce for the GLOW word ------------------------------
Drives the .glow-word wrapper around the viewport, reflecting off the
edges. The letters keep their CSS rotateY spin (translation is on the
wrapper, rotation on the children — they compose). */
var textBounce = (function () {
var raf = null, last = 0, active = false;
var el = $('glowWord'), stage = document.querySelector('.glow-stage');
var x = 0, y = 0, dx = 1, dy = 1, w = 0, h = 0;
function remeasure() {
if (!active) return;
var r = el.getBoundingClientRect();
w = r.width; h = r.height;
x = Math.min(x, Math.max(0, window.innerWidth - w));
y = Math.min(y, Math.max(0, window.innerHeight - h));
}
function frame(t) {
if (!active) return;
if (!last) last = t;
var dt = Math.min((t - last) / 1000, 0.05);
last = t;
var sp = 160; // px/sec
x += dx * sp * dt;
y += dy * sp * dt;
var maxX = window.innerWidth - w, maxY = window.innerHeight - h;
if (x < 0) { x = 0; dx = Math.abs(dx); }
else if (x > maxX) { x = maxX; dx = -Math.abs(dx); }
if (y < 0) { y = 0; dy = Math.abs(dy); }
else if (y > maxY) { y = maxY; dy = -Math.abs(dy); }
el.style.transform = 'translate(' + x + 'px,' + y + 'px)';
raf = requestAnimationFrame(frame);
}
return {
remeasure: remeasure,
start: function () {
active = true; last = 0;
// pin the word to the top-left so we can translate it freely
stage.style.display = 'block';
el.style.position = 'absolute';
el.style.top = '0';
el.style.left = '0';
var r = el.getBoundingClientRect();
w = r.width; h = r.height;
// start from roughly the current centred spot
x = Math.max(0, (window.innerWidth - w) / 2);
y = Math.max(0, (window.innerHeight - h) / 2);
var ang = (Math.random() * 0.8 + 0.3) * Math.PI / 2; // avoid pure axes
dx = Math.cos(ang) < 0 ? -1 : 1;
dy = Math.sin(ang) < 0 ? -1 : 1;
window.addEventListener('resize', remeasure);
raf = requestAnimationFrame(frame);
},
stop: function () {
active = false;
if (raf) cancelAnimationFrame(raf);
window.removeEventListener('resize', remeasure);
stage.style.display = '';
el.style.position = '';
el.style.top = '';
el.style.left = '';
el.style.transform = '';
}
};
})();
$('bounce').addEventListener('input', function () {
if ($('bounce').checked) bounce.start(); else bounce.stop();
});
$('textBounce').addEventListener('input', function () {
if ($('textBounce').checked) textBounce.start(); else textBounce.stop();
});
$('toggle').addEventListener('click', function () {
var collapsed = $('panel').classList.toggle('collapsed');
$('toggle').textContent = collapsed ? '+' : '–';
$('toggle').title = collapsed ? 'expand' : 'collapse';
});
// Fullscreen
$('fullscreen').addEventListener('click', function () {
if (document.fullscreenElement) {
document.exitFullscreen();
} else {
document.documentElement.requestFullscreen();
}
});
document.addEventListener('fullscreenchange', function () {
$('fullscreen').textContent = document.fullscreenElement ? 'Exit fullscreen' : 'Enter fullscreen';
});
// boot
renderGlow();
loadPreset('light');
</script>
</body>
</html>