write a single index.html file (inline css and js, no libraries) that draws a lava lamp with metaballs on a full-window canvas. 6 blobs drift up and down with slow sine motion inside a tall rounded glass shape in the center. compute the metaball field per pixel at quarter resolution and threshold it, color the blobs with a warm orange to magenta gradient on a dark purple background. keep it under 120 lines.
115 lines, runs with zero errors, but look at it. the 1/d² field has such a long tail that all 6 blobs merge into one fat egg, so there is no lava, just a gradient. the glass is a pixel mask, so the rim is 4px stairs, and the metal cap and base float off the glass. good start, wrong field.
// filename: index.html (gemini 3.8 flash output, the per-pixel field)
for (let y = minY; y < maxY; y++) {
const py = y < y1 ? y1 : (y > y2 ? y2 : y);
const dy = y - py, row = y * ow;
for (let x = minX; x < maxX; x++) {
const dx = x - cx;
if (dx * dx + dy * dy <= lr2) {
let sum = 0;
for (let i = 0; i < 6; i++) {
const b = blobs[i];
sum += b.wt / ((x - b.x) ** 2 + (y - b.y) ** 2 + 0.1);
}
if (sum >= 1.0) {
const v = (y - topY) / lh, boost = Math.min(45, (sum - 1) * 28);
const r = Math.min(255, 230 + 25 * v + boost);
const g = Math.min(255, 25 + 125 * v + boost * 0.9);
const b = Math.min(255, 160 - 140 * v + boost * 0.3);
u32[row + x] = (255 << 24) | (b << 16) | (g << 8) | r;
} else {
u32[row + x] = 0xFF350C24; // Lamp liquid #240c35
}
}
}
}







