· 3 min read
A command for covers, and covers that follow the theme
pnpm covers (scripts/covers/, with a README) replaces the temporary Python scripts. draft asks SwarmUI for drafts and makes a sheet to compare them. use turns…
What we did
pnpm covers(scripts/covers/, with a README) replaces the temporary Python scripts.draftasks SwarmUI for drafts and makes a sheet to compare them.useturns one into the cover and its masks, with no AI. The settings, style and scenes are incovers.yaml.- Covers are drafted at 1600 × 912 and trimmed to 1600 × 900, the widest the site shows, so they're never upscaled.
- We tested four pairs of colours for the masks (12 drafts). Magenta and lime won: two separate groups of hues, and they didn't tint the ivory titles.
- Themed covers:
cover.avifis painted in the default theme's colours.ThemedCover.svelteputs--brandand--code-typeover it through two masks withmix-blend-mode: color.data-theme="dark"gives it the theme's dark colours in light mode too. Older covers don't have masks and don't change. - A faint, slow glow (a 6 s loop), which lights up when you point at a cover or reach its card with the keyboard. The first version stopped after 4.8 s (WCAG 2.2.2). I think a fade this faint and slow doesn't count as blinking, but that's my own reading. The loop doesn't run with reduced motion.
:::theme-demoshows a cover in every theme, and the image and masks it's made of.- Both new posts have covers made this way. A draft post explains how it works, in English and Spanish.
What I learned
- Image colours can be data. The model only has to mark where the light is.
- OKLCH makes "this hue, and strong enough" two simple checks. Greys and ivory have almost no chroma.
colortakes the layer's full saturation, however weak the colour under it was.- In Chromium, a mask on an element with
display: nonewasn't downloaded. - Fading a colour layer shows the image's own colour. To add light, it needs another layer with
screen.
Problems & fixes
- A better number, a worse picture. Widening the mask cut the leftover purple from about 5% to 0.15%, but made the whole floor glow. Now the mask follows how strong the light is, and faint traces turn grey separately. The leftover purple is about 0.15% with both, and the floor is dark.
- The cover's margin and border were on the image, so the layers wouldn't line up. They're on the wrapper now.
- The masks are black on a transparent background, so you couldn't see them on a dark page without JavaScript. Now they have a white background there.
- Pointing at a cover made the light jump, and not to its brightest. The loop controlled the opacity, so the result depended on where it was: from 0 it jumped to 0.55, then took almost three seconds to reach 0.8. My test had only checked that the settings changed smoothly. Measuring the opacity on every frame showed the jump. The hover light is now its own layer, and fades in over half a second. (It first went to full brightness. That glared, so now it stops at 0.6.)
Links
- MDN:
mix-blend-mode - MDN:
mask-image - Compositing spec: non-separable blend modes
- Oklab, by Björn Ottosson
- WCAG 2.2.2: pause, stop, hide
Next
- Check it in Firefox and Safari, and measure
/blogwith many themed cards.