Skip to content

Isometric line figures that answer the pointer. For React and for anything with a DOM.

Site: /skill becomes /skills, with hairline-adopt and its four examples beside hairline-create

Lucas Marques4f6ab3763dda
diff --git a/README.md b/README.md
index b0fc0af..54f1586 100644
--- a/README.md
+++ b/README.md
@@ -152,7 +152,7 @@ With a drawing you already have, an icon or a logo as an SVG, `hairline-adopt` r
/hairline-adopt icons/deploy.svg
```
-Four figures it drew, each beside its prompt: [hairline.lucasmarkes.com/skill](https://hairline.lucasmarkes.com/skill).
+What both skills drew, each beside its prompt: [hairline.lucasmarkes.com/skills](https://hairline.lucasmarkes.com/skills).
## More
diff --git a/apps/site/app/figures/page.tsx b/apps/site/app/figures/page.tsx
index ab13785..a8e93ed 100644
--- a/apps/site/app/figures/page.tsx
+++ b/apps/site/app/figures/page.tsx
@@ -41,7 +41,7 @@ export default async function Figures() {
header={
<header className="hero-rise">
<h1 className="col-h1" style={at(0)}>Every figure, by what it <em>draws</em>.</h1>
- <p className="col-lede" style={at(1)}>{LEAD} <a className="doc-more" href="/skill">{SKILL}</a> {TAIL}</p>
+ <p className="col-lede" style={at(1)}>{LEAD} <a className="doc-more" href="/skills">{SKILL}</a> {TAIL}</p>
</header>
}
end={
diff --git a/apps/site/app/skill/page.tsx b/apps/site/app/skill/page.tsx
deleted file mode 100644
index b27942e..0000000
--- a/apps/site/app/skill/page.tsx
+++ /dev/null
@@ -1,124 +0,0 @@
-import type { Metadata } from "next";
-import type { CSSProperties, ReactNode } from "react";
-import { Anchor } from "@/components/anchor";
-import { Footer, Topbar } from "@/components/chrome";
-import { Command } from "@/components/command";
-import { ExampleFrame } from "@/components/example-frame";
-import { Rail } from "@/components/rail";
-import { NOTICE } from "@/lib/catalogue";
-import { COUNT, LINKS } from "@/lib/figures";
-import { share } from "@/lib/share";
-import { COMMAND, FOLDER, INSTALL, STEPS, SUMMARY, USE, examples } from "@/lib/skill";
-
-/** The file the skill writes, set as code where a line names it. USE stays plain text for llms.txt. */
-const FILE = "hairline-<name>.html";
-const named = (line: string) => {
- const i = line.indexOf(FILE);
- if (i < 0) return line;
- return <>{line.slice(0, i)}<code className="doc-code">{FILE}</code>{line.slice(i + FILE.length)}</>;
-};
-
-/** A block's place in the header's entrance. */
-const at = (i: number) => ({ "--i": i }) as CSSProperties;
-
-export const metadata: Metadata = share("/skill", "Make your own figure", SUMMARY);
-
-const RAIL = [
- {
- title: "hairline-create",
- icon: "sparkle" as const,
- color: "#8b5cf6",
- items: [
- { id: "install", title: "Install" },
- { id: "use", title: "How to use it" },
- { id: "how", title: "How it works" },
- { id: "examples", title: "What it draws" },
- ],
- },
-];
-
-/** A section in the column: its title beside a button that copies its link. */
-function Section({ id, title, children }: { id: string; title: string; children: ReactNode }) {
- return (
- <section id={id} aria-labelledby={`${id}-title`} className="doc-section">
- <div className="doc-head">
- <h2 id={`${id}-title`} className="doc-h2">{title}</h2>
- <Anchor id={id} title={title} />
- </div>
- {children}
- </section>
- );
-}
-
-/**
- * The skill's page, as a catalogue: how to get it and use it, then each idea it has drawn, on a card with the line
- * that asked for it and the page it wrote, in a frame. A Server Component: it reads each example's name and meaning
- * from that page.
- */
-export default function Skill() {
- const shown = examples();
- return (
- <>
- <Topbar />
- <Rail label="Skill" groups={RAIL} />
- <main className="col skill">
- {/* the home's hero sends people here, and the header arrives as the hero does */}
- <header className="hero-rise">
- <p className="col-label" style={at(0)}>Skill</p>
- <h1 className="col-h1" style={at(1)}>Make your own figure</h1>
- <p className="col-lede" style={at(2)}>{SUMMARY}</p>
- </header>
-
- <Section id="install" title="Install">
- <Command code={INSTALL} kind="install" label="Copy install command" />
- <p className="doc-p">{FOLDER}</p>
- </Section>
-
- <Section id="use" title="How to use it">
- <Command code={`${COMMAND} <idea>`} kind="usage" label="Copy command" />
- <ul role="list" className="doc-list">
- {USE.map((line) => <li key={line}>{named(line)}</li>)}
- </ul>
- </Section>
-
- <Section id="how" title="How it works">
- <ol className="howto" data-steps>
- {STEPS.map((s) => (
- <li key={s.title}><span><b>{s.title}.</b> {s.text}</span></li>
- ))}
- </ol>
- </Section>
-
- <Section id="examples" title="What it draws">
- <p className="doc-p">Seven ideas, seven files. The last three start from a company&rsquo;s mark. Each one opens from disk with no dependencies. Move the pointer over one.</p>
- {shown.map((e) => (
- <article key={e.file} className="card ex" data-example={e.name} aria-label={e.prompt}>
- <div className="ex-h">
- <Command code={e.prompt} kind="prompt" label={`Copy prompt: ${e.idea}`} />
- </div>
- <div className="ex-b">
- <p className="ex-name">{e.name}</p>
- <p className="ex-means">{e.means}</p>
- {e.followUp && (
- <div className="ex-fu">
- <p className="ex-then">Then asked</p>
- <Command code={e.followUp} kind="follow-up" label={`Copy follow-up: ${e.idea}`} />
- </div>
- )}
- </div>
- <div className="ex-f example-figure">
- <ExampleFrame src={`${e.href}?theme=light`} title={e.means} />
- </div>
- </article>
- ))}
- <p className="doc-p">{NOTICE}</p>
- </Section>
-
- <p className="col-end">
- The {COUNT} figures and their options are in <a className="doc-more" href="/docs">the docs</a>. The skill&rsquo;s files are in <a className="doc-more" href={`${LINKS.github}/tree/main/skills/hairline-create`}>its folder on GitHub</a>.
- </p>
- </main>
- <Footer />
- </>
- );
-}
diff --git a/apps/site/app/skills/page.tsx b/apps/site/app/skills/page.tsx
new file mode 100644
index 0000000..ace8ac3
--- /dev/null
+++ b/apps/site/app/skills/page.tsx
@@ -0,0 +1,163 @@
+import type { Metadata } from "next";
+import type { CSSProperties, ReactNode } from "react";
+import { Anchor } from "@/components/anchor";
+import { Footer, Topbar } from "@/components/chrome";
+import { Command } from "@/components/command";
+import { ExampleFrame } from "@/components/example-frame";
+import { Rail } from "@/components/rail";
+import { NOTICE } from "@/lib/catalogue";
+import { COUNT, LINKS } from "@/lib/figures";
+import { share } from "@/lib/share";
+import { ADOPT, ADOPTED, ADOPT_STEPS, ADOPT_USE, COMMAND, FOLDER, INSTALL, STEPS, SUMMARY, USE, examples, type Shown } from "@/lib/skill";
+
+/** The file the skill writes, set as code where a line names it. USE stays plain text for llms.txt. */
+const FILE = "hairline-<name>.html";
+const named = (line: string) => {
+ const i = line.indexOf(FILE);
+ if (i < 0) return line;
+ return <>{line.slice(0, i)}<code className="doc-code">{FILE}</code>{line.slice(i + FILE.length)}</>;
+};
+
+/** A block's place in the header's entrance. */
+const at = (i: number) => ({ "--i": i }) as CSSProperties;
+
+export const metadata: Metadata = share("/skills", "Make your own figure", SUMMARY);
+
+const RAIL = [
+ {
+ title: "hairline-create",
+ icon: "sparkle" as const,
+ color: "#8b5cf6",
+ items: [
+ { id: "install", title: "Install" },
+ { id: "use", title: "How to use it" },
+ { id: "how", title: "How it works" },
+ { id: "examples", title: "What it draws" },
+ ],
+ },
+ {
+ title: "hairline-adopt",
+ icon: "path" as const,
+ color: "#10b981",
+ items: [
+ { id: "adopt-use", title: "Start from an SVG" },
+ { id: "adopt-how", title: "How it reads a drawing" },
+ { id: "adopt-examples", title: "What it made" },
+ ],
+ },
+];
+
+/** A section in the column: its title beside a button that copies its link. */
+function Section({ id, title, children }: { id: string; title: string; children: ReactNode }) {
+ return (
+ <section id={id} aria-labelledby={`${id}-title`} className="doc-section">
+ <div className="doc-head">
+ <h2 id={`${id}-title`} className="doc-h2">{title}</h2>
+ <Anchor id={id} title={title} />
+ </div>
+ {children}
+ </section>
+ );
+}
+
+/** One example: the line that asked for it, what its figure means, and the page the skill wrote, in a frame. */
+function Example({ e }: { e: Shown }) {
+ return (
+ <article className="card ex" data-example={e.name} aria-label={e.prompt}>
+ <div className="ex-h">
+ <Command code={e.prompt} kind="prompt" label={`Copy prompt: ${e.idea}`} />
+ </div>
+ <div className="ex-b">
+ <p className="ex-name">{e.name}</p>
+ <p className="ex-means">{e.means}</p>
+ {e.followUp && (
+ <div className="ex-fu">
+ <p className="ex-then">Then asked</p>
+ <Command code={e.followUp} kind="follow-up" label={`Copy follow-up: ${e.idea}`} />
+ </div>
+ )}
+ </div>
+ <div className="ex-f example-figure">
+ <ExampleFrame src={`${e.href}?theme=light`} title={e.means} />
+ </div>
+ </article>
+ );
+}
+
+/** The steps a skill takes, as a numbered list. */
+function Steps({ steps }: { steps: { title: string; text: string }[] }) {
+ return (
+ <ol className="howto" data-steps>
+ {steps.map((s) => (
+ <li key={s.title}><span><b>{s.title}.</b> {s.text}</span></li>
+ ))}
+ </ol>
+ );
+}
+
+/**
+ * The skills' page, as a catalogue: how to get them and use each, then what each has drawn, on a card with the line
+ * that asked for it and the page it wrote, in a frame. A Server Component: it reads each example's name and meaning
+ * from that page.
+ */
+export default function Skills() {
+ const drawn = examples();
+ const adopted = examples(ADOPTED, ADOPT);
+ return (
+ <>
+ <Topbar />
+ <Rail label="Skills" groups={RAIL} />
+ <main className="col skill">
+ {/* the home's hero sends people here, and the header arrives as the hero does */}
+ <header className="hero-rise">
+ <p className="col-label" style={at(0)}>Skills</p>
+ <h1 className="col-h1" style={at(1)}>Make your own figure</h1>
+ <p className="col-lede" style={at(2)}>{SUMMARY}</p>
+ </header>
+
+ <Section id="install" title="Install">
+ <Command code={INSTALL} kind="install" label="Copy install command" />
+ <p className="doc-p">{FOLDER}</p>
+ </Section>
+
+ <Section id="use" title="How to use it">
+ <Command code={`${COMMAND} <idea>`} kind="usage" label="Copy command" />
+ <ul role="list" className="doc-list">
+ {USE.map((line) => <li key={line}>{named(line)}</li>)}
+ </ul>
+ </Section>
+
+ <Section id="how" title="How it works">
+ <Steps steps={STEPS} />
+ </Section>
+
+ <Section id="examples" title="What it draws">
+ <p className="doc-p">Four ideas, four files. Each one opens from disk with no dependencies. Move the pointer over one.</p>
+ {drawn.map((e) => <Example key={e.file} e={e} />)}
+ </Section>
+
+ <Section id="adopt-use" title="Start from an SVG">
+ <Command code={`${ADOPT} <file.svg>`} kind="usage" label="Copy adopt command" />
+ <ul role="list" className="doc-list">
+ {ADOPT_USE.map((line) => <li key={line}>{named(line)}</li>)}
+ </ul>
+ </Section>
+
+ <Section id="adopt-how" title="How it reads a drawing">
+ <Steps steps={ADOPT_STEPS} />
+ </Section>
+
+ <Section id="adopt-examples" title="What it made">
+ <p className="doc-p">Four SVGs, four files. The rocket was drawn for the demo; the other three are companies&rsquo; marks. Each page took a few rounds of changes after the first line. Move the pointer over one.</p>
+ {adopted.map((e) => <Example key={e.file} e={e} />)}
+ <p className="doc-p">{NOTICE}</p>
+ </Section>
+
+ <p className="col-end">
+ The {COUNT} figures and their options are in <a className="doc-more" href="/docs">the docs</a>. The skills&rsquo; files are on GitHub, in <a className="doc-more" href={`${LINKS.github}/tree/main/skills/hairline-create`}>hairline-create</a> and <a className="doc-more" href={`${LINKS.github}/tree/main/skills/hairline-adopt`}>hairline-adopt</a>.
+ </p>
+ </main>
+ <Footer />
+ </>
+ );
+}
diff --git a/apps/site/components/catalogue.tsx b/apps/site/components/catalogue.tsx
index d043329..b354d23 100644
--- a/apps/site/components/catalogue.tsx
+++ b/apps/site/components/catalogue.tsx
@@ -375,7 +375,7 @@ function Detail({
{made ? (
<div className="detail-made">
<Command code={made.prompt} kind="prompt" label={`Copy prompt: ${entry.name}`} />
- <p className="doc-p">Made with <a className="doc-more" href="/skill">hairline-create</a>. It is not in the package: the page is one file, and the prompt above draws it again.</p>
+ <p className="doc-p">Made with <a className="doc-more" href="/skills">hairline-create</a>. It is not in the package: the page is one file, and the prompt above draws it again.</p>
<p className="doc-p figs-notice">{NOTICE}</p>
</div>
) : Figure ? (
diff --git a/apps/site/components/chrome.tsx b/apps/site/components/chrome.tsx
index b023942..38be814 100644
--- a/apps/site/components/chrome.tsx
+++ b/apps/site/components/chrome.tsx
@@ -9,7 +9,7 @@ export function GitHub() {
);
}
-/** The bar on every page: the name home with the version beside it, then the figures, the skill, the docs, the story, GitHub. */
+/** The bar on every page: the name home with the version beside it, then the figures, the skills, the docs, the story, GitHub. */
export function Topbar() {
return (
<header className="topbar">
@@ -19,7 +19,7 @@ export function Topbar() {
</div>
<nav className="flex items-center">
<a className="topbar-link" href="/figures">Figures</a>
- <a className="topbar-link" href="/skill">Skill</a>
+ <a className="topbar-link" href="/skills">Skills</a>
<a className="topbar-link" href="/docs">Docs</a>
<a className="topbar-link" href="/inspo">Inspo</a>
<a className="topbar-link" href={LINKS.github} aria-label="GitHub"><GitHub /></a>
diff --git a/apps/site/components/rail.tsx b/apps/site/components/rail.tsx
index 8d750b8..6b6df2f 100644
--- a/apps/site/components/rail.tsx
+++ b/apps/site/components/rail.tsx
@@ -2,7 +2,7 @@
import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ReactNode } from "react";
-export type RailIcon = "bolt" | "braces" | "stack" | "book" | "sparkle";
+export type RailIcon = "bolt" | "braces" | "stack" | "book" | "sparkle" | "path";
export type RailGroup = { title: string; icon: RailIcon; color: string; items: { id: string; title: string }[] };
const svg = (children: ReactNode) => (
@@ -38,6 +38,13 @@ const ICONS: Record<RailIcon, ReactNode> = {
<path d="M12.75 11.25v2.5M11.5 12.5H14" />
</>,
),
+ path: svg(
+ <>
+ <path d="M3 13c.5-5 3.5-9.5 10-10" />
+ <rect x="1.75" y="11.75" width="2.5" height="2.5" rx=".6" fill="currentColor" fillOpacity=".2" />
+ <rect x="11.75" y="1.75" width="2.5" height="2.5" rx=".6" fill="currentColor" fillOpacity=".2" />
+ </>,
+ ),
};
/**
diff --git a/apps/site/components/skill-link.tsx b/apps/site/components/skill-link.tsx
index 909a7e1..7a0b927 100644
--- a/apps/site/components/skill-link.tsx
+++ b/apps/site/components/skill-link.tsx
@@ -5,7 +5,7 @@
*/
export function SkillLink() {
return (
- <a className="skill-link" href="/skill">
+ <a className="skill-link" href="/skills">
<svg viewBox="0 0 16 16" width="15" height="15" fill="none" strokeWidth="1.1" strokeLinejoin="round" strokeLinecap="round" aria-hidden="true">
<path className="skill-link-hex" d="M8 1.5 13.6 4.75v6.5L8 14.5 2.4 11.25v-6.5z" />
<path className="skill-link-edge" pathLength={1} d="M8 8 2.4 4.75" />
diff --git a/apps/site/lib/llms.ts b/apps/site/lib/llms.ts
index 9a677b6..60c6d7b 100644
--- a/apps/site/lib/llms.ts
+++ b/apps/site/lib/llms.ts
@@ -1,7 +1,7 @@
import { NOTICE } from "./catalogue";
import { COUNT, FIGURES, INTENSITY, LINKS, OPTIONS, THEME, measure, type Row } from "./figures";
import { CDN, EMPTY, PACKAGE, REACT, VANILLA, install } from "./snippets";
-import { COMMAND, EXAMPLES, INSTALL, SUMMARY } from "./skill";
+import { ADOPT, ADOPTED, COMMAND, EXAMPLES, INSTALL, SUMMARY } from "./skill";
/** The page as plain text, for a model to read: the same data, the same copy. */
@@ -66,10 +66,12 @@ export function llms(base: string): string {
"", "## Make your own", "",
SUMMARY,
"", fence("sh", INSTALL),
- "", `Then type \`${COMMAND} <idea>\` in the agent. Seven ideas, each with the page the skill wrote for it, and the change asked for next where there was one:`,
+ "", `Then type \`${COMMAND} <idea>\` in the agent. Four ideas, each with the page the skill wrote for it, and the change asked for next where there was one:`,
"", EXAMPLES.map((e) => `- \`${COMMAND} ${e.idea}\`${e.followUp ? `, then "${e.followUp}"` : ""}: ${base}/skill/${e.file}`).join("\n"),
+ "", `Or start from an SVG you already have: type \`${ADOPT} <file.svg>\` and what the pointer should do. Four SVGs, each with the page it led to after a few rounds of changes:`,
+ "", ADOPTED.map((e) => `- \`${ADOPT} ${e.idea}\`: ${base}/skill/${e.file}`).join("\n"),
"", NOTICE,
- "", `More: ${base}/skill`,
+ "", `More: ${base}/skills`,
"", "## Links", "",
`- Site: ${base}`, `- Source: ${LINKS.github}`, `- npm: ${LINKS.npm}`, `- The essay the figures come from: ${LINKS.essay}`, `- shadcn registry item: ${base}/r/hairline.json`, "",
);
diff --git a/apps/site/lib/share.ts b/apps/site/lib/share.ts
index 998d324..8b7396c 100644
--- a/apps/site/lib/share.ts
+++ b/apps/site/lib/share.ts
@@ -6,7 +6,7 @@ import { cap } from "./words";
export const DESCRIPTION = `${cap(COUNT)} isometric line figures that answer the pointer. SVG, no dependencies, for React and for everything else.`;
/** The pages a reader can land on, in the top bar's order: the sitemap lists these. /og is left out, a picture to photograph. */
-export const PAGES = ["/", "/figures", "/docs", "/skill", "/inspo"] as const;
+export const PAGES = ["/", "/figures", "/docs", "/skills", "/inspo"] as const;
const NAME = "hairline";
diff --git a/apps/site/lib/skill.ts b/apps/site/lib/skill.ts
index a57db3e..77e1f2a 100644
--- a/apps/site/lib/skill.ts
+++ b/apps/site/lib/skill.ts
@@ -3,13 +3,14 @@ import { join } from "node:path";
import { COUNT } from "./figures";
/**
- * The skill, as the site tells it: the two commands, the examples, and the
- * page's copy as plain text, so /skill and /llms.txt say the same thing.
+ * The skills, as the site tells them: the commands, the examples, and the
+ * page's copy as plain text, so /skills and /llms.txt say the same thing.
* Server only: it reads the generated pages from public/skill.
*/
export const INSTALL = "npx skills add lucasmarkes/hairline";
export const COMMAND = "/hairline-create";
+export const ADOPT = "/hairline-adopt";
/**
* `followUp` is a change asked for after the first prompt, when the page shown is the one that came out of it.
@@ -17,17 +18,36 @@ export const COMMAND = "/hairline-create";
*/
export type Example = { idea: string; file: string; sha256: string; followUp?: string };
-/** What was typed after the command, and the page the skill wrote for it. The pages are never edited. */
+/** What was typed after the command, and the page the skill wrote for it, as /skills shows them. These pages are never edited. */
export const EXAMPLES: Example[] = [
{ idea: "a sales funnel", file: "hairline-funnel.html", sha256: "1c2ad4fb6305da1ceda532da6d96f1cd3060c67d588dec2db6043920e33fc044" },
{ idea: "a rate limiter", file: "hairline-clearance.html", sha256: "36935c2412526af4331070e5a2d350f6c0a8071156b59955e815175b7a88b34d" },
{ idea: "git branches", file: "hairline-sidings.html", sha256: "c6844a3c0dc684237508644ef677ae8905b120b73c2af74d7abf5990775106ae", followUp: "The rails almost disappear and the trains read as loose blocks. Make it read as a railway at a glance." },
{ idea: "weather over a city", file: "hairline-storm.html", sha256: "fe23e7a760c742bf0c68401bb2d3544f700af36865f720b39214ebde237507c0", followUp: "The cloud looks like a stack of cylinders. Make it read as a cloud at a glance." },
+];
+
+/**
+ * Three more pages hairline-create wrote, each from a company's mark. They are the Figures page's marks shelf, not
+ * examples on /skills, and are pinned and checked as the examples are.
+ */
+export const MARKS: Example[] = [
{ idea: "an empty state for \"No deployments yet\", from Vercel's mark: the triangle as an upright slab hovering over a pad with its slot marked dim; the nearer the pointer, the lower it settles, until it seats. Name it vercel.", file: "hairline-vercel.html", sha256: "781db9ab5891183261c3ed03e1050d9fabbc9b95a2a9333425706135953dc839" },
{ idea: "an empty state for \"No agents connected\", from Mastra's mark: the spheres of the M joined by necks on a board, the lone sphere standing apart; the pointer draws it toward the others, a neck forms, stretches and lets go. Name it mastra.", file: "hairline-mastra.html", sha256: "fa4f03c971f626296cd3a720aed23b81beeda0221652b1c560820a9c3858876a" },
{ idea: "an empty state for \"No pages inside\", from Notion's mark: the cube as a box with a lid, the N a relief on its front face; the pointer's height opens the lid on a spring, and the box is empty. Name it notion.", file: "hairline-notion.html", sha256: "4ba5f67ee4a4c7d0a0a46757889c8264af3c6a21d285e81e6aa02e65e23f68d7" },
];
+/**
+ * What was typed after /hairline-adopt: the SVG, then what the pointer does. Each page came out of a few rounds of
+ * changes after that line, so none carries a single follow-up. Two were touched once on the site: firecrawl's name
+ * is in English, and linear's tick reads performance.now(), the clock its departures are set by.
+ */
+export const ADOPTED: Example[] = [
+ { idea: "deploy.svg the pointer's height is the thrust; raised high enough, the rocket lifts off", file: "hairline-deploy-liftoff.html", sha256: "0b7392c2befd22bf553c6c08edb3b07f7945a3d01a1f3852011e309f2c4bca33" },
+ { idea: "firecrawl.svg the flame reads a page: point down it, and each part peels off onto a sheet of markdown", file: "hairline-firecrawl-reader.html", sha256: "df47f616e57fbc9e2f5ab65acff68c28bbb87ac33c3a73bf4939d8c83245fd76" },
+ { idea: "linear.svg the stripes are lanes: point up across them, and the issues move lane to lane until they are done", file: "hairline-linear-cycle.html", sha256: "2272ea7240311a7cf1ce9ff3c54d6a93d03cda4a41a1b3c85bceb5680ed99ba8" },
+ { idea: "cursor.svg the mark is the caret over code: point down the page, and each suggested line is accepted", file: "hairline-cursor-tab.html", sha256: "1dcbfb43b851b95d7adb001fc14e5f40a688e058e761f6c1596c240ba137a073" },
+];
+
export type Shown = Example & { name: string; means: string; prompt: string; href: string };
const FIGURE = /<script type="module" id="hl-figure">([\s\S]*?)<\/script>/;
@@ -45,15 +65,15 @@ export function declared(html: string, file: string): { name: string; means: str
return { name, means: means.replace(/\\(.)/g, "$1") };
}
-/** The examples with what their pages declare. `next build` and vitest both run from apps/site. */
-export function examples(): Shown[] {
- return EXAMPLES.map((e) => {
+/** A skill's examples with what their pages declare. `next build` and vitest both run from apps/site. */
+export function examples(list = EXAMPLES, command = COMMAND): Shown[] {
+ return list.map((e) => {
const html = readFileSync(join(process.cwd(), "public", "skill", e.file), "utf8");
- return { ...e, ...declared(html, e.file), prompt: `${COMMAND} ${e.idea}`, href: `/skill/${e.file}` };
+ return { ...e, ...declared(html, e.file), prompt: `${command} ${e.idea}`, href: `/skill/${e.file}` };
});
}
-export const SUMMARY = `hairline-create is a skill for coding agents. Give it an idea and it draws a new figure to Hairline's ten rules, on the same engine as the ${COUNT} in the docs, as one HTML file.`;
+export const SUMMARY = `Two skills for coding agents. hairline-create draws a new figure from an idea, and hairline-adopt starts from an SVG you already have. Both draw to Hairline's ten rules, on the same engine as the ${COUNT} in the docs, as one HTML file.`;
export const STEPS: { title: string; text: string }[] = [
{ title: "Concepts", text: "It offers two or three concepts, one line each: the object, what the pointer does, what the read-out says. You pick one." },
@@ -63,10 +83,23 @@ export const STEPS: { title: string; text: string }[] = [
{ title: "Adjust", text: "Ask for changes while you use it. It edits the figure and checks again." },
];
-export const FOLDER = "What you install is one folder of small text files. There is no npm install, and Node is only needed to run the checks.";
+export const FOLDER = "One command installs both skills. Each is a folder of small text files. There is no npm install, and Node is only needed to run the checks.";
export const USE: string[] = [
"Type the command with an idea. If you already have the metaphor, say it, and the concepts step is skipped.",
"Out comes hairline-<name>.html: one file with no dependencies that opens from disk, holding the figure, an intensity slider, a theme switch and a play button that walks its tour.",
"It runs on any agent that reads skills: Claude Code, Cursor, Codex and others.",
];
+
+export const ADOPT_STEPS: { title: string; text: string }[] = [
+ { title: "Read", text: "It measures the SVG's shapes and says what it read the drawing as and which parts it kept. If the reading is wrong, say so and it reads again." },
+ { title: "Concepts", text: "It offers two or three gestures for that object, one line each. You pick one." },
+ { title: "Build", text: "It builds the object new, as solids on Hairline's engine. It never traces the SVG and never animates it." },
+ { title: "Check", text: "The same checks as hairline-create, with your SVG beside the figure, so the agent can see it still reads as yours." },
+ { title: "Hand over", text: "You get the page. If the mark belongs to someone else, it tells you so." },
+];
+
+export const ADOPT_USE: string[] = [
+ "Give it one SVG: an icon, a logo or an illustration. Say what the pointer should do, or leave that to the concepts.",
+ "Out comes hairline-<name>.html, the same kind of file hairline-create writes. It hands the drawing to hairline-create, so the build and the checks are that skill's.",
+];
diff --git a/apps/site/next.config.mjs b/apps/site/next.config.mjs
index d2825bb..8444617 100644
--- a/apps/site/next.config.mjs
+++ b/apps/site/next.config.mjs
@@ -6,4 +6,6 @@ import { resolveBaseUrl } from "../../scripts/base-url.mjs";
*/
export default {
env: { NEXT_PUBLIC_SITE_URL: resolveBaseUrl() },
+ // the page was /skill while there was one skill; only the page moved, its examples stay under /skill/
+ redirects: async () => [{ source: "/skill", destination: "/skills", permanent: true }],
};
diff --git a/apps/site/public/skill/hairline-cursor-tab.html b/apps/site/public/skill/hairline-cursor-tab.html
new file mode 100644
index 0000000..75cdab9
--- /dev/null
+++ b/apps/site/public/skill/hairline-cursor-tab.html
@@ -0,0 +1,1039 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Hairline figure</title>
+<link rel="icon" href="data:,">
+<style>
+ :root { color-scheme: light; --ground: #ffffff; --ink: #232327; --muted: #6f6f78; --line: #e0e0e4; }
+ @media (prefers-color-scheme: dark) {
+ :root:not([data-theme="light"]) { color-scheme: dark; --ground: #08090a; --ink: #d0d6e0; --muted: #8a8c95; --line: #29292d; }
+ }
+ :root[data-theme="dark"] { color-scheme: dark; --ground: #08090a; --ink: #d0d6e0; --muted: #8a8c95; --line: #29292d; }
+ :root[data-theme="light"] { color-scheme: light; }
+ * { box-sizing: border-box; }
+ body {
+ margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
+ background: var(--ground); color: var(--ink);
+ font: 13px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased;
+ }
+ main { width: 100%; max-width: 640px; }
+ .plate { position: relative; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
+ .tag, .label, output, button { font: 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.02em; }
+ .tag { position: absolute; top: 12px; z-index: 1; color: var(--muted); pointer-events: none; }
+ #name { left: 14px; }
+ #read { right: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
+ .controls { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 14px; }
+ .label { color: var(--muted); }
+ input[type="range"] {
+ flex: 1 1 96px; min-width: 0; height: 32px; margin: 0; background: transparent; cursor: pointer;
+ -webkit-appearance: none; appearance: none;
+ }
+ input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--muted); }
+ input[type="range"]::-webkit-slider-thumb {
+ -webkit-appearance: none; width: 13px; height: 13px; margin-top: -6px; border-radius: 50%;
+ border: 1px solid var(--ink); background: var(--ground);
+ }
+ input[type="range"]::-moz-range-track { height: 1px; background: var(--muted); }
+ input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--ink); background: var(--ground); }
+ input[type="range"]:focus-visible, button:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 2px; }
+ output { min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; }
+ button {
+ height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px;
+ background: transparent; color: var(--ink); cursor: pointer;
+ }
+ #play[aria-pressed="true"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }
+ #means { margin: 14px 0 0; text-wrap: pretty; }
+ #rules { margin: 6px 0 0; line-height: 1.6; }
+ #error { margin: 12px 0 0; padding-left: 10px; border-left: 1px solid var(--ink); }
+</style>
+</head>
+<body>
+<main>
+ <div class="plate">
+ <span class="tag" id="name"></span>
+ <span class="tag" id="read"></span>
+ <div id="stage"></div>
+ </div>
+ <div class="controls">
+ <label class="label" for="intensity">intensity</label>
+ <input id="intensity" type="range" min="0" max="1" step="0.01" value="0.5">
+ <output id="value" for="intensity"></output>
+ <span class="label">theme</span>
+ <button id="theme" type="button" aria-label="Switch between the light and the dark theme"></button>
+ <span class="label">play</span>
+ <button id="play" type="button" aria-pressed="false">play</button>
+ </div>
+ <p id="means"></p>
+ <p id="rules" class="label"></p>
+ <p id="error" role="alert" hidden></p>
+</main>
+<script id="hl-kernel">
+/* hairline kernel sha256:3a19aa2640ba8c6c306184d05fddfbd4f3323a6ebd9217dd3cbb38e9db74991c */
+/*
+ * HL: everything a figure may call. Read this index; the code under it is the
+ * package's src/core, unchanged, and a figure should not need to read it.
+ *
+ * Every figure is drawn in a 400 × 320 viewBox. World space is x/y on the
+ * ground and z up. Plates are filled with the ground colour and painted back
+ * to front, so a nearer one covers a farther one: append in that order. At
+ * the default camera, Cam(45, 0.5, S), +x runs down to the right and +y down
+ * to the left, so the corner with the largest x and y is nearest the viewer:
+ * append by ascending x + y, from the far corner (smallest x and y) to it.
+ *
+ * Camera
+ * Cam(azDeg, k, S) a camera: azimuth in degrees, k = sin(elevation) (0.5 is the 2:1 view), S = scale
+ * fit(C, points, cx, cy) centres the box of [x, y, z] points on (cx, cy); call it once, before proj
+ * it only centres, it never scales: choose S by trying values, with the most extreme pose in points.
+ * The six figures use S 1.42 to 2.12; the boxes they fit come out 230 to 310 wide and 180 to 245 tall
+ * proj(C) returns P(x, y, z), which gives [sx, sy]
+ * unproj(C, sx, sy, z) the world [x, y] under a screen point, on the plane at height z
+ * facing(C) returns front(sample): whether a ring sample faces the camera
+ * Rounded solids
+ * rrect(u0, v0, u1, v1, r, n) a rounded rectangle, as a ring of samples {u, v, nu, nv}
+ * circ(R, n) a circle, as a ring
+ * rings(x0, y0, x1, y1, r, b) [ring, inner]: a rounded footprint and its crease ring, inset by b
+ * r, the corner radius, is cut to half the shorter side. b, the crease's inset in world units
+ * (0.6 to 2.2 in the figures), must stay under half the shorter side or the crease turns inside out
+ * prism(P, front, ring, inner, z0, z1) {sil, crease}: a solid standing from z0 to z1, as two path strings
+ * ringAt(P, ring, z) the ring's points, projected at height z
+ * run(ring, keep) the one cyclic run of samples that pass keep
+ * hull(points) the convex hull of screen points
+ * extremes(P, ring) [left, right, nearest] samples: where dashed drops fall from
+ * fillet(points, radii, n) rounds every vertex of a closed polygon; returns the new points
+ * radii is an array, one radius per vertex, each cut to half its shorter edge; a single number gives NaN.
+ * n is the steps round each corner, default 4: each vertex becomes n + 1 points
+ * ghost(P, front, ring, z0, depth) a reflection's path {d, y0, y1}; reflect() draws it for you
+ * Paths and numbers
+ * poly(points) a closed path string
+ * open(points) an open polyline string
+ * seg(a, b) one segment between two screen points [sx, sy], as its own subpath; project world points with P first
+ * clamp(v, a, b)
+ * lerp(a, b, t)
+ * rad(deg)
+ * r2(n) two decimals
+ * The continuous clock: one spring per moving number
+ * spring(x, opts) at rest on x; write .t to retarget; opts {k, c, m, eps}, default k 100, c 18, m 1
+ * stepS(sp, dt) advances by dt seconds; returns whether it is still moving
+ * The discrete clock: a 700ms tween on (.32, .72, 0, 1)
+ * tween(v, dur) at rest on v; dur defaults to 700 (ms)
+ * tset(tw, to, now, delay) retargets from where it is, after delay ms: the stagger
+ * the same target again does nothing, so calling it on every pointer move is safe
+ * tval(tw, now) its value at now
+ * tdone(tw, now) whether it has landed
+ * bezier(x1, y1, x2, y2) a CSS cubic-bezier, as a function of progress
+ * EASE_LIFT the lift curve itself
+ * reducedMotion() true when the reader asked for less motion; springs and tweens already land at once
+ * setReducedMotion(on) the loop's business, not a figure's
+ * Drawing
+ * mk(tag, attrs, parent) one svg element: the only way a figure makes a node
+ * solid(parent) {g, sil, cr}: a group holding a silhouette path and a crease path
+ * put(solid, paths) writes prism()'s {sil, crease} into solid()'s {sil, cr}: sil into sil, crease into cr
+ * flatDot(parent, C, r, cls) a dot lying on the ground plane; cls is "dot", "dot m" or "dot off"
+ * place(el, point) moves a dot or a circle to [sx, sy]
+ * reflect(svg, parent, P, front, ring, z0, depth) a fading mirror under a solid
+ * fade(svg, y0, y1, a0) a vertical fade, as a mask; returns the value for a mask attribute
+ * Life
+ * register(stage, tick) joins the one frame loop; tick(dt in seconds, now in ms) returns true to ask for another frame; gives {wake, unregister}
+ * pointer(stage, handlers) {move(point), down(point), leave()}, points in viewBox units; returns its disposer
+ * disposer() {add, on, dispose}: collects tear-down, so destroy is bag.dispose
+ * The bench's business, not a figure's
+ * css(lightDark)
+ * inject(root)
+ * tour(stage, stops, onStop) an unseen pointer that walks the stops, [x, y] in viewBox units or null to leave, and gives way to a real one; onStop(i) on each arrival; returns {stop}
+ * LAP the default stops: a diamond around the centre, then a leave
+ *
+ * Classes, on path, polygon, ellipse and line. They are the whole palette; a
+ * figure sets no colour, width or fill of its own.
+ * (none) filled with the ground colour, medium stroke
+ * sil the silhouette's stroke hi the bright stroke: the only highlight
+ * lo the dim stroke nf no fill fo fill only, no stroke
+ * dash a dashed guide
+ * dot a bright dot dot m a medium dot dot off a dim dot
+ */
+var HL = (() => {
+ var __defProp = Object.defineProperty;
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
+ var __getOwnPropNames = Object.getOwnPropertyNames;
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
+ var __export = (target, all) => {
+ for (var name in all)
+ __defProp(target, name, { get: all[name], enumerable: true });
+ };
+ var __copyProps = (to, from, except, desc) => {
+ if (from && typeof from === "object" || typeof from === "function") {
+ for (let key of __getOwnPropNames(from))
+ if (!__hasOwnProp.call(to, key) && key !== except)
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
+ }
+ return to;
+ };
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
+
+ // packages/hairline/src/core/kernel.ts
+ var kernel_exports = {};
+ __export(kernel_exports, {
+ Cam: () => Cam,
+ EASE_LIFT: () => EASE_LIFT,
+ LAP: () => LAP,
+ bezier: () => bezier,
+ circ: () => circ,
+ clamp: () => clamp,
+ css: () => css,
+ disposer: () => disposer,
+ extremes: () => extremes,
+ facing: () => facing,
+ fade: () => fade,
+ fillet: () => fillet,
+ fit: () => fit,
+ flatDot: () => flatDot,
+ ghost: () => ghost,
+ hull: () => hull,
+ inject: () => inject,
+ lerp: () => lerp,
+ mk: () => mk,
+ open: () => open,
+ place: () => place,
+ pointer: () => pointer,
+ poly: () => poly,
+ prism: () => prism,
+ proj: () => proj,
+ put: () => put,
+ r2: () => r2,
+ rad: () => rad,
+ reducedMotion: () => reducedMotion,
+ reflect: () => reflect,
+ register: () => register,
+ ringAt: () => ringAt,
+ rings: () => rings,
+ rrect: () => rrect,
+ run: () => run,
+ seg: () => seg,
+ setReducedMotion: () => setReducedMotion,
+ solid: () => solid,
+ spring: () => spring,
+ stepS: () => stepS,
+ tdone: () => tdone,
+ tour: () => tour,
+ tset: () => tset,
+ tval: () => tval,
+ tween: () => tween,
+ unproj: () => unproj
+ });
+
+ // packages/hairline/src/core/iso.ts
+ var clamp = (v, a, b) => Math.max(a, Math.min(b, v));
+ var lerp = (a, b, t) => a + (b - a) * t;
+ var rad = (d) => d * Math.PI / 180;
+ var r2 = (n) => Math.round(n * 100) / 100;
+ var poly = (pts) => "M" + pts.map((p) => r2(p[0]) + " " + r2(p[1])).join("L") + "Z";
+ var seg = (a, b) => `M${r2(a[0])} ${r2(a[1])}L${r2(b[0])} ${r2(b[1])}`;
+ var open = (pts) => pts.length < 2 ? "" : "M" + pts.map((p) => r2(p[0]) + " " + r2(p[1])).join("L");
+ var Cam = (azDeg, k, S) => ({ az: rad(azDeg), k, S, ox: 0, oy: 0 });
+ function proj(C) {
+ const c = Math.cos(C.az), s = Math.sin(C.az), zf = Math.sqrt(1 - C.k * C.k);
+ return (x, y, z) => {
+ const X = x * c - y * s, Y = x * s + y * c;
+ return [C.ox + C.S * X, C.oy + C.S * (Y * C.k - z * zf)];
+ };
+ }
+ function unproj(C, sx, sy, z) {
+ const c = Math.cos(C.az), s = Math.sin(C.az), zf = Math.sqrt(1 - C.k * C.k);
+ const X = (sx - C.ox) / C.S, Y = ((sy - C.oy) / C.S + z * zf) / C.k;
+ return [X * c + Y * s, -X * s + Y * c];
+ }
+ function fit(C, pts, cx, cy) {
+ C.ox = 0;
+ C.oy = 0;
+ const P = proj(C);
+ let a = 1e9, b = -1e9, c = 1e9, d = -1e9;
+ for (const p of pts) {
+ const q = P(p[0], p[1], p[2]);
+ a = Math.min(a, q[0]);
+ b = Math.max(b, q[0]);
+ c = Math.min(c, q[1]);
+ d = Math.max(d, q[1]);
+ }
+ C.ox = cx - (a + b) / 2;
+ C.oy = cy - (c + d) / 2;
+ }
+ function rrect(u0, v0, u1, v1, r, n = 4) {
+ r = Math.max(0, Math.min(r, (u1 - u0) / 2, (v1 - v0) / 2));
+ const out = [];
+ for (const [cu, cv, a0] of [[u1 - r, v1 - r, 0], [u0 + r, v1 - r, 90], [u0 + r, v0 + r, 180], [u1 - r, v0 + r, 270]])
+ for (let k = 0; k <= n; k++) {
+ const a = rad(a0 + 90 * k / n), ca = Math.cos(a), sa = Math.sin(a);
+ out.push({ u: cu + r * ca, v: cv + r * sa, nu: ca, nv: sa });
+ }
+ return out;
+ }
+ function circ(R, n = 96) {
+ const out = [];
+ for (let k = 0; k < n; k++) {
+ const a = k / n * Math.PI * 2, ca = Math.cos(a), sa = Math.sin(a);
+ out.push({ u: R * ca, v: R * sa, nu: ca, nv: sa });
+ }
+ return out;
+ }
+ function hull(input) {
+ const pts = input.slice().sort((a, b) => a[0] - b[0] || a[1] - b[1]);
+ const x = (o, a, b) => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
+ const lo = [], up = [];
+ for (const p of pts) {
+ while (lo.length > 1 && x(lo[lo.length - 2], lo[lo.length - 1], p) <= 0) lo.pop();
+ lo.push(p);
+ }
+ for (let i = pts.length - 1; i >= 0; i--) {
+ const p = pts[i];
+ while (up.length > 1 && x(up[up.length - 2], up[up.length - 1], p) <= 0) up.pop();
+ up.push(p);
+ }
+ lo.pop();
+ up.pop();
+ return lo.concat(up);
+ }
+ var ringAt = (P, ring, z) => ring.map((q) => P(q.u, q.v, z));
+ var facing = (C) => {
+ const s = Math.sin(C.az), c = Math.cos(C.az);
+ return (q) => q.nu * s + q.nv * c >= -1e-6;
+ };
+ function run(ring, keep) {
+ const n = ring.length;
+ let s = -1;
+ for (let i = 0; i < n; i++) if (keep(ring[i]) && !keep(ring[(i + n - 1) % n])) {
+ s = i;
+ break;
+ }
+ if (s < 0) return keep(ring[0]) ? ring.slice() : [];
+ const out = [];
+ for (let k = 0; k < n && keep(ring[(s + k) % n]); k++) out.push(ring[(s + k) % n]);
+ return out;
+ }
+ function prism(P, front, ring, inner, z0, z1) {
+ return {
+ sil: poly(hull(ringAt(P, ring, z1).concat(ringAt(P, ring, z0)))),
+ crease: inner ? open(ringAt(P, run(inner, front), z1)) : ""
+ };
+ }
+ var rings = (x0, y0, x1, y1, r, b) => [
+ rrect(x0, y0, x1, y1, r),
+ rrect(x0 + b, y0 + b, x1 - b, y1 - b, Math.max(0.3, r - b))
+ ];
+ function extremes(P, ring) {
+ const pr = ring.map((q) => P(q.u, q.v, 0));
+ let a = 0, b = 0, c = 0;
+ pr.forEach((p, k) => {
+ if (p[0] < pr[a][0]) a = k;
+ if (p[0] > pr[b][0]) b = k;
+ if (p[1] > pr[c][1]) c = k;
+ });
+ return [ring[a], ring[b], ring[c]];
+ }
+ function fillet(pts, rs, n = 4) {
+ const m = pts.length, out = [];
+ for (let i = 0; i < m; i++) {
+ const a = pts[(i + m - 1) % m], p = pts[i], b = pts[(i + 1) % m];
+ const la = Math.hypot(a[0] - p[0], a[1] - p[1]), lb = Math.hypot(b[0] - p[0], b[1] - p[1]);
+ const t = Math.min(rs[i], la / 2, lb / 2);
+ const p1 = [p[0] + (a[0] - p[0]) / la * t, p[1] + (a[1] - p[1]) / la * t];
+ const p2 = [p[0] + (b[0] - p[0]) / lb * t, p[1] + (b[1] - p[1]) / lb * t];
+ for (let k = 0; k <= n; k++) {
+ const s = k / n, w = 1 - s;
+ out.push([w * w * p1[0] + 2 * w * s * p[0] + s * s * p2[0], w * w * p1[1] + 2 * w * s * p[1] + s * s * p2[1]]);
+ }
+ }
+ return out;
+ }
+ function ghost(P, front, ring, z0, depth) {
+ const f = run(ring, front), lowP = ringAt(P, f, z0 - depth);
+ return {
+ d: open(lowP) + [f[0], f[f.length - 1]].map((q) => seg(P(q.u, q.v, z0), P(q.u, q.v, z0 - depth))).join(""),
+ y0: Math.min(...ringAt(P, f, z0).map((p) => p[1])),
+ y1: Math.max(...lowP.map((p) => p[1])) + 2
+ };
+ }
+
+ // packages/hairline/src/core/motion.ts
+ var reduced = false;
+ var setReducedMotion = (on) => {
+ reduced = on;
+ };
+ var reducedMotion = () => reduced;
+ function spring(x, o = {}) {
+ return { x, v: 0, t: x, k: o.k ?? 100, c: o.c ?? 18, m: o.m ?? 1, eps: o.eps ?? 0.01 };
+ }
+ function stepS(sp, dt) {
+ if (reduced) {
+ sp.x = sp.t;
+ sp.v = 0;
+ return false;
+ }
+ const n = Math.max(1, Math.ceil(dt * 240)), h = dt / n;
+ for (let i = 0; i < n; i++) {
+ const a = (-sp.k * (sp.x - sp.t) - sp.c * sp.v) / sp.m;
+ sp.v += a * h;
+ sp.x += sp.v * h;
+ }
+ if (Math.abs(sp.x - sp.t) < sp.eps && Math.abs(sp.v) < sp.eps * 10) {
+ sp.x = sp.t;
+ sp.v = 0;
+ return false;
+ }
+ return true;
+ }
+ function bezier(x1, y1, x2, y2) {
+ const cx = 3 * x1, bx = 3 * (x2 - x1) - cx, ax = 1 - cx - bx;
+ const cy = 3 * y1, by = 3 * (y2 - y1) - cy, ay = 1 - cy - by;
+ const X = (u) => ((ax * u + bx) * u + cx) * u;
+ const Y = (u) => ((ay * u + by) * u + cy) * u;
+ const dX = (u) => (3 * ax * u + 2 * bx) * u + cx;
+ return (t) => {
+ if (t <= 0) return 0;
+ if (t >= 1) return 1;
+ let u = t;
+ for (let i = 0; i < 8; i++) {
+ const e = X(u) - t;
+ if (Math.abs(e) < 1e-5) break;
+ const d = dX(u);
+ if (Math.abs(d) < 1e-6) break;
+ u -= e / d;
+ }
+ if (!(u >= 0 && u <= 1) || Math.abs(X(u) - t) > 1e-4) {
+ let lo = 0, hi = 1;
+ u = t;
+ for (let i = 0; i < 24; i++) {
+ if (X(u) < t) lo = u;
+ else hi = u;
+ u = (lo + hi) / 2;
+ }
+ }
+ return Y(u);
+ };
+ }
+ var EASE_LIFT = bezier(0.32, 0.72, 0, 1);
+ var tween = (v, dur = 700) => ({ from: v, to: v, t0: -1e9, dur });
+ var tval = (tw, now) => {
+ const p = clamp((now - tw.t0) / tw.dur, 0, 1);
+ return tw.from + (tw.to - tw.from) * (reduced ? 1 : EASE_LIFT(p));
+ };
+ var tset = (tw, to, now, delay) => {
+ if (tw.to === to) return;
+ tw.from = tval(tw, now);
+ tw.to = to;
+ tw.t0 = now + delay;
+ };
+ var tdone = (tw, now) => reduced || now >= tw.t0 + tw.dur;
+
+ // packages/hairline/src/core/stage.ts
+ var NS = "http://www.w3.org/2000/svg";
+ function mk(tag, attrs, parent) {
+ const e = document.createElementNS(NS, tag);
+ if (attrs) for (const k in attrs) e.setAttribute(k, String(attrs[k]));
+ if (parent) parent.appendChild(e);
+ return e;
+ }
+ function solid(parent) {
+ const g = mk("g", {}, parent);
+ return { g, sil: mk("path", { class: "sil" }, g), cr: mk("path", { class: "nf lo" }, g) };
+ }
+ var put = (el, s) => {
+ el.sil.setAttribute("d", s.sil);
+ el.cr.setAttribute("d", s.crease);
+ };
+ var flatDot = (parent, C, r, cls) => mk("ellipse", { rx: r2(r * C.S), ry: r2(r * C.S * C.k), class: cls }, parent);
+ var place = (el, q) => {
+ el.setAttribute("cx", String(r2(q[0])));
+ el.setAttribute("cy", String(r2(q[1])));
+ };
+ var fid = 0;
+ function fade(svg, y0, y1, a0 = 0.7) {
+ const id = "hl-fd" + ++fid, defs = mk("defs", {}, svg);
+ const lg = mk("linearGradient", { id: id + "g", gradientUnits: "userSpaceOnUse", x1: 0, y1: r2(y0), x2: 0, y2: r2(y1) }, defs);
+ mk("stop", { offset: 0, "stop-color": "#fff", "stop-opacity": a0 }, lg);
+ mk("stop", { offset: 1, "stop-color": "#fff", "stop-opacity": 0 }, lg);
+ const m = mk("mask", { id, maskUnits: "userSpaceOnUse", x: 0, y: 0, width: 400, height: 320 }, defs);
+ mk("rect", { x: 0, y: 0, width: 400, height: 320, fill: `url(#${id}g)` }, m);
+ return `url(#${id})`;
+ }
+ function reflect(svg, parent, P, front, ring, z0, depth) {
+ const r = ghost(P, front, ring, z0, depth);
+ const gh = mk("g", { class: "ghost", mask: fade(svg, r.y0, r.y1) }, parent);
+ mk("path", { d: r.d }, gh);
+ }
+ var boards = [];
+ var byStage = /* @__PURE__ */ new Map();
+ var raf = 0;
+ var last = 0;
+ var io = null;
+ var rm = null;
+ function frame(now) {
+ const dt = Math.min(0.05, Math.max(0, (now - last) / 1e3));
+ last = now;
+ let any = false;
+ for (const b of boards.slice()) if (b.vis && b.awake) {
+ try {
+ b.awake = !!b.tick(dt, now);
+ } catch (err) {
+ b.awake = false;
+ setTimeout(() => {
+ throw err;
+ });
+ }
+ any = any || b.awake;
+ }
+ raf = any ? requestAnimationFrame(frame) : 0;
+ }
+ function wake(b) {
+ b.awake = true;
+ if (!raf) {
+ last = performance.now();
+ raf = requestAnimationFrame(frame);
+ }
+ }
+ var onMotion = () => {
+ setReducedMotion(!!rm?.matches);
+ boards.forEach(wake);
+ };
+ function start() {
+ if (io) return;
+ io = new IntersectionObserver((es) => {
+ for (const e of es) {
+ const set = byStage.get(e.target);
+ if (!set) continue;
+ for (const b of set) {
+ b.vis = e.isIntersecting;
+ if (b.vis) wake(b);
+ }
+ }
+ }, { rootMargin: "80px" });
+ rm = matchMedia("(prefers-reduced-motion: reduce)");
+ setReducedMotion(rm.matches);
+ rm.addEventListener("change", onMotion);
+ }
+ function stop() {
+ if (raf) cancelAnimationFrame(raf);
+ raf = 0;
+ io?.disconnect();
+ io = null;
+ rm?.removeEventListener("change", onMotion);
+ rm = null;
+ }
+ function register(stage, tick) {
+ start();
+ const b = { stage, tick, vis: false, awake: true };
+ boards.push(b);
+ const peers = byStage.get(stage);
+ if (peers) {
+ for (const p of peers) b.vis = p.vis;
+ peers.add(b);
+ if (b.vis) wake(b);
+ } else {
+ byStage.set(stage, /* @__PURE__ */ new Set([b]));
+ io.observe(stage);
+ }
+ tick(0, performance.now());
+ let gone = false;
+ return {
+ wake: () => {
+ if (!gone) wake(b);
+ },
+ unregister: () => {
+ if (gone) return;
+ gone = true;
+ boards = boards.filter((x) => x !== b);
+ const set = byStage.get(stage);
+ if (set) {
+ set.delete(b);
+ if (!set.size) {
+ byStage.delete(stage);
+ io?.unobserve(stage);
+ }
+ }
+ if (!boards.length) stop();
+ }
+ };
+ }
+ var handlers = /* @__PURE__ */ new WeakMap();
+ var touring = /* @__PURE__ */ new WeakMap();
+ function pointer(stage, on) {
+ handlers.set(stage, on);
+ let tm = 0;
+ const pt = (e) => {
+ const r = stage.getBoundingClientRect();
+ return [(e.clientX - r.left) / r.width * 400, (e.clientY - r.top) / r.height * 320];
+ };
+ const move = (e) => {
+ clearTimeout(tm);
+ touring.get(stage)?.hold();
+ on.move(pt(e), e);
+ };
+ const down = (e) => {
+ clearTimeout(tm);
+ touring.get(stage)?.hold();
+ if (e.pointerType !== "mouse") stage.releasePointerCapture?.(e.pointerId);
+ if (on.down) on.down(pt(e), e);
+ else on.move(pt(e), e);
+ };
+ const leave = (e) => {
+ clearTimeout(tm);
+ tm = window.setTimeout(() => {
+ on.leave(e);
+ touring.get(stage)?.release();
+ }, e.pointerType === "mouse" ? 0 : 1400);
+ };
+ stage.addEventListener("pointermove", move);
+ stage.addEventListener("pointerdown", down);
+ stage.addEventListener("pointerleave", leave);
+ return () => {
+ clearTimeout(tm);
+ if (handlers.get(stage) === on) handlers.delete(stage);
+ stage.removeEventListener("pointermove", move);
+ stage.removeEventListener("pointerdown", down);
+ stage.removeEventListener("pointerleave", leave);
+ };
+ }
+ var LAP = [[128, 150], [200, 118], [272, 150], [200, 206], null];
+ var TRAVEL = 900;
+ var DWELL = 1200;
+ var REST = 1800;
+ var RESUME = 1200;
+ var STAGGER = 450;
+ var GHOST = { pointerType: "ghost" };
+ var started = 0;
+ function entry([x, y]) {
+ const dx = x - 200, dy = y - 160;
+ if (!dx && !dy) return [200, 320];
+ const k = Math.min(dx ? (dx > 0 ? 200 : -200) / dx : Infinity, dy ? (dy > 0 ? 160 : -160) / dy : Infinity);
+ return [200 + dx * k, 160 + dy * k];
+ }
+ function tour(stage, stops, onStop) {
+ let i = 0;
+ let wait = RESUME + STAGGER * (started++ % 4);
+ let t = -1;
+ let at = null;
+ let origin = [200, 320];
+ let hand = false, keys = stage.contains(stage.ownerDocument.activeElement);
+ let gone = false;
+ const leave = () => {
+ at = null;
+ t = -1;
+ handlers.get(stage)?.leave(GHOST);
+ };
+ const tick = (dt) => {
+ if (hand || keys || !stops.length) return false;
+ if (reducedMotion()) {
+ if (at) leave();
+ return false;
+ }
+ if (wait > 0) {
+ wait -= dt * 1e3;
+ return true;
+ }
+ const stop2 = stops[i];
+ if (stop2 === null) {
+ if (at) leave();
+ onStop?.(i);
+ i = (i + 1) % stops.length;
+ wait = REST;
+ return true;
+ }
+ const h = handlers.get(stage);
+ if (!h) return true;
+ if (t < 0) {
+ origin = at ?? entry(stop2);
+ t = 0;
+ }
+ t = Math.min(TRAVEL, t + dt * 1e3);
+ const k = EASE_LIFT(t / TRAVEL);
+ at = [origin[0] + (stop2[0] - origin[0]) * k, origin[1] + (stop2[1] - origin[1]) * k];
+ h.move(at, GHOST);
+ if (t < TRAVEL) return true;
+ onStop?.(i);
+ i = (i + 1) % stops.length;
+ t = -1;
+ wait = DWELL;
+ return true;
+ };
+ const take = () => {
+ at = null;
+ t = -1;
+ };
+ const give = () => {
+ if (hand || keys) return;
+ i = 0;
+ t = -1;
+ wait = RESUME;
+ board.wake();
+ };
+ const me = {
+ hold: () => {
+ hand = true;
+ take();
+ },
+ release: () => {
+ if (!hand) return;
+ hand = false;
+ give();
+ }
+ };
+ const focusIn = () => {
+ keys = true;
+ take();
+ };
+ const focusOut = (e) => {
+ if (keys && !stage.contains(e.relatedTarget)) {
+ keys = false;
+ give();
+ }
+ };
+ stage.addEventListener("focusin", focusIn);
+ stage.addEventListener("focusout", focusOut);
+ touring.set(stage, me);
+ const board = register(stage, tick);
+ return {
+ stop: () => {
+ if (gone) return;
+ gone = true;
+ board.unregister();
+ stage.removeEventListener("focusin", focusIn);
+ stage.removeEventListener("focusout", focusOut);
+ if (touring.get(stage) === me) touring.delete(stage);
+ if (at) leave();
+ }
+ };
+ }
+ function disposer() {
+ let fns = [];
+ return {
+ add: (fn) => {
+ fns.push(fn);
+ },
+ on: (target, type, fn, opts) => {
+ const h = fn;
+ target.addEventListener(type, h, opts);
+ fns.push(() => target.removeEventListener(type, h, opts));
+ },
+ dispose: () => {
+ const run2 = fns;
+ fns = [];
+ for (let i = run2.length - 1; i >= 0; i--) run2[i]();
+ }
+ };
+ }
+
+ // packages/hairline/src/core/styles.ts
+ var LIGHT = { plate: "#ffffff", hi: "#232327", edge: "#a4a4ac", mid: "#c3c3c9", lo: "#e0e0e4" };
+ var DARK = { plate: "#08090a", hi: "#d0d6e0", edge: "#5b5d64", mid: "#3e3e44", lo: "#29292d" };
+ var KEYS = ["plate", "hi", "edge", "mid", "lo"];
+ var vars = (p) => KEYS.map((k) => `--hl-${k}:var(--hairline-${k},${p[k]});`).join("");
+ var EASE = "cubic-bezier(0.5,0,0.1,1)";
+ var SVG = ":where([data-hairline]>svg)";
+ function css(lightDark) {
+ const both = Object.fromEntries(KEYS.map((k) => [k, `light-dark(${LIGHT[k]},${DARK[k]})`]));
+ return [
+ // the box, and the palette: light unless something below says otherwise
+ `:where([data-hairline]){display:block;position:relative;aspect-ratio:5/4;touch-action:pan-y;user-select:none;-webkit-user-select:none;--hl-sw:var(--hairline-stroke,0.9);${vars(LIGHT)}}`,
+ // the page's color-scheme
+ lightDark ? `:where([data-hairline]){${vars(both)}}` : "",
+ // an ancestor that says dark
+ `:where(.dark,[data-theme="dark"]) :where([data-hairline]){${vars(DARK)}}`,
+ // the figure's own theme option
+ `:where([data-hairline][data-hairline-theme="light"]){${vars(LIGHT)}}`,
+ `:where([data-hairline][data-hairline-theme="dark"]){${vars(DARK)}}`,
+ `:where([data-hairline]:focus-visible){outline:1.5px solid var(--hl-hi);outline-offset:2px}`,
+ `${SVG}{position:absolute;inset:0;width:100%;height:100%;display:block}`,
+ // Riffle's live region: read, not seen
+ `:where([data-hairline]>[data-hairline-live]){position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}`,
+ // the drawing: plates are filled with the plate colour and painted back to front
+ `${SVG} :where(path,polygon,ellipse,line){fill:var(--hl-plate);stroke:var(--hl-mid);stroke-width:var(--hl-sw);vector-effect:non-scaling-stroke;stroke-linejoin:round;stroke-linecap:round;transition:stroke 260ms ${EASE}}`,
+ `${SVG} :where(.nf){fill:none}`,
+ `${SVG} :where(.fo){stroke:none}`,
+ `${SVG} :where(.sil){stroke:var(--hl-edge)}`,
+ `${SVG} :where(.hi){stroke:var(--hl-hi)}`,
+ `${SVG} :where(.lo){stroke:var(--hl-lo)}`,
+ `${SVG} :where(.dash){stroke-dasharray:1 3}`,
+ `${SVG} :where(.dot){stroke:none;fill:var(--hl-hi);transition:fill 260ms ${EASE}}`,
+ `${SVG} :where(.dot.m){fill:var(--hl-edge)}`,
+ `${SVG} :where(.dot.off){fill:var(--hl-lo)}`,
+ `${SVG} :where(.ghost path){fill:none;stroke:var(--hl-mid)}`
+ ].join("");
+ }
+ var done = /* @__PURE__ */ new WeakSet();
+ function inject(root) {
+ if (done.has(root)) return;
+ done.add(root);
+ const doc = root.nodeType === 9 ? root : root.ownerDocument;
+ const win = doc.defaultView;
+ const text = css(!!win?.CSS?.supports?.("color", "light-dark(#000,#fff)"));
+ if (win && "adoptedStyleSheets" in root) {
+ try {
+ const sheet = new win.CSSStyleSheet();
+ sheet.replaceSync(text);
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
+ return;
+ } catch {
+ }
+ }
+ const style = doc.createElement("style");
+ style.setAttribute("data-hairline-style", "");
+ style.textContent = text;
+ (root.nodeType === 9 ? doc.head ?? doc.documentElement : root).appendChild(style);
+ }
+ return __toCommonJS(kernel_exports);
+})();
+/* /hairline kernel */
+</script>
+<script id="hl-bench">
+/*
+ * The bench: the page a figure is shown on. It makes the host and the svg the
+ * way the package's mount does, hands them to the figure, and owns everything
+ * around it: the read-out, the slider, the theme, the line under the stage.
+ */
+(() => {
+ const RULES = ["hit", "order", "reach", "accent", "rest", "honesty", "cost", "clock", "radius", "quiet"];
+ const $ = (id) => document.getElementById(id);
+ const root = document.documentElement, params = new URLSearchParams(location.search);
+
+ /* the theme: the system's until the switch is pressed, then the switch's */
+ const dark = () => (root.dataset.theme ? root.dataset.theme === "dark" : matchMedia("(prefers-color-scheme: dark)").matches);
+ const label = () => { $("theme").textContent = dark() ? "dark" : "light"; };
+ $("theme").addEventListener("click", () => { root.dataset.theme = dark() ? "light" : "dark"; label(); });
+ /* ?theme=light or ?theme=dark wins over the system's, as pressing the switch does */
+ if (["light", "dark"].includes(params.get("theme"))) root.dataset.theme = params.get("theme");
+ label();
+
+ /* ?intensity=0 sets the slider before the figure mounts, for a look at either end */
+ const i = (params.get("intensity") || "").trim();
+ if (i && Number.isFinite(Number(i))) $("intensity").value = String(Math.min(1, Math.max(0, Number(i))));
+
+ /* ?w=240 narrows the page, for a look at the size of a thumbnail */
+ const w = Number(params.get("w"));
+ if (w > 0) document.querySelector("main").style.maxWidth = w + "px";
+
+ /* a figure that fails says so under the stage, instead of leaving an empty plate */
+ addEventListener("error", (e) => {
+ $("error").hidden = false;
+ $("error").textContent = String((e.error && e.error.message) || e.message);
+ });
+
+ let mounted = false;
+ window.hairline = (figure) => {
+ if (mounted) throw new Error("hairline: one figure per page.");
+ mounted = true;
+ const stage = $("stage"), slider = $("intensity");
+
+ /* intensity to the figure's own number: two straight lines that meet at 0.5, as in the package */
+ const [lo, mid, hi] = figure.range;
+ const at = (i) => Math.round((i <= 0.5 ? lo + (i / 0.5) * (mid - lo) : mid + ((i - 0.5) / 0.5) * (hi - mid)) * 1000) / 1000;
+
+ HL.inject(document);
+ stage.setAttribute("data-hairline", figure.name);
+ stage.setAttribute("role", "img");
+ stage.setAttribute("aria-label", figure.means);
+ const svg = HL.mk("svg", { viewBox: "0 0 400 320", "aria-hidden": "true" }, stage);
+
+ let text = null;
+ const read = {
+ get textContent() { return text; },
+ set textContent(value) { text = value == null ? "" : String(value); $("read").textContent = text; },
+ };
+
+ document.title = "Hairline · " + figure.name;
+ $("name").textContent = figure.name;
+ $("means").textContent = figure.means;
+ $("rules").textContent = figure.rules.map((n) => String(n).padStart(2, "0") + " " + RULES[n - 1]).join(" · ");
+ const show = () => { $("value").textContent = String(at(Number(slider.value))); };
+ show();
+
+ const handle = figure.mount({ stage, svg, read }, at(Number(slider.value)));
+ if (text === null) read.textContent = "rest";
+ slider.addEventListener("input", () => { show(); handle.set(at(Number(slider.value))); });
+ window.hairline.figure = handle;
+
+ /* play: an unseen pointer walks the figure's tour (or HL.LAP) until a hand arrives; ?play=1 starts it on load */
+ const play = $("play");
+ window.hairline.playing = null;
+ play.addEventListener("click", () => {
+ const was = play.getAttribute("aria-pressed") === "true";
+ if (was) { window.hairline.playing.stop(); window.hairline.playing = null; }
+ else window.hairline.playing = HL.tour(stage, figure.tour || HL.LAP, (i) => { if (window.hairline.onStop) window.hairline.onStop(i); });
+ play.setAttribute("aria-pressed", String(!was));
+ });
+ if (params.get("play") === "1") play.click();
+
+ /* ?at=200,160 holds the pointer at a viewBox point, for a picture of the answer without a mouse */
+ const p = (params.get("at") || "").split(",").map(Number);
+ if (p.length === 2 && p.every(Number.isFinite)) {
+ const r = stage.getBoundingClientRect();
+ stage.dispatchEvent(new PointerEvent("pointermove", {
+ pointerType: "mouse", pointerId: 1, bubbles: true,
+ clientX: r.left + (p[0] / 400) * r.width, clientY: r.top + (p[1] / 320) * r.height,
+ }));
+ }
+ };
+})();
+</script>
+<script type="module" id="hl-figure">
+/**
+ * Cursor, tab: a code page lies on the ground, and the mark floats over it as the caret,
+ * a cube whose middle edge runs on down as the text cursor's bar. Ahead of the caret,
+ * the next lines wait as a dashed suggestion. Point down the page: the cube glides in one
+ * eased move to the end of the line under the pointer, each line it passes is accepted,
+ * swept from dashed to solid, and the suggestion draws itself on ahead of it.
+ * Going back up gives them back. At rest five lines are written and six more are suggested.
+ * The slider is how long a line takes to be accepted, in ms.
+ */
+const {
+ Cam, clamp, fit, fillet, open, poly, prism, proj, rad, rings, rrect, seg, solid, put,
+ spring, stepS, disposer, mk, pointer, register, unproj, facing,
+} = HL;
+
+const PW = 84, PH = 118, D = 2.5, T0 = 21, ROW = 8, U0 = 17, IND = 6, GAP = 2.6, R = 1.3, G = 6, REST = 5;
+const CS = 18, ZC = 9;
+/** The code, row by row: [indent, ...token lengths]; an empty row is a blank line. */
+const CODE = [[0, 10, 14, 6], [1, 8, 22], [1, 6, 10, 13], [1, 5, 16, 4], [2, 12, 18], [2, 9, 8, 7], [1, 4],
+ [1, 10, 20, 5], [0, 6], [], [0, 11, 13, 6], [1, 16, 18]];
+
+function mount({ stage, svg, read }, value) {
+ const bag = disposer();
+ let pace = value;
+
+ const C = Cam(45, 0.5, 2.35);
+ /** A point on the page, from the page's own (u along a line, t down the page). */
+ const at = (u, t, z = D) => [t, PW / 2 - u, z];
+ /** A critically damped spring that lands in about `ms`: no overshoot, and a retarget keeps its speed. */
+ const tune = (sp, ms) => { const w = 5600 / ms; sp.k = w * w; sp.c = 2 * w; return sp; };
+ const rows = CODE.map(([ind = 0, ...lens], k) => {
+ const t = T0 + k * ROW, toks = [];
+ let u = U0 + ind * IND;
+ lens.forEach((l) => { toks.push([u, u + l]); u += l + GAP; });
+ const ua = U0 + ind * IND, ub = toks.length ? toks[toks.length - 1][1] : ua;
+ return { t, toks, ua, ub, a: spring(k < REST ? 1 : 0, { eps: 0.002 }), g: spring(k < REST + G ? 1 : 0, { eps: 0.002 }), drawn: "" };
+ });
+ /** The cube's eight corners around a caret at (u, t), its foot at z. */
+ const cube = (u, t, z) => {
+ const [x, y] = at(u, t);
+ return [[x - CS, y - CS], [x, y - CS], [x, y], [x - CS, y]].flatMap(([a, b]) => [[a, b, z], [a, b, z + CS]]);
+ };
+ fit(C, [[0, -PW / 2, 0], [PH, -PW / 2, 0], [PH, PW / 2, 0], [0, PW / 2, 0],
+ ...rows.flatMap((r) => [...cube(r.ub, r.t, D + ZC - 2), ...cube(r.ua, r.t, D + ZC - 2)])], 200, 168);
+ const P = proj(C), W = (u, t, z) => P(...at(u, t, z)), ring = (u0, t0, u1, t1, r) => rrect(u0, t0, u1, t1, r, 3).map((q) => W(q.u, q.v));
+
+ const g = mk("g", {}, svg);
+ // the page: a thin plate; a thin top strip (three dots, the open file's tab, a second one) ruled off from the code; a gutter
+ put(solid(g), prism(P, facing(C), ...rings(0, -PW / 2, PH, PW / 2, 3, 1.4), 0, D));
+ const dot = (u, t, r) => poly(Array.from({ length: 12 }, (_, k) => W(u + r * Math.cos(rad(k * 30)), t + r * Math.sin(rad(k * 30)))));
+ const HB = 9, TA = 19, TB = 33;
+ /** A tab: its top rounded, open at its foot so it stands on the strip's rule. */
+ const tab = (u0, u1) => open(fillet([W(u0, HB), W(u0, 3.5), W(u1, 3.5), W(u1, HB)], [0, 2, 2, 0], 3));
+ mk("path", { class: "nf lo", d: [5, 9, 13].map((u) => dot(u, 5.5, 1)).join("") + tab(TB + 1, TB + 13)
+ + seg(W(1.5, HB), W(TA, HB)) + seg(W(TB, HB), W(PW - 1.5, HB)) + seg(W(U0 - 4, HB + 3), W(U0 - 4, PH - 4))
+ + CODE.map((_, k) => seg(W(U0 - 9.5, T0 + k * ROW), W(U0 - 7.5, T0 + k * ROW))).join("") }, g);
+ // the open file's tab is drawn in mid, and the rule breaks under it, so it runs on into the page it shows
+ mk("path", { class: "nf", d: tab(TA, TB) }, g);
+
+ // each row: what is written, solid; what is suggested, dashed behind it
+ rows.forEach((r) => {
+ r.ghost = mk("path", { class: "nf lo dash" }, g);
+ r.ink = mk("path", { class: "nf" }, g);
+ });
+ /** The row's tokens between u0 and u1, each a flat pill on the page. */
+ const span = (r, u0, u1) => r.toks.map(([a, b]) => {
+ const s0 = Math.max(a, u0), s1 = Math.min(b, u1);
+ return s1 > s0 + 0.3 ? poly(ring(s0, r.t - R, s1, r.t + R, R)) : "";
+ }).join("");
+ const uAt = (r, f) => r.ua + (r.ub - r.ua) * f;
+ function paintRow(r) {
+ const a = clamp(r.a.x, 0, 1), gv = Math.max(a, clamp(r.g.x, 0, 1)), key = `${a.toFixed(3)} ${gv.toFixed(3)}`;
+ if (key === r.drawn) return;
+ r.drawn = key;
+ r.ink.setAttribute("d", span(r, -1, uAt(r, a)));
+ r.ghost.setAttribute("d", span(r, uAt(r, a) + 1.2, uAt(r, gv)));
+ }
+
+ // the caret: the text cursor's bar, ticked at its foot, and the mark floating on it
+ const bar = mk("path", { class: "sil" }, g);
+ const hex = mk("path", { class: "sil hi" }, g), shade = mk("path", { class: "nf" }, g), facet = mk("path", { class: "nf sil hi" }, g);
+ const cu = spring(rows[REST - 1].ub), ct = spring(rows[REST - 1].t);
+ let drawnC = "";
+ function paintCaret() {
+ const key = `${cu.x.toFixed(2)} ${ct.x.toFixed(2)}`;
+ if (key === drawnC) return;
+ drawnC = key;
+ const [x, y] = at(cu.x, ct.x), z0 = D + ZC, z1 = z0 + CS, p = (a, b, z) => P(x + a, y + b, z);
+ // the cube stands its near corner over the caret, so the mark's middle edge runs on down as the cursor's bar
+ bar.setAttribute("d", seg(p(0, 0, D), p(0, 0, z0)) + seg(p(0, 2.2, D), p(0, -2.2, D)));
+ // the hexagon is the cube; the facet runs across the top's near half and down the right face, as in the mark
+ const UL = p(-CS, 0, z1), UR = p(0, -CS, z1), N = p(0, 0, z1), B = p(0, 0, z0);
+ hex.setAttribute("d", poly(fillet([p(-CS, -CS, z1), UR, p(0, -CS, z0), B, p(-CS, 0, z0), UL], Array(6).fill(1.6), 3)));
+ facet.setAttribute("d", poly(fillet([UL, UR, B, N], [1, 1, 1, 0.5], 3)));
+ // the mark's dark: the left face, the top's far half and the right face's low half are hatched, so the arrow is the light
+ let h = "";
+ for (let k = 1; k < 8; k++) {
+ const c = (CS * k) / 8;
+ h += seg(p(-c, 0, z0 + 0.8), p(-c, 0, z1 - 0.8)) + seg(p(0, -c, z0 + 0.8), p(0, -c, z0 + c - 0.8))
+ + seg(p(-CS + 0.6, -c + 0.6, z1), p(-c + 0.6, -CS + 0.6, z1));
+ }
+ shade.setAttribute("d", h);
+ }
+
+ let n = REST, hover = false, shown = -1;
+ /** Retune every spring to the pace: the lines land in about one pace, the cube crosses in about three. */
+ const retune = () => {
+ tune(cu, pace * 2.6); tune(ct, pace * 2.6);
+ rows.forEach((r) => { tune(r.a, pace * 1.2); tune(r.g, pace * 1.8); });
+ };
+ retune();
+
+ const B = register(stage, (dt) => {
+ let moving = stepS(cu, dt) | stepS(ct, dt);
+ // where the cube is, in rows: a line is accepted once the cube reaches it, given back once it rises off it
+ const f = (ct.x - T0) / ROW;
+ rows.forEach((r, i) => {
+ r.a.t = i < n && i <= f + 0.35 ? 1 : 0;
+ r.g.t = i < f + 0.5 + G ? 1 : 0;
+ moving = stepS(r.a, dt) | stepS(r.g, dt) || moving;
+ paintRow(r);
+ });
+ paintCaret();
+ const lines = rows.slice(0, n).filter((r) => r.toks.length).length;
+ if (lines !== shown) { shown = lines; read.textContent = hover ? `${lines} lines` : "rest"; }
+ return moving;
+ });
+ bag.add(B.unregister);
+
+ /** The pointer, put on the page's top, which never moves: the row under it is how far to accept. */
+ function aim(p) {
+ hover = p !== null;
+ n = hover ? clamp(Math.round((unproj(C, p[0], p[1], D)[0] - T0) / ROW), 0, rows.length - 1) + 1 : REST;
+ cu.t = rows[n - 1].ub; ct.t = rows[n - 1].t;
+ rows.forEach((r, i) => {
+ const lit = hover && i === n - 1;
+ r.ink.setAttribute("class", lit ? "nf hi" : "nf");
+ r.ghost.setAttribute("class", lit ? "nf hi dash" : "nf lo dash");
+ });
+ hex.classList.toggle("hi", !hover); facet.classList.toggle("hi", !hover);
+ shown = -1;
+ B.wake();
+ }
+ bag.add(pointer(stage, { move: (p) => aim(p), leave: () => aim(null) }));
+ bag.add(() => svg.replaceChildren());
+
+ return {
+ set: (v) => { pace = v; retune(); },
+ destroy: bag.dispose,
+ };
+}
+
+hairline({
+ name: "cursor-tab",
+ means: "The mark is the caret over code: point down the page, and each suggested line down to the pointer is accepted, in order.",
+ rules: [1, 2, 5, 8, 10],
+ range: [160, 280, 440],
+ tour: [[130, 182], [200, 200], [283, 225], null],
+ mount,
+});
+</script>
+</body>
+</html>
diff --git a/apps/site/public/skill/hairline-deploy-liftoff.html b/apps/site/public/skill/hairline-deploy-liftoff.html
new file mode 100644
index 0000000..3385c61
--- /dev/null
+++ b/apps/site/public/skill/hairline-deploy-liftoff.html
@@ -0,0 +1,1031 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Hairline figure</title>
+<link rel="icon" href="data:,">
+<style>
+ :root { color-scheme: light; --ground: #ffffff; --ink: #232327; --muted: #6f6f78; --line: #e0e0e4; }
+ @media (prefers-color-scheme: dark) {
+ :root:not([data-theme="light"]) { color-scheme: dark; --ground: #08090a; --ink: #d0d6e0; --muted: #8a8c95; --line: #29292d; }
+ }
+ :root[data-theme="dark"] { color-scheme: dark; --ground: #08090a; --ink: #d0d6e0; --muted: #8a8c95; --line: #29292d; }
+ :root[data-theme="light"] { color-scheme: light; }
+ * { box-sizing: border-box; }
+ body {
+ margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
+ background: var(--ground); color: var(--ink);
+ font: 13px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased;
+ }
+ main { width: 100%; max-width: 640px; }
+ .plate { position: relative; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
+ .tag, .label, output, button { font: 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.02em; }
+ .tag { position: absolute; top: 12px; z-index: 1; color: var(--muted); pointer-events: none; }
+ #name { left: 14px; }
+ #read { right: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
+ .controls { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 14px; }
+ .label { color: var(--muted); }
+ input[type="range"] {
+ flex: 1 1 96px; min-width: 0; height: 32px; margin: 0; background: transparent; cursor: pointer;
+ -webkit-appearance: none; appearance: none;
+ }
+ input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--muted); }
+ input[type="range"]::-webkit-slider-thumb {
+ -webkit-appearance: none; width: 13px; height: 13px; margin-top: -6px; border-radius: 50%;
+ border: 1px solid var(--ink); background: var(--ground);
+ }
+ input[type="range"]::-moz-range-track { height: 1px; background: var(--muted); }
+ input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--ink); background: var(--ground); }
+ input[type="range"]:focus-visible, button:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 2px; }
+ output { min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; }
+ button {
+ height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px;
+ background: transparent; color: var(--ink); cursor: pointer;
+ }
+ #play[aria-pressed="true"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }
+ #means { margin: 14px 0 0; text-wrap: pretty; }
+ #rules { margin: 6px 0 0; line-height: 1.6; }
+ #error { margin: 12px 0 0; padding-left: 10px; border-left: 1px solid var(--ink); }
+</style>
+</head>
+<body>
+<main>
+ <div class="plate">
+ <span class="tag" id="name"></span>
+ <span class="tag" id="read"></span>
+ <div id="stage"></div>
+ </div>
+ <div class="controls">
+ <label class="label" for="intensity">intensity</label>
+ <input id="intensity" type="range" min="0" max="1" step="0.01" value="0.5">
+ <output id="value" for="intensity"></output>
+ <span class="label">theme</span>
+ <button id="theme" type="button" aria-label="Switch between the light and the dark theme"></button>
+ <span class="label">play</span>
+ <button id="play" type="button" aria-pressed="false">play</button>
+ </div>
+ <p id="means"></p>
+ <p id="rules" class="label"></p>
+ <p id="error" role="alert" hidden></p>
+</main>
+<script id="hl-kernel">
+/* hairline kernel sha256:3a19aa2640ba8c6c306184d05fddfbd4f3323a6ebd9217dd3cbb38e9db74991c */
+/*
+ * HL: everything a figure may call. Read this index; the code under it is the
+ * package's src/core, unchanged, and a figure should not need to read it.
+ *
+ * Every figure is drawn in a 400 × 320 viewBox. World space is x/y on the
+ * ground and z up. Plates are filled with the ground colour and painted back
+ * to front, so a nearer one covers a farther one: append in that order. At
+ * the default camera, Cam(45, 0.5, S), +x runs down to the right and +y down
+ * to the left, so the corner with the largest x and y is nearest the viewer:
+ * append by ascending x + y, from the far corner (smallest x and y) to it.
+ *
+ * Camera
+ * Cam(azDeg, k, S) a camera: azimuth in degrees, k = sin(elevation) (0.5 is the 2:1 view), S = scale
+ * fit(C, points, cx, cy) centres the box of [x, y, z] points on (cx, cy); call it once, before proj
+ * it only centres, it never scales: choose S by trying values, with the most extreme pose in points.
+ * The six figures use S 1.42 to 2.12; the boxes they fit come out 230 to 310 wide and 180 to 245 tall
+ * proj(C) returns P(x, y, z), which gives [sx, sy]
+ * unproj(C, sx, sy, z) the world [x, y] under a screen point, on the plane at height z
+ * facing(C) returns front(sample): whether a ring sample faces the camera
+ * Rounded solids
+ * rrect(u0, v0, u1, v1, r, n) a rounded rectangle, as a ring of samples {u, v, nu, nv}
+ * circ(R, n) a circle, as a ring
+ * rings(x0, y0, x1, y1, r, b) [ring, inner]: a rounded footprint and its crease ring, inset by b
+ * r, the corner radius, is cut to half the shorter side. b, the crease's inset in world units
+ * (0.6 to 2.2 in the figures), must stay under half the shorter side or the crease turns inside out
+ * prism(P, front, ring, inner, z0, z1) {sil, crease}: a solid standing from z0 to z1, as two path strings
+ * ringAt(P, ring, z) the ring's points, projected at height z
+ * run(ring, keep) the one cyclic run of samples that pass keep
+ * hull(points) the convex hull of screen points
+ * extremes(P, ring) [left, right, nearest] samples: where dashed drops fall from
+ * fillet(points, radii, n) rounds every vertex of a closed polygon; returns the new points
+ * radii is an array, one radius per vertex, each cut to half its shorter edge; a single number gives NaN.
+ * n is the steps round each corner, default 4: each vertex becomes n + 1 points
+ * ghost(P, front, ring, z0, depth) a reflection's path {d, y0, y1}; reflect() draws it for you
+ * Paths and numbers
+ * poly(points) a closed path string
+ * open(points) an open polyline string
+ * seg(a, b) one segment between two screen points [sx, sy], as its own subpath; project world points with P first
+ * clamp(v, a, b)
+ * lerp(a, b, t)
+ * rad(deg)
+ * r2(n) two decimals
+ * The continuous clock: one spring per moving number
+ * spring(x, opts) at rest on x; write .t to retarget; opts {k, c, m, eps}, default k 100, c 18, m 1
+ * stepS(sp, dt) advances by dt seconds; returns whether it is still moving
+ * The discrete clock: a 700ms tween on (.32, .72, 0, 1)
+ * tween(v, dur) at rest on v; dur defaults to 700 (ms)
+ * tset(tw, to, now, delay) retargets from where it is, after delay ms: the stagger
+ * the same target again does nothing, so calling it on every pointer move is safe
+ * tval(tw, now) its value at now
+ * tdone(tw, now) whether it has landed
+ * bezier(x1, y1, x2, y2) a CSS cubic-bezier, as a function of progress
+ * EASE_LIFT the lift curve itself
+ * reducedMotion() true when the reader asked for less motion; springs and tweens already land at once
+ * setReducedMotion(on) the loop's business, not a figure's
+ * Drawing
+ * mk(tag, attrs, parent) one svg element: the only way a figure makes a node
+ * solid(parent) {g, sil, cr}: a group holding a silhouette path and a crease path
+ * put(solid, paths) writes prism()'s {sil, crease} into solid()'s {sil, cr}: sil into sil, crease into cr
+ * flatDot(parent, C, r, cls) a dot lying on the ground plane; cls is "dot", "dot m" or "dot off"
+ * place(el, point) moves a dot or a circle to [sx, sy]
+ * reflect(svg, parent, P, front, ring, z0, depth) a fading mirror under a solid
+ * fade(svg, y0, y1, a0) a vertical fade, as a mask; returns the value for a mask attribute
+ * Life
+ * register(stage, tick) joins the one frame loop; tick(dt in seconds, now in ms) returns true to ask for another frame; gives {wake, unregister}
+ * pointer(stage, handlers) {move(point), down(point), leave()}, points in viewBox units; returns its disposer
+ * disposer() {add, on, dispose}: collects tear-down, so destroy is bag.dispose
+ * The bench's business, not a figure's
+ * css(lightDark)
+ * inject(root)
+ * tour(stage, stops, onStop) an unseen pointer that walks the stops, [x, y] in viewBox units or null to leave, and gives way to a real one; onStop(i) on each arrival; returns {stop}
+ * LAP the default stops: a diamond around the centre, then a leave
+ *
+ * Classes, on path, polygon, ellipse and line. They are the whole palette; a
+ * figure sets no colour, width or fill of its own.
+ * (none) filled with the ground colour, medium stroke
+ * sil the silhouette's stroke hi the bright stroke: the only highlight
+ * lo the dim stroke nf no fill fo fill only, no stroke
+ * dash a dashed guide
+ * dot a bright dot dot m a medium dot dot off a dim dot
+ */
+var HL = (() => {
+ var __defProp = Object.defineProperty;
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
+ var __getOwnPropNames = Object.getOwnPropertyNames;
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
+ var __export = (target, all) => {
+ for (var name in all)
+ __defProp(target, name, { get: all[name], enumerable: true });
+ };
+ var __copyProps = (to, from, except, desc) => {
+ if (from && typeof from === "object" || typeof from === "function") {
+ for (let key of __getOwnPropNames(from))
+ if (!__hasOwnProp.call(to, key) && key !== except)
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
+ }
+ return to;
+ };
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
+
+ // packages/hairline/src/core/kernel.ts
+ var kernel_exports = {};
+ __export(kernel_exports, {
+ Cam: () => Cam,
+ EASE_LIFT: () => EASE_LIFT,
+ LAP: () => LAP,
+ bezier: () => bezier,
+ circ: () => circ,
+ clamp: () => clamp,
+ css: () => css,
+ disposer: () => disposer,
+ extremes: () => extremes,
+ facing: () => facing,
+ fade: () => fade,
+ fillet: () => fillet,
+ fit: () => fit,
+ flatDot: () => flatDot,
+ ghost: () => ghost,
+ hull: () => hull,
+ inject: () => inject,
+ lerp: () => lerp,
+ mk: () => mk,
+ open: () => open,
+ place: () => place,
+ pointer: () => pointer,
+ poly: () => poly,
+ prism: () => prism,
+ proj: () => proj,
+ put: () => put,
+ r2: () => r2,
+ rad: () => rad,
+ reducedMotion: () => reducedMotion,
+ reflect: () => reflect,
+ register: () => register,
+ ringAt: () => ringAt,
+ rings: () => rings,
+ rrect: () => rrect,
+ run: () => run,
+ seg: () => seg,
+ setReducedMotion: () => setReducedMotion,
+ solid: () => solid,
+ spring: () => spring,
+ stepS: () => stepS,
+ tdone: () => tdone,
+ tour: () => tour,
+ tset: () => tset,
+ tval: () => tval,
+ tween: () => tween,
+ unproj: () => unproj
+ });
+
+ // packages/hairline/src/core/iso.ts
+ var clamp = (v, a, b) => Math.max(a, Math.min(b, v));
+ var lerp = (a, b, t) => a + (b - a) * t;
+ var rad = (d) => d * Math.PI / 180;
+ var r2 = (n) => Math.round(n * 100) / 100;
+ var poly = (pts) => "M" + pts.map((p) => r2(p[0]) + " " + r2(p[1])).join("L") + "Z";
+ var seg = (a, b) => `M${r2(a[0])} ${r2(a[1])}L${r2(b[0])} ${r2(b[1])}`;
+ var open = (pts) => pts.length < 2 ? "" : "M" + pts.map((p) => r2(p[0]) + " " + r2(p[1])).join("L");
+ var Cam = (azDeg, k, S) => ({ az: rad(azDeg), k, S, ox: 0, oy: 0 });
+ function proj(C) {
+ const c = Math.cos(C.az), s = Math.sin(C.az), zf = Math.sqrt(1 - C.k * C.k);
+ return (x, y, z) => {
+ const X = x * c - y * s, Y = x * s + y * c;
+ return [C.ox + C.S * X, C.oy + C.S * (Y * C.k - z * zf)];
+ };
+ }
+ function unproj(C, sx, sy, z) {
+ const c = Math.cos(C.az), s = Math.sin(C.az), zf = Math.sqrt(1 - C.k * C.k);
+ const X = (sx - C.ox) / C.S, Y = ((sy - C.oy) / C.S + z * zf) / C.k;
+ return [X * c + Y * s, -X * s + Y * c];
+ }
+ function fit(C, pts, cx, cy) {
+ C.ox = 0;
+ C.oy = 0;
+ const P = proj(C);
+ let a = 1e9, b = -1e9, c = 1e9, d = -1e9;
+ for (const p of pts) {
+ const q = P(p[0], p[1], p[2]);
+ a = Math.min(a, q[0]);
+ b = Math.max(b, q[0]);
+ c = Math.min(c, q[1]);
+ d = Math.max(d, q[1]);
+ }
+ C.ox = cx - (a + b) / 2;
+ C.oy = cy - (c + d) / 2;
+ }
+ function rrect(u0, v0, u1, v1, r, n = 4) {
+ r = Math.max(0, Math.min(r, (u1 - u0) / 2, (v1 - v0) / 2));
+ const out = [];
+ for (const [cu, cv, a0] of [[u1 - r, v1 - r, 0], [u0 + r, v1 - r, 90], [u0 + r, v0 + r, 180], [u1 - r, v0 + r, 270]])
+ for (let k = 0; k <= n; k++) {
+ const a = rad(a0 + 90 * k / n), ca = Math.cos(a), sa = Math.sin(a);
+ out.push({ u: cu + r * ca, v: cv + r * sa, nu: ca, nv: sa });
+ }
+ return out;
+ }
+ function circ(R, n = 96) {
+ const out = [];
+ for (let k = 0; k < n; k++) {
+ const a = k / n * Math.PI * 2, ca = Math.cos(a), sa = Math.sin(a);
+ out.push({ u: R * ca, v: R * sa, nu: ca, nv: sa });
+ }
+ return out;
+ }
+ function hull(input) {
+ const pts = input.slice().sort((a, b) => a[0] - b[0] || a[1] - b[1]);
+ const x = (o, a, b) => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
+ const lo = [], up = [];
+ for (const p of pts) {
+ while (lo.length > 1 && x(lo[lo.length - 2], lo[lo.length - 1], p) <= 0) lo.pop();
+ lo.push(p);
+ }
+ for (let i = pts.length - 1; i >= 0; i--) {
+ const p = pts[i];
+ while (up.length > 1 && x(up[up.length - 2], up[up.length - 1], p) <= 0) up.pop();
+ up.push(p);
+ }
+ lo.pop();
+ up.pop();
+ return lo.concat(up);
+ }
+ var ringAt = (P, ring, z) => ring.map((q) => P(q.u, q.v, z));
+ var facing = (C) => {
+ const s = Math.sin(C.az), c = Math.cos(C.az);
+ return (q) => q.nu * s + q.nv * c >= -1e-6;
+ };
+ function run(ring, keep) {
+ const n = ring.length;
+ let s = -1;
+ for (let i = 0; i < n; i++) if (keep(ring[i]) && !keep(ring[(i + n - 1) % n])) {
+ s = i;
+ break;
+ }
+ if (s < 0) return keep(ring[0]) ? ring.slice() : [];
+ const out = [];
+ for (let k = 0; k < n && keep(ring[(s + k) % n]); k++) out.push(ring[(s + k) % n]);
+ return out;
+ }
+ function prism(P, front, ring, inner, z0, z1) {
+ return {
+ sil: poly(hull(ringAt(P, ring, z1).concat(ringAt(P, ring, z0)))),
+ crease: inner ? open(ringAt(P, run(inner, front), z1)) : ""
+ };
+ }
+ var rings = (x0, y0, x1, y1, r, b) => [
+ rrect(x0, y0, x1, y1, r),
+ rrect(x0 + b, y0 + b, x1 - b, y1 - b, Math.max(0.3, r - b))
+ ];
+ function extremes(P, ring) {
+ const pr = ring.map((q) => P(q.u, q.v, 0));
+ let a = 0, b = 0, c = 0;
+ pr.forEach((p, k) => {
+ if (p[0] < pr[a][0]) a = k;
+ if (p[0] > pr[b][0]) b = k;
+ if (p[1] > pr[c][1]) c = k;
+ });
+ return [ring[a], ring[b], ring[c]];
+ }
+ function fillet(pts, rs, n = 4) {
+ const m = pts.length, out = [];
+ for (let i = 0; i < m; i++) {
+ const a = pts[(i + m - 1) % m], p = pts[i], b = pts[(i + 1) % m];
+ const la = Math.hypot(a[0] - p[0], a[1] - p[1]), lb = Math.hypot(b[0] - p[0], b[1] - p[1]);
+ const t = Math.min(rs[i], la / 2, lb / 2);
+ const p1 = [p[0] + (a[0] - p[0]) / la * t, p[1] + (a[1] - p[1]) / la * t];
+ const p2 = [p[0] + (b[0] - p[0]) / lb * t, p[1] + (b[1] - p[1]) / lb * t];
+ for (let k = 0; k <= n; k++) {
+ const s = k / n, w = 1 - s;
+ out.push([w * w * p1[0] + 2 * w * s * p[0] + s * s * p2[0], w * w * p1[1] + 2 * w * s * p[1] + s * s * p2[1]]);
+ }
+ }
+ return out;
+ }
+ function ghost(P, front, ring, z0, depth) {
+ const f = run(ring, front), lowP = ringAt(P, f, z0 - depth);
+ return {
+ d: open(lowP) + [f[0], f[f.length - 1]].map((q) => seg(P(q.u, q.v, z0), P(q.u, q.v, z0 - depth))).join(""),
+ y0: Math.min(...ringAt(P, f, z0).map((p) => p[1])),
+ y1: Math.max(...lowP.map((p) => p[1])) + 2
+ };
+ }
+
+ // packages/hairline/src/core/motion.ts
+ var reduced = false;
+ var setReducedMotion = (on) => {
+ reduced = on;
+ };
+ var reducedMotion = () => reduced;
+ function spring(x, o = {}) {
+ return { x, v: 0, t: x, k: o.k ?? 100, c: o.c ?? 18, m: o.m ?? 1, eps: o.eps ?? 0.01 };
+ }
+ function stepS(sp, dt) {
+ if (reduced) {
+ sp.x = sp.t;
+ sp.v = 0;
+ return false;
+ }
+ const n = Math.max(1, Math.ceil(dt * 240)), h = dt / n;
+ for (let i = 0; i < n; i++) {
+ const a = (-sp.k * (sp.x - sp.t) - sp.c * sp.v) / sp.m;
+ sp.v += a * h;
+ sp.x += sp.v * h;
+ }
+ if (Math.abs(sp.x - sp.t) < sp.eps && Math.abs(sp.v) < sp.eps * 10) {
+ sp.x = sp.t;
+ sp.v = 0;
+ return false;
+ }
+ return true;
+ }
+ function bezier(x1, y1, x2, y2) {
+ const cx = 3 * x1, bx = 3 * (x2 - x1) - cx, ax = 1 - cx - bx;
+ const cy = 3 * y1, by = 3 * (y2 - y1) - cy, ay = 1 - cy - by;
+ const X = (u) => ((ax * u + bx) * u + cx) * u;
+ const Y = (u) => ((ay * u + by) * u + cy) * u;
+ const dX = (u) => (3 * ax * u + 2 * bx) * u + cx;
+ return (t) => {
+ if (t <= 0) return 0;
+ if (t >= 1) return 1;
+ let u = t;
+ for (let i = 0; i < 8; i++) {
+ const e = X(u) - t;
+ if (Math.abs(e) < 1e-5) break;
+ const d = dX(u);
+ if (Math.abs(d) < 1e-6) break;
+ u -= e / d;
+ }
+ if (!(u >= 0 && u <= 1) || Math.abs(X(u) - t) > 1e-4) {
+ let lo = 0, hi = 1;
+ u = t;
+ for (let i = 0; i < 24; i++) {
+ if (X(u) < t) lo = u;
+ else hi = u;
+ u = (lo + hi) / 2;
+ }
+ }
+ return Y(u);
+ };
+ }
+ var EASE_LIFT = bezier(0.32, 0.72, 0, 1);
+ var tween = (v, dur = 700) => ({ from: v, to: v, t0: -1e9, dur });
+ var tval = (tw, now) => {
+ const p = clamp((now - tw.t0) / tw.dur, 0, 1);
+ return tw.from + (tw.to - tw.from) * (reduced ? 1 : EASE_LIFT(p));
+ };
+ var tset = (tw, to, now, delay) => {
+ if (tw.to === to) return;
+ tw.from = tval(tw, now);
+ tw.to = to;
+ tw.t0 = now + delay;
+ };
+ var tdone = (tw, now) => reduced || now >= tw.t0 + tw.dur;
+
+ // packages/hairline/src/core/stage.ts
+ var NS = "http://www.w3.org/2000/svg";
+ function mk(tag, attrs, parent) {
+ const e = document.createElementNS(NS, tag);
+ if (attrs) for (const k in attrs) e.setAttribute(k, String(attrs[k]));
+ if (parent) parent.appendChild(e);
+ return e;
+ }
+ function solid(parent) {
+ const g = mk("g", {}, parent);
+ return { g, sil: mk("path", { class: "sil" }, g), cr: mk("path", { class: "nf lo" }, g) };
+ }
+ var put = (el, s) => {
+ el.sil.setAttribute("d", s.sil);
+ el.cr.setAttribute("d", s.crease);
+ };
+ var flatDot = (parent, C, r, cls) => mk("ellipse", { rx: r2(r * C.S), ry: r2(r * C.S * C.k), class: cls }, parent);
+ var place = (el, q) => {
+ el.setAttribute("cx", String(r2(q[0])));
+ el.setAttribute("cy", String(r2(q[1])));
+ };
+ var fid = 0;
+ function fade(svg, y0, y1, a0 = 0.7) {
+ const id = "hl-fd" + ++fid, defs = mk("defs", {}, svg);
+ const lg = mk("linearGradient", { id: id + "g", gradientUnits: "userSpaceOnUse", x1: 0, y1: r2(y0), x2: 0, y2: r2(y1) }, defs);
+ mk("stop", { offset: 0, "stop-color": "#fff", "stop-opacity": a0 }, lg);
+ mk("stop", { offset: 1, "stop-color": "#fff", "stop-opacity": 0 }, lg);
+ const m = mk("mask", { id, maskUnits: "userSpaceOnUse", x: 0, y: 0, width: 400, height: 320 }, defs);
+ mk("rect", { x: 0, y: 0, width: 400, height: 320, fill: `url(#${id}g)` }, m);
+ return `url(#${id})`;
+ }
+ function reflect(svg, parent, P, front, ring, z0, depth) {
+ const r = ghost(P, front, ring, z0, depth);
+ const gh = mk("g", { class: "ghost", mask: fade(svg, r.y0, r.y1) }, parent);
+ mk("path", { d: r.d }, gh);
+ }
+ var boards = [];
+ var byStage = /* @__PURE__ */ new Map();
+ var raf = 0;
+ var last = 0;
+ var io = null;
+ var rm = null;
+ function frame(now) {
+ const dt = Math.min(0.05, Math.max(0, (now - last) / 1e3));
+ last = now;
+ let any = false;
+ for (const b of boards.slice()) if (b.vis && b.awake) {
+ try {
+ b.awake = !!b.tick(dt, now);
+ } catch (err) {
+ b.awake = false;
+ setTimeout(() => {
+ throw err;
+ });
+ }
+ any = any || b.awake;
+ }
+ raf = any ? requestAnimationFrame(frame) : 0;
+ }
+ function wake(b) {
+ b.awake = true;
+ if (!raf) {
+ last = performance.now();
+ raf = requestAnimationFrame(frame);
+ }
+ }
+ var onMotion = () => {
+ setReducedMotion(!!rm?.matches);
+ boards.forEach(wake);
+ };
+ function start() {
+ if (io) return;
+ io = new IntersectionObserver((es) => {
+ for (const e of es) {
+ const set = byStage.get(e.target);
+ if (!set) continue;
+ for (const b of set) {
+ b.vis = e.isIntersecting;
+ if (b.vis) wake(b);
+ }
+ }
+ }, { rootMargin: "80px" });
+ rm = matchMedia("(prefers-reduced-motion: reduce)");
+ setReducedMotion(rm.matches);
+ rm.addEventListener("change", onMotion);
+ }
+ function stop() {
+ if (raf) cancelAnimationFrame(raf);
+ raf = 0;
+ io?.disconnect();
+ io = null;
+ rm?.removeEventListener("change", onMotion);
+ rm = null;
+ }
+ function register(stage, tick) {
+ start();
+ const b = { stage, tick, vis: false, awake: true };
+ boards.push(b);
+ const peers = byStage.get(stage);
+ if (peers) {
+ for (const p of peers) b.vis = p.vis;
+ peers.add(b);
+ if (b.vis) wake(b);
+ } else {
+ byStage.set(stage, /* @__PURE__ */ new Set([b]));
+ io.observe(stage);
+ }
+ tick(0, performance.now());
+ let gone = false;
+ return {
+ wake: () => {
+ if (!gone) wake(b);
+ },
+ unregister: () => {
+ if (gone) return;
+ gone = true;
+ boards = boards.filter((x) => x !== b);
+ const set = byStage.get(stage);
+ if (set) {
+ set.delete(b);
+ if (!set.size) {
+ byStage.delete(stage);
+ io?.unobserve(stage);
+ }
+ }
+ if (!boards.length) stop();
+ }
+ };
+ }
+ var handlers = /* @__PURE__ */ new WeakMap();
+ var touring = /* @__PURE__ */ new WeakMap();
+ function pointer(stage, on) {
+ handlers.set(stage, on);
+ let tm = 0;
+ const pt = (e) => {
+ const r = stage.getBoundingClientRect();
+ return [(e.clientX - r.left) / r.width * 400, (e.clientY - r.top) / r.height * 320];
+ };
+ const move = (e) => {
+ clearTimeout(tm);
+ touring.get(stage)?.hold();
+ on.move(pt(e), e);
+ };
+ const down = (e) => {
+ clearTimeout(tm);
+ touring.get(stage)?.hold();
+ if (e.pointerType !== "mouse") stage.releasePointerCapture?.(e.pointerId);
+ if (on.down) on.down(pt(e), e);
+ else on.move(pt(e), e);
+ };
+ const leave = (e) => {
+ clearTimeout(tm);
+ tm = window.setTimeout(() => {
+ on.leave(e);
+ touring.get(stage)?.release();
+ }, e.pointerType === "mouse" ? 0 : 1400);
+ };
+ stage.addEventListener("pointermove", move);
+ stage.addEventListener("pointerdown", down);
+ stage.addEventListener("pointerleave", leave);
+ return () => {
+ clearTimeout(tm);
+ if (handlers.get(stage) === on) handlers.delete(stage);
+ stage.removeEventListener("pointermove", move);
+ stage.removeEventListener("pointerdown", down);
+ stage.removeEventListener("pointerleave", leave);
+ };
+ }
+ var LAP = [[128, 150], [200, 118], [272, 150], [200, 206], null];
+ var TRAVEL = 900;
+ var DWELL = 1200;
+ var REST = 1800;
+ var RESUME = 1200;
+ var STAGGER = 450;
+ var GHOST = { pointerType: "ghost" };
+ var started = 0;
+ function entry([x, y]) {
+ const dx = x - 200, dy = y - 160;
+ if (!dx && !dy) return [200, 320];
+ const k = Math.min(dx ? (dx > 0 ? 200 : -200) / dx : Infinity, dy ? (dy > 0 ? 160 : -160) / dy : Infinity);
+ return [200 + dx * k, 160 + dy * k];
+ }
+ function tour(stage, stops, onStop) {
+ let i = 0;
+ let wait = RESUME + STAGGER * (started++ % 4);
+ let t = -1;
+ let at = null;
+ let origin = [200, 320];
+ let hand = false, keys = stage.contains(stage.ownerDocument.activeElement);
+ let gone = false;
+ const leave = () => {
+ at = null;
+ t = -1;
+ handlers.get(stage)?.leave(GHOST);
+ };
+ const tick = (dt) => {
+ if (hand || keys || !stops.length) return false;
+ if (reducedMotion()) {
+ if (at) leave();
+ return false;
+ }
+ if (wait > 0) {
+ wait -= dt * 1e3;
+ return true;
+ }
+ const stop2 = stops[i];
+ if (stop2 === null) {
+ if (at) leave();
+ onStop?.(i);
+ i = (i + 1) % stops.length;
+ wait = REST;
+ return true;
+ }
+ const h = handlers.get(stage);
+ if (!h) return true;
+ if (t < 0) {
+ origin = at ?? entry(stop2);
+ t = 0;
+ }
+ t = Math.min(TRAVEL, t + dt * 1e3);
+ const k = EASE_LIFT(t / TRAVEL);
+ at = [origin[0] + (stop2[0] - origin[0]) * k, origin[1] + (stop2[1] - origin[1]) * k];
+ h.move(at, GHOST);
+ if (t < TRAVEL) return true;
+ onStop?.(i);
+ i = (i + 1) % stops.length;
+ t = -1;
+ wait = DWELL;
+ return true;
+ };
+ const take = () => {
+ at = null;
+ t = -1;
+ };
+ const give = () => {
+ if (hand || keys) return;
+ i = 0;
+ t = -1;
+ wait = RESUME;
+ board.wake();
+ };
+ const me = {
+ hold: () => {
+ hand = true;
+ take();
+ },
+ release: () => {
+ if (!hand) return;
+ hand = false;
+ give();
+ }
+ };
+ const focusIn = () => {
+ keys = true;
+ take();
+ };
+ const focusOut = (e) => {
+ if (keys && !stage.contains(e.relatedTarget)) {
+ keys = false;
+ give();
+ }
+ };
+ stage.addEventListener("focusin", focusIn);
+ stage.addEventListener("focusout", focusOut);
+ touring.set(stage, me);
+ const board = register(stage, tick);
+ return {
+ stop: () => {
+ if (gone) return;
+ gone = true;
+ board.unregister();
+ stage.removeEventListener("focusin", focusIn);
+ stage.removeEventListener("focusout", focusOut);
+ if (touring.get(stage) === me) touring.delete(stage);
+ if (at) leave();
+ }
+ };
+ }
+ function disposer() {
+ let fns = [];
+ return {
+ add: (fn) => {
+ fns.push(fn);
+ },
+ on: (target, type, fn, opts) => {
+ const h = fn;
+ target.addEventListener(type, h, opts);
+ fns.push(() => target.removeEventListener(type, h, opts));
+ },
+ dispose: () => {
+ const run2 = fns;
+ fns = [];
+ for (let i = run2.length - 1; i >= 0; i--) run2[i]();
+ }
+ };
+ }
+
+ // packages/hairline/src/core/styles.ts
+ var LIGHT = { plate: "#ffffff", hi: "#232327", edge: "#a4a4ac", mid: "#c3c3c9", lo: "#e0e0e4" };
+ var DARK = { plate: "#08090a", hi: "#d0d6e0", edge: "#5b5d64", mid: "#3e3e44", lo: "#29292d" };
+ var KEYS = ["plate", "hi", "edge", "mid", "lo"];
+ var vars = (p) => KEYS.map((k) => `--hl-${k}:var(--hairline-${k},${p[k]});`).join("");
+ var EASE = "cubic-bezier(0.5,0,0.1,1)";
+ var SVG = ":where([data-hairline]>svg)";
+ function css(lightDark) {
+ const both = Object.fromEntries(KEYS.map((k) => [k, `light-dark(${LIGHT[k]},${DARK[k]})`]));
+ return [
+ // the box, and the palette: light unless something below says otherwise
+ `:where([data-hairline]){display:block;position:relative;aspect-ratio:5/4;touch-action:pan-y;user-select:none;-webkit-user-select:none;--hl-sw:var(--hairline-stroke,0.9);${vars(LIGHT)}}`,
+ // the page's color-scheme
+ lightDark ? `:where([data-hairline]){${vars(both)}}` : "",
+ // an ancestor that says dark
+ `:where(.dark,[data-theme="dark"]) :where([data-hairline]){${vars(DARK)}}`,
+ // the figure's own theme option
+ `:where([data-hairline][data-hairline-theme="light"]){${vars(LIGHT)}}`,
+ `:where([data-hairline][data-hairline-theme="dark"]){${vars(DARK)}}`,
+ `:where([data-hairline]:focus-visible){outline:1.5px solid var(--hl-hi);outline-offset:2px}`,
+ `${SVG}{position:absolute;inset:0;width:100%;height:100%;display:block}`,
+ // Riffle's live region: read, not seen
+ `:where([data-hairline]>[data-hairline-live]){position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}`,
+ // the drawing: plates are filled with the plate colour and painted back to front
+ `${SVG} :where(path,polygon,ellipse,line){fill:var(--hl-plate);stroke:var(--hl-mid);stroke-width:var(--hl-sw);vector-effect:non-scaling-stroke;stroke-linejoin:round;stroke-linecap:round;transition:stroke 260ms ${EASE}}`,
+ `${SVG} :where(.nf){fill:none}`,
+ `${SVG} :where(.fo){stroke:none}`,
+ `${SVG} :where(.sil){stroke:var(--hl-edge)}`,
+ `${SVG} :where(.hi){stroke:var(--hl-hi)}`,
+ `${SVG} :where(.lo){stroke:var(--hl-lo)}`,
+ `${SVG} :where(.dash){stroke-dasharray:1 3}`,
+ `${SVG} :where(.dot){stroke:none;fill:var(--hl-hi);transition:fill 260ms ${EASE}}`,
+ `${SVG} :where(.dot.m){fill:var(--hl-edge)}`,
+ `${SVG} :where(.dot.off){fill:var(--hl-lo)}`,
+ `${SVG} :where(.ghost path){fill:none;stroke:var(--hl-mid)}`
+ ].join("");
+ }
+ var done = /* @__PURE__ */ new WeakSet();
+ function inject(root) {
+ if (done.has(root)) return;
+ done.add(root);
+ const doc = root.nodeType === 9 ? root : root.ownerDocument;
+ const win = doc.defaultView;
+ const text = css(!!win?.CSS?.supports?.("color", "light-dark(#000,#fff)"));
+ if (win && "adoptedStyleSheets" in root) {
+ try {
+ const sheet = new win.CSSStyleSheet();
+ sheet.replaceSync(text);
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
+ return;
+ } catch {
+ }
+ }
+ const style = doc.createElement("style");
+ style.setAttribute("data-hairline-style", "");
+ style.textContent = text;
+ (root.nodeType === 9 ? doc.head ?? doc.documentElement : root).appendChild(style);
+ }
+ return __toCommonJS(kernel_exports);
+})();
+/* /hairline kernel */
+</script>
+<script id="hl-bench">
+/*
+ * The bench: the page a figure is shown on. It makes the host and the svg the
+ * way the package's mount does, hands them to the figure, and owns everything
+ * around it: the read-out, the slider, the theme, the line under the stage.
+ */
+(() => {
+ const RULES = ["hit", "order", "reach", "accent", "rest", "honesty", "cost", "clock", "radius", "quiet"];
+ const $ = (id) => document.getElementById(id);
+ const root = document.documentElement, params = new URLSearchParams(location.search);
+
+ /* the theme: the system's until the switch is pressed, then the switch's */
+ const dark = () => (root.dataset.theme ? root.dataset.theme === "dark" : matchMedia("(prefers-color-scheme: dark)").matches);
+ const label = () => { $("theme").textContent = dark() ? "dark" : "light"; };
+ $("theme").addEventListener("click", () => { root.dataset.theme = dark() ? "light" : "dark"; label(); });
+ /* ?theme=light or ?theme=dark wins over the system's, as pressing the switch does */
+ if (["light", "dark"].includes(params.get("theme"))) root.dataset.theme = params.get("theme");
+ label();
+
+ /* ?intensity=0 sets the slider before the figure mounts, for a look at either end */
+ const i = (params.get("intensity") || "").trim();
+ if (i && Number.isFinite(Number(i))) $("intensity").value = String(Math.min(1, Math.max(0, Number(i))));
+
+ /* ?w=240 narrows the page, for a look at the size of a thumbnail */
+ const w = Number(params.get("w"));
+ if (w > 0) document.querySelector("main").style.maxWidth = w + "px";
+
+ /* a figure that fails says so under the stage, instead of leaving an empty plate */
+ addEventListener("error", (e) => {
+ $("error").hidden = false;
+ $("error").textContent = String((e.error && e.error.message) || e.message);
+ });
+
+ let mounted = false;
+ window.hairline = (figure) => {
+ if (mounted) throw new Error("hairline: one figure per page.");
+ mounted = true;
+ const stage = $("stage"), slider = $("intensity");
+
+ /* intensity to the figure's own number: two straight lines that meet at 0.5, as in the package */
+ const [lo, mid, hi] = figure.range;
+ const at = (i) => Math.round((i <= 0.5 ? lo + (i / 0.5) * (mid - lo) : mid + ((i - 0.5) / 0.5) * (hi - mid)) * 1000) / 1000;
+
+ HL.inject(document);
+ stage.setAttribute("data-hairline", figure.name);
+ stage.setAttribute("role", "img");
+ stage.setAttribute("aria-label", figure.means);
+ const svg = HL.mk("svg", { viewBox: "0 0 400 320", "aria-hidden": "true" }, stage);
+
+ let text = null;
+ const read = {
+ get textContent() { return text; },
+ set textContent(value) { text = value == null ? "" : String(value); $("read").textContent = text; },
+ };
+
+ document.title = "Hairline · " + figure.name;
+ $("name").textContent = figure.name;
+ $("means").textContent = figure.means;
+ $("rules").textContent = figure.rules.map((n) => String(n).padStart(2, "0") + " " + RULES[n - 1]).join(" · ");
+ const show = () => { $("value").textContent = String(at(Number(slider.value))); };
+ show();
+
+ const handle = figure.mount({ stage, svg, read }, at(Number(slider.value)));
+ if (text === null) read.textContent = "rest";
+ slider.addEventListener("input", () => { show(); handle.set(at(Number(slider.value))); });
+ window.hairline.figure = handle;
+
+ /* play: an unseen pointer walks the figure's tour (or HL.LAP) until a hand arrives; ?play=1 starts it on load */
+ const play = $("play");
+ window.hairline.playing = null;
+ play.addEventListener("click", () => {
+ const was = play.getAttribute("aria-pressed") === "true";
+ if (was) { window.hairline.playing.stop(); window.hairline.playing = null; }
+ else window.hairline.playing = HL.tour(stage, figure.tour || HL.LAP, (i) => { if (window.hairline.onStop) window.hairline.onStop(i); });
+ play.setAttribute("aria-pressed", String(!was));
+ });
+ if (params.get("play") === "1") play.click();
+
+ /* ?at=200,160 holds the pointer at a viewBox point, for a picture of the answer without a mouse */
+ const p = (params.get("at") || "").split(",").map(Number);
+ if (p.length === 2 && p.every(Number.isFinite)) {
+ const r = stage.getBoundingClientRect();
+ stage.dispatchEvent(new PointerEvent("pointermove", {
+ pointerType: "mouse", pointerId: 1, bubbles: true,
+ clientX: r.left + (p[0] / 400) * r.width, clientY: r.top + (p[1] / 320) * r.height,
+ }));
+ }
+ };
+})();
+</script>
+<script type="module" id="hl-figure">
+/**
+ * Deploy, liftoff: the rocket of the source drawing, rebuilt as solids, stands on its
+ * fins on a launch pad, its service arm at its side and a pilot flame under it. The
+ * pointer's height over the figure is the thrust. Raise it: the flame widens on the pad,
+ * then the rocket lifts off in one eased move, the flame stretches out behind it, and a
+ * dashed exhaust column draws itself down to the pad. Lower it, or leave, and it settles
+ * back. The slider is how high it climbs.
+ */
+const {
+ Cam, clamp, facing, fit, fillet, hull, open, poly, prism, proj, rings, seg, solid, put,
+ spring, stepS, disposer, mk, pointer, register,
+} = HL;
+
+const R = 14, ZB = 12, CYL = 26, TOP = 64, FIN = 12, NZ = 3.5, PILOT = 14, FL = 32, FR0 = 5, FR = 7.5, TRAIL = 4.5, RMAX = 40;
+const WZ = 36, WR = 6.5, MH = 50, ARM = 40;
+/** The body's profile, nose to base, [r, z above its base], from the source's curve (y 18 → 56), its tip rounded off. */
+const PROFILE = (() => {
+ const b = (a, c, d, e, t) => (1 - t) ** 3 * a + 3 * (1 - t) ** 2 * t * c + 3 * (1 - t) * t * t * d + t ** 3 * e;
+ const out = [];
+ for (let k = 0; k <= 12; k++) { const t = 0.05 + (0.95 * k) / 12; out.push([60 - b(60, 50, 46, 46, t), 82 - b(18, 28, 42, 56, t)]); }
+ return out.concat([[R, 0]]);
+})();
+const rAt = (z) => {
+ for (let i = 1; i < PROFILE.length; i++) {
+ const [r0, z0] = PROFILE[i - 1], [r1, z1] = PROFILE[i];
+ if (z <= z0 && z >= z1) return r0 + ((r1 - r0) * (z0 - z)) / (z0 - z1);
+ }
+ return R;
+};
+/** A fin in its own plane, [u out from the axis, z above the body's base]: the source's trapezoid, its tip on the pad. */
+const FINP = [[R - 1, 18], [R + FIN, 4], [R + FIN, -ZB], [R - 1, 0]];
+
+/** A thin plate from two outlines of the same points, its near face and its far one: far face, the walls that show, their turns, near face. */
+function slab(front, back) {
+ const n = front.length, o = [back[0][0] - front[0][0], back[0][1] - front[0][1]];
+ const area = front.reduce((a, p, i) => { const q = front[(i + 1) % n]; return a + p[0] * q[1] - q[0] * p[1]; }, 0);
+ const vis = front.map((p, i) => { const q = front[(i + 1) % n], ex = q[0] - p[0], ey = q[1] - p[1]; return (area > 0 ? ey * o[0] - ex * o[1] : ex * o[1] - ey * o[0]) > 0; });
+ let walls = "", turns = "";
+ front.forEach((p, i) => {
+ const j = (i + 1) % n;
+ if (vis[i]) walls += poly([p, front[j], back[j], back[i]]);
+ if (vis[i] !== vis[(i + n - 1) % n]) turns += seg(p, back[i]);
+ });
+ return [poly(back), walls, turns, poly(front)];
+}
+
+function mount({ stage, svg, read }, value) {
+ const bag = disposer();
+ let reach = value, thr = 0, hover = false;
+
+ const C = Cam(45, 0.5, 2.1);
+ fit(C, [[-26, -60, -4], [26, -60, -4], [26, 26, -4], [-26, 26, -4], [0, -48, MH], [0, 0, ZB + TOP + RMAX],
+ [-R, R, ZB + TOP + RMAX], [R, -R, ZB + TOP + RMAX]], 200, 166);
+ const P = proj(C), front = facing(C);
+ /** A ring round the axis at radius r and height z, from angle a0 to a1 (degrees). */
+ const ring = (r, z, a0 = 0, a1 = 360, n = 32) => Array.from({ length: n + (a1 - a0 < 360 ? 1 : 0) }, (_, k) => {
+ const a = ((a0 + ((a1 - a0) * k) / n) * Math.PI) / 180;
+ return P(r * Math.cos(a), r * Math.sin(a), z);
+ });
+
+ const g = mk("g", {}, svg);
+ // the pad: a thick plate, longer toward the back where the mast stands; the flame trench under the rocket, which the pilot flame dips into
+ put(solid(g), prism(P, front, ...rings(-26, -60, 26, 26, 9, 2.2), -4, 0));
+ mk("path", { class: "nf lo", d: poly(ring(11, 0)) }, g);
+ // the mast, and its service arm reaching to the rocket's side
+ put(solid(g), prism(P, front, ...rings(-3.5, -52, 3.5, -45, 1.6, 0.8), 0, MH));
+ put(solid(g), prism(P, front, ...rings(-1.5, -45, 1.5, -15, 0.7, 0.5), ARM, ARM + 3));
+
+ // the rocket, back to front: exhaust column, flame, nozzle, body, window, fins
+ const trail = mk("path", { class: "nf lo dash" }, g);
+ const flame = mk("path", { class: "sil" }, g), core = mk("path", { class: "nf lo" }, g);
+ const nozzle = mk("path", { class: "sil" }, g);
+ const body = solid(g);
+ const win = mk("path", { class: "sil hi" }, g), rim = mk("path", { class: "nf lo" }, g);
+ const fins = [330, 120].map((deg) => {
+ const a = (deg * Math.PI) / 180, d = [Math.cos(a), Math.sin(a)], n = [-d[1], d[0]], s = n[0] + n[1] > 0 ? 1 : -1;
+ const els = ["sil", "fo", "sil nf", "sil"].map((cls) => mk("path", { class: cls }, g));
+ return { d, n: [n[0] * s, n[1] * s], els };
+ });
+
+ /** A point on the body's skin, a radians round from the near side and z above its base. */
+ const skin = (a, z, zb) => { const r = rAt(z), t = Math.PI / 4 + a / r; return P(r * Math.cos(t), r * Math.sin(t), zb + z); };
+ const disc = (rw, zb) => Array.from({ length: 24 }, (_, k) => skin(rw * Math.cos((k * Math.PI) / 12), WZ + rw * Math.sin((k * Math.PI) / 12), zb));
+
+ const tune = (sp, ms) => { const w = 5600 / ms; sp.k = w * w; sp.c = 2 * w; return sp; };
+ const lift = tune(spring(0, { eps: 0.02 }), 1400), fl = tune(spring(PILOT, { eps: 0.02 }), 520), fr = tune(spring(FR0, { eps: 0.01 }), 520);
+ let drawn = "";
+ function paint() {
+ const key = `${lift.x.toFixed(2)} ${fl.x.toFixed(2)} ${fr.x.toFixed(2)}`;
+ if (key === drawn) return;
+ drawn = key;
+ const zb = ZB + lift.x, zn = zb - NZ, L = Math.min(fl.x, zn + 5.5), tip = zn - L;
+ // the flame: a teardrop round the axis, straight down from the nozzle and closing to a point; its core inside
+ const tear = (r, l) => hull(Array.from({ length: 9 }, (_, k) => ring(r * Math.cos((k * Math.PI) / 16), zn - (l * k) / 8, 0, 360, 24)).flat());
+ flame.setAttribute("d", poly(tear(fr.x, L)));
+ core.setAttribute("d", L > 9 ? poly(tear(fr.x * 0.42, L * 0.62)) : "");
+ // the exhaust column, dashed from the flame's tip down to the pad, where it meets it in a front arc
+ const a = TRAIL * Math.SQRT1_2;
+ trail.setAttribute("d", tip > 2.5 ? seg(P(-a, a, tip), P(-a, a, 0)) + seg(P(a, -a, tip), P(a, -a, 0)) + open(ring(TRAIL, 0, -45, 135, 16)) : "");
+ nozzle.setAttribute("d", poly(hull(ring(6, zb).concat(ring(7.8, zn)))));
+ // the body: the hull of its profile's rings; one crease where the nose meets the barrel
+ put(body, { sil: poly(hull(PROFILE.flatMap(([r, z]) => ring(r, zb + z)))), crease: open(ring(R - 0.8, zb + CYL, -45, 135, 16)) });
+ win.setAttribute("d", poly(disc(WR, zb)));
+ rim.setAttribute("d", poly(disc(WR - 2, zb)));
+ fins.forEach(({ d, n, els }) => {
+ const face = (h) => fillet(FINP.map(([u, z]) => P(d[0] * u + n[0] * h, d[1] * u + n[1] * h, zb + z)), [0.6, 1.6, 1.2, 0.6], 3);
+ slab(face(1), face(-1)).forEach((s, i) => els[i].setAttribute("d", s));
+ });
+ }
+
+ let shown = "";
+ const B = register(stage, (dt) => {
+ const moving = stepS(lift, dt) | stepS(fl, dt) | stepS(fr, dt);
+ paint();
+ const label = !hover ? "rest" : lift.t < 0.5 ? "on the pad" : `liftoff · ${Math.round(lift.x)} m`;
+ if (label !== shown) { shown = label; read.textContent = label; }
+ return !!moving;
+ });
+ bag.add(B.unregister);
+
+ /** The pointer's height on screen, which never moves, from the pad (0) to the nose at full climb (1), is the thrust. */
+ const y0 = P(0, 0, 0)[1], y1 = P(0, 0, ZB + TOP + RMAX)[1];
+ function aim() {
+ const up = clamp((thr - 0.2) / 0.7, 0, 1), burn = clamp(thr / 0.6, 0, 1);
+ lift.t = hover ? reach * up * up * (3 - 2 * up) : 0;
+ fl.t = hover ? PILOT + (FL - PILOT) * burn : PILOT;
+ fr.t = hover ? FR0 + (FR - FR0) * burn : FR0;
+ win.classList.toggle("hi", !hover);
+ flame.classList.toggle("hi", hover);
+ B.wake();
+ }
+ bag.add(pointer(stage, {
+ move: (p) => { hover = true; thr = clamp((y0 - p[1]) / (y0 - y1), 0, 1); aim(); },
+ leave: () => { hover = false; thr = 0; aim(); },
+ }));
+ bag.add(() => svg.replaceChildren());
+
+ return {
+ set: (v) => { reach = v; aim(); },
+ destroy: bag.dispose,
+ };
+}
+
+hairline({
+ name: "deploy-liftoff",
+ means: "A rocket on its pad: the pointer's height is the thrust, and raised high enough it lifts off on a flame and settles back.",
+ rules: [1, 3, 5, 8],
+ range: [20, 30, 40],
+ tour: [[175, 222], [175, 50], [175, 134], null],
+ mount,
+});
+</script>
+</body>
+</html>
diff --git a/apps/site/public/skill/hairline-firecrawl-reader.html b/apps/site/public/skill/hairline-firecrawl-reader.html
new file mode 100644
index 0000000..814a461
--- /dev/null
+++ b/apps/site/public/skill/hairline-firecrawl-reader.html
@@ -0,0 +1,1072 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Hairline figure</title>
+<link rel="icon" href="data:,">
+<style>
+ :root { color-scheme: light; --ground: #ffffff; --ink: #232327; --muted: #6f6f78; --line: #e0e0e4; }
+ @media (prefers-color-scheme: dark) {
+ :root:not([data-theme="light"]) { color-scheme: dark; --ground: #08090a; --ink: #d0d6e0; --muted: #8a8c95; --line: #29292d; }
+ }
+ :root[data-theme="dark"] { color-scheme: dark; --ground: #08090a; --ink: #d0d6e0; --muted: #8a8c95; --line: #29292d; }
+ :root[data-theme="light"] { color-scheme: light; }
+ * { box-sizing: border-box; }
+ body {
+ margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
+ background: var(--ground); color: var(--ink);
+ font: 13px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased;
+ }
+ main { width: 100%; max-width: 640px; }
+ .plate { position: relative; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
+ .tag, .label, output, button { font: 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.02em; }
+ .tag { position: absolute; top: 12px; z-index: 1; color: var(--muted); pointer-events: none; }
+ #name { left: 14px; }
+ #read { right: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
+ .controls { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 14px; }
+ .label { color: var(--muted); }
+ input[type="range"] {
+ flex: 1 1 96px; min-width: 0; height: 32px; margin: 0; background: transparent; cursor: pointer;
+ -webkit-appearance: none; appearance: none;
+ }
+ input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--muted); }
+ input[type="range"]::-webkit-slider-thumb {
+ -webkit-appearance: none; width: 13px; height: 13px; margin-top: -6px; border-radius: 50%;
+ border: 1px solid var(--ink); background: var(--ground);
+ }
+ input[type="range"]::-moz-range-track { height: 1px; background: var(--muted); }
+ input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--ink); background: var(--ground); }
+ input[type="range"]:focus-visible, button:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 2px; }
+ output { min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; }
+ button {
+ height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px;
+ background: transparent; color: var(--ink); cursor: pointer;
+ }
+ #play[aria-pressed="true"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }
+ #means { margin: 14px 0 0; text-wrap: pretty; }
+ #rules { margin: 6px 0 0; line-height: 1.6; }
+ #error { margin: 12px 0 0; padding-left: 10px; border-left: 1px solid var(--ink); }
+</style>
+</head>
+<body>
+<main>
+ <div class="plate">
+ <span class="tag" id="name"></span>
+ <span class="tag" id="read"></span>
+ <div id="stage"></div>
+ </div>
+ <div class="controls">
+ <label class="label" for="intensity">intensity</label>
+ <input id="intensity" type="range" min="0" max="1" step="0.01" value="0.5">
+ <output id="value" for="intensity"></output>
+ <span class="label">theme</span>
+ <button id="theme" type="button" aria-label="Switch between the light and the dark theme"></button>
+ <span class="label">play</span>
+ <button id="play" type="button" aria-pressed="false">play</button>
+ </div>
+ <p id="means"></p>
+ <p id="rules" class="label"></p>
+ <p id="error" role="alert" hidden></p>
+</main>
+<script id="hl-kernel">
+/* hairline kernel sha256:3a19aa2640ba8c6c306184d05fddfbd4f3323a6ebd9217dd3cbb38e9db74991c */
+/*
+ * HL: everything a figure may call. Read this index; the code under it is the
+ * package's src/core, unchanged, and a figure should not need to read it.
+ *
+ * Every figure is drawn in a 400 × 320 viewBox. World space is x/y on the
+ * ground and z up. Plates are filled with the ground colour and painted back
+ * to front, so a nearer one covers a farther one: append in that order. At
+ * the default camera, Cam(45, 0.5, S), +x runs down to the right and +y down
+ * to the left, so the corner with the largest x and y is nearest the viewer:
+ * append by ascending x + y, from the far corner (smallest x and y) to it.
+ *
+ * Camera
+ * Cam(azDeg, k, S) a camera: azimuth in degrees, k = sin(elevation) (0.5 is the 2:1 view), S = scale
+ * fit(C, points, cx, cy) centres the box of [x, y, z] points on (cx, cy); call it once, before proj
+ * it only centres, it never scales: choose S by trying values, with the most extreme pose in points.
+ * The six figures use S 1.42 to 2.12; the boxes they fit come out 230 to 310 wide and 180 to 245 tall
+ * proj(C) returns P(x, y, z), which gives [sx, sy]
+ * unproj(C, sx, sy, z) the world [x, y] under a screen point, on the plane at height z
+ * facing(C) returns front(sample): whether a ring sample faces the camera
+ * Rounded solids
+ * rrect(u0, v0, u1, v1, r, n) a rounded rectangle, as a ring of samples {u, v, nu, nv}
+ * circ(R, n) a circle, as a ring
+ * rings(x0, y0, x1, y1, r, b) [ring, inner]: a rounded footprint and its crease ring, inset by b
+ * r, the corner radius, is cut to half the shorter side. b, the crease's inset in world units
+ * (0.6 to 2.2 in the figures), must stay under half the shorter side or the crease turns inside out
+ * prism(P, front, ring, inner, z0, z1) {sil, crease}: a solid standing from z0 to z1, as two path strings
+ * ringAt(P, ring, z) the ring's points, projected at height z
+ * run(ring, keep) the one cyclic run of samples that pass keep
+ * hull(points) the convex hull of screen points
+ * extremes(P, ring) [left, right, nearest] samples: where dashed drops fall from
+ * fillet(points, radii, n) rounds every vertex of a closed polygon; returns the new points
+ * radii is an array, one radius per vertex, each cut to half its shorter edge; a single number gives NaN.
+ * n is the steps round each corner, default 4: each vertex becomes n + 1 points
+ * ghost(P, front, ring, z0, depth) a reflection's path {d, y0, y1}; reflect() draws it for you
+ * Paths and numbers
+ * poly(points) a closed path string
+ * open(points) an open polyline string
+ * seg(a, b) one segment between two screen points [sx, sy], as its own subpath; project world points with P first
+ * clamp(v, a, b)
+ * lerp(a, b, t)
+ * rad(deg)
+ * r2(n) two decimals
+ * The continuous clock: one spring per moving number
+ * spring(x, opts) at rest on x; write .t to retarget; opts {k, c, m, eps}, default k 100, c 18, m 1
+ * stepS(sp, dt) advances by dt seconds; returns whether it is still moving
+ * The discrete clock: a 700ms tween on (.32, .72, 0, 1)
+ * tween(v, dur) at rest on v; dur defaults to 700 (ms)
+ * tset(tw, to, now, delay) retargets from where it is, after delay ms: the stagger
+ * the same target again does nothing, so calling it on every pointer move is safe
+ * tval(tw, now) its value at now
+ * tdone(tw, now) whether it has landed
+ * bezier(x1, y1, x2, y2) a CSS cubic-bezier, as a function of progress
+ * EASE_LIFT the lift curve itself
+ * reducedMotion() true when the reader asked for less motion; springs and tweens already land at once
+ * setReducedMotion(on) the loop's business, not a figure's
+ * Drawing
+ * mk(tag, attrs, parent) one svg element: the only way a figure makes a node
+ * solid(parent) {g, sil, cr}: a group holding a silhouette path and a crease path
+ * put(solid, paths) writes prism()'s {sil, crease} into solid()'s {sil, cr}: sil into sil, crease into cr
+ * flatDot(parent, C, r, cls) a dot lying on the ground plane; cls is "dot", "dot m" or "dot off"
+ * place(el, point) moves a dot or a circle to [sx, sy]
+ * reflect(svg, parent, P, front, ring, z0, depth) a fading mirror under a solid
+ * fade(svg, y0, y1, a0) a vertical fade, as a mask; returns the value for a mask attribute
+ * Life
+ * register(stage, tick) joins the one frame loop; tick(dt in seconds, now in ms) returns true to ask for another frame; gives {wake, unregister}
+ * pointer(stage, handlers) {move(point), down(point), leave()}, points in viewBox units; returns its disposer
+ * disposer() {add, on, dispose}: collects tear-down, so destroy is bag.dispose
+ * The bench's business, not a figure's
+ * css(lightDark)
+ * inject(root)
+ * tour(stage, stops, onStop) an unseen pointer that walks the stops, [x, y] in viewBox units or null to leave, and gives way to a real one; onStop(i) on each arrival; returns {stop}
+ * LAP the default stops: a diamond around the centre, then a leave
+ *
+ * Classes, on path, polygon, ellipse and line. They are the whole palette; a
+ * figure sets no colour, width or fill of its own.
+ * (none) filled with the ground colour, medium stroke
+ * sil the silhouette's stroke hi the bright stroke: the only highlight
+ * lo the dim stroke nf no fill fo fill only, no stroke
+ * dash a dashed guide
+ * dot a bright dot dot m a medium dot dot off a dim dot
+ */
+var HL = (() => {
+ var __defProp = Object.defineProperty;
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
+ var __getOwnPropNames = Object.getOwnPropertyNames;
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
+ var __export = (target, all) => {
+ for (var name in all)
+ __defProp(target, name, { get: all[name], enumerable: true });
+ };
+ var __copyProps = (to, from, except, desc) => {
+ if (from && typeof from === "object" || typeof from === "function") {
+ for (let key of __getOwnPropNames(from))
+ if (!__hasOwnProp.call(to, key) && key !== except)
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
+ }
+ return to;
+ };
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
+
+ // packages/hairline/src/core/kernel.ts
+ var kernel_exports = {};
+ __export(kernel_exports, {
+ Cam: () => Cam,
+ EASE_LIFT: () => EASE_LIFT,
+ LAP: () => LAP,
+ bezier: () => bezier,
+ circ: () => circ,
+ clamp: () => clamp,
+ css: () => css,
+ disposer: () => disposer,
+ extremes: () => extremes,
+ facing: () => facing,
+ fade: () => fade,
+ fillet: () => fillet,
+ fit: () => fit,
+ flatDot: () => flatDot,
+ ghost: () => ghost,
+ hull: () => hull,
+ inject: () => inject,
+ lerp: () => lerp,
+ mk: () => mk,
+ open: () => open,
+ place: () => place,
+ pointer: () => pointer,
+ poly: () => poly,
+ prism: () => prism,
+ proj: () => proj,
+ put: () => put,
+ r2: () => r2,
+ rad: () => rad,
+ reducedMotion: () => reducedMotion,
+ reflect: () => reflect,
+ register: () => register,
+ ringAt: () => ringAt,
+ rings: () => rings,
+ rrect: () => rrect,
+ run: () => run,
+ seg: () => seg,
+ setReducedMotion: () => setReducedMotion,
+ solid: () => solid,
+ spring: () => spring,
+ stepS: () => stepS,
+ tdone: () => tdone,
+ tour: () => tour,
+ tset: () => tset,
+ tval: () => tval,
+ tween: () => tween,
+ unproj: () => unproj
+ });
+
+ // packages/hairline/src/core/iso.ts
+ var clamp = (v, a, b) => Math.max(a, Math.min(b, v));
+ var lerp = (a, b, t) => a + (b - a) * t;
+ var rad = (d) => d * Math.PI / 180;
+ var r2 = (n) => Math.round(n * 100) / 100;
+ var poly = (pts) => "M" + pts.map((p) => r2(p[0]) + " " + r2(p[1])).join("L") + "Z";
+ var seg = (a, b) => `M${r2(a[0])} ${r2(a[1])}L${r2(b[0])} ${r2(b[1])}`;
+ var open = (pts) => pts.length < 2 ? "" : "M" + pts.map((p) => r2(p[0]) + " " + r2(p[1])).join("L");
+ var Cam = (azDeg, k, S) => ({ az: rad(azDeg), k, S, ox: 0, oy: 0 });
+ function proj(C) {
+ const c = Math.cos(C.az), s = Math.sin(C.az), zf = Math.sqrt(1 - C.k * C.k);
+ return (x, y, z) => {
+ const X = x * c - y * s, Y = x * s + y * c;
+ return [C.ox + C.S * X, C.oy + C.S * (Y * C.k - z * zf)];
+ };
+ }
+ function unproj(C, sx, sy, z) {
+ const c = Math.cos(C.az), s = Math.sin(C.az), zf = Math.sqrt(1 - C.k * C.k);
+ const X = (sx - C.ox) / C.S, Y = ((sy - C.oy) / C.S + z * zf) / C.k;
+ return [X * c + Y * s, -X * s + Y * c];
+ }
+ function fit(C, pts, cx, cy) {
+ C.ox = 0;
+ C.oy = 0;
+ const P = proj(C);
+ let a = 1e9, b = -1e9, c = 1e9, d = -1e9;
+ for (const p of pts) {
+ const q = P(p[0], p[1], p[2]);
+ a = Math.min(a, q[0]);
+ b = Math.max(b, q[0]);
+ c = Math.min(c, q[1]);
+ d = Math.max(d, q[1]);
+ }
+ C.ox = cx - (a + b) / 2;
+ C.oy = cy - (c + d) / 2;
+ }
+ function rrect(u0, v0, u1, v1, r, n = 4) {
+ r = Math.max(0, Math.min(r, (u1 - u0) / 2, (v1 - v0) / 2));
+ const out = [];
+ for (const [cu, cv, a0] of [[u1 - r, v1 - r, 0], [u0 + r, v1 - r, 90], [u0 + r, v0 + r, 180], [u1 - r, v0 + r, 270]])
+ for (let k = 0; k <= n; k++) {
+ const a = rad(a0 + 90 * k / n), ca = Math.cos(a), sa = Math.sin(a);
+ out.push({ u: cu + r * ca, v: cv + r * sa, nu: ca, nv: sa });
+ }
+ return out;
+ }
+ function circ(R, n = 96) {
+ const out = [];
+ for (let k = 0; k < n; k++) {
+ const a = k / n * Math.PI * 2, ca = Math.cos(a), sa = Math.sin(a);
+ out.push({ u: R * ca, v: R * sa, nu: ca, nv: sa });
+ }
+ return out;
+ }
+ function hull(input) {
+ const pts = input.slice().sort((a, b) => a[0] - b[0] || a[1] - b[1]);
+ const x = (o, a, b) => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
+ const lo = [], up = [];
+ for (const p of pts) {
+ while (lo.length > 1 && x(lo[lo.length - 2], lo[lo.length - 1], p) <= 0) lo.pop();
+ lo.push(p);
+ }
+ for (let i = pts.length - 1; i >= 0; i--) {
+ const p = pts[i];
+ while (up.length > 1 && x(up[up.length - 2], up[up.length - 1], p) <= 0) up.pop();
+ up.push(p);
+ }
+ lo.pop();
+ up.pop();
+ return lo.concat(up);
+ }
+ var ringAt = (P, ring, z) => ring.map((q) => P(q.u, q.v, z));
+ var facing = (C) => {
+ const s = Math.sin(C.az), c = Math.cos(C.az);
+ return (q) => q.nu * s + q.nv * c >= -1e-6;
+ };
+ function run(ring, keep) {
+ const n = ring.length;
+ let s = -1;
+ for (let i = 0; i < n; i++) if (keep(ring[i]) && !keep(ring[(i + n - 1) % n])) {
+ s = i;
+ break;
+ }
+ if (s < 0) return keep(ring[0]) ? ring.slice() : [];
+ const out = [];
+ for (let k = 0; k < n && keep(ring[(s + k) % n]); k++) out.push(ring[(s + k) % n]);
+ return out;
+ }
+ function prism(P, front, ring, inner, z0, z1) {
+ return {
+ sil: poly(hull(ringAt(P, ring, z1).concat(ringAt(P, ring, z0)))),
+ crease: inner ? open(ringAt(P, run(inner, front), z1)) : ""
+ };
+ }
+ var rings = (x0, y0, x1, y1, r, b) => [
+ rrect(x0, y0, x1, y1, r),
+ rrect(x0 + b, y0 + b, x1 - b, y1 - b, Math.max(0.3, r - b))
+ ];
+ function extremes(P, ring) {
+ const pr = ring.map((q) => P(q.u, q.v, 0));
+ let a = 0, b = 0, c = 0;
+ pr.forEach((p, k) => {
+ if (p[0] < pr[a][0]) a = k;
+ if (p[0] > pr[b][0]) b = k;
+ if (p[1] > pr[c][1]) c = k;
+ });
+ return [ring[a], ring[b], ring[c]];
+ }
+ function fillet(pts, rs, n = 4) {
+ const m = pts.length, out = [];
+ for (let i = 0; i < m; i++) {
+ const a = pts[(i + m - 1) % m], p = pts[i], b = pts[(i + 1) % m];
+ const la = Math.hypot(a[0] - p[0], a[1] - p[1]), lb = Math.hypot(b[0] - p[0], b[1] - p[1]);
+ const t = Math.min(rs[i], la / 2, lb / 2);
+ const p1 = [p[0] + (a[0] - p[0]) / la * t, p[1] + (a[1] - p[1]) / la * t];
+ const p2 = [p[0] + (b[0] - p[0]) / lb * t, p[1] + (b[1] - p[1]) / lb * t];
+ for (let k = 0; k <= n; k++) {
+ const s = k / n, w = 1 - s;
+ out.push([w * w * p1[0] + 2 * w * s * p[0] + s * s * p2[0], w * w * p1[1] + 2 * w * s * p[1] + s * s * p2[1]]);
+ }
+ }
+ return out;
+ }
+ function ghost(P, front, ring, z0, depth) {
+ const f = run(ring, front), lowP = ringAt(P, f, z0 - depth);
+ return {
+ d: open(lowP) + [f[0], f[f.length - 1]].map((q) => seg(P(q.u, q.v, z0), P(q.u, q.v, z0 - depth))).join(""),
+ y0: Math.min(...ringAt(P, f, z0).map((p) => p[1])),
+ y1: Math.max(...lowP.map((p) => p[1])) + 2
+ };
+ }
+
+ // packages/hairline/src/core/motion.ts
+ var reduced = false;
+ var setReducedMotion = (on) => {
+ reduced = on;
+ };
+ var reducedMotion = () => reduced;
+ function spring(x, o = {}) {
+ return { x, v: 0, t: x, k: o.k ?? 100, c: o.c ?? 18, m: o.m ?? 1, eps: o.eps ?? 0.01 };
+ }
+ function stepS(sp, dt) {
+ if (reduced) {
+ sp.x = sp.t;
+ sp.v = 0;
+ return false;
+ }
+ const n = Math.max(1, Math.ceil(dt * 240)), h = dt / n;
+ for (let i = 0; i < n; i++) {
+ const a = (-sp.k * (sp.x - sp.t) - sp.c * sp.v) / sp.m;
+ sp.v += a * h;
+ sp.x += sp.v * h;
+ }
+ if (Math.abs(sp.x - sp.t) < sp.eps && Math.abs(sp.v) < sp.eps * 10) {
+ sp.x = sp.t;
+ sp.v = 0;
+ return false;
+ }
+ return true;
+ }
+ function bezier(x1, y1, x2, y2) {
+ const cx = 3 * x1, bx = 3 * (x2 - x1) - cx, ax = 1 - cx - bx;
+ const cy = 3 * y1, by = 3 * (y2 - y1) - cy, ay = 1 - cy - by;
+ const X = (u) => ((ax * u + bx) * u + cx) * u;
+ const Y = (u) => ((ay * u + by) * u + cy) * u;
+ const dX = (u) => (3 * ax * u + 2 * bx) * u + cx;
+ return (t) => {
+ if (t <= 0) return 0;
+ if (t >= 1) return 1;
+ let u = t;
+ for (let i = 0; i < 8; i++) {
+ const e = X(u) - t;
+ if (Math.abs(e) < 1e-5) break;
+ const d = dX(u);
+ if (Math.abs(d) < 1e-6) break;
+ u -= e / d;
+ }
+ if (!(u >= 0 && u <= 1) || Math.abs(X(u) - t) > 1e-4) {
+ let lo = 0, hi = 1;
+ u = t;
+ for (let i = 0; i < 24; i++) {
+ if (X(u) < t) lo = u;
+ else hi = u;
+ u = (lo + hi) / 2;
+ }
+ }
+ return Y(u);
+ };
+ }
+ var EASE_LIFT = bezier(0.32, 0.72, 0, 1);
+ var tween = (v, dur = 700) => ({ from: v, to: v, t0: -1e9, dur });
+ var tval = (tw, now) => {
+ const p = clamp((now - tw.t0) / tw.dur, 0, 1);
+ return tw.from + (tw.to - tw.from) * (reduced ? 1 : EASE_LIFT(p));
+ };
+ var tset = (tw, to, now, delay) => {
+ if (tw.to === to) return;
+ tw.from = tval(tw, now);
+ tw.to = to;
+ tw.t0 = now + delay;
+ };
+ var tdone = (tw, now) => reduced || now >= tw.t0 + tw.dur;
+
+ // packages/hairline/src/core/stage.ts
+ var NS = "http://www.w3.org/2000/svg";
+ function mk(tag, attrs, parent) {
+ const e = document.createElementNS(NS, tag);
+ if (attrs) for (const k in attrs) e.setAttribute(k, String(attrs[k]));
+ if (parent) parent.appendChild(e);
+ return e;
+ }
+ function solid(parent) {
+ const g = mk("g", {}, parent);
+ return { g, sil: mk("path", { class: "sil" }, g), cr: mk("path", { class: "nf lo" }, g) };
+ }
+ var put = (el, s) => {
+ el.sil.setAttribute("d", s.sil);
+ el.cr.setAttribute("d", s.crease);
+ };
+ var flatDot = (parent, C, r, cls) => mk("ellipse", { rx: r2(r * C.S), ry: r2(r * C.S * C.k), class: cls }, parent);
+ var place = (el, q) => {
+ el.setAttribute("cx", String(r2(q[0])));
+ el.setAttribute("cy", String(r2(q[1])));
+ };
+ var fid = 0;
+ function fade(svg, y0, y1, a0 = 0.7) {
+ const id = "hl-fd" + ++fid, defs = mk("defs", {}, svg);
+ const lg = mk("linearGradient", { id: id + "g", gradientUnits: "userSpaceOnUse", x1: 0, y1: r2(y0), x2: 0, y2: r2(y1) }, defs);
+ mk("stop", { offset: 0, "stop-color": "#fff", "stop-opacity": a0 }, lg);
+ mk("stop", { offset: 1, "stop-color": "#fff", "stop-opacity": 0 }, lg);
+ const m = mk("mask", { id, maskUnits: "userSpaceOnUse", x: 0, y: 0, width: 400, height: 320 }, defs);
+ mk("rect", { x: 0, y: 0, width: 400, height: 320, fill: `url(#${id}g)` }, m);
+ return `url(#${id})`;
+ }
+ function reflect(svg, parent, P, front, ring, z0, depth) {
+ const r = ghost(P, front, ring, z0, depth);
+ const gh = mk("g", { class: "ghost", mask: fade(svg, r.y0, r.y1) }, parent);
+ mk("path", { d: r.d }, gh);
+ }
+ var boards = [];
+ var byStage = /* @__PURE__ */ new Map();
+ var raf = 0;
+ var last = 0;
+ var io = null;
+ var rm = null;
+ function frame(now) {
+ const dt = Math.min(0.05, Math.max(0, (now - last) / 1e3));
+ last = now;
+ let any = false;
+ for (const b of boards.slice()) if (b.vis && b.awake) {
+ try {
+ b.awake = !!b.tick(dt, now);
+ } catch (err) {
+ b.awake = false;
+ setTimeout(() => {
+ throw err;
+ });
+ }
+ any = any || b.awake;
+ }
+ raf = any ? requestAnimationFrame(frame) : 0;
+ }
+ function wake(b) {
+ b.awake = true;
+ if (!raf) {
+ last = performance.now();
+ raf = requestAnimationFrame(frame);
+ }
+ }
+ var onMotion = () => {
+ setReducedMotion(!!rm?.matches);
+ boards.forEach(wake);
+ };
+ function start() {
+ if (io) return;
+ io = new IntersectionObserver((es) => {
+ for (const e of es) {
+ const set = byStage.get(e.target);
+ if (!set) continue;
+ for (const b of set) {
+ b.vis = e.isIntersecting;
+ if (b.vis) wake(b);
+ }
+ }
+ }, { rootMargin: "80px" });
+ rm = matchMedia("(prefers-reduced-motion: reduce)");
+ setReducedMotion(rm.matches);
+ rm.addEventListener("change", onMotion);
+ }
+ function stop() {
+ if (raf) cancelAnimationFrame(raf);
+ raf = 0;
+ io?.disconnect();
+ io = null;
+ rm?.removeEventListener("change", onMotion);
+ rm = null;
+ }
+ function register(stage, tick) {
+ start();
+ const b = { stage, tick, vis: false, awake: true };
+ boards.push(b);
+ const peers = byStage.get(stage);
+ if (peers) {
+ for (const p of peers) b.vis = p.vis;
+ peers.add(b);
+ if (b.vis) wake(b);
+ } else {
+ byStage.set(stage, /* @__PURE__ */ new Set([b]));
+ io.observe(stage);
+ }
+ tick(0, performance.now());
+ let gone = false;
+ return {
+ wake: () => {
+ if (!gone) wake(b);
+ },
+ unregister: () => {
+ if (gone) return;
+ gone = true;
+ boards = boards.filter((x) => x !== b);
+ const set = byStage.get(stage);
+ if (set) {
+ set.delete(b);
+ if (!set.size) {
+ byStage.delete(stage);
+ io?.unobserve(stage);
+ }
+ }
+ if (!boards.length) stop();
+ }
+ };
+ }
+ var handlers = /* @__PURE__ */ new WeakMap();
+ var touring = /* @__PURE__ */ new WeakMap();
+ function pointer(stage, on) {
+ handlers.set(stage, on);
+ let tm = 0;
+ const pt = (e) => {
+ const r = stage.getBoundingClientRect();
+ return [(e.clientX - r.left) / r.width * 400, (e.clientY - r.top) / r.height * 320];
+ };
+ const move = (e) => {
+ clearTimeout(tm);
+ touring.get(stage)?.hold();
+ on.move(pt(e), e);
+ };
+ const down = (e) => {
+ clearTimeout(tm);
+ touring.get(stage)?.hold();
+ if (e.pointerType !== "mouse") stage.releasePointerCapture?.(e.pointerId);
+ if (on.down) on.down(pt(e), e);
+ else on.move(pt(e), e);
+ };
+ const leave = (e) => {
+ clearTimeout(tm);
+ tm = window.setTimeout(() => {
+ on.leave(e);
+ touring.get(stage)?.release();
+ }, e.pointerType === "mouse" ? 0 : 1400);
+ };
+ stage.addEventListener("pointermove", move);
+ stage.addEventListener("pointerdown", down);
+ stage.addEventListener("pointerleave", leave);
+ return () => {
+ clearTimeout(tm);
+ if (handlers.get(stage) === on) handlers.delete(stage);
+ stage.removeEventListener("pointermove", move);
+ stage.removeEventListener("pointerdown", down);
+ stage.removeEventListener("pointerleave", leave);
+ };
+ }
+ var LAP = [[128, 150], [200, 118], [272, 150], [200, 206], null];
+ var TRAVEL = 900;
+ var DWELL = 1200;
+ var REST = 1800;
+ var RESUME = 1200;
+ var STAGGER = 450;
+ var GHOST = { pointerType: "ghost" };
+ var started = 0;
+ function entry([x, y]) {
+ const dx = x - 200, dy = y - 160;
+ if (!dx && !dy) return [200, 320];
+ const k = Math.min(dx ? (dx > 0 ? 200 : -200) / dx : Infinity, dy ? (dy > 0 ? 160 : -160) / dy : Infinity);
+ return [200 + dx * k, 160 + dy * k];
+ }
+ function tour(stage, stops, onStop) {
+ let i = 0;
+ let wait = RESUME + STAGGER * (started++ % 4);
+ let t = -1;
+ let at = null;
+ let origin = [200, 320];
+ let hand = false, keys = stage.contains(stage.ownerDocument.activeElement);
+ let gone = false;
+ const leave = () => {
+ at = null;
+ t = -1;
+ handlers.get(stage)?.leave(GHOST);
+ };
+ const tick = (dt) => {
+ if (hand || keys || !stops.length) return false;
+ if (reducedMotion()) {
+ if (at) leave();
+ return false;
+ }
+ if (wait > 0) {
+ wait -= dt * 1e3;
+ return true;
+ }
+ const stop2 = stops[i];
+ if (stop2 === null) {
+ if (at) leave();
+ onStop?.(i);
+ i = (i + 1) % stops.length;
+ wait = REST;
+ return true;
+ }
+ const h = handlers.get(stage);
+ if (!h) return true;
+ if (t < 0) {
+ origin = at ?? entry(stop2);
+ t = 0;
+ }
+ t = Math.min(TRAVEL, t + dt * 1e3);
+ const k = EASE_LIFT(t / TRAVEL);
+ at = [origin[0] + (stop2[0] - origin[0]) * k, origin[1] + (stop2[1] - origin[1]) * k];
+ h.move(at, GHOST);
+ if (t < TRAVEL) return true;
+ onStop?.(i);
+ i = (i + 1) % stops.length;
+ t = -1;
+ wait = DWELL;
+ return true;
+ };
+ const take = () => {
+ at = null;
+ t = -1;
+ };
+ const give = () => {
+ if (hand || keys) return;
+ i = 0;
+ t = -1;
+ wait = RESUME;
+ board.wake();
+ };
+ const me = {
+ hold: () => {
+ hand = true;
+ take();
+ },
+ release: () => {
+ if (!hand) return;
+ hand = false;
+ give();
+ }
+ };
+ const focusIn = () => {
+ keys = true;
+ take();
+ };
+ const focusOut = (e) => {
+ if (keys && !stage.contains(e.relatedTarget)) {
+ keys = false;
+ give();
+ }
+ };
+ stage.addEventListener("focusin", focusIn);
+ stage.addEventListener("focusout", focusOut);
+ touring.set(stage, me);
+ const board = register(stage, tick);
+ return {
+ stop: () => {
+ if (gone) return;
+ gone = true;
+ board.unregister();
+ stage.removeEventListener("focusin", focusIn);
+ stage.removeEventListener("focusout", focusOut);
+ if (touring.get(stage) === me) touring.delete(stage);
+ if (at) leave();
+ }
+ };
+ }
+ function disposer() {
+ let fns = [];
+ return {
+ add: (fn) => {
+ fns.push(fn);
+ },
+ on: (target, type, fn, opts) => {
+ const h = fn;
+ target.addEventListener(type, h, opts);
+ fns.push(() => target.removeEventListener(type, h, opts));
+ },
+ dispose: () => {
+ const run2 = fns;
+ fns = [];
+ for (let i = run2.length - 1; i >= 0; i--) run2[i]();
+ }
+ };
+ }
+
+ // packages/hairline/src/core/styles.ts
+ var LIGHT = { plate: "#ffffff", hi: "#232327", edge: "#a4a4ac", mid: "#c3c3c9", lo: "#e0e0e4" };
+ var DARK = { plate: "#08090a", hi: "#d0d6e0", edge: "#5b5d64", mid: "#3e3e44", lo: "#29292d" };
+ var KEYS = ["plate", "hi", "edge", "mid", "lo"];
+ var vars = (p) => KEYS.map((k) => `--hl-${k}:var(--hairline-${k},${p[k]});`).join("");
+ var EASE = "cubic-bezier(0.5,0,0.1,1)";
+ var SVG = ":where([data-hairline]>svg)";
+ function css(lightDark) {
+ const both = Object.fromEntries(KEYS.map((k) => [k, `light-dark(${LIGHT[k]},${DARK[k]})`]));
+ return [
+ // the box, and the palette: light unless something below says otherwise
+ `:where([data-hairline]){display:block;position:relative;aspect-ratio:5/4;touch-action:pan-y;user-select:none;-webkit-user-select:none;--hl-sw:var(--hairline-stroke,0.9);${vars(LIGHT)}}`,
+ // the page's color-scheme
+ lightDark ? `:where([data-hairline]){${vars(both)}}` : "",
+ // an ancestor that says dark
+ `:where(.dark,[data-theme="dark"]) :where([data-hairline]){${vars(DARK)}}`,
+ // the figure's own theme option
+ `:where([data-hairline][data-hairline-theme="light"]){${vars(LIGHT)}}`,
+ `:where([data-hairline][data-hairline-theme="dark"]){${vars(DARK)}}`,
+ `:where([data-hairline]:focus-visible){outline:1.5px solid var(--hl-hi);outline-offset:2px}`,
+ `${SVG}{position:absolute;inset:0;width:100%;height:100%;display:block}`,
+ // Riffle's live region: read, not seen
+ `:where([data-hairline]>[data-hairline-live]){position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}`,
+ // the drawing: plates are filled with the plate colour and painted back to front
+ `${SVG} :where(path,polygon,ellipse,line){fill:var(--hl-plate);stroke:var(--hl-mid);stroke-width:var(--hl-sw);vector-effect:non-scaling-stroke;stroke-linejoin:round;stroke-linecap:round;transition:stroke 260ms ${EASE}}`,
+ `${SVG} :where(.nf){fill:none}`,
+ `${SVG} :where(.fo){stroke:none}`,
+ `${SVG} :where(.sil){stroke:var(--hl-edge)}`,
+ `${SVG} :where(.hi){stroke:var(--hl-hi)}`,
+ `${SVG} :where(.lo){stroke:var(--hl-lo)}`,
+ `${SVG} :where(.dash){stroke-dasharray:1 3}`,
+ `${SVG} :where(.dot){stroke:none;fill:var(--hl-hi);transition:fill 260ms ${EASE}}`,
+ `${SVG} :where(.dot.m){fill:var(--hl-edge)}`,
+ `${SVG} :where(.dot.off){fill:var(--hl-lo)}`,
+ `${SVG} :where(.ghost path){fill:none;stroke:var(--hl-mid)}`
+ ].join("");
+ }
+ var done = /* @__PURE__ */ new WeakSet();
+ function inject(root) {
+ if (done.has(root)) return;
+ done.add(root);
+ const doc = root.nodeType === 9 ? root : root.ownerDocument;
+ const win = doc.defaultView;
+ const text = css(!!win?.CSS?.supports?.("color", "light-dark(#000,#fff)"));
+ if (win && "adoptedStyleSheets" in root) {
+ try {
+ const sheet = new win.CSSStyleSheet();
+ sheet.replaceSync(text);
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
+ return;
+ } catch {
+ }
+ }
+ const style = doc.createElement("style");
+ style.setAttribute("data-hairline-style", "");
+ style.textContent = text;
+ (root.nodeType === 9 ? doc.head ?? doc.documentElement : root).appendChild(style);
+ }
+ return __toCommonJS(kernel_exports);
+})();
+/* /hairline kernel */
+</script>
+<script id="hl-bench">
+/*
+ * The bench: the page a figure is shown on. It makes the host and the svg the
+ * way the package's mount does, hands them to the figure, and owns everything
+ * around it: the read-out, the slider, the theme, the line under the stage.
+ */
+(() => {
+ const RULES = ["hit", "order", "reach", "accent", "rest", "honesty", "cost", "clock", "radius", "quiet"];
+ const $ = (id) => document.getElementById(id);
+ const root = document.documentElement, params = new URLSearchParams(location.search);
+
+ /* the theme: the system's until the switch is pressed, then the switch's */
+ const dark = () => (root.dataset.theme ? root.dataset.theme === "dark" : matchMedia("(prefers-color-scheme: dark)").matches);
+ const label = () => { $("theme").textContent = dark() ? "dark" : "light"; };
+ $("theme").addEventListener("click", () => { root.dataset.theme = dark() ? "light" : "dark"; label(); });
+ /* ?theme=light or ?theme=dark wins over the system's, as pressing the switch does */
+ if (["light", "dark"].includes(params.get("theme"))) root.dataset.theme = params.get("theme");
+ label();
+
+ /* ?intensity=0 sets the slider before the figure mounts, for a look at either end */
+ const i = (params.get("intensity") || "").trim();
+ if (i && Number.isFinite(Number(i))) $("intensity").value = String(Math.min(1, Math.max(0, Number(i))));
+
+ /* ?w=240 narrows the page, for a look at the size of a thumbnail */
+ const w = Number(params.get("w"));
+ if (w > 0) document.querySelector("main").style.maxWidth = w + "px";
+
+ /* a figure that fails says so under the stage, instead of leaving an empty plate */
+ addEventListener("error", (e) => {
+ $("error").hidden = false;
+ $("error").textContent = String((e.error && e.error.message) || e.message);
+ });
+
+ let mounted = false;
+ window.hairline = (figure) => {
+ if (mounted) throw new Error("hairline: one figure per page.");
+ mounted = true;
+ const stage = $("stage"), slider = $("intensity");
+
+ /* intensity to the figure's own number: two straight lines that meet at 0.5, as in the package */
+ const [lo, mid, hi] = figure.range;
+ const at = (i) => Math.round((i <= 0.5 ? lo + (i / 0.5) * (mid - lo) : mid + ((i - 0.5) / 0.5) * (hi - mid)) * 1000) / 1000;
+
+ HL.inject(document);
+ stage.setAttribute("data-hairline", figure.name);
+ stage.setAttribute("role", "img");
+ stage.setAttribute("aria-label", figure.means);
+ const svg = HL.mk("svg", { viewBox: "0 0 400 320", "aria-hidden": "true" }, stage);
+
+ let text = null;
+ const read = {
+ get textContent() { return text; },
+ set textContent(value) { text = value == null ? "" : String(value); $("read").textContent = text; },
+ };
+
+ document.title = "Hairline · " + figure.name;
+ $("name").textContent = figure.name;
+ $("means").textContent = figure.means;
+ $("rules").textContent = figure.rules.map((n) => String(n).padStart(2, "0") + " " + RULES[n - 1]).join(" · ");
+ const show = () => { $("value").textContent = String(at(Number(slider.value))); };
+ show();
+
+ const handle = figure.mount({ stage, svg, read }, at(Number(slider.value)));
+ if (text === null) read.textContent = "rest";
+ slider.addEventListener("input", () => { show(); handle.set(at(Number(slider.value))); });
+ window.hairline.figure = handle;
+
+ /* play: an unseen pointer walks the figure's tour (or HL.LAP) until a hand arrives; ?play=1 starts it on load */
+ const play = $("play");
+ window.hairline.playing = null;
+ play.addEventListener("click", () => {
+ const was = play.getAttribute("aria-pressed") === "true";
+ if (was) { window.hairline.playing.stop(); window.hairline.playing = null; }
+ else window.hairline.playing = HL.tour(stage, figure.tour || HL.LAP, (i) => { if (window.hairline.onStop) window.hairline.onStop(i); });
+ play.setAttribute("aria-pressed", String(!was));
+ });
+ if (params.get("play") === "1") play.click();
+
+ /* ?at=200,160 holds the pointer at a viewBox point, for a picture of the answer without a mouse */
+ const p = (params.get("at") || "").split(",").map(Number);
+ if (p.length === 2 && p.every(Number.isFinite)) {
+ const r = stage.getBoundingClientRect();
+ stage.dispatchEvent(new PointerEvent("pointermove", {
+ pointerType: "mouse", pointerId: 1, bubbles: true,
+ clientX: r.left + (p[0] / 400) * r.width, clientY: r.top + (p[1] / 320) * r.height,
+ }));
+ }
+ };
+})();
+</script>
+<script type="module" id="hl-figure">
+/**
+ * Firecrawl, reader: a browser page stands on the ground, and the flame floats
+ * in front of it, a reading head over its read-line. The pointer's height over
+ * the page sets how far down it reads. Each part it passes peels off the face
+ * like tape, twists flat and settles in order on a sheet that feeds out at the
+ * page's foot, growing as it fills: the page, read into markdown. The heading
+ * lands as a thick bar, list items behind a dash, the picture as a strip behind
+ * a square. Where a part was, a dashed ghost stays. Going back up puts them back.
+ * At rest the head has read the heading. The slider is how long a part flies, in ms.
+ */
+const {
+ Cam, clamp, facing, fit, open, poly, prism, proj, rad, rings, rrect, seg, solid, put,
+ spring, stepS, tween, tset, tval, tdone, disposer, mk, pointer, register,
+} = HL;
+
+const PW = 96, PH = 130, D = 3, T0 = 16, T1 = 126, REST = 30, FS = 2.2, UF = PW - 22, XF = 8;
+const DX0 = 18, YL = 20, YR = -40, DT = 2, K = 0.5, N = 10, LAG = 0.55;
+/** What the page holds, top to bottom: [kind, u0, u1, t]; kind 0 heading, 1 text, 2 picture, 3 list item. */
+const ITEMS = [[0, 8, 62, 24], [1, 8, 88, 35], [1, 8, 84, 42], [1, 8, 58, 49], [2, 8, 52, 69],
+ [3, 16, 70, 91], [3, 16, 80, 98], [3, 16, 60, 105], [1, 8, 86, 115], [1, 8, 64, 122]];
+/** Each kind: half width on the page, half width on the sheet, where on the sheet it starts, its length there (0: as on the page). */
+const KIND = [[1.8, 2.1, 14, 0], [0, 0, 14, 0], [12, 1.6, 9, 16], [0, 0, 10, 0]];
+
+/** The flame of the mark, read from its own path (a 20 square, y down), cubics sampled finely. */
+const F = (() => {
+ const d = "M13.7605 6.61389C13.138 6.79867 12.6687 7.21667 12.3251 7.67073C12.2513 7.76819 12.0975 7.69495 12.1268 7.57552C12.7848 4.86978 11.9155 2.6209 9.20582 1.51393C9.06836 1.4576 8.92527 1.58097 8.96132 1.72519C10.1939 6.67417 5.00941 6.25673 5.66459 11.8671C5.67585 11.9634 5.56769 12.0293 5.48882 11.973C5.2432 11.7967 4.96885 11.4288 4.78069 11.1702C4.72548 11.0942 4.60605 11.1156 4.5807 11.2063C4.43085 11.7482 4.35986 12.2586 4.35986 12.7656C4.35986 14.7373 5.37333 16.473 6.90734 17.4791C6.99522 17.5366 7.10789 17.4543 7.07804 17.3535C6.99917 17.0887 6.95466 16.8093 6.95128 16.5203C6.95128 16.3429 6.96255 16.1615 6.99015 15.9925C7.05438 15.5677 7.20197 15.1632 7.44985 14.7948C8.29995 13.5188 10.0041 12.2862 9.73199 10.6125C9.71453 10.5066 9.83959 10.4368 9.91846 10.5094C11.119 11.6063 11.3567 13.0817 11.1595 14.405C11.1426 14.5199 11.2868 14.5813 11.3595 14.4912C11.5432 14.2613 11.7674 14.0596 12.0113 13.9081C12.0722 13.8703 12.1533 13.8991 12.1764 13.9667C12.3121 14.3616 12.5138 14.7323 12.7042 15.1029C12.9318 15.5485 13.0529 16.0573 13.0338 16.5958C13.0242 16.8578 12.9808 17.1113 12.9082 17.3524C12.8772 17.4543 12.9887 17.5394 13.0783 17.4808C14.6134 16.4747 15.6275 14.739 15.6275 12.7662C15.6275 12.0806 15.5075 11.4085 15.2804 10.7787C14.8044 9.45766 13.5966 8.46561 13.9019 6.74403C13.9166 6.66178 13.8405 6.59023 13.7605 6.61389Z";
+ const tok = d.match(/[A-Za-z]|-?[\d.]+/g), out = [], num = () => parseFloat(tok[i++]);
+ let i = 0, cmd = "", x = 0, y = 0;
+ while (i < tok.length && tok[i] !== "Z") {
+ if (/[A-Za-z]/.test(tok[i])) cmd = tok[i++];
+ if (cmd === "C") {
+ const [x1, y1, x2, y2, x3, y3] = Array.from({ length: 6 }, num), b = (a, b, c, e, t) => (1 - t) ** 3 * a + 3 * (1 - t) ** 2 * t * b + 3 * (1 - t) * t * t * c + t ** 3 * e;
+ for (let k = 1; k <= 12; k++) out.push([b(x, x1, x2, x3, k / 12), b(y, y1, y2, y3, k / 12)]);
+ [x, y] = [x3, y3];
+ } else { x = num(); y = num(); out.push([x, y]); }
+ }
+ // in its own plane: a across to the right, b down, its foot at b = 8
+ return out.slice(0, -1).map(([px, py]) => [(px - 10) * FS, (py - 9.5) * FS]);
+})();
+
+/**
+ * A thin slab from two outlines of the same points on screen, its front and its back: the back's outline,
+ * the walls that face you (those whose outward edge points the way the back is shifted), their turning edges, the front.
+ */
+function slab(front, back) {
+ const n = front.length, o = [back[0][0] - front[0][0], back[0][1] - front[0][1]];
+ const area = front.reduce((a, p, i) => { const q = front[(i + 1) % n]; return a + p[0] * q[1] - q[0] * p[1]; }, 0);
+ const vis = front.map((p, i) => { const q = front[(i + 1) % n], ex = q[0] - p[0], ey = q[1] - p[1]; return (area > 0 ? ey * o[0] - ex * o[1] : ex * o[1] - ey * o[0]) > 0; });
+ let walls = "", turns = "";
+ front.forEach((p, i) => {
+ const j = (i + 1) % n;
+ if (vis[i]) walls += poly([p, front[j], back[j], back[i]]);
+ if (vis[i] !== vis[(i + n - 1) % n]) turns += seg(p, back[i]);
+ });
+ return [poly(back), walls, turns, poly(front)];
+}
+
+function mount({ stage, svg, read }, value) {
+ const bag = disposer();
+ let fly = value;
+
+ const C = Cam(45, 0.5, 1.6);
+ fit(C, [[0, PW / 2, 0], [0, -PW / 2, 0], [-D, PW / 2, PH], [XF, PW / 2 - UF, PH + 24], [100, YL, 0], [100, YR, 0], [DX0, YR, 0]], 200, 162);
+ const P = proj(C), front = facing(C);
+ /** A point on the page's face, or a plane x in front of or behind it, from the page's own (u right, t down). */
+ const W = (u, t, x = 0) => P(x, PW / 2 - u, PH - t);
+ const ring = (q, x = 0) => q.map((p) => W(p.u, p.v, x));
+
+ const g = mk("g", {}, svg);
+ /** Draws a slab's four strings into four paths under parent; returns them so a moving one can be redrawn. */
+ const draw = (parent, s, cls = "sil") => {
+ const els = [mk("path", { class: "sil" }, parent), mk("path", { class: "fo" }, parent), mk("path", { class: "sil nf" }, parent), mk("path", { class: cls }, parent)];
+ if (s) els.forEach((el, i) => el.setAttribute("d", s[i]));
+ return els;
+ };
+
+ // the page: a thin standing sheet, its top bar (three dots, the address pill), and the picture's drawing
+ const edge = rrect(0, 0, PW, PH, 2, 3);
+ draw(g, slab(ring(edge), ring(edge, -D)));
+ const dot = (u, t, r) => poly(Array.from({ length: 12 }, (_, k) => W(u + r * Math.cos(rad(k * 30)), t + r * Math.sin(rad(k * 30)))));
+ mk("path", { class: "nf lo", d: [7, 12, 17].map((u) => dot(u, 7, 1.3)).join("") + poly(ring(rrect(24, 4.5, 88, 9.5, 2.5))) + seg(W(0, 14), W(PW, 14)) }, g);
+ const art = mk("path", { class: "nf lo", d: open([[11, 78], [21, 67], [27, 72], [36, 62], [49, 78]].map(([u, t]) => W(u, t))) + dot(18, 63, 2.4) }, g);
+
+ // where each part was: a dashed ghost on the face, under the part itself
+ const ghosts = mk("path", { class: "nf lo dash" }, g);
+ // the read-line across the face, a tick standing at each edge
+ const line = mk("path", { class: "sil" }, g);
+
+ // the sheet at the page's foot, which feeds out as parts land on it
+ const sheet = solid(g), rowX = ITEMS.map((_, k) => DX0 + 8 + k * 7 + (k ? 3 : 0)), grow = spring(rowX[0] + 7, { k: 40, c: 13 });
+ let sheetAt = NaN;
+
+ // each part: on the page it lies on the face; peeling, its far end leads, twisting flat; landed it lies on the sheet
+ const strips = mk("g", {}, g);
+ const items = ITEMS.map(([kind, u0, u1, t], k) => {
+ const [r0, r1, y0, l1] = KIND[kind];
+ return { kind, u0, u1, t, r0, r1, x1: rowX[k], y1: YL - y0, len: l1 || (u1 - u0) * K,
+ el: mk("path", { class: kind === 0 ? "sil" : kind === 2 ? "nf lo" : "lo" }, strips), tw: tween(k === 0 ? 1 : 0, fly), drawn: NaN, read: k === 0 };
+ });
+ ghosts.setAttribute("d", items.map((it) => it.r0
+ ? poly([[it.u0, it.t - it.r0], [it.u1, it.t - it.r0], [it.u1, it.t + it.r0], [it.u0, it.t + it.r0]].map(([u, t]) => W(u, t, 0.2)))
+ : seg(W(it.u0, it.t, 0.2), W(it.u1, it.t, 0.2))).join(""));
+
+ /** A point of a part at s along it (0 its near end, 1 its far end), q of the way from the page to the sheet, lifted on the way. */
+ function at3(it, s, q, dp = 0, ds = 0) {
+ const p = [0.3, PW / 2 - it.u0 - (it.u1 - it.u0) * s + dp, PH - it.t], w = [it.x1, it.y1 - it.len * s + ds, DT + 0.2];
+ return p.map((v, i) => v + (w[i] - v) * q + (i === 2 ? 14 * Math.sin(Math.PI * q) : 0));
+ }
+ /** Across the part at q: upright on the page, lying on the sheet. */
+ const across = (q, r) => [r * Math.sin((Math.PI / 2) * q), 0, r * Math.cos((Math.PI / 2) * q)];
+ const off = (c, h, m = 1) => P(...c.map((v, i) => v + h[i] * m));
+ function paintItem(it, e) {
+ if (it.drawn === e) return;
+ it.drawn = e;
+ const side = [], back = [];
+ for (let i = 0; i <= N; i++) {
+ const s = i / N, q = clamp(e * (1 + LAG) - LAG * (1 - s), 0, 1), c = at3(it, s, q);
+ const h = across(q, it.r0 + (it.r1 - it.r0) * q + 1.3 * Math.sin(Math.PI * q));
+ side.push(off(c, h)); back.unshift(off(c, h, -1));
+ }
+ let d = poly([...side, ...back]);
+ const q = clamp(e * (1 + LAG) - LAG, 0, 1);
+ if (it.kind === 3 || (it.kind === 2 && q > 0)) {
+ // its mark before it: a list item's bullet that becomes a dash; the picture's square, only once it leaves
+ const c = at3(it, 0, q, 4, 4.5), h = across(q, 1);
+ const [ml, mw] = it.kind === 3 ? [0.9 + 0.7 * q, 0.9 - 0.3 * q] : [2.2 * q, 2.2 * q];
+ d += poly([[1, 1], [-1, 1], [-1, -1], [1, -1]].map(([a, b]) => P(c[0] + h[0] * mw * b, c[1] - ml * a, c[2] + h[2] * mw * b)));
+ }
+ it.el.setAttribute("d", d);
+ }
+
+ // the head: the read-line at t down the page, the flame floating in front over its right end
+ const flame = draw(g, null, "sil hi");
+ const pos = spring(REST, { k: 30, c: 11 });
+ let hover = false, drawnT = NaN, count = -1;
+ function paintHead(t) {
+ if (t === drawnT) return;
+ drawnT = t;
+ line.setAttribute("d", seg(W(-3, t, 0.4), W(PW + 3, t, 0.4)) + seg(W(-3, t - 3, 0.4), W(-3, t + 3, 0.4)) + seg(W(PW + 3, t - 3, 0.4), W(PW + 3, t + 3, 0.4)));
+ const z = PH - t + 4 + 8 * FS, y = PW / 2 - UF, r = Math.SQRT1_2;
+ const pts = (n) => F.map(([a, b]) => P(XF + (a + n) * r, y - (a - n) * r, z - b));
+ slab(pts(1.5), pts(-1.5)).forEach((d, i) => flame[i].setAttribute("d", d));
+ }
+
+ const B = register(stage, (dt, now) => {
+ let moving = stepS(pos, dt);
+ paintHead(pos.x);
+ let n = 0;
+ items.forEach((it) => {
+ const r = pos.x >= it.t - 2;
+ if (r !== it.read) { it.read = r; it.tw.dur = fly; tset(it.tw, r ? 1 : 0, now, 0); }
+ if (it.read) n++;
+ paintItem(it, tval(it.tw, now));
+ if (!tdone(it.tw, now)) moving = true;
+ });
+ art.classList.toggle("dash", items[4].read);
+ grow.t = rowX[Math.max(0, n - 1)] + 7;
+ if (stepS(grow, dt)) moving = true;
+ if (grow.x !== sheetAt) { sheetAt = grow.x; put(sheet, prism(P, front, ...rings(DX0, YR, sheetAt, YL, 4, 2), 0, DT)); }
+ if (n !== count) { count = n; read.textContent = hover ? `${n} lines` : "rest"; }
+ return moving;
+ });
+ bag.add(B.unregister);
+
+ /** The pointer, put on the page's plane (x 0), which never moves: its height there is how far down to read. */
+ const zf = Math.sqrt(1 - C.k * C.k), cs = Math.cos(C.az), sn = Math.sin(C.az);
+ function aim(p) {
+ hover = p !== null;
+ if (hover) { const y = -(p[0] - C.ox) / (C.S * sn), z = (y * cs * C.k - (p[1] - C.oy) / C.S) / zf; pos.t = clamp(PH - z, T0, T1); }
+ else pos.t = REST;
+ flame[3].classList.toggle("hi", !hover);
+ line.classList.toggle("hi", hover);
+ count = -1;
+ B.wake();
+ }
+ bag.add(pointer(stage, { move: (p) => aim(p), leave: () => aim(null) }));
+ bag.add(() => svg.replaceChildren());
+
+ return {
+ set: (v) => { fly = v; },
+ destroy: bag.dispose,
+ };
+}
+
+hairline({
+ name: "firecrawl-reader",
+ means: "The flame reads a page: point down the page, and every part it passes peels off and settles, in order, on a sheet of markdown.",
+ rules: [1, 5, 8, 10],
+ range: [400, 700, 1000],
+ tour: [[200, 110], [200, 170], [200, 230], null],
+ mount,
+});
+</script>
+</body>
+</html>
diff --git a/apps/site/public/skill/hairline-linear-cycle.html b/apps/site/public/skill/hairline-linear-cycle.html
new file mode 100644
index 0000000..8bc8767
--- /dev/null
+++ b/apps/site/public/skill/hairline-linear-cycle.html
@@ -0,0 +1,1037 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Hairline figure</title>
+<link rel="icon" href="data:,">
+<style>
+ :root { color-scheme: light; --ground: #ffffff; --ink: #232327; --muted: #6f6f78; --line: #e0e0e4; }
+ @media (prefers-color-scheme: dark) {
+ :root:not([data-theme="light"]) { color-scheme: dark; --ground: #08090a; --ink: #d0d6e0; --muted: #8a8c95; --line: #29292d; }
+ }
+ :root[data-theme="dark"] { color-scheme: dark; --ground: #08090a; --ink: #d0d6e0; --muted: #8a8c95; --line: #29292d; }
+ :root[data-theme="light"] { color-scheme: light; }
+ * { box-sizing: border-box; }
+ body {
+ margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
+ background: var(--ground); color: var(--ink);
+ font: 13px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased;
+ }
+ main { width: 100%; max-width: 640px; }
+ .plate { position: relative; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
+ .tag, .label, output, button { font: 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.02em; }
+ .tag { position: absolute; top: 12px; z-index: 1; color: var(--muted); pointer-events: none; }
+ #name { left: 14px; }
+ #read { right: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
+ .controls { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 14px; }
+ .label { color: var(--muted); }
+ input[type="range"] {
+ flex: 1 1 96px; min-width: 0; height: 32px; margin: 0; background: transparent; cursor: pointer;
+ -webkit-appearance: none; appearance: none;
+ }
+ input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--muted); }
+ input[type="range"]::-webkit-slider-thumb {
+ -webkit-appearance: none; width: 13px; height: 13px; margin-top: -6px; border-radius: 50%;
+ border: 1px solid var(--ink); background: var(--ground);
+ }
+ input[type="range"]::-moz-range-track { height: 1px; background: var(--muted); }
+ input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--ink); background: var(--ground); }
+ input[type="range"]:focus-visible, button:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 2px; }
+ output { min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; }
+ button {
+ height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px;
+ background: transparent; color: var(--ink); cursor: pointer;
+ }
+ #play[aria-pressed="true"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }
+ #means { margin: 14px 0 0; text-wrap: pretty; }
+ #rules { margin: 6px 0 0; line-height: 1.6; }
+ #error { margin: 12px 0 0; padding-left: 10px; border-left: 1px solid var(--ink); }
+</style>
+</head>
+<body>
+<main>
+ <div class="plate">
+ <span class="tag" id="name"></span>
+ <span class="tag" id="read"></span>
+ <div id="stage"></div>
+ </div>
+ <div class="controls">
+ <label class="label" for="intensity">intensity</label>
+ <input id="intensity" type="range" min="0" max="1" step="0.01" value="0.5">
+ <output id="value" for="intensity"></output>
+ <span class="label">theme</span>
+ <button id="theme" type="button" aria-label="Switch between the light and the dark theme"></button>
+ <span class="label">play</span>
+ <button id="play" type="button" aria-pressed="false">play</button>
+ </div>
+ <p id="means"></p>
+ <p id="rules" class="label"></p>
+ <p id="error" role="alert" hidden></p>
+</main>
+<script id="hl-kernel">
+/* hairline kernel sha256:3a19aa2640ba8c6c306184d05fddfbd4f3323a6ebd9217dd3cbb38e9db74991c */
+/*
+ * HL: everything a figure may call. Read this index; the code under it is the
+ * package's src/core, unchanged, and a figure should not need to read it.
+ *
+ * Every figure is drawn in a 400 × 320 viewBox. World space is x/y on the
+ * ground and z up. Plates are filled with the ground colour and painted back
+ * to front, so a nearer one covers a farther one: append in that order. At
+ * the default camera, Cam(45, 0.5, S), +x runs down to the right and +y down
+ * to the left, so the corner with the largest x and y is nearest the viewer:
+ * append by ascending x + y, from the far corner (smallest x and y) to it.
+ *
+ * Camera
+ * Cam(azDeg, k, S) a camera: azimuth in degrees, k = sin(elevation) (0.5 is the 2:1 view), S = scale
+ * fit(C, points, cx, cy) centres the box of [x, y, z] points on (cx, cy); call it once, before proj
+ * it only centres, it never scales: choose S by trying values, with the most extreme pose in points.
+ * The six figures use S 1.42 to 2.12; the boxes they fit come out 230 to 310 wide and 180 to 245 tall
+ * proj(C) returns P(x, y, z), which gives [sx, sy]
+ * unproj(C, sx, sy, z) the world [x, y] under a screen point, on the plane at height z
+ * facing(C) returns front(sample): whether a ring sample faces the camera
+ * Rounded solids
+ * rrect(u0, v0, u1, v1, r, n) a rounded rectangle, as a ring of samples {u, v, nu, nv}
+ * circ(R, n) a circle, as a ring
+ * rings(x0, y0, x1, y1, r, b) [ring, inner]: a rounded footprint and its crease ring, inset by b
+ * r, the corner radius, is cut to half the shorter side. b, the crease's inset in world units
+ * (0.6 to 2.2 in the figures), must stay under half the shorter side or the crease turns inside out
+ * prism(P, front, ring, inner, z0, z1) {sil, crease}: a solid standing from z0 to z1, as two path strings
+ * ringAt(P, ring, z) the ring's points, projected at height z
+ * run(ring, keep) the one cyclic run of samples that pass keep
+ * hull(points) the convex hull of screen points
+ * extremes(P, ring) [left, right, nearest] samples: where dashed drops fall from
+ * fillet(points, radii, n) rounds every vertex of a closed polygon; returns the new points
+ * radii is an array, one radius per vertex, each cut to half its shorter edge; a single number gives NaN.
+ * n is the steps round each corner, default 4: each vertex becomes n + 1 points
+ * ghost(P, front, ring, z0, depth) a reflection's path {d, y0, y1}; reflect() draws it for you
+ * Paths and numbers
+ * poly(points) a closed path string
+ * open(points) an open polyline string
+ * seg(a, b) one segment between two screen points [sx, sy], as its own subpath; project world points with P first
+ * clamp(v, a, b)
+ * lerp(a, b, t)
+ * rad(deg)
+ * r2(n) two decimals
+ * The continuous clock: one spring per moving number
+ * spring(x, opts) at rest on x; write .t to retarget; opts {k, c, m, eps}, default k 100, c 18, m 1
+ * stepS(sp, dt) advances by dt seconds; returns whether it is still moving
+ * The discrete clock: a 700ms tween on (.32, .72, 0, 1)
+ * tween(v, dur) at rest on v; dur defaults to 700 (ms)
+ * tset(tw, to, now, delay) retargets from where it is, after delay ms: the stagger
+ * the same target again does nothing, so calling it on every pointer move is safe
+ * tval(tw, now) its value at now
+ * tdone(tw, now) whether it has landed
+ * bezier(x1, y1, x2, y2) a CSS cubic-bezier, as a function of progress
+ * EASE_LIFT the lift curve itself
+ * reducedMotion() true when the reader asked for less motion; springs and tweens already land at once
+ * setReducedMotion(on) the loop's business, not a figure's
+ * Drawing
+ * mk(tag, attrs, parent) one svg element: the only way a figure makes a node
+ * solid(parent) {g, sil, cr}: a group holding a silhouette path and a crease path
+ * put(solid, paths) writes prism()'s {sil, crease} into solid()'s {sil, cr}: sil into sil, crease into cr
+ * flatDot(parent, C, r, cls) a dot lying on the ground plane; cls is "dot", "dot m" or "dot off"
+ * place(el, point) moves a dot or a circle to [sx, sy]
+ * reflect(svg, parent, P, front, ring, z0, depth) a fading mirror under a solid
+ * fade(svg, y0, y1, a0) a vertical fade, as a mask; returns the value for a mask attribute
+ * Life
+ * register(stage, tick) joins the one frame loop; tick(dt in seconds, now in ms) returns true to ask for another frame; gives {wake, unregister}
+ * pointer(stage, handlers) {move(point), down(point), leave()}, points in viewBox units; returns its disposer
+ * disposer() {add, on, dispose}: collects tear-down, so destroy is bag.dispose
+ * The bench's business, not a figure's
+ * css(lightDark)
+ * inject(root)
+ * tour(stage, stops, onStop) an unseen pointer that walks the stops, [x, y] in viewBox units or null to leave, and gives way to a real one; onStop(i) on each arrival; returns {stop}
+ * LAP the default stops: a diamond around the centre, then a leave
+ *
+ * Classes, on path, polygon, ellipse and line. They are the whole palette; a
+ * figure sets no colour, width or fill of its own.
+ * (none) filled with the ground colour, medium stroke
+ * sil the silhouette's stroke hi the bright stroke: the only highlight
+ * lo the dim stroke nf no fill fo fill only, no stroke
+ * dash a dashed guide
+ * dot a bright dot dot m a medium dot dot off a dim dot
+ */
+var HL = (() => {
+ var __defProp = Object.defineProperty;
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
+ var __getOwnPropNames = Object.getOwnPropertyNames;
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
+ var __export = (target, all) => {
+ for (var name in all)
+ __defProp(target, name, { get: all[name], enumerable: true });
+ };
+ var __copyProps = (to, from, except, desc) => {
+ if (from && typeof from === "object" || typeof from === "function") {
+ for (let key of __getOwnPropNames(from))
+ if (!__hasOwnProp.call(to, key) && key !== except)
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
+ }
+ return to;
+ };
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
+
+ // packages/hairline/src/core/kernel.ts
+ var kernel_exports = {};
+ __export(kernel_exports, {
+ Cam: () => Cam,
+ EASE_LIFT: () => EASE_LIFT,
+ LAP: () => LAP,
+ bezier: () => bezier,
+ circ: () => circ,
+ clamp: () => clamp,
+ css: () => css,
+ disposer: () => disposer,
+ extremes: () => extremes,
+ facing: () => facing,
+ fade: () => fade,
+ fillet: () => fillet,
+ fit: () => fit,
+ flatDot: () => flatDot,
+ ghost: () => ghost,
+ hull: () => hull,
+ inject: () => inject,
+ lerp: () => lerp,
+ mk: () => mk,
+ open: () => open,
+ place: () => place,
+ pointer: () => pointer,
+ poly: () => poly,
+ prism: () => prism,
+ proj: () => proj,
+ put: () => put,
+ r2: () => r2,
+ rad: () => rad,
+ reducedMotion: () => reducedMotion,
+ reflect: () => reflect,
+ register: () => register,
+ ringAt: () => ringAt,
+ rings: () => rings,
+ rrect: () => rrect,
+ run: () => run,
+ seg: () => seg,
+ setReducedMotion: () => setReducedMotion,
+ solid: () => solid,
+ spring: () => spring,
+ stepS: () => stepS,
+ tdone: () => tdone,
+ tour: () => tour,
+ tset: () => tset,
+ tval: () => tval,
+ tween: () => tween,
+ unproj: () => unproj
+ });
+
+ // packages/hairline/src/core/iso.ts
+ var clamp = (v, a, b) => Math.max(a, Math.min(b, v));
+ var lerp = (a, b, t) => a + (b - a) * t;
+ var rad = (d) => d * Math.PI / 180;
+ var r2 = (n) => Math.round(n * 100) / 100;
+ var poly = (pts) => "M" + pts.map((p) => r2(p[0]) + " " + r2(p[1])).join("L") + "Z";
+ var seg = (a, b) => `M${r2(a[0])} ${r2(a[1])}L${r2(b[0])} ${r2(b[1])}`;
+ var open = (pts) => pts.length < 2 ? "" : "M" + pts.map((p) => r2(p[0]) + " " + r2(p[1])).join("L");
+ var Cam = (azDeg, k, S) => ({ az: rad(azDeg), k, S, ox: 0, oy: 0 });
+ function proj(C) {
+ const c = Math.cos(C.az), s = Math.sin(C.az), zf = Math.sqrt(1 - C.k * C.k);
+ return (x, y, z) => {
+ const X = x * c - y * s, Y = x * s + y * c;
+ return [C.ox + C.S * X, C.oy + C.S * (Y * C.k - z * zf)];
+ };
+ }
+ function unproj(C, sx, sy, z) {
+ const c = Math.cos(C.az), s = Math.sin(C.az), zf = Math.sqrt(1 - C.k * C.k);
+ const X = (sx - C.ox) / C.S, Y = ((sy - C.oy) / C.S + z * zf) / C.k;
+ return [X * c + Y * s, -X * s + Y * c];
+ }
+ function fit(C, pts, cx, cy) {
+ C.ox = 0;
+ C.oy = 0;
+ const P = proj(C);
+ let a = 1e9, b = -1e9, c = 1e9, d = -1e9;
+ for (const p of pts) {
+ const q = P(p[0], p[1], p[2]);
+ a = Math.min(a, q[0]);
+ b = Math.max(b, q[0]);
+ c = Math.min(c, q[1]);
+ d = Math.max(d, q[1]);
+ }
+ C.ox = cx - (a + b) / 2;
+ C.oy = cy - (c + d) / 2;
+ }
+ function rrect(u0, v0, u1, v1, r, n = 4) {
+ r = Math.max(0, Math.min(r, (u1 - u0) / 2, (v1 - v0) / 2));
+ const out = [];
+ for (const [cu, cv, a0] of [[u1 - r, v1 - r, 0], [u0 + r, v1 - r, 90], [u0 + r, v0 + r, 180], [u1 - r, v0 + r, 270]])
+ for (let k = 0; k <= n; k++) {
+ const a = rad(a0 + 90 * k / n), ca = Math.cos(a), sa = Math.sin(a);
+ out.push({ u: cu + r * ca, v: cv + r * sa, nu: ca, nv: sa });
+ }
+ return out;
+ }
+ function circ(R, n = 96) {
+ const out = [];
+ for (let k = 0; k < n; k++) {
+ const a = k / n * Math.PI * 2, ca = Math.cos(a), sa = Math.sin(a);
+ out.push({ u: R * ca, v: R * sa, nu: ca, nv: sa });
+ }
+ return out;
+ }
+ function hull(input) {
+ const pts = input.slice().sort((a, b) => a[0] - b[0] || a[1] - b[1]);
+ const x = (o, a, b) => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
+ const lo = [], up = [];
+ for (const p of pts) {
+ while (lo.length > 1 && x(lo[lo.length - 2], lo[lo.length - 1], p) <= 0) lo.pop();
+ lo.push(p);
+ }
+ for (let i = pts.length - 1; i >= 0; i--) {
+ const p = pts[i];
+ while (up.length > 1 && x(up[up.length - 2], up[up.length - 1], p) <= 0) up.pop();
+ up.push(p);
+ }
+ lo.pop();
+ up.pop();
+ return lo.concat(up);
+ }
+ var ringAt = (P, ring, z) => ring.map((q) => P(q.u, q.v, z));
+ var facing = (C) => {
+ const s = Math.sin(C.az), c = Math.cos(C.az);
+ return (q) => q.nu * s + q.nv * c >= -1e-6;
+ };
+ function run(ring, keep) {
+ const n = ring.length;
+ let s = -1;
+ for (let i = 0; i < n; i++) if (keep(ring[i]) && !keep(ring[(i + n - 1) % n])) {
+ s = i;
+ break;
+ }
+ if (s < 0) return keep(ring[0]) ? ring.slice() : [];
+ const out = [];
+ for (let k = 0; k < n && keep(ring[(s + k) % n]); k++) out.push(ring[(s + k) % n]);
+ return out;
+ }
+ function prism(P, front, ring, inner, z0, z1) {
+ return {
+ sil: poly(hull(ringAt(P, ring, z1).concat(ringAt(P, ring, z0)))),
+ crease: inner ? open(ringAt(P, run(inner, front), z1)) : ""
+ };
+ }
+ var rings = (x0, y0, x1, y1, r, b) => [
+ rrect(x0, y0, x1, y1, r),
+ rrect(x0 + b, y0 + b, x1 - b, y1 - b, Math.max(0.3, r - b))
+ ];
+ function extremes(P, ring) {
+ const pr = ring.map((q) => P(q.u, q.v, 0));
+ let a = 0, b = 0, c = 0;
+ pr.forEach((p, k) => {
+ if (p[0] < pr[a][0]) a = k;
+ if (p[0] > pr[b][0]) b = k;
+ if (p[1] > pr[c][1]) c = k;
+ });
+ return [ring[a], ring[b], ring[c]];
+ }
+ function fillet(pts, rs, n = 4) {
+ const m = pts.length, out = [];
+ for (let i = 0; i < m; i++) {
+ const a = pts[(i + m - 1) % m], p = pts[i], b = pts[(i + 1) % m];
+ const la = Math.hypot(a[0] - p[0], a[1] - p[1]), lb = Math.hypot(b[0] - p[0], b[1] - p[1]);
+ const t = Math.min(rs[i], la / 2, lb / 2);
+ const p1 = [p[0] + (a[0] - p[0]) / la * t, p[1] + (a[1] - p[1]) / la * t];
+ const p2 = [p[0] + (b[0] - p[0]) / lb * t, p[1] + (b[1] - p[1]) / lb * t];
+ for (let k = 0; k <= n; k++) {
+ const s = k / n, w = 1 - s;
+ out.push([w * w * p1[0] + 2 * w * s * p[0] + s * s * p2[0], w * w * p1[1] + 2 * w * s * p[1] + s * s * p2[1]]);
+ }
+ }
+ return out;
+ }
+ function ghost(P, front, ring, z0, depth) {
+ const f = run(ring, front), lowP = ringAt(P, f, z0 - depth);
+ return {
+ d: open(lowP) + [f[0], f[f.length - 1]].map((q) => seg(P(q.u, q.v, z0), P(q.u, q.v, z0 - depth))).join(""),
+ y0: Math.min(...ringAt(P, f, z0).map((p) => p[1])),
+ y1: Math.max(...lowP.map((p) => p[1])) + 2
+ };
+ }
+
+ // packages/hairline/src/core/motion.ts
+ var reduced = false;
+ var setReducedMotion = (on) => {
+ reduced = on;
+ };
+ var reducedMotion = () => reduced;
+ function spring(x, o = {}) {
+ return { x, v: 0, t: x, k: o.k ?? 100, c: o.c ?? 18, m: o.m ?? 1, eps: o.eps ?? 0.01 };
+ }
+ function stepS(sp, dt) {
+ if (reduced) {
+ sp.x = sp.t;
+ sp.v = 0;
+ return false;
+ }
+ const n = Math.max(1, Math.ceil(dt * 240)), h = dt / n;
+ for (let i = 0; i < n; i++) {
+ const a = (-sp.k * (sp.x - sp.t) - sp.c * sp.v) / sp.m;
+ sp.v += a * h;
+ sp.x += sp.v * h;
+ }
+ if (Math.abs(sp.x - sp.t) < sp.eps && Math.abs(sp.v) < sp.eps * 10) {
+ sp.x = sp.t;
+ sp.v = 0;
+ return false;
+ }
+ return true;
+ }
+ function bezier(x1, y1, x2, y2) {
+ const cx = 3 * x1, bx = 3 * (x2 - x1) - cx, ax = 1 - cx - bx;
+ const cy = 3 * y1, by = 3 * (y2 - y1) - cy, ay = 1 - cy - by;
+ const X = (u) => ((ax * u + bx) * u + cx) * u;
+ const Y = (u) => ((ay * u + by) * u + cy) * u;
+ const dX = (u) => (3 * ax * u + 2 * bx) * u + cx;
+ return (t) => {
+ if (t <= 0) return 0;
+ if (t >= 1) return 1;
+ let u = t;
+ for (let i = 0; i < 8; i++) {
+ const e = X(u) - t;
+ if (Math.abs(e) < 1e-5) break;
+ const d = dX(u);
+ if (Math.abs(d) < 1e-6) break;
+ u -= e / d;
+ }
+ if (!(u >= 0 && u <= 1) || Math.abs(X(u) - t) > 1e-4) {
+ let lo = 0, hi = 1;
+ u = t;
+ for (let i = 0; i < 24; i++) {
+ if (X(u) < t) lo = u;
+ else hi = u;
+ u = (lo + hi) / 2;
+ }
+ }
+ return Y(u);
+ };
+ }
+ var EASE_LIFT = bezier(0.32, 0.72, 0, 1);
+ var tween = (v, dur = 700) => ({ from: v, to: v, t0: -1e9, dur });
+ var tval = (tw, now) => {
+ const p = clamp((now - tw.t0) / tw.dur, 0, 1);
+ return tw.from + (tw.to - tw.from) * (reduced ? 1 : EASE_LIFT(p));
+ };
+ var tset = (tw, to, now, delay) => {
+ if (tw.to === to) return;
+ tw.from = tval(tw, now);
+ tw.to = to;
+ tw.t0 = now + delay;
+ };
+ var tdone = (tw, now) => reduced || now >= tw.t0 + tw.dur;
+
+ // packages/hairline/src/core/stage.ts
+ var NS = "http://www.w3.org/2000/svg";
+ function mk(tag, attrs, parent) {
+ const e = document.createElementNS(NS, tag);
+ if (attrs) for (const k in attrs) e.setAttribute(k, String(attrs[k]));
+ if (parent) parent.appendChild(e);
+ return e;
+ }
+ function solid(parent) {
+ const g = mk("g", {}, parent);
+ return { g, sil: mk("path", { class: "sil" }, g), cr: mk("path", { class: "nf lo" }, g) };
+ }
+ var put = (el, s) => {
+ el.sil.setAttribute("d", s.sil);
+ el.cr.setAttribute("d", s.crease);
+ };
+ var flatDot = (parent, C, r, cls) => mk("ellipse", { rx: r2(r * C.S), ry: r2(r * C.S * C.k), class: cls }, parent);
+ var place = (el, q) => {
+ el.setAttribute("cx", String(r2(q[0])));
+ el.setAttribute("cy", String(r2(q[1])));
+ };
+ var fid = 0;
+ function fade(svg, y0, y1, a0 = 0.7) {
+ const id = "hl-fd" + ++fid, defs = mk("defs", {}, svg);
+ const lg = mk("linearGradient", { id: id + "g", gradientUnits: "userSpaceOnUse", x1: 0, y1: r2(y0), x2: 0, y2: r2(y1) }, defs);
+ mk("stop", { offset: 0, "stop-color": "#fff", "stop-opacity": a0 }, lg);
+ mk("stop", { offset: 1, "stop-color": "#fff", "stop-opacity": 0 }, lg);
+ const m = mk("mask", { id, maskUnits: "userSpaceOnUse", x: 0, y: 0, width: 400, height: 320 }, defs);
+ mk("rect", { x: 0, y: 0, width: 400, height: 320, fill: `url(#${id}g)` }, m);
+ return `url(#${id})`;
+ }
+ function reflect(svg, parent, P, front, ring, z0, depth) {
+ const r = ghost(P, front, ring, z0, depth);
+ const gh = mk("g", { class: "ghost", mask: fade(svg, r.y0, r.y1) }, parent);
+ mk("path", { d: r.d }, gh);
+ }
+ var boards = [];
+ var byStage = /* @__PURE__ */ new Map();
+ var raf = 0;
+ var last = 0;
+ var io = null;
+ var rm = null;
+ function frame(now) {
+ const dt = Math.min(0.05, Math.max(0, (now - last) / 1e3));
+ last = now;
+ let any = false;
+ for (const b of boards.slice()) if (b.vis && b.awake) {
+ try {
+ b.awake = !!b.tick(dt, now);
+ } catch (err) {
+ b.awake = false;
+ setTimeout(() => {
+ throw err;
+ });
+ }
+ any = any || b.awake;
+ }
+ raf = any ? requestAnimationFrame(frame) : 0;
+ }
+ function wake(b) {
+ b.awake = true;
+ if (!raf) {
+ last = performance.now();
+ raf = requestAnimationFrame(frame);
+ }
+ }
+ var onMotion = () => {
+ setReducedMotion(!!rm?.matches);
+ boards.forEach(wake);
+ };
+ function start() {
+ if (io) return;
+ io = new IntersectionObserver((es) => {
+ for (const e of es) {
+ const set = byStage.get(e.target);
+ if (!set) continue;
+ for (const b of set) {
+ b.vis = e.isIntersecting;
+ if (b.vis) wake(b);
+ }
+ }
+ }, { rootMargin: "80px" });
+ rm = matchMedia("(prefers-reduced-motion: reduce)");
+ setReducedMotion(rm.matches);
+ rm.addEventListener("change", onMotion);
+ }
+ function stop() {
+ if (raf) cancelAnimationFrame(raf);
+ raf = 0;
+ io?.disconnect();
+ io = null;
+ rm?.removeEventListener("change", onMotion);
+ rm = null;
+ }
+ function register(stage, tick) {
+ start();
+ const b = { stage, tick, vis: false, awake: true };
+ boards.push(b);
+ const peers = byStage.get(stage);
+ if (peers) {
+ for (const p of peers) b.vis = p.vis;
+ peers.add(b);
+ if (b.vis) wake(b);
+ } else {
+ byStage.set(stage, /* @__PURE__ */ new Set([b]));
+ io.observe(stage);
+ }
+ tick(0, performance.now());
+ let gone = false;
+ return {
+ wake: () => {
+ if (!gone) wake(b);
+ },
+ unregister: () => {
+ if (gone) return;
+ gone = true;
+ boards = boards.filter((x) => x !== b);
+ const set = byStage.get(stage);
+ if (set) {
+ set.delete(b);
+ if (!set.size) {
+ byStage.delete(stage);
+ io?.unobserve(stage);
+ }
+ }
+ if (!boards.length) stop();
+ }
+ };
+ }
+ var handlers = /* @__PURE__ */ new WeakMap();
+ var touring = /* @__PURE__ */ new WeakMap();
+ function pointer(stage, on) {
+ handlers.set(stage, on);
+ let tm = 0;
+ const pt = (e) => {
+ const r = stage.getBoundingClientRect();
+ return [(e.clientX - r.left) / r.width * 400, (e.clientY - r.top) / r.height * 320];
+ };
+ const move = (e) => {
+ clearTimeout(tm);
+ touring.get(stage)?.hold();
+ on.move(pt(e), e);
+ };
+ const down = (e) => {
+ clearTimeout(tm);
+ touring.get(stage)?.hold();
+ if (e.pointerType !== "mouse") stage.releasePointerCapture?.(e.pointerId);
+ if (on.down) on.down(pt(e), e);
+ else on.move(pt(e), e);
+ };
+ const leave = (e) => {
+ clearTimeout(tm);
+ tm = window.setTimeout(() => {
+ on.leave(e);
+ touring.get(stage)?.release();
+ }, e.pointerType === "mouse" ? 0 : 1400);
+ };
+ stage.addEventListener("pointermove", move);
+ stage.addEventListener("pointerdown", down);
+ stage.addEventListener("pointerleave", leave);
+ return () => {
+ clearTimeout(tm);
+ if (handlers.get(stage) === on) handlers.delete(stage);
+ stage.removeEventListener("pointermove", move);
+ stage.removeEventListener("pointerdown", down);
+ stage.removeEventListener("pointerleave", leave);
+ };
+ }
+ var LAP = [[128, 150], [200, 118], [272, 150], [200, 206], null];
+ var TRAVEL = 900;
+ var DWELL = 1200;
+ var REST = 1800;
+ var RESUME = 1200;
+ var STAGGER = 450;
+ var GHOST = { pointerType: "ghost" };
+ var started = 0;
+ function entry([x, y]) {
+ const dx = x - 200, dy = y - 160;
+ if (!dx && !dy) return [200, 320];
+ const k = Math.min(dx ? (dx > 0 ? 200 : -200) / dx : Infinity, dy ? (dy > 0 ? 160 : -160) / dy : Infinity);
+ return [200 + dx * k, 160 + dy * k];
+ }
+ function tour(stage, stops, onStop) {
+ let i = 0;
+ let wait = RESUME + STAGGER * (started++ % 4);
+ let t = -1;
+ let at = null;
+ let origin = [200, 320];
+ let hand = false, keys = stage.contains(stage.ownerDocument.activeElement);
+ let gone = false;
+ const leave = () => {
+ at = null;
+ t = -1;
+ handlers.get(stage)?.leave(GHOST);
+ };
+ const tick = (dt) => {
+ if (hand || keys || !stops.length) return false;
+ if (reducedMotion()) {
+ if (at) leave();
+ return false;
+ }
+ if (wait > 0) {
+ wait -= dt * 1e3;
+ return true;
+ }
+ const stop2 = stops[i];
+ if (stop2 === null) {
+ if (at) leave();
+ onStop?.(i);
+ i = (i + 1) % stops.length;
+ wait = REST;
+ return true;
+ }
+ const h = handlers.get(stage);
+ if (!h) return true;
+ if (t < 0) {
+ origin = at ?? entry(stop2);
+ t = 0;
+ }
+ t = Math.min(TRAVEL, t + dt * 1e3);
+ const k = EASE_LIFT(t / TRAVEL);
+ at = [origin[0] + (stop2[0] - origin[0]) * k, origin[1] + (stop2[1] - origin[1]) * k];
+ h.move(at, GHOST);
+ if (t < TRAVEL) return true;
+ onStop?.(i);
+ i = (i + 1) % stops.length;
+ t = -1;
+ wait = DWELL;
+ return true;
+ };
+ const take = () => {
+ at = null;
+ t = -1;
+ };
+ const give = () => {
+ if (hand || keys) return;
+ i = 0;
+ t = -1;
+ wait = RESUME;
+ board.wake();
+ };
+ const me = {
+ hold: () => {
+ hand = true;
+ take();
+ },
+ release: () => {
+ if (!hand) return;
+ hand = false;
+ give();
+ }
+ };
+ const focusIn = () => {
+ keys = true;
+ take();
+ };
+ const focusOut = (e) => {
+ if (keys && !stage.contains(e.relatedTarget)) {
+ keys = false;
+ give();
+ }
+ };
+ stage.addEventListener("focusin", focusIn);
+ stage.addEventListener("focusout", focusOut);
+ touring.set(stage, me);
+ const board = register(stage, tick);
+ return {
+ stop: () => {
+ if (gone) return;
+ gone = true;
+ board.unregister();
+ stage.removeEventListener("focusin", focusIn);
+ stage.removeEventListener("focusout", focusOut);
+ if (touring.get(stage) === me) touring.delete(stage);
+ if (at) leave();
+ }
+ };
+ }
+ function disposer() {
+ let fns = [];
+ return {
+ add: (fn) => {
+ fns.push(fn);
+ },
+ on: (target, type, fn, opts) => {
+ const h = fn;
+ target.addEventListener(type, h, opts);
+ fns.push(() => target.removeEventListener(type, h, opts));
+ },
+ dispose: () => {
+ const run2 = fns;
+ fns = [];
+ for (let i = run2.length - 1; i >= 0; i--) run2[i]();
+ }
+ };
+ }
+
+ // packages/hairline/src/core/styles.ts
+ var LIGHT = { plate: "#ffffff", hi: "#232327", edge: "#a4a4ac", mid: "#c3c3c9", lo: "#e0e0e4" };
+ var DARK = { plate: "#08090a", hi: "#d0d6e0", edge: "#5b5d64", mid: "#3e3e44", lo: "#29292d" };
+ var KEYS = ["plate", "hi", "edge", "mid", "lo"];
+ var vars = (p) => KEYS.map((k) => `--hl-${k}:var(--hairline-${k},${p[k]});`).join("");
+ var EASE = "cubic-bezier(0.5,0,0.1,1)";
+ var SVG = ":where([data-hairline]>svg)";
+ function css(lightDark) {
+ const both = Object.fromEntries(KEYS.map((k) => [k, `light-dark(${LIGHT[k]},${DARK[k]})`]));
+ return [
+ // the box, and the palette: light unless something below says otherwise
+ `:where([data-hairline]){display:block;position:relative;aspect-ratio:5/4;touch-action:pan-y;user-select:none;-webkit-user-select:none;--hl-sw:var(--hairline-stroke,0.9);${vars(LIGHT)}}`,
+ // the page's color-scheme
+ lightDark ? `:where([data-hairline]){${vars(both)}}` : "",
+ // an ancestor that says dark
+ `:where(.dark,[data-theme="dark"]) :where([data-hairline]){${vars(DARK)}}`,
+ // the figure's own theme option
+ `:where([data-hairline][data-hairline-theme="light"]){${vars(LIGHT)}}`,
+ `:where([data-hairline][data-hairline-theme="dark"]){${vars(DARK)}}`,
+ `:where([data-hairline]:focus-visible){outline:1.5px solid var(--hl-hi);outline-offset:2px}`,
+ `${SVG}{position:absolute;inset:0;width:100%;height:100%;display:block}`,
+ // Riffle's live region: read, not seen
+ `:where([data-hairline]>[data-hairline-live]){position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}`,
+ // the drawing: plates are filled with the plate colour and painted back to front
+ `${SVG} :where(path,polygon,ellipse,line){fill:var(--hl-plate);stroke:var(--hl-mid);stroke-width:var(--hl-sw);vector-effect:non-scaling-stroke;stroke-linejoin:round;stroke-linecap:round;transition:stroke 260ms ${EASE}}`,
+ `${SVG} :where(.nf){fill:none}`,
+ `${SVG} :where(.fo){stroke:none}`,
+ `${SVG} :where(.sil){stroke:var(--hl-edge)}`,
+ `${SVG} :where(.hi){stroke:var(--hl-hi)}`,
+ `${SVG} :where(.lo){stroke:var(--hl-lo)}`,
+ `${SVG} :where(.dash){stroke-dasharray:1 3}`,
+ `${SVG} :where(.dot){stroke:none;fill:var(--hl-hi);transition:fill 260ms ${EASE}}`,
+ `${SVG} :where(.dot.m){fill:var(--hl-edge)}`,
+ `${SVG} :where(.dot.off){fill:var(--hl-lo)}`,
+ `${SVG} :where(.ghost path){fill:none;stroke:var(--hl-mid)}`
+ ].join("");
+ }
+ var done = /* @__PURE__ */ new WeakSet();
+ function inject(root) {
+ if (done.has(root)) return;
+ done.add(root);
+ const doc = root.nodeType === 9 ? root : root.ownerDocument;
+ const win = doc.defaultView;
+ const text = css(!!win?.CSS?.supports?.("color", "light-dark(#000,#fff)"));
+ if (win && "adoptedStyleSheets" in root) {
+ try {
+ const sheet = new win.CSSStyleSheet();
+ sheet.replaceSync(text);
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
+ return;
+ } catch {
+ }
+ }
+ const style = doc.createElement("style");
+ style.setAttribute("data-hairline-style", "");
+ style.textContent = text;
+ (root.nodeType === 9 ? doc.head ?? doc.documentElement : root).appendChild(style);
+ }
+ return __toCommonJS(kernel_exports);
+})();
+/* /hairline kernel */
+</script>
+<script id="hl-bench">
+/*
+ * The bench: the page a figure is shown on. It makes the host and the svg the
+ * way the package's mount does, hands them to the figure, and owns everything
+ * around it: the read-out, the slider, the theme, the line under the stage.
+ */
+(() => {
+ const RULES = ["hit", "order", "reach", "accent", "rest", "honesty", "cost", "clock", "radius", "quiet"];
+ const $ = (id) => document.getElementById(id);
+ const root = document.documentElement, params = new URLSearchParams(location.search);
+
+ /* the theme: the system's until the switch is pressed, then the switch's */
+ const dark = () => (root.dataset.theme ? root.dataset.theme === "dark" : matchMedia("(prefers-color-scheme: dark)").matches);
+ const label = () => { $("theme").textContent = dark() ? "dark" : "light"; };
+ $("theme").addEventListener("click", () => { root.dataset.theme = dark() ? "light" : "dark"; label(); });
+ /* ?theme=light or ?theme=dark wins over the system's, as pressing the switch does */
+ if (["light", "dark"].includes(params.get("theme"))) root.dataset.theme = params.get("theme");
+ label();
+
+ /* ?intensity=0 sets the slider before the figure mounts, for a look at either end */
+ const i = (params.get("intensity") || "").trim();
+ if (i && Number.isFinite(Number(i))) $("intensity").value = String(Math.min(1, Math.max(0, Number(i))));
+
+ /* ?w=240 narrows the page, for a look at the size of a thumbnail */
+ const w = Number(params.get("w"));
+ if (w > 0) document.querySelector("main").style.maxWidth = w + "px";
+
+ /* a figure that fails says so under the stage, instead of leaving an empty plate */
+ addEventListener("error", (e) => {
+ $("error").hidden = false;
+ $("error").textContent = String((e.error && e.error.message) || e.message);
+ });
+
+ let mounted = false;
+ window.hairline = (figure) => {
+ if (mounted) throw new Error("hairline: one figure per page.");
+ mounted = true;
+ const stage = $("stage"), slider = $("intensity");
+
+ /* intensity to the figure's own number: two straight lines that meet at 0.5, as in the package */
+ const [lo, mid, hi] = figure.range;
+ const at = (i) => Math.round((i <= 0.5 ? lo + (i / 0.5) * (mid - lo) : mid + ((i - 0.5) / 0.5) * (hi - mid)) * 1000) / 1000;
+
+ HL.inject(document);
+ stage.setAttribute("data-hairline", figure.name);
+ stage.setAttribute("role", "img");
+ stage.setAttribute("aria-label", figure.means);
+ const svg = HL.mk("svg", { viewBox: "0 0 400 320", "aria-hidden": "true" }, stage);
+
+ let text = null;
+ const read = {
+ get textContent() { return text; },
+ set textContent(value) { text = value == null ? "" : String(value); $("read").textContent = text; },
+ };
+
+ document.title = "Hairline · " + figure.name;
+ $("name").textContent = figure.name;
+ $("means").textContent = figure.means;
+ $("rules").textContent = figure.rules.map((n) => String(n).padStart(2, "0") + " " + RULES[n - 1]).join(" · ");
+ const show = () => { $("value").textContent = String(at(Number(slider.value))); };
+ show();
+
+ const handle = figure.mount({ stage, svg, read }, at(Number(slider.value)));
+ if (text === null) read.textContent = "rest";
+ slider.addEventListener("input", () => { show(); handle.set(at(Number(slider.value))); });
+ window.hairline.figure = handle;
+
+ /* play: an unseen pointer walks the figure's tour (or HL.LAP) until a hand arrives; ?play=1 starts it on load */
+ const play = $("play");
+ window.hairline.playing = null;
+ play.addEventListener("click", () => {
+ const was = play.getAttribute("aria-pressed") === "true";
+ if (was) { window.hairline.playing.stop(); window.hairline.playing = null; }
+ else window.hairline.playing = HL.tour(stage, figure.tour || HL.LAP, (i) => { if (window.hairline.onStop) window.hairline.onStop(i); });
+ play.setAttribute("aria-pressed", String(!was));
+ });
+ if (params.get("play") === "1") play.click();
+
+ /* ?at=200,160 holds the pointer at a viewBox point, for a picture of the answer without a mouse */
+ const p = (params.get("at") || "").split(",").map(Number);
+ if (p.length === 2 && p.every(Number.isFinite)) {
+ const r = stage.getBoundingClientRect();
+ stage.dispatchEvent(new PointerEvent("pointermove", {
+ pointerType: "mouse", pointerId: 1, bubbles: true,
+ clientX: r.left + (p[0] / 400) * r.width, clientY: r.top + (p[1] / 320) * r.height,
+ }));
+ }
+ };
+})();
+</script>
+<script type="module" id="hl-figure">
+/**
+ * Linear, cycle: the mark lies on the ground in relief, rebuilt from its own path: a disc cut by
+ * parallel chords into its big segment and three stripes. The stripes are lanes, slower toward the
+ * rim: in progress, todo, backlog; the segment is done. Twelve issues, three to a lane, three done.
+ * Point up across the mark, the way it moves, and the cycle runs: in each column the front issue
+ * glides over the gap to the next lane, lifting as it goes and landing softly, one after another
+ * from the disc down, and the done ones settle in three neat piles on the segment. Back down unstacks them. Each issue wears its state as Linear does: a dashed
+ * ring in backlog, a ring in todo, half filled in progress, filled when done. The slider is how long a glide takes, in ms.
+ */
+const {
+ Cam, clamp, facing, fit, poly, prism, proj, rad, rrect, seg, solid, put,
+ spring, stepS, disposer, mk, pointer, register, unproj,
+} = HL;
+
+const R = 60, K = R / 12, H = 2, TH = 2, CL = 12, CW = 6.5, PX = 14.5, N = 12, REST = 3, YD = -17;
+
+/**
+ * The chords of the mark, read from its path (a 24 square, y down, the disc's centre at 12,12):
+ * each chord's start point, and n = (x - y) / √2 across the stripes, toward the segment.
+ */
+const CH = [[2.886, 4.18], [1.817, 5.626], [0.951, 7.277], [0.322, 9.163], [0, 11.358], [0.152, 14.025]].map(([x, y]) => (x - y) / Math.SQRT2);
+/** The four parts as bands of n: the segment, then the stripes toward the rim. */
+const BANDS = [[CH[0], 12], [CH[2], CH[1]], [CH[4], CH[3]], [-12, CH[5]]];
+
+/**
+ * A band of the disc on the ground, as a ring {u, v, nu, nv}: along the stripes is x, across is y,
+ * the segment toward -y (screen up and right), so the mark lies as it is drawn.
+ */
+function band([n0, n1]) {
+ const a = Math.asin(clamp((-n1 * K) / R, -1, 1)), b = Math.asin(clamp((-n0 * K) / R, -1, 1)), M = 40, pts = [];
+ for (let k = 0; k <= M; k++) { const t = a + ((b - a) * k) / M; pts.push([R * Math.cos(t), R * Math.sin(t)]); }
+ for (let k = 0; k <= M; k++) { const t = Math.PI - b + ((b - a) * k) / M; pts.push([R * Math.cos(t), R * Math.sin(t)]); }
+ const ring = pts.filter((p, i) => { const q = pts[(i + 1) % pts.length]; return Math.hypot(p[0] - q[0], p[1] - q[1]) > 1e-6; });
+ return ring.map((p, i) => {
+ const o = ring[(i + ring.length - 1) % ring.length], q = ring[(i + 1) % ring.length];
+ const nx = q[1] - o[1], ny = o[0] - q[0], l = Math.hypot(nx, ny);
+ return { u: p[0], v: p[1], nu: nx / l, nv: ny / l };
+ });
+}
+
+/** Where each lane's issues ride: the segment's piles, then each stripe, the rim's cap pulled in where it is long enough. */
+const LY = [YD, ...BANDS.slice(1).map(([, n1], k) => -n1 * K + (k < 2 ? 4.45 : 3.85))];
+
+function mount({ stage, svg, read }, value) {
+ const bag = disposer();
+ let fly = value;
+
+ const C = Cam(45, 0.5, 2.9);
+ fit(C, [[R, 0, 0], [-R, 0, 0], [0, R, 0], [0, -R, 0], [0, -R, 12], [0, 2, 22]], 200, 162);
+ const P = proj(C), front = facing(C);
+
+ const g = mk("g", {}, svg);
+ // the mark: four raised parts, the farthest first
+ const parts = BANDS.map((b) => { const s = solid(g); put(s, prism(P, front, band(b), band(b), 0, H)); return s; });
+
+ /** An issue's place, [y, z], for a cycle that has run c: done ones in their column's pile, the rest three to a lane. */
+ const slot = (i, c) => (i < c ? [YD, H + Math.floor(i / 3) * (TH + 0.7)] : [LY[1 + Math.floor((i - c) / 3)], H]);
+
+ /**
+ * Each issue rides two springs per axis, critically damped: a goal that chases the place, and the card that
+ * chases the goal. So it eases out and lands softly, never overshoots, and a new place mid-flight bends the
+ * path from where it is, at the speed it has. It lifts by how fast it goes, more for a longer trip, through
+ * a third spring, so the lift swells and settles too, even when it turns back.
+ */
+ let w = 9000 / fly;
+ const spr = (x) => spring(x, { k: w * w, c: 2 * w, eps: 0.005 }), pair = (x) => [spr(x), spr(x)];
+ const deck = mk("g", {}, g);
+ const cards = Array.from({ length: N }, (_, i) => {
+ const [y, z] = slot(i, REST), el = mk("g", {}, deck);
+ return {
+ i, el, x: ((i % 3) - 1) * PX, ys: pair(y), zs: pair(z), lf: spr(0), want: [y, z], due: 0, at: [0, y, z], body: solid(el),
+ ring: mk("path", { class: "nf" }, el), mark: mk("path", { class: "dot m" }, el), title: mk("path", { class: "nf lo" }, el),
+ };
+ });
+
+ /** A small flat circle on the card's top, or the part of it from a0 to a1 degrees, closed through its centre. */
+ const disc = (x, y, z, r, a0 = 0, a1 = 360) => {
+ const pts = Array.from({ length: 17 }, (_, k) => { const t = rad(a0 + ((a1 - a0) * k) / 16); return P(x + r * Math.cos(t), y + r * Math.sin(t), z); });
+ return poly(a1 - a0 < 360 ? [P(x, y, z), ...pts] : pts.slice(0, -1));
+ };
+
+ function paint(cd) {
+ const x = cd.x, y = cd.ys[1].x, z = cd.zs[1].x + cd.lf.x;
+ cd.at = [x, y, z];
+ // its state is the lane it is over: nothing inside in backlog and todo, the near half in progress, all of it done
+ const lane = LY.reduce((b, v, k) => (Math.abs(v - y) < Math.abs(LY[b] - y) ? k : b), 0);
+ const top = z + TH, r = rrect(x - CL / 2, y - CW / 2, x + CL / 2, y + CW / 2, 2, 3), hx = x - CL / 2 + 2.2;
+ put(cd.body, prism(P, front, r, r, z, top));
+ cd.ring.setAttribute("d", disc(hx, y, top, 1.2));
+ cd.mark.setAttribute("d", lane === 0 ? disc(hx, y, top, 0.8) : lane === 1 ? disc(hx, y, top, 0.8, 90, 270) : "");
+ cd.ring.setAttribute("class", lane === 3 ? "nf lo dash" : lane === 2 ? "nf lo" : "nf");
+ cd.title.setAttribute("class", lane === 0 ? "nf" : "nf lo");
+ cd.title.setAttribute("d", seg(P(hx + 2.2, y - 0.8, top), P(x + CL / 2 - 1.6, y - 0.8, top)) + seg(P(hx + 2.2, y + 1, top), P(x + CL / 4, y + 1, top)));
+ }
+
+ let hover = false, order = "", was = REST;
+ /**
+ * Sets where every issue is headed for a cycle that has run c. They leave one after another, the one in front
+ * first, so a follower never catches the card ahead; undone, the order runs backwards.
+ */
+ function run(c, now) {
+ const go = cards.filter((cd) => slot(cd.i, c).some((v, k) => v !== cd.want[k]));
+ if (c < was) go.reverse();
+ was = c;
+ go.forEach((cd, k) => { cd.want = slot(cd.i, c); cd.due = now + 0.1 * fly * k; });
+ cards.forEach((cd) => cd.body.sil.classList.toggle("hi", hover && cd.i === c - 1));
+ parts[0].sil.classList.toggle("hi", !hover);
+ read.textContent = hover ? `${c}/${N} done` : "rest";
+ }
+
+ // its own clock: the departures are set by performance.now(), and a frame's time can lag it by seconds in a frame loaded late
+ const B = register(stage, (dt) => {
+ const now = performance.now();
+ let moving = false;
+ cards.forEach((cd) => {
+ if (now >= cd.due) { cd.ys[0].t = cd.want[0]; cd.zs[0].t = cd.want[1]; } else moving = true;
+ let m = false;
+ for (const s of [cd.ys, cd.zs]) { m = stepS(s[0], dt) | m; s[1].t = s[0].x; m = stepS(s[1], dt) | m; }
+ cd.lf.t = Math.abs(cd.ys[1].v) / w;
+ m = stepS(cd.lf, dt) | m;
+ if (m || !cd.body.sil.getAttribute("d")) paint(cd);
+ moving = moving || m;
+ });
+ // farther cards first, a lower one before a card above it
+ const sorted = cards.slice().sort((m, n) => m.at[0] + m.at[1] + m.at[2] * 1.5 - (n.at[0] + n.at[1] + n.at[2] * 1.5));
+ const key = sorted.map((cd) => cd.i).join();
+ if (key !== order) { order = key; sorted.forEach((cd) => deck.appendChild(cd.el)); }
+ return moving;
+ });
+ bag.add(B.unregister);
+ run(REST, performance.now());
+
+ /** The pointer, put on the mark's top: how far up across the stripes it is, toward the segment, is how far the cycle has run. */
+ function aim(p) {
+ hover = p !== null;
+ let c = REST;
+ if (hover) { const y = unproj(C, p[0], p[1], H)[1]; c = Math.round(REST + (N - REST) * clamp((LY[3] - y) / (LY[3] - YD - 22), 0, 1)); }
+ run(c, performance.now());
+ B.wake();
+ }
+ bag.add(pointer(stage, { move: (p) => aim(p), leave: () => aim(null) }));
+ bag.add(() => svg.replaceChildren());
+
+ return {
+ set: (v) => { fly = v; w = 9000 / v; cards.forEach((cd) => [...cd.ys, ...cd.zs, cd.lf].forEach((sp) => Object.assign(sp, { k: w * w, c: 2 * w }))); },
+ destroy: bag.dispose,
+ };
+}
+
+hairline({
+ name: "linear-cycle",
+ means: "The mark's stripes are lanes: point up across them, the way it moves, and the issues glide lane to lane until they stack, done, on the disc.",
+ rules: [1, 5, 8, 10],
+ range: [250, 480, 900],
+ tour: [[114, 215], [160, 192], [262, 141], null],
+ mount,
+});
+</script>
+</body>
+</html>
diff --git a/apps/site/test/catalogue.test.ts b/apps/site/test/catalogue.test.ts
index a64798e..3bf727a 100644
--- a/apps/site/test/catalogue.test.ts
+++ b/apps/site/test/catalogue.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, it } from "vitest";
import { ENTRIES, NOTICE, SHELVES, spell, tally } from "@/lib/catalogue";
import { FIGURES } from "@/lib/figures";
-import { COMMAND, EXAMPLES } from "@/lib/skill";
+import { COMMAND, MARKS } from "@/lib/skill";
import { REACT, VANILLA, CDN, paste } from "@/lib/snippets";
describe("the catalogue", () => {
@@ -26,7 +26,7 @@ describe("the catalogue", () => {
for (const f of marks.figures) {
expect(f.drawn).toBe(false);
const made = (f as { made?: { file: string; prompt: string } }).made!;
- const example = EXAMPLES.find((e) => e.file === made.file)!;
+ const example = MARKS.find((e) => e.file === made.file)!;
expect(made.prompt).toBe(`${COMMAND} ${example.idea}`);
}
// each line says what that page's slider does
diff --git a/apps/site/test/docs.test.ts b/apps/site/test/docs.test.ts
index 59c8518..463861a 100644
--- a/apps/site/test/docs.test.ts
+++ b/apps/site/test/docs.test.ts
@@ -10,7 +10,7 @@ import { SECTIONS } from "@/lib/docs";
import { FIGURES, INTENSITY, OPTIONS, measure } from "@/lib/figures";
import { llms, scale } from "@/lib/llms";
import { tiny } from "@/lib/size";
-import { COMMAND, EXAMPLES, INSTALL } from "@/lib/skill";
+import { ADOPT, ADOPTED, COMMAND, EXAMPLES, INSTALL } from "@/lib/skill";
import { highlight } from "@/lib/highlight";
import { CDN, CSS, EMPTY, QUICKSTART, REACT, REACT_SIGNATURE, VANILLA, VANILLA_SIGNATURE, install } from "@/lib/snippets";
@@ -135,13 +135,18 @@ describe("/llms.txt", () => {
// the two pages a follow-up made say so
expect(text).toContain(`- \`${COMMAND} git branches\`, then "The rails almost disappear`);
expect(text).toContain(`- \`${COMMAND} weather over a city\`, then "The cloud looks like a stack of cylinders`);
- expect(text).toContain("https://example.test/skill\n");
+ expect(text).toContain("https://example.test/skills\n");
expect(text.indexOf("## Make your own")).toBeLessThan(text.indexOf("## Links"));
});
- it("says, right after the examples drawn from a company's mark, that the marks are their owners'", () => {
- const last = EXAMPLES.at(-1)!;
- expect(text).toContain(`https://example.test/skill/${last.file}\n\n${NOTICE}\n`);
+ it("says, right after hairline-adopt's examples, which start from companies' marks, that the marks are their owners'", () => {
+ expect(text).toContain(`https://example.test/skill/${ADOPTED.at(-1)!.file}\n\n${NOTICE}\n`);
+ expect(text.split(NOTICE)).toHaveLength(2);
+ });
+
+ it("says how to start from an SVG and links each of hairline-adopt's examples to its page", () => {
+ expect(text).toContain(`type \`${ADOPT} <file.svg>\``);
+ for (const e of ADOPTED) expect(text).toContain(`- \`${ADOPT} ${e.idea}\`: https://example.test/skill/${e.file}`);
});
it.each(FIGURES)("names $name with its row of the intensity table", (doc) => {
diff --git a/apps/site/test/figures.spec.ts b/apps/site/test/figures.spec.ts
index 3835014..29eecf1 100644
--- a/apps/site/test/figures.spec.ts
+++ b/apps/site/test/figures.spec.ts
@@ -225,7 +225,7 @@ test("the Marks shelf shows three figures the skill made, each with its prompt a
await expect(drawer).toContainText("not affiliated");
await expect(drawer.getByRole("tab")).toHaveCount(0);
await expect(drawer.locator("input[type=range]")).toHaveCount(0);
- await expect(drawer.getByRole("link", { name: "hairline-create" })).toHaveAttribute("href", "/skill");
+ await expect(drawer.getByRole("link", { name: "hairline-create" })).toHaveAttribute("href", "/skills");
});
test("Escape pressed inside a made page's frame closes the drawer, as it does outside", async ({ page }) => {
diff --git a/apps/site/test/site.spec.ts b/apps/site/test/site.spec.ts
index cf7b85c..38d66d8 100644
--- a/apps/site/test/site.spec.ts
+++ b/apps/site/test/site.spec.ts
@@ -35,11 +35,11 @@ test("the home prerenders the drawing's empty box, then draws it with a clean co
expect(noise).toEqual([]);
});
-test("the top bar holds the name with the version beside it, then the figures, the skill, the docs, the story and GitHub, and no llms.txt button", async ({ page }) => {
+test("the top bar holds the name with the version beside it, then the figures, the skills, the docs, the story and GitHub, and no llms.txt button", async ({ page }) => {
await page.goto("/");
await expect(page.locator(".topbar nav > *")).toHaveCount(5);
await expect(page.locator(".topbar nav > a").nth(0)).toHaveText("Figures");
- await expect(page.locator(".topbar nav > a").nth(1)).toHaveText("Skill");
+ await expect(page.locator(".topbar nav > a").nth(1)).toHaveText("Skills");
await expect(page.locator(".topbar nav > a").nth(2)).toHaveText("Docs");
await expect(page.locator(".topbar nav [data-version]")).toHaveCount(0);
await expect(page.locator(".topbar")).not.toContainText("llms.txt");
@@ -335,7 +335,7 @@ test("a pasted link shows the page it leads to: each page's card has its own tit
["/", "hairline", /^Thirty-three isometric line figures/],
["/figures", "Figures", /^Eight shelves, thirty-three figures, grouped by what they draw/],
["/docs", "Docs", /^Thirty-three isometric line figures/],
- ["/skill", "Make your own figure", /^hairline-create is a skill/],
+ ["/skills", "Make your own figure", /^Two skills for coding agents/],
["/inspo", "How Hairline was made", /^A long brief/],
] as const;
for (const [path, title, text] of CARDS) {
@@ -358,7 +358,7 @@ test("robots.txt lets every crawler in and names the sitemap, which lists the fi
expect(robots).toContain(`Sitemap: ${BASE}/sitemap.xml`);
const sitemap = await (await request.get("/sitemap.xml")).text();
- expect([...sitemap.matchAll(/<loc>([^<]+)<\/loc>/g)].map((m) => m[1])).toEqual([BASE, `${BASE}/figures`, `${BASE}/docs`, `${BASE}/skill`, `${BASE}/inspo`]);
+ expect([...sitemap.matchAll(/<loc>([^<]+)<\/loc>/g)].map((m) => m[1])).toEqual([BASE, `${BASE}/figures`, `${BASE}/docs`, `${BASE}/skills`, `${BASE}/inspo`]);
});
test("the page fits a phone, with the longest install command, and its buttons", async ({ page }) => {
diff --git a/apps/site/test/skill.spec.ts b/apps/site/test/skill.spec.ts
index fe5d812..83e3366 100644
--- a/apps/site/test/skill.spec.ts
+++ b/apps/site/test/skill.spec.ts
@@ -6,10 +6,16 @@ const IDEAS = [
"a rate limiter",
"git branches",
"weather over a city",
- "an empty state for \"No deployments yet\", from Vercel's mark: the triangle as an upright slab hovering over a pad with its slot marked dim; the nearer the pointer, the lower it settles, until it seats. Name it vercel.",
- "an empty state for \"No agents connected\", from Mastra's mark: the spheres of the M joined by necks on a board, the lone sphere standing apart; the pointer draws it toward the others, a neck forms, stretches and lets go. Name it mastra.",
- "an empty state for \"No pages inside\", from Notion's mark: the cube as a box with a lid, the N a relief on its front face; the pointer's height opens the lid on a spring, and the box is empty. Name it notion.",
];
+/** What was typed after /hairline-adopt, in page order: the SVG, then what the pointer does. */
+const ADOPTED = [
+ "deploy.svg the pointer's height is the thrust; raised high enough, the rocket lifts off",
+ "firecrawl.svg the flame reads a page: point down it, and each part peels off onto a sheet of markdown",
+ "linear.svg the stripes are lanes: point up across them, and the issues move lane to lane until they are done",
+ "cursor.svg the mark is the caret over code: point down the page, and each suggested line is accepted",
+];
+/** Every example on the page: hairline-create's, then hairline-adopt's. */
+const ALL = IDEAS.length + ADOPTED.length;
/** A line as a pattern that matches only itself: the marks' prompts hold full stops. */
const literal = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -27,7 +33,7 @@ function watch(page: Page): string[] {
/** The frames are lazy: each is brought on screen, then waited for until its figure is drawn. */
async function frames(page: Page): Promise<FrameLocator[]> {
const out: FrameLocator[] = [];
- for (let i = 0; i < IDEAS.length; i++) {
+ for (let i = 0; i < ALL; i++) {
const row = page.locator("[data-example]").nth(i);
await row.scrollIntoViewIfNeeded();
const frame = row.frameLocator("iframe");
@@ -46,21 +52,29 @@ const fit = (frame: FrameLocator) => frame.locator("main").evaluate((main) => ({
band: window.innerHeight - main.getBoundingClientRect().bottom - 24,
}));
-test("/skill opens with the install command, seven prompts and seven live figures, and a clean console", async ({ page }) => {
+test("/skills opens with the install command, eight prompts and eight live figures, and a clean console", async ({ page }) => {
const noise = watch(page);
- await page.goto("/skill");
+ await page.goto("/skills");
await expect(page).toHaveTitle("Make your own figure · hairline");
await expect(page.getByRole("heading", { level: 1 })).toHaveText("Make your own figure");
await expect(page.locator('[data-command="install"]')).toHaveText(new RegExp(INSTALL));
- await expect(page.locator('[data-command="prompt"]')).toHaveText(IDEAS.map((idea) => new RegExp(`/hairline-create ${literal(idea)}$`)));
- await expect(page.locator("[data-steps] > li")).toHaveCount(5);
- await expect(page.locator("#examples")).toContainText("Hairline is not affiliated with them.");
+ await expect(page.locator('[data-command="prompt"]')).toHaveText([
+ ...IDEAS.map((idea) => new RegExp(`/hairline-create ${literal(idea)}$`)),
+ ...ADOPTED.map((idea) => new RegExp(`/hairline-adopt ${literal(idea)}$`)),
+ ]);
+ await expect(page.locator("#how [data-steps] > li")).toHaveCount(5);
+ await expect(page.locator("#adopt-how [data-steps] > li")).toHaveCount(5);
+ await expect(page.locator('#adopt-use [data-command="usage"]')).toHaveText(/\/hairline-adopt <file\.svg>/);
+ // only hairline-adopt's examples start from companies' marks
+ await expect(page.locator("#adopt-examples")).toContainText("Hairline is not affiliated with them.");
+ await expect(page.locator("#examples")).not.toContainText("Hairline is not affiliated with them.");
+ for (const name of ["vercel", "mastra", "notion"]) await expect(page.locator(`[data-example="${name}"]`)).toHaveCount(0);
await frames(page);
expect(noise).toEqual([]);
});
test("a figure on /skill answers the pointer and goes back to rest", async ({ page }) => {
- await page.goto("/skill");
+ await page.goto("/skills");
for (const frame of await frames(page)) {
const read = frame.locator("#read");
await expect(read).toHaveText("rest");
@@ -83,8 +97,8 @@ test("a figure on /skill answers the pointer and goes back to rest", async ({ pa
});
test("each frame is named by what its figure means, and shows the page the skill wrote, light", async ({ page, request }) => {
- await page.goto("/skill");
- await expect(page.locator("[data-example]")).toHaveCount(IDEAS.length);
+ await page.goto("/skills");
+ await expect(page.locator("[data-example]")).toHaveCount(ALL);
for (const row of await page.locator("[data-example]").all()) {
const frame = row.locator("iframe");
expect((await frame.getAttribute("title"))!.length).toBeGreaterThan(20);
@@ -98,7 +112,7 @@ test("each frame is named by what its figure means, and shows the page the skill
});
test("each example shows the figure, its controls and what it means, without the page's name tags or rules line", async ({ page }) => {
- await page.goto("/skill");
+ await page.goto("/skills");
await expect(page.getByRole("link", { name: "Open the page" })).toHaveCount(0);
for (const frame of await frames(page)) {
for (const hidden of ["#name", "#read", "#rules"]) await expect(frame.locator(hidden)).toBeHidden();
@@ -108,19 +122,24 @@ test("each example shows the figure, its controls and what it means, without the
});
test("each example is named by its prompt, and each copy button says which line it copies", async ({ page }) => {
- await page.goto("/skill");
+ await page.goto("/skills");
for (const idea of IDEAS) {
const row = page.getByRole("article", { name: `/hairline-create ${idea}`, exact: true });
await expect(row).toHaveCount(1);
await expect(row.getByRole("button", { name: `Copy prompt: ${idea}`, exact: true })).toHaveCount(1);
}
+ for (const idea of ADOPTED) {
+ const row = page.getByRole("article", { name: `/hairline-adopt ${idea}`, exact: true });
+ await expect(row).toHaveCount(1);
+ await expect(row.getByRole("button", { name: `Copy prompt: ${idea}`, exact: true })).toHaveCount(1);
+ }
await expect(page.getByRole("button", { name: "Copy follow-up: git branches", exact: true })).toHaveCount(1);
await expect(page.getByRole("button", { name: "Copy follow-up: weather over a city", exact: true })).toHaveCount(1);
});
test("the install command and a prompt copy as they are written", async ({ page, context }) => {
await context.grantPermissions(["clipboard-read", "clipboard-write"]);
- await page.goto("/skill");
+ await page.goto("/skills");
await page.locator('[data-command="install"] .icopy').click();
expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(INSTALL);
await page.locator('[data-command="prompt"] .icopy').nth(2).click();
@@ -130,7 +149,7 @@ test("the install command and a prompt copy as they are written", async ({ page,
for (const width of [1200, 320]) {
test(`at ${width}px /skill does not scroll sideways, and no frame scrolls inside`, async ({ page }) => {
await page.setViewportSize({ width, height: 800 });
- await page.goto("/skill");
+ await page.goto("/skills");
const list = await frames(page);
expect(await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth)).toBe(0);
for (const frame of list) {
@@ -142,9 +161,9 @@ for (const width of [1200, 320]) {
for (const width of [320, 900]) {
test(`at ${width}px every prompt reads whole, and the install line fades while more of it is hidden`, async ({ page }) => {
await page.setViewportSize({ width, height: 800 });
- await page.goto("/skill");
+ await page.goto("/skills");
const lines = page.locator('[data-command="prompt"] .pill-line');
- await expect(lines).toHaveCount(IDEAS.length);
+ await expect(lines).toHaveCount(ALL);
for (const over of await lines.evaluateAll((els) => els.map((el) => el.scrollWidth - el.clientWidth))) expect(over).toBeLessThanOrEqual(0);
const install = page.locator('[data-command="install"] .pill-line');
expect(await install.evaluate((el) => getComputedStyle(el).whiteSpace)).toBe("nowrap");
@@ -160,7 +179,7 @@ for (const width of [320, 900]) {
}
test("at 1200px each card stacks its words over its figure, and the plate sits centred in the card", async ({ page }) => {
- await page.goto("/skill");
+ await page.goto("/skills");
await frames(page);
await page.evaluate(() => window.scrollTo(0, 0));
for (const row of await page.locator("[data-example]").all()) {
@@ -182,7 +201,7 @@ test.describe("on a dark system", () => {
test.use({ colorScheme: "dark" });
test("every frame is still light, as the site is", async ({ page }) => {
- await page.goto("/skill");
+ await page.goto("/skills");
for (const frame of await frames(page)) {
expect(await frame.locator("body").evaluate((body) => getComputedStyle(body).backgroundColor)).toBe("rgb(255, 255, 255)");
}
@@ -192,26 +211,26 @@ test.describe("on a dark system", () => {
test.describe("without JavaScript", () => {
test.use({ javaScriptEnabled: false });
- test("/skill still gives the install command, the prompts and the frames with the pages", async ({ page }) => {
- await page.goto("/skill");
+ test("/skills still gives the install command, the prompts and the frames with the pages", async ({ page }) => {
+ await page.goto("/skills");
await expect(page.locator('[data-command="install"]')).toHaveText(new RegExp(INSTALL));
- await expect(page.locator('[data-command="prompt"]')).toHaveCount(IDEAS.length);
- await expect(page.locator('[data-example] iframe[src^="/skill/hairline-"]')).toHaveCount(IDEAS.length);
+ await expect(page.locator('[data-command="prompt"]')).toHaveCount(ALL);
+ await expect(page.locator('[data-example] iframe[src^="/skill/hairline-"]')).toHaveCount(ALL);
});
});
-test("the top bar's Skill link opens /skill", async ({ page }) => {
+test("the top bar's Skills link opens /skills", async ({ page }) => {
await page.goto("/");
- await page.getByRole("banner").getByRole("link", { name: "Skill" }).click();
- await expect(page).toHaveURL(/\/skill$/);
+ await page.getByRole("banner").getByRole("link", { name: "Skills" }).click();
+ await expect(page).toHaveURL(/\/skills$/);
await expect(page.getByRole("heading", { level: 1 })).toHaveText("Make your own figure");
});
test("the top bar fits a 320px screen on one row, the version left out so the name stands clear of the links", async ({ page }) => {
await page.setViewportSize({ width: 320, height: 700 });
- await page.goto("/skill");
+ await page.goto("/skills");
await expect(page.locator(".topbar [data-version]")).toBeHidden();
- // from the name's last letter to the Skill link's first: at least the 20px the links keep between each other
+ // from the name's last letter to the Skills link's first: at least the 20px the links keep between each other
const gap = await page.evaluate(() => {
const text = (el: Element) => { const r = document.createRange(); r.selectNodeContents(el); return r.getBoundingClientRect(); };
return text(document.querySelector(".topbar-link")!).left - text(document.querySelector(".topbar-name")!).right;
@@ -225,12 +244,12 @@ test("the top bar fits a 320px screen on one row, the version left out so the na
expect(last.x + last.width).toBeLessThanOrEqual(bar.x + bar.width);
});
-test("the home's hero points to the skill in one line between the buttons and the drawing, and it reaches /skill", async ({ page }) => {
+test("the home's hero points to the skills in one line between the buttons and the drawing, and it reaches /skills", async ({ page }) => {
for (const width of [1200, 320]) {
await page.setViewportSize({ width, height: 800 });
await page.goto("/");
const link = page.locator(".hero-rise").getByRole("link", { name: "Or draw your own with the skill" });
- await expect(link).toHaveAttribute("href", "/skill");
+ await expect(link).toHaveAttribute("href", "/skills");
expect(await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth)).toBe(0);
const get = (await page.locator(".hero-get").boundingBox())!;
const box = (await link.boundingBox())!;
@@ -239,7 +258,7 @@ test("the home's hero points to the skill in one line between the buttons and th
expect(box.y + box.height).toBeLessThanOrEqual(art.y);
}
await page.locator(".hero-rise").getByRole("link", { name: "Or draw your own with the skill" }).click();
- await expect(page).toHaveURL(/\/skill$/);
+ await expect(page).toHaveURL(/\/skills$/);
await expect(page.getByRole("heading", { level: 1 })).toHaveText("Make your own figure");
});
@@ -257,15 +276,16 @@ const FOLLOW_UPS: Record<string, string | undefined> = {
clearance: undefined,
sidings: "The rails almost disappear and the trains read as loose blocks. Make it read as a railway at a glance.",
storm: "The cloud looks like a stack of cylinders. Make it read as a cloud at a glance.",
- vercel: undefined,
- mastra: undefined,
- notion: undefined,
+ "deploy-liftoff": undefined,
+ "firecrawl-reader": undefined,
+ "linear-cycle": undefined,
+ "cursor-tab": undefined,
};
test("a follow-up sits under its prompt as a second line that wraps instead of scrolling, and copies on its own", async ({ page, context }) => {
await context.grantPermissions(["clipboard-read", "clipboard-write"]);
await page.setViewportSize({ width: 320, height: 800 });
- await page.goto("/skill");
+ await page.goto("/skills");
for (const [name, text] of Object.entries(FOLLOW_UPS)) {
const row = page.locator(`[data-example="${name}"]`);
const line = row.locator('[data-command="follow-up"]');
@@ -278,3 +298,44 @@ test("a follow-up sits under its prompt as a second line that wraps instead of s
expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(text);
}
});
+
+test("/skill, the page's old address, moves for good to /skills, and the examples stay where they were", async ({ page, request }) => {
+ const res = await request.get("/skill", { maxRedirects: 0 });
+ expect(res.status()).toBe(308);
+ expect(res.headers()["location"]).toBe("/skills");
+ await page.goto("/skill");
+ await expect(page).toHaveURL(/\/skills$/);
+ await expect(page.getByRole("heading", { level: 1 })).toHaveText("Make your own figure");
+ expect((await request.get("/skill/hairline-funnel.html", { maxRedirects: 0 })).status()).toBe(200);
+});
+
+test("the rail holds a group for each skill, and hairline-adopt's reaches its sections", async ({ page }) => {
+ await page.setViewportSize({ width: 1400, height: 900 });
+ await page.goto("/skills");
+ await expect(page.locator(".rail-title")).toHaveText(["hairline-create", "hairline-adopt"]);
+ for (const id of ["adopt-use", "adopt-how", "adopt-examples"]) await expect(page.locator(`#${id}`)).toHaveCount(1);
+ await expect(page.locator(".col-end").getByRole("link", { name: "hairline-adopt" })).toHaveAttribute("href", /\/tree\/main\/skills\/hairline-adopt$/);
+});
+
+test("the Linear issues glide while the pointer moves, in a frame that loaded late", async ({ page }) => {
+ await page.goto("/skills");
+ // read down the page, so the frame loads long after the page did, where a frame's clock lags performance.now()
+ const row = page.locator('[data-example="linear-cycle"]');
+ for (let i = 0; i < 40 && !(await row.isVisible() && (await row.boundingBox())!.y < 300); i++) {
+ await page.mouse.wheel(0, 500);
+ await page.waitForTimeout(150);
+ }
+ await row.scrollIntoViewIfNeeded();
+ const frame = row.frameLocator("iframe");
+ await expect(frame.locator("#stage svg")).toHaveCount(1);
+ const shapes = () => frame.locator("#stage svg").evaluate((svg) => [...svg.querySelectorAll("path")].map((p) => p.getAttribute("d")).join("|"));
+ const box = (await row.locator("iframe").boundingBox())!;
+ const at = (await frame.locator("#stage").boundingBox())!;
+ await page.mouse.move(box.x + 10, box.y + 10);
+ const rest = await shapes();
+ // up across the stripes, toward the disc, the way the mark moves; the cards leave while the pointer is still going
+ for (let k = 0; k <= 10; k++) await page.mouse.move(at.x + at.width * (0.3 + 0.04 * k), at.y + at.height * (0.8 - 0.05 * k), { steps: 2 });
+ await page.waitForTimeout(600);
+ expect(await shapes()).not.toBe(rest);
+});
+
diff --git a/apps/site/test/skill.test.ts b/apps/site/test/skill.test.ts
index e1e0e94..9a855f7 100644
--- a/apps/site/test/skill.test.ts
+++ b/apps/site/test/skill.test.ts
@@ -3,7 +3,7 @@ import { createHash } from "node:crypto";
import { readdirSync, readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
-import { COMMAND, EXAMPLES, INSTALL, declared, examples } from "@/lib/skill";
+import { ADOPT, ADOPTED, COMMAND, EXAMPLES, INSTALL, MARKS, declared, examples } from "@/lib/skill";
/**
* The showcase is the skill's own output: these fail if an example was edited (its hash is pinned in lib/skill.ts),
@@ -19,27 +19,24 @@ const MASTRA = "an empty state for \"No agents connected\", from Mastra's mark:
const NOTION = "an empty state for \"No pages inside\", from Notion's mark: the cube as a box with a lid, the N a relief on its front face; the pointer's height opens the lid on a spring, and the box is empty. Name it notion.";
describe("the skill's examples", () => {
- it("are the seven ideas, in page order", () => {
- expect(EXAMPLES.map((e) => e.idea)).toEqual([
- "a sales funnel",
- "a rate limiter",
- "git branches",
- "weather over a city",
- VERCEL,
- MASTRA,
- NOTION,
- ]);
+ it("are the four ideas, in page order", () => {
+ expect(EXAMPLES.map((e) => e.idea)).toEqual(["a sales funnel", "a rate limiter", "git branches", "weather over a city"]);
});
- it("are exactly the files in public/skill", () => {
- expect(EXAMPLES.map((e) => e.file).sort()).toEqual(readdirSync(PUBLIC).sort());
+ it("leave the three marks to the Figures page, which shows them", () => {
+ expect(MARKS.map((e) => e.idea)).toEqual([VERCEL, MASTRA, NOTION]);
+ expect(MARKS.map((e) => e.file)).toEqual(["hairline-vercel.html", "hairline-mastra.html", "hairline-notion.html"]);
});
- it.each(EXAMPLES)("$file is byte for byte the page the skill wrote", ({ file, sha256 }) => {
+ it("are, with the marks and hairline-adopt's, exactly the files in public/skill", () => {
+ expect([...EXAMPLES, ...MARKS, ...ADOPTED].map((e) => e.file).sort()).toEqual(readdirSync(PUBLIC).sort());
+ });
+
+ it.each([...EXAMPLES, ...MARKS, ...ADOPTED])("$file is byte for byte the page pinned", ({ file, sha256 }) => {
expect(createHash("sha256").update(readFileSync(PUBLIC + file)).digest("hex")).toBe(sha256);
});
- it.each(EXAMPLES)("$file passes the skill's validator untouched", ({ file }) => {
+ it.each([...EXAMPLES, ...MARKS, ...ADOPTED])("$file passes the skill's validator", ({ file }) => {
const run = spawnSync(process.execPath, [VALIDATE, PUBLIC + file], { encoding: "utf8" });
expect(run.stderr).toBe("");
expect(run.status).toBe(0);
@@ -61,9 +58,6 @@ describe("the skill's examples", () => {
"a rate limiter": undefined,
"git branches": "The rails almost disappear and the trains read as loose blocks. Make it read as a railway at a glance.",
"weather over a city": "The cloud looks like a stack of cylinders. Make it read as a cloud at a glance.",
- [VERCEL]: undefined,
- [MASTRA]: undefined,
- [NOTION]: undefined,
});
});
@@ -77,10 +71,29 @@ describe("the skill's examples", () => {
});
});
+describe("hairline-adopt's examples", () => {
+ it("are the rocket and three marks, each an SVG and then what the pointer does", () => {
+ expect(ADOPTED.map((e) => e.idea.split(" ")[0])).toEqual(["deploy.svg", "firecrawl.svg", "linear.svg", "cursor.svg"]);
+ for (const e of ADOPTED) expect(e.followUp).toBeUndefined();
+ });
+
+ it("each carry their file's name, a meaning, the adopt prompt and the link", () => {
+ for (const e of examples(ADOPTED, ADOPT)) {
+ expect(e.file).toBe(`hairline-${e.name}.html`);
+ expect(e.means.length).toBeGreaterThan(0);
+ expect(e.means.length).toBeLessThanOrEqual(140);
+ expect(e.prompt).toBe(`${ADOPT} ${e.idea}`);
+ expect(e.href).toBe(`/skill/${e.file}`);
+ }
+ });
+});
+
describe("the skill's commands", () => {
it("are the ones the skill is installed and called by", () => {
expect(INSTALL).toBe("npx skills add lucasmarkes/hairline");
expect(COMMAND).toBe("/hairline-create");
expect(readFileSync(fileURLToPath(new URL("../../../skills/hairline-create/SKILL.md", import.meta.url)), "utf8")).toContain("name: hairline-create");
+ expect(ADOPT).toBe("/hairline-adopt");
+ expect(readFileSync(fileURLToPath(new URL("../../../skills/hairline-adopt/SKILL.md", import.meta.url)), "utf8")).toContain("name: hairline-adopt");
});
});