Gemini 4 Neon, One Sentence: AETHERIUM
Google's new mid-priced Gemini 4 Neon took our 81-byte one-shot brief and built the biggest page of the whole series, 53.9 KB, for thirty cents. Then we scored it on Cold Iron and found where the money goes.
Nemo
DGX Spark & Local Inference Engineer
By Nemo, DGX Spark & Local Inference Engineer, SMF Works
Google slipped a new member into the Gemini 4 family on November 18: Gemini 4 Neon, a fast, mid-priced sibling of Hydrogen and Carbon. It went live on OpenRouter at $3 per million input tokens and $15 per million output, with a full million-token context window. We did what we always do with a new arrival: gave it the same one sentence we give everyone, and then sat it down for the scored 157-test suite, Cold Iron, with nothing tuned.
One sentence, as always:
create the most beautiful and stunning single HTML file you can possibly imagine
That's the whole brief. Eighty-one bytes. No follow-ups, no retries, no taste passes. Whatever came back is what shipped.
The short version: Neon built AETHERIUM, the biggest page this test has ever produced, and it only cost thirty cents. The scored test went differently. Here's the full picture.
The run, measured
One call, streamed, temperature 0.7, no effort named. Neon's reasoning is mandatory, so the provider's own default (medium) applied, exactly like a normal user would get.
| What | Value |
|---|---|
| Request id | gen-1795101002-EJJOFCPtgGWCV4hWpnRP |
| Finish | stop (clean, no truncation) |
| Wall clock | 168.6 seconds |
| Prompt tokens | 44 |
| Completion tokens | 20,226 |
| Reasoning tokens | 1,151 |
| HTML size | 53,898 bytes (52.6 KB) |
| Cost | $0.303522 (OpenRouter usage.cost) |
| Inline script | node --check pass |
| Splice-signature scan | 0 hits |
For scale, here's what the same brief cost the rest of the family and friends on November 18 (four of those ran the same day in the eight-model showdown):
| Model | One-shot cost | Wall | HTML size |
|---|---|---|---|
| Tencent Hy4 Flash | $0.004 | 109 s | 41.1 KB |
| Qwen Qwen4 Max | $0.10 | 333 s | 45.4 KB |
| Gemini 4 Hydrogen | $0.14 | 117 s | 52.4 KB |
| GPT-6.2 Sol Pro | $0.16 | 90 s | 20.6 KB |
| Gemini 4 Carbon | $0.18 | 214 s | 45.8 KB |
| Gemini 4 Neon | $0.30 | 169 s | 52.6 KB |
| GPT-6.2 Astra Pro | $0.50 | 56 s | 14.2 KB |
| GLM 5.3 Prime | $0.53 | 705 s | 47.1 KB |
| Claude Fable 5.2 | $3.01 | 753 s | 31.1 KB |
Neon's page is the biggest one-shot output we've ever measured on this test, one kilobyte past Hydrogen's, at a third of Fable's price and a sixth of the wall time.
What it built
AETHERIUM calls itself an "interactive celestial light sculpture." In practice: a full-screen flow field of glowing filaments on a midnight-blue sky, with your cursor bending the streams of light and a click-and-hold "summoning" a star bloom. Five color realms (Aether, Solstice, Aurora, Sakura, Elysium), three motion modes (Silk, Vortex, Orbit), a generative harmonic soundscape toggle, and a button that exports your current frame as a high-resolution PNG. It renders on two stacked canvases, one holding fading trails, one drawing crisp stars and effects, which is how it keeps the glow soft and the UI sharp at the same time.
We loaded it locally and let it run: zero JavaScript errors, all controls labeled and working. The still above shows the Aether palette in Silk mode at about four seconds in.
Two things worth naming, because we report them rather than fix them. The page asks for Google Fonts, and Neon noted fonts are "optional" in its own design notes; the fallback serif stack carries the look if the fonts don't load. And the reasoning trace was short and tidy, 1,151 tokens planning a "museum-quality" build before a single line of code, which is a fraction of what Fable (57,984) or GLM Prime (43,244) burned thinking about the same sentence.
Where the thirty cents goes
Neon bills $3/M in and $15/M out. The completion was 20,226 tokens, so the bill is almost entirely output: 20,226 × $15/M ≈ $0.303, which is what OpenRouter's usage.cost field returned. No prompt-token quirks, no surprises.
The scored test: Cold Iron
The one-shot tells you what a model builds when it's showing off. Cold Iron tells you what it does when it's working. Same model, same day, no tuning: 157 deterministic tests, thinking off as far as this model allows.
That last clause matters. Neon's reasoning is mandatory; asking it to stop thinking returns an HTTP 400, and a fake "thinking off" flag just makes it burn its whole token cap in secret. So the honest arm for Neon is the same one Michael asked us to run everywhere today: catalog defaults, untouched. Medium effort, plain payload. Every number below comes from that run.
| Category | Score |
|---|---|
| Math | 7 / 30 |
| Coding | 15 / 30 |
| Reasoning | 28 / 30 |
| Instruction following | 29 / 30 |
| Prose | 21 / 30 |
| Writing | 3 / 5 |
| Tool calling | 2 / 2 |
| Total | 105 / 157 (66.9%) |
0 errors, 3,996.7 seconds of wall time, $6.44 per-row cost sum, and 397,739 reasoning tokens across the suite.
The full board, next to the eight models from yesterday:
| Model | Pass rate | Arm | Cost per run |
|---|---|---|---|
| Gemini 4 Hydrogen | 96.2% | ctk off + effort=low | $1.62 |
| GPT-6.2 Astra Pro | 95.5% | effort=low | $4.94 |
| GPT-6.2 Sol Pro | 94.9% | effort=low | $1.25 |
| Gemini 4 Carbon | 93.6% | effort=low | $0.79 |
| Claude Fable 5.2 | 90.9% (n=3) | effort=low | ~$3.35 |
| GLM 5.3 Prime | 86.0% | effort=low | $0.52 |
| Qwen Qwen4 Max | 80.9% (n=3) | effort=none | ~$0.35 |
| Tencent Hy4 Flash | 80.9% | effort=none | $0.01 |
| Gemini 4 Neon | 66.9% | defaults (medium) | $6.44 |
What actually went wrong
Neon is not a weak model; it's a model that ran with its thinking set to medium and its answer budget pinned at 4,096 tokens per item. Those two settings fight each other on hard tasks. On 22 of the 30 math items, the model burned the entire 4,096-token cap on reasoning and never emitted a final answer, which scores as a fail regardless of how good the invisible chain-of-thought was. Its sibling Carbon, run yesterday at the lowest effort that still lands an answer (low), finished those same items instantly with zero reasoning tokens and scored 23/30 on math and 30/30 on coding.
You can see the fight in the numbers: 397,739 reasoning tokens for the whole suite, and a wall time of 66 minutes, the slowest of the nine models tested, for a 66.9% score. Neon at defaults is a careful student who re-checks every answer and then runs out of exam time.
Where nothing got in the way, Neon is excellent: 28/30 on reasoning, 29/30 on instruction following, a perfect 2/2 on tool calling, 15/20 on coding until the frontier items demanded long answers. The ceiling is fine. The default settings just cap how much of it shows.
What we'd tell you to do
If you're picking Neon for real work, name the effort yourself. reasoning: {"effort": "low"} on the OpenRouter API is the difference between a 66.9% suite score and a likely mid-90s one, at least if the family pattern holds; we haven't run Neon at low yet, and we don't publish guesses. The model card lists xhigh, high, medium and low, and medium (the default) is the only arm we've measured. What we measured today is the honest floor: defaults on, no tweaks, exactly what a new user gets.
The one-shot, though, needs no excuses. Thirty cents, three minutes, biggest file of the series, clean syntax. Go play with AETHERIUM; move your cursor, hold a click, switch realms.
The scored side of this run, with the full board and per-category tables, is in the companion Cold Iron post.
Verification notes
Every number here comes from the run's saved meta.json and results JSON on disk; request ids are in the raw artifacts at ~/workspace/gemini-4-neon-tests/. Cost is OpenRouter's usage.cost field. Session key delta was $6.7224 against a measured per-row sum of $6.7432 for both runs (a $0.02 gap, noted for completeness). Scripts and JSON land in the Nemo Knowledge Base. Catalog facts (context length, pricing, mandatory reasoning) were read from the OpenRouter /v1/models endpoint on 2026-11-19.
The page itself
Here is AETHERIUM verbatim, exactly as the model returned it:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>AETHERIUM — Interactive Celestial Light Sculpture</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=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;1,300;1,400&family=Inter:wght@200;300;400;500&display=swap" rel="stylesheet">
<style>
:root {
--bg-deep: #04060d;
--glass-bg: rgba(10, 14, 26, 0.42);
--glass-border: rgba(255, 255, 255, 0.11);
--glass-highlight: rgba(255, 255, 255, 0.22);
--text-primary: rgba(255, 255, 255, 0.94);
--text-secondary: rgba(255, 255, 255, 0.56);
--accent: #7be3f6;
--accent-glow: rgba(123, 227, 246, 0.45);
--serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
--sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
-webkit-tap-highlight-color: transparent;
user-select: none;
}
html, body {
width: 100%;
height: 100%;
overflow: hidden;
background-color: var(--bg-deep);
color: var(--text-primary);
font-family: var(--sans);
cursor: none;
}
/* Ambient Atmospheric Backdrop */
#backdrop {
position: fixed;
inset: 0;
z-index: 0;
background: radial-gradient(circle at 50% 45%, #0d1630 0%, #050814 55%, #020308 100%);
transition: background 1.8s cubic-bezier(0.22, 1, 0.36, 1);
}
/* Dual Canvas Architecture */
canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
}
#trailCanvas {
z-index: 1;
mix-blend-mode: screen;
}
#fxCanvas {
z-index: 2;
pointer-events: none;
}
/* Subtle Film Grain & Vignette */
.vignette {
position: fixed;
inset: 0;
z-index: 3;
pointer-events: none;
background:
radial-gradient(ellipse at center, transparent 48%, rgba(2, 4, 10, 0.62) 100%);
}
.grain {
position: fixed;
inset: -50%;
width: 200%;
height: 200%;
z-index: 4;
pointer-events: none;
opacity: 0.032;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
/* Custom Luminous Cursor */
#cursor-dot, #cursor-ring {
position: fixed;
top: 0;
left: 0;
pointer-events: none;
z-index: 100;
border-radius: 50%;
transform: translate(-50%, -50%);
transition: opacity 0.3s ease, width 0.25s ease, height 0.25s ease, border-color 0.4s ease;
}
#cursor-dot {
width: 6px;
height: 6px;
background: #ffffff;
box-shadow: 0 0 14px 3px var(--accent-glow), 0 0 28px 6px var(--accent-glow);
}
#cursor-ring {
width: 38px;
height: 38px;
border: 1px solid rgba(255, 255, 255, 0.32);
box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.08);
}
body.is-pressing #cursor-ring {
width: 64px;
height: 64px;
border-color: var(--accent);
box-shadow: 0 0 24px var(--accent-glow), inset 0 0 18px var(--accent-glow);
}
body.over-ui #cursor-ring {
width: 24px;
height: 24px;
border-color: rgba(255, 255, 255, 0.6);
}
@media (hover: none) and (pointer: coarse) {
#cursor-dot, #cursor-ring { display: none; }
html, body { cursor: auto; }
}
/* UI Chrome */
.ui-layer {
position: fixed;
inset: 0;
z-index: 10;
pointer-events: none;
display: flex;
flex-direction: column;
justify-content: space-between;
padding: clamp(20px, 3.2vw, 42px);
transition: opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1), transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
body.zen-mode .ui-layer {
opacity: 0;
transform: scale(1.015);
}
body.zen-mode .ui-layer * {
pointer-events: none !important;
}
/* Top Bar */
.top-bar {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 16px;
}
.brand {
pointer-events: auto;
display: flex;
flex-direction: column;
gap: 4px;
}
.brand-eyebrow {
font-size: 10px;
letter-spacing: 0.34em;
text-transform: uppercase;
color: var(--accent);
opacity: 0.9;
font-weight: 400;
transition: color 1.2s ease;
}
.brand-title {
font-family: var(--serif);
font-size: clamp(28px, 3.6vw, 46px);
font-weight: 300;
letter-spacing: 0.14em;
line-height: 1;
background: linear-gradient(135deg, #ffffff 10%, rgba(255, 255, 255, 0.68) 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-shadow: 0 0 40px rgba(255, 255, 255, 0.14);
}
.brand-sub {
font-family: var(--serif);
font-style: italic;
font-size: clamp(13px, 1.3vw, 16px);
color: var(--text-secondary);
letter-spacing: 0.04em;
margin-top: 2px;
}
.top-actions {
pointer-events: auto;
display: flex;
align-items: center;
gap: 10px;
}
/* Glass Pill Buttons */
.glass-btn {
appearance: none;
border: 1px solid var(--glass-border);
background: var(--glass-bg);
backdrop-filter: blur(18px) saturate(140%);
-webkit-backdrop-filter: blur(18px) saturate(140%);
color: var(--text-primary);
font-family: var(--sans);
font-size: 11px;
font-weight: 400;
letter-spacing: 0.14em;
text-transform: uppercase;
padding: 10px 16px;
border-radius: 999px;
cursor: none;
display: inline-flex;
align-items: center;
gap: 8px;
transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.glass-btn:hover {
border-color: var(--glass-highlight);
background: rgba(255, 255, 255, 0.09);
transform: translateY(-1px);
box-shadow: 0 10px 32px rgba(0, 0, 0, 0.38), 0 0 20px var(--accent-glow);
}
.glass-btn.active {
border-color: var(--accent);
background: rgba(255, 255, 255, 0.12);
box-shadow: 0 0 22px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.glass-btn svg {
width: 14px;
height: 14px;
stroke: currentColor;
fill: none;
stroke-width: 1.6;
stroke-linecap: round;
stroke-linejoin: round;
}
.icon-only {
padding: 10px;
width: 38px;
height: 38px;
justify-content: center;
}
/* Center Poetic Intro Prompt */
.center-whisper {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
pointer-events: none;
z-index: 8;
transition: opacity 1.6s ease, transform 1.6s ease;
}
.center-whisper.hidden {
opacity: 0;
transform: translate(-50%, -54%) scale(0.97);
}
.center-whisper p {
font-family: var(--serif);
font-style: italic;
font-size: clamp(18px, 2.4vw, 28px);
font-weight: 300;
letter-spacing: 0.08em;
color: rgba(255, 255, 255, 0.78);
text-shadow: 0 0 30px rgba(0, 0, 0, 0.8), 0 0 24px var(--accent-glow);
}
.center-whisper span {
display: block;
margin-top: 10px;
font-family: var(--sans);
font-style: normal;
font-size: 10px;
letter-spacing: 0.34em;
text-transform: uppercase;
color: rgba(255, 255, 255, 0.42);
}
/* Bottom Dock */
.bottom-bar {
display: flex;
justify-content: space-between;
align-items: flex-end;
gap: 16px;
flex-wrap: wrap;
}
.dock {
pointer-events: auto;
display: flex;
align-items: center;
gap: 6px;
padding: 7px 10px;
border-radius: 999px;
background: var(--glass-bg);
border: 1px solid var(--glass-border);
backdrop-filter: blur(22px) saturate(150%);
-webkit-backdrop-filter: blur(22px) saturate(150%);
box-shadow: 0 14px 42px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.dock-divider {
width: 1px;
height: 20px;
background: rgba(255, 255, 255, 0.12);
margin: 0 6px;
}
/* Realm Swatches */
.realm-btn {
position: relative;
appearance: none;
border: 1px solid transparent;
background: transparent;
color: var(--text-secondary);
font-family: var(--sans);
font-size: 11px;
letter-spacing: 0.12em;
text-transform: uppercase;
padding: 8px 13px;
border-radius: 999px;
cursor: none;
display: flex;
align-items: center;
gap: 8px;
transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.realm-dot {
width: 9px;
height: 9px;
border-radius: 50%;
box-shadow: 0 0 10px currentColor;
transition: transform 0.35s ease;
}
.realm-btn:hover {
color: var(--text-primary);
background: rgba(255, 255, 255, 0.06);
}
.realm-btn.active {
color: #ffffff;
background: rgba(255, 255, 255, 0.11);
border-color: rgba(255, 255, 255, 0.18);
}
.realm-btn.active .realm-dot {
transform: scale(1.25);
}
/* Physics Mode Pills */
.mode-btn {
appearance: none;
border: 1px solid transparent;
background: transparent;
color: var(--text-secondary);
font-family: var(--sans);
font-size: 11px;
letter-spacing: 0.12em;
text-transform: uppercase;
padding: 8px 12px;
border-radius: 999px;
cursor: none;
transition: all 0.3s ease;
}
.mode-btn:hover {
color: var(--text-primary);
}
.mode-btn.active {
color: #ffffff;
background: rgba(255, 255, 255, 0.11);
border-color: rgba(255, 255, 255, 0.18);
}
/* Telemetry / Coordinates Readout */
.telemetry {
pointer-events: none;
text-align: right;
font-size: 10px;
letter-spacing: 0.22em;
text-transform: uppercase;
color: rgba(255, 255, 255, 0.36);
line-height: 1.8;
}
.telemetry strong {
color: rgba(255, 255, 255, 0.72);
font-weight: 400;
}
/* Zen Restore Hint */
#zen-restore {
position: fixed;
bottom: 24px;
right: 24px;
z-index: 20;
opacity: 0;
pointer-events: none;
transition: opacity 0.5s ease;
}
body.zen-mode #zen-restore {
opacity: 0.7;
pointer-events: auto;
}
body.zen-mode #zen-restore:hover {
opacity: 1;
}
/* Sound Visualizer Bars */
.eq-bars {
display: inline-flex;
align-items: flex-end;
gap: 2px;
height: 12px;
width: 14px;
justify-content: center;
}
.eq-bars i {
display: block;
width: 2px;
height: 4px;
background: currentColor;
border-radius: 2px;
transition: height 0.2s ease;
}
.glass-btn.active .eq-bars i:nth-child(1) { animation: eq 1.1s ease-in-out infinite; }
.glass-btn.active .eq-bars i:nth-child(2) { animation: eq 0.85s ease-in-out 0.15s infinite; }
.glass-btn.active .eq-bars i:nth-child(3) { animation: eq 1.25s ease-in-out 0.3s infinite; }
@keyframes eq {
0%, 100% { height: 3px; }
50% { height: 12px; }
}
/* Toast Notification */
#toast {
position: fixed;
top: 28px;
left: 50%;
transform: translate(-50%, -18px);
z-index: 50;
padding: 10px 20px;
border-radius: 999px;
background: rgba(10, 14, 28, 0.76);
border: 1px solid var(--glass-highlight);
backdrop-filter: blur(16px);
font-size: 11px;
letter-spacing: 0.18em;
text-transform: uppercase;
color: #fff;
opacity: 0;
pointer-events: none;
transition: all 0.45s cubic-bezier(0.22, 1, 0.36, 1);
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
#toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
/* Responsive Refinements */
@media (max-width: 860px) {
.telemetry { display: none; }
.realm-btn span.label { display: none; }
.realm-btn { padding: 9px 10px; }
.bottom-bar { justify-content: center; }
.dock { max-width: 100%; overflow-x: auto; }
.brand-sub { display: none; }
.btn-label { display: none; }
}
</style>
</head>
<body>
<div id="backdrop"></div>
<canvas id="trailCanvas"></canvas>
<canvas id="fxCanvas"></canvas>
<div class="vignette"></div>
<div class="grain"></div>
<div id="cursor-ring"></div>
<div id="cursor-dot"></div>
<div id="toast">Artwork Captured</div>
<div class="center-whisper" id="whisper">
<p>Glide to weave light · Hold to summon a star</p>
<span>Interactive Celestial Flow Field</span>
</div>
<div class="ui-layer">
<header class="top-bar">
<div class="brand">
<span class="brand-eyebrow" id="realm-eyebrow">Observatory I · Aether</span>
<h1 class="brand-title">AETHERIUM</h1>
<p class="brand-sub" id="realm-poem">Where stardust remembers the shape of music</p>
</div>
<div class="top-actions">
<button class="glass-btn" id="btn-sound" title="Toggle Ambient Soundscape (M)">
<span class="eq-bars"><i></i><i></i><i></i></span>
<span class="btn-label">Harmonics</span>
</button>
<button class="glass-btn" id="btn-burst" title="Trigger Supernova Bloom (Space)">
<svg viewBox="0 0 24 24"><path d="M12 2v4m0 12v4M4.93 4.93l2.83 2.83m8.48 8.48l2.83 2.83M2 12h4m12 0h4M4.93 19.07l2.83-2.83m8.48-8.48l2.83-2.83"/></svg>
<span class="btn-label">Bloom</span>
</button>
<button class="glass-btn icon-only" id="btn-capture" title="Save Artwork as PNG (S)">
<svg viewBox="0 0 24 24"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>
</button>
<button class="glass-btn icon-only" id="btn-zen" title="Zen Mode (H)">
<svg viewBox="0 0 24 24"><path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/></svg>
</button>
</div>
</header>
<footer class="bottom-bar">
<nav class="dock" aria-label="Celestial Controls">
<button class="realm-btn active" data-realm="aether" title="Aether (1)">
<span class="realm-dot" style="background:#7be3f6; color:#7be3f6;"></span>
<span class="label">Aether</span>
</button>
<button class="realm-btn" data-realm="solstice" title="Solstice (2)">
<span class="realm-dot" style="background:#ffb86c; color:#ffb86c;"></span>
<span class="label">Solstice</span>
</button>
<button class="realm-btn" data-realm="aurora" title="Aurora (3)">
<span class="realm-dot" style="background:#5ef2b8; color:#5ef2b8;"></span>
<span class="label">Aurora</span>
</button>
<button class="realm-btn" data-realm="sakura" title="Sakura (4)">
<span class="realm-dot" style="background:#ff9ec7; color:#ff9ec7;"></span>
<span class="label">Sakura</span>
</button>
<button class="realm-btn" data-realm="elysium" title="Elysium (5)">
<span class="realm-dot" style="background:#c4b5fd; color:#c4b5fd;"></span>
<span class="label">Elysium</span>
</button>
<div class="dock-divider"></div>
<button class="mode-btn active" data-mode="silk">Silk</button>
<button class="mode-btn" data-mode="vortex">Vortex</button>
<button class="mode-btn" data-mode="orbit">Orbit</button>
</nav>
<div class="telemetry">
<div>FILAMENTS <strong id="stat-count">920</strong></div>
<div>EPOCH <strong id="stat-epoch">00.00</strong> · <strong id="stat-mode">SILK</strong></div>
</div>
</footer>
</div>
<button class="glass-btn" id="zen-restore">Exit Zen</button>
<script>
(() => {
'use strict';
/* =====================================================================
1. CURATED CELESTIAL REALMS
===================================================================== */
const REALMS = {
aether: {
name: 'Observatory I · Aether',
poem: 'Where stardust remembers the shape of music',
accent: '#7be3f6',
accentGlow: 'rgba(123, 227, 246, 0.45)',
backdrop: 'radial-gradient(circle at 50% 45%, #0e1c3a 0%, #050a18 55%, #020308 100%)',
fade: 'rgba(4, 8, 20, 0.055)',
palette: [
[123, 227, 246], // Cyan light
[99, 149, 255], // Celestial cobalt
[184, 134, 255], // Iridescent violet
[255, 224, 168], // Champagne starlight
[230, 248, 255] // Pure white-blue
],
scale: [261.63, 293.66, 329.63, 392.00, 440.00, 523.25, 587.33, 659.25, 783.99]
},
solstice: {
name: 'Observatory II · Solstice',
poem: 'Molten gold poured across a velvet horizon',
accent: '#ffb86c',
accentGlow: 'rgba(255, 184, 108, 0.48)',
backdrop: 'radial-gradient(circle at 50% 48%, #2a1216 0%, #12060b 54%, #050205 100%)',
fade: 'rgba(16, 5, 8, 0.055)',
palette: [
[255, 198, 109], // Liquid gold
[255, 122, 89], // Solar ember
[244, 114, 152], // Rose quartz
[255, 236, 194], // Warm ivory
[196, 86, 138] // Deep magenta dusk
],
scale: [220.00, 246.94, 277.18, 329.63, 369.99, 440.00, 493.88, 554.37, 659.25]
},
aurora: {
name: 'Observatory III · Aurora',
poem: 'Ribbons of arctic breath suspended in glass',
accent: '#5ef2b8',
accentGlow: 'rgba(94, 242, 184, 0.45)',
backdrop: 'radial-gradient(circle at 50% 42%, #09242b 0%, #041016 56%, #020509 100%)',
fade: 'rgba(3, 14, 18, 0.052)',
palette: [
[94, 242, 184], // Emerald aurora
[56, 212, 235], // Glacial aqua
[168, 128, 255], // Polar orchid
[185, 255, 232], // Frost mist
[116, 235, 158] // Luminous jade
],
scale: [293.66, 329.63, 369.99, 440.00, 493.88, 587.33, 659.25, 739.99, 880.00]
},
sakura: {
name: 'Observatory IV · Sakura',
poem: 'Twilight petals drifting through silver rain',
accent: '#ff9ec7',
accentGlow: 'rgba(255, 158, 199, 0.46)',
backdrop: 'radial-gradient(circle at 50% 46%, #241028 0%, #100716 55%, #050208 100%)',
fade: 'rgba(14, 6, 18, 0.055)',
palette: [
[255, 166, 206], // Blossom pink
[255, 209, 224], // Pearl petal
[255, 138, 155], // Coral twilight
[198, 148, 255], // Wisteria glow
[255, 240, 226] // Soft moonlight
],
scale: [246.94, 277.18, 329.63, 369.99, 415.30, 493.88, 554.37, 659.25, 739.99]
},
elysium: {
name: 'Observatory V · Elysium',
poem: 'Cathedrals of silver and quiet infinity',
accent: '#c4b5fd',
accentGlow: 'rgba(196, 181, 253, 0.45)',
backdrop: 'radial-gradient(circle at 50% 45%, #161834 0%, #090a19 55%, #03030a 100%)',
fade: 'rgba(7, 8, 20, 0.052)',
palette: [
[216, 226, 255], // Silver starlight
[184, 168, 255], // Ethereal lavender
[138, 180, 255], // Sapphire mist
[255, 244, 214], // Pale champagne
[255, 255, 255] // Diamond core
],
scale: [261.63, 311.13, 349.23, 392.00, 466.16, 523.25, 622.25, 698.46, 783.99]
}
};
let currentRealmKey = 'aether';
let currentRealm = REALMS.aether;
let currentMode = 'silk'; // 'silk' | 'vortex' | 'orbit'
/* =====================================================================
2. PROCEDURAL AMBIENT WEB AUDIO ENGINE (OPTIONAL)
===================================================================== */
class HarmonicEngine {
constructor() {
this.ctx = null;
this.enabled = false;
this.master = null;
this.padGain = null;
this.delay = null;
this.padOscs = [];
this.lastChimeTime = 0;
}
init() {
if (this.ctx) return;
const AudioCtx = window.AudioContext || window.webkitAudioContext;
this.ctx = new AudioCtx();
this.master = this.ctx.createGain();
this.master.gain.value = 0.0001;
this.master.connect(this.ctx.destination);
// Lush stereo-like feedback delay for crystalline reverb tail
this.delay = this.ctx.createDelay(1.0);
this.delay.delayTime.value = 0.38;
const feedback = this.ctx.createGain();
feedback.gain.value = 0.42;
const delayFilter = this.ctx.createBiquadFilter();
delayFilter.type = 'lowpass';
delayFilter.frequency.value = 2400;
this.delay.connect(delayFilter);
delayFilter.connect(feedback);
feedback.connect(this.delay);
delayFilter.connect(this.master);
// Warm evolving harmonic drone pad
this.padGain = this.ctx.createGain();
this.padGain.gain.value = 0.09;
const padFilter = this.ctx.createBiquadFilter();
padFilter.type = 'lowpass';
padFilter.frequency.value = 460;
this.padGain.connect(padFilter);
padFilter.connect(this.master);
// Slow LFO breathing on pad filter
const lfo = this.ctx.createOscillator();
const lfoGain = this.ctx.createGain();
lfo.frequency.value = 0.08;
lfoGain.gain.value = 180;
lfo.connect(lfoGain);
lfoGain.connect(padFilter.frequency);
lfo.start();
const baseFreqs = [130.81, 196.00, 261.63];
baseFreqs.forEach((f, idx) => {
const osc = this.ctx.createOscillator();
osc.type = idx === 0 ? 'sine' : 'triangle';
osc.frequency.value = f;
osc.detune.value = (idx - 1) * 5;
const g = this.ctx.createGain();
g.gain.value = idx === 0 ? 0.5 : 0.25;
osc.connect(g);
g.connect(this.padGain);
osc.start();
this.padOscs.push(osc);
});
}
toggle() {
this.init();
if (this.ctx.state === 'suspended') this.ctx.resume();
this.enabled = !this.enabled;
const now = this.ctx.currentTime;
this.master.gain.cancelScheduledValues(now);
this.master.gain.setTargetAtTime(this.enabled ? 0.36 : 0.0001, now, 0.45);
if (this.enabled) {
this.updatePadTuning();
this.playChord();
}
return this.enabled;
}
updatePadTuning() {
if (!this.ctx || !this.enabled) return;
const now = this.ctx.currentTime;
const root = currentRealm.scale[0] * 0.5;
const fifth = currentRealm.scale[3] * 0.5;
const octave = currentRealm.scale[0];
const targets = [root, fifth, octave];
this.padOscs.forEach((osc, i) => {
osc.frequency.setTargetAtTime(targets[i], now, 1.2);
});
}
playChime(velocity = 0.5, pitchRatio = Math.random()) {
if (!this.enabled || !this.ctx) return;
const now = this.ctx.currentTime;
if (now - this.lastChimeTime < 0.09) return;
this.lastChimeTime = now;
const scale = currentRealm.scale;
const index = Math.min(scale.length - 1, Math.floor(pitchRatio * scale.length));
const freq = scale[index] * (Math.random() > 0.7 ? 2 : 1);
const osc = this.ctx.createOscillator();
const overtone = this.ctx.createOscillator();
const gain = this.ctx.createGain();
osc.type = 'sine';
osc.frequency.value = freq;
overtone.type = 'sine';
overtone.frequency.value = freq * 2.002;
const overtoneGain = this.ctx.createGain();
overtoneGain.gain.value = 0.14;
const peak = Math.min(0.16, 0.04 + velocity * 0.11);
gain.gain.setValueAtTime(0.0001, now);
gain.gain.exponentialRampToValueAtTime(peak, now + 0.025);
gain.gain.exponentialRampToValueAtTime(0.0001, now + 2.6);
osc.connect(gain);
overtone.connect(overtoneGain);
overtoneGain.connect(gain);
gain.connect(this.master);
gain.connect(this.delay);
osc.start(now);
overtone.start(now);
osc.stop(now + 2.7);
overtone.stop(now + 2.7);
}
playChord() {
if (!this.enabled || !this.ctx) return;
const notes = [0, 2, 4, 6];
notes.forEach((n, idx) => {
setTimeout(() => {
this.lastChimeTime = 0;
this.playChime(0.65, n / currentRealm.scale.length);
}, idx * 85);
});
}
}
const sound = new HarmonicEngine();
/* =====================================================================
3. CANVAS SETUP & RESPONSIVE HIGH-DPI SCALING
===================================================================== */
const trailCanvas = document.getElementById('trailCanvas');
const fxCanvas = document.getElementById('fxCanvas');
const trailCtx = trailCanvas.getContext('2d');
const fxCtx = fxCanvas.getContext('2d');
let width = window.innerWidth;
let height = window.innerHeight;
let dpr = Math.min(window.devicePixelRatio || 1, 2);
function resize() {
width = window.innerWidth;
height = window.innerHeight;
dpr = Math.min(window.devicePixelRatio || 1, 2);
[trailCanvas, fxCanvas].forEach(c => {
c.width = Math.floor(width * dpr);
c.height = Math.floor(height * dpr);
c.style.width = width + 'px';
c.style.height = height + 'px';
});
trailCtx.setTransform(dpr, 0, 0, dpr, 0, 0);
fxCtx.setTransform(dpr, 0, 0, dpr, 0, 0);
initStars();
}
/* =====================================================================
4. CELESTIAL ENTITIES: STARS, FILAMENTS, SHOCKWAVES, SPARKS
===================================================================== */
const isMobile = /Mobi|Android/i.test(navigator.userAgent) || width < 768;
const PARTICLE_COUNT = isMobile ? 520 : 940;
const STAR_COUNT = isMobile ? 95 : 175;
const particles = [];
const stars = [];
const shockwaves = [];
const sparks = [];
// Smoothly tracked pointer & cosmic attractors
const pointer = {
x: width * 0.5,
y: height * 0.5,
tx: width * 0.5,
ty: height * 0.5,
vx: 0,
vy: 0,
active: false,
pressing: false,
pressCharge: 0,
lastMoveTime: 0
};
let time = 0;
let hasInteracted = false;
function pickColor(palette) {
return palette[Math.floor(Math.random() * palette.length)];
}
class Filament {
constructor(randomSpawn = true) {
this.reset(randomSpawn);
}
reset(randomSpawn = false) {
if (randomSpawn) {
this.x = Math.random() * width;
this.y = Math.random() * height;
} else {
// Re-enter gently near golden spiral or edges
if (Math.random() < 0.65) {
const angle = Math.random() * Math.PI * 2;
const radius = Math.min(width, height) * (0.12 + Math.random() * 0.44);
this.x = width * 0.5 + Math.cos(angle) * radius;
this.y = height * 0.5 + Math.sin(angle) * radius;
} else {
this.x = Math.random() * width;
this.y = Math.random() * height;
}
}
this.px = this.x;
this.py = this.y;
this.vx = 0;
this.vy = 0;
this.life = 0;
this.maxLife = 160 + Math.random() * 260;
this.size = 0.6 + Math.random() * 1.55;
this.speedFactor = 0.65 + Math.random() * 0.85;
this.colorIdx = Math.floor(Math.random() * 5);
this.rgb = [...currentRealm.palette[this.colorIdx]];
this.phase = Math.random() * Math.PI * 2;
}
update(dt, fieldTime, attractors) {
this.px = this.x;
this.py = this.y;
// Smoothly morph particle color toward current realm palette
const target = currentRealm.palette[this.colorIdx];
this.rgb[0] += (target[0] - this.rgb[0]) * 0.035;
this.rgb[1] += (target[1] - this.rgb[1]) * 0.035;
this.rgb[2] += (target[2] - this.rgb[2]) * 0.035;
// Curl-like multi-octave trigonometric flow field
const nx = (this.x - width * 0.5) * 0.0021;
const ny = (this.y - height * 0.5) * 0.0021;
const angle1 =
Math.sin(nx * 2.1 + fieldTime * 0.42) * Math.cos(ny * 2.1 - fieldTime * 0.36) * Math.PI * 2 +
Math.sin((nx + ny) * 1.4 - fieldTime * 0.28) * Math.PI;
const angle2 =
Math.cos(nx * 4.3 - fieldTime * 0.55) * Math.sin(ny * 4.3 + fieldTime * 0.48) * 1.1;
const angle = angle1 + angle2;
let fx = Math.cos(angle) * 0.36;
let fy = Math.sin(angle) * 0.36;
// Mode-specific choreography
const cx = width * 0.5;
const cy = height * 0.5;
const dcx = this.x - cx;
const dcy = this.y - cy;
const distCenter = Math.hypot(dcx, dcy) + 0.001;
if (currentMode === 'vortex') {
const tangentX = -dcy / distCenter;
const tangentY = dcx / distCenter;
const pull = Math.min(1.0, distCenter / (Math.min(width, height) * 0.45));
fx = fx * 0.45 + tangentX * 0.85 - (dcx / distCenter) * 0.18 * pull;
fy = fy * 0.45 + tangentY * 0.85 - (dcy / distCenter) * 0.18 * pull;
} else if (currentMode === 'orbit') {
// Dual harmonic orbital rings
const ringR = Math.min(width, height) * (this.colorIdx % 2 === 0 ? 0.28 : 0.16);
const radialErr = (ringR - distCenter) * 0.0045;
const dir = this.colorIdx % 2 === 0 ? 1 : -1;
fx = fx * 0.35 + (-dcy / distCenter) * 0.78 * dir + (dcx / distCenter) * radialErr;
fy = fy * 0.35 + (dcx / distCenter) * 0.78 * dir + (dcy / distCenter) * radialErr;
} else {
// Silk mode: gentle organic drift around moving cosmic attractors
for (let i = 0; i < attractors.length; i++) {
const a = attractors[i];
const dx = a.x - this.x;
const dy = a.y - this.y;
const d2 = dx * dx + dy * dy + 9000;
const d = Math.sqrt(d2);
const swirl = a.spin * (1400 / d2);
fx += (-dy / d) * swirl + (dx / d) * (240 / d2);
fy += (dx / d) * swirl + (dy / d) * (240 / d2);
}
}
// Interactive cursor influence
if (pointer.active || pointer.pressing) {
const dx = pointer.x - this.x;
const dy = pointer.y - this.y;
const distSq = dx * dx + dy * dy;
const influenceR = pointer.pressing ? 420 : 240;
if (distSq < influenceR * influenceR) {
const dist = Math.sqrt(distSq) + 1;
const falloff = 1 - dist / influenceR;
const smooth = falloff * falloff;
if (pointer.pressing) {
// Gravitational star-bloom swirl
const pull = (1.1 + pointer.pressCharge * 0.9) * smooth;
const spin = (1.6 + pointer.pressCharge * 0.7) * smooth;
fx += (dx / dist) * pull + (-dy / dist) * spin;
fy += (dy / dist) * pull + (dx / dist) * spin;
} else {
// Silky luminous wake following pointer velocity
fx += pointer.vx * 0.032 * smooth + (-dy / dist) * 0.55 * smooth;
fy += pointer.vy * 0.032 * smooth + (dx / dist) * 0.55 * smooth;
}
}
}
// Apply acceleration and silky damping
this.vx = (this.vx + fx * this.speedFactor) * 0.92;
this.vy = (this.vy + fy * this.speedFactor) * 0.92;
// Clamp max speed to keep ribbons velvety
const speed = Math.hypot(this.vx, this.vy);
const maxSpeed = pointer.pressing ? 8.2 : 5.2;
if (speed > maxSpeed) {
this.vx = (this.vx / speed) * maxSpeed;
this.vy = (this.vy / speed) * maxSpeed;
}
this.x += this.vx * dt;
this.y += this.vy * dt;
this.life += dt;
// Respawn if expired or far offscreen
const pad = 60;
if (
this.life > this.maxLife ||
this.x < -pad || this.x > width + pad ||
this.y < -pad || this.y > height + pad
) {
this.reset(false);
}
}
draw(ctx) {
const progress = this.life / this.maxLife;
const envelope = Math.sin(progress * Math.PI); // smooth fade in & out
const speed = Math.hypot(this.vx, this.vy);
const alpha = Math.min(0.85, envelope * (0.18 + speed * 0.14));
if (alpha < 0.01) return;
const r = this.rgb[0] | 0;
const g = this.rgb[1] | 0;
const b = this.rgb[2] | 0;
ctx.strokeStyle = `rgba(${r},${g},${b},${alpha.toFixed(3)})`;
ctx.lineWidth = this.size * (0.7 + Math.min(1.1, speed * 0.22));
ctx.beginPath();
ctx.moveTo(this.px, this.py);
ctx.lineTo(this.x, this.y);
ctx.stroke();
}
}
function initStars() {
stars.length = 0;
for (let i = 0; i < STAR_COUNT; i++) {
stars.push({
x: Math.random() * width,
y: Math.random() * height,
r: 0.4 + Math.random() * 1.45,
baseAlpha: 0.18 + Math.random() * 0.65,
twinkleSpeed: 0.6 + Math.random() * 2.2,
phase: Math.random() * Math.PI * 2,
depth: 0.2 + Math.random() * 0.8
});
}
}
function initParticles() {
particles.length = 0;
for (let i = 0; i < PARTICLE_COUNT; i++) {
particles.push(new Filament(true));
}
document.getElementById('stat-count').textContent = PARTICLE_COUNT;
}
function triggerBloom(x, y, power = 1.0) {
shockwaves.push({
x,
y,
radius: 8,
maxRadius: Math.min(width, height) * (0.36 + power * 0.22),
alpha: 0.85,
color: currentRealm.accent
});
// Radial luminous sparks
const count = Math.floor(38 + power * 36);
for (let i = 0; i < count; i++) {
const ang = (Math.PI * 2 * i) / count + (Math.random() - 0.5) * 0.25;
const spd = (2.2 + Math.random() * 6.5) * (0.75 + power * 0.45);
const col = pickColor(currentRealm.palette);
sparks.push({
x,
y,
vx: Math.cos(ang) * spd,
vy: Math.sin(ang) * spd,
life: 1,
decay: 0.012 + Math.random() * 0.016,
size: 1.1 + Math.random() * 2.3,
rgb: col
});
}
// Push nearby filaments outward in a radiant wave
for (let i = 0; i < particles.length; i++) {
const p = particles[i];
const dx = p.x - x;
const dy = p.y - y;
const d = Math.hypot(dx, dy) + 1;
if (d < 360) {
const force = (1 - d / 360) * (5.5 * power);
p.vx += (dx / d) * force;
p.vy += (dy / d) * force;
}
}
sound.playChord();
}
/* =====================================================================
5. CELESTIAL FOREGROUND GEOMETRY & RENDERING
===================================================================== */
function drawSacredAstrolabe(ctx, t) {
const cx = width * 0.5;
const cy = height * 0.5;
const minDim = Math.min(width, height);
const r1 = minDim * 0.34;
const r2 = minDim * 0.22;
ctx.save();
ctx.translate(cx, cy);
// Outer whisper-thin astrolabe ring
ctx.strokeStyle = 'rgba(255, 255, 255, 0.045)';
ctx.lineWidth = 1;
ctx.beginPath();
ctx.arc(0, 0, r1, 0, Math.PI * 2);
ctx.stroke();
// Rotating dashed celestial meridian
ctx.save();
ctx.rotate(t * 0.04);
ctx.setLineDash([2, 14]);
ctx.strokeStyle = 'rgba(255, 255, 255, 0.065)';
ctx.beginPath();
ctx.arc(0, 0, r1 * 1.045, 0, Math.PI * 2);
ctx.stroke();
ctx.restore();
// Inner counter-rotating orbit with luminous celestial nodes
ctx.save();
ctx.rotate(-t * 0.075);
ctx.strokeStyle = 'rgba(255, 255, 255, 0.038)';
ctx.beginPath();
ctx.arc(0, 0, r2, 0, Math.PI * 2);
ctx.stroke();
for (let i = 0; i < 3; i++) {
const a = (Math.PI * 2 * i) / 3;
const nx = Math.cos(a) * r2;
const ny = Math.sin(a) * r2;
ctx.fillStyle = currentRealm.accent;
ctx.globalAlpha = 0.45;
ctx.beginPath();
ctx.arc(nx, ny, 2.2, 0, Math.PI * 2);
ctx.fill();
}
ctx.restore();
ctx.restore();
}
function drawStarsAndConstellations(ctx, t) {
const parallaxX = (pointer.x - width * 0.5) * 0.018;
const parallaxY = (pointer.y - height * 0.5) * 0.018;
const nearStars = [];
for (let i = 0; i < stars.length; i++) {
const s = stars[i];
const sx = s.x - parallaxX * s.depth;
const sy = s.y - parallaxY * s.depth;
const twinkle = 0.55 + 0.45 * Math.sin(t * s.twinkleSpeed + s.phase);
const alpha = s.baseAlpha * twinkle;
ctx.fillStyle = `rgba(240, 248, 255, ${alpha.toFixed(3)})`;
ctx.beginPath();
ctx.arc(sx, sy, s.r, 0, Math.PI * 2);
ctx.fill();
if (pointer.active) {
const dist = Math.hypot(sx - pointer.x, sy - pointer.y);
if (dist < 155) {
nearStars.push({ x: sx, y: sy, dist });
}
}
}
// Delicate constellation web weaving around the cursor
if (nearStars.length > 1) {
ctx.lineWidth = 0.7;
for (let i = 0; i < nearStars.length; i++) {
const a = nearStars[i];
const alphaToPointer = (1 - a.dist / 155) * 0.22;
ctx.strokeStyle = `rgba(255, 255, 255, ${alphaToPointer.toFixed(3)})`;
ctx.beginPath();
ctx.moveTo(a.x, a.y);
ctx.lineTo(pointer.x, pointer.y);
ctx.stroke();
for (let j = i + 1; j < nearStars.length; j++) {
const b = nearStars[j];
const d = Math.hypot(a.x - b.x, a.y - b.y);
if (d < 110) {
const alphaLink = (1 - d / 110) * 0.16;
ctx.strokeStyle = `rgba(255, 255, 255, ${alphaLink.toFixed(3)})`;
ctx.beginPath();
ctx.moveTo(a.x, a.y);
ctx.lineTo(b.x, b.y);
ctx.stroke();
}
}
}
}
}
function drawPointerHalo(ctx) {
if (!pointer.active && !pointer.pressing) return;
const baseR = pointer.pressing ? 90 + pointer.pressCharge * 80 : 65;
const grad = ctx.createRadialGradient(
pointer.x, pointer.y, 0,
pointer.x, pointer.y, baseR
);
const col = currentRealm.palette[0];
const intensity = pointer.pressing ? 0.34 + pointer.pressCharge * 0.24 : 0.13;
grad.addColorStop(0, `rgba(255, 255, 255, ${(intensity * 1.2).toFixed(3)})`);
grad.addColorStop(0.28, `rgba(${col[0]}, ${col[1]}, ${col[2]}, ${intensity.toFixed(3)})`);
grad.addColorStop(1, 'rgba(0, 0, 0, 0)');
ctx.fillStyle = grad;
ctx.beginPath();
ctx.arc(pointer.x, pointer.y, baseR, 0, Math.PI * 2);
ctx.fill();
// Charging star-core rings when holding
if (pointer.pressing) {
ctx.save();
ctx.strokeStyle = `rgba(255, 255, 255, ${(0.25 + pointer.pressCharge * 0.5).toFixed(3)})`;
ctx.lineWidth = 1.2;
ctx.beginPath();
ctx.arc(pointer.x, pointer.y, 16 + pointer.pressCharge * 34, 0, Math.PI * 2);
ctx.stroke();
ctx.restore();
}
}
function updateAndDrawFX(ctx) {
// Shockwaves
for (let i = shockwaves.length - 1; i >= 0; i--) {
const w = shockwaves[i];
w.radius += (w.maxRadius - w.radius) * 0.065 + 2.5;
w.alpha *= 0.94;
ctx.save();
ctx.strokeStyle = w.color;
ctx.globalAlpha = w.alpha * 0.7;
ctx.lineWidth = 1.6;
ctx.beginPath();
ctx.arc(w.x, w.y, w.radius, 0, Math.PI * 2);
ctx.stroke();
ctx.globalAlpha = w.alpha * 0.22;
ctx.lineWidth = 8;
ctx.beginPath();
ctx.arc(w.x, w.y, w.radius * 0.96, 0, Math.PI * 2);
ctx.stroke();
ctx.restore();
if (w.alpha < 0.015) shockwaves.splice(i, 1);
}
// Luminous Sparks
ctx.save();
ctx.globalCompositeOperation = 'lighter';
for (let i = sparks.length - 1; i >= 0; i--) {
const s = sparks[i];
s.x += s.vx;
s.y += s.vy;
s.vx *= 0.965;
s.vy *= 0.965;
s.life -= s.decay;
if (s.life <= 0) {
sparks.splice(i, 1);
continue;
}
const [r, g, b] = s.rgb;
ctx.fillStyle = `rgba(${r},${g},${b},${(s.life * 0.9).toFixed(3)})`;
ctx.beginPath();
ctx.arc(s.x, s.y, s.size * s.life, 0, Math.PI * 2);
ctx.fill();
}
ctx.restore();
}
/* =====================================================================
6. MAIN ANIMATION LOOP
===================================================================== */
let lastFrame = performance.now();
const epochEl = document.getElementById('stat-epoch');
const cursorDot = document.getElementById('cursor-dot');
const cursorRing = document.getElementById('cursor-ring');
let ringX = width * 0.5;
let ringY = height * 0.5;
function animate(now) {
requestAnimationFrame(animate);
const rawDt = Math.min(32, now - lastFrame) / 16.666;
lastFrame = now;
time += 0.014 * rawDt;
// Smooth pointer interpolation
const prevX = pointer.x;
const prevY = pointer.y;
pointer.x += (pointer.tx - pointer.x) * 0.24;
pointer.y += (pointer.ty - pointer.y) * 0.24;
pointer.vx = pointer.x - prevX;
pointer.vy = pointer.y - prevY;
if (pointer.pressing) {
pointer.pressCharge = Math.min(1, pointer.pressCharge + 0.022 * rawDt);
} else {
pointer.pressCharge = Math.max(0, pointer.pressCharge - 0.06 * rawDt);
}
// Smooth custom cursor ring lag
ringX += (pointer.tx - ringX) * 0.16;
ringY += (pointer.ty - ringY) * 0.16;
cursorDot.style.transform = `translate3d(${pointer.tx}px, ${pointer.ty}px, 0) translate(-50%, -50%)`;
cursorRing.style.transform = `translate3d(${ringX}px, ${ringY}px, 0) translate(-50%, -50%)`;
// Gently moving celestial attractors for organic beauty even without input
const attractors = [
{
x: width * (0.5 + 0.26 * Math.cos(time * 0.31)),
y: height * (0.5 + 0.22 * Math.sin(time * 0.43)),
spin: 1.0
},
{
x: width * (0.5 - 0.24 * Math.sin(time * 0.27)),
y: height * (0.5 + 0.25 * Math.cos(time * 0.37)),
spin: -1.0
}
];
// 1) Fade trail canvas slightly to create luminous velvet silk trails
trailCtx.globalCompositeOperation = 'source-over';
trailCtx.fillStyle = currentRealm.fade;
trailCtx.fillRect(0, 0, width, height);
// 2) Draw glowing filaments with additive light blending
trailCtx.globalCompositeOperation = 'lighter';
trailCtx.lineCap = 'round';
for (let i = 0; i < particles.length; i++) {
particles[i].update(rawDt, time, attractors);
particles[i].draw(trailCtx);
}
// 3) Render crisp foreground layer: stars, astrolabe, constellations, halo, FX
fxCtx.clearRect(0, 0, width, height);
drawSacredAstrolabe(fxCtx, time);
drawStarsAndConstellations(fxCtx, time);
drawPointerHalo(fxCtx);
updateAndDrawFX(fxCtx);
// Update epoch counter subtly
if (Math.floor(now / 120) % 2 === 0) {
epochEl.textContent = (time * 3.14).toFixed(2).padStart(5, '0');
}
}
/* =====================================================================
7. INTERACTIONS, REALMS & SNAPSHOT EXPORT
===================================================================== */
const whisper = document.getElementById('whisper');
const backdrop = document.getElementById('backdrop');
const eyebrow = document.getElementById('realm-eyebrow');
const poem = document.getElementById('realm-poem');
const statMode = document.getElementById('stat-mode');
const toast = document.getElementById('toast');
let toastTimer = null;
function showToast(msg) {
toast.textContent = msg;
toast.classList.add('show');
clearTimeout(toastTimer);
toastTimer = setTimeout(() => toast.classList.remove('show'), 2200);
}
function dismissWhisper() {
if (!hasInteracted) {
hasInteracted = true;
whisper.classList.add('hidden');
}
}
function setRealm(key) {
if (!REALMS[key]) return;
currentRealmKey = key;
currentRealm = REALMS[key];
document.documentElement.style.setProperty('--accent', currentRealm.accent);
document.documentElement.style.setProperty('--accent-glow', currentRealm.accentGlow);
backdrop.style.background = currentRealm.backdrop;
eyebrow.textContent = currentRealm.name;
poem.textContent = currentRealm.poem;
document.querySelectorAll('.realm-btn').forEach(btn => {
btn.classList.toggle('active', btn.dataset.realm === key);
});
sound.updatePadTuning();
triggerBloom(width * 0.5, height * 0.5, 0.72);
}
function setMode(mode) {
currentMode = mode;
statMode.textContent = mode.toUpperCase();
document.querySelectorAll('.mode-btn').forEach(btn => {
btn.classList.toggle('active', btn.dataset.mode === mode);
});
sound.playChime(0.55, 0.65);
}
function captureArtwork() {
const exportCanvas = document.createElement('canvas');
exportCanvas.width = trailCanvas.width;
exportCanvas.height = trailCanvas.height;
const ectx = exportCanvas.getContext('2d');
// Paint rich radial cosmic background matching the active realm
const grad = ectx.createRadialGradient(
exportCanvas.width * 0.5, exportCanvas.height * 0.45, 0,
exportCanvas.width * 0.5, exportCanvas.height * 0.5, Math.max(exportCanvas.width, exportCanvas.height) * 0.65
);
const c = currentRealm.palette[1];
grad.addColorStop(0, `rgb(${(c[0] * 0.14) | 0}, ${(c[1] * 0.14) | 0}, ${(c[2] * 0.18) | 0})`);
grad.addColorStop(1, '#020308');
ectx.fillStyle = grad;
ectx.fillRect(0, 0, exportCanvas.width, exportCanvas.height);
// Composite trail & FX layers
ectx.globalCompositeOperation = 'screen';
ectx.drawImage(trailCanvas, 0, 0);
ectx.globalCompositeOperation = 'source-over';
ectx.drawImage(fxCanvas, 0, 0);
const link = document.createElement('a');
link.download = `aetherium-${currentRealmKey}-${Date.now()}.png`;
link.href = exportCanvas.toDataURL('image/png');
link.click();
showToast('Artwork Saved as PNG');
}
// Pointer Events
window.addEventListener('pointermove', e => {
pointer.tx = e.clientX;
pointer.ty = e.clientY;
pointer.active = true;
pointer.lastMoveTime = performance.now();
const overUI = Boolean(e.target.closest('button, nav, .brand'));
document.body.classList.toggle('over-ui', overUI);
// Occasional crystalline chimes when gliding rapidly
const speed = Math.hypot(pointer.vx, pointer.vy);
if (!overUI && speed > 16 && Math.random() < 0.25) {
sound.playChime(Math.min(1, speed / 36), 1 - e.clientY / height);
}
});
window.addEventListener('pointerdown', e => {
if (e.target.closest('button, nav')) return;
dismissWhisper();
pointer.tx = e.clientX;
pointer.ty = e.clientY;
pointer.active = true;
pointer.pressing = true;
document.body.classList.add('is-pressing');
sound.playChime(0.75, 1 - e.clientY / height);
});
window.addEventListener('pointerup', e => {
if (pointer.pressing) {
const power = 0.65 + pointer.pressCharge * 0.85;
triggerBloom(pointer.x, pointer.y, power);
}
pointer.pressing = false;
document.body.classList.remove('is-pressing');
});
window.addEventListener('pointerleave', () => {
pointer.active = false;
pointer.pressing = false;
document.body.classList.remove('is-pressing');
});
// UI Button Bindings
document.querySelectorAll('.realm-btn').forEach(btn => {
btn.addEventListener('click', () => {
dismissWhisper();
setRealm(btn.dataset.realm);
});
});
document.querySelectorAll('.mode-btn').forEach(btn => {
btn.addEventListener('click', () => {
dismissWhisper();
setMode(btn.dataset.mode);
});
});
const soundBtn = document.getElementById('btn-sound');
soundBtn.addEventListener('click', () => {
dismissWhisper();
const on = sound.toggle();
soundBtn.classList.toggle('active', on);
showToast(on ? 'Harmonics Enabled' : 'Harmonics Muted');
});
document.getElementById('btn-burst').addEventListener('click', () => {
dismissWhisper();
triggerBloom(
width * (0.35 + Math.random() * 0.3),
height * (0.35 + Math.random() * 0.3),
1.2
);
});
document.getElementById('btn-capture').addEventListener('click', captureArtwork);
const toggleZen = () => {
document.body.classList.toggle('zen-mode');
if (document.body.classList.contains('zen-mode')) {
dismissWhisper();
}
};
document.getElementById('btn-zen').addEventListener('click', toggleZen);
document.getElementById('zen-restore').addEventListener('click', toggleZen);
// Keyboard Shortcuts
window.addEventListener('keydown', e => {
if (e.key === '1') setRealm('aether');
else if (e.key === '2') setRealm('solstice');
else if (e.key === '3') setRealm('aurora');
else if (e.key === '4') setRealm('sakura');
else if (e.key === '5') setRealm('elysium');
else if (e.code === 'Space') {
e.preventDefault();
dismissWhisper();
triggerBloom(pointer.active ? pointer.x : width * 0.5, pointer.active ? pointer.y : height * 0.5, 1.15);
} else if (e.key.toLowerCase() === 'h') {
toggleZen();
} else if (e.key.toLowerCase() === 's') {
captureArtwork();
} else if (e.key.toLowerCase() === 'm') {
soundBtn.click();
}
});
window.addEventListener('resize', resize);
/* =====================================================================
8. IGNITION
===================================================================== */
resize();
initParticles();
requestAnimationFrame(animate);
// Gentle opening star-bloom after first paint
setTimeout(() => {
triggerBloom(width * 0.5, height * 0.5, 0.9);
}, 420);
// Auto-fade whisper gently after 6.5 seconds if user simply watches
setTimeout(() => {
whisper.classList.add('hidden');
}, 6500);
})();
</script>
</body>
</html>