fix(lab-organic): жидкость в пробирке не вылезает за стекло

Клип жидкости был прямоугольник на всю ширину + полукруг — вместе они
шире трубки в зоне закруглённого дна, и заливка торчала за стеклом.
Заменён на путь по внутреннему контуру пробирки (прямые стенки +
дугообразное дно, тем же радиусом w/2-4, что и обводка стекла).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Maxim Dolgolyov
2026-06-24 19:45:02 +03:00
parent 7829360391
commit 4be7f9a07c
+9 -3
View File
@@ -1437,10 +1437,16 @@ class OrganicSim {
ctx.lineTo(x + w - 4, y);
ctx.stroke();
// clip to tube for liquid
// clip to the tube interior (straight sides + rounded bottom) so the
// liquid never spills past the glass outline
const rBot = w/2 - 4;
ctx.beginPath();
ctx.rect(x + 4, liqY, w - 8, liqH - 8);
ctx.arc(x + w/2, y + h - (w/2 - 4), w/2 - 4, 0, Math.PI);
ctx.moveTo(x + 4, liqY);
ctx.lineTo(x + 4, y + h - rBot);
ctx.arcTo(x + 4, y + h, x + w/2, y + h, rBot);
ctx.arcTo(x + w - 4, y + h, x + w - 4, y + h - rBot, rBot);
ctx.lineTo(x + w - 4, liqY);
ctx.closePath();
ctx.clip();
// base liquid (reagent color)