// Spelling Bee art — "The Apiary at Golden Hour", baked to canvases (no new // image files; the honeycomb photo backdrop and intro clip are the only assets). // // bee-cell a beeswax comb cell (the six outer letters) // bee-cell-center the honey-glazed center cell // bee-cell-shadow soft drop shadow under a cell // bee-body a little bee (body, stripes, eye) — wings are separate // bee-wing one translucent wing (flapped by scaleY) // bee-jar the glass honey jar (rank meter); honey is drawn under it // bee-ledger the beekeeper's ledger page (found words) // bee-card a parchment card (start screen + overlays) // bee-vignette warm golden-hour vignette over the backdrop // bee-glow soft round glow (pangram light, motes) // bee-drip a honey drop // // Also exports layout constants, the palette, HiveButton (a wax-tag button) // and playBuzz (a short synthesised buzz). import * as Phaser from 'phaser'; import { canvas, rr, noisePattern } from '../../ui/casino/CasinoArt.js'; // ── Layout ──────────────────────────────────────────────────────────────────── export const W = 1920, H = 1080; export const HIVE = { x: 640, y: 600 }; export const HEX_R = 92; // center-to-vertex export const HEX_D = Math.round(HEX_R * Math.sqrt(3)) + 6; // center-to-center (+ wax gap) export const INPUT_Y = 290; export const FEEDBACK_Y = 222; export const CONTROLS_Y = 930; export const JAR = { x: 150, top: 380, w: 168, h: 400 }; // glass body; neck + lid above export const LEDGER = { x: 1140, y: 40, w: 740, h: 960 }; export const LEDGER_LIST = { x: LEDGER.x + 56, y: LEDGER.y + 236, w: LEDGER.w - 100, h: 520 }; export const LEDGER_BONUS_Y = LEDGER.y + 790; // ── Palette ─────────────────────────────────────────────────────────────────── export const SERIF = 'Georgia, "Times New Roman", "Liberation Serif", "DejaVu Serif", serif'; export const HONEY = 0xf2b632; export const HONEY_DEEP = 0xc77d0e; export const WAX = 0xf6dfa0; export const INK = '#3a2611'; // ledger ink (brown) export const INK_N = 0x3a2611; export const FADED = '#8a6d45'; export const GOLD = '#f2c14e'; export const CREAM = '#fff4d6'; export const GOOD = '#5e9c3c'; export const BAD = '#c2452d'; export const BAD_N = 0xc2452d; function hexPath(ctx, cx, cy, r) { ctx.beginPath(); for (let i = 0; i < 6; i++) { const a = (Math.PI / 180) * (60 * i - 90); const x = cx + Math.cos(a) * r, y = cy + Math.sin(a) * r; if (i === 0) ctx.moveTo(x, y); else ctx.lineTo(x, y); } ctx.closePath(); } // ── Cells ───────────────────────────────────────────────────────────────────── function bakeCell(scene, key, center) { const pad = 10, S = (HEX_R + pad) * 2; const c = canvas(S, S), ctx = c.getContext('2d'); const cx = S / 2, cy = S / 2; // Rim: a darker wax wall. hexPath(ctx, cx, cy, HEX_R); const rim = ctx.createLinearGradient(0, cy - HEX_R, 0, cy + HEX_R); if (center) { rim.addColorStop(0, '#f7c64a'); rim.addColorStop(1, '#8f5208'); } else { rim.addColorStop(0, '#fbe7b0'); rim.addColorStop(1, '#b88a3a'); } ctx.fillStyle = rim; ctx.fill(); // Face: inset hex with a radial body. const inner = HEX_R - 9; hexPath(ctx, cx, cy, inner); const face = ctx.createRadialGradient(cx - 18, cy - 26, 6, cx, cy, inner * 1.05); if (center) { face.addColorStop(0, '#ffe08a'); face.addColorStop(0.45, '#f5ad22'); face.addColorStop(1, '#c46f05'); } else { face.addColorStop(0, '#fff6da'); face.addColorStop(0.55, '#f4dc9c'); face.addColorStop(1, '#d9b468'); } ctx.fillStyle = face; ctx.fill(); // Faint wax grain. ctx.save(); hexPath(ctx, cx, cy, inner); ctx.clip(); ctx.fillStyle = noisePattern(ctx, 96, center ? 18 : 26); ctx.fillRect(0, 0, S, S); // Tiny ghost comb pattern on the wax cells only. if (!center) { ctx.strokeStyle = 'rgba(150,105,40,0.10)'; ctx.lineWidth = 1.5; for (let gy = -2; gy < 8; gy++) { for (let gx = -2; gx < 8; gx++) { const hx = gx * 26 + (gy % 2) * 13, hy = gy * 22.5; hexPath(ctx, hx, hy, 13); ctx.stroke(); } } } // Inner shadow along the lower edge. const sh = ctx.createLinearGradient(0, cy, 0, cy + inner); sh.addColorStop(0, 'rgba(0,0,0,0)'); sh.addColorStop(1, center ? 'rgba(90,40,0,0.35)' : 'rgba(110,70,10,0.25)'); ctx.fillStyle = sh; ctx.fillRect(0, cy, S, inner); ctx.restore(); // Gloss: an arc of light across the top. ctx.save(); hexPath(ctx, cx, cy, inner - 4); ctx.clip(); const gloss = ctx.createLinearGradient(0, cy - inner, 0, cy - inner * 0.15); gloss.addColorStop(0, `rgba(255,255,255,${center ? 0.55 : 0.45})`); gloss.addColorStop(1, 'rgba(255,255,255,0)'); ctx.fillStyle = gloss; ctx.beginPath(); ctx.ellipse(cx - 8, cy - inner * 0.55, inner * 0.8, inner * 0.42, -0.12, 0, Math.PI * 2); ctx.fill(); ctx.restore(); // Crisp outline. hexPath(ctx, cx, cy, HEX_R - 1); ctx.lineWidth = 2; ctx.strokeStyle = center ? 'rgba(110,55,0,0.85)' : 'rgba(140,100,40,0.8)'; ctx.stroke(); scene.textures.addCanvas(key, c); } function bakeCellShadow(scene) { const S = (HEX_R + 30) * 2; const c = canvas(S, S), ctx = c.getContext('2d'); ctx.filter = 'blur(10px)'; hexPath(ctx, S / 2, S / 2, HEX_R); ctx.fillStyle = 'rgba(30,14,0,0.55)'; ctx.fill(); scene.textures.addCanvas('bee-cell-shadow', c); } // ── Bee ─────────────────────────────────────────────────────────────────────── function bakeBee(scene) { // Body, facing right, 64×44. const c = canvas(64, 44), ctx = c.getContext('2d'); // Stinger ctx.fillStyle = '#2a1a08'; ctx.beginPath(); ctx.moveTo(6, 22); ctx.lineTo(14, 18); ctx.lineTo(14, 26); ctx.closePath(); ctx.fill(); // Abdomen with stripes (clipped). ctx.save(); ctx.beginPath(); ctx.ellipse(28, 22, 18, 14, 0, 0, Math.PI * 2); ctx.clip(); const body = ctx.createRadialGradient(24, 15, 2, 28, 22, 20); body.addColorStop(0, '#ffe27a'); body.addColorStop(1, '#e9a512'); ctx.fillStyle = body; ctx.fillRect(0, 0, 64, 44); ctx.fillStyle = '#2b1c0b'; for (const x of [17, 27, 37]) ctx.fillRect(x, 0, 5, 44); ctx.restore(); // Fuzz outline ctx.strokeStyle = 'rgba(80,50,10,0.6)'; ctx.lineWidth = 1.5; ctx.beginPath(); ctx.ellipse(28, 22, 18, 14, 0, 0, Math.PI * 2); ctx.stroke(); // Head ctx.fillStyle = '#2b1c0b'; ctx.beginPath(); ctx.arc(50, 21, 9, 0, Math.PI * 2); ctx.fill(); ctx.fillStyle = '#ffffff'; ctx.beginPath(); ctx.arc(53, 18, 2.6, 0, Math.PI * 2); ctx.fill(); // Antennae ctx.strokeStyle = '#2b1c0b'; ctx.lineWidth = 1.6; ctx.beginPath(); ctx.moveTo(53, 13); ctx.quadraticCurveTo(57, 4, 62, 5); ctx.stroke(); ctx.beginPath(); ctx.moveTo(50, 12); ctx.quadraticCurveTo(51, 3, 56, 1); ctx.stroke(); scene.textures.addCanvas('bee-body', c); // Wing, 34×22, anchored at its left-bottom. const w = canvas(34, 22), wx = w.getContext('2d'); wx.fillStyle = 'rgba(235,245,255,0.62)'; wx.strokeStyle = 'rgba(120,140,160,0.75)'; wx.lineWidth = 1.2; wx.beginPath(); wx.ellipse(17, 11, 16, 9.5, -0.25, 0, Math.PI * 2); wx.fill(); wx.stroke(); wx.strokeStyle = 'rgba(120,140,160,0.35)'; wx.beginPath(); wx.moveTo(4, 15); wx.lineTo(28, 7); wx.stroke(); scene.textures.addCanvas('bee-wing', w); } // ── Jar ─────────────────────────────────────────────────────────────────────── // The jar body's interior rectangle in scene coords (for the honey fill). export function jarInterior(inset = 6) { return { x: JAR.x - JAR.w / 2 + inset, y: JAR.top + inset, w: JAR.w - inset * 2, h: JAR.h - inset * 2, r: 34 - inset }; } function bakeJar(scene) { const pad = 20, neck = 46, lid = 34; const Wc = JAR.w + pad * 2, Hc = JAR.h + neck + lid + pad * 2; const c = canvas(Wc, Hc), ctx = c.getContext('2d'); const bx = pad, by = pad + lid + neck, bw = JAR.w, bh = JAR.h; // Lid: wooden cap with a gingham cloth. ctx.fillStyle = '#7a4a1e'; rr(ctx, bx + 18, pad + 6, bw - 36, lid, 8); ctx.fill(); ctx.fillStyle = 'rgba(255,255,255,0.18)'; rr(ctx, bx + 22, pad + 9, bw - 44, 8, 4); ctx.fill(); ctx.save(); rr(ctx, bx + 4, pad + lid - 2, bw - 8, 26, 10); ctx.clip(); ctx.fillStyle = '#f3ead8'; ctx.fillRect(bx, pad + lid - 2, bw, 26); ctx.fillStyle = 'rgba(196,58,42,0.55)'; for (let x = bx; x < bx + bw; x += 16) ctx.fillRect(x, pad + lid - 2, 8, 26); for (let y = pad + lid - 2; y < pad + lid + 24; y += 16) ctx.fillRect(bx, y, bw, 8); ctx.restore(); // twine ctx.strokeStyle = '#9b7a46'; ctx.lineWidth = 3; ctx.beginPath(); ctx.moveTo(bx + 14, pad + lid + 22); ctx.lineTo(bx + bw - 14, pad + lid + 22); ctx.stroke(); // Neck + body glass. ctx.save(); ctx.beginPath(); rr(ctx, bx + 24, pad + lid + 20, bw - 48, neck - 10, 6); ctx.fillStyle = 'rgba(255,255,255,0.10)'; ctx.fill(); ctx.strokeStyle = 'rgba(255,255,255,0.55)'; ctx.lineWidth = 2.5; ctx.stroke(); ctx.restore(); rr(ctx, bx, by, bw, bh, 34); ctx.fillStyle = 'rgba(255,255,255,0.08)'; ctx.fill(); ctx.lineWidth = 4; ctx.strokeStyle = 'rgba(255,255,255,0.6)'; ctx.stroke(); ctx.lineWidth = 1.5; ctx.strokeStyle = 'rgba(90,60,20,0.5)'; rr(ctx, bx + 3, by + 3, bw - 6, bh - 6, 31); ctx.stroke(); // Glass highlights. const hl = ctx.createLinearGradient(bx, 0, bx + bw, 0); hl.addColorStop(0, 'rgba(255,255,255,0.0)'); hl.addColorStop(0.12, 'rgba(255,255,255,0.42)'); hl.addColorStop(0.2, 'rgba(255,255,255,0.0)'); hl.addColorStop(0.82, 'rgba(255,255,255,0.0)'); hl.addColorStop(0.9, 'rgba(255,255,255,0.22)'); hl.addColorStop(1, 'rgba(255,255,255,0.0)'); ctx.fillStyle = hl; rr(ctx, bx + 6, by + 10, bw - 12, bh - 20, 28); ctx.fill(); // Paper label. const ly = by + bh * 0.58, lh = 88; ctx.fillStyle = '#f4e6c4'; rr(ctx, bx + 14, ly, bw - 28, lh, 6); ctx.fill(); ctx.strokeStyle = 'rgba(90,60,20,0.55)'; ctx.lineWidth = 1.5; rr(ctx, bx + 19, ly + 5, bw - 38, lh - 10, 4); ctx.stroke(); scene.textures.addCanvas('bee-jar', c); } export const JAR_TEX = { padX: 20, padTop: 20 + 34 + 46 }; // body top-left inside the texture export const JAR_LABEL_Y = JAR.top + JAR.h * 0.58 + 44; // centre of the paper label // ── Paper (ledger + cards) ──────────────────────────────────────────────────── function paperFill(ctx, x, y, w, h, r) { rr(ctx, x, y, w, h, r); const g = ctx.createLinearGradient(x, y, x + w * 0.3, y + h); g.addColorStop(0, '#fbf1d8'); g.addColorStop(1, '#efdcb0'); ctx.fillStyle = g; ctx.fill(); ctx.save(); rr(ctx, x, y, w, h, r); ctx.clip(); ctx.fillStyle = noisePattern(ctx, 128, 22); ctx.fillRect(x, y, w, h); // edge darkening const e = ctx.createRadialGradient(x + w / 2, y + h / 2, Math.min(w, h) * 0.35, x + w / 2, y + h / 2, Math.max(w, h) * 0.75); e.addColorStop(0, 'rgba(120,80,20,0)'); e.addColorStop(1, 'rgba(120,80,20,0.22)'); ctx.fillStyle = e; ctx.fillRect(x, y, w, h); ctx.restore(); } function honeyRing(ctx, x, y, r) { ctx.save(); ctx.strokeStyle = 'rgba(200,130,20,0.16)'; ctx.lineWidth = 7; ctx.beginPath(); ctx.arc(x, y, r, 0.3, Math.PI * 1.85); ctx.stroke(); ctx.strokeStyle = 'rgba(200,130,20,0.09)'; ctx.lineWidth = 3; ctx.beginPath(); ctx.arc(x + 2, y + 1, r - 6, 0, Math.PI * 2); ctx.stroke(); ctx.restore(); } function bakeLedger(scene) { const pad = 18; const c = canvas(LEDGER.w + pad * 2, LEDGER.h + pad * 2), ctx = c.getContext('2d'); ctx.filter = 'blur(12px)'; ctx.fillStyle = 'rgba(20,10,0,0.55)'; rr(ctx, pad + 6, pad + 12, LEDGER.w, LEDGER.h, 14); ctx.fill(); ctx.filter = 'none'; paperFill(ctx, pad, pad, LEDGER.w, LEDGER.h, 12); // Ruled lines for the word list + a red margin. const lx = pad + 40, top = pad + 236 - 18; ctx.strokeStyle = 'rgba(80,120,170,0.18)'; ctx.lineWidth = 1; for (let y = top; y < pad + LEDGER.h - 30; y += 30) { ctx.beginPath(); ctx.moveTo(pad + 16, y); ctx.lineTo(pad + LEDGER.w - 16, y); ctx.stroke(); } ctx.strokeStyle = 'rgba(190,60,50,0.35)'; ctx.lineWidth = 1.5; ctx.beginPath(); ctx.moveTo(lx, pad + 16); ctx.lineTo(lx, pad + LEDGER.h - 16); ctx.stroke(); // Header rule. ctx.strokeStyle = 'rgba(58,38,17,0.6)'; ctx.lineWidth = 2; ctx.beginPath(); ctx.moveTo(pad + 30, pad + 176); ctx.lineTo(pad + LEDGER.w - 30, pad + 176); ctx.stroke(); ctx.lineWidth = 1; ctx.beginPath(); ctx.moveTo(pad + 30, pad + 181); ctx.lineTo(pad + LEDGER.w - 30, pad + 181); ctx.stroke(); // Rare finds rule. const by = pad + (LEDGER_BONUS_Y - LEDGER.y) - 14; ctx.setLineDash([6, 5]); ctx.strokeStyle = 'rgba(58,38,17,0.45)'; ctx.beginPath(); ctx.moveTo(pad + 30, by); ctx.lineTo(pad + LEDGER.w - 30, by); ctx.stroke(); ctx.setLineDash([]); honeyRing(ctx, pad + LEDGER.w - 120, pad + LEDGER.h - 120, 54); // Washi-tape corners. ctx.fillStyle = 'rgba(242,182,50,0.55)'; for (const [x, y, a] of [[pad + 30, pad + 6, -0.5], [pad + LEDGER.w - 30, pad + 6, 0.5]]) { ctx.save(); ctx.translate(x, y); ctx.rotate(a); ctx.fillRect(-40, -12, 80, 24); ctx.restore(); } scene.textures.addCanvas('bee-ledger', c); } export const LEDGER_PAD = 18; function bakeCard(scene, key, w, h) { const pad = 18; const c = canvas(w + pad * 2, h + pad * 2), ctx = c.getContext('2d'); ctx.filter = 'blur(12px)'; ctx.fillStyle = 'rgba(20,10,0,0.6)'; rr(ctx, pad + 6, pad + 12, w, h, 16); ctx.fill(); ctx.filter = 'none'; paperFill(ctx, pad, pad, w, h, 16); ctx.strokeStyle = 'rgba(160,100,20,0.55)'; ctx.lineWidth = 2; rr(ctx, pad + 12, pad + 12, w - 24, h - 24, 10); ctx.stroke(); // little comb motif in the corners ctx.strokeStyle = 'rgba(200,130,20,0.35)'; ctx.lineWidth = 2; for (const [x, y] of [[pad + 38, pad + 38], [pad + w - 38, pad + 38], [pad + 38, pad + h - 38], [pad + w - 38, pad + h - 38]]) { hexPath(ctx, x, y, 12); ctx.stroke(); } honeyRing(ctx, pad + w - 90, pad + 90, 40); scene.textures.addCanvas(key, c); } export const CARD = { w: 1120, h: 760 }; export const OVERLAY_CARD = { w: 900, h: 640 }; // ── Atmosphere ──────────────────────────────────────────────────────────────── function bakeVignette(scene) { const c = canvas(W / 2, H / 2), ctx = c.getContext('2d'); const g = ctx.createRadialGradient(W / 4 - 80, H / 4, 80, W / 4, H / 4, W / 2.6); g.addColorStop(0, 'rgba(255,190,90,0.10)'); g.addColorStop(0.55, 'rgba(60,25,0,0.25)'); g.addColorStop(1, 'rgba(15,6,0,0.82)'); ctx.fillStyle = g; ctx.fillRect(0, 0, W / 2, H / 2); scene.textures.addCanvas('bee-vignette', c); } function bakeGlow(scene) { const c = canvas(128, 128), ctx = c.getContext('2d'); const g = ctx.createRadialGradient(64, 64, 0, 64, 64, 64); g.addColorStop(0, 'rgba(255,236,170,1)'); g.addColorStop(0.4, 'rgba(255,200,90,0.45)'); g.addColorStop(1, 'rgba(255,180,60,0)'); ctx.fillStyle = g; ctx.fillRect(0, 0, 128, 128); scene.textures.addCanvas('bee-glow', c); } function bakeDrip(scene) { const c = canvas(20, 28), ctx = c.getContext('2d'); const g = ctx.createRadialGradient(8, 18, 1, 10, 18, 10); g.addColorStop(0, '#ffd56a'); g.addColorStop(1, '#c4730a'); ctx.fillStyle = g; ctx.beginPath(); ctx.moveTo(10, 0); ctx.bezierCurveTo(12, 8, 19, 12, 19, 18); ctx.arc(10, 18, 9, 0, Math.PI); ctx.bezierCurveTo(1, 12, 8, 8, 10, 0); ctx.fill(); ctx.fillStyle = 'rgba(255,255,255,0.7)'; ctx.beginPath(); ctx.arc(7, 17, 2.4, 0, Math.PI * 2); ctx.fill(); scene.textures.addCanvas('bee-drip', c); } export function prepareBeeArt(scene) { if (!scene.textures.exists('bee-cell')) bakeCell(scene, 'bee-cell', false); if (!scene.textures.exists('bee-cell-center')) bakeCell(scene, 'bee-cell-center', true); if (!scene.textures.exists('bee-cell-shadow')) bakeCellShadow(scene); if (!scene.textures.exists('bee-body')) bakeBee(scene); if (!scene.textures.exists('bee-jar')) bakeJar(scene); if (!scene.textures.exists('bee-ledger')) bakeLedger(scene); if (!scene.textures.exists('bee-card')) bakeCard(scene, 'bee-card', CARD.w, CARD.h); if (!scene.textures.exists('bee-overlay-card')) bakeCard(scene, 'bee-overlay-card', OVERLAY_CARD.w, OVERLAY_CARD.h); if (!scene.textures.exists('bee-vignette')) bakeVignette(scene); if (!scene.textures.exists('bee-glow')) bakeGlow(scene); if (!scene.textures.exists('bee-drip')) bakeDrip(scene); } // ── HiveButton ──────────────────────────────────────────────────────────────── // A beeswax tag with a stamped label. Container centred on (x, y); every child // is centred too (a Container's hit area is always centred on it). export class HiveButton extends Phaser.GameObjects.Container { constructor(scene, x, y, label, onClick, { width = 180, height = 60, fontSize = 24, accent = false, dark = false } = {}) { super(scene, x, y); this.w = width; this.h = height; this.accent = accent; this.dark = dark; this.enabled = true; this.hover = false; this.gfx = scene.add.graphics(); this.text = scene.add.text(0, 1, label, { fontFamily: SERIF, fontSize: `${fontSize}px`, fontStyle: 'bold', color: accent ? '#4a2604' : (dark ? CREAM : INK), }).setOrigin(0.5); this.baseSize = fontSize; this.fit(); this.add([this.gfx, this.text]); this.setSize(width, height); this.setInteractive({ useHandCursor: true }); this.draw(); this.on('pointerover', () => { this.hover = true; this.draw(); }); this.on('pointerout', () => { this.hover = false; this.draw(); this.gfx.y = 0; this.text.y = 1; }); this.on('pointerdown', () => { if (this.enabled) { this.gfx.y = 2; this.text.y = 3; } }); this.on('pointerup', () => { this.gfx.y = 0; this.text.y = 1; if (this.enabled) onClick?.(); }); scene.add.existing(this); } fit() { const maxW = this.w - 20; this.text.setFontSize(this.baseSize); if (this.text.width > maxW) this.text.setFontSize(Math.max(12, Math.floor(this.baseSize * maxW / this.text.width))); } draw() { const g = this.gfx, w = this.w, h = this.h, r = Math.min(16, h / 2); const lit = this.hover && this.enabled; g.clear(); g.fillStyle(0x1a0c00, 0.35); g.fillRoundedRect(-w / 2 + 2, -h / 2 + 5, w, h, r); let fill, edge; if (this.accent) { fill = lit ? 0xffcf55 : HONEY; edge = HONEY_DEEP; } else if (this.dark) { fill = lit ? 0x5a3a18 : 0x3d260e; edge = 0x8a6030; } else { fill = lit ? 0xfff1c8 : WAX; edge = 0xb88a3a; } g.fillStyle(fill, 1); g.fillRoundedRect(-w / 2, -h / 2, w, h, r); g.fillStyle(0xffffff, this.dark ? 0.06 : 0.28); g.fillRoundedRect(-w / 2 + 6, -h / 2 + 4, w - 12, h * 0.36, { tl: r - 4, tr: r - 4, bl: 4, br: 4 }); g.lineStyle(2, edge, 1); g.strokeRoundedRect(-w / 2, -h / 2, w, h, r); } setLabel(t) { this.text.setText(t); this.fit(); return this; } setEnabled(on) { this.enabled = on; this.setAlpha(on ? 1 : 0.45); if (this.input) this.input.cursor = on ? 'pointer' : 'default'; this.draw(); return this; } } // ── Sound ───────────────────────────────────────────────────────────────────── // A short, soft buzz synthesised with WebAudio (there is no bee clip in the // SFX set). Quietly does nothing under the HTML5 sound manager or when muted. export function playBuzz(scene, { duration = 0.55, pitch = 190, volume = 0.05 } = {}) { try { const sm = scene.sound; const ctx = sm?.context; if (!ctx || sm.mute || ctx.state !== 'running') return; const t = ctx.currentTime; const osc = ctx.createOscillator(); osc.type = 'sawtooth'; osc.frequency.setValueAtTime(pitch, t); osc.frequency.linearRampToValueAtTime(pitch * 1.18, t + duration * 0.4); osc.frequency.linearRampToValueAtTime(pitch * 0.92, t + duration); const lfo = ctx.createOscillator(); lfo.frequency.value = 23; const lfoGain = ctx.createGain(); lfoGain.gain.value = 0.35; const amp = ctx.createGain(); const v = volume; // sm.destination already applies the master volume/mute amp.gain.setValueAtTime(0, t); amp.gain.linearRampToValueAtTime(v, t + 0.06); amp.gain.setValueAtTime(v, t + duration * 0.7); amp.gain.linearRampToValueAtTime(0, t + duration); const lp = ctx.createBiquadFilter(); lp.type = 'lowpass'; lp.frequency.value = 900; lfo.connect(lfoGain).connect(amp.gain); osc.connect(lp).connect(amp).connect(sm.destination ?? ctx.destination); osc.start(t); lfo.start(t); osc.stop(t + duration + 0.05); lfo.stop(t + duration + 0.05); } catch { /* audio is a nicety */ } } // ── Backdrop ────────────────────────────────────────────────────────────────── // A softened copy of the honeycomb photo, baked once at half resolution (cheap // to blur, and the upscale softens it further) so the busy comb sits behind // the real hive instead of competing with it. export function bakeSoftBackdrop(scene, srcKey) { const key = 'bee-bg-soft'; if (scene.textures.exists(key)) return key; if (!scene.textures.exists(srcKey)) return srcKey; const src = scene.textures.get(srcKey).getSourceImage(); const c = canvas(W / 2, H / 2), ctx = c.getContext('2d'); ctx.filter = 'blur(3px) saturate(1.08)'; ctx.drawImage(src, -10, -10, W / 2 + 20, H / 2 + 20); // overdraw so the blur doesn't darken the edges scene.textures.addCanvas(key, c); return key; }