Ring code: static logo, stronger dark/light contrast, cross-fade on code change

This commit is contained in:
2026-11-16 18:19:40 +01:00
parent 112ba3967d
commit fe1da7ea1c
2 changed files with 19 additions and 10 deletions
+7 -2
View File
@@ -11,8 +11,12 @@ for (const ms of [1000, 500]) {
if (ms === MS) a.classList.add("on");
}
let slot = 0, bits = "", idx = 0;
let slot = 0, bits = "", prevBits = "", switchedAt = 0, idx = 0;
// changed dashes cross-fade over a short time, a few frames are then unreadable, which is fine
const FADE = Math.min(220, MS * 0.25);
function tick() {
prevBits = bits || null;
switchedAt = performance.now();
slot = (slot + 1) & 0xffff;
const mac = [...crypto.getRandomValues(new Uint8Array(4))];
bits = SYNC + dataBits(rsEncode([(slot >> 8) & 255, slot & 255, ...mac]));
@@ -29,7 +33,8 @@ function frame(t) {
const size = Math.min(w, h) * 0.9;
if (MODE === "ring") {
// one full turn every 45 s
render(ctx, w / 2, h / 2, size / (2 * DISC), (t / 1000) * (2 * Math.PI / 45), bits, t / 1000);
const k = prevBits ? Math.min(1, (t - switchedAt) / FADE) : 1;
render(ctx, w / 2, h / 2, size / (2 * DISC), (t / 1000) * (2 * Math.PI / 45), bits, t / 1000, prevBits ? { from: prevBits, k } : null);
} else {
const m = lab.classic[idx].modules, n = m.length, s = Math.floor(size / (n + 8));
const x0 = (w - n * s) / 2, y0 = (h - n * s) / 2;