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

This commit is contained in:
2026-08-16 22:55:08 +01:00
parent 9fca6d81cc
commit a9a645ce1c
7 changed files with 20 additions and 15 deletions
+2
View File
@@ -52,6 +52,8 @@
<label for="s-interval">Rotation du code</label> <label for="s-interval">Rotation du code</label>
<select id="s-interval"> <select id="s-interval">
<option value="500">0,5 s</option> <option value="500">0,5 s</option>
<option value="700">0,7 s</option>
<option value="800">0,8 s</option>
<option value="1000">1 s</option> <option value="1000">1 s</option>
<option value="1500">1,5 s</option> <option value="1500">1,5 s</option>
<option value="2000">2 s</option> <option value="2000">2 s</option>
+2
View File
@@ -23,6 +23,8 @@
<label for="interval">Rotation du code</label> <label for="interval">Rotation du code</label>
<select id="interval"> <select id="interval">
<option value="500" selected>0,5 s</option> <option value="500" selected>0,5 s</option>
<option value="700">0,7 s</option>
<option value="800">0,8 s</option>
<option value="1000">1 s</option> <option value="1000">1 s</option>
<option value="1500">1,5 s</option> <option value="1500">1,5 s</option>
<option value="2000">2 s</option> <option value="2000">2 s</option>
+8 -9
View File
@@ -183,7 +183,7 @@ export function render(ctx, cx, cy, unit, theta, bits, t = 0, fade = null) {
ctx.strokeStyle = INK; ctx.strokeStyle = INK;
ringsOf(bits).forEach((ring, k) => { ringsOf(bits).forEach((ring, k) => {
const n = ring.length, r = RADII[k] * unit, step = (2 * Math.PI) / n; 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++) { 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 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; 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(); dash();
continue; continue;
} }
// the edge runs cap to cap: the new tone grows as a bean from one end while the old one shrinks into // the bean keeps its shape, only its inside changes: an edge runs cap to cap, clipped by a wedge
// the other, a bean shorter than its own width thins down to a dot instead of popping // 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 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 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]]; 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) { for (const [alpha, s0, s1] of parts) {
const span = s1 - s0, f = Math.min(1, span / (2 * cap)); if (s1 - s0 < 1e-4) continue;
if (f < 0.02) continue; ctx.save();
const c = cap * f; ctx.beginPath(); ctx.moveTo(cx, cy); ctx.arc(cx, cy, outer, s0, s1); ctx.closePath(); ctx.clip();
ctx.globalAlpha = alpha; ctx.globalAlpha = alpha;
ctx.lineWidth = THICK * unit * f; dash();
ctx.beginPath(); ctx.arc(cx, cy, r, s0 + c, Math.max(s0 + c, s1 - c) + 1e-4); ctx.stroke(); ctx.restore();
} }
ctx.lineWidth = THICK * unit;
} }
}); });
ctx.globalAlpha = 1; ctx.globalAlpha = 1;
+1 -1
View File
@@ -78,7 +78,7 @@ function ringLoop(t) {
if (c.width !== size) { c.width = c.height = size; } if (c.width !== size) { c.width = c.height = size; }
const ctx = c.getContext("2d"); const ctx = c.getContext("2d");
ctx.clearRect(0, 0, size, size); 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; 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, 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); prevBits ? { from: prevBits, k, seed: qr.slot } : null);
+1 -1
View File
@@ -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 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]; for (const key of Object.keys(scanners)) delete scanners[key];
let px = 0, py = 0; 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++) { 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 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; const cur = s.tokens[idx], prev = idx > 0 ? s.tokens[idx - 1] : null, since = ms - slot * s.interval;
+1 -1
View File
@@ -14,7 +14,7 @@ for (const ms of [1000, 500]) {
let slot = 0, bits = "", prevBits = "", switchedAt = 0, idx = 0; 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 // 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 // ?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() { function tick() {
prevBits = bits || null; prevBits = bits || null;
switchedAt = performance.now(); switchedAt = performance.now();
+5 -3
View File
@@ -1,7 +1,7 @@
"""ring code bench: renders codes with perspective, blur, washed contrast and clutter in headless chrome, """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] 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 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 asyncio
import base64 import base64
import collections 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 d, contrast, fps in itertools.product([60, 70, 80, 100, 120, 150], [0.45, 0.3], [15, 7]):
for _ in range(n): for _ in range(n):
s = camera(r, d, contrast, r.choice([0.7, 1.5]), 1920) 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), iv = int(os.environ.get("IV", "500"))
tokens=[code(r) for _ in range(14)], t0=r.randrange(1 << 20) * 500 + r.uniform(0, 400)) 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) out.append(s)
return out return out