From 0138e54828b95c772be3f982ee355450135d4e32 Mon Sep 17 00:00:00 2001 From: Showdown76py Date: Mon, 16 Nov 2026 22:55:08 +0100 Subject: [PATCH] Ring code: bean keeps its shape during the wipe; 0.7 and 0.8 s intervals; wipe as long as at 1 s from 0.8 s --- static/admin.html | 2 ++ static/index.html | 2 ++ static/js/ringcode.js | 17 ++++++++--------- static/js/screen.js | 2 +- static/ringlab/far.js | 2 +- static/ringlab/screen.js | 2 +- tools/ringbench.py | 8 +++++--- 7 files changed, 20 insertions(+), 15 deletions(-) diff --git a/static/admin.html b/static/admin.html index 0db61da..64303c0 100644 --- a/static/admin.html +++ b/static/admin.html @@ -52,6 +52,8 @@ + + diff --git a/static/js/ringcode.js b/static/js/ringcode.js index 05e1d9c..4226eb0 100644 --- a/static/js/ringcode.js +++ b/static/js/ringcode.js @@ -183,7 +183,7 @@ export function render(ctx, cx, cy, unit, theta, bits, t = 0, fade = null) { ctx.strokeStyle = INK; ringsOf(bits).forEach((ring, k) => { const n = ring.length, r = RADII[k] * unit, step = (2 * Math.PI) / n; - const cap = (THICK * unit) / 2 / r; + const cap = (THICK * unit) / 2 / r, outer = r + THICK * unit; for (let j = 0; j < n; j++) { const ph = phase(k, j) * 2 * Math.PI, w = 0.5 + 0.5 * Math.sin(t * 1.3 + ph), w2 = 0.5 + 0.5 * Math.sin(t * 0.9 + ph * 1.7); const len = LEN[0] + (LEN[1] - LEN[0]) * w; @@ -196,20 +196,19 @@ export function render(ctx, cx, cy, unit, theta, bits, t = 0, fade = null) { dash(); continue; } - // the edge runs cap to cap: the new tone grows as a bean from one end while the old one shrinks into - // the other, a bean shorter than its own width thins down to a dot instead of popping + // the bean keeps its shape, only its inside changes: an edge runs cap to cap, clipped by a wedge + // from the center, new tone behind it and old tone ahead const lo = a - half - cap, hi = a + half + cap, fwd = phase(k + 7, j + (fade.seed || 0) * 31) < 0.5; const edge = fwd ? lo + (hi - lo) * ease : hi - (hi - lo) * ease; const parts = [[alphaOf(ring[j]), fwd ? lo : edge, fwd ? edge : hi], [alphaOf(prev[k][j]), fwd ? edge : lo, fwd ? hi : edge]]; for (const [alpha, s0, s1] of parts) { - const span = s1 - s0, f = Math.min(1, span / (2 * cap)); - if (f < 0.02) continue; - const c = cap * f; + if (s1 - s0 < 1e-4) continue; + ctx.save(); + ctx.beginPath(); ctx.moveTo(cx, cy); ctx.arc(cx, cy, outer, s0, s1); ctx.closePath(); ctx.clip(); ctx.globalAlpha = alpha; - ctx.lineWidth = THICK * unit * f; - ctx.beginPath(); ctx.arc(cx, cy, r, s0 + c, Math.max(s0 + c, s1 - c) + 1e-4); ctx.stroke(); + dash(); + ctx.restore(); } - ctx.lineWidth = THICK * unit; } }); ctx.globalAlpha = 1; diff --git a/static/js/screen.js b/static/js/screen.js index 7d9c174..cdb527e 100644 --- a/static/js/screen.js +++ b/static/js/screen.js @@ -78,7 +78,7 @@ function ringLoop(t) { if (c.width !== size) { c.width = c.height = size; } const ctx = c.getContext("2d"); ctx.clearRect(0, 0, size, size); - const fadeMs = Math.min(220, qr.interval_ms * 0.25); + const fadeMs = Math.min(220, qr.interval_ms * 0.28); const k = prevBits ? Math.min(1, (t - switchedAt) / fadeMs) : 1; drawRing(ctx, size / 2, size / 2, (size / 2) / DISC * 0.98, (t / 1000) * (2 * Math.PI / 45), qr.bits, t / 1000, prevBits ? { from: prevBits, k, seed: qr.slot } : null); diff --git a/static/ringlab/far.js b/static/ringlab/far.js index 3e1a71c..f731745 100644 --- a/static/ringlab/far.js +++ b/static/ringlab/far.js @@ -165,7 +165,7 @@ window.runSeq = async (cfg) => { for (const name of cfg.pipes) res[name] = { got: [], false: 0, frames: 0, ms: 0, first5: null }; for (const key of Object.keys(scanners)) delete scanners[key]; let px = 0, py = 0; - const fadeMs = Math.min(220, s.interval * 0.25), t00 = s.t0 || 0; + const fadeMs = Math.min(220, s.interval * (s.fadeK || 0.25)), t00 = s.t0 || 0; for (let i = 0; i < s.fps * s.secs; i++) { const ms = t00 + (i * 1000) / s.fps + rnd() * 20, slot = Math.floor(ms / s.interval), idx = slot - Math.floor(t00 / s.interval); const cur = s.tokens[idx], prev = idx > 0 ? s.tokens[idx - 1] : null, since = ms - slot * s.interval; diff --git a/static/ringlab/screen.js b/static/ringlab/screen.js index f340d85..38d5be5 100644 --- a/static/ringlab/screen.js +++ b/static/ringlab/screen.js @@ -14,7 +14,7 @@ for (const ms of [1000, 500]) { let slot = 0, bits = "", prevBits = "", switchedAt = 0, idx = 0; // changed dashes wipe over a short time, a few frames are then unreadable, which is fine // ?fade=0.5 tries a longer wipe, as a share of the interval -const FADE = params.get("fade") ? MS * +params.get("fade") : Math.min(220, MS * 0.25); +const FADE = params.get("fade") ? MS * +params.get("fade") : Math.min(220, MS * 0.28); function tick() { prevBits = bits || null; switchedAt = performance.now(); diff --git a/tools/ringbench.py b/tools/ringbench.py index 5353d93..7f33c37 100644 --- a/tools/ringbench.py +++ b/tools/ringbench.py @@ -1,7 +1,7 @@ """ring code bench: renders codes with perspective, blur, washed contrast and clutter in headless chrome, runs the real decoder and prints read rates. usage: uv run python tools/ringbench.py [trials per cell] env: SUITE=legacy,far,seq,neg (default all) PIPES=legacy,cap960,scan DIAG=legacy|native FAR_D=80,100 NEG=300 - CPU=6 (slow phone) V1=1 (decoder and dash design from before the far-reading work, the baseline)""" + IV=700 FADE_K=0.3 (sequence code interval and wipe share) CPU=6 (slow phone) V1=1 (decoder and dash design from before the far-reading work, the baseline)""" import asyncio import base64 import collections @@ -101,8 +101,10 @@ def seqs(n): for d, contrast, fps in itertools.product([60, 70, 80, 100, 120, 150], [0.45, 0.3], [15, 7]): for _ in range(n): s = camera(r, d, contrast, r.choice([0.7, 1.5]), 1920) - s.update(tilt=r.choice([0, 10, 20]), fps=fps, secs=6, interval=500, shake=r.uniform(0.3, 1.2), - tokens=[code(r) for _ in range(14)], t0=r.randrange(1 << 20) * 500 + r.uniform(0, 400)) + iv = int(os.environ.get("IV", "500")) + s.update(tilt=r.choice([0, 10, 20]), fps=fps, secs=6, interval=iv, shake=r.uniform(0.3, 1.2), + fadeK=float(os.environ.get("FADE_K", "0.25")), + tokens=[code(r) for _ in range(14)], t0=r.randrange(1 << 20) * iv + r.uniform(0, iv * 0.8)) out.append(s) return out