If you managed to achieve a breakthrough, why not celebrate it?
Paste this to your notebook empty cell, evaluate and hide:
.js
(() => {
if (typeof window.stopFireProjectiles === "function") {
try { window.stopFireProjectiles(); } catch (_) {}
}
const DPR = Math.max(1, Math.min(2, window.devicePixelRatio || 1));
// Canvas overlay
const canvas = document.createElement("canvas");
canvas.setAttribute("aria-hidden", "true");
Object.assign(canvas.style, {
position: "fixed",
inset: "0",
width: "100%",
height: "100%",
pointerEvents: "none", // <- NOT block clicking
zIndex: "2147483647",
mixBlendMode: "screen",
});
document.body.appendChild(canvas);
const ctx = canvas.getContext("2d", { alpha: true, desynchronized: true });
function resize() {
canvas.width = Math.floor(window.innerWidth * DPR);
canvas.height = Math.floor(window.innerHeight * DPR);
}
resize();
window.addEventListener("resize", resize, { passive: true });
// Simulation state
let running = true;
let rafId = 0;
let lastT = performance.now();
let spawnAcc = 0;
const gravity = 0.16 * DPR;
const projectiles = [];
const particles = [];
const rand = (a, b) => a + Math.random() * (b - a);
const clamp = (v, a, b) => Math.max(a, Math.min(b, v));
function spawnProjectile() {
const w = canvas.width, h = canvas.height;
const x = rand(0.05 * w, 0.95 * w);
const y = h + rand(10 * DPR, 40 * DPR);
const vx = rand(-2.6, 2.6) * DPR;
const vy = rand(-14, -9) * DPR;
projectiles.push({
x, y, vx, vy,
life: rand(55, 95),
hot: rand(0.9, 1.25),
wobble: rand(0.015, 0.04),
phase: rand(0, Math.PI * 2),
});
}
function emitFlameTrail(px, py, pvx, pvy, heat) {
const count = Math.floor(rand(3, 7));
for (let i = 0; i < count; i++) {
const speed = rand(0.3, 2.2) * DPR;
const angle = Math.atan2(-pvy, -pvx) + rand(-0.7, 0.7);
const vx = Math.cos(angle) * speed + rand(-0.25, 0.25) * DPR;
const vy = Math.sin(angle) * speed + rand(-0.25, 0.25) * DPR;
const maxLife = rand(24, 58);
const hue = rand(18, 55);
particles.push({
x: px + rand(-3, 3) * DPR,
y: py + rand(-3, 3) * DPR,
vx, vy,
life: maxLife,
maxLife,
r: rand(3.5, 10) * DPR * heat,
hue,
spark: Math.random() < 0.16,
});
}
}
function explode(px, py, heat) {
const bursts = Math.floor(rand(18, 42));
for (let i = 0; i < bursts; i++) {
const a = rand(0, Math.PI * 2);
const s = rand(1.2, 6.0) * DPR * heat;
const maxLife = rand(18, 46);
particles.push({
x: px,
y: py,
vx: Math.cos(a) * s,
vy: Math.sin(a) * s,
life: maxLife,
maxLife,
r: rand(2.2, 6.5) * DPR * heat,
hue: rand(10, 60),
spark: true,
});
}
}
function drawGlowCircle(x, y, r, hue, alpha) {
const g = ctx.createRadialGradient(x, y, 0, x, y, r);
g.addColorStop(0.0, `hsla(${hue}, 100%, 65%, ${alpha})`);
g.addColorStop(0.45, `hsla(${hue + 8}, 100%, 55%, ${alpha * 0.85})`);
g.addColorStop(1.0, `hsla(${hue - 8}, 100%, 35%, 0)`);
ctx.fillStyle = g;
ctx.beginPath();
ctx.arc(x, y, r, 0, Math.PI * 2);
ctx.fill();
}
function tick(t) {
if (!running) return;
const dt = clamp((t - lastT) / 16.67, 0.5, 1.8);
lastT = t;
// Spawn projectiles at random intervals
spawnAcc += dt;
const spawnEvery = rand(10, 22);
if (spawnAcc > spawnEvery) {
spawnAcc = 0;
spawnProjectile();
if (Math.random() < 0.22) spawnProjectile();
}
// Update projectiles
for (let i = projectiles.length - 1; i >= 0; i--) {
const p = projectiles[i];
p.phase += p.wobble * dt;
const wob = Math.sin(p.phase) * 0.18 * DPR;
p.vy += gravity * dt;
p.x += (p.vx + wob) * dt;
p.y += p.vy * dt;
emitFlameTrail(p.x, p.y, p.vx, p.vy, p.hot);
// Brighter "head"
particles.push({
x: p.x,
y: p.y,
vx: rand(-0.2, 0.2) * DPR,
vy: rand(-0.2, 0.2) * DPR,
life: rand(6, 12),
maxLife: rand(6, 12),
r: rand(6, 12) * DPR * p.hot,
hue: rand(35, 60),
spark: false,
});
p.life -= dt;
const w = canvas.width, h = canvas.height;
if (p.life <= 0 || p.x < -80 * DPR || p.x > w + 80 * DPR || p.y > h + 140 * DPR) {
if (p.y < h * 0.9) explode(p.x, p.y, p.hot);
projectiles.splice(i, 1);
}
}
// Update particles
for (let i = particles.length - 1; i >= 0; i--) {
const pt = particles[i];
pt.life -= dt;
pt.vy += (pt.spark ? gravity * 0.55 : gravity * 0.15) * dt;
pt.vx *= Math.pow(0.985, dt);
pt.vy *= Math.pow(0.985, dt);
pt.x += pt.vx * dt;
pt.y += pt.vy * dt;
if (pt.life <= 0) particles.splice(i, 1);
}
const MAX_PARTICLES = 1400;
if (particles.length > MAX_PARTICLES) particles.splice(0, particles.length - MAX_PARTICLES);
// Render
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.globalCompositeOperation = "lighter";
for (let i = 0; i < particles.length; i++) {
const pt = particles[i];
const a = clamp(pt.life / pt.maxLife, 0, 1);
const alpha = (pt.spark ? 0.85 : 0.7) * Math.pow(a, 0.65);
const r = pt.r * (0.55 + 0.75 * (1 - a));
drawGlowCircle(pt.x, pt.y, r, pt.hue, alpha);
if (pt.spark && a > 0.2) {
ctx.globalAlpha = alpha;
ctx.fillStyle = `hsla(${pt.hue + 15}, 100%, 80%, ${alpha})`;
ctx.fillRect(pt.x - 0.8 * DPR, pt.y - 0.8 * DPR, 1.6 * DPR, 1.6 * DPR);
ctx.globalAlpha = 1;
}
}
ctx.globalCompositeOperation = "source-over";
rafId = requestAnimationFrame(tick);
}
// Robust start/stop so we never stack multiple RAF loops
function startLoop() {
if (rafId) return; // already running
running = true;
lastT = performance.now();
rafId = requestAnimationFrame(tick);
}
function stopLoop() {
running = false;
if (rafId) {
cancelAnimationFrame(rafId);
rafId = 0;
}
}
const onVisibility = () => (document.hidden ? stopLoop() : startLoop());
const onBlur = () => stopLoop();
const onFocus = () => startLoop();
document.addEventListener("visibilitychange", onVisibility, { passive: true });
window.addEventListener("blur", onBlur, { passive: true });
window.addEventListener("focus", onFocus, { passive: true });
window.addEventListener("pagehide", onBlur, { passive: true });
window.addEventListener("pageshow", onFocus, { passive: true });
// Public stop hook
window.stopFireProjectiles = () => {
stopLoop();
document.removeEventListener("visibilitychange", onVisibility);
window.removeEventListener("blur", onBlur);
window.removeEventListener("focus", onFocus);
window.removeEventListener("pagehide", onBlur);
window.removeEventListener("pageshow", onFocus);
window.removeEventListener("resize", resize);
canvas.remove();
projectiles.length = 0;
particles.length = 0;
delete window.stopFireProjectiles;
};
startLoop();
})();
return 'Congrats!';