import type { AiStyleId } from '../ai.ts'; import { escapeXml as esc } from '../format.ts'; import type { PersonaId } from '../stats.ts'; import { DISPLAY_FAMILY, HEADLINE_FAMILY } from './font.ts'; import { BLUE, BRICK, CREAM, GREEN, INK, NAVY, ORANGE, PINK, PLUM, RED, TEAL, YELLOW } from './palette.ts'; /** * A badge for each personality and AI style, in place of emoji: emoji look different on * every system and clash with the cards. The look is flat and geometric, like a print * poster: a square tile in one colour, a character built from circles, half-circles and * triangles in two or three more, and the same round eyes on every one of them. * * With a `figure`, the badge is built around the user's own number: the character peeks * over it, so no two people's badges are the same. Without one it is just the character, * which still reads at chip size. * * Pages that include ART_CSS bring the characters to life (the owl blinks, the clock * runs); on cards and posters they stand still. `key` keeps the clip ids unique, so * several badges can share one page. */ export interface Place { size?: number; x?: number; y?: number; } /** The number a badge is built around and what it counts, e.g. ["02:47", "LATEST COMMIT"]. */ export type Figure = [value: string, label: string]; export function personaArt(id: PersonaId, key: string, place: Place = {}, figure?: Figure): string { return badge(PERSONAS[id], key, place, figure); } export function aiArt(id: AiStyleId, key: string, place: Place = {}, figure?: Figure): string { return badge(AI[id], key, place, figure); } interface Look { bg: string; /** The label's colour, and anything else that picks out the number. */ accent: string; /** The character, drawn with its face above y=76; over a number it is lifted 4 and the band starts at 80. */ draw: (u: string) => string; } const round = (n: number): number => Math.round(n * 10) / 10; function badge(look: Look, key: string, place: Place, figure?: Figure): string { const u = `art-${key}`; const size = place.size ?? 120; const at = place.x === undefined ? '' : ` x="${round(place.x)}" y="${round(place.y ?? 0)}"`; // Without a number, the character drops into the middle of the tile. const body = figure ? `${look.draw(u)}${number(figure, look.accent)}` : `${look.draw(u)}`; return ``; } /** The figure in the headline face, shrunk to fit, with its label underneath. */ function number([value, label]: Figure, accent: string): string { const size = Math.min(32, 104 / Math.max(1, [...value].length * 0.5)); return `${esc(value)} ${esc(label)}`; } /** The family face: two round eyes that blink and follow the pointer. */ function eyes(y: number, gap = 11, r = 8.5, x = 60, white = CREAM): string { const p = r * 0.5; return ` `; } /** The AI in every AI-style badge: a rounded robot with a screen for a face. */ function robot(body: string, x = 60, face = pillEyes(x)): string { return ` ${face}`; } const pillEyes = (x: number, colour = CREAM): string => ``; const PERSONAS: Record = { // An owl in two triangles and a rectangle, under a crescent moon. nightOwl: { bg: NAVY, accent: YELLOW, draw: () => ` ${eyes(54, 13, 12)} `, }, // A round bird in front of the rising sun, flapping and hopping. earlyBird: { bg: ORANGE, accent: NAVY, draw: () => ` ${eyes(55, 10, 7.5)} `, }, // A knight's helmet with a visor, a plume and a lightning bolt. weekendWarrior: { bg: RED, accent: YELLOW, draw: () => ` `, }, // A runner in a headband, ties flying, mid-stride. marathoner: { bg: GREEN, accent: CREAM, draw: () => ` ${eyes(60, 11, 8)} `, }, // A ladybug under a sweeping magnifier. bugHunter: { bg: YELLOW, accent: NAVY, draw: () => ` ${eyes(40, 8, 5.5)} `, }, // A head in a knotted kerchief, with soap bubbles drifting up. cleaner: { bg: TEAL, accent: CREAM, draw: () => ` ${eyes(65, 11, 8)}`, }, // A globe with two speech bubbles in code. polyglot: { bg: PLUM, accent: YELLOW, draw: (u) => ` ${eyes(60, 11, 8)} `, }, // A clock for a head, hands always going. nineToFive: { bg: BLUE, accent: YELLOW, draw: () => ` `, }, // A head in a hard hat, with the next block lowered onto the stack. builder: { bg: RED, accent: YELLOW, draw: () => ` ${eyes(70, 10, 7.5, 54)}`, }, }; const AI: Record = { // The AI peeks up when asked the odd question. spotChecker: { bg: ORANGE, accent: NAVY, draw: () => ` ${robot(TEAL, 52)}`, }, // You and the AI side by side, taking turns. pairProgrammer: { bg: BLUE, accent: YELLOW, draw: () => ` ${eyes(62, 7.5, 5.5, 36)} `, }, // The AI drives; you hold the compass, which swings and settles. navigator: { bg: TEAL, accent: CREAM, draw: () => ` ${robot(NAVY, 60, pillEyes(60, YELLOW))}`, }, // You describe it; the AI hands back the finished parcel. delegator: { bg: PLUM, accent: YELLOW, draw: () => `${robot(TEAL, 50)} `, }, // The AI in headphones, nodding along. vibeCoder: { bg: PINK, accent: YELLOW, draw: () => ` ${robot(NAVY, 60, ``)} `, }, }; /** The motion. Scoped to `.art`; anyone who prefers reduced motion gets the still pictures. */ export const ART_CSS = ` .art *{transform-box:fill-box} .art .a-late{animation-delay:.6s!important} .art .a-twinkle{transform-origin:center;animation:a-twinkle 2.4s ease-in-out infinite} @keyframes a-twinkle{50%{opacity:.2;transform:scale(.6)}} .art .a-bob,.art .a-float{animation:a-bob 3s ease-in-out infinite} @keyframes a-bob{50%{transform:translateY(-2.5px)}} .art .a-blink{transform-origin:center;animation:a-blink 4.5s infinite} @keyframes a-blink{0%,92%,100%{transform:none}95%{transform:scaleY(.1)}} .art .a-pupils{transition:transform .25s ease-out} .art .a-hop{animation:a-hop 2.2s cubic-bezier(.3,0,.3,1) infinite} @keyframes a-hop{0%,40%,100%{transform:none}52%{transform:translateY(-6px)}64%{transform:none}72%{transform:translateY(-3px)}82%{transform:none}} .art .a-wing-l{transform-origin:100% 0;animation:a-flap-l 2.2s ease-in-out infinite} .art .a-wing-r{transform-origin:0 0;animation:a-flap-r 2.2s ease-in-out infinite} @keyframes a-flap-l{0%,40%,100%{transform:none}50%,62%{transform:rotate(22deg)}} @keyframes a-flap-r{0%,40%,100%{transform:none}50%,62%{transform:rotate(-22deg)}} .art .a-sway{transform-origin:0 100%;animation:a-sway 3s ease-in-out infinite} @keyframes a-sway{50%{transform:rotate(-8deg)}} .art .a-bolt{transform-origin:center;animation:a-bolt 2.6s ease-in-out infinite} @keyframes a-bolt{0%,100%{transform:none}50%{transform:scale(1.12)}} .art .a-speed rect{animation:a-speed .8s linear infinite} .art .a-speed rect:nth-child(2){animation-delay:-.3s}.art .a-speed rect:nth-child(3){animation-delay:-.55s} @keyframes a-speed{from{transform:translateX(10px);opacity:0}30%{opacity:1}to{transform:translateX(-14px);opacity:0}} .art .a-bounce{animation:a-bounce .8s cubic-bezier(.3,0,.3,1) infinite} @keyframes a-bounce{50%{transform:translateY(-5px)}} .art .a-tie{transform-origin:100% 50%;animation:a-tie .4s ease-in-out infinite alternate} @keyframes a-tie{to{transform:rotate(-12deg) scaleX(.9)}} .art .a-drip{animation:a-drip 1.6s ease-in infinite} @keyframes a-drip{0%{opacity:0;transform:none}20%{opacity:1}100%{opacity:0;transform:translate(6px,10px)}} .art .a-antenna{transform-origin:50% 100%;animation:a-antenna 1.8s ease-in-out infinite} @keyframes a-antenna{25%{transform:rotate(-6deg)}75%{transform:rotate(6deg)}} .art .a-sweep{animation:a-sweep 4s ease-in-out infinite} @keyframes a-sweep{0%,100%{transform:none}35%{transform:translate(-22px,4px)}65%{transform:translate(-8px,-12px)}} .art .a-bubble circle{animation:a-rise 3s ease-in infinite} .art .a-bubble circle:nth-child(2){animation-delay:1s}.art .a-bubble circle:nth-child(3){animation-delay:2s} @keyframes a-rise{0%{opacity:0;transform:translateY(10px)}20%{opacity:1}100%{opacity:0;transform:translateY(-20px)}} .art .a-turn{transform-origin:center;animation:a-turn 2.4s ease-in-out infinite alternate} @keyframes a-turn{to{transform:scaleX(.2)}} .art .a-hour{transform-origin:50% 100%;animation:a-spin 24s linear infinite} .art .a-minute{transform-origin:50% 100%;animation:a-spin 4s linear infinite} @keyframes a-spin{to{transform:rotate(360deg)}} .art .a-drop{animation:a-drop 3.4s cubic-bezier(.5,0,.3,1) infinite} @keyframes a-drop{0%,100%{transform:translateY(-40px)}45%,80%{transform:none}} .art .a-peek{animation:a-peek 4.8s cubic-bezier(.3,0,.3,1) infinite} @keyframes a-peek{0%,100%{transform:translateY(34px)}30%,85%{transform:none}} .art .a-ask{transform-origin:0 100%;animation:a-ask 4.8s ease-out infinite} @keyframes a-ask{0%,30%{transform:scale(0)}38%{transform:scale(1.12)}44%,82%{transform:none}92%,100%{transform:scale(0)}} .art .a-take{animation:a-take 2.8s ease-in-out infinite} .art .a-say{animation:a-say 2.8s ease-in-out infinite} .art .a-take.a-late,.art .a-say.a-late{animation-delay:-1.4s!important} @keyframes a-take{0%,50%,100%{transform:none}15%,35%{transform:translateY(-4px)}} @keyframes a-say{0%,50%,100%{opacity:0}12%,38%{opacity:1}} .art .a-needle{transform-origin:center;animation:a-needle 4s ease-in-out infinite} @keyframes a-needle{0%,64%,100%{transform:none}12%{transform:rotate(-40deg)}28%{transform:rotate(24deg)}42%{transform:rotate(-10deg)}54%{transform:rotate(4deg)}} .art .a-ship{animation:a-ship 3.2s cubic-bezier(.3,0,.3,1) infinite} @keyframes a-ship{0%{transform:translate(-24px,30px) scale(.5);opacity:0}35%,75%{transform:none;opacity:1}100%{transform:translateY(-16px);opacity:0}} .art .a-groove{transform-origin:50% 100%;animation:a-groove 1.2s ease-in-out infinite} @keyframes a-groove{25%{transform:rotate(-4deg)}75%{transform:rotate(4deg)}} .art .a-note{animation:a-note 2.4s ease-out infinite} @keyframes a-note{0%{opacity:0;transform:translateY(8px)}30%{opacity:1}100%{opacity:0;transform:translateY(-12px)}} @media (prefers-reduced-motion:reduce){.art *{animation:none!important}} `;