The decoding motto
Craft 09 · Type, motion
Never the same line twice in a row.
The line under my name on the home page, on its own.
Mostly tools I wanted to exist.
Typed, not printed
Each letter gets its own moment to settle: 38 ms after the one before it, plus up to 120 ms of chance. Until then it shows a random letter. Spaces never scramble, so the shape of the sentence is there from the first frame and your eye already knows how long it is.
export function decoder(final: string, t0: number) {
const at = [...final].map((_, i) => t0 + 300 + i * 38 + Math.random() * 120);
return (t: number) => {
let text = "";
let done = true;
for (let i = 0; i < final.length; i++) {
if (final[i] === " " || t >= at[i]) text += final[i];
else {
text += LETTERS[Math.floor(Math.random() * 26)];
done = false;
}
}
return { text, done };
};
}The randomness is what sells it. With a fixed step the line wipes in like a progress bar; with a little jitter, neighbouring letters land out of order and it reads like someone typing fast. Once every letter has landed, the loop unsubscribes itself, so a finished motto costs nothing.
Never twice in a row
On my home page the line changes on every visit. The index of the last one is kept in local storage and skipped when the next one is picked, so a reload never shows you the same line twice in a row. If storage is blocked, it just picks at random.