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:
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user