Branchwell

Skillfarm / website · skillfarm.ai / src / views / art.ts

Raw 16.9 KB on 443f4fb7f176dfa237ca639945f31e22fbe94e8c
1// Flat, 2D artwork drawn as inline SVG. No gradients, no filters.
2import { raw } from 'hono/html';
3
4export const SPROUT_PATH = 'M230 460 V386 C230 358 140 344 102 240 C180 234 230 268 230 310 V292 C230 172 318 86 446 70 C440 196 350 262 296 284 C276 292 270 302 270 324 V460 A20 20 0 0 1 230 460Z';
5
6export const sprout = (size = 28, color = 'currentColor', cls = '') =>
7 raw(`<svg class="${cls}" width="${size}" height="${size}" viewBox="0 0 512 512" aria-hidden="true"><path fill="${color}" transform="translate(-6 0)" d="${SPROUT_PATH}"/></svg>`);
8
9const ICONS: Record<string, string> = {
10 leaf: '<path d="M6 18 C5 10 10 5 19 5 C19 14 14 19 6 18Z"/><path d="M6 18 L13 11"/><path d="M6 18 L3.5 20.5"/>',
11 'leaf-filled': '<path d="M6 18 C5 10 10 5 19 5 C19 14 14 19 6 18Z" fill="currentColor"/><path d="M6 18 L3.5 20.5"/>',
12 star: '<path d="M12 3.6l2.6 5.3 5.8.8-4.2 4.1 1 5.8L12 16.9 6.8 19.6l1-5.8L3.6 9.7l5.8-.8L12 3.6z"/>',
13 download: '<path d="M12 4v11"/><path d="M7.5 11 12 15.5 16.5 11"/><path d="M5 19.5h14"/>',
14 replant: '<path d="M12 21v-8"/><path d="M12 13c0-3-2-5-6-5 0 3 2 5 6 5z"/><path d="M12 11c0-3.5 2-6 6.5-6 0 3.500-2 6-6.5 6z"/><path d="M4 21h16"/>',
15 search: '<circle cx="11" cy="11" r="6.5"/><path d="M16 16l4.5 4.5"/>',
16 external: '<path d="M7 7h10v10"/><path d="M7 17 17 7"/>',
17 copy: '<rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V6a2 2 0 0 1 2-2h9"/>',
18 send: '<path d="M20.500 3.500 3.500 10l6.500 3.500L13.500 20l7-16.500z"/><path d="M10 13.500l10.500-10"/>',
19 help: '<circle cx="12" cy="12" r="8.500"/><path d="M9.500 9.500a2.500 2.500 0 1 1 3.500 2.300c-.700.400-1 1-1 1.700"/><path d="M12 16.500v.100"/>',
20 check: '<path d="M5 12.5l4.5 4.5L19 7.500"/>',
21 flag: '<path d="M6 21V4"/><path d="M6 5h11l-2 4 2 4H6"/>',
22 seed: '<path d="M12 21c-4.500 0-7-3.500-7-7.500C5 8 9 4 12 3c3 1 7 5 7 10.500 0 4-2.500 7.500-7 7.500z"/><path d="M12 21V11"/>',
23 shield: '<path d="M12 3l7 3v5.500c0 4.500-3 8-7 9.500-4-1.500-7-5-7-9.500V6l7-3z"/><path d="M9 12l2.200 2.200L15 10.500"/>',
24 fork: '<circle cx="7" cy="5.500" r="2"/><circle cx="17" cy="5.500" r="2"/><circle cx="12" cy="18.500" r="2"/><path d="M7 7.500v2a3 3 0 0 0 3 3h4a3 3 0 0 0 3-3v-2"/><path d="M12 12.500v4"/>',
25 clock: '<circle cx="12" cy="12" r="8.500"/><path d="M12 7.500V12l3 2"/>',
26 file: '<path d="M7 3.500h7l4 4V20a.5.5 0 0 1-.5.5h-10.500A.5.5 0 0 1 6.500 20V4a.5.5 0 0 1 .5-.5z"/><path d="M14 3.500V8h4"/>',
27 plug: '<path d="M9 3v5"/><path d="M15 3v5"/><path d="M6.500 8h11v3a5.500 5.500 0 0 1-11 0V8z"/><path d="M12 16.500V21"/>',
28 menu: '<path d="M4 7h16"/><path d="M4 12h16"/><path d="M4 17h16"/>',
29 share: '<circle cx="6.5" cy="12" r="2.3"/><circle cx="17" cy="6" r="2.3"/><circle cx="17" cy="18" r="2.3"/><path d="M8.6 10.900 14.900 7.200"/><path d="M8.6 13.100 14.900 16.800"/>',
30 comment: '<path d="M5 5h14a1.500 1.500 0 0 1 1.500 1.500v8A1.500 1.500 0 0 1 19 16h-7l-4 3.500V16H5a1.500 1.500 0 0 1-1.500-1.500v-8A1.500 1.500 0 0 1 5 5z"/>',
31 lock: '<rect x="5" y="10.5" width="14" height="10" rx="2"/><path d="M8 10.5V7.500a4 4 0 0 1 8 0v3"/><path d="M12 14.500v2"/>',
32};
33
34// Social marks, the same ones the other sites use.
35const BRAND: Record<string, string> = {
36 x: '<path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/>',
37 linkedin: '<path d="M20.45 20.45h-3.56v-5.57c0-1.33-.02-3.04-1.85-3.04-1.85 0-2.14 1.45-2.14 2.94v5.67H9.35V9h3.41v1.56h.05c.48-.9 1.64-1.85 3.37-1.85 3.6 0 4.27 2.37 4.27 5.46v6.28ZM5.34 7.43a2.06 2.06 0 1 1 0-4.13 2.06 2.06 0 0 1 0 4.13ZM7.12 20.45H3.56V9h3.56v11.45ZM22.22 0H1.77C.79 0 0 .77 0 1.73v20.54C0 23.23.79 24 1.77 24h20.45c.98 0 1.78-.77 1.78-1.73V1.73C24 .77 23.2 0 22.22 0Z"/>',
38 youtube: '<path fill-rule="evenodd" d="M23.5 6.2a3 3 0 0 0-2.1-2.1C19.5 3.6 12 3.6 12 3.6s-7.5 0-9.4.5A3 3 0 0 0 .5 6.2 31.4 31.4 0 0 0 0 12a31.4 31.4 0 0 0 .5 5.8 3 3 0 0 0 2.1 2.1c1.9.5 9.4.5 9.4.5s7.5 0 9.4-.5a3 3 0 0 0 2.1-2.1A31.4 31.4 0 0 0 24 12a31.4 31.4 0 0 0-.5-5.8ZM9.6 15.6V8.4l6.2 3.6-6.2 3.6Z"/>',
39 instagram: '<g fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="5"/><circle cx="12" cy="12" r="4"/></g><circle cx="17.5" cy="6.5" r="1.2"/>',
40 reddit: '<g fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="12" cy="14" rx="9" ry="6"/><path d="m13 8 1.5-5 4 1M3.5 11a2.5 2.5 0 1 0-2 4M20.5 11a2.5 2.5 0 1 1 2 4M8 16c2 2 6 2 8 0"/><circle cx="20" cy="4" r="2"/></g><circle cx="8" cy="13" r="1.3"/><circle cx="16" cy="13" r="1.3"/>',
41 substack: '<path d="M22.54 8.24H1.46V5.41h21.08v2.83ZM1.46 10.81V24L12 18.11 22.54 24V10.81H1.46ZM22.54 0H1.46v2.84h21.08V0Z"/>',
42 makerworld: '<g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/></g>',
43};
44
45export function icon(name: string, size = 18, cls = '') {
46 if (BRAND[name]) return raw(`<svg class="${cls}" width="${size}" height="${size}" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">${BRAND[name]}</svg>`);
47 const body = ICONS[name] ?? '';
48 return raw(`<svg class="${cls}" width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${body}</svg>`);
49}
50
51// ---------------------------------------------------------------------------
52// Illustration system. Everything below is built from four primitives on a
53// fixed grid: the logo sprout, a two-arc leaf, circles and rounded rectangles.
54// Flat fills only, at most two tones per glyph.
55// ---------------------------------------------------------------------------
56
57const n = (v: number) => Math.round(v * 100) / 100;
58
59/** A leaf: two equal arcs between two points. `slim` > 0.71 makes it narrower. */
60function leaf(ax: number, ay: number, bx: number, by: number, slim = 0.76) {
61 const r = n(Math.hypot(bx - ax, by - ay) * slim);
62 return `M${n(ax)} ${n(ay)}A${r} ${r} 0 0 1 ${n(bx)} ${n(by)}A${r} ${r} 0 0 1 ${n(ax)} ${n(ay)}Z`;
63}
64
65/** The logo sprout, centred on (cx, cy) and `h` units tall. */
66function sproutGlyph(cx: number, cy: number, h: number, color: string) {
67 const k = n(h / 410);
68 return `<path fill="${color}" transform="translate(${cx} ${cy}) scale(${k}) translate(-274 -275)" d="${SPROUT_PATH}"/>`;
69}
70
71/** The Skillfarm mark as an app icon: cream sprout on a sage rounded square. */
72export function brandMark(size = 32, cls = '') {
73 return raw(`<svg class="brand-mark ${cls}" width="${size}" height="${size}" viewBox="0 0 512 512" aria-hidden="true"><rect width="512" height="512" rx="116" fill="#5A8A4A"/><rect x="6" y="6" width="500" height="500" rx="110" fill="none" stroke="#3F6B34" stroke-opacity=".55" stroke-width="12"/>${sproutGlyph(256, 256, 312, '#FFFBEF')}</svg>`);
74}
75
76/** Homepage art: farm plots seen from above, each one a skill. */
77export function heroScene() {
78 const pill = (x: number, y: number, label: string) => {
79 const w = 30 + label.length * 7.6;
80 return `<g transform="translate(${x} ${y})"><rect width="${n(w)}" height="26" rx="13" fill="#FFFBEF"/><circle cx="13" cy="13" r="4" fill="#5A8A4A"/><text x="23" y="17.500" font-family="Figtree, system-ui, sans-serif" font-size="13" font-weight="700" fill="#3A1F0F">${label}</text></g>`;
81 };
82 const tree = (x: number, y: number, r: number) => `<circle cx="${x}" cy="${y}" r="${r}" fill="#3F6B34"/>`;
83 return raw(`<svg class="hero-art" viewBox="0 0 720 540" role="img" aria-label="A flat illustration of farm plots seen from above: striped crop rows, a round irrigated field, a wheat field, an orchard, a pond and a barn. Small labels mark plots as skills.">
84 <defs>
85 <pattern id="hp-rows-a" x="24" width="16" height="16" patternUnits="userSpaceOnUse"><rect width="16" height="16" fill="#5A8A4A"/><rect width="6" height="16" fill="#6E9C5C"/></pattern>
86 <pattern id="hp-rows-b" y="206" width="16" height="16" patternUnits="userSpaceOnUse"><rect width="16" height="16" fill="#93B87A"/><rect width="16" height="8" fill="#A8C790"/></pattern>
87 <pattern id="hp-rows-c" x="467" width="14" height="14" patternUnits="userSpaceOnUse"><rect width="14" height="14" fill="#6E9C5C"/><rect width="5" height="14" fill="#5A8A4A"/></pattern>
88 <pattern id="hp-wheat" width="16" height="16" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"><rect width="16" height="16" fill="#F2B93B"/><rect width="6" height="16" fill="#F6CC6A"/></pattern>
89 <pattern id="hp-soil" y="386" width="14" height="14" patternUnits="userSpaceOnUse"><rect width="14" height="14" fill="#8C5A3C"/><rect width="14" height="4" fill="#7A4B30"/></pattern>
90 <pattern id="hp-orchard" x="24" y="206" width="28" height="28" patternUnits="userSpaceOnUse"><rect width="28" height="28" fill="#DDEBC8"/><circle cx="14" cy="14" r="7" fill="#5A8A4A"/></pattern>
91 </defs>
92 <rect width="720" height="540" rx="28" fill="#EFE4C3"/>
93 <rect x="24" y="24" width="214" height="170" rx="14" fill="url(#hp-rows-a)"/>
94 <rect x="250" y="24" width="172" height="170" rx="14" fill="#BCD6A2"/>
95 <g transform="translate(336 109)"><circle r="72" fill="#5A8A4A"/><circle r="56" fill="#6E9C5C"/><circle r="40" fill="#5A8A4A"/><circle r="24" fill="#6E9C5C"/><path d="M0 0L50.900 -50.900" stroke="#FFFBEF" stroke-width="3" stroke-linecap="round"/><circle r="6" fill="#FFFBEF"/></g>
96 <rect x="434" y="24" width="262" height="170" rx="14" fill="url(#hp-wheat)"/>
97 <rect x="24" y="206" width="140" height="168" rx="14" fill="url(#hp-orchard)"/>
98 <rect x="176" y="206" width="300" height="168" rx="14" fill="url(#hp-rows-b)"/>
99 <rect x="488" y="206" width="208" height="168" rx="14" fill="#E3D3AB"/>
100 <g transform="translate(0 2)">
101 <rect x="512" y="232" width="100" height="68" rx="6" fill="#C4552D"/><path d="M512 266h100v28a6 6 0 0 1-6 6h-88a6 6 0 0 1-6-6z" fill="#A8431F"/>
102 <circle cx="652" cy="266" r="24" fill="#FFFBEF"/><circle cx="652" cy="266" r="15" fill="#E3D7B8"/><circle cx="652" cy="266" r="5" fill="#FFFBEF"/>
103 <rect x="512" y="322" width="26" height="22" rx="5" fill="#F2B93B"/><rect x="546" y="322" width="26" height="22" rx="5" fill="#F2B93B"/><rect x="580" y="322" width="26" height="22" rx="5" fill="#F6CC6A"/>
104 ${tree(652, 330, 14)}${tree(676, 312, 9)}
105 </g>
106 <rect x="24" y="386" width="249" height="130" rx="14" fill="#BCD6A2"/>
107 <ellipse cx="118" cy="451" rx="58" ry="34" fill="#8DB7DA"/><ellipse cx="118" cy="451" rx="38" ry="20" fill="#A5C8E4"/>
108 ${tree(206, 424, 14)}${tree(236, 455, 10)}${tree(204, 484, 12)}${tree(52, 412, 9)}
109 <rect x="285" y="386" width="170" height="130" rx="14" fill="url(#hp-soil)"/>
110 <rect x="467" y="386" width="229" height="130" rx="14" fill="url(#hp-rows-c)"/>
111 ${pill(44, 44, 'pdf-forms')}${pill(454, 148, 'changelog')}${pill(196, 328, 'test-hunter')}${pill(305, 406, 'new plot')}${pill(560, 470, 'api-docs')}
112</svg>`);
113}
114
115/** One shallow hill between two flat colour fields. */
116export function hillEdge(fill: string, flip = false) {
117 return raw(`<svg class="hill-edge${flip ? ' flip' : ''}" viewBox="0 0 1440 64" preserveAspectRatio="none" aria-hidden="true"><path fill="${fill}" d="M0 64V48Q720 -32 1440 48V64Z"/></svg>`);
118}
119
120// Tier badges: one round seal per tier, one glyph each, drawn on a 64 grid.
121const stem = (top: number, bottom: number, color: string) => `<rect x="30.500" y="${top}" width="3" height="${bottom - top}" rx="1.500" fill="${color}"/>`;
122const pair = (y: number, dx: number, dy: number, color: string, slim = 0.76) =>
123 `<path fill="${color}" d="${leaf(32, y, 32 - dx, y - dy, slim)}${leaf(32 + dx, y - dy, 32, y, slim)}"/>`;
124
125const TIER_ART: Record<string, { tint: string; ink: string; glyph: string }> = {
126 seedling: { tint: '#E4EFD3', ink: '#5A8A4A', glyph: sproutGlyph(32, 32.500, 30, '#5A8A4A') },
127 grower: {
128 tint: '#CFE2B8', ink: '#3F6B34',
129 glyph: `${stem(20, 50, '#3F6B34')}${pair(44, 13, 9, '#3F6B34')}${pair(33, 11, 8, '#3F6B34')}<path fill="#3F6B34" d="${leaf(32, 24, 32, 11, 0.68)}"/>`,
130 },
131 farmer: {
132 tint: '#FBE7B2', ink: '#9A5F10',
133 glyph: `<rect x="24" y="12" width="16" height="3.500" rx="1.750" fill="#9A5F10"/><rect x="30.250" y="12" width="3.500" height="24" rx="1.750" fill="#9A5F10"/><path fill="#9A5F10" d="M23 33h18v8.500c0 5.500-4 9.500-9 11.500c-5-2-9-6-9-11.500z"/>`,
134 },
135 harvester: {
136 tint: '#F8D5C4', ink: '#B5471F',
137 glyph: `${stem(24, 52, '#B5471F')}${pair(47, 9, 8, '#B5471F', 0.9)}${pair(39, 9, 8, '#B5471F', 0.9)}${pair(31, 9, 8, '#B5471F', 0.9)}<path fill="#B5471F" d="${leaf(32, 25, 32, 11, 0.8)}"/>`,
138 },
139 homesteader: {
140 tint: '#EAD3C3', ink: '#6E2F1B',
141 glyph: `<path fill="#6E2F1B" d="M15 33l4.500-11L32 13l12.500 9L49 33z"/><rect x="18" y="33" width="28" height="18" fill="#8C4A2F"/><rect x="27" y="39" width="10" height="12" rx="1.500" fill="#EAD3C3"/><circle cx="32" cy="25" r="3.200" fill="#EAD3C3"/>`,
142 },
143 'blue-ribbon': {
144 tint: '#D5E3F4', ink: '#2F5C94',
145 glyph: `<path fill="#3F74B5" d="M24 34l8 3-4 16-3.500-4.500L20 51z"/><path fill="#3F74B5" d="M40 34l-8 3 4 16 3.500-4.500L44 51z"/><g fill="#2F5C94">${Array.from({ length: 12 }, (_, i) => `<circle cx="${n(32 + 11.500 * Math.cos((i * Math.PI) / 6))}" cy="${n(26 + 11.500 * Math.sin((i * Math.PI) / 6))}" r="3.800"/>`).join('')}<circle cx="32" cy="26" r="12"/></g><circle cx="32" cy="26" r="7.500" fill="#D5E3F4"/>${sproutGlyph(32, 26, 9.500, '#2F5C94')}`,
146 },
147};
148
149export function tierArt(key: string, size = 40) {
150 const t = TIER_ART[key] ?? TIER_ART.seedling;
151 return raw(`<svg class="tier-art" width="${size}" height="${size}" viewBox="0 0 64 64" aria-hidden="true"><circle cx="32" cy="32" r="32" fill="${t.tint}"/><circle cx="32" cy="32" r="30.500" fill="none" stroke="${t.ink}" stroke-opacity=".22" stroke-width="1.500"/>${t.glyph}</svg>`);
152}
153
154const AVATAR_TINTS = [
155 ['#CFE2B8', '#3F6B34'], ['#FBE7B2', '#8C4A2F'], ['#F8D5C4', '#8C3B22'], ['#D5E3F4', '#2F5C94'], ['#DDEBE3', '#3F6B34'], ['#EAD3C3', '#6E2F1B'],
156];
157
158/** Default avatar: a sprout on a flat tint chosen from the member id. */
159export function defaultAvatar(seed: string, size: number) {
160 let h = 0;
161 for (let i = 0; i < seed.length; i++) h = (h * 31 + seed.charCodeAt(i)) >>> 0;
162 const [bg, fg] = AVATAR_TINTS[h % AVATAR_TINTS.length];
163 return raw(`<svg class="avatar" width="${size}" height="${size}" viewBox="0 0 48 48" aria-hidden="true"><rect width="48" height="48" fill="${bg}"/>${sproutGlyph(24, 24.500, 26, fg)}</svg>`);
164}
165
166const drop = (x: number, y: number, color: string) =>
167 `<path fill="${color}" d="M${x} ${y - 8}C${x + 2.500} ${y - 4} ${x + 5.500} ${y - 1} ${x + 5.500} ${y + 2.500}A5.500 5.500 0 0 1 ${x - 5.500} ${y + 2.500}C${x - 5.500} ${y - 1} ${x - 2.500} ${y - 4} ${x} ${y - 8}Z"/>`;
168
169/** Spot icons: a rounded-square tile with one glyph, on a 72 grid. */
170export function spot(name: 'plant' | 'tend' | 'harvest' | 'empty' | 'mcp' | 'news' | 'coffee') {
171 const ground = (color: string) => `<rect x="14" y="52" width="44" height="6" rx="3" fill="${color}"/>`;
172 const art: Record<string, string> = {
173 plant: `<rect width="72" height="72" rx="18" fill="#FBE7B2"/>${ground('#8C5A3C')}<path fill="#B5471F" d="${leaf(36, 40, 36, 16, 0.62)}"/><circle cx="36" cy="46.500" r="1.800" fill="#8C5A3C"/>`,
174 tend: `<rect width="72" height="72" rx="18" fill="#D9E8F2"/>${ground('#8C5A3C')}${sproutGlyph(36, 39, 24, '#5A8A4A')}${drop(18, 26, '#3F74B5')}${drop(54, 26, '#3F74B5')}${drop(36, 16, '#3F74B5')}`,
175 harvest: `<rect width="72" height="72" rx="18" fill="#F8D5C4"/><circle cx="36" cy="42" r="15" fill="#C4552D"/><rect x="34.500" y="19" width="3" height="10" rx="1.500" fill="#6E2F1B"/><path fill="#5A8A4A" d="${leaf(37, 24, 50, 15, 0.74)}"/>`,
176 empty: `<rect width="72" height="72" rx="18" fill="#F0E6C8"/><rect x="15" y="19" width="42" height="34" rx="9" fill="none" stroke="#A98F68" stroke-width="2.500" stroke-dasharray="5 6" stroke-linecap="round"/><path fill="#8C5A3C" d="${leaf(31, 42, 41, 30, 0.74)}"/>`,
177 news: `<rect width="72" height="72" rx="18" fill="#FBE7B2"/><rect x="13" y="21" width="46" height="32" rx="7" fill="#FFFBEF"/><path fill="#E9A23B" d="M13 28a7 7 0 0 1 7-7h32a7 7 0 0 1 7 7v.500L38.900 41.800a5 5 0 0 1-5.800 0L13 28.500z"/>`,
178 coffee: `<rect width="72" height="72" rx="18" fill="#EAD3C3"/><path fill="#6E2F1B" d="M17 30h30v14a12 12 0 0 1-12 12h-6a12 12 0 0 1-12-12z"/><path fill="none" stroke="#6E2F1B" stroke-width="4" d="M47 34h3.500a6.500 6.500 0 0 1 0 13H46"/><rect x="24.500" y="15" width="3.500" height="10" rx="1.750" fill="#B5471F"/><rect x="36" y="15" width="3.500" height="10" rx="1.750" fill="#B5471F"/>`,
179 mcp: `<rect width="72" height="72" rx="18" fill="#5A8A4A"/><rect x="12" y="17" width="48" height="38" rx="8" fill="#FFFBEF"/><path d="M22 29l7 7-7 7" stroke="#3A1F0F" stroke-width="3.500" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M35 43h13" stroke="#5A8A4A" stroke-width="3.500" stroke-linecap="round"/>`,
180 };
181 return raw(`<svg class="spot" width="72" height="72" viewBox="0 0 72 72" aria-hidden="true">${art[name]}</svg>`);
182}