/* ========================================================================== scenes.js — 60fps Audio-Reactive HTML5 Canvas Visual Engine Supports 7 distinct moods with smooth crossfading: 1. terminal-dark : Phosphor green CRT, kernel logs, vi :wq status bar, hex matrix 2. assembly-heat : Amber/orange CPU registers, pointer arrows, oscilloscope, tech ticker 3. vibe-glitch : Neon magenta/cyan cyberpunk glitch, AI prompt bubbles, flying TAB keycaps 4. manpage-bloat : Retro man(1) pages, race-condition threads, node_modules avalanche vs single-file core 5. synth-arp : Indigo/violet synthwave sun & horizon grid, PASS 100% tests, neural/code constellations 6. mech-140wpm : Blistering 140 WPM top-down mechanical keyboard, sparks, WPM counter, equalizer 7. root-micdrop : High-contrast root # spotlight, CAPS LOCK -> ESC remap, :q! & CRT power-off collapse ========================================================================== */ (function (global) { 'use strict'; const MOOD_LIST = [ 'terminal-dark', 'assembly-heat', 'vibe-glitch', 'manpage-bloat', 'synth-arp', 'mech-140wpm', 'root-micdrop' ]; // Static content pools for authentic developer visuals const KERNEL_LOGS = [ ' CC arch/x86/kernel/cpu/common.o', ' AS arch/x86/entry/entry_64.o', ' CC mm/page_alloc.o', ' CC kernel/sched/fair.o', ' CC [M] drivers/gpu/drm/baremetal_crt.o', ' CC fs/ext4/inode.o', ' CC net/ipv4/tcp_fastopen.o', ' AR built-in.a', ' LD vmlinux.o', ' MODPOST Module.symvers', ' LD vmlinux', ' OBJCOPY arch/x86/boot/vmlinux.bin', ' BUILD arch/x86/boot/bzImage', 'Kernel: arch/x86/boot/bzImage is ready (#42 SMP PREEMPT)', ' CC drivers/tty/vt/keyboard.o', ' CC security/keys/keyring.o', ' CC lib/rbtree.o', ' SYSMAP System.map' ]; const TECH_TICKER = ' +++ BREAKING: STARTUP RAISES $80M FOR ONE-LINE PROMPT WRAPPER ' + '+++ TRENDING #1: "VIBE CODING" REPLACES SEMICOLONS? ' + '+++ ALERT: JUNIOR DEV SHIPS FULL-STACK APP WITHOUT READING DOCS ' + '+++ BENCHMARK: BARE-METAL C STILL 412x FASTER THAN AI SLOP ' + '+++ VIM USERS STILL CAN\'T EXIT (:wq OR :q!) '; const AI_PROMPTS = [ 'make it pop ✨', 'fix bug pls 🙏', 'build SaaS in 10s', 'accept all [TAB]', 'vibes > types', 'no semicolons', 'LGTM ship it 🚀', 'trust the prompt', 'refactor w/ AI' ]; const MAN_LINES = [ 'PTHREAD_MUTEX_LOCK(3) Linux Programmer\'s Manual PTHREAD_MUTEX_LOCK(3)', '', 'NAME', ' pthread_mutex_lock - lock and unlock a mutex without race conditions', '', 'SYNOPSIS', ' #include ', ' int pthread_mutex_lock(pthread_mutex_t *mutex);', '', 'DESCRIPTION', ' Read the man pages cover to cover. Undefined behavior occurs when', ' two threads mutate shared memory without synchronization barriers.', ' Zero dependencies. Single-file clean. Compile with -O3 -Wall -Werror.', '', 'BUGS', ' node_modules/ recursively consumes 4.2 GB across 184,920 tiny files.' ]; const BLOAT_PKGS = [ 'is-odd@3.0.1', 'is-even@1.0.0', 'left-pad@1.3.0', 'webpack-v9', 'babel-core', 'eslint-plugin-vibe', 'lodash-es', 'core-js-compat', 'postcss-loader', 'ts-node-dev', 'rxjs-bundle', 'chalk-ansi', 'rimraf-legacy', 'glob-parent', 'minimatch', 'semver-diff', 'mkdirp-classic', 'acorn-walk', 'ajv-keywords', 'fsevents' ]; const KB_ROWS = [ ['ESC', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 'BKSP'], ['TAB', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '[', ']', '\\'], ['ESC*', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', "'", 'ENTER'], ['SHIFT', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 'SHIFT'], ['CTRL', 'ALT', 'SPACE', 'ALT', 'FN', 'CTRL'] ]; const KB_WIDTHS = { BKSP: 2.0, TAB: 1.5, '\\': 1.5, 'ESC*': 1.8, ENTER: 2.2, SHIFT: 2.25, CTRL: 1.4, ALT: 1.3, FN: 1.3, SPACE: 6.7 }; function clamp(v, lo, hi) { return v < lo ? lo : v > hi ? hi : v; } function lerp(a, b, t) { return a + (b - a) * t; } function hash2(n) { const x = Math.sin(n * 127.1 + 311.7) * 43758.5453123; return x - Math.floor(x); } class SceneEngine { constructor(canvas) { this.canvas = canvas; this.ctx = canvas.getContext('2d', { alpha: false }); this.width = 1280; this.height = 720; this.dpr = 1; this.currentMood = 'terminal-dark'; this.prevMood = null; this.transition = 1; // 1 = fully settled on currentMood this.lastFrameTime = performance.now(); // Persistent animated entity pools this.initPools(); this.resize(); } initPools() { // Hex matrix columns for terminal-dark this.hexCols = []; for (let i = 0; i < 36; i++) { this.hexCols.push({ xFrac: (i + 0.5) / 36, y: Math.random(), speed: 0.04 + Math.random() * 0.09, seed: Math.floor(Math.random() * 65535) }); } // Floating AI prompts + flying TAB keycaps for vibe-glitch this.promptBubbles = AI_PROMPTS.map((text, i) => ({ text, x: 0.1 + (i % 3) * 0.34 + (Math.random() - 0.5) * 0.12, y: 0.14 + Math.floor(i / 3) * 0.28 + (Math.random() - 0.5) * 0.08, vx: (Math.random() - 0.5) * 0.03, vy: -0.015 - Math.random() * 0.025, phase: Math.random() * Math.PI * 2 })); this.tabCaps = []; for (let i = 0; i < 12; i++) { this.tabCaps.push({ x: Math.random(), y: Math.random(), z: 0.2 + Math.random() * 0.8, rot: (Math.random() - 0.5) * 0.5, vrot: (Math.random() - 0.5) * 0.8 }); } // Race condition threads & bloat boxes for manpage-bloat this.threads = []; for (let i = 0; i < 16; i++) { this.threads.push({ isRed: i % 2 === 0, y: 0.12 + (i / 16) * 0.76, x: Math.random(), speed: (0.18 + Math.random() * 0.28) * (i % 2 === 0 ? 1 : -1) }); } this.bloatBoxes = BLOAT_PKGS.map((name, i) => { const side = i % 2 === 0 ? 0 : 1; return { name, x: side === 0 ? 0.02 + Math.random() * 0.24 : 0.72 + Math.random() * 0.22, y: 0.08 + Math.random() * 0.78, w: 0.09 + Math.random() * 0.09, h: 0.055 + Math.random() * 0.065, delay: i / BLOAT_PKGS.length, hue: 12 + (i * 19) % 42 }; }); // Synthwave stars, unit test badges & neural nodes for synth-arp this.stars = []; for (let i = 0; i < 70; i++) { this.stars.push({ x: Math.random(), y: Math.random() * 0.55, r: 0.8 + Math.random() * 1.8, twinkle: Math.random() * Math.PI * 2 }); } this.testBadges = []; for (let i = 0; i < 10; i++) { this.testBadges.push({ x: 0.08 + Math.random() * 0.84, y: 0.15 + Math.random() * 0.7, vy: -0.02 - Math.random() * 0.025, label: i % 3 === 0 ? '✓ PASS 100%' : i % 3 === 1 ? '✓ 42/42 OK' : '✓ 0 ERRORS' }); } this.constellation = []; const glyphs = ['{ }', '< >', '=>', '::', '()', '[]', '&&', '0x']; for (let i = 0; i < 14; i++) { this.constellation.push({ x: 0.08 + (i / 13) * 0.84, y: 0.1 + Math.sin(i * 1.4) * 0.14 + 0.14, vx: (Math.random() - 0.5) * 0.008, vy: (Math.random() - 0.5) * 0.006, glyph: glyphs[i % glyphs.length] }); } // Mechanical keyboard state & sparks for mech-140wpm this.keys = []; KB_ROWS.forEach((row, rIdx) => { let totalUnits = 0; row.forEach((k) => { totalUnits += KB_WIDTHS[k] || 1; }); let cursor = 0; row.forEach((label) => { const u = KB_WIDTHS[label] || 1; this.keys.push({ row: rIdx, label, xNorm: cursor / totalUnits, wNorm: u / totalUnits, heat: 0, press: 0 }); cursor += u; }); }); this.sparks = []; this.keystrokeAcc = 0; this.wpmDisplay = 140; } resize() { this.dpr = Math.min(window.devicePixelRatio || 1, 2); this.width = window.innerWidth; this.height = window.innerHeight; this.canvas.width = Math.floor(this.width * this.dpr); this.canvas.height = Math.floor(this.height * this.dpr); this.ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0); } setMood(mood) { const target = MOOD_LIST.includes(mood) ? mood : 'terminal-dark'; if (target !== this.currentMood) { this.prevMood = this.currentMood; this.currentMood = target; this.transition = 0; } } render(state) { const now = performance.now(); const dt = Math.min((now - this.lastFrameTime) / 1000, 0.05); this.lastFrameTime = now; if (state.mood && state.mood !== this.currentMood) { this.setMood(state.mood); } if (this.transition < 1) { this.transition = Math.min(1, this.transition + dt * 1.45); if (this.transition >= 1) { this.prevMood = null; } } const ctx = this.ctx; const w = this.width; const h = this.height; const audio = state.audio; // Subtle audio-reactive camera shake on high energy let shakeX = 0; let shakeY = 0; if (state.playing && (this.currentMood === 'vibe-glitch' || this.currentMood === 'mech-140wpm' || this.currentMood === 'assembly-heat')) { const amp = Math.max(0, audio.bass - 0.55) * 9; shakeX = (Math.random() - 0.5) * amp; shakeY = (Math.random() - 0.5) * amp; } ctx.save(); ctx.translate(shakeX, shakeY); // Draw previous mood during crossfade if (this.prevMood && this.transition < 1) { ctx.globalAlpha = 1; this.drawMood(this.prevMood, ctx, w, h, dt, state); ctx.globalAlpha = this.transition; this.drawMood(this.currentMood, ctx, w, h, dt, state); ctx.globalAlpha = 1; } else { this.drawMood(this.currentMood, ctx, w, h, dt, state); } ctx.restore(); } drawMood(mood, ctx, w, h, dt, state) { switch (mood) { case 'terminal-dark': this.drawTerminalDark(ctx, w, h, dt, state); break; case 'assembly-heat': this.drawAssemblyHeat(ctx, w, h, dt, state); break; case 'vibe-glitch': this.drawVibeGlitch(ctx, w, h, dt, state); break; case 'manpage-bloat': this.drawManpageBloat(ctx, w, h, dt, state); break; case 'synth-arp': this.drawSynthArp(ctx, w, h, dt, state); break; case 'mech-140wpm': this.drawMech140Wpm(ctx, w, h, dt, state); break; case 'root-micdrop': this.drawRootMicdrop(ctx, w, h, dt, state); break; default: this.drawTerminalDark(ctx, w, h, dt, state); } } /* ---------------------------------------------------------------------- 1. TERMINAL-DARK: Phosphor green CRT, kernel logs, hex matrix, vi :wq ---------------------------------------------------------------------- */ drawTerminalDark(ctx, w, h, dt, state) { const { time, audio, playing } = state; // Deep CRT phosphor backdrop const bg = ctx.createRadialGradient(w * 0.5, h * 0.45, 40, w * 0.5, h * 0.5, Math.max(w, h) * 0.78); bg.addColorStop(0, `rgba(4, ${24 + Math.floor(audio.bass * 18)}, 12, 1)`); bg.addColorStop(1, '#020604'); ctx.fillStyle = bg; ctx.fillRect(0, 0, w, h); // Bare-metal hex dump matrix columns ctx.font = '12px "JetBrains Mono", monospace'; for (let i = 0; i < this.hexCols.length; i++) { const col = this.hexCols[i]; if (playing) { col.y = (col.y + dt * col.speed * (0.7 + audio.energy * 1.4)) % 1.2; } const x = col.xFrac * w; const baseY = (col.y - 0.1) * h; for (let row = 0; row < 5; row++) { const alpha = (1 - row / 5) * (0.14 + audio.treble * 0.22); ctx.fillStyle = `rgba(0, 255, 102, ${alpha.toFixed(3)})`; const val = ((col.seed + row * 97 + Math.floor(time * 4)) & 0xffff).toString(16).padStart(4, '0'); ctx.fillText('0x' + val, x, baseY - row * 18); } } // Scrolling kernel compilation logs (left column) ctx.font = '13px "JetBrains Mono", monospace'; const scrollIdx = Math.floor(time * (3.2 + audio.energy * 2)); const logStartY = h * 0.14; for (let i = 0; i < 14; i++) { const line = KERNEL_LOGS[(scrollIdx + i) % KERNEL_LOGS.length]; const fade = i === 13 ? 0.65 : 0.18 + (i / 14) * 0.25; ctx.fillStyle = `rgba(57, 255, 158, ${fade.toFixed(3)})`; ctx.fillText(line, 28, logStartY + i * 20); } // Audio-reactive phosphor oscilloscope behind lyrics this.drawOscilloscope(ctx, w, h, h * 0.5, audio.waveform, 'rgba(0, 255, 102, 0.55)', 2.2, 42 + audio.bass * 55); // Authentic vi editor status bar above HUD const barH = 30; const barY = h - 148; ctx.fillStyle = 'rgba(0, 255, 102, 0.14)'; ctx.fillRect(24, barY, w - 48, barH); ctx.strokeStyle = 'rgba(0, 255, 102, 0.45)'; ctx.lineWidth = 1; ctx.strokeRect(24, barY, w - 48, barH); ctx.font = 'bold 13px "JetBrains Mono", monospace'; ctx.fillStyle = '#00ff66'; const blink = Math.floor(time * 2.5) % 2 === 0 ? '█' : ' '; ctx.fillText(`:wq${blink} "kernel.c" [unix] 2048L, 65536B`, 38, barY + 19); ctx.textAlign = 'right'; ctx.fillStyle = 'rgba(0, 255, 102, 0.82)'; ctx.fillText(`-- BARE METAL -- Ln ${100 + (scrollIdx % 900)}, Col 42 100%`, w - 38, barY + 19); ctx.textAlign = 'left'; } /* ---------------------------------------------------------------------- 2. ASSEMBLY-HEAT: Amber/orange CPU registers, pointers, oscilloscope, ticker ---------------------------------------------------------------------- */ drawAssemblyHeat(ctx, w, h, dt, state) { const { time, audio } = state; // Molten silicon background const bg = ctx.createRadialGradient(w * 0.5, h * 0.5, 50, w * 0.5, h * 0.5, Math.max(w, h) * 0.8); bg.addColorStop(0, `rgba(${62 + Math.floor(audio.bass * 45)}, 22, 4, 1)`); bg.addColorStop(1, '#090402'); ctx.fillStyle = bg; ctx.fillRect(0, 0, w, h); // Subtle thermal grid ctx.strokeStyle = `rgba(255, 149, 0, ${(0.07 + audio.bass * 0.08).toFixed(3)})`; ctx.lineWidth = 1; const gridSize = 48; for (let x = 0; x < w; x += gridSize) { ctx.beginPath(); ctx.moveTo(x, 0); ctx.lineTo(x, h); ctx.stroke(); } for (let y = 0; y < h; y += gridSize) { ctx.beginPath(); ctx.moveTo(0, y); ctx.lineTo(w, y); ctx.stroke(); } // CPU Register panels (left & right) const regs = ['RAX', 'RBX', 'RCX', 'RDX', 'RSI', 'RDI', 'RSP', 'RIP']; ctx.font = 'bold 13px "JetBrains Mono", monospace'; regs.forEach((reg, idx) => { const y = h * 0.18 + idx * 28; const val = Math.floor(hash2(idx + Math.floor(time * 8)) * 0xffffffff) .toString(16) .padStart(8, '0'); const hot = (idx === Math.floor(time * 6) % regs.length) || audio.peak > 0.72; ctx.fillStyle = hot ? '#ffd166' : 'rgba(255, 149, 0, 0.58)'; ctx.fillText(`${reg} 0x00007ffe${val}`, 28, y); if (w > 900) { ctx.textAlign = 'right'; ctx.fillStyle = 'rgba(255, 90, 31, 0.55)'; const addr = (0x401000 + idx * 16).toString(16); ctx.fillText(`*ptr -> [0x${addr}] LAT: ${(0.4 + audio.mid * 0.3).toFixed(2)}ns`, w - 28, y); ctx.textAlign = 'left'; } }); // Glowing memory pointer arcs for (let i = 0; i < 4; i++) { const t = (time * 0.6 + i * 0.25) % 1; const x1 = w * 0.16; const y1 = h * (0.24 + i * 0.12); const x2 = w * 0.84; const y2 = h * (0.3 + ((i + 2) % 4) * 0.12); const cx = w * 0.5; const cy = h * 0.15 + Math.sin(time * 2 + i) * 70; ctx.strokeStyle = `rgba(255, 149, 0, ${(0.18 + audio.mid * 0.25).toFixed(3)})`; ctx.lineWidth = 1.6; ctx.beginPath(); ctx.moveTo(x1, y1); ctx.quadraticCurveTo(cx, cy, x2, y2); ctx.stroke(); // Moving pointer packet along curve const inv = 1 - t; const px = inv * inv * x1 + 2 * inv * t * cx + t * t * x2; const py = inv * inv * y1 + 2 * inv * t * cy + t * t * y2; ctx.fillStyle = '#ffd166'; ctx.beginPath(); ctx.arc(px, py, 4 + audio.bass * 3, 0, Math.PI * 2); ctx.fill(); } // Heating dual-layer oscilloscope this.drawOscilloscope(ctx, w, h, h * 0.5, audio.waveform, 'rgba(255, 59, 31, 0.45)', 5, 65 + audio.bass * 85); this.drawOscilloscope(ctx, w, h, h * 0.5, audio.waveform, 'rgba(255, 209, 102, 0.9)', 2, 55 + audio.bass * 75); // Scrolling tech industry news ticker const tickerY = h - 146; ctx.fillStyle = 'rgba(255, 90, 31, 0.2)'; ctx.fillRect(0, tickerY, w, 28); ctx.fillStyle = '#ffd166'; ctx.font = 'bold 13px "JetBrains Mono", monospace'; const tickerW = ctx.measureText(TECH_TICKER).width; const offset = (time * 110) % tickerW; ctx.fillText(TECH_TICKER, -offset, tickerY + 19); ctx.fillText(TECH_TICKER, tickerW - offset, tickerY + 19); } /* ---------------------------------------------------------------------- 3. VIBE-GLITCH: Neon magenta/cyan cyberpunk glitch, AI bubbles, flying TABs ---------------------------------------------------------------------- */ drawVibeGlitch(ctx, w, h, dt, state) { const { time, audio, playing } = state; // Electric dark violet backdrop const bg = ctx.createLinearGradient(0, 0, w, h); bg.addColorStop(0, '#0c0318'); bg.addColorStop(0.5, `rgba(${28 + Math.floor(audio.bass * 36)}, 4, 42, 1)`); bg.addColorStop(1, '#03131f'); ctx.fillStyle = bg; ctx.fillRect(0, 0, w, h); // Clean terminal grid (left) vs chaotic neon glitch (right) ctx.strokeStyle = 'rgba(0, 255, 102, 0.14)'; ctx.lineWidth = 1; for (let x = 0; x < w * 0.45; x += 40) { ctx.beginPath(); ctx.moveTo(x, 0); ctx.lineTo(x, h); ctx.stroke(); } for (let y = 0; y < h; y += 40) { ctx.beginPath(); ctx.moveTo(0, y); ctx.lineTo(w * 0.45, y); ctx.stroke(); } // Cyberpunk spectrum bars on bottom half const bins = audio.bins; const barCount = Math.min(48, bins.length); const barW = w / barCount; for (let i = 0; i < barCount; i++) { const v = bins[i] || 0; const bh = v * h * 0.34; const grad = ctx.createLinearGradient(0, h - bh, 0, h); grad.addColorStop(0, i % 2 === 0 ? 'rgba(0, 245, 255, 0.55)' : 'rgba(255, 0, 170, 0.55)'); grad.addColorStop(1, 'rgba(184, 41, 255, 0.05)'); ctx.fillStyle = grad; ctx.fillRect(i * barW + 2, h - bh, barW - 4, bh); } // Floating AI prompt bubbles ctx.font = '600 13px "JetBrains Mono", monospace'; for (let i = 0; i < this.promptBubbles.length; i++) { const b = this.promptBubbles[i]; if (playing) { b.x += b.vx * dt; b.y += b.vy * dt * (1 + audio.energy * 1.4); if (b.y < -0.08) { b.y = 1.06; b.x = 0.08 + Math.random() * 0.84; } if (b.x < 0.05 || b.x > 0.92) b.vx *= -1; } const px = b.x * w; const py = b.y * h + Math.sin(time * 2 + b.phase) * 8; const tw = ctx.measureText(b.text).width + 26; const th = 30; const pulse = 1 + audio.mid * 0.12; ctx.save(); ctx.translate(px, py); ctx.scale(pulse, pulse); ctx.fillStyle = 'rgba(255, 0, 170, 0.16)'; ctx.strokeStyle = i % 2 === 0 ? 'rgba(255, 0, 170, 0.72)' : 'rgba(0, 245, 255, 0.72)'; ctx.lineWidth = 1.5; this.roundRect(ctx, -tw / 2, -th / 2, tw, th, 15); ctx.fill(); ctx.stroke(); ctx.fillStyle = '#ffffff'; ctx.textAlign = 'center'; ctx.fillText(b.text, 0, 5); ctx.restore(); } ctx.textAlign = 'left'; // Giant pulsing flying TAB keycaps for (let i = 0; i < this.tabCaps.length; i++) { const cap = this.tabCaps[i]; if (playing) { cap.z += dt * (0.28 + audio.bass * 0.75); cap.rot += cap.vrot * dt; if (cap.z > 1.35) { cap.z = 0.15; cap.x = Math.random(); cap.y = Math.random(); } } const scale = cap.z * (1 + audio.bass * 0.35); const cx = (cap.x - 0.5) * w * cap.z * 1.4 + w * 0.5; const cy = (cap.y - 0.5) * h * cap.z * 1.4 + h * 0.5; const kw = 86 * scale; const kh = 42 * scale; const alpha = clamp(cap.z * 0.75, 0.08, 0.75); ctx.save(); ctx.translate(cx, cy); ctx.rotate(cap.rot); ctx.globalAlpha = alpha; ctx.fillStyle = 'rgba(12, 14, 30, 0.85)'; ctx.strokeStyle = i % 2 === 0 ? '#00f5ff' : '#ff00aa'; ctx.lineWidth = 2; this.roundRect(ctx, -kw / 2, -kh / 2, kw, kh, 8 * scale); ctx.fill(); ctx.stroke(); ctx.fillStyle = '#ffffff'; ctx.font = `800 ${Math.max(10, Math.floor(15 * scale))}px "JetBrains Mono", monospace`; ctx.textAlign = 'center'; ctx.fillText('TAB ⇥', 0, 5 * scale); ctx.restore(); } ctx.textAlign = 'left'; // Horizontal chromatic glitch slices on strong beats if (audio.bass > 0.58 || audio.isBeat) { const sliceCount = 4 + Math.floor(audio.bass * 6); for (let s = 0; s < sliceCount; s++) { const sy = Math.random() * h; const sh = 2 + Math.random() * 14; ctx.fillStyle = s % 2 === 0 ? 'rgba(0, 245, 255, 0.22)' : 'rgba(255, 0, 170, 0.22)'; ctx.fillRect(0, sy, w, sh); } } } /* ---------------------------------------------------------------------- 4. MANPAGE-BLOAT: man(1) pages, colliding race threads, node_modules avalanche vs core ---------------------------------------------------------------------- */ drawManpageBloat(ctx, w, h, dt, state) { const { time, audio, playing, sectionProgress } = state; ctx.fillStyle = '#090806'; ctx.fillRect(0, 0, w, h); // Retro man(1) background text ctx.font = '13px "JetBrains Mono", monospace'; ctx.fillStyle = 'rgba(255, 224, 160, 0.16)'; const manX = Math.max(24, w * 0.08); for (let i = 0; i < MAN_LINES.length; i++) { ctx.fillText(MAN_LINES[i], manX, h * 0.14 + i * 22); } // Colliding race-condition threads for (let i = 0; i < this.threads.length; i++) { const th = this.threads[i]; if (playing) { th.x += th.speed * dt * (1 + audio.energy); if (th.x > 1.05) th.x = -0.05; if (th.x < -0.05) th.x = 1.05; } const tx = th.x * w; const ty = th.y * h; const color = th.isRed ? 'rgba(255, 89, 94, 0.72)' : 'rgba(0, 245, 212, 0.72)'; ctx.strokeStyle = color; ctx.lineWidth = 2; ctx.beginPath(); ctx.moveTo(tx - (th.isRed ? 60 : -60), ty); ctx.lineTo(tx, ty); ctx.stroke(); ctx.fillStyle = color; ctx.beginPath(); ctx.arc(tx, ty, 3.5, 0, Math.PI * 2); ctx.fill(); } // Exploding node_modules treemap boxes piling up around edges const bloatIntensity = clamp(0.25 + sectionProgress * 0.95, 0.25, 1); ctx.font = '600 11px "JetBrains Mono", monospace'; for (let i = 0; i < this.bloatBoxes.length; i++) { const b = this.bloatBoxes[i]; if (bloatIntensity < b.delay * 0.85) continue; const pop = clamp((bloatIntensity - b.delay * 0.85) * 4, 0, 1); const bx = b.x * w; const by = b.y * h + Math.sin(time * 2 + i) * 4; const bw = b.w * w * pop; const bh = b.h * h * pop; ctx.fillStyle = `hsla(${b.hue}, 82%, 48%, ${(0.16 + audio.bass * 0.14).toFixed(3)})`; ctx.strokeStyle = `hsla(${b.hue}, 90%, 62%, 0.65)`; ctx.lineWidth = 1.2; ctx.fillRect(bx, by, bw, bh); ctx.strokeRect(bx, by, bw, bh); if (bw > 68) { ctx.fillStyle = 'rgba(255, 240, 210, 0.82)'; ctx.fillText(b.name, bx + 6, by + 16); } } // Glowing single-file clean core in the center const coreR = 54 + audio.bass * 18; const cx = w * 0.5; const cy = h * 0.5; const glow = ctx.createRadialGradient(cx, cy, 8, cx, cy, coreR * 2.2); glow.addColorStop(0, 'rgba(0, 255, 160, 0.36)'); glow.addColorStop(0.5, 'rgba(255, 209, 102, 0.14)'); glow.addColorStop(1, 'rgba(0, 0, 0, 0)'); ctx.fillStyle = glow; ctx.beginPath(); ctx.arc(cx, cy, coreR * 2.2, 0, Math.PI * 2); ctx.fill(); ctx.strokeStyle = '#ffd166'; ctx.lineWidth = 2; ctx.beginPath(); ctx.arc(cx, cy, coreR, 0, Math.PI * 2); ctx.stroke(); ctx.fillStyle = '#ffd166'; ctx.font = 'bold 12px "JetBrains Mono", monospace'; ctx.textAlign = 'center'; ctx.fillText('main.c • 0 DEPS', cx, cy + coreR + 18); ctx.textAlign = 'left'; } /* ---------------------------------------------------------------------- 5. SYNTH-ARP: Indigo/violet synthwave sun, horizon grid, PASS 100%, constellations ---------------------------------------------------------------------- */ drawSynthArp(ctx, w, h, dt, state) { const { time, audio, playing } = state; const horizonY = h * 0.56; // Deep indigo/violet sky gradient const sky = ctx.createLinearGradient(0, 0, 0, horizonY); sky.addColorStop(0, '#060318'); sky.addColorStop(0.6, '#1c0b47'); sky.addColorStop(1, '#4c146c'); ctx.fillStyle = sky; ctx.fillRect(0, 0, w, horizonY); // Ground void const ground = ctx.createLinearGradient(0, horizonY, 0, h); ground.addColorStop(0, '#19083a'); ground.addColorStop(1, '#05020d'); ctx.fillStyle = ground; ctx.fillRect(0, horizonY, w, h - horizonY); // Twinkling stars for (let i = 0; i < this.stars.length; i++) { const st = this.stars[i]; const a = 0.35 + 0.55 * Math.sin(time * 2.2 + st.twinkle); ctx.fillStyle = `rgba(220, 235, 255, ${a.toFixed(3)})`; ctx.beginPath(); ctx.arc(st.x * w, st.y * h, st.r, 0, Math.PI * 2); ctx.fill(); } // Neural + code bracket constellations in upper sky ctx.strokeStyle = 'rgba(0, 245, 212, 0.24)'; ctx.lineWidth = 1; for (let i = 0; i < this.constellation.length; i++) { const n = this.constellation[i]; if (playing) { n.x += n.vx * dt; n.y += n.vy * dt; if (n.x < 0.05 || n.x > 0.95) n.vx *= -1; if (n.y < 0.08 || n.y > 0.44) n.vy *= -1; } if (i > 0) { const prev = this.constellation[i - 1]; ctx.beginPath(); ctx.moveTo(prev.x * w, prev.y * h); ctx.lineTo(n.x * w, n.y * h); ctx.stroke(); } } ctx.font = 'bold 12px "JetBrains Mono", monospace'; ctx.textAlign = 'center'; for (let i = 0; i < this.constellation.length; i++) { const n = this.constellation[i]; const nx = n.x * w; const ny = n.y * h; ctx.fillStyle = '#00f5d4'; ctx.beginPath(); ctx.arc(nx, ny, 3 + audio.treble * 2.5, 0, Math.PI * 2); ctx.fill(); ctx.fillStyle = 'rgba(200, 255, 245, 0.72)'; ctx.fillText(n.glyph, nx, ny - 9); } // Retro synthwave sun with horizontal cutouts const sunR = Math.min(w, h) * 0.17 + audio.bass * 14; const sunX = w * 0.5; const sunY = horizonY - sunR * 0.25; const sunGrad = ctx.createLinearGradient(sunX, sunY - sunR, sunX, sunY + sunR); sunGrad.addColorStop(0, '#ffe066'); sunGrad.addColorStop(0.5, '#ff5e9c'); sunGrad.addColorStop(1, '#7b2cbf'); ctx.save(); ctx.beginPath(); ctx.arc(sunX, sunY, sunR, 0, Math.PI * 2); ctx.clip(); ctx.fillStyle = sunGrad; ctx.fillRect(sunX - sunR, sunY - sunR, sunR * 2, sunR * 2); // Horizontal retro sun scanline bands ctx.fillStyle = '#1c0b47'; for (let i = 0; i < 6; i++) { const bandY = sunY + sunR * (0.05 + i * 0.15); const bandH = 2.5 + i * 2.1; ctx.fillRect(sunX - sunR, bandY, sunR * 2, bandH); } ctx.restore(); // Perspective synthwave horizon grid ctx.strokeStyle = `rgba(0, 245, 212, ${(0.32 + audio.mid * 0.3).toFixed(3)})`; ctx.lineWidth = 1.2; // Horizon glow line ctx.beginPath(); ctx.moveTo(0, horizonY); ctx.lineTo(w, horizonY); ctx.stroke(); // Radial perspective verticals const cols = 18; for (let i = -cols; i <= cols; i++) { const bx = w * 0.5 + (i / cols) * w * 1.45; ctx.beginPath(); ctx.moveTo(w * 0.5 + i * 16, horizonY); ctx.lineTo(bx, h); ctx.stroke(); } // Moving horizontal depth lines const gridSpeed = (time * 0.55) % 1; for (let i = 0; i < 12; i++) { const p = ((i + gridSpeed) / 12); const y = horizonY + Math.pow(p, 2.1) * (h - horizonY); ctx.beginPath(); ctx.moveTo(0, y); ctx.lineTo(w, y); ctx.stroke(); } // Floating green unit test checkmarks (PASS 100%) ctx.font = 'bold 13px "JetBrains Mono", monospace'; for (let i = 0; i < this.testBadges.length; i++) { const tb = this.testBadges[i]; if (playing) { tb.y += tb.vy * dt; if (tb.y < 0.06) { tb.y = 0.92; tb.x = 0.08 + Math.random() * 0.84; } } const bx = tb.x * w; const by = tb.y * h; ctx.fillStyle = 'rgba(0, 255, 136, 0.14)'; ctx.strokeStyle = 'rgba(0, 255, 136, 0.65)'; this.roundRect(ctx, bx - 56, by - 13, 112, 24, 12); ctx.fill(); ctx.stroke(); ctx.fillStyle = '#00ff88'; ctx.fillText(tb.label, bx, by + 4); } ctx.textAlign = 'left'; } /* ---------------------------------------------------------------------- 6. MECH-140WPM: Blistering 140 WPM mechanical keyboard, sparks, WPM counter, EQ ---------------------------------------------------------------------- */ drawMech140Wpm(ctx, w, h, dt, state) { const { time, audio, playing } = state; // High-energy dark steel backdrop const bg = ctx.createRadialGradient(w * 0.5, h * 0.62, 40, w * 0.5, h * 0.55, Math.max(w, h) * 0.78); bg.addColorStop(0, `rgba(0, ${42 + Math.floor(audio.bass * 40)}, 68, 1)`); bg.addColorStop(1, '#04060d'); ctx.fillStyle = bg; ctx.fillRect(0, 0, w, h); // Full-width audio-reactive equalizer behind the keyboard const bins = audio.bins; const eqCount = Math.min(44, bins.length); const eqW = w / eqCount; for (let i = 0; i < eqCount; i++) { const val = bins[i] || 0; const eh = val * h * 0.42; const grad = ctx.createLinearGradient(0, h * 0.55 - eh, 0, h * 0.55); grad.addColorStop(0, 'rgba(255, 107, 0, 0.75)'); grad.addColorStop(0.5, 'rgba(0, 229, 255, 0.55)'); grad.addColorStop(1, 'rgba(0, 229, 255, 0.04)'); ctx.fillStyle = grad; ctx.fillRect(i * eqW + 3, h * 0.55 - eh, eqW - 6, eh); } // Keyboard bounding box (lower-center hero placement) const kbW = Math.min(w * 0.86, 860); const kbH = Math.min(h * 0.36, 265); const kbX = (w - kbW) * 0.5; const kbY = Math.max(h * 0.44, h - kbH - 148); const pad = 12; // Trigger rapid-fire 140+ WPM keystrokes (~12-16 keys/sec) if (playing) { const keysPerSec = 11.5 + audio.energy * 9; this.keystrokeAcc += dt * keysPerSec; while (this.keystrokeAcc >= 1) { this.keystrokeAcc -= 1; const idx = Math.floor(Math.random() * this.keys.length); const k = this.keys[idx]; k.heat = 1; k.press = 1; // Spawn glowing sparks from struck key const kx = kbX + pad + (k.xNorm + k.wNorm * 0.5) * (kbW - pad * 2); const ky = kbY + pad + ((k.row + 0.5) / KB_ROWS.length) * (kbH - pad * 2); for (let s = 0; s < 5; s++) { const ang = -Math.PI * 0.15 - Math.random() * Math.PI * 0.7; const spd = 90 + Math.random() * 220; this.sparks.push({ x: kx, y: ky, vx: Math.cos(ang) * spd, vy: Math.sin(ang) * spd - 40, life: 1, color: Math.random() > 0.4 ? '#00e5ff' : '#ff6b00' }); } } this.wpmDisplay = lerp(this.wpmDisplay, 138 + audio.energy * 18 + Math.sin(time * 7) * 4, dt * 6); } // Keyboard aluminum chassis ctx.fillStyle = 'rgba(10, 14, 24, 0.94)'; ctx.strokeStyle = 'rgba(0, 229, 255, 0.55)'; ctx.lineWidth = 2; this.roundRect(ctx, kbX, kbY, kbW, kbH, 14); ctx.fill(); ctx.stroke(); // Draw every keycap const innerW = kbW - pad * 2; const innerH = kbH - pad * 2; const rowH = innerH / KB_ROWS.length; const gap = 4; ctx.textAlign = 'center'; for (let i = 0; i < this.keys.length; i++) { const k = this.keys[i]; k.heat = Math.max(0, k.heat - dt * 3.4); k.press = Math.max(0, k.press - dt * 9.0); const kx = kbX + pad + k.xNorm * innerW + gap * 0.5; const ky = kbY + pad + k.row * rowH + gap * 0.5 + k.press * 3; const kw = k.wNorm * innerW - gap; const kh = rowH - gap - k.press * 2; const isSpecial = k.label === 'ESC*' || k.label === 'ESC' || k.label === 'ENTER'; if (k.heat > 0.05) { ctx.fillStyle = k.heat > 0.55 ? `rgba(255, 107, 0, ${(0.35 + k.heat * 0.65).toFixed(3)})` : `rgba(0, 229, 255, ${(0.22 + k.heat * 0.72).toFixed(3)})`; ctx.strokeStyle = k.heat > 0.55 ? '#ffd166' : '#00e5ff'; } else { ctx.fillStyle = isSpecial ? 'rgba(255, 42, 85, 0.18)' : 'rgba(24, 30, 44, 0.92)'; ctx.strokeStyle = isSpecial ? 'rgba(255, 42, 85, 0.55)' : 'rgba(255, 255, 255, 0.14)'; } ctx.lineWidth = 1.2; this.roundRect(ctx, kx, ky, kw, kh, 6); ctx.fill(); ctx.stroke(); ctx.fillStyle = k.heat > 0.4 ? '#ffffff' : 'rgba(220, 235, 255, 0.75)'; ctx.font = `700 ${Math.max(9, Math.floor(kbW / 72))}px "JetBrains Mono", monospace`; ctx.fillText(k.label, kx + kw * 0.5, ky + kh * 0.6); } // Render flying mechanical sparks (preserve crossfade globalAlpha) ctx.save(); const baseAlpha = ctx.globalAlpha; for (let i = this.sparks.length - 1; i >= 0; i--) { const sp = this.sparks[i]; sp.x += sp.vx * dt; sp.y += sp.vy * dt; sp.vy += 420 * dt; sp.life -= dt * 2.2; if (sp.life <= 0) { this.sparks.splice(i, 1); continue; } ctx.fillStyle = sp.color; ctx.globalAlpha = baseAlpha * sp.life; ctx.beginPath(); ctx.arc(sp.x, sp.y, 2.2 * sp.life + 0.8, 0, Math.PI * 2); ctx.fill(); } ctx.restore(); // Giant WPM telemetry readout above keyboard const wpmY = kbY - 22; ctx.font = '800 28px "JetBrains Mono", monospace'; ctx.fillStyle = '#00e5ff'; ctx.fillText(`${Math.round(this.wpmDisplay)} WPM`, w * 0.5, wpmY); ctx.font = '600 11px "JetBrains Mono", monospace'; ctx.fillStyle = 'rgba(255, 175, 90, 0.88)'; ctx.fillText('MECHANICAL CHERRY MX BLUE // AUDIO PEAK OVERDRIVE', w * 0.5, wpmY + 16); ctx.textAlign = 'left'; } /* ---------------------------------------------------------------------- 7. ROOT-MICDROP: Stark root # spotlight, CAPS LOCK -> ESC, :q! & CRT power-off ---------------------------------------------------------------------- */ drawRootMicdrop(ctx, w, h, dt, state) { const { time, duration, audio, sectionProgress, currentLineText, quitLine } = state; const lineLower = (currentLineText || '').toLowerCase(); // Stark high-contrast obsidian spotlight const bg = ctx.createRadialGradient(w * 0.5, h * 0.45, 20, w * 0.5, h * 0.5, Math.max(w, h) * 0.65); bg.addColorStop(0, `rgba(${28 + Math.floor(audio.bass * 36)}, 6, 12, 1)`); bg.addColorStop(1, '#020203'); ctx.fillStyle = bg; ctx.fillRect(0, 0, w, h); // Giant watermark root `#` prompt in background ctx.save(); ctx.font = `800 ${Math.floor(Math.min(w, h) * 0.44)}px "JetBrains Mono", monospace`; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; ctx.fillStyle = `rgba(255, 42, 85, ${(0.06 + audio.bass * 0.08).toFixed(3)})`; ctx.fillText('#', w * 0.5, h * 0.46); ctx.restore(); // Determine `:q!` mic-drop timing dynamically from MUSIC_VIDEO_DATA when available const isQuitMoment = lineLower.includes(':q!') || lineLower.includes('mic drop') || (quitLine ? time >= quitLine.start - 0.15 : sectionProgress > 0.72); // CAPS LOCK -> ESC keycap remap graphic (prominent until `:q!` starts) const showRemap = !isQuitMoment && (lineLower.includes('caps') || lineLower.includes('esc') || sectionProgress < 0.65); if (showRemap) { const y = h * 0.23; const pulse = 1 + audio.bass * 0.08; ctx.save(); ctx.translate(w * 0.5, y); ctx.scale(pulse, pulse); // CAPS LOCK keycap (crossed/dimmed) ctx.fillStyle = 'rgba(255, 255, 255, 0.07)'; ctx.strokeStyle = 'rgba(255, 255, 255, 0.35)'; ctx.lineWidth = 2; this.roundRect(ctx, -175, -24, 130, 48, 8); ctx.fill(); ctx.stroke(); ctx.fillStyle = 'rgba(255, 255, 255, 0.55)'; ctx.font = '700 15px "JetBrains Mono", monospace'; ctx.textAlign = 'center'; ctx.fillText('CAPS LOCK', -110, 5); // Glowing remap arrow ctx.fillStyle = '#ff2a55'; ctx.font = '800 22px "JetBrains Mono", monospace'; ctx.fillText('⟶', -12, 7); // ESC keycap (bright highlighted) ctx.fillStyle = 'rgba(255, 42, 85, 0.28)'; ctx.strokeStyle = '#ff2a55'; ctx.lineWidth = 2.5; this.roundRect(ctx, 22, -24, 110, 48, 8); ctx.fill(); ctx.stroke(); ctx.fillStyle = '#ffffff'; ctx.font = '800 18px "JetBrains Mono", monospace'; ctx.fillText('ESC', 77, 6); ctx.restore(); } // Dramatic `:q!` typed out + mic-drop shockwave near the end if (isQuitMoment) { let quitPhase; let chars; let shockP = 0; let offP = 0; if (quitLine) { const qStart = quitLine.start; const qEnd = Math.max(qStart + 0.8, quitLine.end); const qDur = qEnd - qStart; const elapsed = time - qStart; quitPhase = clamp(elapsed / Math.max(1.5, (duration || qEnd + 2.5) - qStart), 0, 1); chars = elapsed < qDur * 0.22 ? ':' : elapsed < qDur * 0.45 ? ':q' : ':q!'; if (elapsed > qDur * 0.48) { shockP = clamp((elapsed - qDur * 0.48) / Math.max(0.8, qDur * 0.75), 0, 1); } const offStart = qEnd + 0.25; const offEnd = Math.max(offStart + 0.8, (duration || offStart + 2.0) - 0.15); if (time > offStart) { offP = clamp((time - offStart) / (offEnd - offStart), 0, 1); } } else { quitPhase = clamp((sectionProgress - 0.72) / 0.28, 0, 1); chars = quitPhase < 0.15 ? ':' : quitPhase < 0.3 ? ':q' : ':q!'; if (quitPhase > 0.35) shockP = clamp((quitPhase - 0.35) / 0.45, 0, 1); if (quitPhase > 0.78) offP = clamp((quitPhase - 0.78) / 0.22, 0, 1); } const y = h * 0.72; ctx.save(); ctx.textAlign = 'center'; ctx.font = '800 44px "JetBrains Mono", monospace'; ctx.fillStyle = '#ffffff'; ctx.shadowColor = '#ff2a55'; ctx.shadowBlur = 24; ctx.fillText(`root@metal:~# ${chars}${Math.floor(time * 4) % 2 === 0 ? '█' : ''}`, w * 0.5, y); ctx.restore(); // Mic-drop shockwave rings if (shockP > 0 && shockP < 1) { const radius = shockP * Math.max(w, h) * 0.62; ctx.strokeStyle = `rgba(255, 42, 85, ${(1 - shockP).toFixed(3)})`; ctx.lineWidth = 4 * (1 - shockP) + 1; ctx.beginPath(); ctx.arc(w * 0.5, h * 0.5, radius, 0, Math.PI * 2); ctx.stroke(); } // Authentic CRT TV horizontal-line power-off collapse on the final beat! if (offP > 0) { // Closing black shutters top & bottom const openH = Math.max(2, (1 - offP) * h); const shutH = (h - openH) * 0.5; ctx.fillStyle = '#000000'; ctx.fillRect(0, 0, w, shutH); ctx.fillRect(0, h - shutH, w, shutH); // Bright phosphor horizontal collapse line -> center dot const lineW = offP < 0.7 ? w : w * (1 - (offP - 0.7) / 0.3); const alpha = offP < 0.88 ? 0.95 : (1 - offP) / 0.12; ctx.fillStyle = `rgba(255, 255, 255, ${clamp(alpha, 0, 1).toFixed(3)})`; ctx.fillRect((w - lineW) * 0.5, h * 0.5 - 2, Math.max(6, lineW), 4); } } } /* ---------------------------------------------------------------------- Shared Drawing Helpers ---------------------------------------------------------------------- */ drawOscilloscope(ctx, w, h, centerY, waveform, color, lineWidth, amp) { if (!waveform || waveform.length === 0) return; ctx.save(); ctx.strokeStyle = color; ctx.lineWidth = lineWidth; ctx.beginPath(); const len = waveform.length; for (let i = 0; i < len; i++) { const x = (i / (len - 1)) * w; const y = centerY + waveform[i] * amp; if (i === 0) ctx.moveTo(x, y); else ctx.lineTo(x, y); } ctx.stroke(); ctx.restore(); } roundRect(ctx, x, y, w, h, r) { const radius = Math.min(r, w * 0.5, h * 0.5); ctx.beginPath(); ctx.moveTo(x + radius, y); ctx.arcTo(x + w, y, x + w, y + h, radius); ctx.arcTo(x + w, y + h, x, y + h, radius); ctx.arcTo(x, y + h, x, y, radius); ctx.arcTo(x, y, x + w, y, radius); ctx.closePath(); } } global.SceneEngine = SceneEngine; })(window);