From abab42ad0b92b582a19137c305cb8c26fc591ac8 Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Sun, 10 May 2026 15:14:21 +0200 Subject: [PATCH] oh lord --- modules/web/fm95.html | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/modules/web/fm95.html b/modules/web/fm95.html index d242dd3..620b846 100644 --- a/modules/web/fm95.html +++ b/modules/web/fm95.html @@ -259,36 +259,21 @@ // draw series function drawLine(hist, color) { - const slice = hist.slice(-nPts).filter((v, i, a) => { - // fill nulls with neighbors for smoother rendering - return true; - }); - const pts = slice.map((v, i) => ({ x: i * (W / (nPts - 1)), y: v === null ? null : toY(v) })); - + const slice = hist.slice(-nPts); + const step = W / (nPts - 1); ctx.strokeStyle = color; ctx.lineWidth = 1.5; ctx.beginPath(); let started = false; - - for (let i = 0; i < pts.length; i++) { - if (pts[i].y === null) { started = false; continue; } - if (!started) { ctx.moveTo(pts[i].x, pts[i].y); started = true; continue; } - - // cardinal spline control points - const p0 = pts[i - 2]?.y !== null ? pts[i - 2] : pts[i - 1]; - const p1 = pts[i - 1]; - const p2 = pts[i]; - const p3 = pts[i + 1] ?? p2; - - const tension = 0.4; - const cp1x = p1.x + (p2.x - p0.x) * tension / 2; - const cp1y = p1.y + (p2.y - p0.y) * tension / 2; - const cp2x = p2.x - (p3.x - p1.x) * tension / 2; - const cp2y = p2.y - (p3.y - p1.y) * tension / 2; - - ctx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, p2.x, p2.y); + for (let i = 0; i < slice.length; i++) { + if (slice[i] === null) { started = false; continue; } + const x = i * step; + const y = toY(slice[i]); + if (!started) { ctx.moveTo(x, y); started = true; } + else ctx.lineTo(x, y); } ctx.stroke(); + // glow ctx.strokeStyle = color + '44'; ctx.lineWidth = 4; ctx.stroke();