Skip to content

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

Connectivity: a patch panel whose cables lift and lean, a dish the pointer aims, and a router whose antennas lean toward it

Lucas Marques72f3e45d009d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4b4828b..28651f4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -38,6 +38,15 @@ Every release of `@lucasmarkes/hairline`. The format follows
- `padlock` and `Padlock`: a padlock. As the pointer nears, the shackle
springs up out of the body and swings open about its long leg. A stronger
`intensity` swings the shackle further.
+- `patch` and `Patch`: a patch panel of twenty-four ports. The cable under the
+ pointer lifts, and its neighbours lean away, less the further away. A
+ stronger `intensity` spreads the lean over more ports.
+- `dish` and `Dish`: a parabolic dish on a two-axis gimbal. The pointer aims
+ it, and it follows on a spring. A stronger `intensity` swings the dish
+ further.
+- `router` and `Router`: a wifi router. Its antennas lean toward the pointer,
+ the nearest the most and the others less the further away. A stronger
+ `intensity` spreads the lean over more antennas.
## 0.1.0 - 2026-10-01
diff --git a/README.md b/README.md
index 9bddc74..f371b26 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# hairline
-Sixteen isometric line figures that answer the pointer. For React and for anything with a DOM.
+Nineteen isometric line figures that answer the pointer. For React and for anything with a DOM.
[![npm](https://img.shields.io/npm/v/@lucasmarkes/hairline)](https://www.npmjs.com/package/@lucasmarkes/hairline)
[![CI](https://github.com/lucasmarkes/hairline/actions/workflows/ci.yml/badge.svg)](https://github.com/lucasmarkes/hairline/actions/workflows/ci.yml)
@@ -71,6 +71,9 @@ A figure draws into the element you give it, at the element's width and a 5:4 as
| `vault` | `Vault` | A vault door with a dial and three bolts. The pointer turns the dial; detents catch every ten, and on the combination the bolts draw back. | The dial coasts longer. |
| `lockers` | `Lockers` | A bank of twelve lockers, one ajar at rest. The locker under the pointer opens; the one at rest closes. | The door opens wider. |
| `padlock` | `Padlock` | A padlock with its shackle in. As the pointer comes near the shackle lifts out and swings open. | The shackle swings further. |
+| `patch` | `Patch` | A patch panel of twenty-four ports with cables. The cable under the pointer lifts and its neighbours lean away. | The lean spreads further. |
+| `dish` | `Dish` | A parabolic dish on a two-axis gimbal. The pointer aims the dish; it follows on a spring. | The dish swings further. |
+| `router` | `Router` | A router with its antennas up. Each antenna leans toward the pointer, the nearest most. | The lean spreads further. |
## Options
@@ -114,7 +117,7 @@ The figure's styles have no specificity, so any rule of yours wins without `!imp
## Make your own
-`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 sixteen above, as one HTML file.
+`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 nineteen above, as one HTML file.
```sh
npx skills add lucasmarkes/hairline
diff --git a/apps/site/app/docs/sections.tsx b/apps/site/app/docs/sections.tsx
index dcbd060..fbf5cb6 100644
--- a/apps/site/app/docs/sections.tsx
+++ b/apps/site/app/docs/sections.tsx
@@ -1,5 +1,5 @@
import type { ReactNode } from "react";
-import { Branches, Cabinet, Elevator, Exploded, Keyboard, Laptop, Lockers, Padlock, Phone, Phosphor, Riffle, Slow, Terminal, Terrain, Turntable, Vault } from "@lucasmarkes/hairline/react";
+import { Branches, Cabinet, Dish, Elevator, Exploded, Keyboard, Laptop, Lockers, Padlock, Patch, Phone, Phosphor, Riffle, Router, Slow, Terminal, Terrain, Turntable, Vault } from "@lucasmarkes/hairline/react";
import { Anchor } from "@/components/anchor";
import { CodeBlock } from "@/components/code-block";
import { Install } from "@/components/install";
@@ -8,7 +8,7 @@ import { SECTIONS } from "@/lib/docs";
import { COUNT, FIGURES, INTENSITY, OPTIONS, THEME, measure } from "@/lib/figures";
import { PACKAGE } from "@/lib/snippets";
-const SMALL = { riffle: Riffle, terrain: Terrain, exploded: Exploded, phosphor: Phosphor, slow: Slow, turntable: Turntable, keyboard: Keyboard, elevator: Elevator, phone: Phone, laptop: Laptop, terminal: Terminal, cabinet: Cabinet, branches: Branches, vault: Vault, lockers: Lockers, padlock: Padlock };
+const SMALL = { riffle: Riffle, terrain: Terrain, exploded: Exploded, phosphor: Phosphor, slow: Slow, turntable: Turntable, keyboard: Keyboard, elevator: Elevator, phone: Phone, laptop: Laptop, terminal: Terminal, cabinet: Cabinet, branches: Branches, vault: Vault, lockers: Lockers, padlock: Padlock, patch: Patch, dish: Dish, router: Router };
/** A section takes its title from SECTIONS, the list the rail reads, so the two always agree. Its link copies from beside its title. */
function Section({ id, children }: { id: string; children: ReactNode }) {
diff --git a/apps/site/components/catalogue.tsx b/apps/site/components/catalogue.tsx
index b2f47b5..f7afa80 100644
--- a/apps/site/components/catalogue.tsx
+++ b/apps/site/components/catalogue.tsx
@@ -1,12 +1,12 @@
"use client";
import { useCallback, useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ReactNode } from "react";
-import { Branches, Cabinet, Elevator, Exploded, Keyboard, Laptop, Lockers, Padlock, Phone, Phosphor, Riffle, Slow, Terminal, Terrain, Turntable, Vault } from "@lucasmarkes/hairline/react";
+import { Branches, Cabinet, Dish, Elevator, Exploded, Keyboard, Laptop, Lockers, Padlock, Patch, Phone, Phosphor, Riffle, Router, Slow, Terminal, Terrain, Turntable, Vault } from "@lucasmarkes/hairline/react";
import { ENTRIES, SHELVES, type Entry, type Shelf, type ShelfId } from "@/lib/catalogue";
import { LINKS, type FigureId } from "@/lib/figures";
import { Tabs, type Tab } from "./tabs";
-const COMPONENTS: Record<FigureId, typeof Riffle> = { riffle: Riffle, terrain: Terrain, exploded: Exploded, phosphor: Phosphor, slow: Slow, turntable: Turntable, keyboard: Keyboard, elevator: Elevator, phone: Phone, laptop: Laptop, terminal: Terminal, cabinet: Cabinet, branches: Branches, vault: Vault, lockers: Lockers, padlock: Padlock };
+const COMPONENTS: Record<FigureId, typeof Riffle> = { riffle: Riffle, terrain: Terrain, exploded: Exploded, phosphor: Phosphor, slow: Slow, turntable: Turntable, keyboard: Keyboard, elevator: Elevator, phone: Phone, laptop: Laptop, terminal: Terminal, cabinet: Cabinet, branches: Branches, vault: Vault, lockers: Lockers, padlock: Padlock, patch: Patch, dish: Dish, router: Router };
type Filter = "all" | ShelfId;
diff --git a/apps/site/components/reel.tsx b/apps/site/components/reel.tsx
index a2ffb33..0941d73 100644
--- a/apps/site/components/reel.tsx
+++ b/apps/site/components/reel.tsx
@@ -1,10 +1,10 @@
"use client";
import { useEffect, useRef, useState, type CSSProperties } from "react";
-import { Branches, Cabinet, Elevator, Exploded, Keyboard, Laptop, Lockers, Padlock, Phone, Phosphor, Riffle, Slow, Terminal, Terrain, Turntable, Vault } from "@lucasmarkes/hairline/react";
+import { Branches, Cabinet, Dish, Elevator, Exploded, Keyboard, Laptop, Lockers, Padlock, Patch, Phone, Phosphor, Riffle, Router, Slow, Terminal, Terrain, Turntable, Vault } from "@lucasmarkes/hairline/react";
import { FIGURES } from "@/lib/figures";
-const COMPONENTS = { riffle: Riffle, terrain: Terrain, exploded: Exploded, phosphor: Phosphor, slow: Slow, turntable: Turntable, keyboard: Keyboard, elevator: Elevator, phone: Phone, laptop: Laptop, terminal: Terminal, cabinet: Cabinet, branches: Branches, vault: Vault, lockers: Lockers, padlock: Padlock };
+const COMPONENTS = { riffle: Riffle, terrain: Terrain, exploded: Exploded, phosphor: Phosphor, slow: Slow, turntable: Turntable, keyboard: Keyboard, elevator: Elevator, phone: Phone, laptop: Laptop, terminal: Terminal, cabinet: Cabinet, branches: Branches, vault: Vault, lockers: Lockers, padlock: Padlock, patch: Patch, dish: Dish, router: Router };
/**
* One pass of a pointer over each figure, in its viewBox (400 × 320): [x, y, ms]. Each path does the
@@ -27,6 +27,9 @@ const DEMO: Record<keyof typeof COMPONENTS, [number, number, number][]> = {
vault: [[214, 187, 0], [207, 216, 1100], [207, 216, 2300], [214, 187, 3400]],
lockers: [[200, 160, 0], [250, 230, 1800], [120, 110, 3200]],
padlock: [[40, 280, 0], [200, 170, 1500], [330, 100, 3000]],
+ patch: [[200, 160, 0], [120, 110, 1800], [230, 180, 3200]],
+ dish: [[100, 100, 0], [300, 100, 1200], [300, 250, 2400], [120, 240, 3500]],
+ router: [[80, 200, 0], [320, 200, 2000], [200, 120, 3200]],
};
/** Long enough for the slowest dissolve (the reel's own, 520ms) to finish before its leaver goes. */
diff --git a/apps/site/lib/catalogue.ts b/apps/site/lib/catalogue.ts
index 2a791ca..05289f5 100644
--- a/apps/site/lib/catalogue.ts
+++ b/apps/site/lib/catalogue.ts
@@ -65,9 +65,9 @@ export const SHELVES: Shelf[] = [
},
{
id: "connectivity", title: "Connectivity", color: "#ec4899", figures: [
- planned("patch", "Patch", "A patch panel of twenty-four ports with cables. The cable under the pointer lifts and its neighbours lean away.", "The lean spreads further."),
- planned("dish", "Dish", "A parabolic dish on a two-axis gimbal. The pointer aims the dish; it follows on a spring.", "The dish swings further."),
- planned("router", "Router", "A router with its antennas up. Each antenna leans toward the pointer, the nearest most.", "The lean spreads further."),
+ drawn("patch"),
+ drawn("dish"),
+ drawn("router"),
],
},
];
diff --git a/apps/site/lib/figures.ts b/apps/site/lib/figures.ts
index e25d737..e2e2be3 100644
--- a/apps/site/lib/figures.ts
+++ b/apps/site/lib/figures.ts
@@ -8,7 +8,7 @@
import { spell } from "./words";
-export type FigureId = "riffle" | "terrain" | "exploded" | "phosphor" | "slow" | "turntable" | "keyboard" | "elevator" | "phone" | "laptop" | "terminal" | "cabinet" | "branches" | "vault" | "lockers" | "padlock";
+export type FigureId = "riffle" | "terrain" | "exploded" | "phosphor" | "slow" | "turntable" | "keyboard" | "elevator" | "phone" | "laptop" | "terminal" | "cabinet" | "branches" | "vault" | "lockers" | "padlock" | "patch" | "dish" | "router";
export type FigureDoc = {
id: FigureId;
@@ -134,9 +134,30 @@ export const FIGURES: FigureDoc[] = [
stronger: "The shackle swings further.",
parameter: { name: "swing", unit: "degrees" },
},
+ {
+ id: "patch",
+ name: "Patch",
+ summary: "A patch panel of twenty-four ports with cables. The cable under the pointer lifts and its neighbours lean away.",
+ stronger: "The lean spreads further.",
+ parameter: { name: "radius", unit: "ports" },
+ },
+ {
+ id: "dish",
+ name: "Dish",
+ summary: "A parabolic dish on a two-axis gimbal. The pointer aims the dish; it follows on a spring.",
+ stronger: "The dish swings further.",
+ parameter: { name: "reach", unit: "degrees" },
+ },
+ {
+ id: "router",
+ name: "Router",
+ summary: "A router with its antennas up. Each antenna leans toward the pointer, the nearest most.",
+ stronger: "The lean spreads further.",
+ parameter: { name: "spread", unit: "antennas" },
+ },
];
-/** How many figures the package has, as the prose writes it: "sixteen". */
+/** How many figures the package has, as the prose writes it: "nineteen". */
export const COUNT = spell(FIGURES.length);
/** Each figure's number at intensity 0, 0.5 and 1: a copy of the package's table. */
@@ -157,6 +178,9 @@ export const INTENSITY: Record<FigureId, readonly [number, number, number]> = {
vault: [250, 600, 1500],
lockers: [55, 90, 120],
padlock: [45, 90, 100],
+ patch: [1, 2.5, 5],
+ dish: [30, 50, 70],
+ router: [0.5, 1.5, 3],
};
/** A number with its unit, as the docs' table and /llms.txt write it: "40 ms", "0.2× normal speed". */
diff --git a/apps/site/test/figures.spec.ts b/apps/site/test/figures.spec.ts
index 034798b..5918748 100644
--- a/apps/site/test/figures.spec.ts
+++ b/apps/site/test/figures.spec.ts
@@ -16,21 +16,20 @@ function watch(page: Page): string[] {
const tiles = (page: Page) => page.locator(".fig-tile");
const shelf = (page: Page, name: string) => page.locator(".shelves .shelf", { hasText: name });
-test("/figures prerenders sixteen empty boxes among nineteen tiles, then draws them with a clean console", async ({ page, request }) => {
+test("/figures prerenders nineteen empty boxes among nineteen tiles, then draws them with a clean console", async ({ page, request }) => {
const html = await (await request.get("/figures")).text();
- expect(html.match(/<div style="aspect-ratio:5 \/ 4"><\/div>/g)).toHaveLength(16);
+ expect(html.match(/<div style="aspect-ratio:5 \/ 4"><\/div>/g)).toHaveLength(19);
expect(html.match(/class="fig-tile"/g)).toHaveLength(19);
- expect(html.match(/class="fig-tile" data-planned=""/g)).toHaveLength(3);
+ expect(html).not.toContain("data-planned");
const noise = watch(page);
await page.goto("/figures");
await expect(tiles(page)).toHaveCount(19);
- await expect(page.locator(".fig-tile [data-hairline] > svg")).toHaveCount(16);
- await expect(page.locator(".fig-tile .fig-ghost")).toHaveCount(3);
+ await expect(page.locator(".fig-tile [data-hairline] > svg")).toHaveCount(19);
+ await expect(page.locator(".fig-tile .fig-ghost, .fig-tile[data-planned]")).toHaveCount(0);
await expect(page.locator("h1")).toHaveText("Every figure, by what it draws.");
await expect(page.locator(".doc-section h2")).toHaveText(SHELVES);
await expect(page.locator(".fig-name").first()).toHaveAccessibleName("Exploded");
- await expect(page.locator(".fig-tile[data-planned] .fig-name").first()).toHaveAccessibleName("Patch, planned");
expect(noise).toEqual([]);
});
@@ -120,19 +119,6 @@ test("picking a figure opens the drawer: the figure large, the slider, what it r
expect(noise).toEqual([]);
});
-test("a planned figure's drawer has its outline and a link to ask for it, and no code", async ({ page }) => {
- await page.goto("/figures");
- await page.locator(".fig-name", { hasText: "Patch" }).click();
- const drawer = page.locator("#figure-drawer");
- await expect(drawer).toHaveAttribute("data-open", "");
- await expect(drawer.locator(".detail-tag")).toHaveText("planned");
- await expect(drawer.locator(".fig-ghost")).toHaveCount(1);
- await expect(drawer.locator(".code, input[type=range]")).toHaveCount(0);
- await expect(drawer.getByRole("link", { name: "Request on GitHub" })).toHaveAttribute("href", "https://github.com/lucasmarkes/hairline/issues/new?title=Figure%3A%20Patch");
- await drawer.locator(".detail-close").click();
- await expect(drawer).not.toHaveAttribute("data-open");
-});
-
test("closing the drawer returns focus to the tile's button, with its ring for the keyboard alone", async ({ page }) => {
await page.goto("/figures");
const drawer = page.locator("#figure-drawer");
diff --git a/apps/site/test/site.spec.ts b/apps/site/test/site.spec.ts
index 476d1ca..31a1e52 100644
--- a/apps/site/test/site.spec.ts
+++ b/apps/site/test/site.spec.ts
@@ -1,6 +1,6 @@
import { expect, test, type Page } from "@playwright/test";
-const IDS = ["riffle", "terrain", "exploded", "phosphor", "slow", "turntable", "keyboard", "elevator", "phone", "laptop", "terminal", "cabinet", "branches", "vault", "lockers", "padlock"];
+const IDS = ["riffle", "terrain", "exploded", "phosphor", "slow", "turntable", "keyboard", "elevator", "phone", "laptop", "terminal", "cabinet", "branches", "vault", "lockers", "padlock", "patch", "dish", "router"];
const MANAGERS = [
["npm", "npm i @lucasmarkes/hairline"],
["pnpm", "pnpm add @lucasmarkes/hairline"],
@@ -288,9 +288,9 @@ const BASE = "http://localhost:3000";
test("a pasted link shows the page it leads to: each page's card has its own title, text and address", async ({ request }) => {
const CARDS = [
- ["/", "hairline", /^Sixteen isometric line figures/],
+ ["/", "hairline", /^Nineteen isometric line figures/],
["/figures", "Figures", /^Seven shelves, nineteen figures, grouped by what they draw/],
- ["/docs", "Docs", /^Sixteen isometric line figures/],
+ ["/docs", "Docs", /^Nineteen isometric line figures/],
["/skill", "Make your own figure", /^hairline-create is a skill/],
["/inspo", "How Hairline was made", /^A long brief/],
] as const;
diff --git a/fixtures/vite-vanilla/index.html b/fixtures/vite-vanilla/index.html
index 1eed51d..59afff4 100644
--- a/fixtures/vite-vanilla/index.html
+++ b/fixtures/vite-vanilla/index.html
@@ -27,6 +27,9 @@
<div id="vault"></div>
<div id="lockers"></div>
<div id="padlock"></div>
+ <div id="patch"></div>
+ <div id="dish"></div>
+ <div id="router"></div>
</main>
<output id="read"></output>
<script type="module" src="/src/main.ts"></script>
diff --git a/fixtures/vite-vanilla/src/main.ts b/fixtures/vite-vanilla/src/main.ts
index cb6ab07..fedad49 100644
--- a/fixtures/vite-vanilla/src/main.ts
+++ b/fixtures/vite-vanilla/src/main.ts
@@ -1,6 +1,6 @@
-import { branches, cabinet, elevator, exploded, keyboard, laptop, lockers, padlock, phone, phosphor, riffle, slow, terminal, terrain, turntable, vault, type Figure } from "@lucasmarkes/hairline";
+import { branches, cabinet, dish, elevator, exploded, keyboard, laptop, lockers, padlock, patch, phone, phosphor, riffle, router, slow, terminal, terrain, turntable, vault, type Figure } from "@lucasmarkes/hairline";
-/** No framework: sixteen elements, sixteen calls. */
+/** No framework: nineteen elements, nineteen calls. */
const el = (id: string) => document.getElementById(id)!;
const read = el("read");
@@ -23,5 +23,8 @@ branches(el("branches"));
vault(el("vault"));
lockers(el("lockers"));
padlock(el("padlock"));
+patch(el("patch"));
+dish(el("dish"));
+router(el("router"));
cards.update({ intensity: 0.8 });
diff --git a/package.json b/package.json
index 7c98aab..3389c1a 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "hairline-monorepo",
"version": "0.0.0",
"private": true,
- "description": "Sixteen isometric line figures that answer the pointer",
+ "description": "Nineteen isometric line figures that answer the pointer",
"packageManager": "[email protected]",
"engines": {
"node": ">=22"
diff --git a/packages/hairline/package.json b/packages/hairline/package.json
index 92273e5..1ea6924 100644
--- a/packages/hairline/package.json
+++ b/packages/hairline/package.json
@@ -1,7 +1,7 @@
{
"name": "@lucasmarkes/hairline",
"version": "0.2.0",
- "description": "Sixteen isometric line figures that answer the pointer. For React and for anything with a DOM.",
+ "description": "Nineteen isometric line figures that answer the pointer. For React and for anything with a DOM.",
"license": "MIT",
"type": "module",
"sideEffects": false,
@@ -83,7 +83,7 @@
{
"name": "vanilla, every figure",
"path": "dist/index.js",
- "limit": "23.8 kB"
+ "limit": "27.6 kB"
},
{
"name": "vanilla, one figure",
@@ -94,7 +94,7 @@
{
"name": "react, every component",
"path": "dist/react.js",
- "limit": "24.1 kB",
+ "limit": "28.1 kB",
"ignore": [
"react",
"react/jsx-runtime"
diff --git a/packages/hairline/src/figures/dish.ts b/packages/hairline/src/figures/dish.ts
new file mode 100644
index 0000000..573c4c4
--- /dev/null
+++ b/packages/hairline/src/figures/dish.ts
@@ -0,0 +1,186 @@
+import { Cam, circ, facing, fit, hull, open, poly, prism, proj, rad, ringAt, rings, rrect, run, seg, type Ring, type Vec2, type Vec3 } from "../core/iso";
+import { spring, stepS } from "../core/motion";
+import { disposer, flatDot, mk, place, pointer, put, register, solid, type FigureMount, type Solid } from "../core/stage";
+
+/**
+ * Dish: a parabolic dish on a two-axis gimbal. A base plate engraved with an
+ * azimuth scale, a turntable with an index dot, and a yoke whose two arms hold
+ * the elevation axis; the dish hangs on it by two trunnions at its rim, with a
+ * feed horn on three struts at its focus. The pointer aims the dish, as if it
+ * stood in front of the screen: azimuth and elevation each ride a spring. The
+ * bowl's outline is computed at every pose: the rim circle projected, and the
+ * hull of the rim and the back. The reach is clamped so the dish always shows
+ * its inside. At rest it looks off to the right, rim bright. The slider is the
+ * azimuth reach, in degrees; elevation reaches half of it.
+ *
+ * The pattern: a continuous aim. Two springs, a clamped reach, a hit test that
+ * reads only the pointer, and a paint order fixed by separating planes.
+ */
+
+const R = 26, FOC = 17, SK = 1.4, DEP = (R * R) / (4 * FOC), ZE = 46, W = 31, T = 5, ZB = 10, ZY = 16;
+const AZ0 = 45, EL0 = 40, REST = [-20, 30], PIV: Vec3 = [0, 0, ZE];
+const ax = (p: Vec3, q: Vec3, s: number): Vec3 => [p[0] + q[0] * s, p[1] + q[1] * s, p[2] + q[2] * s];
+const dot3 = (p: Vec3, q: Vec3) => p[0] * q[0] + p[1] * q[1] + p[2] * q[2];
+
+type Frame = { th: number; h: Vec3; e: Vec3; a: Vec3; u: Vec3 };
+/** An aim's frame: h and e on the ground (e is the elevation axis), a the dish's axis, u the rim's up. */
+function frame(th: number, ph: number): Frame {
+ const t = rad(th), f = rad(ph), c = Math.cos(f), s = Math.sin(f);
+ const h: Vec3 = [Math.cos(t), Math.sin(t), 0], e: Vec3 = [-Math.sin(t), Math.cos(t), 0];
+ return { th, h, e, a: [h[0] * c, h[1] * c, s], u: [-h[0] * s, -h[1] * s, c] };
+}
+/** A point of the dish: `along` its axis from the rim's centre, rho out from it at angle psi. */
+const onDish = (F: Frame, along: number, rho: number, psi: number) => ax(ax(ax(PIV, F.a, along), F.e, rho * Math.cos(psi)), F.u, rho * Math.sin(psi));
+/** A circle of n points about centre c, in the plane of x and y. */
+const disc = (c: Vec3, x: Vec3, y: Vec3, r: number, n: number) => Array.from({ length: n }, (_, i) => ax(ax(c, x, r * Math.cos((2 * Math.PI * i) / n)), y, r * Math.sin((2 * Math.PI * i) / n)));
+/** A ring drawn in the (h, e) frame turned onto the ground. */
+const turn = (ring: Ring, F: Frame): Ring => ring.map((q) => ({
+ u: q.u * F.h[0] + q.v * F.e[0], v: q.u * F.h[1] + q.v * F.e[1], nu: q.nu * F.h[0] + q.nv * F.e[0], nv: q.nu * F.h[1] + q.nv * F.e[1],
+}));
+
+type Side = {
+ s: number; g: SVGGElement; near: boolean | null;
+ ring: SVGPathElement; arm: Solid; trun: SVGPathElement;
+ foot: Ring; top: Ring; inner: Ring;
+};
+
+export const mount: FigureMount = ({ stage, svg, read }, value) => {
+ const bag = disposer();
+ let reach = value, over: Vec2 | null = null;
+
+ // Fitted to the four corners of the widest reach, and rest, so nothing leaves the frame.
+ const C = Cam(45, 0.5, 2.5), pts: Vec3[] = [[-30, -30, 0], [30, 30, 0], [30, -30, 0], [-30, 30, 0]];
+ for (const [th, ph] of [[-25, 5], [-25, 75], [115, 5], [115, 75], REST]) {
+ const F = frame(th, ph);
+ pts.push(...disc(PIV, F.e, F.u, R, 16), onDish(F, FOC - DEP + 3, 0, 0));
+ for (const s of [-1, 1]) pts.push(ax(ax(PIV, F.e, s * (W + T / 2)), [0, 0, 1], 6));
+ }
+ fit(C, pts, 200, 166);
+ const P = proj(C), front = facing(C), Pv = (q: Vec3) => P(q[0], q[1], q[2]);
+ // the direction toward the camera, from the projection itself
+ const o = P(0, 0, 0), cx = P(1, 0, 0), cy = P(0, 1, 0), cz = P(0, 0, 1);
+ const r1 = [cx[0] - o[0], cy[0] - o[0], cz[0] - o[0]], r2 = [cx[1] - o[1], cy[1] - o[1], cz[1] - o[1]];
+ const cross: Vec3 = [r1[1] * r2[2] - r1[2] * r2[1], r1[2] * r2[0] - r1[0] * r2[2], r1[0] * r2[1] - r1[1] * r2[0]];
+ const vl = Math.hypot(...cross) * Math.sign(cross[2]);
+ const VD = cross.map((x) => x / vl) as Vec3;
+
+ // Static, back to front: the base, its azimuth scale, the turntable.
+ const g = mk("g", {}, svg);
+ const [br, bi] = rings(-30, -30, 30, 30, 9, 2);
+ put(solid(g), prism(P, front, br, bi, 0, 5));
+ for (let i = 0; i < 36; i++) {
+ const t = (i / 36) * 2 * Math.PI, r = i % 9 === 0 ? 26.5 : 25.5;
+ place(flatDot(g, C, i % 9 === 0 ? 0.75 : 0.5, "dot off"), P(r * Math.cos(t), r * Math.sin(t), 5));
+ }
+ put(solid(g), prism(P, front, circ(20, 48), circ(18.8, 48), 5, ZB));
+ const index = flatDot(g, C, 0.8, "dot m");
+
+ // Turning with the azimuth: the yoke's beam, then each side's arm, bearing and trunnion, in an order set per frame.
+ const beam = solid(g);
+ const yb = W + T / 2 + 1, [bmr, bmi] = rings(-9, -yb, 9, yb, 4, 1.4);
+ const dishG = mk("g", {}, g);
+ const sides: Side[] = [-1, 1].map((s) => {
+ const sg = mk("g", {}, g);
+ return {
+ s, g: sg, near: null,
+ ring: mk("path", { class: "nf" }, sg), arm: solid(sg), trun: mk("path", { class: "sil" }, sg),
+ foot: rrect(-8, s * W - T / 2, 8, s * W + T / 2, 2.5, 4),
+ top: rrect(-5.5, s * W - T / 2, 5.5, s * W + T / 2, 2.5, 4),
+ inner: rrect(-4.5, s * W - T / 2 + 1, 4.5, s * W + T / 2 - 1, 1.5, 4),
+ };
+ });
+
+ // The dish: its outline, a panel seam and the hub at its vertex seen through the aperture, the rim, the struts, the feed.
+ const outline = mk("path", { class: "sil" }, dishG), seam = mk("path", { class: "nf lo" }, dishG), hubR = mk("path", { class: "nf lo" }, dishG);
+ const rim = mk("path", { class: "nf hi" }, dishG), struts = mk("path", { class: "nf" }, dishG);
+ const feed = solid(dishG);
+ const BACK = [0, 0.35, 0.6, 0.78, 0.9, 0.97, 1];
+
+ /** The seam at rho: the run of it seen through the aperture, its ends cut where the sight line meets the rim. */
+ function seen(F: Frame, rho: number, n: number) {
+ const along = (rho * rho) / (4 * FOC) - DEP, t = -along / dot3(F.a, VD), q: Vec3[] = [], s: number[] = [];
+ for (let i = 0; i < n; i++) {
+ q.push(onDish(F, along, rho, (2 * Math.PI * i) / n));
+ const hit = ax(q[i], VD, t);
+ s.push(R - Math.hypot(hit[0] - PIV[0], hit[1] - PIV[1], hit[2] - PIV[2]));
+ }
+ if (s.every((x) => x > 0)) return poly(q.map(Pv));
+ const i0 = s.findIndex((x, i) => x > 0 && s[(i + n - 1) % n] <= 0);
+ if (i0 < 0) return "";
+ const cut = (i: number, j: number) => Pv(ax(q[i], [q[j][0] - q[i][0], q[j][1] - q[i][1], q[j][2] - q[i][2]], s[i] / (s[i] - s[j])));
+ const out = [cut((i0 + n - 1) % n, i0)];
+ let i = i0;
+ while (s[i] > 0) { out.push(Pv(q[i])); i = (i + 1) % n; }
+ out.push(cut((i + n - 1) % n, i));
+ return open(out);
+ }
+
+ let drawn = "";
+ function draw(th: number, ph: number) {
+ const key = th.toFixed(3) + "," + ph.toFixed(3);
+ if (key === drawn) return;
+ drawn = key;
+ const F = frame(th, ph);
+ place(index, P(18 * F.h[0], 18 * F.h[1], ZB));
+ put(beam, prism(P, front, turn(bmr, F), turn(bmi, F), ZB, ZY));
+ // a side whose outer face looks at the camera paints after the dish, inside out; the other before it, outside in
+ for (const sd of sides) {
+ const near = sd.s * dot3(F.e, VD) > 0;
+ if (near !== sd.near) {
+ sd.near = near;
+ if (near) { sd.g.append(sd.trun, sd.arm.g, sd.ring); dishG.after(sd.g); }
+ else { sd.g.append(sd.ring, sd.arm.g, sd.trun); dishG.before(sd.g); }
+ }
+ put(sd.arm, {
+ sil: poly(hull(ringAt(P, turn(sd.foot, F), ZY).concat(ringAt(P, turn(sd.top, F), ZE + 6)))),
+ crease: open(ringAt(P, run(turn(sd.inner, F), front), ZE + 6)),
+ });
+ const zz: Vec3 = [0, 0, 1], out = ax(PIV, F.e, sd.s * (W + T / 2));
+ sd.ring.setAttribute("d", poly(disc(out, F.h, zz, 3.4, 24).map(Pv)));
+ sd.trun.setAttribute("d", poly(hull(disc(ax(PIV, F.e, sd.s * R), F.h, zz, 2.2, 16).concat(disc(ax(PIV, F.e, sd.s * (W - T / 2)), F.h, zz, 2.2, 16)).map(Pv))));
+ }
+ // the bowl: its outline is the hull of the rim and the back, a skin SK thick; the rim is all seen, as the reach keeps the inside to the camera
+ const lip = disc(PIV, F.e, F.u, R, 72), back: Vec3[] = [];
+ for (const f of BACK) for (let i = 0; i < 40; i++) back.push(onDish(F, (f * f * R * R) / (4 * FOC) - DEP - SK, f * R, (2 * Math.PI * i) / 40));
+ outline.setAttribute("d", poly(hull(lip.concat(back).map(Pv))));
+ seam.setAttribute("d", seen(F, 0.62 * R, 48));
+ hubR.setAttribute("d", seen(F, 3.2, 20));
+ rim.setAttribute("d", poly(lip.map(Pv)));
+ const mouth = onDish(F, FOC - DEP - 3, 0, 0), tail = onDish(F, FOC - DEP + 3, 0, 0);
+ struts.setAttribute("d", [90, 210, 330].map((d) => seg(Pv(onDish(F, 0, R, rad(d))), Pv(mouth))).join(""));
+ put(feed, {
+ sil: poly(hull(disc(mouth, F.e, F.u, 3.6, 16).concat(disc(tail, F.e, F.u, 2.4, 16)).map(Pv))),
+ crease: poly(disc(tail, F.e, F.u, 1.3, 16).map(Pv)),
+ });
+ }
+
+ const az = spring(REST[0], { eps: 0.01 }), el = spring(REST[1], { eps: 0.01 });
+ const B = register(stage, (dt) => {
+ const a = stepS(az, dt), b = stepS(el, dt);
+ draw(az.x, el.x);
+ return a || b;
+ });
+ bag.add(B.unregister);
+
+ // The aim reads only the pointer's offset from the axis on screen, never what is drawn: nothing can flicker.
+ const hub = P(0, 0, ZE);
+ function retarget() {
+ if (over) {
+ az.t = AZ0 - reach * Math.tanh((over[0] - hub[0]) / 120);
+ el.t = EL0 + (reach / 2) * Math.tanh((hub[1] - over[1]) / 90);
+ read.textContent = `az ${Math.round((az.t + 360) % 360)} · el ${Math.round(el.t)}`;
+ } else { az.t = REST[0]; el.t = REST[1]; read.textContent = "rest"; }
+ B.wake();
+ }
+
+ bag.add(pointer(stage, {
+ move: (p) => { over = p; retarget(); },
+ leave: () => { over = null; retarget(); },
+ }));
+ bag.add(() => svg.replaceChildren());
+
+ return {
+ set: (v) => { reach = v; if (over) retarget(); },
+ destroy: bag.dispose,
+ };
+};
diff --git a/packages/hairline/src/figures/patch.ts b/packages/hairline/src/figures/patch.ts
new file mode 100644
index 0000000..8ea339d
--- /dev/null
+++ b/packages/hairline/src/figures/patch.ts
@@ -0,0 +1,198 @@
+import { Cam, clamp, facing, fillet, fit, hull, open, poly, prism, proj, rings, rrect, run, seg, type Ring, type Sample, type Vec2, type Vec3 } from "../core/iso";
+import { spring, stepS, type Spring } from "../core/motion";
+import { disposer, mk, pointer, put, register, solid, type FigureMount, type Solid } from "../core/stage";
+
+/**
+ * Patch: a 2U rack patch panel, its face plate running out past a shallow body
+ * into two rack ears, each with two screw slots. Twenty-four RJ45 jacks sit in
+ * two modules of six by two, each jack a rectangle with the latch's notch on
+ * top. Twenty-one hold a plug, a tapered boot and a short cable: the top row's
+ * cables rise, the bottom row's hang. The pointer is put on the plane of the
+ * plugs at rest; the cable under it lifts, its plug half out of the jack, and
+ * its neighbours lean away from it, less the further away, each on its own
+ * springs. At rest, port 08 is caught half out, bright. The slider is the
+ * falloff radius, in ports.
+ *
+ * The pattern: a continuous field over discrete parts, as Keyboard's: a spring
+ * per number, a falloff by distance, a hit test on a fixed plane at rest.
+ */
+
+const NC = 12, PITCH = 15, GAP = 8, EAR = 15, MAR = 5, H = 44, T = 2.6, DEEP = 18;
+const X0 = EAR + MAR, W = 2 * X0 + NC * PITCH + GAP, ZT = 30, ZB = 12.5;
+const JW = 5, JH = 4.2, NW = 1.9, NH = 1.7, JD = 2.4;
+const PW = 4.3, PH = 3.5, PL = 4, BL = 5, CR = 1.8, OUT = 6, LEAN = 10, LZ = 7, LIFT = 9;
+const EMPTY = [2, 10, 18], REST = 7, HIT_Y = 2.5;
+/** Small irregularities, so no two cables at rest hang alike: [x, z] at the tip. */
+const JIT = (p: number): Vec2 => [((p * 7) % 5) - 2, ((p * 11) % 7) - 3];
+
+/** The share of the full lean a cable takes, d ports from the one lifted: all of it next door, none past R more. */
+const falloff = (d: number, R: number) => (d === 0 ? 0 : clamp(1 - (d - 1) / R, 0, 1));
+
+type Port = {
+ p: number; r: number; c: number; cx: number; cz: number; full: boolean;
+ jack: SVGPathElement; pull: Spring; lx: Spring; lz: Spring; drawn: string;
+ plug: Solid; latch: SVGPathElement; boot: Solid; cable: SVGPathElement;
+};
+
+/** A closed tube round a run of screen points, w wide each side, with a round cap at each end. */
+function tube(q: readonly Vec2[], w: number): string {
+ const n = q.length, L: Vec2[] = [], Rt: Vec2[] = [], nrm: Vec2[] = [];
+ for (let i = 0; i < n; i++) {
+ const a = q[Math.max(0, i - 1)], b = q[Math.min(n - 1, i + 1)], l = Math.hypot(b[0] - a[0], b[1] - a[1]) || 1;
+ const t: Vec2 = [(b[0] - a[0]) / l, (b[1] - a[1]) / l];
+ nrm.push(t);
+ L.push([q[i][0] - t[1] * w, q[i][1] + t[0] * w]); Rt.push([q[i][0] + t[1] * w, q[i][1] - t[0] * w]);
+ }
+ const cap = (c: Vec2, t: Vec2, s: number): Vec2[] => {
+ const out: Vec2[] = [];
+ for (let k = 1; k < 6; k++) {
+ const th = (k / 6) * Math.PI, cs = Math.cos(th), sn = Math.sin(th);
+ out.push([c[0] + s * w * (-t[1] * cs + t[0] * sn), c[1] + s * w * (t[0] * cs + t[1] * sn)]);
+ }
+ return out;
+ };
+ return poly([...L, ...cap(q[n - 1], nrm[n - 1], 1), ...Rt.reverse(), ...cap(q[0], nrm[0], -1)]);
+}
+
+export const mount: FigureMount = ({ stage, svg, read }, value) => {
+ const bag = disposer();
+ const S = 1.5, C = Cam(45, 0.5, S);
+ const tipZ = ZT + 27 + LIFT + LZ, lowZ = ZB - 26 - LZ;
+ fit(C, [[0, -DEEP, H], [W, -DEEP, H], [0, 0, 0], [W, 0, 0], [X0, 34, tipZ], [W - X0, 34, lowZ], [X0, 34, lowZ]], 200, 166);
+ const P = proj(C), front = facing(C);
+ let R = value, over = -1, lit: Port | null = null;
+
+ /** A ring standing in the x–z plane, projected at depth y; `seen` keeps the sides of a solid along y that face the camera. */
+ const at = (ring: Ring, cx: number, y: number, cz: number) => ring.map((q) => P(cx + q.u, y, cz + q.v));
+ const seen = (q: Sample) => 0.612 * q.nu + 0.5 * q.nv > 0;
+ const slab = (ring: Ring, inner: Ring, cx: number, cz: number, y0: number, y1: number) => ({
+ sil: poly(hull(at(ring, cx, y0, cz).concat(at(ring, cx, y1, cz)))),
+ crease: open(at(run(inner, seen), cx, y1, cz)),
+ });
+
+ const g = mk("g", {}, svg);
+ // the body behind the plate, narrower than it, so the plate's ends stand out as ears
+ const [br, bi] = rings(EAR + 2, -DEEP, W - EAR - 2, -T, 3, 1.6);
+ put(solid(g), prism(P, front, br, bi, 3, H - 3));
+ put(solid(g), slab(rrect(0, 0, W, H, 3, 4), rrect(0.7, 0.7, W - 0.7, H - 0.7, 2.3, 4), 0, 0, -T, 0));
+ const flat = (ring: Ring): Vec2[] => ring.map((q) => [q.u, q.v]);
+ const face = (pts: Vec2[], cls: string) => mk("path", { d: poly(pts.map(([x, z]) => P(x, 0, z))), class: cls }, g);
+ for (const ex of [EAR / 2 + 1, W - EAR / 2 - 1]) for (const ez of [8, H - 8]) {
+ face(flat(rrect(ex - 3.4, ez - 1.5, ex + 3.4, ez + 1.5, 1.5, 3)), "nf");
+ }
+
+ const ports = [] as Port[];
+ for (let p = 0; p < 2 * NC; p++) {
+ const r = p < NC ? 0 : 1, c = p % NC;
+ ports.push({ p, r, c, cx: X0 + (c + 0.5) * PITCH + (c >= 6 ? GAP : 0), cz: r ? ZB : ZT, full: !EMPTY.includes(p) } as Port);
+ }
+ // two modules, six by two
+ for (const m of [0, 6]) {
+ const a = ports[m].cx - PITCH / 2 + 1, b = ports[m + 5].cx + PITCH / 2 - 1;
+ face(flat(rrect(a, ZB - JH - 3, b, ZT + JH + NH + 2.6, 2.4, 4)), "lo nf");
+ }
+ // each jack: its opening with the latch's notch, and the far wall seen through it
+ const jack = fillet([[-JW, -JH], [JW, -JH], [JW, JH], [NW, JH], [NW, JH + NH], [-NW, JH + NH], [-NW, JH], [-JW, JH]], [1, 1, 1, 0.4, 0.5, 0.5, 0.4, 1]);
+ for (const pt of ports) {
+ const { cx, cz } = pt, d = JD;
+ pt.jack = face(jack.map(([u, v]): Vec2 => [cx + u, cz + v]), "nf");
+ mk("path", { d: open(([[-JW + d, JH], [-JW + d, -JH + 0.816 * d], [JW, -JH + 0.816 * d]] as Vec2[]).map(([u, v]) => P(cx + u, 0, cz + v))), class: "lo nf" }, g);
+ }
+
+ // plugs and boots, then the cables in front of them, each painted left to right
+ const plugG = mk("g", {}, g), cabG = mk("g", {}, g);
+ const plug = rrect(-PW, -PH, PW, PH, 1.2, 3), plugIn = rrect(-PW + 0.7, -PH + 0.7, PW - 0.7, PH - 0.7, 0.6, 3);
+ const bootA = rrect(-3.7, -3, 3.7, 3, 1.6, 3), bootB = rrect(-2.4, -2.4, 2.4, 2.4, 2.3, 3);
+ const order = ports.slice().sort((a, b) => a.c - b.c || a.r - b.r);
+ for (const pt of order) {
+ pt.pull = spring(0, { eps: 0.002 }); pt.lx = spring(0, { eps: 0.01 }); pt.lz = spring(0, { eps: 0.01 });
+ if (!pt.full) continue;
+ pt.plug = solid(plugG); pt.latch = mk("path", { class: "lo nf" }, pt.plug.g); pt.boot = solid(plugG);
+ pt.cable = mk("path", { class: "sil" }, cabG);
+ pt.drawn = "";
+ }
+
+ function drawPort(pt: Port) {
+ const k = pt.pull.x, lx = pt.lx.x, lz = pt.lz.x, key = [k, lx, lz].map((v) => v.toFixed(3)).join();
+ if (key === pt.drawn) return;
+ pt.drawn = key;
+ const { cx, cz, r, p } = pt, y1 = PL + OUT * k, y2 = y1 + BL, up = r ? -1 : 1, [jx, jz] = JIT(p);
+ put(pt.plug, slab(plug, plugIn, cx, cz, 0, y1));
+ pt.latch.setAttribute("d", seg(P(cx, 0.6, cz + PH), P(cx, y1 - 0.8, cz + PH)));
+ put(pt.boot, { sil: poly(hull(at(bootA, cx, y1, cz).concat(at(bootB, cx, y2, cz)))), crease: "" });
+ // the cable: out of the boot along y, then bending up (top row) or down (bottom row)
+ // a rising cable leaves its boot upwards, so it climbs between two jacks; a hanging one sags out first
+ const out = r ? 6 : 2, lean = r ? 2 : 3;
+ const p0: Vec3 = [cx, y2 - 1.5, cz], p1: Vec3 = r ? [cx + 0.5, y2 + out + 4 * k, cz] : [cx, y2 + 1 + 2 * k, cz + 6];
+ const p3: Vec3 = [cx + lean + jx + lx, y2 + out + 1 + LIFT * k, cz + up * (24 + jz) + lz + LIFT * k], p2: Vec3 = [p3[0] - 0.6, p3[1] - 1, p3[2] - up * 12];
+ const q: Vec2[] = [];
+ for (let i = 0; i <= 16; i++) {
+ const s = i / 16, a = (1 - s) ** 3, b = 3 * (1 - s) ** 2 * s, c = 3 * (1 - s) * s * s, d = s ** 3;
+ q.push(P(...([0, 1, 2].map((j) => a * p0[j] + b * p1[j] + c * p2[j] + d * p3[j]) as Vec3)));
+ }
+ pt.cable.setAttribute("d", tube(q, CR * S));
+ }
+
+ /** Each port's targets, from the port lifted, a radius in ports and a share of the full answer. */
+ function aim(a: number, radius: number, depth: number) {
+ const A = ports[a];
+ for (const pt of ports) {
+ const dx = pt.c - A.c, dr = pt.r - A.r, d = Math.hypot(dx, dr), f = falloff(d, radius) * depth;
+ pt.pull.t = pt === A ? depth : 0;
+ pt.lx.t = d ? clamp((dx / d) * f * LEAN, -LEAN, LEAN) : 0;
+ pt.lz.t = d ? clamp((-dr / d) * f * LZ, -LZ, LZ) : 0;
+ }
+ }
+ function light(pt: Port) {
+ if (pt === lit) return;
+ const mark = (q: Port, on: boolean) => (q.full ? [q.plug.sil, q.boot.sil, q.cable] : [q.jack]).forEach((el) => el.classList.toggle("hi", on));
+ if (lit) mark(lit, false);
+ lit = pt;
+ mark(pt, true);
+ }
+ aim(REST, 1.6, 0.55);
+ for (const pt of ports) for (const s of [pt.pull, pt.lx, pt.lz]) s.x = s.t;
+ light(ports[REST]);
+ read.textContent = "rest";
+
+ const B = register(stage, (dt) => {
+ let m = false;
+ for (const pt of ports) {
+ for (const s of [pt.pull, pt.lx, pt.lz]) if (stepS(s, dt)) m = true;
+ if (pt.full) drawPort(pt);
+ }
+ return m;
+ });
+ bag.add(B.unregister);
+
+ // The plane of the plugs at rest, y = HIT_Y: it never moves, so a cable lifting cannot change the pick.
+ const o = P(0, HIT_Y, 0), ux = P(1, HIT_Y, 0), uz = P(0, HIT_Y, 1);
+ const ex = [ux[0] - o[0], ux[1] - o[1]], ez = [uz[0] - o[0], uz[1] - o[1]], det = ex[0] * ez[1] - ex[1] * ez[0];
+ function hit([sx, sy]: Vec2) {
+ const qx = sx - o[0], qy = sy - o[1], x = (qx * ez[1] - qy * ez[0]) / det, z = (ex[0] * qy - ex[1] * qx) / det;
+ if (x < X0 - 2 || x > W - X0 + 2 || z < ZB - JH - 6 || z > ZT + JH + 8) return -1;
+ let best = -1, bd = Infinity;
+ for (const pt of ports) {
+ const dd = Math.abs(pt.cx - x) + (Math.abs(pt.cz - z) > (ZT - ZB) / 2 ? 1e3 : 0);
+ if (dd < bd) { bd = dd; best = pt.p; }
+ }
+ return best;
+ }
+
+ function retarget() {
+ if (over >= 0) { aim(over, R, 1); light(ports[over]); read.textContent = "port " + String(over + 1).padStart(2, "0"); }
+ else { aim(REST, 1.6, 0.55); light(ports[REST]); read.textContent = "rest"; }
+ B.wake();
+ }
+
+ bag.add(pointer(stage, {
+ move: (p) => { const h = hit(p); if (h !== over) { over = h; retarget(); } },
+ leave: () => { over = -1; retarget(); },
+ }));
+ bag.add(() => svg.replaceChildren());
+
+ return {
+ set: (v) => { R = v; if (over >= 0) retarget(); },
+ destroy: bag.dispose,
+ };
+};
diff --git a/packages/hairline/src/figures/router.ts b/packages/hairline/src/figures/router.ts
new file mode 100644
index 0000000..bf572e1
--- /dev/null
+++ b/packages/hairline/src/figures/router.ts
@@ -0,0 +1,133 @@
+import { Cam, circ, clamp, facing, fit, hull, lerp, open, poly, prism, proj, rad, ringAt, rrect, run, seg, type Ring, type Vec2, type Vec3 } from "../core/iso";
+import { spring, stepS, type Spring } from "../core/motion";
+import { disposer, flatDot, mk, place, pointer, put, register, solid, type FigureMount, type Solid } from "../core/stage";
+
+/**
+ * Router: a low wifi router with a row of status lights along its front edge
+ * and four antennas standing on swivel bosses along its back. Each antenna is a
+ * tapered rod that leans in its own upright plane, square to the line of sight,
+ * so the four never touch and always paint in the same order. The pointer pulls
+ * each one toward itself on its own spring: the nearest reaches all the way
+ * for it, the others less the further away they are. At rest they stand as they
+ * were left, the last one tilted out and bright. The slider is the spread, in
+ * antennas.
+ *
+ * The pattern: a continuous aim over a row of parts. A spring per antenna, a
+ * falloff by distance with a floor, a clamped lean, and a hit test on the
+ * antennas' fixed pivots.
+ */
+
+const X1 = 124, Y1 = 58, H = 14, T = 3, BR = 13;
+const XS = [18, 48, 78, 108], YB = 11, KH = 5, KR = 4.6, L = 56, R0 = 3.3, R1 = 2.1, ELBOW = 0.21;
+const STOP = R1 + 1, MAX = 44, REST = [-9, 3, -4, 32], LIT0 = 3;
+const D = [Math.SQRT1_2, -Math.SQRT1_2];
+
+/** The share of its reach an antenna takes, u pivots further from the pointer than the nearest one: all of it, down to a floor R pivots on. */
+const falloff = (u: number, R: number) => clamp(1 - u / R, 0.1, 1);
+
+/** Antenna i's axis, `l` along it, leaning th degrees in its plane (positive leans right on screen). */
+const along = (i: number, th: number, l: number): Vec3 => {
+ const s = Math.sin(rad(th)), c = Math.cos(rad(th));
+ return [XS[i] + D[0] * s * l, YB + D[1] * s * l, H + KH - 1 + c * l];
+};
+
+type Ant = { i: number; el: Solid; sp: Spring; drawn: number; piv: Vec2 };
+
+export const mount: FigureMount = ({ stage, svg, read }, value) => {
+ const bag = disposer();
+ let R = value, over: Vec2 | null = null, lit: Ant | null = null;
+
+ // Fitted to the body and to every antenna at both ends of its lean, so nothing leaves the frame.
+ const C = Cam(45, 0.5, 1.78), pts: Vec3[] = [[0, 0, 0], [X1, Y1, 0], [X1, 0, 0], [0, Y1, 0]];
+ XS.forEach((_, i) => { for (const th of [-MAX, 0, MAX]) pts.push(along(i, th, L + R1)); });
+ fit(C, pts, 200, 166);
+ const P = proj(C), front = facing(C), Pv = (q: Vec3) => P(q[0], q[1], q[2]);
+ const o = P(0, 0, 0), dd = P(D[0], D[1], 0), zz = P(0, 0, 1);
+ const SH = Math.hypot(dd[0] - o[0], dd[1] - o[1]), SZ = o[1] - zz[1];
+
+ // The body: a low shell, narrower at its top than at its foot, and the status lights along its front.
+ const g = mk("g", {}, svg);
+ const foot = rrect(0, 0, X1, Y1, BR, 6), top = rrect(T, T, X1 - T, Y1 - T, BR - T, 6);
+ const inner = rrect(T + 1.6, T + 1.6, X1 - T - 1.6, Y1 - T - 1.6, BR - T - 1.6, 6);
+ put(solid(g), { sil: poly(hull(ringAt(P, foot, 0).concat(ringAt(P, top, H)))), crease: open(ringAt(P, run(inner, front), H)) });
+ for (let k = 0; k < 6; k++) {
+ const z = H * 0.56, y = Y1 - T * (z / H) + 0.1;
+ place(mk("circle", { r: 1.05, class: k === 0 ? "dot m" : "dot off" }, g), P(34 + k * 9, y, z));
+ }
+ // a vent grille across the front of the lid, in staggered rows
+ for (let j = 0; j < 3; j++) for (let k = 0; k < 13 - (j % 2); k++) place(flatDot(g, C, 0.5, "dot off"), P(26 + (j % 2) * 3 + k * 6, 29 + j * 5.5, H));
+
+ // Back to front: each antenna's boss, then the antenna. Every antenna leans in a plane x + y = const, so the order never changes.
+ const ants: Ant[] = XS.map((x, i) => {
+ const boss = solid(g);
+ const shift = (ring: Ring): Ring => ring.map((q) => ({ ...q, u: q.u + x, v: q.v + YB }));
+ put(boss, prism(P, front, shift(circ(KR, 16)), shift(circ(KR - 1.1, 16)), H, H + KH));
+ return { i, el: solid(g), sp: spring(REST[i], { eps: 0.05 }), drawn: NaN, piv: Pv(along(i, 0, 0)) };
+ });
+ const gap = Math.abs(ants[1].piv[0] - ants[0].piv[0]) / SH;
+
+ /** A disc of screen points about p, r world units across. */
+ const disc = (p: Vec2, r: number): Vec2[] => Array.from({ length: 20 }, (_, k): Vec2 => [p[0] + r * SH * Math.cos((k * Math.PI) / 10), p[1] + r * SH * Math.sin((k * Math.PI) / 10)]);
+ function drawAnt(a: Ant) {
+ const th = a.sp.x;
+ if (th === a.drawn) return;
+ a.drawn = th;
+ const b = Pv(along(a.i, th, 0)), t = Pv(along(a.i, th, L)), e = Pv(along(a.i, th, L * ELBOW));
+ const len = Math.hypot(t[0] - b[0], t[1] - b[1]), n = [-(t[1] - b[1]) / len, (t[0] - b[0]) / len];
+ const w = lerp(R0, R1, ELBOW) * SH - 1.1;
+ put(a.el, {
+ sil: poly(hull(disc(b, R0).concat(disc(t, R1)))),
+ crease: seg([e[0] + n[0] * w, e[1] + n[1] * w], [e[0] - n[0] * w, e[1] - n[1] * w]),
+ });
+ }
+ function light(a: Ant) {
+ if (a === lit) return;
+ lit?.el.sil.classList.remove("hi");
+ lit = a;
+ a.el.sil.classList.add("hi");
+ }
+
+ const B = register(stage, (dt) => {
+ let m = false;
+ for (const a of ants) { if (stepS(a.sp, dt)) m = true; drawAnt(a); }
+ return m;
+ });
+ bag.add(B.unregister);
+
+ /**
+ * Each antenna aims at the pointer from its fixed pivot, in its own plane. A
+ * pointer within reach is raised onto the circle the tip sweeps, so a tip
+ * stops just short of it and never passes it: two antennas either side of
+ * the pointer meet over it, and never cross.
+ */
+ function retarget() {
+ if (!over) {
+ ants.forEach((a, i) => { a.sp.t = REST[i]; });
+ light(ants[LIT0]); read.textContent = "rest";
+ } else {
+ const at = over;
+ const dxs = ants.map((a) => (at[0] - a.piv[0]) / SH), d0 = Math.min(...dxs.map(Math.abs));
+ const near = ants[dxs.findIndex((d) => Math.abs(d) === d0)];
+ ants.forEach((a, i) => {
+ const dx = Math.sign(dxs[i]) * Math.max(Math.abs(dxs[i]) - STOP, 0), hz = Math.max((a.piv[1] - at[1]) / SZ, Math.sqrt(Math.max(L * L - dx * dx, 0)), 0);
+ const aim = (Math.atan2(dx, hz) * 180) / Math.PI;
+ a.sp.t = clamp(aim, -MAX, MAX) * falloff((Math.abs(dxs[i]) - d0) / gap, R);
+ });
+ light(near);
+ read.textContent = `antenna ${near.i + 1} · ${Math.round(Math.abs(near.sp.t))}°`;
+ }
+ B.wake();
+ }
+ light(ants[LIT0]);
+
+ bag.add(pointer(stage, {
+ move: (p) => { over = p; retarget(); },
+ leave: () => { over = null; retarget(); },
+ }));
+ bag.add(() => svg.replaceChildren());
+
+ return {
+ set: (v) => { R = v; if (over) retarget(); },
+ destroy: bag.dispose,
+ };
+};
diff --git a/packages/hairline/src/index.ts b/packages/hairline/src/index.ts
index c6aaf1c..2533bad 100644
--- a/packages/hairline/src/index.ts
+++ b/packages/hairline/src/index.ts
@@ -1,15 +1,18 @@
import { create, type Figure, type HairlineOptions } from "./mount";
import { mount as branchesEngine } from "./figures/branches";
import { mount as cabinetEngine } from "./figures/cabinet";
+import { mount as dishEngine } from "./figures/dish";
import { mount as elevatorEngine } from "./figures/elevator";
import { mount as explodedEngine } from "./figures/exploded";
import { mount as keyboardEngine } from "./figures/keyboard";
import { mount as laptopEngine } from "./figures/laptop";
import { mount as lockersEngine } from "./figures/lockers";
import { mount as padlockEngine } from "./figures/padlock";
+import { mount as patchEngine } from "./figures/patch";
import { mount as phoneEngine } from "./figures/phone";
import { mount as phosphorEngine } from "./figures/phosphor";
import { mount as riffleEngine } from "./figures/riffle";
+import { mount as routerEngine } from "./figures/router";
import { mount as slowEngine } from "./figures/slow";
import { mount as terminalEngine } from "./figures/terminal";
import { mount as terrainEngine } from "./figures/terrain";
@@ -17,7 +20,7 @@ import { mount as turntableEngine } from "./figures/turntable";
import { mount as vaultEngine } from "./figures/vault";
/**
- * @lucasmarkes/hairline — sixteen isometric line figures that answer the pointer.
+ * @lucasmarkes/hairline — nineteen isometric line figures that answer the pointer.
*
* One function per figure. Each takes an element and the same options, draws
* into the element, and returns `{ update, destroy }`. Each function names
@@ -186,3 +189,33 @@ export function padlock(el: HTMLElement, options?: HairlineOptions): Figure {
engine: padlockEngine,
}, el, options);
}
+
+/** A patch panel of twenty-four ports: the cable under the pointer lifts, and its neighbours lean away, less the further away. `intensity` spreads the lean over more ports. */
+export function patch(el: HTMLElement, options?: HairlineOptions): Figure {
+ return create({
+ id: "patch",
+ label: "A patch panel of twenty-four ports: the cable under the pointer lifts, and its neighbours lean away, less the further away.",
+ rest: "rest",
+ engine: patchEngine,
+ }, el, options);
+}
+
+/** A parabolic dish on a two-axis gimbal: the pointer aims it, and it follows on a spring. `intensity` swings the dish further. */
+export function dish(el: HTMLElement, options?: HairlineOptions): Figure {
+ return create({
+ id: "dish",
+ label: "A parabolic dish on a two-axis gimbal: the pointer aims it, and it follows on a spring.",
+ rest: "rest",
+ engine: dishEngine,
+ }, el, options);
+}
+
+/** A wifi router whose antennas lean toward the pointer, the nearest the most and the others less the further away. `intensity` spreads the lean over more antennas. */
+export function router(el: HTMLElement, options?: HairlineOptions): Figure {
+ return create({
+ id: "router",
+ label: "A wifi router whose antennas lean toward the pointer, the nearest the most and the others less the further away.",
+ rest: "rest",
+ engine: routerEngine,
+ }, el, options);
+}
diff --git a/packages/hairline/src/intensity.ts b/packages/hairline/src/intensity.ts
index c4ddfba..673bbaf 100644
--- a/packages/hairline/src/intensity.ts
+++ b/packages/hairline/src/intensity.ts
@@ -7,7 +7,7 @@
* copy and its tests hold the two together.
*/
-export type FigureId = "riffle" | "terrain" | "exploded" | "phosphor" | "slow" | "turntable" | "keyboard" | "elevator" | "phone" | "laptop" | "terminal" | "cabinet" | "branches" | "vault" | "lockers" | "padlock";
+export type FigureId = "riffle" | "terrain" | "exploded" | "phosphor" | "slow" | "turntable" | "keyboard" | "elevator" | "phone" | "laptop" | "terminal" | "cabinet" | "branches" | "vault" | "lockers" | "padlock" | "patch" | "dish" | "router";
/** Each figure's number at intensity 0, 0.5 and 1. Slow's falls: a slower clock is a stronger answer. */
export const TABLE: Record<FigureId, readonly [number, number, number]> = {
@@ -27,6 +27,9 @@ export const TABLE: Record<FigureId, readonly [number, number, number]> = {
vault: [250, 600, 1500], // coast, ms
lockers: [55, 90, 120], // opening, degrees
padlock: [45, 90, 100], // swing, degrees
+ patch: [1, 2.5, 5], // radius, ports
+ dish: [30, 50, 70], // reach, degrees
+ router: [0.5, 1.5, 3], // spread, antennas
};
export const DEFAULT = 0.5;
diff --git a/packages/hairline/src/react.tsx b/packages/hairline/src/react.tsx
index 5923a62..5fac56a 100644
--- a/packages/hairline/src/react.tsx
+++ b/packages/hairline/src/react.tsx
@@ -2,10 +2,10 @@ import {
forwardRef, useCallback, useEffect, useLayoutEffect, useRef,
type ComponentPropsWithoutRef, type ForwardRefExoticComponent, type RefAttributes,
} from "react";
-import { branches, cabinet, elevator, exploded, keyboard, laptop, lockers, padlock, phone, phosphor, riffle, slow, terminal, terrain, turntable, vault, type Figure, type HairlineOptions } from "./index";
+import { branches, cabinet, dish, elevator, exploded, keyboard, laptop, lockers, padlock, patch, phone, phosphor, riffle, router, slow, terminal, terrain, turntable, vault, type Figure, type HairlineOptions } from "./index";
/**
- * @lucasmarkes/hairline/react — the sixteen figures as components.
+ * @lucasmarkes/hairline/react — the nineteen figures as components.
*
* A component renders one empty `<div>` and mounts the figure on it in a
* layout effect, so on the server the box is there and the drawing is not.
@@ -85,3 +85,9 @@ export const Vault = make("Vault", vault);
export const Lockers = make("Lockers", lockers);
/** A padlock: as the pointer nears, the shackle springs up out of the body and swings open about its long leg. `intensity` swings the shackle further. */
export const Padlock = make("Padlock", padlock);
+/** A patch panel of twenty-four ports: the cable under the pointer lifts, and its neighbours lean away, less the further away. `intensity` spreads the lean over more ports. */
+export const Patch = make("Patch", patch);
+/** A parabolic dish on a two-axis gimbal: the pointer aims it, and it follows on a spring. `intensity` swings the dish further. */
+export const Dish = make("Dish", dish);
+/** A wifi router whose antennas lean toward the pointer, the nearest the most and the others less the further away. `intensity` spreads the lean over more antennas. */
+export const Router = make("Router", router);
diff --git a/packages/hairline/test/browser/entry.ts b/packages/hairline/test/browser/entry.ts
index ed2788a..4c3c196 100644
--- a/packages/hairline/test/browser/entry.ts
+++ b/packages/hairline/test/browser/entry.ts
@@ -4,7 +4,7 @@ import * as hairline from "../../src/index";
* The harness page's script: the package, on `window`, with one figure at a
* time on #host. Tests drive it through page.evaluate.
*/
-type Id = "riffle" | "terrain" | "exploded" | "phosphor" | "slow" | "turntable" | "keyboard" | "elevator" | "phone" | "laptop" | "terminal" | "cabinet" | "branches" | "vault" | "lockers" | "padlock";
+type Id = "riffle" | "terrain" | "exploded" | "phosphor" | "slow" | "turntable" | "keyboard" | "elevator" | "phone" | "laptop" | "terminal" | "cabinet" | "branches" | "vault" | "lockers" | "padlock" | "patch" | "dish" | "router";
type Loose = Record<string, unknown>;
type Mount = (el: HTMLElement, options?: Loose) => { update(o: Loose): void; destroy(): void };
diff --git a/packages/hairline/test/browser/figures.spec.ts b/packages/hairline/test/browser/figures.spec.ts
index 232354d..c779f42 100644
--- a/packages/hairline/test/browser/figures.spec.ts
+++ b/packages/hairline/test/browser/figures.spec.ts
@@ -2,7 +2,7 @@ import { expect, test, type Page } from "@playwright/test";
/** The figures in a real browser: input, focus, reduced motion, shadow roots, a clean console. */
-const IDS = ["riffle", "terrain", "exploded", "phosphor", "slow", "turntable", "keyboard", "elevator", "phone", "laptop", "terminal", "cabinet", "branches", "vault", "lockers", "padlock"] as const;
+const IDS = ["riffle", "terrain", "exploded", "phosphor", "slow", "turntable", "keyboard", "elevator", "phone", "laptop", "terminal", "cabinet", "branches", "vault", "lockers", "padlock", "patch", "dish", "router"] as const;
type Id = (typeof IDS)[number];
const mount = (page: Page, id: Id, options: Record<string, unknown> = {}) =>
diff --git a/packages/hairline/test/mount.test.ts b/packages/hairline/test/mount.test.ts
index ef60ce6..ffcb8c4 100644
--- a/packages/hairline/test/mount.test.ts
+++ b/packages/hairline/test/mount.test.ts
@@ -1,10 +1,10 @@
// @vitest-environment jsdom
import { describe, expect, it, vi } from "vitest";
import { frames, host, observers, pending } from "./dom";
-import { branches, cabinet, elevator, exploded, keyboard, laptop, lockers, padlock, phone, phosphor, riffle, slow, terminal, terrain, turntable, vault } from "../src/index";
+import { branches, cabinet, dish, elevator, exploded, keyboard, laptop, lockers, padlock, patch, phone, phosphor, riffle, router, slow, terminal, terrain, turntable, vault } from "../src/index";
import { css } from "../src/core/styles";
-const ALL = { riffle, terrain, exploded, phosphor, slow, turntable, keyboard, elevator, phone, laptop, terminal, cabinet, branches, vault, lockers, padlock };
+const ALL = { riffle, terrain, exploded, phosphor, slow, turntable, keyboard, elevator, phone, laptop, terminal, cabinet, branches, vault, lockers, padlock, patch, dish, router };
const key = (el: Element, k: string) => el.dispatchEvent(new KeyboardEvent("keydown", { key: k, bubbles: true, cancelable: true }));
describe("mount", () => {
@@ -152,6 +152,9 @@ describe("intensity", () => {
vault: [[260, 170], 2, [200, 230], 2, [140, 170], 2, [200, 110], 8],
lockers: [[200, 160], 8],
padlock: [[200, 170], 60],
+ patch: [[200, 160], 8],
+ dish: [[300, 100], 12],
+ router: [[300, 120], 12],
};
const svg = (el: Element) => el.querySelector("svg")!.innerHTML.replace(/hl-fd\d+/g, "hl-fd");
diff --git a/packages/hairline/test/react.test.tsx b/packages/hairline/test/react.test.tsx
index 60df784..98dd850 100644
--- a/packages/hairline/test/react.test.tsx
+++ b/packages/hairline/test/react.test.tsx
@@ -3,7 +3,7 @@ import { StrictMode, createRef } from "react";
import { cleanup, render } from "@testing-library/react";
import { afterEach, describe, expect, it, vi } from "vitest";
import { frames, observers, pending } from "./dom";
-import { Branches, Cabinet, Elevator, Exploded, Keyboard, Laptop, Lockers, Padlock, Phone, Phosphor, Riffle, Slow, Terminal, Terrain, Turntable, Vault } from "../src/react";
+import { Branches, Cabinet, Dish, Elevator, Exploded, Keyboard, Laptop, Lockers, Padlock, Patch, Phone, Phosphor, Riffle, Router, Slow, Terminal, Terrain, Turntable, Vault } from "../src/react";
afterEach(cleanup);
@@ -17,9 +17,9 @@ const svg = (el: Element) => el.querySelector("svg")!.innerHTML.replace(/hl-fd\d
describe("components", () => {
it("renders each figure into one div", () => {
- const { container } = render(<><Riffle /><Terrain /><Exploded /><Phosphor /><Slow /><Turntable /><Keyboard /><Elevator /><Phone /><Laptop /><Terminal /><Cabinet /><Branches /><Vault /><Lockers /><Padlock /></>);
+ const { container } = render(<><Riffle /><Terrain /><Exploded /><Phosphor /><Slow /><Turntable /><Keyboard /><Elevator /><Phone /><Laptop /><Terminal /><Cabinet /><Branches /><Vault /><Lockers /><Padlock /><Patch /><Dish /><Router /></>);
const ids = [...container.children].map((el) => el.getAttribute("data-hairline"));
- expect(ids).toEqual(["riffle", "terrain", "exploded", "phosphor", "slow", "turntable", "keyboard", "elevator", "phone", "laptop", "terminal", "cabinet", "branches", "vault", "lockers", "padlock"]);
+ expect(ids).toEqual(["riffle", "terrain", "exploded", "phosphor", "slow", "turntable", "keyboard", "elevator", "phone", "laptop", "terminal", "cabinet", "branches", "vault", "lockers", "padlock", "patch", "dish", "router"]);
for (const el of container.children) expect(el.querySelectorAll(":scope > svg")).toHaveLength(1);
});
@@ -118,7 +118,7 @@ describe("components", () => {
});
it("names the components for the dev tools", () => {
- expect([Riffle, Terrain, Exploded, Phosphor, Slow, Turntable, Keyboard, Elevator, Phone, Laptop, Terminal, Cabinet, Branches, Vault, Lockers, Padlock].map((c) => c.displayName))
- .toEqual(["Riffle", "Terrain", "Exploded", "Phosphor", "Slow", "Turntable", "Keyboard", "Elevator", "Phone", "Laptop", "Terminal", "Cabinet", "Branches", "Vault", "Lockers", "Padlock"]);
+ expect([Riffle, Terrain, Exploded, Phosphor, Slow, Turntable, Keyboard, Elevator, Phone, Laptop, Terminal, Cabinet, Branches, Vault, Lockers, Padlock, Patch, Dish, Router].map((c) => c.displayName))
+ .toEqual(["Riffle", "Terrain", "Exploded", "Phosphor", "Slow", "Turntable", "Keyboard", "Elevator", "Phone", "Laptop", "Terminal", "Cabinet", "Branches", "Vault", "Lockers", "Padlock", "Patch", "Dish", "Router"]);
});
});
diff --git a/packages/hairline/test/types.test-d.tsx b/packages/hairline/test/types.test-d.tsx
index 9ccc142..12fd9f6 100644
--- a/packages/hairline/test/types.test-d.tsx
+++ b/packages/hairline/test/types.test-d.tsx
@@ -4,10 +4,10 @@
* an error. Vitest does not pick it up (it is not a `.test.` file).
*/
import { createRef } from "react";
-import { branches, cabinet, elevator, exploded, keyboard, laptop, lockers, padlock, phone, phosphor, riffle, slow, terminal, terrain, turntable, vault, type Figure, type HairlineOptions } from "../src/index";
+import { branches, cabinet, dish, elevator, exploded, keyboard, laptop, lockers, padlock, patch, phone, phosphor, riffle, router, slow, terminal, terrain, turntable, vault, type Figure, type HairlineOptions } from "../src/index";
import * as vanilla from "../src/index";
import * as components from "../src/react";
-import { Branches, Cabinet, Elevator, Exploded, Keyboard, Laptop, Lockers, Padlock, Phone, Phosphor, Riffle, Slow, Terminal, Terrain, Turntable, Vault, type HairlineProps } from "../src/react";
+import { Branches, Cabinet, Dish, Elevator, Exploded, Keyboard, Laptop, Lockers, Padlock, Patch, Phone, Phosphor, Riffle, Router, Slow, Terminal, Terrain, Turntable, Vault, type HairlineProps } from "../src/react";
declare const el: HTMLElement;
type Equal<A, B> = (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2 ? true : false;
@@ -16,7 +16,7 @@ const yes = <T extends true>() => {};
/* every figure takes the same options */
riffle(el, { intensity: 0.8, theme: "dark", label: "Cards", onRead: (t: string) => t });
riffle(el);
-for (const mount of [riffle, terrain, exploded, phosphor, slow, turntable, keyboard, elevator, phone, laptop, terminal, cabinet, branches, vault, lockers, padlock]) {
+for (const mount of [riffle, terrain, exploded, phosphor, slow, turntable, keyboard, elevator, phone, laptop, terminal, cabinet, branches, vault, lockers, padlock, patch, dish, router]) {
yes<Equal<typeof mount, (el: HTMLElement, options?: HairlineOptions) => Figure>>();
// @ts-expect-error the old per-figure options are gone
mount(el, { stagger: 60 });
@@ -46,8 +46,8 @@ f.update({ stagger: 60 });
f.update({ bands: true });
/* the entries export the functions, the components and three types, and nothing of the old API */
-yes<Equal<keyof typeof vanilla, "riffle" | "terrain" | "exploded" | "phosphor" | "slow" | "turntable" | "keyboard" | "elevator" | "phone" | "laptop" | "terminal" | "cabinet" | "branches" | "vault" | "lockers" | "padlock">>();
-yes<Equal<keyof typeof components, "Riffle" | "Terrain" | "Exploded" | "Phosphor" | "Slow" | "Turntable" | "Keyboard" | "Elevator" | "Phone" | "Laptop" | "Terminal" | "Cabinet" | "Branches" | "Vault" | "Lockers" | "Padlock">>();
+yes<Equal<keyof typeof vanilla, "riffle" | "terrain" | "exploded" | "phosphor" | "slow" | "turntable" | "keyboard" | "elevator" | "phone" | "laptop" | "terminal" | "cabinet" | "branches" | "vault" | "lockers" | "padlock" | "patch" | "dish" | "router">>();
+yes<Equal<keyof typeof components, "Riffle" | "Terrain" | "Exploded" | "Phosphor" | "Slow" | "Turntable" | "Keyboard" | "Elevator" | "Phone" | "Laptop" | "Terminal" | "Cabinet" | "Branches" | "Vault" | "Lockers" | "Padlock" | "Patch" | "Dish" | "Router">>();
// @ts-expect-error ranges is gone
void vanilla.ranges;
// @ts-expect-error the per-figure option types are gone
@@ -60,7 +60,7 @@ const ref = createRef<HTMLDivElement>();
<Riffle ref={ref} intensity={0.8} theme="dark" className="w-80" id="cards" onClick={() => {}} onRead={(text) => text.length} />;
<Terrain style={{ width: 320 }} aria-label="Dunes" data-x="1" />;
<Riffle />;
-for (const C of [Riffle, Terrain, Exploded, Phosphor, Slow, Turntable, Keyboard, Elevator, Phone, Laptop, Terminal, Cabinet, Branches, Vault, Lockers, Padlock]) {
+for (const C of [Riffle, Terrain, Exploded, Phosphor, Slow, Turntable, Keyboard, Elevator, Phone, Laptop, Terminal, Cabinet, Branches, Vault, Lockers, Padlock, Patch, Dish, Router]) {
// @ts-expect-error the old per-figure options are gone
<C stagger={60} />;
// @ts-expect-error the old per-figure options are gone
diff --git a/registry/src/hairline.tsx b/registry/src/hairline.tsx
index dd7e0a6..bb4b75e 100644
--- a/registry/src/hairline.tsx
+++ b/registry/src/hairline.tsx
@@ -81,3 +81,15 @@ export function Lockers({ style, ...props }: ComponentProps<typeof Hairline.Lock
export function Padlock({ style, ...props }: ComponentProps<typeof Hairline.Padlock>) {
return <Hairline.Padlock style={{ ...tokens, ...style }} {...props} />;
}
+
+export function Patch({ style, ...props }: ComponentProps<typeof Hairline.Patch>) {
+ return <Hairline.Patch style={{ ...tokens, ...style }} {...props} />;
+}
+
+export function Dish({ style, ...props }: ComponentProps<typeof Hairline.Dish>) {
+ return <Hairline.Dish style={{ ...tokens, ...style }} {...props} />;
+}
+
+export function Router({ style, ...props }: ComponentProps<typeof Hairline.Router>) {
+ return <Hairline.Router style={{ ...tokens, ...style }} {...props} />;
+}
diff --git a/registry/validate.mjs b/registry/validate.mjs
index afe8982..3548956 100644
--- a/registry/validate.mjs
+++ b/registry/validate.mjs
@@ -29,7 +29,7 @@ const [source] = item.files ?? [];
if (item.dependencies?.join() !== "@lucasmarkes/hairline") problems.push("dependencies must be exactly @lucasmarkes/hairline");
if (source?.path !== "components/ui/hairline.tsx") problems.push("the file must be components/ui/hairline.tsx");
if (!source?.content?.startsWith('"use client";')) problems.push('the file must start with "use client"');
-for (const name of ["Riffle", "Terrain", "Exploded", "Phosphor", "Slow", "Turntable", "Keyboard", "Elevator", "Phone", "Laptop", "Terminal", "Cabinet", "Branches", "Vault", "Lockers", "Padlock"]) {
+for (const name of ["Riffle", "Terrain", "Exploded", "Phosphor", "Slow", "Turntable", "Keyboard", "Elevator", "Phone", "Laptop", "Terminal", "Cabinet", "Branches", "Vault", "Lockers", "Padlock", "Patch", "Dish", "Router"]) {
if (!source?.content?.includes(`export function ${name}(`)) problems.push(`the file does not export ${name}`);
}
if (/localhost/.test(JSON.stringify(item)) && process.env.VERCEL) problems.push("the item points at localhost in a deployed build");
diff --git a/scripts/consumers.mjs b/scripts/consumers.mjs
index b323d7c..db55beb 100644
--- a/scripts/consumers.mjs
+++ b/scripts/consumers.mjs
@@ -22,7 +22,7 @@ const { chromium } = createRequire(join(PKG, "package.json"))("@playwright/test"
const FIXTURES = {
next: { dir: "fixtures/next-app", port: 4311, serve: (port) => ["npx", ["next", "start", "-p", String(port)]], figures: ["riffle", "slow", "phosphor"] },
- vite: { dir: "fixtures/vite-vanilla", port: 4312, serve: (port) => ["npx", ["vite", "preview", "--port", String(port), "--strictPort"]], figures: ["riffle", "terrain", "exploded", "phosphor", "slow", "turntable", "keyboard", "elevator", "phone", "laptop", "terminal", "cabinet", "branches", "vault", "lockers", "padlock"] },
+ vite: { dir: "fixtures/vite-vanilla", port: 4312, serve: (port) => ["npx", ["vite", "preview", "--port", String(port), "--strictPort"]], figures: ["riffle", "terrain", "exploded", "phosphor", "slow", "turntable", "keyboard", "elevator", "phone", "laptop", "terminal", "cabinet", "branches", "vault", "lockers", "padlock", "patch", "dish", "router"] },
};
const only = process.argv[2];
if (only && !FIXTURES[only]) { console.error(`Unknown fixture "${only}". Use: ${Object.keys(FIXTURES).join(" | ")}`); process.exit(2); }