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>
<select id="s-interval">
<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="1500">1,5 s</option>
<option value="2000">2 s</option>
+2
View File
@@ -23,6 +23,8 @@
<label for="interval">Rotation du code</label>
<select id="interval">
<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="1500">1,5 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;
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;
+1 -1
View File
@@ -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);
+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 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;
+1 -1
View File
@@ -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();