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-11-16 22:55:08 +01:00
parent 9a979078f0
commit 0138e54828
7 changed files with 20 additions and 15 deletions
+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;