@andamento/core 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-HBEJOXUC.cjs +10138 -0
- package/dist/chunk-HBEJOXUC.cjs.map +1 -0
- package/dist/chunk-JHWTRUDN.js +10138 -0
- package/dist/chunk-JHWTRUDN.js.map +1 -0
- package/dist/css-BG8JRNrD.d.cts +776 -0
- package/dist/css-BG8JRNrD.d.ts +776 -0
- package/dist/index.cjs +318 -10441
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -887
- package/dist/index.d.ts +20 -887
- package/dist/index.js +148 -10123
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +81 -0
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.cts +111 -0
- package/dist/internal.d.ts +111 -0
- package/dist/internal.js +81 -0
- package/dist/internal.js.map +1 -0
- package/package.json +11 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/geometry.ts","../src/offset.ts","../src/overlay.ts","../src/random.ts","../src/procedural.ts","../src/substitution.ts","../src/cover.ts","../src/hat.ts","../src/vendor/tactile.ts","../src/isohedral.ts","../src/spectre.ts","../src/density.ts","../src/flow.ts","../src/tilings.ts","../src/rounding.ts","../src/layout.ts","../src/shape.ts","../src/safe.ts","../src/css.ts","../src/relief.ts","../src/navigation.ts","../src/hit.ts","../src/content.ts","../src/fills.ts","../src/fit.ts","../src/focus.ts","../src/weights.ts"],"sourcesContent":["/**\n * Small, dependency-free 2D geometry kernel.\n *\n * Conventions:\n * - Coordinates are SVG-style (y grows downward), but all math is orientation-agnostic.\n * - Polygons are arrays of vertices without a repeated closing vertex.\n * - \"Positive\" orientation means a positive shoelace area. All internal polygons are\n * normalized to positive orientation, so the interior is to the left of each edge\n * in the shoelace sense and the inward normal of edge (dx, dy) is (-dy, dx).\n * - `clipConvex` needs a convex clip polygon (the subject can be any simple polygon);\n * `insetConvex` needs a convex polygon and `containsPolygon` a convex `outer`. Non-convex tiles are inset\n * with `insetPolygon` (offset.ts).\n */\n\nexport interface Vec {\n x: number;\n y: number;\n}\n\nexport type Polygon = Vec[];\n\nexport interface Rect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport const vec = (x: number, y: number): Vec => ({ x, y });\n\nexport const add = (a: Vec, b: Vec): Vec => ({ x: a.x + b.x, y: a.y + b.y });\nexport const sub = (a: Vec, b: Vec): Vec => ({ x: a.x - b.x, y: a.y - b.y });\nexport const scale = (a: Vec, s: number): Vec => ({ x: a.x * s, y: a.y * s });\nexport const dot = (a: Vec, b: Vec): number => a.x * b.x + a.y * b.y;\nexport const cross = (a: Vec, b: Vec): number => a.x * b.y - a.y * b.x;\nexport const length = (a: Vec): number => Math.hypot(a.x, a.y);\n\n/** Polygon for an axis-aligned rectangle, in positive orientation. */\nexport function rectPolygon(x: number, y: number, width: number, height: number): Polygon {\n return [vec(x, y), vec(x + width, y), vec(x + width, y + height), vec(x, y + height)];\n}\n\n/** Shoelace signed area. Positive for the library's canonical orientation. */\nexport function signedArea(p: Polygon): number {\n let s = 0;\n for (let i = 0, n = p.length; i < n; i++) {\n const a = p[i]!;\n const b = p[(i + 1) % n]!;\n s += a.x * b.y - b.x * a.y;\n }\n return s / 2;\n}\n\nexport const area = (p: Polygon): number => Math.abs(signedArea(p));\n\nexport function ensurePositive(p: Polygon): Polygon {\n return signedArea(p) < 0 ? [...p].reverse() : p;\n}\n\nexport function centroid(p: Polygon): Vec {\n const a = signedArea(p);\n if (Math.abs(a) < 1e-12) {\n // Degenerate: fall back to the vertex average.\n const s = p.reduce((acc, v) => add(acc, v), vec(0, 0));\n return scale(s, 1 / Math.max(p.length, 1));\n }\n let cx = 0;\n let cy = 0;\n for (let i = 0, n = p.length; i < n; i++) {\n const v0 = p[i]!;\n const v1 = p[(i + 1) % n]!;\n const f = v0.x * v1.y - v1.x * v0.y;\n cx += (v0.x + v1.x) * f;\n cy += (v0.y + v1.y) * f;\n }\n return vec(cx / (6 * a), cy / (6 * a));\n}\n\nexport function bbox(p: Polygon): Rect {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (const v of p) {\n if (v.x < minX) minX = v.x;\n if (v.y < minY) minY = v.y;\n if (v.x > maxX) maxX = v.x;\n if (v.y > maxY) maxY = v.y;\n }\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };\n}\n\nexport function rectsOverlap(a: Rect, b: Rect, tol = 0): boolean {\n return (\n a.x <= b.x + b.width + tol &&\n b.x <= a.x + a.width + tol &&\n a.y <= b.y + b.height + tol &&\n b.y <= a.y + a.height + tol\n );\n}\n\n/** Rotate by `radians` about the coordinate origin, then translate by `offset`. */\nexport function transform(p: Polygon, radians: number, offset: Vec): Polygon {\n const c = Math.cos(radians);\n const s = Math.sin(radians);\n return p.map((v) => vec(v.x * c - v.y * s + offset.x, v.x * s + v.y * c + offset.y));\n}\n\nexport function isConvex(p: Polygon, tol = 1e-9): boolean {\n const n = p.length;\n if (n < 3) return false;\n let sign = 0;\n for (let i = 0; i < n; i++) {\n const a = p[i]!;\n const b = p[(i + 1) % n]!;\n const c = p[(i + 2) % n]!;\n const z = cross(sub(b, a), sub(c, b));\n if (Math.abs(z) <= tol) continue;\n const s = Math.sign(z);\n if (sign === 0) sign = s;\n else if (s !== sign) return false;\n }\n return sign !== 0;\n}\n\n/**\n * Keep the part of `poly` where dot(normal, v - point) >= offset\n * (one pass of Sutherland–Hodgman).\n */\nexport function clipHalfPlane(poly: Polygon, point: Vec, normal: Vec, offset = 0): Polygon {\n const out: Polygon = [];\n const n = poly.length;\n if (n === 0) return out;\n const dist = (v: Vec) => dot(normal, sub(v, point)) - offset;\n let prev = poly[n - 1]!;\n let dPrev = dist(prev);\n for (let i = 0; i < n; i++) {\n const cur = poly[i]!;\n const dCur = dist(cur);\n if (dCur >= 0) {\n if (dPrev < 0) out.push(lerpAt(prev, cur, dPrev, dCur));\n out.push(cur);\n } else if (dPrev >= 0) {\n out.push(lerpAt(prev, cur, dPrev, dCur));\n }\n prev = cur;\n dPrev = dCur;\n }\n return out;\n}\n\nfunction lerpAt(a: Vec, b: Vec, da: number, db: number): Vec {\n const t = da / (da - db);\n return vec(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t);\n}\n\nfunction inwardNormal(a: Vec, b: Vec): Vec {\n const d = sub(b, a);\n const len = length(d);\n return len === 0 ? vec(0, 0) : vec(-d.y / len, d.x / len);\n}\n\n/** Remove consecutive duplicate vertices; return [] if the result has no area. */\nexport function cleanPolygon(p: Polygon, tol = 1e-9): Polygon {\n const out: Polygon = [];\n for (const v of p) {\n const last = out[out.length - 1];\n if (!last || Math.abs(last.x - v.x) > tol || Math.abs(last.y - v.y) > tol) out.push(v);\n }\n while (out.length > 1) {\n const first = out[0]!;\n const last = out[out.length - 1]!;\n if (Math.abs(first.x - last.x) > tol || Math.abs(first.y - last.y) > tol) break;\n out.pop();\n }\n return out.length >= 3 && area(out) > tol * tol ? out : [];\n}\n\n/**\n * Intersection of `subject` (any simple polygon) with a convex `clip` polygon.\n * If a non-convex subject is cut into separate parts, they come back as one polygon\n * joined by zero-width strips along the clip edge; use `clipPolygonToConvex` to get\n * the parts separately.\n */\nexport function clipConvex(subject: Polygon, clip: Polygon): Polygon {\n const c = ensurePositive(clip);\n let out = subject;\n for (let i = 0, n = c.length; i < n && out.length > 0; i++) {\n const a = c[i]!;\n const b = c[(i + 1) % n]!;\n out = clipHalfPlane(out, a, inwardNormal(a, b));\n }\n return cleanPolygon(out);\n}\n\n/**\n * Shrink a convex polygon by moving every edge inward by `distance`.\n * Implemented as a half-plane intersection, so edges that collapse simply vanish\n * and an over-inset polygon returns [].\n */\nexport function insetConvex(poly: Polygon, distance: number): Polygon {\n const p = ensurePositive(poly);\n if (distance <= 0) return p;\n let out = p;\n for (let i = 0, n = p.length; i < n && out.length > 0; i++) {\n const a = p[i]!;\n const b = p[(i + 1) % n]!;\n out = clipHalfPlane(out, a, inwardNormal(a, b), distance);\n }\n return cleanPolygon(out);\n}\n\n/** True if every vertex of `inner` lies inside (or on) convex polygon `outer`. */\nexport function containsPolygon(outer: Polygon, inner: Polygon, tol = 1e-9): boolean {\n const o = ensurePositive(outer);\n for (let i = 0, n = o.length; i < n; i++) {\n const a = o[i]!;\n const nrm = inwardNormal(a, o[(i + 1) % n]!);\n for (const v of inner) if (dot(nrm, sub(v, a)) < -tol) return false;\n }\n return true;\n}\n\n/** Do two polygons share a boundary segment of positive length? */\nexport function sharesEdge(a: Polygon, b: Polygon, tol: number): boolean {\n for (let i = 0, n = a.length; i < n; i++) {\n const a0 = a[i]!;\n const a1 = a[(i + 1) % n]!;\n const d = sub(a1, a0);\n const len = length(d);\n if (len <= tol) continue;\n const u = scale(d, 1 / len);\n for (let j = 0, m = b.length; j < m; j++) {\n const b0 = b[j]!;\n const b1 = b[(j + 1) % m]!;\n // Both endpoints of b's edge must lie on a's edge line.\n if (Math.abs(cross(u, sub(b0, a0))) > tol || Math.abs(cross(u, sub(b1, a0))) > tol) continue;\n const t0 = dot(u, sub(b0, a0));\n const t1 = dot(u, sub(b1, a0));\n const lo = Math.max(0, Math.min(t0, t1));\n const hi = Math.min(len, Math.max(t0, t1));\n if (hi - lo > tol) return true;\n }\n }\n return false;\n}\n\n/** Convex hull (positive orientation) of a set of points. */\nexport function convexHull(points: Vec[]): Polygon {\n const pts = [...points].sort((a, b) => a.x - b.x || a.y - b.y);\n if (pts.length < 3) return pts;\n const half = (list: Vec[]) => {\n const out: Vec[] = [];\n for (const p of list) {\n while (out.length >= 2 && cross(sub(out[out.length - 1]!, out[out.length - 2]!), sub(p, out[out.length - 1]!)) <= 0) out.pop();\n out.push(p);\n }\n out.pop();\n return out;\n };\n return ensurePositive([...half(pts), ...half([...pts].reverse())]);\n}\n","import { area, cleanPolygon, ensurePositive, signedArea, vec, type Polygon, type Vec } from \"./geometry\";\n\n/*\n * Inward offset (inset) for simple polygons that may be non-convex.\n *\n * Every edge moves inward by `distance` and neighboring offset edges are joined at\n * the intersection of their lines (a mitre join). That's exact at convex corners;\n * at concave corners it keeps a sharp corner, which is what makes neighboring\n * tiles stay exactly `2 × distance` apart, edge for edge.\n *\n * Two things can go wrong as the edges move:\n * - An edge shrinks to nothing and then turns inside out. Edges are removed in the\n * order they collapse (the \"edge events\" of a straight skeleton) and the offset\n * is recomputed without them.\n * - A narrow neck pinches off, splitting the shape. The offset outline then crosses\n * itself; it is cut into loops and the largest proper (positively oriented) piece\n * is kept.\n */\n\n/**\n * Shrink a simple polygon (convex or not) by moving every edge inward by `distance`.\n * Returns [] if nothing is left. If the shape splits, the largest piece is returned.\n */\nexport function insetPolygon(poly: Polygon, distance: number): Polygon {\n const p = cleanPolygon(ensurePositive(poly));\n if (p.length < 3) return [];\n if (distance <= 0) return p;\n const pieces = offsetLoops(p, distance);\n if (pieces.length === 0) return [];\n let best = pieces[0]!;\n for (const q of pieces) if (area(q) > area(best)) best = q;\n return best;\n}\n\n/** Like `insetPolygon`, but every piece when a narrow neck pinches the shape apart. */\nexport function insetPolygonPieces(poly: Polygon, distance: number): Polygon[] {\n const p = cleanPolygon(ensurePositive(poly));\n if (p.length < 3) return [];\n if (distance <= 0) return [p];\n return offsetLoops(p, distance);\n}\n\n/**\n * Grow a simple polygon by moving every edge outward by `distance` (mitred corners;\n * pockets narrower than 2 × distance close up). Positively oriented.\n */\nexport function outsetPolygon(poly: Polygon, distance: number): Polygon {\n const p = cleanPolygon(ensurePositive(poly));\n if (p.length < 3) return [];\n if (distance <= 0) return p;\n // Offsetting toward the left of a clockwise outline moves it outward.\n const loops = offsetLoops([...p].reverse(), distance);\n let best: Polygon = [];\n for (const q of loops) if (area(q) > area(best)) best = q;\n return best.length ? [...best].reverse() : [];\n}\n\n/**\n * Move every edge of `p` (cleaned, either orientation) to its left by `distance`, and\n * return the resulting loops that keep `p`'s orientation.\n */\nfunction offsetLoops(p: Polygon, distance: number): Polygon[] {\n const sign = Math.sign(signedArea(p));\n\n // Edge lines as flat arrays: a point on the edge, its unit direction and inward normal.\n const px: number[] = [], py: number[] = [], ux: number[] = [], uy: number[] = [];\n for (let i = 0; i < p.length; i++) {\n const a = p[i]!;\n const b = p[(i + 1) % p.length]!;\n const len = Math.hypot(b.x - a.x, b.y - a.y);\n if (len === 0) continue;\n px.push(a.x);\n py.push(a.y);\n ux.push((b.x - a.x) / len);\n uy.push((b.y - a.y) / len);\n }\n const n = px.length;\n if (n < 3) return [];\n\n // Join of line i with the following line j at offset t (written to jx, jy). Parallel\n // lines (the same line continuing, or a hairpin) meet halfway.\n let jx = 0;\n let jy = 0;\n const join = (i: number, j: number, t: number) => {\n // Inward normal of a direction (x, y) is (-y, x).\n const ax = px[i]! - uy[i]! * t, ay = py[i]! + ux[i]! * t;\n const bx = px[j]! - uy[j]! * t, by = py[j]! + ux[j]! * t;\n const den = ux[i]! * uy[j]! - uy[i]! * ux[j]!;\n if (Math.abs(den) < 1e-12) {\n jx = (ax + bx) / 2;\n jy = (ay + by) / 2;\n return;\n }\n const s = ((bx - ax) * uy[j]! - (by - ay) * ux[j]!) / den;\n jx = ax + ux[i]! * s;\n jy = ay + uy[i]! * s;\n };\n\n // Doubly linked ring of the edges still present.\n const prev = Array.from({ length: n }, (_, k) => (k - 1 + n) % n);\n const next = Array.from({ length: n }, (_, k) => (k + 1) % n);\n const alive = new Array<boolean>(n).fill(true);\n const version = new Array<number>(n).fill(0);\n let count = n;\n\n /** Signed length of edge k between its current neighbors' joins, at offset t. */\n const lengthAt = (k: number, t: number) => {\n join(prev[k]!, k, t);\n const sx = jx, sy = jy;\n join(k, next[k]!, t);\n return (jx - sx) * ux[k]! + (jy - sy) * uy[k]!;\n };\n /** When edge k shrinks to nothing (Infinity if not before `distance`), from time t. */\n const collapseTime = (k: number, t: number) => {\n const now = lengthAt(k, t);\n const then = lengthAt(k, distance);\n if (then >= 0) return Infinity;\n return now <= 0 ? t : t + ((distance - t) * now) / (now - then);\n };\n\n // Edge events: drop edges in the order they collapse. Between events, lengths change\n // linearly with t, and a collapse only changes its two neighbors' collapse times, so\n // those are kept in a heap ordered by (time, edge index) and updated locally.\n type Event = { time: number; edge: number; version: number };\n const heap: Event[] = [];\n const before = (a: Event, b: Event) => a.time < b.time || (a.time === b.time && a.edge < b.edge);\n const push = (e: Event) => {\n heap.push(e);\n for (let i = heap.length - 1; i > 0; ) {\n const parent = (i - 1) >> 1;\n if (!before(heap[i]!, heap[parent]!)) break;\n [heap[i], heap[parent]] = [heap[parent]!, heap[i]!];\n i = parent;\n }\n };\n const pop = (): Event => {\n const top = heap[0]!;\n const last = heap.pop()!;\n if (heap.length > 0) {\n heap[0] = last;\n for (let i = 0; ; ) {\n const l = 2 * i + 1, r = l + 1;\n let m = i;\n if (l < heap.length && before(heap[l]!, heap[m]!)) m = l;\n if (r < heap.length && before(heap[r]!, heap[m]!)) m = r;\n if (m === i) break;\n [heap[i], heap[m]] = [heap[m]!, heap[i]!];\n i = m;\n }\n }\n return top;\n };\n const schedule = (k: number, t: number) => {\n version[k]!++;\n const time = collapseTime(k, t);\n if (time < Infinity) push({ time, edge: k, version: version[k]! });\n };\n\n for (let k = 0; k < n; k++) schedule(k, 0);\n let t = 0;\n while (heap.length > 0 && count >= 3) {\n const e = pop();\n if (!alive[e.edge] || e.version !== version[e.edge]) continue; // stale\n t = Math.min(distance, Math.max(t, e.time));\n const k = e.edge;\n alive[k] = false;\n count--;\n const a = prev[k]!, b = next[k]!;\n next[a] = b;\n prev[b] = a;\n if (count >= 3) {\n schedule(a, t);\n schedule(b, t);\n }\n }\n if (count < 3) return [];\n\n const outline: Vec[] = [];\n let start = 0;\n while (!alive[start]) start++;\n let k = start;\n do {\n join(prev[k]!, k, distance);\n outline.push(vec(jx, jy));\n k = next[k]!;\n } while (k !== start);\n return splitSelfIntersections(outline)\n .filter((q) => signedArea(q) * sign > 0)\n .map((q) => dropStraightVertices(cleanPolygon(q)))\n .filter((q) => q.length >= 3);\n}\n\n/** Remove vertices that sit in the middle of a straight run. */\nfunction dropStraightVertices(poly: Polygon): Polygon {\n const out = poly.filter((v, i) => {\n const a = poly[(i - 1 + poly.length) % poly.length]!;\n const b = poly[(i + 1) % poly.length]!;\n const ux = v.x - a.x, uy = v.y - a.y, wx = b.x - v.x, wy = b.y - v.y;\n const cross = ux * wy - uy * wx;\n return Math.abs(cross) > 1e-12 * Math.hypot(ux, uy) * Math.hypot(wx, wy) || ux * wx + uy * wy < 0;\n });\n return out.length >= 3 ? out : poly;\n}\n\n/**\n * Where segments a0–a1 and b0–b1 cross, if they do: a proper crossing point, or the\n * middle of the shared stretch when they lie along the same line and overlap (which\n * is how a pinched-off neck shows up on straight-sided shapes).\n */\nfunction crossing(a0: Vec, a1: Vec, b0: Vec, b1: Vec): Vec | null {\n const d1x = a1.x - a0.x, d1y = a1.y - a0.y;\n const d2x = b1.x - b0.x, d2y = b1.y - b0.y;\n const den = d1x * d2y - d1y * d2x;\n const len1 = Math.hypot(d1x, d1y);\n const len2 = Math.hypot(d2x, d2y);\n if (Math.abs(den) <= 1e-12 * len1 * len2) {\n if (len1 === 0) return null;\n // Parallel. Collinear only if b0 lies on a's line.\n const off = ((b0.x - a0.x) * d1y - (b0.y - a0.y) * d1x) / len1;\n if (Math.abs(off) > 1e-9 * Math.max(len1, len2)) return null;\n const along = (v: Vec) => ((v.x - a0.x) * d1x + (v.y - a0.y) * d1y) / (len1 * len1);\n const lo = Math.max(0, Math.min(along(b0), along(b1)));\n const hi = Math.min(1, Math.max(along(b0), along(b1)));\n if (hi - lo <= 1e-9) return null;\n const m = (lo + hi) / 2;\n return vec(a0.x + d1x * m, a0.y + d1y * m);\n }\n const s = ((b0.x - a0.x) * d2y - (b0.y - a0.y) * d2x) / den;\n const r = ((b0.x - a0.x) * d1y - (b0.y - a0.y) * d1x) / den;\n const eps = 1e-12;\n if (s <= eps || s >= 1 - eps || r <= eps || r >= 1 - eps) return null;\n return vec(a0.x + d1x * s, a0.y + d1y * s);\n}\n\n/** Cut a closed outline at its self-crossings into simple loops. */\nexport function splitSelfIntersections(poly: Polygon): Polygon[] {\n const n = poly.length;\n // Sweep over edges sorted by their left end; only edges whose x-ranges overlap can cross.\n const order = Array.from({ length: n }, (_, i) => i);\n const x0 = order.map((i) => Math.min(poly[i]!.x, poly[(i + 1) % n]!.x));\n const x1 = order.map((i) => Math.max(poly[i]!.x, poly[(i + 1) % n]!.x));\n order.sort((a, b) => x0[a]! - x0[b]!);\n const eps = 1e-12 * (1 + Math.abs(x1[order[n - 1]!]!));\n for (let oa = 0; oa < n; oa++) {\n const a = order[oa]!;\n for (let ob = oa + 1; ob < n; ob++) {\n const b = order[ob]!;\n if (x0[b]! > x1[a]! + eps) break;\n const i = Math.min(a, b);\n const j = Math.max(a, b);\n if (j - i < 2 || (i === 0 && j === n - 1)) continue; // adjacent edges\n const x = crossing(poly[i]!, poly[(i + 1) % n]!, poly[j]!, poly[(j + 1) % n]!);\n if (!x) continue;\n // Loop 1 skips from edge i to edge j at the crossing; loop 2 is what it skipped.\n const one = [...poly.slice(0, i + 1), x, ...poly.slice(j + 1)];\n const two = [x, ...poly.slice(i + 1, j + 1)];\n return [...splitSelfIntersections(one), ...splitSelfIntersections(two)];\n }\n }\n return [poly];\n}\n\n/** Ray-casting point-in-polygon test (even–odd rule). */\nexport function pointInPolygon(pt: Vec, poly: Polygon): boolean {\n let inside = false;\n for (let i = 0, j = poly.length - 1; i < poly.length; j = i++) {\n const a = poly[i]!;\n const b = poly[j]!;\n if (a.y > pt.y !== b.y > pt.y && pt.x < ((b.x - a.x) * (pt.y - a.y)) / (b.y - a.y) + a.x) inside = !inside;\n }\n return inside;\n}\n\n/**\n * Intersection of a simple polygon (convex or not) with a convex `clip` polygon, as\n * separate pieces. Unlike `clipConvex`, a subject that the clip edge cuts into several\n * parts comes back as several clean polygons.\n *\n * The subject's outline is walked edge by edge; the stretches inside the clip region form\n * chains that enter and leave through the clip outline. Each piece is a chain followed by\n * a walk forward along the clip outline to wherever the next chain enters (both outlines\n * have the same orientation, so \"forward\" stays on the inside).\n */\nexport function clipPolygonToConvex(subject: Polygon, clip: Polygon): Polygon[] {\n const P = ensurePositive(subject);\n const C = ensurePositive(clip);\n const n = P.length;\n const m = C.length;\n if (n < 3 || m < 3) return [];\n let scale = 0;\n for (const v of C) scale = Math.max(scale, Math.abs(v.x), Math.abs(v.y));\n const eps = 1e-12 * Math.max(1, scale);\n\n // Inward normals of the clip edges.\n const normals = C.map((a, i) => {\n const b = C[(i + 1) % m]!;\n const len = Math.hypot(b.x - a.x, b.y - a.y) || 1;\n return vec(-(b.y - a.y) / len, (b.x - a.x) / len);\n });\n\n /** Cyrus–Beck: the part [t0, t1] of segment a→b inside C, or null. */\n const clipSegment = (a: Vec, b: Vec): [number, number] | null => {\n let t0 = 0;\n let t1 = 1;\n for (let i = 0; i < m; i++) {\n const c = C[i]!;\n const nrm = normals[i]!;\n const num = nrm.x * (a.x - c.x) + nrm.y * (a.y - c.y) + eps;\n const den = nrm.x * (b.x - a.x) + nrm.y * (b.y - a.y);\n if (Math.abs(den) < 1e-15) {\n if (num < 0) return null;\n } else if (den > 0) {\n t0 = Math.max(t0, -num / den);\n } else {\n t1 = Math.min(t1, -num / den);\n }\n if (t0 > t1) return null;\n }\n return [t0, t1];\n };\n\n /** Position along the clip outline: edge index + fraction (0 ≤ s < m). */\n const outlinePos = (p: Vec): number => {\n let best = 0;\n let bestD = Infinity;\n for (let i = 0; i < m; i++) {\n const a = C[i]!;\n const b = C[(i + 1) % m]!;\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n const t = Math.max(0, Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / (dx * dx + dy * dy || 1)));\n const d = Math.hypot(p.x - a.x - t * dx, p.y - a.y - t * dy);\n if (d < bestD) {\n bestD = d;\n best = (i + t) % m;\n }\n }\n return best;\n };\n\n // Chains of inside stretches. A chain continues across a vertex when one edge's inside\n // part ends at the vertex and the next edge's starts there.\n type Chain = { points: Vec[]; open: boolean; close: boolean };\n const chains: Chain[] = [];\n const at = (a: Vec, b: Vec, t: number) => vec(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t);\n const tiny = 1e-12;\n let current: Chain | null = null;\n for (let i = 0; i < n; i++) {\n const a = P[i]!;\n const b = P[(i + 1) % n]!;\n const part = clipSegment(a, b);\n if (!part) {\n current = null;\n continue;\n }\n const [t0, t1] = part;\n if (current && t0 <= tiny) {\n current.points.push(at(a, b, t1));\n } else {\n current = { points: [at(a, b, t0), at(a, b, t1)], open: t0 > tiny, close: false };\n chains.push(current);\n }\n if (t1 < 1 - tiny) {\n current.close = true;\n current = null;\n }\n }\n if (chains.length === 0) {\n // No part of the outline is inside: either C lies within P, or they don't meet.\n return pointInPolygon(C[0]!, P) ? [C] : [];\n }\n // The walk started mid-chain if the last chain runs into the first one.\n if (chains.length > 1) {\n const last = chains[chains.length - 1]!;\n const first = chains[0]!;\n if (!last.close && !first.open) {\n first.points = [...last.points, ...first.points.slice(1)];\n first.open = last.open;\n chains.pop();\n }\n }\n if (chains.length === 1 && !chains[0]!.open && !chains[0]!.close) return [P];\n\n const entries = chains.map((c) => outlinePos(c.points[0]!));\n const exits = chains.map((c) => outlinePos(c.points[c.points.length - 1]!));\n const forward = (from: number, to: number) => ((to - from) % m + m) % m;\n\n const used = new Array<boolean>(chains.length).fill(false);\n const pieces: Polygon[] = [];\n for (let start = 0; start < chains.length; start++) {\n if (used[start]) continue;\n const piece: Vec[] = [];\n let k = start;\n for (let guard = 0; guard <= chains.length; guard++) {\n used[k] = true;\n piece.push(...chains[k]!.points);\n // Next chain to enter, walking forward along the clip outline from this exit.\n const s = exits[k]!;\n let next = -1;\n let bestGap = Infinity;\n for (let j = 0; j < chains.length; j++) {\n const gap = forward(s, entries[j]!);\n if (gap < bestGap - 1e-12) {\n bestGap = gap;\n next = j;\n }\n }\n // Clip corners passed on the way.\n for (let step = 1; step <= m; step++) {\n const corner = (Math.floor(s) + step) % m;\n if (forward(s, corner) > 0 && forward(s, corner) < bestGap) piece.push(C[corner]!);\n else break;\n }\n if (next === start || used[next]) break;\n k = next;\n }\n const clean = dropSpikes(cleanPolygon(piece), eps * 1e3);\n if (clean.length >= 3) pieces.push(clean);\n }\n return pieces;\n}\n\n/**\n * Remove zero-width spikes: points where the outline runs out along a line and straight\n * back (a tile edge lying along the clip edge can leave one). They have no area, but they\n * confuse anything that follows the outline, such as bevels.\n */\nfunction dropSpikes(poly: Polygon, tol: number): Polygon {\n let pts = poly;\n for (let changed = true; changed && pts.length >= 3; ) {\n changed = false;\n for (let i = 0; i < pts.length && pts.length >= 3; i++) {\n const n = pts.length;\n const a = pts[(i - 1 + n) % n]!, v = pts[i]!, b = pts[(i + 1) % n]!;\n const ux = v.x - a.x, uy = v.y - a.y, wx = b.x - v.x, wy = b.y - v.y;\n const lu = Math.hypot(ux, uy), lw = Math.hypot(wx, wy);\n const flat = Math.abs(ux * wy - uy * wx) <= tol * Math.max(lu, lw, tol);\n if (lu <= tol || lw <= tol || (flat && ux * wx + uy * wy < 0)) {\n pts = [...pts.slice(0, i), ...pts.slice(i + 1)];\n changed = true;\n i--;\n }\n }\n }\n return pts.length >= 3 ? pts : [];\n}\n","import { area, centroid, signedArea, vec, type Polygon, type Vec } from \"./geometry\";\nimport { pointInPolygon } from \"./offset\";\n\n/**\n * Polygon boolean operations by overlay.\n *\n * Every input outline is cut at every point where it meets another, giving a set of\n * pieces that don't cross. For each piece, a point just to its left and just to its\n * right is tested against what the result should contain (any combination of inside /\n * outside tests). Pieces with the result on exactly one side form the result's\n * boundary, oriented with the result on the left, and are chained into loops.\n *\n * This handles holes, shapes touching at a point, and edges that run along each other,\n * as long as features are much larger than the tolerance.\n */\n\n/** A region with holes: `outer` is positively oriented, `holes` negatively. */\nexport interface Shape {\n outer: Polygon;\n holes: Polygon[];\n}\n\ntype Seg = { ax: number; ay: number; bx: number; by: number };\n\n/**\n * The boundary of `{ p : inside(p) }` among the given outlines, as shapes.\n * `scale` is the size of the scene; tolerances are relative to it.\n */\nexport function overlay(outlines: Polygon[], inside: (p: Vec) => boolean, scale: number): Shape[] {\n const { vx, vy, pieces, eps, delta } = splitSegments(outlines, scale);\n const from: number[] = [], to: number[] = [];\n for (const [a, b] of pieces) {\n const { left, right } = sides(vx, vy, a, b, delta, inside);\n if (left && !right) { from.push(a); to.push(b); }\n else if (right && !left) { from.push(b); to.push(a); }\n }\n return assemble(chainLoops(from, to, vx, vy, eps, scale), delta);\n}\n\n/**\n * Split the plane into regions by a labeling function: each point gets a label (a number;\n * negative for \"nothing\"), and every region of equal label is returned as shapes. The\n * labels may only change across the given outlines (closed loops; pass an open polyline's\n * segments as two-point \"loops\"), which are cut where they meet like `overlay`'s.\n */\nexport function partition(outlines: Polygon[], label: (p: Vec) => number, scale: number): Map<number, Shape[]> {\n const { vx, vy, pieces, eps, delta } = splitSegments(outlines, scale);\n const edges = new Map<number, { from: number[]; to: number[] }>();\n const add = (l: number, a: number, b: number) => {\n if (l < 0) return;\n let e = edges.get(l);\n if (!e) edges.set(l, (e = { from: [], to: [] }));\n e.from.push(a);\n e.to.push(b);\n };\n for (const [a, b] of pieces) {\n const { left, right } = sides(vx, vy, a, b, delta, label);\n if (left === right) continue;\n // Each region keeps its boundary on its left.\n add(left, a, b);\n add(right, b, a);\n }\n const out = new Map<number, Shape[]>();\n for (const [l, e] of edges) {\n const shapes = assemble(chainLoops(e.from, e.to, vx, vy, eps, scale), delta);\n if (shapes.length) out.set(l, shapes);\n }\n return out;\n}\n\n/** What `f` says just left and just right of the middle of piece a→b. */\nfunction sides<T>(vx: number[], vy: number[], a: number, b: number, delta: number, f: (p: Vec) => T): { left: T; right: T } {\n const ax = vx[a]!, ay = vy[a]!, bx = vx[b]!, by = vy[b]!;\n const len = Math.hypot(bx - ax, by - ay);\n const mx = (ax + bx) / 2, my = (ay + by) / 2;\n // Left normal of (dx, dy) is (-dy, dx).\n const nx = (-(by - ay) / len) * delta, ny = ((bx - ax) / len) * delta;\n return { left: f(vec(mx + nx, my + ny)), right: f(vec(mx - nx, my - ny)) };\n}\n\n/**\n * Every outline cut at every point where it meets another: the pieces (as vertex index\n * pairs, deduplicated) and the shared vertices.\n */\nfunction splitSegments(outlines: Polygon[], scale: number) {\n const eps = 1e-9 * scale;\n const delta = 1e-7 * scale;\n\n const segs: Seg[] = [];\n for (const poly of outlines) {\n for (let i = 0, n = poly.length; i < n; i++) {\n const a = poly[i]!;\n const b = poly[(i + 1) % n]!;\n if (Math.hypot(b.x - a.x, b.y - a.y) > eps) segs.push({ ax: a.x, ay: a.y, bx: b.x, by: b.y });\n }\n }\n\n // Cut points per segment, as (t, x, y).\n const cuts: number[][] = segs.map((s) => [0, s.ax, s.ay, 1, s.bx, s.by]);\n const addCut = (k: number, t: number, x: number, y: number) => cuts[k]!.push(t, x, y);\n\n /** If point (x, y) lies on segment k away from its ends, cut it there. */\n const touch = (k: number, x: number, y: number) => {\n const s = segs[k]!;\n const dx = s.bx - s.ax, dy = s.by - s.ay;\n const len = Math.hypot(dx, dy);\n const t = ((x - s.ax) * dx + (y - s.ay) * dy) / (len * len);\n if (t * len <= eps || (1 - t) * len <= eps) return false;\n if (Math.abs((x - s.ax) * dy - (y - s.ay) * dx) / len > eps) return false;\n addCut(k, t, x, y);\n return true;\n };\n\n // Sweep over segments sorted by left end; only overlapping x-ranges can meet.\n const order = segs.map((_, i) => i);\n const x0 = segs.map((s) => Math.min(s.ax, s.bx));\n const x1 = segs.map((s) => Math.max(s.ax, s.bx));\n order.sort((a, b) => x0[a]! - x0[b]!);\n for (let oi = 0; oi < order.length; oi++) {\n const i = order[oi]!;\n const p = segs[i]!;\n const pminY = Math.min(p.ay, p.by), pmaxY = Math.max(p.ay, p.by);\n for (let oj = oi + 1; oj < order.length; oj++) {\n const j = order[oj]!;\n if (x0[j]! > x1[i]! + eps) break;\n const q = segs[j]!;\n if (Math.min(q.ay, q.by) > pmaxY + eps || Math.max(q.ay, q.by) < pminY - eps) continue;\n // Ends lying on the other segment (T-junctions and overlapping runs).\n const t1 = touch(i, q.ax, q.ay);\n const t2 = touch(i, q.bx, q.by);\n const t3 = touch(j, p.ax, p.ay);\n const t4 = touch(j, p.bx, p.by);\n if (t1 || t2 || t3 || t4) continue;\n // A proper crossing.\n const d1x = p.bx - p.ax, d1y = p.by - p.ay;\n const d2x = q.bx - q.ax, d2y = q.by - q.ay;\n const den = d1x * d2y - d1y * d2x;\n const l1 = Math.hypot(d1x, d1y), l2 = Math.hypot(d2x, d2y);\n // (Nearly) parallel: no proper crossing. Runs along each other were cut above; and\n // for collinear segments meeting end to end, dividing by a rounding-error `den`\n // would put a bogus cut anywhere along them.\n if (Math.abs(den) <= 1e-9 * l1 * l2) continue;\n const s = ((q.ax - p.ax) * d2y - (q.ay - p.ay) * d2x) / den;\n const r = ((q.ax - p.ax) * d1y - (q.ay - p.ay) * d1x) / den;\n if (s * l1 <= eps || (1 - s) * l1 <= eps || r * l2 <= eps || (1 - r) * l2 <= eps) continue;\n const x = p.ax + d1x * s, y = p.ay + d1y * s;\n addCut(i, s, x, y);\n addCut(j, r, x, y);\n }\n }\n\n // Shared vertices: points closer than eps are the same vertex.\n const vx: number[] = [], vy: number[] = [];\n const grid = new Map<string, number[]>();\n const cell = eps * 4;\n const vertex = (x: number, y: number): number => {\n const gx = Math.floor(x / cell), gy = Math.floor(y / cell);\n for (let dx = -1; dx <= 1; dx++) {\n for (let dy = -1; dy <= 1; dy++) {\n for (const v of grid.get(`${gx + dx},${gy + dy}`) ?? []) {\n if (Math.abs(vx[v]! - x) <= eps * 2 && Math.abs(vy[v]! - y) <= eps * 2) return v;\n }\n }\n }\n const id = vx.length;\n vx.push(x);\n vy.push(y);\n const key = `${gx},${gy}`;\n const list = grid.get(key);\n if (list) list.push(id);\n else grid.set(key, [id]);\n return id;\n };\n\n // Pieces between consecutive cuts, deduplicated (overlapping runs give the same piece twice).\n const seen = new Set<string>();\n const pieces: [number, number][] = [];\n for (const c of cuts) {\n const idx = Array.from({ length: c.length / 3 }, (_, k) => k).sort((a, b) => c[a * 3]! - c[b * 3]!);\n let prev = vertex(c[idx[0]! * 3 + 1]!, c[idx[0]! * 3 + 2]!);\n for (let k = 1; k < idx.length; k++) {\n const v = vertex(c[idx[k]! * 3 + 1]!, c[idx[k]! * 3 + 2]!);\n if (v === prev) continue;\n const key = prev < v ? `${prev},${v}` : `${v},${prev}`;\n if (!seen.has(key)) {\n seen.add(key);\n pieces.push([prev, v]);\n }\n prev = v;\n }\n }\n return { vx, vy, pieces, eps, delta };\n}\n\n/**\n * Chain directed boundary pieces into closed loops. Where several continue from one vertex\n * (shapes touching at a point), take the sharpest left turn, which keeps the loops separate.\n */\nfunction chainLoops(from: number[], to: number[], vx: number[], vy: number[], eps: number, scale: number): Polygon[] {\n const outgoing = new Map<number, number[]>();\n from.forEach((v, e) => {\n const list = outgoing.get(v);\n if (list) list.push(e);\n else outgoing.set(v, [e]);\n });\n const used = new Uint8Array(from.length);\n const loops: Polygon[] = [];\n // Where a chain dead-ends, carry on from an unused piece starting a hair away: points\n // where segments meet at a shallow angle can land a few rounding errors apart.\n const slop = 1e-6 * scale;\n const cell = slop * 4;\n const near = new Map<string, number[]>();\n from.forEach((v, e) => {\n const key = `${Math.floor(vx[v]! / cell)},${Math.floor(vy[v]! / cell)}`;\n const list = near.get(key);\n if (list) list.push(e);\n else near.set(key, [e]);\n });\n const nearby = (x: number, y: number): number[] => {\n const gx = Math.floor(x / cell), gy = Math.floor(y / cell);\n const out: number[] = [];\n for (let dx = -1; dx <= 1; dx++) {\n for (let dy = -1; dy <= 1; dy++) {\n for (const e of near.get(`${gx + dx},${gy + dy}`) ?? []) {\n if (!used[e] && Math.hypot(vx[from[e]!]! - x, vy[from[e]!]! - y) <= slop) out.push(e);\n }\n }\n }\n return out;\n };\n for (let e0 = 0; e0 < from.length; e0++) {\n if (used[e0]) continue;\n used[e0] = 1;\n const start = from[e0]!;\n // The chain so far; a piece leading nowhere (a misjudged crumb where lines nearly meet)\n // is dropped and the chain backs up to try the next turn.\n const path = [e0];\n let closed = false;\n for (let guard = 0; guard <= 4 * from.length && path.length; guard++) {\n const e = path[path.length - 1]!;\n const v = to[e]!;\n if (v === start) { closed = true; break; }\n const inx = vx[v]! - vx[from[e]!]!, iny = vy[v]! - vy[from[e]!]!;\n let best = -1, bestTurn = -Infinity;\n const consider = (f: number) => {\n const ox = vx[to[f]!]! - vx[v]!, oy = vy[to[f]!]! - vy[v]!;\n const turn = Math.atan2(inx * oy - iny * ox, inx * ox + iny * oy);\n if (turn > bestTurn) { bestTurn = turn; best = f; }\n };\n for (const f of outgoing.get(v) ?? []) if (!used[f]) consider(f);\n if (best < 0) {\n // Carry on from an unused piece starting a hair away, or close if the start is.\n if (Math.hypot(vx[v]! - vx[start]!, vy[v]! - vy[start]!) <= slop) { closed = true; break; }\n for (const f of nearby(vx[v]!, vy[v]!)) consider(f);\n }\n if (best >= 0) {\n used[best] = 1;\n path.push(best);\n } else path.pop();\n }\n if (closed) {\n const loop = path.map((e) => vec(vx[from[e]!]!, vy[from[e]!]!));\n const clean = dropCollinear(loop, eps);\n if (clean.length >= 3 && Math.abs(signedArea(clean)) > eps * scale) loops.push(clean);\n }\n }\n return loops;\n}\n\n/** Positive loops are outlines, negative ones holes; each hole goes in the smallest outline around it. */\nfunction assemble(loops: Polygon[], delta: number): Shape[] {\n const outers = loops.filter((l) => signedArea(l) > 0).sort((a, b) => area(a) - area(b));\n const shapes: Shape[] = outers.map((outer) => ({ outer, holes: [] }));\n for (const hole of loops.filter((l) => signedArea(l) < 0)) {\n // A point just inside the result next to the hole: left of its first edge.\n const a = hole[0]!, b = hole[1]!;\n const len = Math.hypot(b.x - a.x, b.y - a.y);\n const p = vec((a.x + b.x) / 2 - ((b.y - a.y) / len) * delta, (a.y + b.y) / 2 + ((b.x - a.x) / len) * delta);\n const home = shapes.find((s) => pointInPolygon(p, s.outer));\n if (home) home.holes.push(hole);\n }\n return shapes;\n}\n\n\nfunction dropCollinear(loop: Vec[], eps: number): Vec[] {\n let pts = loop;\n for (let changed = true; changed && pts.length >= 3; ) {\n changed = false;\n const out: Vec[] = [];\n for (let i = 0; i < pts.length; i++) {\n const a = out.length ? out[out.length - 1]! : pts[pts.length - 1]!;\n const v = pts[i]!;\n const b = pts[(i + 1) % pts.length]!;\n const ux = v.x - a.x, uy = v.y - a.y, wx = b.x - v.x, wy = b.y - v.y;\n const lw = Math.hypot(wx, wy) || 1;\n // v is on the straight line from a to b, going forward.\n if (Math.abs(ux * wy - uy * wx) / lw <= eps && ux * wx + uy * wy > 0) { changed = true; continue; }\n out.push(v);\n }\n pts = out;\n }\n return pts;\n}\n\n/** Even–odd membership in a set of non-overlapping loops (outlines and their holes). */\nexport function inShapes(p: Vec, loops: Polygon[]): boolean {\n let inside = false;\n for (const l of loops) if (pointInPolygon(p, l)) inside = !inside;\n return inside;\n}\n\n/** Area of a shape (outline minus holes). */\nexport const shapeArea = (s: Shape): number => area(s.outer) - s.holes.reduce((sum, h) => sum + area(h), 0);\n\n/** Centroid of a shape, holes included. */\nexport function shapeCentroid(s: Shape): Vec {\n let ax = 0, ay = 0, aw = 0;\n for (const [loop, sign] of [[s.outer, 1], ...s.holes.map((h) => [h, -1] as const)] as const) {\n const a = area(loop);\n const c = centroid(loop);\n ax += c.x * a * sign;\n ay += c.y * a * sign;\n aw += a * sign;\n }\n return aw > 0 ? vec(ax / aw, ay / aw) : centroid(s.outer);\n}\n","/** Small, fast, seedable PRNG returning floats in [0, 1). */\nexport function mulberry32(seed: number): () => number {\n let a = seed >>> 0;\n return () => {\n a = (a + 0x6d2b79f5) >>> 0;\n let t = a;\n t = Math.imul(t ^ (t >>> 15), t | 1);\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61);\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n","import { bbox, centroid, clipHalfPlane, rectPolygon, sub, vec, type Polygon, type Rect, type Vec } from \"./geometry\";\nimport { mulberry32 } from \"./random\";\nimport type { AshlarSpec, DelaunaySpec, GenerateContext, JigsawSpec, RawTile, VoronoiSpec } from \"./tilings\";\n\n/*\n * Seeded, non-periodic generators. Like Mondrian they fill the bounding box of the\n * region (the layout then clips to the region itself) and ignore rotation and origin.\n */\n\nfunction positive(name: string, value: number | undefined): number {\n if (value === undefined || !Number.isFinite(value) || value <= 0) {\n throw new RangeError(`${name} must be a positive number (got ${value})`);\n }\n return value;\n}\n\nfunction checkCount(kind: string, count: number, ctx: GenerateContext) {\n if (count > ctx.maxTiles) {\n throw new RangeError(\n `Tiles are too small for this region (~${Math.round(count)} ${kind} cells, limit ${ctx.maxTiles}). ` +\n \"Increase the size or raise maxTiles.\",\n );\n }\n}\n\n/**\n * Random points in `box`, about one per `size × size` square; with `sizeAt`, about one per\n * `(size · sizeAt(p))²` instead (thinned from the densest rate), so cells shrink where it's small.\n */\nfunction randomSites(box: Rect, size: number, rng: () => number, sizeAt?: (p: Vec) => number): Vec[] {\n if (!sizeAt) {\n const n = Math.max(1, Math.round((box.width * box.height) / (size * size)));\n return Array.from({ length: n }, () => vec(box.x + rng() * box.width, box.y + rng() * box.height));\n }\n const fmin = minOver(sizeAt, box);\n const n = Math.max(1, Math.round((box.width * box.height) / (size * fmin) ** 2));\n const out: Vec[] = [];\n for (let i = 0; i < n; i++) {\n const p = vec(box.x + rng() * box.width, box.y + rng() * box.height);\n if (rng() < (fmin / Math.max(fmin, sizeAt(p))) ** 2) out.push(p);\n }\n return out.length ? out : [vec(box.x + box.width / 2, box.y + box.height / 2)];\n}\n\n/** Smallest value of a size factor over a box (sampled), clamped to (0, 1]. */\nfunction minOver(sizeAt: (p: Vec) => number, box: Rect): number {\n let m = 1;\n for (let i = 0; i <= 32; i++) for (let j = 0; j <= 32; j++) m = Math.min(m, sizeAt(vec(box.x + (box.width * i) / 32, box.y + (box.height * j) / 32)));\n return Math.max(m, 1e-3);\n}\n\n/** Expected number of sites `randomSites` gives. */\nfunction expectedSites(box: Rect, size: number, sizeAt?: (p: Vec) => number): number {\n if (!sizeAt) return (box.width * box.height) / (size * size);\n let sum = 0;\n for (let i = 0; i < 32; i++) {\n for (let j = 0; j < 32; j++) {\n const f = Math.max(1e-3, sizeAt(vec(box.x + (box.width * (i + 0.5)) / 32, box.y + (box.height * (j + 0.5)) / 32)));\n sum += 1 / (f * f);\n }\n }\n return ((box.width * box.height) / (size * size)) * (sum / 1024);\n}\n\n/**\n * Voronoi cells of `sites` within `box`: each cell is the box clipped by the\n * perpendicular bisectors towards nearby sites. Neighbors are visited ring by ring\n * through a bucket grid, stopping once no further site can cut the cell.\n */\nexport function voronoiCells(sites: Vec[], box: Rect): Polygon[] {\n const n = sites.length;\n const g = Math.max(1e-9, Math.sqrt((box.width * box.height) / Math.max(1, n)));\n const cols = Math.max(1, Math.ceil(box.width / g));\n const rows = Math.max(1, Math.ceil(box.height / g));\n const buckets: number[][] = Array.from({ length: cols * rows }, () => []);\n const colOf = (p: Vec) => Math.min(cols - 1, Math.max(0, Math.floor((p.x - box.x) / g)));\n const rowOf = (p: Vec) => Math.min(rows - 1, Math.max(0, Math.floor((p.y - box.y) / g)));\n sites.forEach((p, i) => buckets[rowOf(p) * cols + colOf(p)]!.push(i));\n\n const boxPoly = rectPolygon(box.x, box.y, box.width, box.height);\n return sites.map((p, i) => {\n let cell = boxPoly;\n const c0 = colOf(p);\n const r0 = rowOf(p);\n for (let ring = 0; ring <= Math.max(cols, rows); ring++) {\n // Sites in this ring are at least (ring - 1)·g away; a site further than twice the\n // cell's radius can't cut it.\n let radius = 0;\n for (const v of cell) radius = Math.max(radius, Math.hypot(v.x - p.x, v.y - p.y));\n if ((ring - 1) * g > 2 * radius) break;\n for (let r = r0 - ring; r <= r0 + ring; r++) {\n if (r < 0 || r >= rows) continue;\n for (let c = c0 - ring; c <= c0 + ring; c++) {\n if (c < 0 || c >= cols) continue;\n if (Math.max(Math.abs(r - r0), Math.abs(c - c0)) !== ring) continue;\n for (const j of buckets[r * cols + c]!) {\n if (j === i) continue;\n const q = sites[j]!;\n // Keep the side of the bisector nearer to p.\n const mid = vec((p.x + q.x) / 2, (p.y + q.y) / 2);\n cell = clipHalfPlane(cell, mid, sub(p, q));\n }\n }\n }\n }\n return cell;\n });\n}\n\n/**\n * Lloyd relaxation: move each free site to the centroid of its cell, `rounds` times. With\n * `sizeAt`, centroids are weighted by density (1 / size²), which evens out spacing locally\n * while keeping the change in size across the box.\n */\nfunction relax(sites: Vec[], fixed: number, box: Rect, rounds: number, sizeAt?: (p: Vec) => number): Vec[] {\n let out = sites;\n for (let k = 0; k < rounds; k++) {\n const cells = voronoiCells(out, box);\n out = out.map((p, i) => (i < fixed || cells[i]!.length < 3 ? p : sizeAt ? weightedCentroid(cells[i]!, sizeAt) : centroid(cells[i]!)));\n }\n return out;\n}\n\n/** Centroid of a convex polygon with density 1 / sizeAt², by fan triangles. */\nfunction weightedCentroid(poly: Polygon, sizeAt: (p: Vec) => number): Vec {\n let sx = 0, sy = 0, sw = 0;\n const a = poly[0]!;\n for (let i = 1; i + 1 < poly.length; i++) {\n const b = poly[i]!, c = poly[i + 1]!;\n const ar = Math.abs((b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)) / 2;\n const m = vec((a.x + b.x + c.x) / 3, (a.y + b.y + c.y) / 3);\n const f = Math.max(1e-3, sizeAt(m));\n const w = ar / (f * f);\n sx += m.x * w; sy += m.y * w; sw += w;\n }\n return sw > 0 ? vec(sx / sw, sy / sw) : centroid(poly);\n}\n\nexport function generateVoronoi(spec: VoronoiSpec, ctx: GenerateContext): RawTile[] {\n const size = positive(\"voronoi.size\", spec.size);\n const box = bbox(ctx.region);\n checkCount(\"Voronoi\", expectedSites(box, size, ctx.sizeAt), ctx);\n const rng = mulberry32(spec.seed ?? 1);\n const sites = relax(randomSites(box, size, rng, ctx.sizeAt), 0, box, Math.max(0, Math.round(spec.relax ?? 2)), ctx.sizeAt);\n return voronoiCells(sites, box)\n .map((polygon, i) => ({ id: `v${i}`, polygon, protoTile: 0 }))\n .filter((t) => t.polygon.length >= 3);\n}\n\n/** Bowyer–Watson Delaunay triangulation. Returns index triples into `pts`. */\nexport function delaunayTriangles(pts: Vec[]): [number, number, number][] {\n const box = bbox(pts);\n const cx = box.x + box.width / 2;\n const cy = box.y + box.height / 2;\n const d = Math.max(box.width, box.height, 1) * 50;\n const all = [...pts, vec(cx - d, cy - d), vec(cx + d, cy - d), vec(cx, cy + d)];\n const n = pts.length;\n\n type Tri = { a: number; b: number; c: number; x: number; y: number; r2: number };\n const make = (a: number, b: number, c: number): Tri => {\n const A = all[a]!, B = all[b]!, C = all[c]!;\n const D = 2 * (A.x * (B.y - C.y) + B.x * (C.y - A.y) + C.x * (A.y - B.y));\n const a2 = A.x * A.x + A.y * A.y, b2 = B.x * B.x + B.y * B.y, c2 = C.x * C.x + C.y * C.y;\n const x = (a2 * (B.y - C.y) + b2 * (C.y - A.y) + c2 * (A.y - B.y)) / D;\n const y = (a2 * (C.x - B.x) + b2 * (A.x - C.x) + c2 * (B.x - A.x)) / D;\n return { a, b, c, x, y, r2: (A.x - x) ** 2 + (A.y - y) ** 2 };\n };\n\n let tris: Tri[] = [make(n, n + 1, n + 2)];\n for (let i = 0; i < n; i++) {\n const p = all[i]!;\n const bad: Tri[] = [];\n const keep: Tri[] = [];\n for (const t of tris) ((p.x - t.x) ** 2 + (p.y - t.y) ** 2 < t.r2 ? bad : keep).push(t);\n // Boundary of the cavity: edges belonging to exactly one bad triangle.\n const edges = new Map<string, [number, number]>();\n for (const t of bad) {\n for (const [u, v] of [[t.a, t.b], [t.b, t.c], [t.c, t.a]] as const) {\n const key = u < v ? `${u},${v}` : `${v},${u}`;\n if (edges.has(key)) edges.delete(key);\n else edges.set(key, [u, v]);\n }\n }\n for (const [u, v] of edges.values()) keep.push(make(u, v, i));\n tris = keep;\n }\n return tris.filter((t) => t.a < n && t.b < n && t.c < n).map((t) => [t.a, t.b, t.c]);\n}\n\nexport function generateDelaunay(spec: DelaunaySpec, ctx: GenerateContext): RawTile[] {\n const size = positive(\"delaunay.size\", spec.size);\n const box = bbox(ctx.region);\n // Roughly two triangles per site.\n checkCount(\"triangle\", 2 * expectedSites(box, size, ctx.sizeAt), ctx);\n const rng = mulberry32(spec.seed ?? 1);\n\n // Fixed sites around the outside of the box, nudged outwards at random so the\n // triangulation covers the whole box and no four points are exactly cocircular.\n const pad = () => size * (0.05 + 0.1 * rng());\n const { x, y, width: w, height: h } = box;\n const ring: Vec[] = [vec(x - pad(), y - pad()), vec(x + w + pad(), y - pad()), vec(x + w + pad(), y + h + pad()), vec(x - pad(), y + h + pad())];\n // Points along the outside, closer together where tiles should be small.\n const local = (p: Vec) => size * Math.min(1, Math.max(0.05, ctx.sizeAt ? ctx.sizeAt(p) : 1));\n // Evenly spaced along each side, at the smallest size wanted along it.\n const along = (len: number, a: Vec, b: Vec) => {\n let step = Infinity;\n for (let t = 0; t <= 1; t += 0.125) step = Math.min(step, local(vec(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t)));\n return Math.max(1, Math.round(len / step));\n };\n for (let k = 1, m = along(w, vec(x, y), vec(x + w, y)); k < m; k++) ring.push(vec(x + (w * k) / m, y - pad()));\n for (let k = 1, m = along(w, vec(x, y + h), vec(x + w, y + h)); k < m; k++) ring.push(vec(x + w - (w * k) / m, y + h + pad()));\n for (let k = 1, m = along(h, vec(x + w, y), vec(x + w, y + h)); k < m; k++) ring.push(vec(x + w + pad(), y + (h * k) / m));\n for (let k = 1, m = along(h, vec(x, y), vec(x, y + h)); k < m; k++) ring.push(vec(x - pad(), y + h - (h * k) / m));\n\n const outer: Rect = { x: x - size, y: y - size, width: w + 2 * size, height: h + 2 * size };\n const inner: Rect = { x: x + size / 4, y: y + size / 4, width: Math.max(0, w - size / 2), height: Math.max(0, h - size / 2) };\n const sites = relax([...ring, ...randomSites(inner, size, rng, ctx.sizeAt)], ring.length, outer, Math.max(0, Math.round(spec.relax ?? 2)), ctx.sizeAt);\n\n return delaunayTriangles(sites).map(([a, b, c], i) => ({\n id: `d${i}`,\n polygon: [sites[a]!, sites[b]!, sites[c]!],\n protoTile: 0,\n }));\n}\n\nexport function generateAshlar(spec: AshlarSpec, ctx: GenerateContext): RawTile[] {\n const height = positive(\"ashlar.height\", spec.height);\n const minL = positive(\"ashlar.minLength\", spec.minLength);\n const maxL = positive(\"ashlar.maxLength\", spec.maxLength);\n if (maxL < minL) throw new RangeError(\"ashlar.maxLength must be at least ashlar.minLength\");\n const variation = Math.min(0.9, Math.max(0, spec.heightVariation ?? 0));\n const box = bbox(ctx.region);\n checkCount(\"ashlar\", (box.width * box.height) / (height * minL), ctx);\n const rng = mulberry32(spec.seed ?? 1);\n const between = (lo: number, hi: number) => lo + rng() * (hi - lo);\n const minCourse = height * (1 - variation);\n const maxCourse = height * (1 + variation);\n\n const tiles: RawTile[] = [];\n const right = box.x + box.width;\n const bottom = box.y + box.height;\n let prevSeams: number[] = [];\n let y = box.y;\n for (let row = 0; y < bottom - 1e-9; row++) {\n let h = height * (1 + variation * (2 * rng() - 1));\n // Never leave less than a minimum course below: take the rest in one course if it\n // fits, otherwise split it evenly over two.\n const rest = bottom - y;\n if (rest - h < minCourse) h = rest <= maxCourse ? rest : rest / 2;\n\n const seams: number[] = [];\n let x = box.x;\n for (let k = 0; x < right - 1e-9; k++) {\n const rest = right - x;\n let len = 0;\n // Avoid lining up with a joint in the course above; a few tries is plenty.\n for (let attempt = 0; attempt < 6; attempt++) {\n if (rest <= maxL) len = rest;\n else if (rest < maxL + minL) len = between(Math.min(minL, rest / 2), rest - Math.min(minL, rest / 2));\n else len = between(minL, maxL);\n const seam = x + len;\n if (len === rest || prevSeams.every((s) => Math.abs(s - seam) > minL / 4)) break;\n }\n tiles.push({ id: `a${row}-${k}`, polygon: rectPolygon(x, y, len, h), protoTile: 0 });\n x += len;\n if (x < right - 1e-9) seams.push(x);\n }\n prevSeams = seams;\n y += h;\n }\n return tiles;\n}\n\n/**\n * Points of one jigsaw tab along the edge p → q (excluding p and q), bulging to the\n * left of the direction of travel when `side` is 1 and to the right when it is -1.\n * `unit` sets the tab's size; `at` (0–1) is where along the edge it sits.\n */\nfunction tab(p: Vec, q: Vec, side: number, unit: number, at: number): Vec[] {\n const len = Math.hypot(q.x - p.x, q.y - p.y);\n const u = vec((q.x - p.x) / len, (q.y - p.y) / len);\n const n = vec(u.y * side, -u.x * side);\n const put = (along: number, out: number) => vec(p.x + u.x * along + n.x * out, p.y + u.y * along + n.y * out);\n const c = len * at; // tab center, along the edge\n const head = 0.2 * unit; // head center, out from the edge\n const r = 0.12 * unit;\n const neck = 0.9; // radians either side of \"straight back at the edge\" where the head meets the neck\n const pts: Vec[] = [put(c - 0.12 * unit, 0)];\n // Round the head the long way: from the neck on one side, out and around, to the other.\n const steps = 18;\n const start = -Math.PI / 2 - neck;\n const sweep = -(2 * Math.PI - 2 * neck);\n for (let k = 0; k <= steps; k++) {\n const a = start + (sweep * k) / steps;\n // Local frame: x along the edge, y outward (so -π/2 points back at the edge).\n pts.push(put(c + r * Math.cos(a), head + r * Math.sin(a)));\n }\n pts.push(put(c + 0.12 * unit, 0));\n return pts;\n}\n\n/**\n * A jigsaw puzzle: a grid sized to fit the region's bounding box exactly, with a tab\n * on every inner edge pointing randomly into one of the two pieces.\n */\nexport function generateJigsaw(spec: JigsawSpec, ctx: GenerateContext): RawTile[] {\n const size = positive(\"jigsaw.size\", spec.size);\n const box = bbox(ctx.region);\n const cols = Math.max(1, Math.round(box.width / size));\n const rows = Math.max(1, Math.round(box.height / size));\n checkCount(\"jigsaw\", cols * rows, ctx);\n const rng = mulberry32(spec.seed ?? 1);\n const cw = box.width / cols;\n const ch = box.height / rows;\n const unit = Math.min(cw, ch);\n const corner = (i: number, j: number) => vec(box.x + i * cw, box.y + j * ch);\n\n // Shared edges, each stored once in a fixed direction: horizontal edges left → right,\n // vertical edges top → bottom. Border edges stay straight.\n const edge = (p: Vec, q: Vec, inner: boolean): Vec[] => (inner ? tab(p, q, rng() < 0.5 ? 1 : -1, unit, 0.42 + 0.16 * rng()) : []);\n const horizontal: Vec[][][] = [];\n for (let j = 0; j <= rows; j++) {\n horizontal.push([]);\n for (let i = 0; i < cols; i++) horizontal[j]!.push(edge(corner(i, j), corner(i + 1, j), j > 0 && j < rows));\n }\n const vertical: Vec[][][] = [];\n for (let i = 0; i <= cols; i++) {\n vertical.push([]);\n for (let j = 0; j < rows; j++) vertical[i]!.push(edge(corner(i, j), corner(i, j + 1), i > 0 && i < cols));\n }\n\n const tiles: RawTile[] = [];\n for (let j = 0; j < rows; j++) {\n for (let i = 0; i < cols; i++) {\n const polygon = [\n corner(i, j),\n ...horizontal[j]![i]!,\n corner(i + 1, j),\n ...vertical[i + 1]![j]!,\n corner(i + 1, j + 1),\n ...[...horizontal[j + 1]![i]!].reverse(),\n corner(i, j + 1),\n ...[...vertical[i]![j]!].reverse(),\n ];\n tiles.push({ id: `j${i},${j}`, polygon, protoTile: 0 });\n }\n }\n return tiles;\n}\n","import { bbox, transform, vec, type Polygon, type Rect, type Vec } from \"./geometry\";\nimport type { GenerateContext, RawTile } from \"./tilings\";\n\n/*\n * Substitution (subdivision) tilings: start from a patch of large pieces centerd on\n * the origin, then repeatedly replace every piece with smaller pieces according to\n * fixed rules. Penrose, Ammann–Beenker and Conway–Radin pinwheel tilings are built this\n * way (the last is unrelated to the repeating `pinwheel` pattern).\n */\n\n/** A piece in a substitution system. `path` records how it was derived, which makes a stable id. */\nexport interface Piece {\n kind: number;\n points: Vec[];\n path: string;\n}\n\nexport interface SubstitutionRule {\n /** Pieces at scale 1, centerd on the origin. */\n seed: Omit<Piece, \"path\">[];\n /** Radius of a disc around the origin that the seed patch fully covers, at scale 1. */\n coverRadius: number;\n /** Edge length of the final tiles at scale 1, before any subdivision. */\n edge: number;\n /** Each subdivision shrinks pieces by this factor. */\n factor: number;\n /**\n * The seed patch reproduces itself (scaled) every `period` subdivisions. Step counts\n * are rounded up to a multiple of it, so a larger region shows more of the same\n * pattern instead of a different one. Defaults to 1.\n */\n period?: number;\n /** Children of one piece, in the same coordinate frame. */\n subdivide(piece: Piece): Omit<Piece, \"path\">[];\n /** Turn the final pieces into tiles (e.g. join half-tiles into whole ones). */\n assemble(pieces: Piece[], tolerance: number): RawTile[];\n}\n\n/**\n * Subdivide `rule`'s seed until the final tiles have edge `size`, keeping only pieces\n * near the region, and assemble them. `ctx.origin` places the center of the seed patch;\n * `ctx.rotation` turns the whole pattern.\n */\nexport function generateSubstitution(\n rule: SubstitutionRule,\n size: number,\n ctx: GenerateContext,\n label: string,\n idPrefix = \"s\",\n): RawTile[] {\n const theta = (ctx.rotation * Math.PI) / 180;\n // Work in the pattern's own frame: origin at the patch center, unrotated.\n const local = transform(\n ctx.region.map((v) => vec(v.x - ctx.origin.x, v.y - ctx.origin.y)),\n -theta,\n vec(0, 0),\n );\n const box = bbox(local);\n let reach = 0;\n for (const v of local) reach = Math.max(reach, Math.hypot(v.x, v.y));\n\n // Fewest subdivisions whose (scaled) seed patch covers the region with room to spare,\n // so that pieces cut off by the patch outline never reach the region.\n let steps = 0;\n const scaleFor = (n: number) => (size * rule.factor ** n) / rule.edge;\n const period = rule.period ?? 1;\n while (scaleFor(steps) * rule.coverRadius < reach + 4 * size || steps % period !== 0) steps++;\n const scale = scaleFor(steps);\n\n let pieces: Piece[] = rule.seed.map((p, i) => ({ kind: p.kind, points: p.points.map((v) => vec(v.x * scale, v.y * scale)), path: `${i}` }));\n for (let step = 1; step <= steps; step++) {\n // Pieces at this level have edges of about `edge`; anything further than a few edges\n // from the region can't contribute (children stay inside their parent).\n const edge = size * rule.factor ** (steps - step);\n const near = grow(box, 3 * edge);\n const next: Piece[] = [];\n for (const p of pieces) {\n rule.subdivide(p).forEach((c, k) => {\n if (overlaps(bbox(c.points), near)) next.push({ ...c, path: `${p.path}.${k}` });\n });\n }\n if (next.length > ctx.maxTiles * 4) {\n throw new RangeError(\n `Tiles are too small for this region (~${Math.round(next.length / 2)} ${label} tiles, limit ${ctx.maxTiles}). ` +\n \"Increase the size or raise maxTiles.\",\n );\n }\n pieces = next;\n }\n\n // Ids come from each tile's position in the pattern (in units of `size`), so they don't\n // depend on how many subdivisions a particular region needed.\n return rule.assemble(pieces, size * 1e-6).map((t) => {\n let cx = 0;\n let cy = 0;\n for (const v of t.polygon) {\n cx += v.x;\n cy += v.y;\n }\n const k = 100 / (size * t.polygon.length);\n return {\n id: `${idPrefix}${Math.round(cx * k)},${Math.round(cy * k)}`,\n protoTile: t.protoTile,\n polygon: transform(t.polygon, theta, ctx.origin),\n };\n });\n}\n\nconst grow = (r: Rect, d: number): Rect => ({ x: r.x - d, y: r.y - d, width: r.width + 2 * d, height: r.height + 2 * d });\nconst overlaps = (a: Rect, b: Rect) => a.x <= b.x + b.width && b.x <= a.x + a.width && a.y <= b.y + b.height && b.y <= a.y + a.height;\n\n/** Key for an undirected edge, robust to tiny floating-point differences. */\nexport function edgeKey(a: Vec, b: Vec, tolerance: number): string {\n const q = (v: Vec) => `${Math.round(v.x / tolerance)},${Math.round(v.y / tolerance)}`;\n const ka = q(a);\n const kb = q(b);\n return ka < kb ? `${ka}|${kb}` : `${kb}|${ka}`;\n}\n\nconst PHI = (1 + Math.sqrt(5)) / 2;\nconst lerp = (a: Vec, b: Vec, t: number): Vec => vec(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t);\n\n/**\n * Penrose P3 (thick and thin rhombs) via Robinson triangles. Each triangle is\n * (apex A, base B–C); two mirror-image triangles sharing a base form one rhomb.\n * Kind 0: 36° apex (half a thin rhomb). Kind 1: 108° apex (half a thick rhomb).\n */\nexport const penroseRhombs: SubstitutionRule = {\n // A \"sun\" of ten thin-rhomb halves around the origin, legs of length 1.\n seed: Array.from({ length: 10 }, (_, i) => {\n let b = vec(Math.cos(((2 * i - 1) * Math.PI) / 10), Math.sin(((2 * i - 1) * Math.PI) / 10));\n let c = vec(Math.cos(((2 * i + 1) * Math.PI) / 10), Math.sin(((2 * i + 1) * Math.PI) / 10));\n // Mirror every other triangle so neighbors pair up into rhombs.\n if (i % 2 === 0) [b, c] = [c, b];\n return { kind: 0, points: [vec(0, 0), b, c] };\n }),\n coverRadius: Math.cos(Math.PI / 10), // the decagon's inner radius\n edge: 1,\n factor: PHI,\n period: 4,\n subdivide({ kind, points: [a, b, c] }) {\n if (kind === 0) {\n const p = lerp(a!, b!, 1 / PHI);\n return [\n { kind: 0, points: [c!, p, b!] },\n { kind: 1, points: [p, c!, a!] },\n ];\n }\n const q = lerp(b!, a!, 1 / PHI);\n const r = lerp(b!, c!, 1 / PHI);\n return [\n { kind: 1, points: [r, c!, a!] },\n { kind: 1, points: [q, r, b!] },\n { kind: 0, points: [r, q, a!] },\n ];\n },\n assemble(pieces, tolerance) {\n const byBase = new Map<string, Piece[]>();\n for (const p of pieces) {\n const key = `${p.kind}:${edgeKey(p.points[1]!, p.points[2]!, tolerance)}`;\n const list = byBase.get(key);\n if (list) list.push(p);\n else byBase.set(key, [p]);\n }\n const tiles: RawTile[] = [];\n for (const pair of byBase.values()) {\n // Halves without a partner lie on the outline of the generated patch, outside the region.\n if (pair.length !== 2) continue;\n const [p, q] = pair[0]!.path < pair[1]!.path ? [pair[0]!, pair[1]!] : [pair[1]!, pair[0]!];\n const [a, b, c] = p.points;\n const polygon: Polygon = [a!, b!, q.points[0]!, c!];\n tiles.push({ id: p.path, polygon, protoTile: p.kind === 1 ? 0 : 1 });\n }\n return tiles;\n },\n};\n\n/** Join mirror-image half-tiles that share their axis (points[0]–points[1]) into whole tiles. */\nfunction joinAlongAxis(pieces: Piece[], tolerance: number, protoTile: (kind: number) => number): RawTile[] {\n const byAxis = new Map<string, Piece[]>();\n for (const p of pieces) {\n // Directed: mirror twins share the same tip *and* the same axis end. Two halves that\n // merely touch along the same segment the other way round are not a pair.\n const q = (v: Vec) => `${Math.round(v.x / tolerance)},${Math.round(v.y / tolerance)}`;\n const key = `${p.kind}:${q(p.points[0]!)}>${q(p.points[1]!)}`;\n const list = byAxis.get(key);\n if (list) list.push(p);\n else byAxis.set(key, [p]);\n }\n const tiles: RawTile[] = [];\n for (const pair of byAxis.values()) {\n if (pair.length !== 2) continue; // half-tiles on the patch outline, outside the region\n const [p, q] = pair[0]!.path < pair[1]!.path ? [pair[0]!, pair[1]!] : [pair[1]!, pair[0]!];\n const [tip, axis, side] = p.points;\n tiles.push({ id: p.path, polygon: [tip!, side!, axis!, q.points[2]!], protoTile: protoTile(p.kind) });\n }\n return tiles;\n}\n\n/**\n * Penrose P2 (kites and darts) via half-tiles. Points are [tip, axis end, side corner]:\n * - kind 0, half-kite: 36° at the tip, legs tip–axis and tip–side of length φ (long sides).\n * - kind 1, half-dart: 36° at the tip and side, 108° at the axis end (the dart's reflex corner).\n * Mirror-image halves sharing the axis form one kite (convex) or dart (non-convex).\n */\nexport const penroseKitesAndDarts: SubstitutionRule = {\n // A \"sun\" of five kites meeting at their tips.\n seed: Array.from({ length: 10 }, (_, i) => {\n const axis = Math.floor(i / 2) * 72;\n const side = axis + (i % 2 === 0 ? 36 : -36);\n const at = (deg: number) => vec(PHI * Math.cos((deg * Math.PI) / 180), PHI * Math.sin((deg * Math.PI) / 180));\n return { kind: 0, points: [vec(0, 0), at(axis), at(side)] };\n }),\n coverRadius: PHI * Math.cos(Math.PI / 10), // the sun is a decagon of radius φ\n edge: PHI, // long side of kites and darts\n factor: PHI,\n period: 4,\n subdivide({ kind, points: [tip, axis, side] }) {\n if (kind === 0) {\n // x on the axis, 1 from the tip; w on the long side, 1 from the side corner. The two\n // new half-kites are mirror twins sharing the axis side → x; the half-dart sits at the tip.\n const x = lerp(tip!, axis!, 1 / PHI);\n const w = lerp(side!, tip!, 1 / PHI);\n return [\n { kind: 0, points: [side!, x, axis!] },\n { kind: 0, points: [side!, x, w] },\n { kind: 1, points: [tip!, w, x] },\n ];\n }\n const z = lerp(tip!, side!, 1 / PHI);\n return [\n { kind: 0, points: [tip!, axis!, z] },\n { kind: 1, points: [side!, z, axis!] },\n ];\n },\n assemble: (pieces, tolerance) => joinAlongAxis(pieces, tolerance, (kind) => kind),\n};\n","import { vec, type Polygon } from \"./geometry\";\nimport { pointInPolygon } from \"./offset\";\n\nexport type Box = { x: number; y: number; width: number; height: number };\n\n/**\n * True if every sample point of `box` lies inside one of `tiles`. Samples are spaced a\n * quarter of `tileWidth` apart and offset by odd fractions, so they don't line up with\n * the lattice lines that monotile edges follow (a point exactly on an edge could be\n * reported as uncovered).\n */\nexport function coversBox(tiles: Polygon[], box: Box, tileWidth: number): boolean {\n const cell = tileWidth;\n const grid = new Map<string, Polygon[]>();\n for (const t of tiles) {\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const p of t) {\n x0 = Math.min(x0, p.x); y0 = Math.min(y0, p.y);\n x1 = Math.max(x1, p.x); y1 = Math.max(y1, p.y);\n }\n for (let i = Math.floor(x0 / cell); i <= Math.floor(x1 / cell); i++) {\n for (let j = Math.floor(y0 / cell); j <= Math.floor(y1 / cell); j++) {\n const k = `${i},${j}`;\n const list = grid.get(k);\n if (list) list.push(t);\n else grid.set(k, [t]);\n }\n }\n }\n const step = tileWidth / 4;\n const nx = Math.max(1, Math.ceil(box.width / step));\n const ny = Math.max(1, Math.ceil(box.height / step));\n for (let i = 0; i <= nx; i++) {\n for (let j = 0; j <= ny; j++) {\n const p = vec(box.x + ((i + 0.1234567) / (nx + 0.2469134)) * box.width, box.y + ((j + 0.0987654) / (ny + 0.1975308)) * box.height);\n const bucket = grid.get(`${Math.floor(p.x / cell)},${Math.floor(p.y / cell)}`);\n if (!bucket || !bucket.some((t) => pointInPolygon(p, t))) return false;\n }\n }\n return true;\n}\n\nexport const grow = (b: Box, d: number): Box => ({ x: b.x - d, y: b.y - d, width: b.width + 2 * d, height: b.height + 2 * d });\n\nexport const boxesOverlap = (a: { x0: number; y0: number; x1: number; y1: number }, b: Box) =>\n a.x1 >= b.x && a.x0 <= b.x + b.width && a.y1 >= b.y && a.y0 <= b.y + b.height;\n","/*!\n * The \"hat\" aperiodic monotile (Smith, Myers, Kaplan & Goodman-Strauss, 2023), built\n * with the H/T/P/F metatile construction.\n *\n * The metatile outlines, the patch rules and the supertile construction below are ported\n * from hatviz (https://github.com/isohedral/hatviz), whose license follows:\n *\n * BSD 3-Clause License\n *\n * Copyright (c) 2023, Craig S. Kaplan\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * 3. Neither the name of the copyright holder nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport { vec, type Polygon, type Vec } from \"./geometry\";\nimport { boxesOverlap, coversBox, grow, type Box } from \"./cover\";\n\n/** 2D affine transform [a, b, c, d, e, f]: x' = a·x + b·y + c, y' = d·x + e·y + f. */\nexport type Affine = [number, number, number, number, number, number];\n\nexport const IDENTITY: Affine = [1, 0, 0, 0, 1, 0];\n\nexport function mul(A: Affine, B: Affine): Affine {\n return [\n A[0] * B[0] + A[1] * B[3],\n A[0] * B[1] + A[1] * B[4],\n A[0] * B[2] + A[1] * B[5] + A[2],\n A[3] * B[0] + A[4] * B[3],\n A[3] * B[1] + A[4] * B[4],\n A[3] * B[2] + A[4] * B[5] + A[5],\n ];\n}\n\nexport function inv(T: Affine): Affine {\n const det = T[0] * T[4] - T[1] * T[3];\n return [\n T[4] / det,\n -T[1] / det,\n (T[1] * T[5] - T[2] * T[4]) / det,\n -T[3] / det,\n T[0] / det,\n (T[2] * T[3] - T[0] * T[5]) / det,\n ];\n}\n\nexport const apply = (M: Affine, p: Vec): Vec => vec(M[0] * p.x + M[1] * p.y + M[2], M[3] * p.x + M[4] * p.y + M[5]);\nconst rot = (a: number): Affine => [Math.cos(a), -Math.sin(a), 0, Math.sin(a), Math.cos(a), 0];\nexport const translate = (x: number, y: number): Affine => [1, 0, x, 0, 1, y];\nconst rotAbout = (p: Vec, a: number): Affine => mul(translate(p.x, p.y), mul(rot(a), translate(-p.x, -p.y)));\nconst padd = (p: Vec, q: Vec): Vec => vec(p.x + q.x, p.y + q.y);\nconst psub = (p: Vec, q: Vec): Vec => vec(p.x - q.x, p.y - q.y);\n\n/** Map the unit segment (0,0)→(1,0) onto p→q (rotation + uniform scale + translation). */\nconst matchSeg = (p: Vec, q: Vec): Affine => [q.x - p.x, p.y - q.y, p.x, q.y - p.y, q.x - p.x, p.y];\n/** Map segment p1→q1 onto p2→q2. */\nexport const matchTwo = (p1: Vec, q1: Vec, p2: Vec, q2: Vec): Affine => mul(matchSeg(p2, q2), inv(matchSeg(p1, q1)));\n\nfunction intersect(p1: Vec, q1: Vec, p2: Vec, q2: Vec): Vec {\n const d = (q2.y - p2.y) * (q1.x - p1.x) - (q2.x - p2.x) * (q1.y - p1.y);\n const uA = ((q2.x - p2.x) * (p1.y - p2.y) - (q2.y - p2.y) * (p1.x - p2.x)) / d;\n return vec(p1.x + uA * (q1.x - p1.x), p1.y + uA * (q1.y - p1.y));\n}\n\nconst HR3 = Math.sqrt(3) / 2;\nconst hexPt = (x: number, y: number): Vec => vec(x + 0.5 * y, HR3 * y);\n\n/** The hat: a 13-sided polykite (eight kites of a hexagonal grid). */\nexport const HAT: Polygon = [\n hexPt(0, 0), hexPt(-1, -1), hexPt(0, -2), hexPt(2, -2),\n hexPt(2, -1), hexPt(4, -2), hexPt(5, -1), hexPt(4, 0),\n hexPt(3, 0), hexPt(2, 2), hexPt(0, 3), hexPt(0, 2),\n hexPt(-1, 2),\n];\n\n/**\n * Hat labels, by the metatile a hat belongs to: \"H1\" is the one reflected hat in each H\n * metatile; the others are unreflected.\n */\nexport type HatLabel = \"H1\" | \"H\" | \"T\" | \"P\" | \"F\";\n\nexport interface HatLeaf {\n kind: \"hat\";\n label: HatLabel;\n}\n\nexport interface MetaTile {\n kind: \"meta\";\n /** Approximate outline of the cluster, in its own coordinates. */\n shape: Polygon;\n children: { T: Affine; geom: Geom }[];\n}\n\nexport type Geom = HatLeaf | MetaTile;\n\nconst hat = (label: HatLabel): HatLeaf => ({ kind: \"hat\", label });\nconst meta = (shape: Polygon, children: MetaTile[\"children\"] = []): MetaTile => ({ kind: \"meta\", shape, children });\nconst evalChild = (m: MetaTile, n: number, i: number): Vec => {\n const ch = m.children[n]!;\n return apply(ch.T, (ch.geom as MetaTile).shape[i]!);\n};\n\nfunction initialMetatiles(): [MetaTile, MetaTile, MetaTile, MetaTile] {\n const hOutline = [vec(0, 0), vec(4, 0), vec(4.5, HR3), vec(2.5, 5 * HR3), vec(1.5, 5 * HR3), vec(-0.5, HR3)];\n const H = meta(hOutline, [\n { T: matchTwo(HAT[5]!, HAT[7]!, hOutline[5]!, hOutline[0]!), geom: hat(\"H\") },\n { T: matchTwo(HAT[9]!, HAT[11]!, hOutline[1]!, hOutline[2]!), geom: hat(\"H\") },\n { T: matchTwo(HAT[5]!, HAT[7]!, hOutline[3]!, hOutline[4]!), geom: hat(\"H\") },\n { T: mul(translate(2.5, HR3), mul([-0.5, -HR3, 0, HR3, -0.5, 0], [0.5, 0, 0, 0, -0.5, 0])), geom: hat(\"H1\") },\n ]);\n const T = meta([vec(0, 0), vec(3, 0), vec(1.5, 3 * HR3)], [{ T: [0.5, 0, 0.5, 0, 0.5, HR3], geom: hat(\"T\") }]);\n const pair = (label: HatLabel): MetaTile[\"children\"] => [\n { T: [0.5, 0, 1.5, 0, 0.5, HR3], geom: hat(label) },\n { T: mul(translate(0, 2 * HR3), mul([0.5, HR3, 0, -HR3, 0.5, 0], [0.5, 0, 0, 0, 0.5, 0])), geom: hat(label) },\n ];\n const P = meta([vec(0, 0), vec(4, 0), vec(3, 2 * HR3), vec(-1, 2 * HR3)], pair(\"P\"));\n const F = meta([vec(0, 0), vec(3, 0), vec(3.5, HR3), vec(3, 2 * HR3), vec(-1, 2 * HR3)], pair(\"F\"));\n return [H, T, P, F];\n}\n\n/**\n * Which of the three H metatiles inside each H supertile (children 0–2) holds the previous\n * level. Chains 0 and 1 sit on their parent's edge, so the pattern would only grow in some\n * directions; chain 2 grows in all of them (covered radius ≈ 3, 7, 16, 37, 99… hat units).\n */\nconst ANCHOR_CHAIN = 2;\n\ntype Shape = \"H\" | \"T\" | \"P\" | \"F\";\n/**\n * How to assemble a patch of metatiles around an H. Each rule places one new metatile:\n * [shape] at the origin; [child, edge, shape, edge] glues the new shape's edge to that\n * edge of an existing child; [childA, vertexA, childB, vertexB, shape, edge] glues it\n * between a vertex of each of two existing children.\n */\nconst PATCH_RULES: (readonly [Shape] | readonly [number, number, Shape, number] | readonly [number, number, number, number, Shape, number])[] = [\n [\"H\"],\n [0, 0, \"P\", 2], [1, 0, \"H\", 2], [2, 0, \"P\", 2], [3, 0, \"H\", 2], [4, 4, \"P\", 2],\n [0, 4, \"F\", 3], [2, 4, \"F\", 3], [4, 1, 3, 2, \"F\", 0], [8, 3, \"H\", 0], [9, 2, \"P\", 0],\n [10, 2, \"H\", 0], [11, 4, \"P\", 2], [12, 0, \"H\", 2], [13, 0, \"F\", 3], [14, 2, \"F\", 1],\n [15, 3, \"H\", 4], [8, 2, \"F\", 1], [17, 3, \"H\", 0], [18, 2, \"P\", 0], [19, 2, \"H\", 2],\n [20, 4, \"F\", 3], [20, 0, \"P\", 2], [22, 0, \"H\", 2], [23, 4, \"F\", 3], [23, 0, \"F\", 3],\n [16, 0, \"P\", 2], [9, 4, 0, 2, \"T\", 2], [4, 0, \"F\", 3],\n];\n\nexport function constructPatch(H: MetaTile, T: MetaTile, P: MetaTile, F: MetaTile): MetaTile {\n const shapes = { H, T, P, F };\n const ret = meta([]);\n for (const r of PATCH_RULES) {\n if (r.length === 1) {\n ret.children.push({ T: IDENTITY, geom: shapes[r[0]] });\n } else if (r.length === 4) {\n const ch = ret.children[r[0]]!;\n const poly = (ch.geom as MetaTile).shape;\n const p = apply(ch.T, poly[(r[1] + 1) % poly.length]!);\n const q = apply(ch.T, poly[r[1]]!);\n const nshp = shapes[r[2]];\n const np = nshp.shape;\n ret.children.push({ T: matchTwo(np[r[3]]!, np[(r[3] + 1) % np.length]!, p, q), geom: nshp });\n } else {\n const chP = ret.children[r[0]]!;\n const chQ = ret.children[r[2]]!;\n const p = apply(chQ.T, (chQ.geom as MetaTile).shape[r[3]]!);\n const q = apply(chP.T, (chP.geom as MetaTile).shape[r[1]]!);\n const nshp = shapes[r[4]];\n const np = nshp.shape;\n ret.children.push({ T: matchTwo(np[r[5]]!, np[(r[5] + 1) % np.length]!, p, q), geom: nshp });\n }\n }\n return ret;\n}\n\n/** Move a metatile's outline (and children) so the outline's vertex average is the origin. */\nfunction recenter(m: MetaTile): MetaTile {\n let cx = 0;\n let cy = 0;\n for (const p of m.shape) {\n cx += p.x;\n cy += p.y;\n }\n cx /= m.shape.length;\n cy /= m.shape.length;\n const M = translate(-cx, -cy);\n return meta(\n m.shape.map((p) => vec(p.x - cx, p.y - cy)),\n m.children.map((ch) => ({ T: mul(M, ch.T), geom: ch.geom })),\n );\n}\n\n/** Build the next level's H, T, P, F metatiles out of a patch of the current ones. */\nexport function constructMetatiles(patch: MetaTile): [MetaTile, MetaTile, MetaTile, MetaTile] {\n const bps1 = evalChild(patch, 8, 2);\n const bps2 = evalChild(patch, 21, 2);\n const rbps = apply(rotAbout(bps1, (-2 * Math.PI) / 3), bps2);\n const p72 = evalChild(patch, 7, 2);\n const p252 = evalChild(patch, 25, 2);\n const llc = intersect(bps1, rbps, evalChild(patch, 6, 2), p72);\n let w = psub(evalChild(patch, 6, 2), llc);\n\n const hOutline: Vec[] = [llc, bps1];\n w = apply(rot(-Math.PI / 3), w);\n hOutline.push(padd(hOutline[1]!, w));\n hOutline.push(evalChild(patch, 14, 2));\n w = apply(rot(-Math.PI / 3), w);\n hOutline.push(psub(hOutline[3]!, w));\n hOutline.push(evalChild(patch, 6, 2));\n\n const pick = (indices: number[]) => indices.map((i) => patch.children[i]!);\n const H = meta(hOutline, pick([0, 9, 16, 27, 26, 6, 1, 8, 10, 15]));\n const P = meta([p72, padd(p72, psub(bps1, llc)), bps1, llc], pick([7, 2, 3, 4, 28]));\n const F = meta(\n [bps2, evalChild(patch, 24, 2), evalChild(patch, 25, 0), p252, padd(p252, psub(llc, bps1))],\n pick([21, 20, 22, 23, 24, 25]),\n );\n const aaa = hOutline[2]!;\n const bbb = padd(hOutline[1]!, psub(hOutline[4]!, hOutline[5]!));\n const ccc = apply(rotAbout(bbb, -Math.PI / 3), aaa);\n const T = meta([bbb, ccc, aaa], pick([11]));\n return [recenter(H), recenter(T), recenter(P), recenter(F)];\n}\n\n/**\n * The H metatile at `level` (0 = the initial four-hat H), and the transform from its\n * coordinates to those of the level-0 H it contains. Each level's H contains the previous\n * level's H as its first child, so anchoring on the level-0 H makes every level an\n * extension of the one before.\n */\nexport function hatSupertile(level: number, chain: number | readonly number[] = ANCHOR_CHAIN): { H: MetaTile; toAnchor: Affine } {\n let tiles = initialMetatiles();\n let toAnchor: Affine = IDENTITY;\n for (let k = 0; k < level; k++) {\n tiles = constructMetatiles(constructPatch(...tiles));\n // Children 0–2 of every H supertile are H metatiles of the level below. The chosen\n // child's transform maps previous-H coordinates into new-H coordinates, so its inverse\n // takes us one level closer to the anchor.\n const pick = typeof chain === \"number\" ? chain : chain[k % chain.length]!;\n toAnchor = mul(toAnchor, inv(tiles[0].children[pick]!.T));\n }\n return { H: tiles[0], toAnchor };\n}\n\ntype Bounds = { x0: number; y0: number; x1: number; y1: number };\nconst hatBoxes = new WeakMap<MetaTile, Bounds>();\n\n/**\n * Bounding box of every hat inside `g`, in g's own coordinates. Hats stray well outside\n * the metatile outlines (by ~2.7× more per level), so pruning must use these real bounds.\n * Metatiles are shared between parents, so each is measured once.\n */\nexport function hatBounds(g: Geom): Bounds {\n if (g.kind === \"hat\") {\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const p of HAT) {\n x0 = Math.min(x0, p.x); y0 = Math.min(y0, p.y);\n x1 = Math.max(x1, p.x); y1 = Math.max(y1, p.y);\n }\n return { x0, y0, x1, y1 };\n }\n const cached = hatBoxes.get(g);\n if (cached) return cached;\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const ch of g.children) {\n const b = hatBounds(ch.geom);\n for (const p of [vec(b.x0, b.y0), vec(b.x1, b.y0), vec(b.x1, b.y1), vec(b.x0, b.y1)]) {\n const q = apply(ch.T, p);\n x0 = Math.min(x0, q.x); y0 = Math.min(y0, q.y);\n x1 = Math.max(x1, q.x); y1 = Math.max(y1, q.y);\n }\n }\n const box = { x0, y0, x1, y1 };\n hatBoxes.set(g, box);\n return box;\n}\n\n/** Bounds of `g`'s hats after transform T (conservative: the transformed box's box). */\nexport function placedBounds(g: Geom, T: Affine): Bounds {\n const b = hatBounds(g);\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const p of [vec(b.x0, b.y0), vec(b.x1, b.y0), vec(b.x1, b.y1), vec(b.x0, b.y1)]) {\n const q = apply(T, p);\n x0 = Math.min(x0, q.x); y0 = Math.min(y0, q.y);\n x1 = Math.max(x1, q.x); y1 = Math.max(y1, q.y);\n }\n return { x0, y0, x1, y1 };\n}\n\nconst LABEL_INDEX: Record<HatLabel, number> = { H: 0, T: 1, P: 2, F: 3, H1: 4 };\n\n/**\n * Widest extent of a hat as placed in the metatiles (which use the outline above at half\n * scale), used to turn the user's `size` into a scale.\n */\nconst HAT_WIDTH = (() => {\n const placed = HAT.map((p) => apply(hatSupertile(0).H.children[0]!.T, p));\n return Math.max(...placed.flatMap((a) => placed.map((b) => Math.hypot(a.x - b.x, a.y - b.y))));\n})();\n\n/** Middle of the level-0 H metatile: the fixed point every level grows around. */\nconst ANCHOR = (() => {\n const { H } = hatSupertile(0);\n return vec(H.shape.reduce((s, p) => s + p.x, 0) / H.shape.length, H.shape.reduce((s, p) => s + p.y, 0) / H.shape.length);\n})();\n\n\nexport interface HatTile {\n polygon: Polygon;\n label: HatLabel;\n}\n\n/**\n * Hats covering `box` (in hat units, relative to the pattern's center): the smallest\n * level whose H supertile, grown around the anchor, actually covers the box.\n */\nexport function hatsCovering(box: Box, maxTiles: number): HatTile[] {\n const near = grow(box, HAT_WIDTH);\n for (let level = 1; level <= 14; level++) {\n const { H, toAnchor } = hatSupertile(level);\n const toLocal = mul(translate(-ANCHOR.x, -ANCHOR.y), toAnchor);\n const out: HatTile[] = [];\n const visit = (g: Geom, T: Affine) => {\n if (g.kind === \"hat\") {\n out.push({ polygon: HAT.map((p) => apply(T, p)), label: g.label });\n if (out.length > maxTiles) {\n throw new RangeError(`Tiles are too small for this region (more than ${maxTiles} hat tiles). Increase the size or raise maxTiles.`);\n }\n return;\n }\n if (!boxesOverlap(placedBounds(g, T), near)) return;\n for (const ch of g.children) visit(ch.geom, mul(T, ch.T));\n };\n visit(H, toLocal);\n if (coversBox(out.map((t) => t.polygon), box, HAT_WIDTH)) return out;\n }\n throw new RangeError(\"hat: region too large for the supported number of levels\");\n}\n\nexport { HAT_WIDTH, LABEL_INDEX };\n","// @ts-nocheck -- vendored JavaScript, wrapped with types in ../isohedral.ts\n/*!\n * Tactile-JS (https://github.com/isohedral/tactile-js), vendored unchanged apart from\n * this header. Its licence follows.\n *\n * BSD 3-Clause License\n *\n * Copyright (c) 2018, Craig S. Kaplan\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n *\n * * Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * * Neither the name of the copyright holder nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n/*\n * Tactile-JS\n * Copyright 2018 Craig S. Kaplan, csk@uwaterloo.ca\n *\n * Distributed under the terms of the 3-clause BSD license. See the\n * file \"LICENSE\" for more information.\n */\n\n'use strict'\n\nconst EdgeShape = {\n\tJ : 10001,\n\tU : 10002,\n\tS : 10003,\n\tI : 10004,\n};\n\nconst numTypes = 81;\n\nfunction mul( A, B ) \n{\n\tif( B.hasOwnProperty( 'x' ) ) {\n\t\t// Matrix * Point\n\t\treturn { \n\t\t\tx : A[0]*B.x + A[1]*B.y + A[2],\n\t\t\ty : A[3]*B.x + A[4]*B.y + A[5] };\n\t} else {\n\t\t// Matrix * Matrix\n\t\treturn [A[0]*B[0] + A[1]*B[3], \n\t\t\tA[0]*B[1] + A[1]*B[4],\n\t\t\tA[0]*B[2] + A[1]*B[5] + A[2],\n\n\t\t\tA[3]*B[0] + A[4]*B[3], \n\t\t\tA[3]*B[1] + A[4]*B[4],\n\t\t\tA[3]*B[2] + A[4]*B[5] + A[5]];\n\t}\n};\n\nfunction matchSeg( p, q )\n{\n\treturn [q.x-p.x, p.y-q.y, p.x, q.y-p.y, q.x-p.x, p.y];\n};\n'use strict'\n\nconst tilingTypes = [\n\t1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 61, 62, 64, 66, 67, 68, 69, 71, 72, 73, 74, 76, 77, 78, 79, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93\n];\n\n\nconst tiling_type_data = (function() {\nconst es_00 = [ EdgeShape.J, EdgeShape.J, EdgeShape.J ];\nconst es_01 = [ EdgeShape.S, EdgeShape.J, EdgeShape.S, EdgeShape.S, EdgeShape.S ];\nconst es_02 = [ EdgeShape.S, EdgeShape.J, EdgeShape.J, EdgeShape.S ];\nconst es_03 = [ EdgeShape.S, EdgeShape.J, EdgeShape.S, EdgeShape.J ];\nconst es_04 = [ EdgeShape.S, EdgeShape.S, EdgeShape.S ];\nconst es_05 = [ EdgeShape.S, EdgeShape.J ];\nconst es_06 = [ EdgeShape.J ];\nconst es_07 = [ EdgeShape.S ];\nconst es_08 = [ EdgeShape.U, EdgeShape.J ];\nconst es_09 = [ EdgeShape.U, EdgeShape.S, EdgeShape.S ];\nconst es_10 = [ EdgeShape.J, EdgeShape.I ];\nconst es_11 = [ EdgeShape.S, EdgeShape.I, EdgeShape.S ];\nconst es_12 = [ EdgeShape.I, EdgeShape.J ];\nconst es_13 = [ EdgeShape.I, EdgeShape.S ];\nconst es_14 = [ EdgeShape.U ];\nconst es_15 = [ EdgeShape.I ];\nconst es_16 = [ EdgeShape.S, EdgeShape.J, EdgeShape.J ];\nconst es_17 = [ EdgeShape.J, EdgeShape.J, EdgeShape.I ];\nconst es_18 = [ EdgeShape.S, EdgeShape.S, EdgeShape.J, EdgeShape.S ];\nconst es_19 = [ EdgeShape.S, EdgeShape.S, EdgeShape.J, EdgeShape.I ];\nconst es_20 = [ EdgeShape.J, EdgeShape.J, EdgeShape.S ];\nconst es_21 = [ EdgeShape.S, EdgeShape.I, EdgeShape.I ];\nconst es_22 = [ EdgeShape.J, EdgeShape.I, EdgeShape.I ];\nconst es_23 = [ EdgeShape.J, EdgeShape.J ];\nconst es_24 = [ EdgeShape.I, EdgeShape.I ];\nconst es_25 = [ EdgeShape.J, EdgeShape.S ];\nconst es_26 = [ EdgeShape.S, EdgeShape.S, EdgeShape.S, EdgeShape.S ];\nconst es_27 = [ EdgeShape.J, EdgeShape.S, EdgeShape.S ];\nconst es_28 = [ EdgeShape.I, EdgeShape.S, EdgeShape.I, EdgeShape.S ];\nconst es_29 = [ EdgeShape.J, EdgeShape.I, EdgeShape.S ];\nconst es_30 = [ EdgeShape.I, EdgeShape.I, EdgeShape.I, EdgeShape.S ];\nconst es_31 = [ EdgeShape.S, EdgeShape.S ];\nconst es_32 = [ EdgeShape.S, EdgeShape.I ];\nconst es_33 = [ EdgeShape.U, EdgeShape.I ];\nconst es_34 = [ EdgeShape.U, EdgeShape.S ];\nconst es_35 = [ EdgeShape.I, EdgeShape.I, EdgeShape.I ];\nconst es_36 = [ EdgeShape.I, EdgeShape.S, EdgeShape.I ];\nconst es_37 = [ EdgeShape.I, EdgeShape.S, EdgeShape.S ];\n\nconst esi_00 = [ 0, 1, 2, 0, 1, 2 ];\nconst esi_01 = [ 0, 0, 1, 2, 2, 1 ];\nconst esi_02 = [ 0, 1, 0, 2, 1, 2 ];\nconst esi_03 = [ 0, 1, 2, 3, 1, 4 ];\nconst esi_04 = [ 0, 1, 2, 2, 1, 3 ];\nconst esi_05 = [ 0, 1, 2, 3, 1, 3 ];\nconst esi_06 = [ 0, 0, 1, 1, 2, 2 ];\nconst esi_07 = [ 0, 1, 1, 0, 1, 1 ];\nconst esi_08 = [ 0, 0, 0, 0, 0, 0 ];\nconst esi_09 = [ 0, 1, 2, 0, 2, 1 ];\nconst esi_10 = [ 0, 1, 0, 0, 1, 0 ];\nconst esi_11 = [ 0, 1, 2, 2, 1, 0 ];\nconst esi_12 = [ 0, 1, 1, 1, 1, 0 ];\nconst esi_13 = [ 0, 1, 1, 2, 2 ];\nconst esi_14 = [ 0, 0, 1, 2, 1 ];\nconst esi_15 = [ 0, 1, 2, 3, 2 ];\nconst esi_16 = [ 0, 1, 2, 1, 2 ];\nconst esi_17 = [ 0, 1, 1, 1, 1 ];\nconst esi_18 = [ 0, 1, 2, 0 ];\nconst esi_19 = [ 0, 1, 1, 0 ];\nconst esi_20 = [ 0, 0, 0, 0 ];\nconst esi_21 = [ 0, 1, 0 ];\nconst esi_22 = [ 0, 1, 0, 1 ];\nconst esi_23 = [ 0, 1, 0, 2 ];\nconst esi_24 = [ 0, 0, 1, 1 ];\nconst esi_25 = [ 0, 1, 2, 3 ];\nconst esi_26 = [ 0, 0, 1, 2 ];\nconst esi_27 = [ 0, 1, 2 ];\nconst esi_28 = [ 0, 0, 1 ];\nconst esi_29 = [ 0, 0, 0 ];\n\nconst eo_00 = [ false, false, false, false, false, false, false, true, false, true, false, true ];\nconst eo_01 = [ false, false, true, true, false, false, false, false, true, true, false, true ];\nconst eo_02 = [ false, false, false, false, true, true, false, false, false, true, true, true ];\nconst eo_03 = [ false, false, false, false, false, false, false, false, false, true, false, false ];\nconst eo_04 = [ false, false, false, false, false, false, true, true, false, true, false, false ];\nconst eo_05 = [ false, false, false, false, false, false, false, false, true, true, true, true ];\nconst eo_06 = [ false, false, false, true, false, false, false, true, false, false, false, true ];\nconst eo_07 = [ false, false, false, false, false, false, false, false, false, false, false, false ];\nconst eo_08 = [ false, false, false, false, true, true, false, false, false, false, true, true ];\nconst eo_09 = [ false, false, false, false, true, true, false, true, false, true, true, false ];\nconst eo_10 = [ false, false, false, false, false, false, false, true, true, false, true, false ];\nconst eo_11 = [ false, false, false, false, true, true, false, true, true, false, true, false ];\nconst eo_12 = [ false, false, false, false, false, false, true, false, true, false, true, false ];\nconst eo_13 = [ false, false, false, false, false, true, true, true, true, false, true, false ];\nconst eo_14 = [ false, false, false, false, true, false, false, false, false, false, true, false ];\nconst eo_15 = [ false, false, false, false, false, true, false, false, false, true ];\nconst eo_16 = [ false, false, true, true, false, false, false, false, false, true ];\nconst eo_17 = [ false, false, false, false, false, false, false, false, false, true ];\nconst eo_18 = [ false, false, true, false, false, false, false, false, true, false ];\nconst eo_19 = [ false, false, false, false, false, false, true, true, true, true ];\nconst eo_20 = [ false, false, false, false, false, true, true, true, true, false ];\nconst eo_21 = [ false, false, false, false, false, false, false, true ];\nconst eo_22 = [ false, false, false, false, false, true, false, true ];\nconst eo_23 = [ false, false, false, false, true, false, true, false ];\nconst eo_24 = [ false, false, false, true, false, false, false, true ];\nconst eo_25 = [ false, false, true, false, true, true, false, true ];\nconst eo_26 = [ false, false, true, false, false, false, true, false ];\nconst eo_27 = [ false, false, false, false, false, true ];\nconst eo_28 = [ false, false, false, false, true, false ];\nconst eo_29 = [ false, false, false, false, false, true, false, false ];\nconst eo_30 = [ false, false, false, false, false, true, true, true ];\nconst eo_31 = [ false, false, true, true, false, false, true, true ];\nconst eo_32 = [ false, false, false, false, true, true, false, false ];\nconst eo_33 = [ false, false, false, false, false, false, false, false ];\nconst eo_34 = [ false, false, false, false, true, true, true, true ];\nconst eo_35 = [ false, false, true, true, false, false, false, false ];\nconst eo_36 = [ false, false, false, true, false, false, false, false ];\nconst eo_37 = [ false, false, false, false, false, true, true, false ];\nconst eo_38 = [ false, false, false, false, true, false, false, false ];\nconst eo_39 = [ false, false, true, true, false, true, true, false ];\nconst eo_40 = [ false, false, false, true, true, true, true, false ];\nconst eo_41 = [ false, false, false, false, false, false ];\nconst eo_42 = [ false, false, true, true, false, false ];\nconst eo_43 = [ false, false, false, true, false, false ];\nconst eo_44 = [ false, false, true, false, false, false ];\n\nconst dp_00 = [ 0.12239750492, 0.5, 0.143395479017, 0.625 ];\nconst dp_01 = [ 0.12239750492, 0.5, 0.225335752741, 0.225335752741 ];\nconst dp_02 = [ 0.12239750492, 0.5, 0.225335752741, 0.625 ];\nconst dp_03 = [ 0.12239750492, 0.5, 0.315470053838, 0.5, 0.315470053838, 0.5 ];\nconst dp_04 = [ 0.12239750492, 0.5, 0.225335752741, 0.225335752741, 0.5 ];\nconst dp_05 = [ 0.12239750492, 0.5, 0.225335752741, 0.625, 0.5 ];\nconst dp_06 = [ 0.6, 0.196416770201 ];\nconst dp_07 = [ 0.12239750492, 0.5, 0.225335752741 ];\nconst dp_08 = [ ];\nconst dp_09 = [ 0.12239750492, 0.225335752741 ];\nconst dp_10 = [ 0.12239750492, 0.225335752741, 0.5 ];\nconst dp_11 = [ 0.12239750492, 0.225335752741, 0.225335752741 ];\nconst dp_12 = [ 0.216506350946 ];\nconst dp_13 = [ 0.104512294489, 0.65 ];\nconst dp_14 = [ 0.230769230769, 0.5, 0.225335752741 ];\nconst dp_15 = [ 0.230769230769, 0.5, 0.225335752741, 0.5 ];\nconst dp_16 = [ 0.230769230769, 0.225335752741 ];\nconst dp_17 = [ 0.141304, 0.465108, 0.534891 ];\nconst dp_18 = [ 0.452827026611, 0.5 ];\nconst dp_19 = [ 0.366873818946 ];\nconst dp_20 = [ 0.230769230769 ];\nconst dp_21 = [ 0.230769230769, 0.5 ];\nconst dp_22 = [ 0.5, 0.102564102564 ];\nconst dp_23 = [ 0.230769230769, 0.869565217391 ];\nconst dp_24 = [ 0.5, 0.230769230769, 0.5, 0.5 ];\nconst dp_25 = [ 0.230769230769, 0.5, 0.230769230769 ];\nconst dp_26 = [ 0.5, 0.5, 0.6 ];\nconst dp_27 = [ 0.5, 0.102564102564, 0.102564102564 ];\nconst dp_28 = [ 0.230769230769, 0.230769230769 ];\nconst dp_29 = [ 0.5 ];\nconst dp_30 = [ 0.105263157895 ];\nconst dp_31 = [ 0.196416770201 ];\nconst dp_32 = [ 0.5, 0.196416770201 ];\n\nconst tvc_00 = [\n\t0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3.9, 0, 0, 0, 0.1, 0, 5, 0, 0, -2.5, 3.9, 0, 5.5, 0, -0.4, 0, 5, 0, -4, 0.5, 3.9, 0, 0, 0, 0.1, 0, 5, 0, 0, -1.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -5.5, 0, 0.5, 0, 0, 0, 4, -2 ];\nconst tvc_01 = [\n\t3.9, 0, 0, 0, 0.1, 0, 5, 0, 0, -2.5, 3.9, 0, 0, 3.5, -0.4, 0, 5, 0, 0, -2, 3.9, 0, 0, 0, 0.1, 0, 5, 0, 0, -1.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -3.5, 0, 0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ];\nconst tvc_02 = [\n\t0, 0, -3.5, 0, 0.5, 0, 0, 0, 4, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3.9, 0, 0, 0, 0.1, 0, 5, 0, 0, -2.5, 3.9, 0, 3.5, 0, -0.4, 0, 5, 0, 4, -4.5, 3.9, 0, 0, 0, 0.1, 0, 5, 0, 0, -1.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ];\nconst tvc_03 = [\n\t0, 0, -2.5, 0, 0, 0, 0.5, 0, 0, 0, 3, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3.9, 0, 0, 0, 0, 0, 0.1, 0, 5, 0, 0, 0, 0, -2.5, 3.9, 0, 0, 0, 2.5, 0, -0.4, 0, 5, 0, 0, 0, 3, -3.5, 3.9, 0, 0, 0, 0, 0, 0.1, 0, 5, 0, 0, 0, 0, -1.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ];\nconst tvc_04 = [\n\t3.9, 0, 0, 3.5, 0, -0.4, 0, 5, 0, 0, 5, -4.5, 3.9, 0, 0, 0, 0, 0.1, 0, 5, 0, 0, 0, -1.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -3.5, 0, 0, 0.5, 0, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3.9, 0, 0, 0, 0, 0.1, 0, 5, 0, 0, 0, -2.5 ];\nconst tvc_05 = [\n\t3.9, 0, 3.5, 0, 0, -0.4, 0, -5, 0, 4, 0, 0.5, 3.9, 0, 0, 0, 5, -2.4, 0, 5, 0, 0, 0, -1.5, 0, 0, 0, 0, 5, -2.5, 0, 0, 0, 0, 0, 1, 0, 0, -3.5, 0, 0, 0.5, 0, 0, 0, 4, 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3.9, 0, 0, 0, 0, 0.1, 0, -5, 0, 0, 0, 2.5 ];\nconst tvc_06 = [\n\t0, 0, 0, 0, 0, 0, 0, 0, 0.5, 0, 0, -0.288675134595, 0, 0, 1, 0, 0, 0, 2.5, 1.12583302492, -0.721132486541, -1.44337567297, 1.95, 1.06036297108, 5, 0, -2.5, 0, 3.9, 0.1, 2.5, -1.12583302492, -1.27886751346, 1.44337567297, 1.95, -0.671687836487 ];\nconst tvc_07 = [\n\t0, 0, 0, 0, 0, 0, 0, 0, 3.9, 0, 0, 0.1, 0, 5, 0, -2.5, 3.9, 0, 3.5, -0.4, 0, 5, 0, -2, 3.9, 0, 0, 0.1, 0, 5, 0, -1.5, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -3.5, 0.5, 0, 0, 0, 0.5 ];\nconst tvc_08 = [\n\t1, 0, 0.5, 0.866025403784, -0.5, 0.866025403784, -1, 0, -0.5, -0.866025403784, 0.5, -0.866025403784 ];\nconst tvc_09 = [\n\t0, 0, 0, 0, 0, 0, 3.9, 0, 0.1, 0, 0, 0, 3.9, 3.5, -0.4, 0, 0, 0.5, 3.9, 0, 0.1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, -3.5, 0.5, 0, 0, 0.5 ];\nconst tvc_10 = [\n\t0, 0, 0, 0, 0, 0, 0, 0, 3.9, 0, 0, 0.1, 0, 0, 0, 0, 3.9, 3.5, 0, -0.4, 0, 0, 5, -2, 3.9, 0, 0, 0.1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, -3.5, 0, 0.5, 0, 0, 5, -2 ];\nconst tvc_11 = [\n\t3.9, 3.5, -0.4, 0, 0, 0.5, 3.9, 0, 0.1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, -3.5, 0.5, 0, 0, 0.5, 0, 0, 0, 0, 0, 0, 3.9, 0, 0.1, 0, 0, 0 ];\nconst tvc_12 = [\n\t0, -3.5, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0, 0, 0, 0, 0, 3.9, 0, 0, 0.1, 0, 0, 0, 0, 3.9, 0, 3.5, -0.4, 0, 0, 0, 0.5, 3.9, 0, 0, 0.1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1 ];\nconst tvc_13 = [\n\t0, 0.5, 0, -0.288675134595, 0, 1, 0, 0, 1.15470053838, 0.75, 2, 0.144337567297, 0, 0.5, 4, 0, -1.15470053838, 0.25, 2, 0.144337567297, 0, 0, 0, 0 ];\nconst tvc_14 = [\n\t0, 0, 1, 0, 0, 0, 0, 5, -2.5, 5.1, 0, -0.1, -1.47224318643, 2.5, -1.22113248654, 2.55, 1.44337567297, -0.771687836487, 0, 0, 0, 0, 0, 0, 0, 0, 0.5, 0, 0, -0.866025403784 ];\nconst tvc_15 = [\n\t3.9, 0, 0, 0.1, 0, 5, 0, -2.5, 3.9, 0, 3.5, -0.4, 0, 5, 0, -2, 3.9, 0, 0, 0.1, 0, 5, 0, -1.5, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ];\nconst tvc_16 = [\n\t3.9, 0, 0, 0, 0.1, 0, 5, 0, 0, -2.5, 3.9, 0, 3.5, 0, -0.4, 0, 5, 0, 4, -4, 3.9, 0, 0, 0, 0.1, 0, 5, 0, 0, -1.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ];\nconst tvc_17 = [\n\t3.9, 0, 0.1, 0, 0, 0, 3.9, 3.5, -0.4, 0, 0, 0.5, 3.9, 0, 0.1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ];\nconst tvc_18 = [\n\t0, 0, 5, -2.5, 0, 0, 0, 1, 0, 0, -5, 2.5, 0, 10, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, 3.9, 0, 0, 0.1, 0, -5, 0, 2.5, 3.9, 0, 5, -2.4, 0, 5, 0, -1.5 ];\nconst tvc_19 = [\n\t0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1.95, 2.5, -0.95, -1.95, 2.5, -1.05, 3.9, 0, 0.1, 0, 5, -2, 1.95, -2.5, 1.55, 1.95, 2.5, -0.45 ];\nconst tvc_20 = [\n\t0, -1, 0, 0, 0, 1, 0, 0, 4.95, 0.55, 4.95, 0.55, 0, 0, 9.9, 0.1, -4.95, -0.55, 4.95, 0.55 ];\nconst tvc_21 = [\n\t0, 1, 0, 0, 2.925, 0.075, 1.68874953738, 0.0433012701892, 0, 0, 0, 0, -2.925, 1.425, 1.68874953738, -0.822724133595 ];\nconst tvc_22 = [\n\t1, 0, 0.75, 0.433012701892, 0, 0, 0.75, -0.433012701892 ];\nconst tvc_23 = [\n\t0.5, 0, 0, 0.866025403784, -0.5, 0, 0, -0.866025403784 ];\nconst tvc_24 = [\n\t0, 0.57735026919, -1, 0, 1, 0 ];\nconst tvc_25 = [\n\t0, 0, 0, 0, 0, 0, 3.9, 0, 0.1, 0, 5, -2.5, 3.9, 0, 0.1, 0, 5, -1.5, 0, 0, 0, 0, 0, 1 ];\nconst tvc_26 = [\n\t5, 0, -2, 0, -3.9, -0.1, 0, 0, 1, 0, 0, 0, 5, 0, -2, 0, 3.9, 0.1, 0, 0, 0, 0, 0, 0 ];\nconst tvc_27 = [\n\t0, 0, 1, 0, 0, 0, 0, -3.45, 4, 3.9, 0, 0.1, 0, 3.45, -3, 3.9, 0, 0.1, 0, 0, 0, 0, 0, 0 ];\nconst tvc_28 = [\n\t0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 5, 0, 0, 0, -1.5, 0, 3.9, 0, 0, 0.1, 0, 0, 5, 0, -2.5, 0, 0, 0, 5, -1.5 ];\nconst tvc_29 = [\n\t0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -5, 3.9, 2.6, 3.9, 0, 0, 0.1, 0, -5, 0, 2.5, 3.9, 0, 0, 0.1 ];\nconst tvc_30 = [\n\t0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -10, 0, 0, 5, 0, 10, 0, -4, 10, 0, 10, -10, 0, 10, 0, -5, 0, 0, 10, -5 ];\nconst tvc_31 = [\n\t0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 3.9, 0.1, 0, 0, 3.9, 0.1 ];\nconst tvc_32 = [\n\t0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0.5, 0, 0, 3.9, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, -2, 0, -3.9, 0, -0.1 ];\nconst tvc_33 = [\n\t0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 3.9, 0, 0.1, 0, 0, 0, 3.9, 0, 0.1, 0, 3.9, 0.1 ];\nconst tvc_34 = [\n\t1, 0, 1, 1, 0, 1, 0, 0 ];\nconst tvc_35 = [\n\t1.8, 0.1, 0, 0, 0, 1, 0, 1, 0, 0, -1.8, 1.9, 0, 0, 0, 0 ];\nconst tvc_36 = [\n\t3.8, 0.1, 0, 0, 0, 0, -3.8, 0.9, -3.8, -0.1, 0, 0, 0, 0, 3.8, -0.9 ];\nconst tvc_37 = [\n\t0, 0, 0.57735026919, 0, 0, 1 ];\nconst tvc_38 = [\n\t0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 3.9, 0.1 ];\nconst tvc_39 = [\n\t0.5, 0.5, 0, 0, 1, 0 ];\nconst tvc_40 = [\n\t0, 1, 0, 0, 0, 0.5, 3.9, 0.1, 0, 0, 0, 0 ];\nconst tvc_41 = [\n\t0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 5, 0, -2, 0, 3.9, 0.1 ];\nconst tvc_42 = [\n\t1, 0, -0.5, 0.866025403784, -0.5, -0.866025403784 ];\n\nconst tc_00 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 3.9, 0, 5.5, 0, -0.4, 0, 5, 0, -4, -0.5 ];\nconst tc_01 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7.8, 0, 3.5, 3.5, -0.8, 0, 0, 0, 0, 0 ];\nconst tc_02 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -7.8, 0, -7, 0, 0.8, 0, 0, 0, 0, -1 ];\nconst tc_03 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -7.8, 0, -2.5, 0, -2.5, 0, 0.8, 0, -10, 0, 3, 0, -3, 4 ];\nconst tc_04 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -15.6, 0, -7, -7, 0, 1.6, 0, 0, 0, 0, 0, -2 ];\nconst tc_05 = [ 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, -3, 7.8, 0, 7, 0, 0, -0.8, 0, 0, 0, 0, 0, 0 ];\nconst tc_06 = [ -2.5, -3.37749907476, 0.663397459622, 4.33012701892, -1.95, -3.08108891325, -2.5, 3.37749907476, 2.33660254038, -4.33012701892, -1.95, 2.11506350946 ];\nconst tc_07 = [ 0, 0, 0, 0, 0, 0, 0, -1, 7.8, 0, 7, -0.8, 0, 0, 0, 0 ];\nconst tc_08 = [ 1.5, 0.866025403784, 1.5, -0.866025403784 ];\nconst tc_09 = [ 1.5, 0.866025403784, 0, 1.73205080757 ];\nconst tc_10 = [ 0, 0, 0, 0, 0, -1, 3.9, 3.5, -0.4, 0, 0, -0.5 ];\nconst tc_11 = [ 0, 0, 0, 0, 0, 0, 0, -1, 7.8, 7, 0, -0.8, 0, 0, 0, 0 ];\nconst tc_12 = [ 3.9, 3.5, -0.4, 0, 0, 0.5, 3.9, 3.5, -0.4, 0, 0, -0.5 ];\nconst tc_13 = [ 0, 0, 0, 0, 0, 0, 0, -1, -7.8, -3.5, -3.5, 0.8, 0, 0, 0, 0 ];\nconst tc_14 = [ 0, 0, -4, -0.866025403784, 3.46410161514, 0.75, -2, -0.433012701892 ];\nconst tc_15 = [ 4.4167295593, -2.5, 2.66339745962, -2.55, -4.33012701892, 1.34903810568, 0, -5, 2.5, -5.1, 0, -1.63205080757 ];\nconst tc_16 = [ -7.8, 0, -3.5, 0.3, 0, 0, 0, -0.5, -7.8, 0, -3.5, 0.3, 0, 0, 0, 0.5 ];\nconst tc_17 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7.8, 0, 3.5, 0, -0.3, 0, 10, 0, 4, -7.5 ];\nconst tc_18 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 15.6, 0, 7, 0, -0.6, 0, 0, 0, 0, 0 ];\nconst tc_19 = [ 0, 0, 0, 0, 0, 0, 0, 1, -15.6, 0, -7, 0.6, 0, 0, 0, 0 ];\nconst tc_20 = [ 0, 0, 0, 0, 0, 1, -7.8, -3.5, 0.3, 0, 0, 0.5 ];\nconst tc_21 = [ 0, 0, 0, 0, 0, 10, 0, -3, -7.8, 0, -10, 4.8, 0, 0, 0, 0 ];\nconst tc_22 = [ -3.9, 5, -3.1, -3.9, -5, 1.9, -3.9, -5, 1.9, 3.9, -5, 3.1 ];\nconst tc_23 = [ 9.9, 1.1, -9.9, -1.1, -9.9, -1.1, -9.9, -1.1 ];\nconst tc_24 = [ 0, 0, 0, 1.73205080757, 0, 1.5, 0, -0.866025403784 ];\nconst tc_25 = [ -1.5, 0.866025403784, -1.5, -0.866025403784 ];\nconst tc_26 = [ 0, 1.73205080757, 1.5, -0.866025403784 ];\nconst tc_27 = [ -1, 1.73205080757, 1, 1.73205080757 ];\nconst tc_28 = [ 1, 1.73205080757, -1, 1.73205080757 ];\nconst tc_29 = [ 1, 1.73205080757, 2, 0 ];\nconst tc_30 = [ 0, 0, 0, 0, 0, -1, 3.9, 0, 0.1, 0, 5, -2.5 ];\nconst tc_31 = [ 0, 0, 0, 0, 0, -1, 7.8, 0, 0.2, 0, 0, 0 ];\nconst tc_32 = [ 0, 0, 0, 0, -7.8, -0.2, 0, 0, 1, 0, 0, 0 ];\nconst tc_33 = [ 0, -6.9, 8, 0, 0, 0, 0, -3.45, 4, -3.9, 0, -0.1 ];\nconst tc_34 = [ -5, 0, -5, 0, 5, 0, -3.9, 0, -5, 1.4, -5, 0, 0, 0, 1.5, 0, -3.9, 0, 0, -0.1 ];\nconst tc_35 = [ 0, 0, 0, 0, 0, -1, 7.8, 0, 0.2, 0, 10, -5 ];\nconst tc_36 = [ 0, 0, 0, 0, -7.8, 0, 0, -0.2, 0, 0, 3.9, 1.1, 0, 0, 0, 0 ];\nconst tc_37 = [ -15.6, 0, -0.4, 0, 0, 0, 0, 0, 0, 0, 0, -1 ];\nconst tc_38 = [ 0, 0, 0, 0, -20, 0, -20, 20, 0, 0, 0, -2, 0, 0, 0, 0 ];\nconst tc_39 = [ 0, 2, 0, 0, 0, 0, -7.8, -0.2 ];\nconst tc_40 = [ 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -7.8, -7.8, -0.4 ];\nconst tc_41 = [ -7.8, 0, -0.2, 0, 0, 0, -3.9, 0, -0.1, 0, 3.9, 1.1 ];\nconst tc_42 = [ 0, 2, 2, 0 ];\nconst tc_43 = [ 0, 0, 0, 4, 0, -2, 0, 2 ];\nconst tc_44 = [ 0, 0, -7.6, 1.8, 7.6, 0.2, -7.6, 1.8 ];\nconst tc_45 = [ 1, 1, 1, -1 ];\nconst tc_46 = [ 1, 0, 0, 1 ];\nconst tc_47 = [ 0, 0, -3.9, -0.1, 0, 1, 0, 0 ];\nconst tc_48 = [ 0, 0, -3.9, -0.1, 0, 2, 0, 0 ];\nconst tc_49 = [ 0, -3.45, 4, -3.9, 0, -0.1, 0, -3.45, 4, 3.9, 0, 0.1 ];\nconst tc_50 = [ 3.8, 0.1, -3.8, 0.9, -3.8, -0.1, -3.8, 0.9 ];\nconst tc_51 = [ 0, 2, -1.73205080757, 1 ];\nconst tc_52 = [ 0, 2, 0, 0, 0, 1, 3.9, 0.1 ];\nconst tc_53 = [ 0, 1, -1, 0 ];\nconst tc_54 = [ -1, 1, -2, 0 ];\nconst tc_55 = [ 0, 1, 1, 0 ];\nconst tc_56 = [ 0, 0.5, -3.9, -0.1, 0, -0.5, -3.9, -0.1 ];\nconst tc_57 = [ -5, 0, 2, 0, -3.9, -0.1, -5, 0, 3, 0, -3.9, -0.1 ];\nconst tc_58 = [ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 7.8, 0.2 ];\nconst tc_59 = [ 0, 1, 0, 0, 0, 0, 7.8, 0.2 ];\nconst tc_60 = [ -1.5, 2.59807621135, -3, 0 ];\nconst tc_61 = [ 0, -0.5,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, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 7.8, 0, 3.5, -0.3, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, -0.5 ];\nconst ac_08 = [\n\t1, 0, 0, 0, 1, 0 ];\nconst ac_09 = [\n\t0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ];\nconst ac_10 = [\n\t0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 7.8, 3.5, 0, -0.3, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 5, -2 ];\nconst ac_11 = [\n\t0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -3.5, 0, 0.5, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0.5 ];\nconst ac_12 = [\n\t0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0.5, 0, 0.866025403784, 0, 0.5, 0, 0.866025403784, 0, -0.5, 0, -0.866025403784, 0, -0.5, 0, -0.866025403784, 0, 0.5, 0, 0.866025403784, 0, -0.5, 0, -0.866025403784 ];\nconst ac_13 = [\n\t0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0.5, 0, 0, 0.866025403784, 0, 0, 1, 0, 0, -0.866025403784, 0, 0, 0.5, 0, 0, 0, 0, 0, -0.5, 0, 0, 0.866025403784, 0, 0, 1.5, 0, 0, -0.866025403784, 0, 0, -0.5, 0, 0, -0.866025403784, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, -1.73205080757, 0, 0, -0.5, 0, 0, -0.866025403784, 0, 0, 0, 0, 0, 0.866025403784, 0, 0, -0.5, 0, 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0, 0, 0, 1, 0, 0, 0, -0.5, 0, 0.866025403784, 0, 1.5, 0, -0.866025403784, 0, -0.5, 0, 0.866025403784, 0, -0.5, 0, -0.866025403784, 0, 1.5, 0, 0.866025403784, 0, -0.5, 0, -0.866025403784, 0, 0.5, 0, 0.866025403784, 0, 0, 0, 0.866025403784, 0, -0.5, 0, 0, 0, -1, 0, 0, 0, 1.5, 0, 0, 0, 1, 0, 0.866025403784, 0, 0.5, 0, -0.866025403784, 0, 0, 0, -0.866025403784, 0, -0.5, 0, 1.73205080757 ];\nconst ac_23 = [\n\t1, 0, 0, 0, 1, 0, 0.5, -0.866025403784, 0, 0.866025403784, 0.5, 0, -0.5, -0.866025403784, 0, 0.866025403784, -0.5, 0, -1, 0, 0, 0, -1, 0, -0.5, 0.866025403784, 0, -0.866025403784, -0.5, 0, 0.5, 0.866025403784, 0, -0.866025403784, 0.5, 0 ];\nconst ac_24 = [\n\t1, 0, 0, 0, 1, 0, -0.5, -0.866025403784, 1.5, 0.866025403784, -0.5, -0.866025403784, -0.5, 0.866025403784, 1.5, -0.866025403784, -0.5, 0.866025403784, 0.5, 0.866025403784, 0, 0.866025403784, -0.5, 0, 0.5, -0.866025403784, 0, -0.866025403784, -0.5, 1.73205080757, -1, 0, 1.5, 0, 1, 0.866025403784 ];\nconst ac_25 = [\n\t1, 0, 0, 0, 1, 0, -0.5, 0.866025403784, 0.75, -0.866025403784, -0.5, 0.433012701892, -0.5, -0.866025403784, 0.75, 0.866025403784, -0.5, -0.433012701892 ];\nconst ac_26 = [\n\t1, 0, 0, 0, 1, 0, 0.5, -0.866025403784, 0.75, 0.866025403784, 0.5, 0.433012701892, -0.5, -0.866025403784, 0.75, 0.866025403784, -0.5, 1.29903810568 ];\nconst ac_27 = [\n\t1, 0, 0, 0, 1, 0, 0.5, 0.866025403784, 0.75, 0.866025403784, -0.5, 0.433012701892, -0.5, -0.866025403784, 0.75, 0.866025403784, -0.5, -0.433012701892 ];\nconst ac_28 = [\n\t1, 0, 0, 0, 1, 0, -0.5, -0.866025403784, 0.75, -0.866025403784, 0.5, 0.433012701892, -0.5, 0.866025403784, 0.75, 0.866025403784, 0.5, -0.433012701892 ];\nconst ac_29 = [\n\t1, 0, 0, 0, 1, 0, -0.5, 0.866025403784, -0.5, -0.866025403784, -0.5, 0.866025403784, -0.5, -0.866025403784, 0.5, 0.866025403784, -0.5, 0.866025403784, -0.5, 0.866025403784, -1.5, 0.866025403784, 0.5, 0.866025403784, -0.5, -0.866025403784, -0.5, -0.866025403784, 0.5, 0.866025403784, 1, 0, -1, 0, -1, 1.73205080757 ];\nconst ac_30 = [\n\t1, 0, 0, 0, 1, 0, -0.5, 0.866025403784, -0.5, -0.866025403784, -0.5, 0.866025403784, -0.5, -0.866025403784, 0.5, 0.866025403784, -0.5, 0.866025403784, 0.5, -0.866025403784, -0.5, 0.866025403784, 0.5, 0.866025403784, 0.5, 0.866025403784, -1.5, -0.866025403784, 0.5, 0.866025403784, -1, 0, -1, 0, -1, 1.73205080757 ];\nconst ac_31 = [\n\t1, 0, 0, 0, 1, 0, -0.5, -0.866025403784, 0.5, 0.866025403784, -0.5, 0.866025403784, -0.5, 0.866025403784, -0.5, -0.866025403784, -0.5, 0.866025403784, 0.5, 0.866025403784, 0.5, -0.866025403784, 0.5, 0.866025403784, 0.5, -0.866025403784, 1.5, 0.866025403784, 0.5, 0.866025403784, -1, 0, 1, 0, -1, 1.73205080757 ];\nconst ac_32 = [\n\t0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 7.8, 0, 0.2, 0, 0, 0, 0, 0, 1, 0, 0, 0 ];\nconst ac_33 = [\n\t0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3.9, 0, 0.1, 0, 0, 0, 0, 0, -1, 0, 5, -1.5 ];\nconst ac_34 = [\n\t0, 0, 1, 0, 0, 0, 0, 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-1, 0, -3.9, -0.1 ];\nconst ac_52 = [\n\t1, 0, 0, 0, 1, 0, 0, -1, 2, 1, 0, 0, -1, 0, 2, 0, -1, 2, 0, 1, 0, -1, 0, 2 ];\nconst ac_53 = [\n\t1, 0, 0, 0, 1, 0, 0.5, 0.866025403784, -0.866025403784, -0.866025403784, 0.5, 0.5, -0.5, 0.866025403784, -0.866025403784, -0.866025403784, -0.5, 1.5, -1, 0, 0, 0, -1, 2, -0.5, -0.866025403784, 0.866025403784, 0.866025403784, -0.5, 1.5, 0.5, -0.866025403784, 0.866025403784, 0.866025403784, 0.5, 0.5, -1, 0, 0, 0, 1, 0, -0.5, 0.866025403784, -0.866025403784, 0.866025403784, 0.5, 0.5, 0.5, 0.866025403784, -0.866025403784, 0.866025403784, -0.5, 1.5, 1, 0, 0, 0, -1, 2, 0.5, -0.866025403784, 0.866025403784, -0.866025403784, -0.5, 1.5, -0.5, -0.866025403784, 0.866025403784, -0.866025403784, 0.5, 0.5 ];\nconst ac_54 = [\n\t0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1, 3.9, 0.1, 0, -1, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, -1, 3.9, 0.1 ];\nconst ac_55 = [\n\t1, 0, 0, 0, 1, 0, 0, 1, 0, -1, 0, 1, -1, 0, 1, 0, -1, 1, 0, -1, 1, 1, 0, 0 ];\nconst ac_56 = [\n\t1, 0, 0, 0, 1, 0, 0, 1, 0, -1, 0, 1, -1, 0, 1, 0, -1, 1, 0, -1, 1, 1, 0, 0, -1, 0, 0, 0, 1, 0, 0, -1, 0, -1, 0, 1, 1, 0, -1, 0, -1, 1, 0, 1, -1, 1, 0, 0 ];\nconst ac_57 = [\n\t1, 0, 0, 0, 1, 0, 0, -1, 1, 1, 0, 0, -1, 0, 1, 0, -1, 1, 0, 1, 0, -1, 0, 1 ];\nconst ac_58 = [\n\t0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0 ];\nconst ac_59 = [\n\t0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0 ];\nconst ac_60 = [\n\t0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 5, 0, -1, 0, 0, 0, 0, 0, -1, 0, 3.9, 0.1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 7.8, 0.2, 0, 0, -1, 0, 0, 0, 5, 0, -1, 0, 0, 0, 0, 0, 1, 0, 3.9, 0.1 ];\nconst ac_61 = [\n\t0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1, 7.8, 0.2, 0, 1, 0, 0, 0, 0.5, 0, 0, 0, -1, 3.9, 0.1, 0, -1, 0, 0, 0, 1.5, 0, 0, 0, 1, 3.9, 0.1 ];\nconst ac_62 = [\n\t1, 0, 0, 0, 1, 0, 0.5, -0.866025403784, 0.5, 0.866025403784, 0.5, 0.866025403784, -0.5, -0.866025403784, 0, 0.866025403784, -0.5, 1.73205080757, -1, 0, -1, 0, -1, 1.73205080757, -0.5, 0.866025403784, -1.5, -0.866025403784, -0.5, 0.866025403784, 0.5, 0.866025403784, -1, -0.866025403784, 0.5, 0 ];\nconst ac_63 = [\n\t1, 0, 0, 0, 1, 0, -1, 0, 0.5, 0, -1, 0.866025403784 ];\nconst ac_64 = [\n\t0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0 ];\n\nconst c_00 = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2,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1,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_00,\n\t\tedge_orientations: eo_00,\n\t\tedge_shape_ids: esi_00,\n\t\tdefault_params: dp_00,\n\t\tvertex_coeffs: tvc_00,\n\t\ttranslation_coeffs: tc_00,\n\t\taspect_coeffs: ac_00,\n\t\tcolouring: c_00\n\t},\n\n\t// IH02\n\t{\n\t\tnum_params: 4,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_00,\n\t\tedge_orientations: eo_01,\n\t\tedge_shape_ids: esi_01,\n\t\tdefault_params: dp_01,\n\t\tvertex_coeffs: tvc_01,\n\t\ttranslation_coeffs: tc_01,\n\t\taspect_coeffs: ac_01,\n\t\tcolouring: c_01\n\t},\n\n\t// IH03\n\t{\n\t\tnum_params: 4,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_00,\n\t\tedge_orientations: eo_02,\n\t\tedge_shape_ids: esi_02,\n\t\tdefault_params: dp_02,\n\t\tvertex_coeffs: tvc_02,\n\t\ttranslation_coeffs: tc_02,\n\t\taspect_coeffs: ac_02,\n\t\tcolouring: c_02\n\t},\n\n\t// IH04\n\t{\n\t\tnum_params: 6,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 5,\n\t\tedge_shapes: es_01,\n\t\tedge_orientations: eo_03,\n\t\tedge_shape_ids: esi_03,\n\t\tdefault_params: dp_03,\n\t\tvertex_coeffs: tvc_03,\n\t\ttranslation_coeffs: tc_03,\n\t\taspect_coeffs: ac_03,\n\t\tcolouring: c_02\n\t},\n\n\t// IH05\n\t{\n\t\tnum_params: 5,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 4,\n\t\tedge_shapes: es_02,\n\t\tedge_orientations: eo_04,\n\t\tedge_shape_ids: esi_04,\n\t\tdefault_params: dp_04,\n\t\tvertex_coeffs: tvc_04,\n\t\ttranslation_coeffs: tc_04,\n\t\taspect_coeffs: ac_04,\n\t\tcolouring: c_03\n\t},\n\n\t// IH06\n\t{\n\t\tnum_params: 5,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 4,\n\t\tedge_shapes: es_03,\n\t\tedge_orientations: eo_05,\n\t\tedge_shape_ids: esi_05,\n\t\tdefault_params: dp_05,\n\t\tvertex_coeffs: tvc_05,\n\t\ttranslation_coeffs: tc_05,\n\t\taspect_coeffs: ac_05,\n\t\tcolouring: c_04\n\t},\n\n\t// IH07\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 3,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_00,\n\t\tedge_orientations: eo_06,\n\t\tedge_shape_ids: esi_06,\n\t\tdefault_params: dp_06,\n\t\tvertex_coeffs: tvc_06,\n\t\ttranslation_coeffs: tc_06,\n\t\taspect_coeffs: ac_06,\n\t\tcolouring: c_05\n\t},\n\n\t// IH08\n\t{\n\t\tnum_params: 4,\n\t\tnum_aspects: 1,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_04,\n\t\tedge_orientations: eo_07,\n\t\tedge_shape_ids: esi_00,\n\t\tdefault_params: dp_00,\n\t\tvertex_coeffs: tvc_00,\n\t\ttranslation_coeffs: tc_00,\n\t\taspect_coeffs: ac_00,\n\t\tcolouring: c_00\n\t},\n\n\t// IH09\n\t{\n\t\tnum_params: 3,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_05,\n\t\tedge_orientations: eo_08,\n\t\tedge_shape_ids: esi_07,\n\t\tdefault_params: dp_07,\n\t\tvertex_coeffs: tvc_07,\n\t\ttranslation_coeffs: tc_07,\n\t\taspect_coeffs: ac_07,\n\t\tcolouring: c_06\n\t},\n\n\t// IH10\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 1,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 1,\n\t\tedge_shapes: es_06,\n\t\tedge_orientations: eo_06,\n\t\tedge_shape_ids: esi_08,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_08,\n\t\ttranslation_coeffs: tc_08,\n\t\taspect_coeffs: ac_08,\n\t\tcolouring: c_00\n\t},\n\n\t// IH11\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 1,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 1,\n\t\tedge_shapes: es_07,\n\t\tedge_orientations: eo_07,\n\t\tedge_shape_ids: esi_08,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_08,\n\t\ttranslation_coeffs: tc_09,\n\t\taspect_coeffs: ac_08,\n\t\tcolouring: c_00\n\t},\n\n\t// IH12\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 1,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_08,\n\t\tedge_orientations: eo_09,\n\t\tedge_shape_ids: esi_07,\n\t\tdefault_params: dp_09,\n\t\tvertex_coeffs: tvc_09,\n\t\ttranslation_coeffs: tc_10,\n\t\taspect_coeffs: ac_09,\n\t\tcolouring: c_00\n\t},\n\n\t// IH13\n\t{\n\t\tnum_params: 3,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_09,\n\t\tedge_orientations: eo_10,\n\t\tedge_shape_ids: esi_09,\n\t\tdefault_params: dp_10,\n\t\tvertex_coeffs: tvc_10,\n\t\ttranslation_coeffs: tc_11,\n\t\taspect_coeffs: ac_10,\n\t\tcolouring: c_06\n\t},\n\n\t// IH14\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 1,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_10,\n\t\tedge_orientations: eo_11,\n\t\tedge_shape_ids: esi_10,\n\t\tdefault_params: dp_09,\n\t\tvertex_coeffs: tvc_11,\n\t\ttranslation_coeffs: tc_12,\n\t\taspect_coeffs: ac_09,\n\t\tcolouring: c_00\n\t},\n\n\t// IH15\n\t{\n\t\tnum_params: 3,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_11,\n\t\tedge_orientations: eo_12,\n\t\tedge_shape_ids: esi_11,\n\t\tdefault_params: dp_11,\n\t\tvertex_coeffs: tvc_12,\n\t\ttranslation_coeffs: tc_13,\n\t\taspect_coeffs: ac_11,\n\t\tcolouring: c_06\n\t},\n\n\t// IH16\n\t{\n\t\tnum_params: 1,\n\t\tnum_aspects: 3,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_12,\n\t\tedge_orientations: eo_13,\n\t\tedge_shape_ids: esi_12,\n\t\tdefault_params: dp_12,\n\t\tvertex_coeffs: tvc_13,\n\t\ttranslation_coeffs: tc_14,\n\t\taspect_coeffs: ac_12,\n\t\tcolouring: c_05\n\t},\n\n\t// IH17\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 1,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_13,\n\t\tedge_orientations: eo_14,\n\t\tedge_shape_ids: esi_07,\n\t\tdefault_params: dp_09,\n\t\tvertex_coeffs: tvc_09,\n\t\ttranslation_coeffs: tc_10,\n\t\taspect_coeffs: ac_09,\n\t\tcolouring: c_00\n\t},\n\n\t// IH18\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 1,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 1,\n\t\tedge_shapes: es_14,\n\t\tedge_orientations: eo_06,\n\t\tedge_shape_ids: esi_08,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_08,\n\t\ttranslation_coeffs: tc_09,\n\t\taspect_coeffs: ac_08,\n\t\tcolouring: c_00\n\t},\n\n\t// IH19 is undefined\n\tnull,\n\n\t// IH20\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 1,\n\t\tnum_vertices: 6,\n\t\tnum_edge_shapes: 1,\n\t\tedge_shapes: es_15,\n\t\tedge_orientations: eo_07,\n\t\tedge_shape_ids: esi_08,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_08,\n\t\ttranslation_coeffs: tc_09,\n\t\taspect_coeffs: ac_08,\n\t\tcolouring: c_00\n\t},\n\n\t// IH21\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 6,\n\t\tnum_vertices: 5,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_16,\n\t\tedge_orientations: eo_15,\n\t\tedge_shape_ids: esi_13,\n\t\tdefault_params: dp_13,\n\t\tvertex_coeffs: tvc_14,\n\t\ttranslation_coeffs: tc_15,\n\t\taspect_coeffs: ac_13,\n\t\tcolouring: c_07\n\t},\n\n\t// IH22\n\t{\n\t\tnum_params: 3,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 5,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_17,\n\t\tedge_orientations: eo_16,\n\t\tedge_shape_ids: esi_14,\n\t\tdefault_params: dp_14,\n\t\tvertex_coeffs: tvc_15,\n\t\ttranslation_coeffs: tc_16,\n\t\taspect_coeffs: ac_14,\n\t\tcolouring: c_06\n\t},\n\n\t// IH23\n\t{\n\t\tnum_params: 4,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 5,\n\t\tnum_edge_shapes: 4,\n\t\tedge_shapes: es_18,\n\t\tedge_orientations: eo_17,\n\t\tedge_shape_ids: esi_15,\n\t\tdefault_params: dp_15,\n\t\tvertex_coeffs: tvc_16,\n\t\ttranslation_coeffs: tc_17,\n\t\taspect_coeffs: ac_15,\n\t\tcolouring: c_08\n\t},\n\n\t// IH24\n\t{\n\t\tnum_params: 4,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 5,\n\t\tnum_edge_shapes: 4,\n\t\tedge_shapes: es_19,\n\t\tedge_orientations: eo_17,\n\t\tedge_shape_ids: esi_15,\n\t\tdefault_params: dp_15,\n\t\tvertex_coeffs: tvc_16,\n\t\ttranslation_coeffs: tc_18,\n\t\taspect_coeffs: ac_16,\n\t\tcolouring: c_09\n\t},\n\n\t// IH25\n\t{\n\t\tnum_params: 3,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 5,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_20,\n\t\tedge_orientations: eo_16,\n\t\tedge_shape_ids: esi_14,\n\t\tdefault_params: dp_14,\n\t\tvertex_coeffs: tvc_15,\n\t\ttranslation_coeffs: tc_19,\n\t\taspect_coeffs: ac_17,\n\t\tcolouring: c_10\n\t},\n\n\t// IH26\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 5,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_21,\n\t\tedge_orientations: eo_18,\n\t\tedge_shape_ids: esi_14,\n\t\tdefault_params: dp_16,\n\t\tvertex_coeffs: tvc_17,\n\t\ttranslation_coeffs: tc_20,\n\t\taspect_coeffs: ac_18,\n\t\tcolouring: c_01\n\t},\n\n\t// IH27\n\t{\n\t\tnum_params: 3,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 5,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_16,\n\t\tedge_orientations: eo_19,\n\t\tedge_shape_ids: esi_16,\n\t\tdefault_params: dp_17,\n\t\tvertex_coeffs: tvc_18,\n\t\ttranslation_coeffs: tc_21,\n\t\taspect_coeffs: ac_19,\n\t\tcolouring: c_11\n\t},\n\n\t// IH28\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 5,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_16,\n\t\tedge_orientations: eo_15,\n\t\tedge_shape_ids: esi_13,\n\t\tdefault_params: dp_18,\n\t\tvertex_coeffs: tvc_19,\n\t\ttranslation_coeffs: tc_22,\n\t\taspect_coeffs: ac_20,\n\t\tcolouring: c_12\n\t},\n\n\t// IH29\n\t{\n\t\tnum_params: 1,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 5,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_12,\n\t\tedge_orientations: eo_20,\n\t\tedge_shape_ids: esi_17,\n\t\tdefault_params: dp_19,\n\t\tvertex_coeffs: tvc_20,\n\t\ttranslation_coeffs: tc_23,\n\t\taspect_coeffs: ac_21,\n\t\tcolouring: c_04\n\t},\n\n\t// IH30\n\t{\n\t\tnum_params: 1,\n\t\tnum_aspects: 6,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_22,\n\t\tedge_orientations: eo_21,\n\t\tedge_shape_ids: esi_18,\n\t\tdefault_params: dp_20,\n\t\tvertex_coeffs: tvc_21,\n\t\ttranslation_coeffs: tc_24,\n\t\taspect_coeffs: ac_22,\n\t\tcolouring: c_13\n\t},\n\n\t// IH31\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 6,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_23,\n\t\tedge_orientations: eo_22,\n\t\tedge_shape_ids: esi_19,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_22,\n\t\ttranslation_coeffs: tc_25,\n\t\taspect_coeffs: ac_23,\n\t\tcolouring: c_14\n\t},\n\n\t// IH32\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 6,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_24,\n\t\tedge_orientations: eo_23,\n\t\tedge_shape_ids: esi_19,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_22,\n\t\ttranslation_coeffs: tc_26,\n\t\taspect_coeffs: ac_24,\n\t\tcolouring: c_15\n\t},\n\n\t// IH33\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 3,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_23,\n\t\tedge_orientations: eo_22,\n\t\tedge_shape_ids: esi_19,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_23,\n\t\ttranslation_coeffs: tc_08,\n\t\taspect_coeffs: ac_25,\n\t\tcolouring: c_05\n\t},\n\n\t// IH34\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 3,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 1,\n\t\tedge_shapes: es_06,\n\t\tedge_orientations: eo_24,\n\t\tedge_shape_ids: esi_20,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_23,\n\t\ttranslation_coeffs: tc_09,\n\t\taspect_coeffs: ac_26,\n\t\tcolouring: c_05\n\t},\n\n\t// IH35 is undefined\n\tnull,\n\n\t// IH36\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 3,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 1,\n\t\tedge_shapes: es_06,\n\t\tedge_orientations: eo_25,\n\t\tedge_shape_ids: esi_20,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_23,\n\t\ttranslation_coeffs: tc_08,\n\t\taspect_coeffs: ac_27,\n\t\tcolouring: c_05\n\t},\n\n\t// IH37\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 3,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 1,\n\t\tedge_shapes: es_15,\n\t\tedge_orientations: eo_26,\n\t\tedge_shape_ids: esi_20,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_23,\n\t\ttranslation_coeffs: tc_08,\n\t\taspect_coeffs: ac_28,\n\t\tcolouring: c_05\n\t},\n\n\t// IH38\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 6,\n\t\tnum_vertices: 3,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_10,\n\t\tedge_orientations: eo_27,\n\t\tedge_shape_ids: esi_21,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_24,\n\t\ttranslation_coeffs: tc_27,\n\t\taspect_coeffs: ac_29,\n\t\tcolouring: c_15\n\t},\n\n\t// IH39\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 6,\n\t\tnum_vertices: 3,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_25,\n\t\tedge_orientations: eo_27,\n\t\tedge_shape_ids: esi_21,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_24,\n\t\ttranslation_coeffs: tc_28,\n\t\taspect_coeffs: ac_30,\n\t\tcolouring: c_16\n\t},\n\n\t// IH40\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 6,\n\t\tnum_vertices: 3,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_24,\n\t\tedge_orientations: eo_28,\n\t\tedge_shape_ids: esi_21,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_24,\n\t\ttranslation_coeffs: tc_29,\n\t\taspect_coeffs: ac_31,\n\t\tcolouring: c_17\n\t},\n\n\t// IH41\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 1,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_23,\n\t\tedge_orientations: eo_22,\n\t\tedge_shape_ids: esi_22,\n\t\tdefault_params: dp_21,\n\t\tvertex_coeffs: tvc_25,\n\t\ttranslation_coeffs: tc_30,\n\t\taspect_coeffs: ac_09,\n\t\tcolouring: c_18\n\t},\n\n\t// IH42\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_22,\n\t\tedge_orientations: eo_29,\n\t\tedge_shape_ids: esi_23,\n\t\tdefault_params: dp_21,\n\t\tvertex_coeffs: tvc_25,\n\t\ttranslation_coeffs: tc_31,\n\t\taspect_coeffs: ac_32,\n\t\tcolouring: c_19\n\t},\n\n\t// IH43\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_23,\n\t\tedge_orientations: eo_30,\n\t\tedge_shape_ids: esi_22,\n\t\tdefault_params: dp_21,\n\t\tvertex_coeffs: tvc_25,\n\t\ttranslation_coeffs: tc_31,\n\t\taspect_coeffs: ac_33,\n\t\tcolouring: c_19\n\t},\n\n\t// IH44\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_23,\n\t\tedge_orientations: eo_31,\n\t\tedge_shape_ids: esi_24,\n\t\tdefault_params: dp_22,\n\t\tvertex_coeffs: tvc_26,\n\t\ttranslation_coeffs: tc_32,\n\t\taspect_coeffs: ac_34,\n\t\tcolouring: c_20\n\t},\n\n\t// IH45\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_22,\n\t\tedge_orientations: eo_32,\n\t\tedge_shape_ids: esi_23,\n\t\tdefault_params: dp_23,\n\t\tvertex_coeffs: tvc_27,\n\t\ttranslation_coeffs: tc_33,\n\t\taspect_coeffs: ac_35,\n\t\tcolouring: c_20\n\t},\n\n\t// IH46\n\t{\n\t\tnum_params: 4,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 4,\n\t\tedge_shapes: es_26,\n\t\tedge_orientations: eo_33,\n\t\tedge_shape_ids: esi_25,\n\t\tdefault_params: dp_24,\n\t\tvertex_coeffs: tvc_28,\n\t\ttranslation_coeffs: tc_34,\n\t\taspect_coeffs: ac_36,\n\t\tcolouring: c_20\n\t},\n\n\t// IH47\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_27,\n\t\tedge_orientations: eo_29,\n\t\tedge_shape_ids: esi_23,\n\t\tdefault_params: dp_21,\n\t\tvertex_coeffs: tvc_25,\n\t\ttranslation_coeffs: tc_35,\n\t\taspect_coeffs: ac_37,\n\t\tcolouring: c_19\n\t},\n\n\t// IH48 is undefined\n\tnull,\n\n\t// IH49\n\t{\n\t\tnum_params: 3,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 4,\n\t\tedge_shapes: es_28,\n\t\tedge_orientations: eo_33,\n\t\tedge_shape_ids: esi_25,\n\t\tdefault_params: dp_25,\n\t\tvertex_coeffs: tvc_29,\n\t\ttranslation_coeffs: tc_36,\n\t\taspect_coeffs: ac_38,\n\t\tcolouring: c_21\n\t},\n\n\t// IH50\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_29,\n\t\tedge_orientations: eo_29,\n\t\tedge_shape_ids: esi_23,\n\t\tdefault_params: dp_21,\n\t\tvertex_coeffs: tvc_25,\n\t\ttranslation_coeffs: tc_37,\n\t\taspect_coeffs: ac_39,\n\t\tcolouring: c_22\n\t},\n\n\t// IH51\n\t{\n\t\tnum_params: 3,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_27,\n\t\tedge_orientations: eo_32,\n\t\tedge_shape_ids: esi_23,\n\t\tdefault_params: dp_26,\n\t\tvertex_coeffs: tvc_30,\n\t\ttranslation_coeffs: tc_38,\n\t\taspect_coeffs: ac_40,\n\t\tcolouring: c_21\n\t},\n\n\t// IH52\n\t{\n\t\tnum_params: 1,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_23,\n\t\tedge_orientations: eo_34,\n\t\tedge_shape_ids: esi_22,\n\t\tdefault_params: dp_20,\n\t\tvertex_coeffs: tvc_31,\n\t\ttranslation_coeffs: tc_39,\n\t\taspect_coeffs: ac_41,\n\t\tcolouring: c_23\n\t},\n\n\t// IH53\n\t{\n\t\tnum_params: 3,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_27,\n\t\tedge_orientations: eo_35,\n\t\tedge_shape_ids: esi_26,\n\t\tdefault_params: dp_27,\n\t\tvertex_coeffs: tvc_32,\n\t\ttranslation_coeffs: tc_40,\n\t\taspect_coeffs: ac_42,\n\t\tcolouring: c_21\n\t},\n\n\t// IH54\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 4,\n\t\tedge_shapes: es_30,\n\t\tedge_orientations: eo_33,\n\t\tedge_shape_ids: esi_25,\n\t\tdefault_params: dp_28,\n\t\tvertex_coeffs: tvc_33,\n\t\ttranslation_coeffs: tc_41,\n\t\taspect_coeffs: ac_43,\n\t\tcolouring: c_22\n\t},\n\n\t// IH55\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_23,\n\t\tedge_orientations: eo_24,\n\t\tedge_shape_ids: esi_24,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_34,\n\t\ttranslation_coeffs: tc_42,\n\t\taspect_coeffs: ac_44,\n\t\tcolouring: c_24\n\t},\n\n\t// IH56\n\t{\n\t\tnum_params: 1,\n\t\tnum_aspects: 8,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_22,\n\t\tedge_orientations: eo_36,\n\t\tedge_shape_ids: esi_26,\n\t\tdefault_params: dp_29,\n\t\tvertex_coeffs: tvc_35,\n\t\ttranslation_coeffs: tc_43,\n\t\taspect_coeffs: ac_45,\n\t\tcolouring: c_25\n\t},\n\n\t// IH57\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 1,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_31,\n\t\tedge_orientations: eo_33,\n\t\tedge_shape_ids: esi_22,\n\t\tdefault_params: dp_21,\n\t\tvertex_coeffs: tvc_25,\n\t\ttranslation_coeffs: tc_30,\n\t\taspect_coeffs: ac_09,\n\t\tcolouring: c_18\n\t},\n\n\t// IH58\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_32,\n\t\tedge_orientations: eo_33,\n\t\tedge_shape_ids: esi_22,\n\t\tdefault_params: dp_21,\n\t\tvertex_coeffs: tvc_25,\n\t\ttranslation_coeffs: tc_31,\n\t\taspect_coeffs: ac_32,\n\t\tcolouring: c_19\n\t},\n\n\t// IH59\n\t{\n\t\tnum_params: 1,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 1,\n\t\tedge_shapes: es_06,\n\t\tedge_orientations: eo_31,\n\t\tedge_shape_ids: esi_20,\n\t\tdefault_params: dp_30,\n\t\tvertex_coeffs: tvc_36,\n\t\ttranslation_coeffs: tc_44,\n\t\taspect_coeffs: ac_46,\n\t\tcolouring: c_20\n\t},\n\n\t// IH60 is undefined\n\tnull,\n\n\t// IH61\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 1,\n\t\tedge_shapes: es_06,\n\t\tedge_orientations: eo_24,\n\t\tedge_shape_ids: esi_20,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_34,\n\t\ttranslation_coeffs: tc_45,\n\t\taspect_coeffs: ac_47,\n\t\tcolouring: c_20\n\t},\n\n\t// IH62\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 1,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 1,\n\t\tedge_shapes: es_07,\n\t\tedge_orientations: eo_33,\n\t\tedge_shape_ids: esi_20,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_34,\n\t\ttranslation_coeffs: tc_46,\n\t\taspect_coeffs: ac_08,\n\t\tcolouring: c_18\n\t},\n\n\t// IH63 is undefined\n\tnull,\n\n\t// IH64\n\t{\n\t\tnum_params: 1,\n\t\tnum_aspects: 1,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_33,\n\t\tedge_orientations: eo_37,\n\t\tedge_shape_ids: esi_22,\n\t\tdefault_params: dp_20,\n\t\tvertex_coeffs: tvc_31,\n\t\ttranslation_coeffs: tc_47,\n\t\taspect_coeffs: ac_48,\n\t\tcolouring: c_18\n\t},\n\n\t// IH65 is undefined\n\tnull,\n\n\t// IH66\n\t{\n\t\tnum_params: 1,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_34,\n\t\tedge_orientations: eo_37,\n\t\tedge_shape_ids: esi_22,\n\t\tdefault_params: dp_20,\n\t\tvertex_coeffs: tvc_31,\n\t\ttranslation_coeffs: tc_48,\n\t\taspect_coeffs: ac_49,\n\t\tcolouring: c_19\n\t},\n\n\t// IH67\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_21,\n\t\tedge_orientations: eo_38,\n\t\tedge_shape_ids: esi_23,\n\t\tdefault_params: dp_23,\n\t\tvertex_coeffs: tvc_27,\n\t\ttranslation_coeffs: tc_49,\n\t\taspect_coeffs: ac_50,\n\t\tcolouring: c_20\n\t},\n\n\t// IH68\n\t{\n\t\tnum_params: 1,\n\t\tnum_aspects: 1,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 1,\n\t\tedge_shapes: es_06,\n\t\tedge_orientations: eo_39,\n\t\tedge_shape_ids: esi_20,\n\t\tdefault_params: dp_30,\n\t\tvertex_coeffs: tvc_36,\n\t\ttranslation_coeffs: tc_50,\n\t\taspect_coeffs: ac_48,\n\t\tcolouring: c_18\n\t},\n\n\t// IH69\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_31,\n\t\tedge_orientations: eo_26,\n\t\tedge_shape_ids: esi_24,\n\t\tdefault_params: dp_22,\n\t\tvertex_coeffs: tvc_26,\n\t\ttranslation_coeffs: tc_32,\n\t\taspect_coeffs: ac_51,\n\t\tcolouring: c_20\n\t},\n\n\t// IH70 is undefined\n\tnull,\n\n\t// IH71\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 1,\n\t\tedge_shapes: es_06,\n\t\tedge_orientations: eo_40,\n\t\tedge_shape_ids: esi_20,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_34,\n\t\ttranslation_coeffs: tc_42,\n\t\taspect_coeffs: ac_52,\n\t\tcolouring: c_24\n\t},\n\n\t// IH72\n\t{\n\t\tnum_params: 1,\n\t\tnum_aspects: 1,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_24,\n\t\tedge_orientations: eo_33,\n\t\tedge_shape_ids: esi_22,\n\t\tdefault_params: dp_20,\n\t\tvertex_coeffs: tvc_31,\n\t\ttranslation_coeffs: tc_47,\n\t\taspect_coeffs: ac_48,\n\t\tcolouring: c_18\n\t},\n\n\t// IH73\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 1,\n\t\tedge_shapes: es_14,\n\t\tedge_orientations: eo_24,\n\t\tedge_shape_ids: esi_20,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_34,\n\t\ttranslation_coeffs: tc_45,\n\t\taspect_coeffs: ac_47,\n\t\tcolouring: c_20\n\t},\n\n\t// IH74\n\t{\n\t\tnum_params: 1,\n\t\tnum_aspects: 1,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 1,\n\t\tedge_shapes: es_07,\n\t\tedge_orientations: eo_26,\n\t\tedge_shape_ids: esi_20,\n\t\tdefault_params: dp_30,\n\t\tvertex_coeffs: tvc_36,\n\t\ttranslation_coeffs: tc_50,\n\t\taspect_coeffs: ac_48,\n\t\tcolouring: c_18\n\t},\n\n\t// IH75 is undefined\n\tnull,\n\n\t// IH76\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 1,\n\t\tnum_vertices: 4,\n\t\tnum_edge_shapes: 1,\n\t\tedge_shapes: es_15,\n\t\tedge_orientations: eo_33,\n\t\tedge_shape_ids: esi_20,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_34,\n\t\ttranslation_coeffs: tc_46,\n\t\taspect_coeffs: ac_08,\n\t\tcolouring: c_18\n\t},\n\n\t// IH77\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 12,\n\t\tnum_vertices: 3,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_35,\n\t\tedge_orientations: eo_41,\n\t\tedge_shape_ids: esi_27,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_37,\n\t\ttranslation_coeffs: tc_51,\n\t\taspect_coeffs: ac_53,\n\t\tcolouring: c_26\n\t},\n\n\t// IH78\n\t{\n\t\tnum_params: 1,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 3,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_36,\n\t\tedge_orientations: eo_41,\n\t\tedge_shape_ids: esi_27,\n\t\tdefault_params: dp_20,\n\t\tvertex_coeffs: tvc_38,\n\t\ttranslation_coeffs: tc_52,\n\t\taspect_coeffs: ac_54,\n\t\tcolouring: c_22\n\t},\n\n\t// IH79\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 3,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_25,\n\t\tedge_orientations: eo_27,\n\t\tedge_shape_ids: esi_21,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_39,\n\t\ttranslation_coeffs: tc_53,\n\t\taspect_coeffs: ac_55,\n\t\tcolouring: c_27\n\t},\n\n\t// IH80 is undefined\n\tnull,\n\n\t// IH81\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 8,\n\t\tnum_vertices: 3,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_10,\n\t\tedge_orientations: eo_27,\n\t\tedge_shape_ids: esi_21,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_39,\n\t\ttranslation_coeffs: tc_54,\n\t\taspect_coeffs: ac_56,\n\t\tcolouring: c_25\n\t},\n\n\t// IH82\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 3,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_24,\n\t\tedge_orientations: eo_28,\n\t\tedge_shape_ids: esi_21,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_39,\n\t\ttranslation_coeffs: tc_55,\n\t\taspect_coeffs: ac_57,\n\t\tcolouring: c_27\n\t},\n\n\t// IH83\n\t{\n\t\tnum_params: 1,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 3,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_10,\n\t\tedge_orientations: eo_42,\n\t\tedge_shape_ids: esi_28,\n\t\tdefault_params: dp_31,\n\t\tvertex_coeffs: tvc_40,\n\t\ttranslation_coeffs: tc_56,\n\t\taspect_coeffs: ac_58,\n\t\tcolouring: c_20\n\t},\n\n\t// IH84\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 3,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_04,\n\t\tedge_orientations: eo_41,\n\t\tedge_shape_ids: esi_27,\n\t\tdefault_params: dp_32,\n\t\tvertex_coeffs: tvc_41,\n\t\ttranslation_coeffs: tc_57,\n\t\taspect_coeffs: ac_59,\n\t\tcolouring: c_20\n\t},\n\n\t// IH85\n\t{\n\t\tnum_params: 2,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 3,\n\t\tnum_edge_shapes: 3,\n\t\tedge_shapes: es_37,\n\t\tedge_orientations: eo_41,\n\t\tedge_shape_ids: esi_27,\n\t\tdefault_params: dp_32,\n\t\tvertex_coeffs: tvc_41,\n\t\ttranslation_coeffs: tc_58,\n\t\taspect_coeffs: ac_60,\n\t\tcolouring: c_21\n\t},\n\n\t// IH86\n\t{\n\t\tnum_params: 1,\n\t\tnum_aspects: 4,\n\t\tnum_vertices: 3,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_25,\n\t\tedge_orientations: eo_42,\n\t\tedge_shape_ids: esi_28,\n\t\tdefault_params: dp_31,\n\t\tvertex_coeffs: tvc_40,\n\t\ttranslation_coeffs: tc_59,\n\t\taspect_coeffs: ac_61,\n\t\tcolouring: c_21\n\t},\n\n\t// IH87 is undefined\n\tnull,\n\n\t// IH88\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 6,\n\t\tnum_vertices: 3,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_25,\n\t\tedge_orientations: eo_43,\n\t\tedge_shape_ids: esi_28,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_42,\n\t\ttranslation_coeffs: tc_60,\n\t\taspect_coeffs: ac_62,\n\t\tcolouring: c_28\n\t},\n\n\t// IH89 is undefined\n\tnull,\n\n\t// IH90\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 3,\n\t\tnum_edge_shapes: 1,\n\t\tedge_shapes: es_07,\n\t\tedge_orientations: eo_41,\n\t\tedge_shape_ids: esi_29,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_42,\n\t\ttranslation_coeffs: tc_09,\n\t\taspect_coeffs: ac_63,\n\t\tcolouring: c_20\n\t},\n\n\t// IH91\n\t{\n\t\tnum_params: 1,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 3,\n\t\tnum_edge_shapes: 2,\n\t\tedge_shapes: es_32,\n\t\tedge_orientations: eo_44,\n\t\tedge_shape_ids: esi_28,\n\t\tdefault_params: dp_31,\n\t\tvertex_coeffs: tvc_40,\n\t\ttranslation_coeffs: tc_61,\n\t\taspect_coeffs: ac_64,\n\t\tcolouring: c_20\n\t},\n\n\t// IH92 is undefined\n\tnull,\n\n\t// IH93\n\t{\n\t\tnum_params: 0,\n\t\tnum_aspects: 2,\n\t\tnum_vertices: 3,\n\t\tnum_edge_shapes: 1,\n\t\tedge_shapes: es_15,\n\t\tedge_orientations: eo_41,\n\t\tedge_shape_ids: esi_29,\n\t\tdefault_params: dp_08,\n\t\tvertex_coeffs: tvc_42,\n\t\ttranslation_coeffs: tc_09,\n\t\taspect_coeffs: ac_63,\n\t\tcolouring: c_20\n\t}\n\n];})();\nfunction makePoint( coeffs, offs, params )\n{\n\tlet ret = { x : 0.0, y : 0.0 }\n\n\tfor( let i = 0; i < params.length; ++i ) {\n\t\tret.x += coeffs[offs+i] * params[i];\n\t\tret.y += coeffs[offs+params.length+i] * params[i];\n\t}\n\n\treturn ret;\n};\n\nfunction makeMatrix( coeffs, offs, params )\n{\n\tlet ret = []\n\n\tfor( let row = 0; row < 2; ++row ) {\n\t\tfor( let col = 0; col < 3; ++col ) {\n\t\t\tlet val = 0.0;\n\t\t\tfor( let idx = 0; idx < params.length; ++idx ) {\n\t\t\t\tval += coeffs[offs+idx] * params[idx];\n\t\t\t}\n\t\t\tret.push( val );\n\t\t\toffs += params.length;\n\t\t}\n\t}\n\n\treturn ret;\n};\n\nconst M_orients = [\n\t[1.0, 0.0, 0.0, 0.0, 1.0, 0.0], // IDENTITY\n\t[-1.0, 0.0, 1.0, 0.0, -1.0, 0.0], // ROT\n\t[-1.0, 0.0, 1.0, 0.0, 1.0, 0.0], // FLIP\n\t[1.0, 0.0, 0.0, 0.0, -1.0, 0.0] // ROFL\n];\n\nconst TSPI_U = [\n\t[0.5, 0.0, 0.0, 0.0, 0.5, 0.0],\n\t[-0.5, 0.0, 1.0, 0.0, 0.5, 0.0]\n];\n\nconst TSPI_S = [\n\t[0.5, 0.0, 0.0, 0.0, 0.5, 0.0],\n\t[-0.5, 0.0, 1.0, 0.0, -0.5, 0.0]\n];\n\nclass IsohedralTiling\n{\n\tconstructor( tp )\n\t{\n\t\tthis.reset( tp );\n\t}\n\n\treset( tp )\n\t{\n\t\tthis.tiling_type = tp;\n\t\tthis.ttd = tiling_type_data[ tp ];\n\t\tthis.parameters = this.ttd.default_params.slice( 0 );\n\t\tthis.parameters.push( 1.0 );\n\t\tthis.recompute();\n\t}\n\n\trecompute()\n\t{\n\t\tconst ntv = this.numVertices();\n\t\tconst np = this.numParameters();\n\t\tconst na = this.numAspects();\n\n\t\t// Recompute tiling vertex locations.\n\t\tthis.verts = [];\n\t\tfor( let idx = 0; idx < ntv; ++idx ) {\n\t\t\tthis.verts.push( makePoint( this.ttd.vertex_coeffs,\n\t\t\t\tidx * (2 * (np + 1)), this.parameters ) );\n\t\t}\n\n\t\t// Recompute edge transforms and reversals from orientation information.\n\t\tthis.reversals = [];\n\t\tthis.edges = []\n\t\tfor( let idx = 0; idx < ntv; ++idx ) {\n\t\t\tconst fl = this.ttd.edge_orientations[2*idx];\n\t\t\tconst ro = this.ttd.edge_orientations[2*idx+1];\n\t\t\tthis.reversals.push( fl != ro );\n\t\t\tthis.edges.push( \n\t\t\t\tmul( matchSeg( this.verts[idx], this.verts[(idx+1)%ntv] ),\n\t\t\t\tM_orients[2*fl+ro] ) );\n\t\t}\n\n\t\t// Recompute aspect xforms.\n\t\tthis.aspects = []\n\t\tfor( let idx = 0; idx < na; ++idx ) {\n\t\t\tthis.aspects.push( \n\t\t\t\tmakeMatrix( this.ttd.aspect_coeffs, 6*(np+1)*idx,\n\t\t\t\t\tthis.parameters ) );\n\t\t}\n\t\t\t\t\t\n\t\t// Recompute translation vectors.\n\t\tthis.t1 = makePoint(\n\t\t\tthis.ttd.translation_coeffs, 0, this.parameters );\n\t\tthis.t2 = makePoint(\n\t\t\tthis.ttd.translation_coeffs, 2*(np+1), this.parameters );\n\t}\n\n\tgetTilingType()\n\t{\n\t\treturn this.tiling_type;\n\t}\n\n\tnumParameters()\n\t{\n\t\treturn this.ttd.num_params;\n\t}\n\n\tsetParameters( arr )\n\t{\n\t\tif( arr.length == (this.parameters.length-1) ) {\n\t\t\tthis.parameters = arr.slice( 0 );\n\t\t\tthis.parameters.push( 1.0 );\n\t\t\tthis.recompute();\n\t\t}\n\t}\n\n\tgetParameters()\n\t{\n\t\treturn this.parameters.slice( 0, -1 );\n\t}\n\n\tnumEdgeShapes()\n\t{\n\t\treturn this.ttd.num_edge_shapes;\n\t}\n\n\tgetEdgeShape( idx )\n\t{\n\t\treturn this.ttd.edge_shapes[ idx ];\n\t}\n\n\t* shape()\n\t{\n\t\tfor( let idx = 0; idx < this.numVertices(); ++idx ) {\n\t\t\tconst an_id = this.ttd.edge_shape_ids[idx];\n\n\t\t\tyield {\n\t\t\t\tT : this.edges[idx],\n\t\t\t\tid : an_id,\n\t\t\t\tshape : this.ttd.edge_shapes[ an_id ],\n\t\t\t\trev : this.reversals[ idx ]\n\t\t\t};\n\t\t}\n\t}\n\n\t* parts()\n\t{\n\t\tfor( let idx = 0; idx < this.numVertices(); ++idx ) {\n\t\t\tconst an_id = this.ttd.edge_shape_ids[idx];\n\t\t\tconst shp = this.ttd.edge_shapes[an_id];\n\n\t\t\tif( (shp == EdgeShape.J) || (shp == EdgeShape.I) ) {\n\t\t\t\tyield {\n\t\t\t\t\tT : this.edges[idx],\n\t\t\t\t\tid : an_id,\n\t\t\t\t\tshape : shp,\n\t\t\t\t\trev : this.reversals[ idx ],\n\t\t\t\t\tsecond : false\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tconst indices = this.reversals[idx] ? [1,0] : [0,1];\n\t\t\t\tconst Ms = (shp == EdgeShape.U) ? TSPI_U : TSPI_S;\n\n\t\t\t\tyield {\n\t\t\t\t\tT : mul( this.edges[idx], Ms[indices[0]] ),\n\t\t\t\t\tid : an_id,\n\t\t\t\t\tshape : shp,\n\t\t\t\t\trev : false,\n\t\t\t\t\tsecond : false\n\t\t\t\t};\n\t\t\t\t\n\t\t\t\tyield {\n\t\t\t\t\tT : mul( this.edges[idx], Ms[indices[1]] ),\n\t\t\t\t\tid : an_id,\n\t\t\t\t\tshape : shp,\n\t\t\t\t\trev : true,\n\t\t\t\t\tsecond : true\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n\n\tnumVertices()\n\t{\n\t\treturn this.ttd.num_vertices;\n\t}\n\n\tgetVertex( idx )\n\t{\n\t\treturn { ...this.verts[ idx ] };\n\t}\n\n\tvertices()\n\t{\n\t\treturn this.verts.map( v => ({ ...v }) );\n\t}\n\n\tnumAspects()\n\t{\n\t\treturn this.ttd.num_aspects;\n\t}\n\t\n\tgetAspectTransform( idx )\n\t{\n\t\treturn [ ...this.aspects[ idx ] ];\n\t}\n\n\tgetT1()\n\t{\n\t\treturn { ...this.t1 };\n\t}\n\n\tgetT2()\n\t{\n\t\treturn { ...this.t2 };\n\t}\n\n\t* fillRegionBounds( xmin, ymin, xmax, ymax )\n\t{\n\t\tyield* this.fillRegionQuad(\n\t\t\t{ x : xmin, y : ymin },\n\t\t\t{ x : xmax, y : ymin },\n\t\t\t{ x : xmax, y : ymax },\n\t\t\t{ x : xmin, y : ymax } );\n\t}\n\n\t* fillRegionQuad( A, B, C, D )\n\t{\n\t\tconst t1 = this.getT1();\n\t\tconst t2 = this.getT2();\n\t\tconst ttd = this.ttd;\n\t\tconst aspects = this.aspects;\n\n\t\tlet last_y;\n\n\t\tfunction bc( M, p ) {\n\t\t\treturn { \n\t\t\t\tx : M[0]*p.x + M[1]*p.y,\n\t\t\t\ty : M[2]*p.x + M[3]*p.y };\n\t\t};\n\n\t\tfunction sampleAtHeight( P, Q, y )\n\t\t{\n\t\t\tconst t = (y-P.y)/(Q.y-P.y);\n\t\t\treturn { x : (1.0-t)*P.x + t*Q.x, y : y };\n\t\t}\n\n\t\tfunction* doFill( A, B, C, D, do_top )\n\t\t{\n\t\t\tlet x1 = A.x;\n\t\t\tconst dx1 = (D.x-A.x)/(D.y-A.y);\n\t\t\tlet x2 = B.x;\n\t\t\tconst dx2 = (C.x-B.x)/(C.y-B.y);\n\t\t\tconst ymin = A.y;\n\t\t\tlet ymax = C.y;\n\n\t\t\tif( do_top ) {\n\t\t\t\tymax = ymax + 1.0;\n\t\t\t}\n\n\t\t\tlet y = Math.floor( ymin );\n\t\t\tif( last_y ) {\n\t\t\t\ty = Math.max( last_y, y );\n\t\t\t}\n\n\t\t\twhile( y < ymax ) {\n\t\t\t\tconst yi = Math.trunc( y );\n\t\t\t\tlet x = Math.floor( x1 );\n\t\t\t\twhile( x < (x2 + 1e-7) ) {\n\t\t\t\t\tconst xi = Math.trunc( x );\n\n\t\t\t\t\tfor( let asp = 0; asp < ttd.num_aspects; ++asp ) {\n\t\t\t\t\t\tlet M = aspects[ asp ].slice( 0 );\n\t\t\t\t\t\tM[2] += xi*t1.x + yi*t2.x;\n\t\t\t\t\t\tM[5] += xi*t1.y + yi*t2.y;\n\n\t\t\t\t\t\tyield {\n\t\t\t\t\t\t\tT : M,\n\t\t\t\t\t\t\tt1 : xi,\n\t\t\t\t\t\t\tt2 : yi,\n\t\t\t\t\t\t\taspect : asp\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tx += 1.0;\n\t\t\t\t}\n\t\t\t\tx1 += dx1;\n\t\t\t\tx2 += dx2;\n\t\t\t\ty += 1.0;\n\t\t\t}\n\n\t\t\tlast_y = y;\n\t\t}\n\n\t\tfunction* fillFixX( A, B, C, D, do_top )\n\t\t{\n\t\t\tif( A.x > B.x ) {\n\t\t\t\tyield* doFill( B, A, D, C, do_top );\n\t\t\t} else {\n\t\t\t\tyield* doFill( A, B, C, D, do_top );\n\t\t\t}\n\t\t}\n\t\t\t\n\t\tfunction* fillFixY( A, B, C, D, do_top ) \n\t\t{\n\t\t\tif( A.y > C.y ) {\n\t\t\t\tyield* doFill( C, D, A, B, do_top );\n\t\t\t} else {\n\t\t\t\tyield* doFill( A, B, C, D, do_top );\n\t\t\t}\n\t\t}\n\n\t\tconst det = 1.0 / (t1.x*t2.y-t2.x*t1.y);\n\t\tconst Mbc = [ t2.y * det, -t2.x * det, -t1.y * det, t1.x * det ];\n\n\t\tlet pts = [ bc( Mbc, A ), bc( Mbc, B ), bc( Mbc, C ), bc( Mbc, D ) ];\n\n\t\tif( det < 0.0 ) {\n\t\t\tlet tmp = pts[1];\n\t\t\tpts[1] = pts[3];\n\t\t\tpts[3] = tmp;\n\t\t}\n\n\t\tif( Math.abs( pts[0].y - pts[1].y ) < 1e-7 ) {\n\t\t\tyield* fillFixY( pts[0], pts[1], pts[2], pts[3], true );\n\t\t} else if( Math.abs( pts[1].y - pts[2].y ) < 1e-7 ) {\n\t\t\tyield* fillFixY( pts[1], pts[2], pts[3], pts[0], true );\n\t\t} else {\n\t\t\tlet lowest = 0;\n\t\t\tfor( let idx = 1; idx < 4; ++idx ) {\n\t\t\t\tif( pts[idx].y < pts[lowest].y ) {\n\t\t\t\t\tlowest = idx;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet bottom = pts[lowest];\n\t\t\tlet left = pts[(lowest+1)%4];\n\t\t\tlet top = pts[(lowest+2)%4];\n\t\t\tlet right = pts[(lowest+3)%4];\n\n\t\t\tif( left.x > right.x ) {\n\t\t\t\tlet tmp = left;\n\t\t\t\tleft = right;\n\t\t\t\tright = tmp;\n\t\t\t}\n\n\t\t\tif( left.y < right.y ) {\n\t\t\t\tconst r1 = sampleAtHeight( bottom, right, left.y );\n\t\t\t\tconst l2 = sampleAtHeight( left, top, right.y );\n\t\t\t\tyield* fillFixX( bottom, bottom, r1, left, false );\n\t\t\t\tyield* fillFixX( left, r1, right, l2, false );\n\t\t\t\tyield* fillFixX( l2, right, top, top, true );\n\t\t\t} else {\n\t\t\t\tconst l1 = sampleAtHeight( bottom, left, right.y );\n\t\t\t\tconst r2 = sampleAtHeight( right, top, left.y );\n\t\t\t\tyield* fillFixX( bottom, bottom, right, l1, false );\n\t\t\t\tyield* fillFixX( l1, right, r2, left, false );\n\t\t\t\tyield* fillFixX( left, r2, top, top, true );\n\t\t\t}\n\t\t}\n\t}\n\t\n\tgetColour( a, b, asp )\n\t{\n\t\tconst clrg = this.ttd.colouring;\n\t\tconst nc = clrg[18];\n\n\t\tlet mt1 = a % nc;\n\t\tif( mt1 < 0 ) {\n\t\t\tmt1 += nc;\n\t\t}\n\t\tlet mt2 = b % nc;\n\t\tif( mt2 < 0 ) {\n\t\t\tmt2 += nc;\n\t\t}\n\t\tlet col = clrg[asp];\n\n\t\tfor( let idx = 0; idx < mt1; ++idx ) {\n\t\t\tcol = clrg[12+col];\n\t\t}\n\t\tfor( let idx = 0; idx < mt2; ++idx ) {\n\t\t\tcol = clrg[15+col];\n\t\t}\n\n\t\treturn col;\n\t}\n};\n\nexport \n{\n\tEdgeShape,\n\n\tnumTypes,\n\ttilingTypes,\n\n\tmakePoint,\n\tmakeMatrix,\n\tmul,\n\tmatchSeg,\n\n\tIsohedralTiling\n};\n","import { bbox, transform, vec, type Polygon, type Vec } from \"./geometry\";\nimport { splitSelfIntersections } from \"./offset\";\nimport type { GenerateContext, IsohedralSpec, RawTile } from \"./tilings\";\nimport { EdgeShape, IsohedralTiling, tilingTypes } from \"./vendor/tactile\";\n\n/*\n * Isohedral (\"Escher-style\") tilings: every tile is a congruent copy of one prototile, and\n * every tile is equivalent to every other under the tiling's symmetries. Craig Kaplan's\n * Tactile library (vendored in ./vendor) supplies the 81 isohedral types with free tile\n * shapes: the prototile's corners for given parameters, the copies' transforms, and for\n * each edge the transform from a canonical edge, (0,0)→(1,0), onto the tile outline.\n */\n\ntype Affine = [number, number, number, number, number, number];\nconst mulPt = (M: Affine, p: Vec): Vec => vec(M[0] * p.x + M[1] * p.y + M[2], M[3] * p.x + M[4] * p.y + M[5]);\n\n/**\n * How a tiling edge may be shaped:\n * - \"J\": any curve.\n * - \"S\": looks the same after a 180° turn (like the letter S).\n * - \"U\": looks the same mirrored across its midpoint (like the letter U).\n * - \"I\": straight.\n */\nexport type EdgeKind = \"J\" | \"S\" | \"U\" | \"I\";\nconst KIND: Record<number, EdgeKind> = {\n [EdgeShape.J]: \"J\",\n [EdgeShape.S]: \"S\",\n [EdgeShape.U]: \"U\",\n [EdgeShape.I]: \"I\",\n};\n\n/** The isohedral types available (IH numbers; 81 of the 93 have freely shaped tiles). */\nexport const isohedralTypes: readonly number[] = [...tilingTypes];\n\nexport interface IsohedralInfo {\n /** Number of shape parameters, which move the tile's corners. */\n numParameters: number;\n defaultParameters: number[];\n /** Shape constraint of each edge class, in the order `edges` curves are given. */\n edgeKinds: EdgeKind[];\n /** Number of tile corners (tiling vertices). */\n numVertices: number;\n}\n\nfunction tilingFor(ih: number): InstanceType<typeof IsohedralTiling> {\n if (!tilingTypes.includes(ih)) {\n throw new RangeError(`isohedral.ih must be one of the isohedral types ${tilingTypes[0]}–${tilingTypes[tilingTypes.length - 1]} with free tile shapes (got ${ih})`);\n }\n return new IsohedralTiling(ih);\n}\n\n/** Parameters and edge constraints of an isohedral type, for building UIs. */\nexport function isohedralInfo(ih: number): IsohedralInfo {\n const t = tilingFor(ih);\n return {\n numParameters: t.numParameters(),\n defaultParameters: t.getParameters(),\n edgeKinds: Array.from({ length: t.numEdgeShapes() }, (_, i) => KIND[t.getEdgeShape(i)]!),\n numVertices: t.numVertices(),\n };\n}\n\n/**\n * Built-in edge curves, in canonical edge coordinates. For \"J\" edges the curve spans the\n * whole edge; for \"S\" and \"U\" edges it spans one half, and the other half is made from it\n * by the required symmetry, so any curve is valid.\n */\nfunction presetCurve(kind: EdgeKind, style: \"straight\" | \"wave\", amount: number): Vec[] {\n if (style === \"straight\" || kind === \"I\" || amount === 0) return [];\n const n = 12;\n return Array.from({ length: n - 1 }, (_, k) => {\n const t = (k + 1) / n;\n // J: a bump then a dip; S and U halves: a single bump (the symmetry adds the rest).\n const y = kind === \"J\" ? amount * Math.sin(2 * Math.PI * t) : amount * Math.sin(Math.PI * t);\n return vec(t, y);\n });\n}\n\n/**\n * The prototile outline (in Tactile's coordinates) for a spec. Without an explicit\n * `amount`, the \"wave\" curves start at 0.15 and are lowered until the outline doesn't\n * cross itself (a few types with short edges or sharp corners need less).\n */\nexport function isohedralPrototile(spec: Omit<IsohedralSpec, \"type\" | \"size\">): Polygon {\n if (spec.amount !== undefined || Array.isArray(spec.edges) || spec.edges === \"straight\") return buildPrototile(spec);\n for (let amount = 0.15; ; amount *= 0.8) {\n try {\n return buildPrototile({ ...spec, amount });\n } catch (e) {\n if (amount < 0.01) throw e;\n }\n }\n}\n\nfunction buildPrototile(spec: Omit<IsohedralSpec, \"type\" | \"size\">): Polygon {\n const t = tilingFor(spec.ih);\n if (spec.params) {\n if (spec.params.length !== t.numParameters()) {\n throw new RangeError(`isohedral type ${spec.ih} takes ${t.numParameters()} parameters (got ${spec.params.length})`);\n }\n t.setParameters([...spec.params]);\n }\n const kinds = Array.from({ length: t.numEdgeShapes() }, (_, i) => KIND[t.getEdgeShape(i)]!);\n const amount = spec.amount ?? 0;\n const curves = kinds.map((kind, i) => {\n if (kind === \"I\") return [];\n const given = Array.isArray(spec.edges) ? spec.edges[i] : undefined;\n return given ?? presetCurve(kind, Array.isArray(spec.edges) ? \"straight\" : spec.edges ?? \"wave\", amount);\n });\n\n const outline: Vec[] = [];\n for (const part of t.parts() as Iterable<{ T: Affine; id: number; rev: boolean }>) {\n let seg = [vec(0, 0), ...curves[part.id]!, vec(1, 0)].map((p) => mulPt(part.T, p));\n if (part.rev) seg = seg.reverse();\n // Each part starts where the previous one ended.\n outline.push(...seg.slice(0, -1));\n }\n if (splitSelfIntersections(outline).length > 1) {\n throw new RangeError(\"isohedral: the edge curves make the tile overlap itself; reduce `amount` or change `edges`\");\n }\n return outline;\n}\n\nconst widthOf = (p: Polygon) => Math.max(...p.flatMap((a) => p.map((b) => Math.hypot(a.x - b.x, a.y - b.y))));\n\nexport function generateIsohedral(spec: IsohedralSpec, ctx: GenerateContext): RawTile[] {\n const prototile = isohedralPrototile(spec);\n const t = tilingFor(spec.ih);\n if (spec.params) t.setParameters([...spec.params]);\n const w = widthOf(prototile);\n const k = spec.size / w;\n const theta = (ctx.rotation * Math.PI) / 180;\n const local = transform(\n ctx.region.map((v) => vec((v.x - ctx.origin.x) / k, (v.y - ctx.origin.y) / k)),\n -theta,\n vec(0, 0),\n );\n const box = bbox(local);\n // Tactile places tiles by their lattice cell; pad so tiles reaching in from outside count.\n const pad = 2 * w;\n const tiles: RawTile[] = [];\n const seen = new Set<string>();\n for (const placed of t.fillRegionBounds(box.x - pad, box.y - pad, box.x + box.width + pad, box.y + box.height + pad) as Iterable<{\n T: Affine;\n t1: number;\n t2: number;\n aspect: number;\n }>) {\n const polygon = prototile.map((p) => {\n const q = mulPt(placed.T, p);\n return vec(q.x * k, q.y * k);\n });\n const id = `i${placed.t1},${placed.t2}:${placed.aspect}`;\n // Tactile's fill can yield a lattice row twice when the region spans several passes\n // (its \"rows done\" check treats row 0 as none); a tile's lattice position is unique.\n if (seen.has(id)) continue;\n seen.add(id);\n tiles.push({ id, polygon: transform(polygon, theta, ctx.origin), protoTile: placed.aspect });\n if (tiles.length > ctx.maxTiles * 2) {\n throw new RangeError(`Tiles are too small for this region (more than ${ctx.maxTiles} isohedral tiles). Increase the size or raise maxTiles.`);\n }\n }\n return tiles;\n}\n","import { vec, type Polygon, type Vec } from \"./geometry\";\nimport { apply, IDENTITY, inv, mul, translate, type Affine } from \"./hat\";\nimport { boxesOverlap, coversBox, grow, type Box } from \"./cover\";\n\n/*\n * The \"spectre\" chiral aperiodic monotile (Smith, Myers, Kaplan & Goodman-Strauss, 2023),\n * Tile(1,1), built with the supertile construction from the paper: nine cluster types,\n * where the Γ cluster is the two-spectre \"mystic\", and each level places eight\n * clusters of the level below around a quadrilateral, then mirrors the result.\n */\n\nconst R3 = Math.sqrt(3) / 2;\n\n/** Tile(1,1): fourteen unit edges (two of them collinear), angles in multiples of 30°. */\nexport const SPECTRE: Polygon = [\n vec(0, 0), vec(1, 0), vec(1.5, -R3), vec(1.5 + R3, 0.5 - R3),\n vec(1.5 + R3, 1.5 - R3), vec(2.5 + R3, 1.5 - R3), vec(3 + R3, 1.5), vec(3, 2),\n vec(3 - R3, 1.5), vec(2.5 - R3, 1.5 + R3), vec(1.5 - R3, 1.5 + R3), vec(0.5 - R3, 1.5 + R3),\n vec(-R3, 1.5), vec(0, 1),\n];\n\nexport type SpectreLabel = \"Gamma1\" | \"Gamma2\" | \"Delta\" | \"Theta\" | \"Lambda\" | \"Xi\" | \"Pi\" | \"Sigma\" | \"Phi\" | \"Psi\";\ntype Cluster = \"Gamma\" | \"Delta\" | \"Theta\" | \"Lambda\" | \"Xi\" | \"Pi\" | \"Sigma\" | \"Phi\" | \"Psi\";\nconst CLUSTERS: Cluster[] = [\"Gamma\", \"Delta\", \"Theta\", \"Lambda\", \"Xi\", \"Pi\", \"Sigma\", \"Phi\", \"Psi\"];\n\ntype Node = { kind: \"tile\"; label: SpectreLabel } | { kind: \"meta\"; children: { T: Affine; node: Node }[]; quad: Vec[] };\n\nconst rotDeg = (deg: number): Affine => {\n const a = (deg * Math.PI) / 180;\n return [Math.cos(a), -Math.sin(a), 0, Math.sin(a), Math.cos(a), 0];\n};\nconst MIRROR: Affine = [-1, 0, 0, 0, 1, 0];\n\n/** Which cluster sits in each of the eight slots of a supertile (null: slot left empty). */\nconst SUPER_RULES: Record<Cluster, (Cluster | null)[]> = {\n Gamma: [\"Pi\", \"Delta\", null, \"Theta\", \"Sigma\", \"Xi\", \"Phi\", \"Gamma\"],\n Delta: [\"Xi\", \"Delta\", \"Xi\", \"Phi\", \"Sigma\", \"Pi\", \"Phi\", \"Gamma\"],\n Theta: [\"Psi\", \"Delta\", \"Pi\", \"Phi\", \"Sigma\", \"Pi\", \"Phi\", \"Gamma\"],\n Lambda: [\"Psi\", \"Delta\", \"Xi\", \"Phi\", \"Sigma\", \"Pi\", \"Phi\", \"Gamma\"],\n Xi: [\"Psi\", \"Delta\", \"Pi\", \"Phi\", \"Sigma\", \"Psi\", \"Phi\", \"Gamma\"],\n Pi: [\"Psi\", \"Delta\", \"Xi\", \"Phi\", \"Sigma\", \"Psi\", \"Phi\", \"Gamma\"],\n Sigma: [\"Xi\", \"Delta\", \"Xi\", \"Phi\", \"Sigma\", \"Pi\", \"Lambda\", \"Gamma\"],\n Phi: [\"Psi\", \"Delta\", \"Psi\", \"Phi\", \"Sigma\", \"Pi\", \"Phi\", \"Gamma\"],\n Psi: [\"Psi\", \"Delta\", \"Psi\", \"Phi\", \"Sigma\", \"Psi\", \"Phi\", \"Gamma\"],\n};\n\n/**\n * Placement of slots 1–7, each relative to the slot before: turn by `angle` (cumulative),\n * then translate so the turned quad's corner `to` meets the previous slot's corner `from`.\n */\nconst SLOT_STEPS: [angle: number, from: number, to: number][] = [\n [60, 3, 1], [0, 2, 0], [60, 3, 1], [60, 3, 1], [0, 2, 0], [60, 3, 1], [-120, 3, 3],\n];\n\nfunction baseClusters(): Record<Cluster, Node> {\n const quad = [SPECTRE[3]!, SPECTRE[5]!, SPECTRE[7]!, SPECTRE[11]!];\n const out = {} as Record<Cluster, Node>;\n for (const c of CLUSTERS) {\n out[c] =\n c === \"Gamma\"\n ? {\n kind: \"meta\",\n quad,\n children: [\n { T: IDENTITY, node: { kind: \"tile\", label: \"Gamma1\" } },\n { T: mul(translate(SPECTRE[8]!.x, SPECTRE[8]!.y), rotDeg(30)), node: { kind: \"tile\", label: \"Gamma2\" } },\n ],\n }\n : { kind: \"meta\", quad, children: [{ T: IDENTITY, node: { kind: \"tile\", label: c } }] };\n }\n return out;\n}\n\nfunction supertiles(level: Record<Cluster, Node>): Record<Cluster, Node> {\n const quad = (level.Delta as Extract<Node, { kind: \"meta\" }>).quad;\n const slots: Affine[] = [IDENTITY];\n let total = 0;\n let rotation = IDENTITY;\n let turned = quad;\n for (const [angle, from, to] of SLOT_STEPS) {\n if (angle !== 0) {\n total += angle;\n rotation = rotDeg(total);\n turned = quad.map((q) => apply(rotation, q));\n }\n const target = apply(slots[slots.length - 1]!, quad[from]!);\n const shift = translate(target.x - turned[to]!.x, target.y - turned[to]!.y);\n slots.push(mul(shift, rotation));\n }\n const placed = slots.map((T) => mul(MIRROR, T));\n const superQuad = [apply(placed[6]!, quad[2]!), apply(placed[5]!, quad[1]!), apply(placed[3]!, quad[2]!), apply(placed[0]!, quad[1]!)];\n\n const out = {} as Record<Cluster, Node>;\n for (const c of CLUSTERS) {\n const children: { T: Affine; node: Node }[] = [];\n SUPER_RULES[c].forEach((sub, i) => {\n if (sub) children.push({ T: placed[i]!, node: level[sub] });\n });\n out[c] = { kind: \"meta\", quad: superQuad, children };\n }\n return out;\n}\n\n/**\n * The supertile of type `cluster` at `level`, and the transform from its coordinates to\n * those of the level-0 cluster at the end of the chain that follows `slot` at every level\n * (the slot must hold the same cluster type), so every level extends the one before.\n */\nexport function spectreSupertile(level: number, cluster: Cluster = \"Delta\", slot = 1): { root: Node; toAnchor: Affine } {\n if (SUPER_RULES[cluster][slot] !== cluster) throw new RangeError(`slot ${slot} of ${cluster} is not a ${cluster}`);\n // Children skip empty slots, so map the slot to its child index.\n const child = SUPER_RULES[cluster].slice(0, slot).filter((c) => c !== null).length;\n let clusters = baseClusters();\n let toAnchor: Affine = IDENTITY;\n for (let k = 0; k < level; k++) {\n clusters = supertiles(clusters);\n const top = clusters[cluster] as Extract<Node, { kind: \"meta\" }>;\n toAnchor = mul(toAnchor, inv(top.children[child]!.T));\n }\n return { root: clusters[cluster], toAnchor };\n}\n\nconst LABELS: SpectreLabel[] = [\"Gamma1\", \"Gamma2\", \"Delta\", \"Theta\", \"Lambda\", \"Xi\", \"Pi\", \"Sigma\", \"Phi\", \"Psi\"];\nexport const SPECTRE_LABEL_INDEX = Object.fromEntries(LABELS.map((l, i) => [l, i])) as Record<SpectreLabel, number>;\nexport const SPECTRE_WIDTH = Math.max(...SPECTRE.flatMap((a) => SPECTRE.map((b) => Math.hypot(a.x - b.x, a.y - b.y))));\n/**\n * Patterns grow around the level-0 Δ spectre, following the Δ in slot 1 of each Δ\n * supertile. (Other self-similar chains, such as Γ in slot 7, sit on their parent's edge\n * and only grow in some directions; Δ/1 grows in all of them, about 2.7× per level.)\n */\nconst ANCHOR = vec(SPECTRE.reduce((s, p) => s + p.x, 0) / SPECTRE.length, SPECTRE.reduce((s, p) => s + p.y, 0) / SPECTRE.length);\n\nexport interface SpectreTile {\n polygon: Polygon;\n label: SpectreLabel;\n}\n\ntype Bounds = { x0: number; y0: number; x1: number; y1: number };\nconst nodeBounds = new WeakMap<Node, Bounds>();\n\n/** Bounds of every spectre inside `n`, in n's coordinates (nodes are shared: measured once). */\nfunction boundsOf(n: Node): Bounds {\n if (n.kind === \"tile\") {\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const p of SPECTRE) {\n x0 = Math.min(x0, p.x); y0 = Math.min(y0, p.y);\n x1 = Math.max(x1, p.x); y1 = Math.max(y1, p.y);\n }\n return { x0, y0, x1, y1 };\n }\n const cached = nodeBounds.get(n);\n if (cached) return cached;\n const b = { x0: Infinity, y0: Infinity, x1: -Infinity, y1: -Infinity };\n for (const ch of n.children) {\n const c = placed(ch.node, ch.T);\n b.x0 = Math.min(b.x0, c.x0); b.y0 = Math.min(b.y0, c.y0);\n b.x1 = Math.max(b.x1, c.x1); b.y1 = Math.max(b.y1, c.y1);\n }\n nodeBounds.set(n, b);\n return b;\n}\n\nfunction placed(n: Node, T: Affine): Bounds {\n const b = boundsOf(n);\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const p of [vec(b.x0, b.y0), vec(b.x1, b.y0), vec(b.x1, b.y1), vec(b.x0, b.y1)]) {\n const q = apply(T, p);\n x0 = Math.min(x0, q.x); y0 = Math.min(y0, q.y);\n x1 = Math.max(x1, q.x); y1 = Math.max(y1, q.y);\n }\n return { x0, y0, x1, y1 };\n}\n\n/** Spectres covering `box` (in tile units, relative to the pattern's center). */\nexport function spectresCovering(box: Box, maxTiles: number): SpectreTile[] {\n const near = grow(box, SPECTRE_WIDTH);\n for (let level = 1; level <= 10; level++) {\n const { root, toAnchor } = spectreSupertile(level);\n const toLocal = mul(translate(-ANCHOR.x, -ANCHOR.y), toAnchor);\n const out: SpectreTile[] = [];\n const visit = (n: Node, T: Affine) => {\n if (n.kind === \"tile\") {\n out.push({ polygon: SPECTRE.map((p) => apply(T, p)), label: n.label });\n if (out.length > maxTiles) {\n throw new RangeError(`Tiles are too small for this region (more than ${maxTiles} spectre tiles). Increase the size or raise maxTiles.`);\n }\n return;\n }\n if (!boxesOverlap(placed(n, T), near)) return;\n for (const ch of n.children) visit(ch.node, mul(T, ch.T));\n };\n visit(root, toLocal);\n if (coversBox(out.map((t) => t.polygon), box, SPECTRE_WIDTH)) return out;\n }\n throw new RangeError(\"spectre: region too large for the supported number of levels\");\n}\n","import { area, bbox, centroid, containsPolygon, ensurePositive, isConvex, rectPolygon, sharesEdge, vec, type Polygon, type Rect, type Vec } from \"./geometry\";\nimport { pointInPolygon } from \"./offset\";\nimport { overlay } from \"./overlay\";\nimport { generateTiles, type RawTile, type TilingSpec } from \"./tilings\";\n\n/**\n * Tile size across a region, as a factor of the tiling's own size at each point: 1 is the\n * size the tiling is given, 0.5 half that. See `LayoutOptions.sizeAt`.\n */\nexport type SizeField = (point: Vec) => number;\n\n/** Smallest and largest values of a size field over a box, from a grid of samples. */\nexport function fieldRange(field: SizeField, box: Rect, samples = 33): { min: number; max: number } {\n let min = Infinity, max = 0;\n for (let i = 0; i < samples; i++) {\n for (let j = 0; j < samples; j++) {\n const v = field(vec(box.x + (box.width * i) / (samples - 1), box.y + (box.height * j) / (samples - 1)));\n if (v > 0 && Number.isFinite(v)) {\n min = Math.min(min, v);\n max = Math.max(max, v);\n }\n }\n }\n if (!(max > 0)) throw new RangeError(\"sizeAt must return positive numbers\");\n return { min, max };\n}\n\ninterface RefineContext {\n spec: TilingSpec;\n rotation: number;\n origin: Vec;\n /** Scale the coarsest tiles were generated at (pattern units → layout units). */\n scale: number;\n /** The field divided by its largest value: 1 for the coarsest tiles. */\n want: SizeField;\n /** How many times tiles may be halved. */\n levels: number;\n maxTiles: number;\n scaleRef: number;\n tol: number;\n}\n\n/**\n * Make tiles smaller where the size field asks: tiles wanting to be under about half their\n * size are replaced, as a group, by the same tiling at half the scale, cut to the area\n * they covered; and so on down. Fine tiles cut into slivers at the edge of a finer area\n * are merged into a neighbor. Tilings that halve exactly (a grid from the same origin, say)\n * nest without cuts.\n */\nexport function refineTiles(raw: RawTile[], ctx: RefineContext): RawTile[] {\n const out: RawTile[] = [];\n let current = raw.map((t) => ({ ...t, polygon: ensurePositive(t.polygon) }));\n let total = current.length;\n for (let level = 0; current.length; level++) {\n const s = 2 ** -level;\n const refine: RawTile[] = [];\n for (const t of current) {\n // Halve when the wanted size is nearer half the current size than the current size.\n if (level < ctx.levels && ctx.want(centroid(t.polygon)) < s / Math.SQRT2) refine.push(t);\n else out.push(t);\n }\n if (!refine.length) break;\n total -= refine.length;\n current = subdivide(refine, ctx, level + 1);\n total += current.length;\n if (total > ctx.maxTiles) {\n throw new RangeError(`Tiles are too small for this region (over ${ctx.maxTiles} tiles with sizeAt). Use larger sizes or raise maxTiles.`);\n }\n }\n return out;\n}\n\n/** The tiling at level `level` (scale halved that many times), cut to the union of `parents`. */\nfunction subdivide(parents: RawTile[], ctx: RefineContext, level: number): RawTile[] {\n const scale = ctx.scale * 2 ** -level;\n const box = bbox(parents.flatMap((p) => p.polygon));\n const down = (v: Vec) => vec(v.x / scale, v.y / scale);\n const fine = generateTiles(ctx.spec, {\n region: rectPolygon(box.x, box.y, box.width, box.height).map(down),\n rotation: ctx.rotation,\n origin: down(ctx.origin),\n maxTiles: ctx.maxTiles,\n });\n\n // Parents by bucket, to find the few under each fine tile.\n const pb = parents.map((p) => bbox(p.polygon));\n const cell = Math.max(Math.sqrt((box.width * box.height) / parents.length), 1e-9);\n const cols = Math.max(1, Math.ceil(box.width / cell)), rows = Math.max(1, Math.ceil(box.height / cell));\n const buckets: number[][] = Array.from({ length: cols * rows }, () => []);\n const range = (r: Rect) => [\n Math.max(0, Math.floor((r.x - box.x) / cell)), Math.max(0, Math.floor((r.y - box.y) / cell)),\n Math.min(cols - 1, Math.floor((r.x + r.width - box.x) / cell)), Math.min(rows - 1, Math.floor((r.y + r.height - box.y) / cell)),\n ] as const;\n pb.forEach((r, i) => {\n const [c0, r0, c1, r1] = range(r);\n for (let y = r0; y <= r1; y++) for (let x = c0; x <= c1; x++) buckets[y * cols + x]!.push(i);\n });\n const convex = parents.map((p) => isConvex(p.polygon));\n\n type Piece = RawTile & { nominal: number };\n const pieces: Piece[] = [];\n for (const t of fine) {\n const polygon = ensurePositive(t.polygon.map((v) => vec(v.x * scale, v.y * scale)));\n const fb = bbox(polygon);\n const [c0, r0, c1, r1] = range(fb);\n const cand = new Set<number>();\n for (let y = r0; y <= r1; y++) for (let x = c0; x <= c1; x++) for (const i of buckets[y * cols + x]!) cand.add(i);\n const under = [...cand].filter((i) => {\n const b = pb[i]!;\n return b.x < fb.x + fb.width && fb.x < b.x + b.width && b.y < fb.y + fb.height && fb.y < b.y + b.height;\n });\n if (!under.length) continue;\n const id = `${t.id}@${level}`;\n const nominal = area(polygon);\n const home = under.find((i) => convex[i] && containsPolygon(parents[i]!.polygon, polygon, ctx.tol));\n if (home !== undefined) {\n pieces.push({ id, polygon, protoTile: t.protoTile, nominal });\n continue;\n }\n // Across the edge of the finer area: keep the part inside it.\n const loops = under.map((i) => parents[i]!.polygon);\n const shapes = overlay([polygon, ...loops], (p) => pointInPolygon(p, polygon) && loops.some((l) => pointInPolygon(p, l)), ctx.scaleRef);\n // Even tiny pieces are kept (they're merged into a neighbor below): dropping one would\n // leave a hole.\n shapes.forEach((s, j) => pieces.push({ id: j ? `${id}~${j}` : id, polygon: s.outer, protoTile: t.protoTile, nominal }));\n }\n return mergeSlivers(pieces, ctx.scaleRef, ctx.tol);\n}\n\n/**\n * Merge pieces under 30% of their full tile's area into the neighbor they share the most\n * with (or any neighbor sharing an edge), so cuts don't leave crumbs.\n */\nexport function mergeSlivers(pieces: (RawTile & { nominal: number; group?: number })[], scaleRef: number, tol0: number): RawTile[] {\n const alive = pieces.map(() => true);\n const polys = pieces.map((p) => p.polygon);\n const small = pieces.map((p, i) => i).filter((i) => area(polys[i]!) < 0.3 * pieces[i]!.nominal).sort((a, b) => area(polys[a]!) - area(polys[b]!));\n const boxes = polys.map(bbox);\n const tol = Math.max(tol0 * 10, 1e-9);\n for (const i of small) {\n if (!alive[i]) continue;\n const bi = boxes[i]!;\n // The biggest neighbor sharing an edge, from the same group (a flow row) if there is one.\n let best = -1, bestArea = -1;\n for (let j = 0; j < pieces.length; j++) {\n if (j === i || !alive[j]) continue;\n const bj = boxes[j]!;\n if (bj.x > bi.x + bi.width + tol || bi.x > bj.x + bj.width + tol || bj.y > bi.y + bi.height + tol || bi.y > bj.y + bj.height + tol) continue;\n if (!sharesEdge(polys[i]!, polys[j]!, tol)) continue;\n const a = area(polys[j]!) + (pieces[j]!.group !== undefined && pieces[j]!.group === pieces[i]!.group ? 1e12 : 0);\n if (a > bestArea) { bestArea = a; best = j; }\n }\n if (best < 0) continue;\n const a = polys[i]!, b = polys[best]!;\n const union = overlay([a, b], (p) => pointInPolygon(p, a) || pointInPolygon(p, b), scaleRef);\n if (union.length !== 1 || union[0]!.holes.length) continue;\n polys[best] = union[0]!.outer;\n boxes[best] = bbox(polys[best]!);\n alive[i] = false;\n }\n const out: RawTile[] = [];\n pieces.forEach((p, i) => {\n if (alive[i]) out.push({ id: p.id, polygon: polys[i]!, protoTile: p.protoTile });\n });\n return out;\n}\n\n/* ---------- Size fields ---------- */\n\n/**\n * Smaller tiles round a point, growing with distance: `inner` (the size factor at the\n * point) to `outer` at `radius` and beyond, with a smooth ease between.\n */\nexport function radialSize(options: { center: Vec; radius: number; inner?: number; outer?: number }): SizeField {\n const { center, radius } = options;\n const inner = options.inner ?? 0.25, outer = options.outer ?? 1;\n return (p) => {\n const t = Math.min(1, Math.hypot(p.x - center.x, p.y - center.y) / (radius || 1));\n return inner + (outer - inner) * (t * t * (3 - 2 * t));\n };\n}\n\n/**\n * Smaller tiles along a region's edges (and its holes' edges): `edge` (the size factor at the\n * edge) to `middle` at `distance` in and beyond. Pass the layout's region and holes.\n */\nexport function edgeSize(region: Polygon, options: { distance: number; edge?: number; middle?: number; holes?: Polygon[] }): SizeField {\n const edge = options.edge ?? 0.25, middle = options.middle ?? 1;\n const loops = [region, ...(options.holes ?? [])];\n return (p) => {\n let d = Infinity;\n for (const l of loops) {\n for (let i = 0; i < l.length; i++) {\n const a = l[i]!, b = l[(i + 1) % l.length]!;\n const dx = b.x - a.x, dy = b.y - a.y;\n const t = Math.max(0, Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / (dx * dx + dy * dy || 1)));\n d = Math.min(d, Math.hypot(p.x - a.x - t * dx, p.y - a.y - t * dy));\n }\n }\n const t = Math.min(1, d / (options.distance || 1));\n return edge + (middle - edge) * (t * t * (3 - 2 * t));\n };\n}\n\n/**\n * Tile size from a picture's brightness: dark areas get `dark` (default 0.25), light ones\n * `light` (default 1), so detail gathers where the picture has it. `pixels` is RGBA data, as\n * from `loadImagePixels`; the picture covers `box` (normally the layout's bounds), cropped\n * like `object-fit: cover`. Use `invert` for small tiles in the light.\n */\nexport function imageSize(\n pixels: { width: number; height: number; data: ArrayLike<number> },\n box: Rect,\n options: { dark?: number; light?: number; invert?: boolean } = {},\n): SizeField {\n const dark = options.dark ?? 0.25, light = options.light ?? 1;\n const { width: w, height: h, data } = pixels;\n const s = Math.max(box.width / w, box.height / h);\n const ox = box.x + (box.width - w * s) / 2, oy = box.y + (box.height - h * s) / 2;\n return (p) => {\n const x = Math.min(w - 1, Math.max(0, Math.floor((p.x - ox) / s)));\n const y = Math.min(h - 1, Math.max(0, Math.floor((p.y - oy) / s)));\n const k = (y * w + x) * 4;\n let lum = (0.2126 * data[k]! + 0.7152 * data[k + 1]! + 0.0722 * data[k + 2]!) / 255;\n if (options.invert) lum = 1 - lum;\n return dark + (light - dark) * lum;\n };\n}\n","import { area, bbox, centroid, clipHalfPlane, rectPolygon, vec, type Polygon, type Rect, type Vec } from \"./geometry\";\nimport { mergeSlivers } from \"./density\";\nimport { pointInPolygon } from \"./offset\";\nimport { partition } from \"./overlay\";\nimport { voronoiCells } from \"./procedural\";\nimport { mulberry32 } from \"./random\";\nimport type { GenerateContext, RawTile } from \"./tilings\";\n\n/**\n * Andamento: tesserae laid in rows (courses) that follow guide curves, circle center points\n * or run along the region's outline, the way mosaicists lay them.\n */\nexport interface FlowSpec {\n type: \"flow\";\n /** Row height: the width of each tessera across its row. */\n size: number;\n /** Tessera length along its row, as a multiple of `size`. Defaults to 1.3. */\n length?: number;\n /** How much tessera lengths vary, 0 (all alike) to 0.9. Defaults to 0.3. */\n jitter?: number;\n /**\n * Curves for rows to follow, in layout units: a row runs along each, and further rows\n * parallel to it on both sides. Open polylines, or `closed` loops.\n */\n guides?: { points: Vec[]; closed?: boolean }[];\n /** Points for rows to circle, in layout units: a round tessera, ringed by row after row. */\n centers?: Vec[];\n /**\n * Rows also run along the region's outline (and round its holes), as in opus\n * vermiculatum. Defaults to true when there are no guides or centers.\n */\n followEdges?: boolean;\n /** Seed for the deterministic random generator. Defaults to 1. */\n seed?: number;\n}\n\n/** Where rows meet (the rows from two guides, say), they end against each other, as in real mosaics. */\nexport function generateFlow(spec: FlowSpec, ctx: GenerateContext): RawTile[] {\n const h = positive(\"flow.size\", spec.size);\n const L = h * positive(\"flow.length\", spec.length ?? 1.3);\n const jitter = Math.min(0.9, Math.max(0, spec.jitter ?? 0.3));\n const rng = mulberry32(spec.seed ?? 1);\n const unit = ctx.unit ?? 1;\n const toGen = (v: Vec) => vec(v.x / unit, v.y / unit);\n const guides = (spec.guides ?? []).filter((g) => g.points.length >= 2).map((g) => ({ points: g.points.map(toGen), closed: !!g.closed }));\n const centers = (spec.centers ?? []).map(toGen);\n const followEdges = spec.followEdges ?? (guides.length === 0 && centers.length === 0);\n const outline = ctx.outline ?? [ctx.region];\n\n const rb = bbox(ctx.region);\n const box: Rect = { x: rb.x - h, y: rb.y - h, width: rb.width + 2 * h, height: rb.height + 2 * h };\n const estimate = (box.width * box.height) / (h * L);\n if (estimate > ctx.maxTiles) {\n throw new RangeError(`Tiles are too small for this region (~${Math.round(estimate)} flow tesserae, limit ${ctx.maxTiles}). Increase the size or raise maxTiles.`);\n }\n const scale = Math.max(box.width, box.height);\n\n // The row field: how far a point is from where rows start. Rows on a guide or round a\n // center are centerd on it (hence + h/2); rows along the outline start at it.\n const lines: [Vec, Vec][] = [];\n const shifted: [Vec, Vec][] = [];\n for (const g of guides) {\n const n = g.points.length;\n for (let i = 0; i < (g.closed ? n : n - 1); i++) shifted.push([g.points[i]!, g.points[(i + 1) % n]!]);\n }\n if (followEdges) for (const loop of outline) loop.forEach((a, i) => lines.push([a, loop[(i + 1) % loop.length]!]));\n const distEdge = segmentDistance(lines, [], box);\n const distGuide = segmentDistance(shifted, centers, box);\n // Outside the area, the outline's rows don't continue: they start at the outline.\n const inArea = (p: Vec) => {\n let inside = false;\n for (const loop of outline) if (pointInPolygon(p, loop)) inside = !inside;\n return inside;\n };\n const raw = (p: Vec) => Math.min(followEdges && !inArea(p) ? 0 : distEdge(p), distGuide(p) + h / 2);\n\n // Sampled on a triangulated grid and interpolated linearly in each triangle, so its level\n // lines (the row boundaries) are exactly the polylines marching triangles gives.\n const g = h / 3;\n const cols = Math.ceil(box.width / g), rows = Math.ceil(box.height / g);\n const F = new Float64Array((cols + 1) * (rows + 1));\n for (let j = 0; j <= rows; j++) for (let i = 0; i <= cols; i++) F[j * (cols + 1) + i] = raw(vec(box.x + i * g, box.y + j * g));\n const at = (i: number, j: number) => F[j * (cols + 1) + i]!;\n const phi = (p: Vec) => {\n const fx = Math.min(cols - 1e-9, Math.max(0, (p.x - box.x) / g)), fy = Math.min(rows - 1e-9, Math.max(0, (p.y - box.y) / g));\n const i = Math.floor(fx), j = Math.floor(fy), u = fx - i, v = fy - j;\n const f00 = at(i, j), f10 = at(i + 1, j), f01 = at(i, j + 1), f11 = at(i + 1, j + 1);\n return u >= v ? f00 + u * (f10 - f00) + v * (f11 - f10) : f00 + v * (f01 - f00) + u * (f11 - f01);\n };\n // Row boundaries sit a little off whole multiples of h: outlines and guides on grid lines\n // would otherwise put level lines a hair from grid points, giving pieces too short to join.\n const eps = h * 0.0137;\n const band = (p: Vec) => Math.max(0, Math.floor((phi(p) - eps) / h));\n const top = Math.floor((Math.max(...F) - eps) / h);\n\n // Row boundaries (level lines between rows), and each row's center line.\n const boundaries: [Vec, Vec][] = [];\n for (let k = 1; k <= top; k++) boundaries.push(...contourSegments(F, cols, rows, box, g, k * h + eps));\n\n // Tesserae along each row: seeds spaced about L apart (varied by `jitter`) on its center line.\n const seeds: { p: Vec; row: number; normal?: Vec }[] = [];\n const step = () => L * (1 + jitter * (2 * rng() - 1));\n const lay = (line: Vec[], closed: boolean, row: number, along = false) => {\n // Level lines hugging a guide (where the field bottoms out) would seed it twice.\n const onGuide = (p: Vec) => !along && distGuide(p) < 0.25 * h;\n const pts = closed ? [...line, line[0]!] : line;\n const lens = [0];\n for (let i = 1; i < pts.length; i++) lens.push(lens[i - 1]! + Math.hypot(pts[i]!.x - pts[i - 1]!.x, pts[i]!.y - pts[i - 1]!.y));\n const total = lens[lens.length - 1]!;\n if (total <= 0) return;\n // Closed rows get a whole number of tesserae, so the ring closes evenly.\n const marks: number[] = [];\n if (closed) {\n const n = Math.max(1, Math.round(total / L));\n const start = rng() * (total / n);\n for (let k = 0; k < n; k++) marks.push(start + ((k + 0.5 * jitter * (2 * rng() - 1) * 0.5) * total) / n);\n } else for (let s = rng() * L * 0.5; s < total; s += step()) marks.push(s);\n let seg = 1;\n for (const m of marks) {\n while (seg < pts.length - 1 && lens[seg]! < m) seg++;\n const a = pts[seg - 1]!, b = pts[seg]!;\n const t = (m - lens[seg - 1]!) / (lens[seg]! - lens[seg - 1]! || 1);\n const p = vec(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t);\n if (p.x < box.x || p.y < box.y || p.x > box.x + box.width || p.y > box.y + box.height || band(p) !== row || onGuide(p)) continue;\n const dl = Math.hypot(b.x - a.x, b.y - a.y) || 1;\n seeds.push({ p, row, normal: along ? vec(-(b.y - a.y) / dl, (b.x - a.x) / dl) : undefined });\n }\n };\n for (const gd of guides) lay(gd.points, gd.closed, 0, true);\n for (const c of centers) if (band(c) === 0) seeds.push({ p: c, row: 0 });\n for (let k = 0; k <= top; k++) {\n for (const line of contourLines(F, cols, rows, box, g, (k + 0.5) * h)) lay(line.points, line.closed, k);\n }\n if (!seeds.length) return [];\n\n // Each row's cells: Voronoi among that row's seeds, cut to a slab across the row so the\n // cell edges that matter (the cuts between tesserae) are short.\n const byRow = new Map<number, number[]>();\n seeds.forEach((s, i) => {\n const list = byRow.get(s.row);\n if (list) list.push(i);\n else byRow.set(s.row, [i]);\n });\n const cells: { poly: Polygon; row: number; seed: number }[] = [];\n const boxPoly = rectPolygon(box.x, box.y, box.width, box.height);\n for (const [row, ids] of byRow) {\n const polys = ids.length === 1 ? [boxPoly] : voronoiCells(ids.map((i) => seeds[i]!.p), box);\n polys.forEach((poly, k) => {\n const s = seeds[ids[k]!]!;\n let n = s.normal;\n if (!n) {\n const dx = phi(vec(s.p.x + g, s.p.y)) - phi(vec(s.p.x - g, s.p.y));\n const dy = phi(vec(s.p.x, s.p.y + g)) - phi(vec(s.p.x, s.p.y - g));\n const len = Math.hypot(dx, dy);\n n = len > 1e-9 ? vec(dx / len, dy / len) : undefined;\n }\n let clipped = poly;\n if (n) {\n clipped = clipHalfPlane(clipped, s.p, n, -1.5 * h);\n clipped = clipHalfPlane(clipped, s.p, vec(-n.x, -n.y), -1.5 * h);\n }\n if (clipped.length >= 3) cells.push({ poly: clipped, row, seed: ids[k]! });\n });\n }\n\n // Cells by bucket, to find the one under a point.\n const bs = Math.max(L, h) * 2;\n const bc = Math.max(1, Math.ceil(box.width / bs)), br = Math.max(1, Math.ceil(box.height / bs));\n const buckets: number[][] = Array.from({ length: bc * br }, () => []);\n const clampC = (x: number) => Math.min(bc - 1, Math.max(0, Math.floor((x - box.x) / bs)));\n const clampR = (y: number) => Math.min(br - 1, Math.max(0, Math.floor((y - box.y) / bs)));\n cells.forEach((c, i) => {\n const b = bbox(c.poly);\n for (let r = clampR(b.y); r <= clampR(b.y + b.height); r++) for (let q = clampC(b.x); q <= clampC(b.x + b.width); q++) buckets[r * bc + q]!.push(i);\n });\n\n // A tessera is a cell's part within its own row; leftovers in a row that no cell of\n // that row reaches (where rows end) get their own label.\n const M = 1 << 20;\n const label = (p: Vec) => {\n if (p.x <= box.x || p.y <= box.y || p.x >= box.x + box.width || p.y >= box.y + box.height) return -1;\n const k = band(p);\n for (const i of buckets[clampR(p.y) * bc + clampC(p.x)]!) {\n const c = cells[i]!;\n if (c.row === k && pointInPolygon(p, c.poly)) return k * M + i + 1;\n }\n return k * M;\n };\n const candidates: Polygon[] = [boxPoly, ...boundaries.map(([a, b]) => [a, b]), ...cells.map((c) => c.poly)];\n const regions = partition(candidates, label, scale);\n\n const pieces: (RawTile & { nominal: number; group: number })[] = [];\n const nominal = h * L;\n for (const [l, shapes] of regions) {\n const row = Math.floor(l / M), cell = (l % M) - 1;\n shapes.forEach((s, j) => {\n const base = cell >= 0 ? `f${row}.${cells[cell]!.seed}` : `f${row}.o${Math.round(centroid(s.outer).x)},${Math.round(centroid(s.outer).y)}`;\n pieces.push({ id: j ? `${base}~${j}` : base, polygon: s.outer, protoTile: row % 2, nominal, group: row });\n });\n }\n // Leftover crumbs where rows meet join a neighbor.\n return mergeSlivers(pieces, scale, scale * 1e-7).filter((t) => area(t.polygon) > 0);\n}\n\nfunction positive(name: string, value: number | undefined): number {\n if (value === undefined || !Number.isFinite(value) || value <= 0) throw new RangeError(`${name} must be a positive number (got ${value})`);\n return value;\n}\n\n/**\n * Distance to the nearest of some segments and points, through a bucket grid searched ring\n * by ring. Infinity when there are none.\n */\nfunction segmentDistance(segs: [Vec, Vec][], points: Vec[], box: Rect): (p: Vec) => number {\n const items: [Vec, Vec][] = [...segs, ...points.map((p) => [p, p] as [Vec, Vec])];\n if (!items.length) return () => Infinity;\n const size = Math.max(Math.sqrt((box.width * box.height) / Math.max(16, items.length)), 1e-9);\n const cols = Math.max(1, Math.ceil(box.width / size)), rows = Math.max(1, Math.ceil(box.height / size));\n const buckets: number[][] = Array.from({ length: cols * rows }, () => []);\n const cx = (x: number) => Math.min(cols - 1, Math.max(0, Math.floor((x - box.x) / size)));\n const cy = (y: number) => Math.min(rows - 1, Math.max(0, Math.floor((y - box.y) / size)));\n items.forEach(([a, b], i) => {\n for (let r = cy(Math.min(a.y, b.y)); r <= cy(Math.max(a.y, b.y)); r++) for (let q = cx(Math.min(a.x, b.x)); q <= cx(Math.max(a.x, b.x)); q++) buckets[r * cols + q]!.push(i);\n });\n const d = (p: Vec, [a, b]: [Vec, Vec]) => {\n const dx = b.x - a.x, dy = b.y - a.y;\n const t = Math.max(0, Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / (dx * dx + dy * dy || 1)));\n return Math.hypot(p.x - a.x - t * dx, p.y - a.y - t * dy);\n };\n return (p) => {\n const c0 = cx(p.x), r0 = cy(p.y);\n // The point may be outside the box (items beyond it are clamped into edge buckets), so\n // the ring bound is measured from the clamped bucket.\n const out = Math.max(box.x - p.x, p.x - box.x - box.width, box.y - p.y, p.y - box.y - box.height, 0);\n let best = Infinity;\n const seen = new Set<number>();\n for (let ring = 0; ring <= Math.max(cols, rows); ring++) {\n for (let r = r0 - ring; r <= r0 + ring; r++) {\n if (r < 0 || r >= rows) continue;\n for (let q = c0 - ring; q <= c0 + ring; q++) {\n if (q < 0 || q >= cols || Math.max(Math.abs(r - r0), Math.abs(q - c0)) !== ring) continue;\n for (const i of buckets[r * cols + q]!) {\n if (seen.has(i)) continue;\n seen.add(i);\n best = Math.min(best, d(p, items[i]!));\n }\n }\n }\n if (ring * size - out >= best) break;\n }\n return best;\n };\n}\n\n/** Level-line segments of the grid field at `level`, by marching triangles. */\nfunction contourSegments(F: Float64Array, cols: number, rows: number, box: Rect, g: number, level: number): [Vec, Vec][] {\n const out: [Vec, Vec][] = [];\n forEachCrossing(F, cols, rows, box, g, level, (a, b) => out.push([a.p, b.p]));\n return out;\n}\n\n/** Level lines of the grid field at `level`, chained into polylines (open or closed). */\nfunction contourLines(F: Float64Array, cols: number, rows: number, box: Rect, g: number, level: number): { points: Vec[]; closed: boolean }[] {\n // Segments meet at grid-edge crossings; chain them through those.\n const next = new Map<string, { key: string; p: Vec }[]>();\n const pos = new Map<string, Vec>();\n forEachCrossing(F, cols, rows, box, g, level, (a, b) => {\n pos.set(a.key, a.p);\n pos.set(b.key, b.p);\n (next.get(a.key) ?? next.set(a.key, []).get(a.key)!).push(b);\n (next.get(b.key) ?? next.set(b.key, []).get(b.key)!).push(a);\n });\n const used = new Set<string>();\n const edge = (a: string, b: string) => (a < b ? `${a}|${b}` : `${b}|${a}`);\n const lines: { points: Vec[]; closed: boolean }[] = [];\n const walk = (start: string) => {\n const keys = [start];\n for (;;) {\n const cur = keys[keys.length - 1]!;\n const n = (next.get(cur) ?? []).find((x) => !used.has(edge(cur, x.key)));\n if (!n) break;\n used.add(edge(cur, n.key));\n if (n.key === start) return { keys, closed: true };\n keys.push(n.key);\n }\n return { keys, closed: false };\n };\n // Open lines start at their ends (a crossing with one neighbor); then the loops.\n for (const [k, ns] of next) {\n if (ns.length !== 1 || ns.every((x) => used.has(edge(k, x.key)))) continue;\n const { keys } = walk(k);\n if (keys.length > 1) lines.push({ points: keys.map((x) => pos.get(x)!), closed: false });\n }\n for (const [k, ns] of next) {\n if (ns.every((x) => used.has(edge(k, x.key)))) continue;\n const { keys, closed } = walk(k);\n if (keys.length > 1) lines.push({ points: keys.map((x) => pos.get(x)!), closed });\n }\n return lines;\n}\n\n/** Calls `emit` for each triangle's level-line segment, with endpoints keyed by grid edge. */\nfunction forEachCrossing(\n F: Float64Array,\n cols: number,\n rows: number,\n box: Rect,\n g: number,\n level: number,\n emit: (a: { key: string; p: Vec }, b: { key: string; p: Vec }) => void,\n) {\n const id = (i: number, j: number) => j * (cols + 1) + i;\n const cross = (u: number, v: number) => {\n const fu = F[u]! - level, fv = F[v]! - level;\n const t = fu / (fu - fv);\n const ui = u % (cols + 1), uj = Math.floor(u / (cols + 1));\n const vi = v % (cols + 1), vj = Math.floor(v / (cols + 1));\n const x = box.x + (ui + (vi - ui) * t) * g, y = box.y + (uj + (vj - uj) * t) * g;\n return { key: u < v ? `${u},${v}` : `${v},${u}`, p: vec(x, y) };\n };\n const tri = (a: number, b: number, c: number) => {\n const sa = F[a]! > level, sb = F[b]! > level, sc = F[c]! > level;\n if (sa === sb && sb === sc) return;\n // The lone vertex on one side, and the two edges from it.\n if (sa !== sb && sa !== sc) emit(cross(a, b), cross(a, c));\n else if (sb !== sa && sb !== sc) emit(cross(b, a), cross(b, c));\n else emit(cross(c, a), cross(c, b));\n };\n for (let j = 0; j < rows; j++) {\n for (let i = 0; i < cols; i++) {\n // Split along the diagonal from (i, j) to (i + 1, j + 1), as `phi` does.\n tri(id(i, j), id(i + 1, j), id(i + 1, j + 1));\n tri(id(i, j), id(i, j + 1), id(i + 1, j + 1));\n }\n }\n}\n","import { area, bbox, rectPolygon, transform, vec, type Polygon, type Rect, type Vec } from \"./geometry\";\nimport { pointInPolygon, splitSelfIntersections } from \"./offset\";\nimport { mulberry32 } from \"./random\";\nimport { generateAshlar, generateDelaunay, generateJigsaw, generateVoronoi } from \"./procedural\";\nimport { generateSubstitution, penroseKitesAndDarts, penroseRhombs } from \"./substitution\";\nimport { HAT_WIDTH, hatsCovering, LABEL_INDEX } from \"./hat\";\nimport { generateIsohedral } from \"./isohedral\";\nimport { SPECTRE_LABEL_INDEX, SPECTRE_WIDTH, spectresCovering } from \"./spectre\";\nimport { generateFlow, type FlowSpec } from \"./flow\";\nexport type { FlowSpec } from \"./flow\";\n\n/*\n * Tiling specs are plain, JSON-serializable objects so a layout can be saved,\n * shared and used as a memo key. The helper functions below just add `type`.\n */\n\nexport interface GridSpec {\n type: \"grid\";\n /** Cell width. */\n width: number;\n /** Cell height. Defaults to `width` (squares). */\n height?: number;\n}\n\nexport interface RunningBondSpec {\n type: \"runningBond\";\n width: number;\n height: number;\n /** Fraction of a brick each row is shifted by. Defaults to 0.5. */\n offset?: number;\n}\n\nexport interface HerringboneSpec {\n type: \"herringbone\";\n /** Long side of each rectangle. Must be greater than `width`. */\n length: number;\n /** Short side of each rectangle. */\n width: number;\n}\n\nexport interface BasketweaveSpec {\n type: \"basketweave\";\n /** Side of each square block (= length of each strip). */\n length: number;\n /** Strips per block. Defaults to 2. */\n strips?: number;\n}\n\nexport interface HexagonalSpec {\n type: \"hexagonal\";\n /** Circumradius: center-to-corner distance. */\n size: number;\n /** \"pointy\" puts a corner at the top; \"flat\" puts an edge at the top. Defaults to \"pointy\". */\n orientation?: \"pointy\" | \"flat\";\n}\n\nexport interface TriangularSpec {\n type: \"triangular\";\n /** Side length of each equilateral triangle. */\n size: number;\n}\n\nexport interface RhombilleSpec {\n type: \"rhombille\";\n /** Side length of each rhombus. Three rhombi form a hexagon (\"tumbling blocks\"). */\n size: number;\n}\n\nexport interface OctagonSquareSpec {\n type: \"octagonSquare\";\n /** Edge length shared by the octagons and the small squares. */\n size: number;\n}\n\nexport interface TrihexagonalSpec {\n type: \"trihexagonal\";\n /** Edge length shared by the hexagons and triangles. */\n size: number;\n}\n\nexport interface RhombitrihexagonalSpec {\n type: \"rhombitrihexagonal\";\n /** Edge length shared by the hexagons, squares and triangles. */\n size: number;\n}\n\nexport interface CairoSpec {\n type: \"cairo\";\n /** Spacing of the underlying square grid; each pentagon is roughly this wide. */\n size: number;\n}\n\nexport interface HopscotchSpec {\n type: \"hopscotch\";\n /** Side of the large squares. */\n large: number;\n /** Side of the small squares. Must not exceed `large`. */\n small: number;\n}\n\nexport interface PinwheelSpec {\n type: \"pinwheel\";\n /** Long side of each rectangle. Must be greater than `width`. */\n length: number;\n /** Short side of each rectangle. The center squares have side `length - width`. */\n width: number;\n}\n\nexport interface FlemishBondSpec {\n type: \"flemishBond\";\n /** Length of the long bricks (stretchers). */\n length: number;\n /** Course height. */\n height: number;\n /** Length of the short bricks (headers). Defaults to `length / 2`. */\n header?: number;\n}\n\nexport interface ChevronSpec {\n type: \"chevron\";\n /** Long side of each plank. */\n length: number;\n /** Plank width, measured across the plank. */\n width: number;\n /** Plank slope in degrees from horizontal, between 0 and 90 (exclusive). Defaults to 45. */\n angle?: number;\n}\n\nexport interface FishScaleSpec {\n type: \"fishScale\";\n /** Width of each scale. Scales overlap like roof shingles: rounded below, pointed on top. */\n size: number;\n}\n\nexport interface VoronoiSpec {\n type: \"voronoi\";\n /** Typical cell width: about one cell per size × size area. */\n size: number;\n /** Rounds of Lloyd relaxation; more rounds give more even, rounder cells. Defaults to 2. */\n relax?: number;\n /** Seed for the deterministic random generator. Defaults to 1. */\n seed?: number;\n}\n\nexport interface DelaunaySpec {\n type: \"delaunay\";\n /** Typical spacing of the triangle corners. */\n size: number;\n /** Rounds of Lloyd relaxation on the corners; more rounds give more even triangles. Defaults to 2. */\n relax?: number;\n /** Seed for the deterministic random generator. Defaults to 1. */\n seed?: number;\n}\n\nexport interface AshlarSpec {\n type: \"ashlar\";\n /** Typical course (row) height. */\n height: number;\n /** Shortest stone. */\n minLength: number;\n /** Longest stone. */\n maxLength: number;\n /** How much course heights vary, 0–0.9, as a fraction of `height`. Defaults to 0. */\n heightVariation?: number;\n /** Seed for the deterministic random generator. Defaults to 1. */\n seed?: number;\n}\n\nexport interface PenroseSpec {\n type: \"penrose\";\n /** Edge length of the rhombs, or the long edge of the kites and darts. */\n size: number;\n /**\n * \"rhombs\" (P3: thick and thin rhombs, all convex) or \"kitesAndDarts\" (P2: convex kites\n * and non-convex darts). Defaults to \"rhombs\".\n */\n variant?: \"rhombs\" | \"kitesAndDarts\";\n}\n\nexport interface HatSpec {\n type: \"hat\";\n /** Approximate width of each hat (its widest extent). */\n size: number;\n}\n\nexport interface SpectreSpec {\n type: \"spectre\";\n /** Approximate width of each spectre (its widest extent). */\n size: number;\n}\n\nexport interface IsohedralSpec {\n type: \"isohedral\";\n /** Isohedral type number (see `isohedralTypes`; 81 of the 93 types). */\n ih: number;\n /** Approximate tile width (its widest extent). */\n size: number;\n /** Shape parameters moving the tile's corners; see `isohedralInfo(ih)`. Defaults per type. */\n params?: number[];\n /**\n * Edge curves: \"wave\" (default) or \"straight\", or one curve per edge class (see\n * `isohedralInfo(ih).edgeKinds`) as points strictly between (0,0) and (1,0). Curves for\n * \"S\" and \"U\" edges describe the first half of the edge; \"I\" edges are always straight.\n */\n edges?: \"wave\" | \"straight\" | Vec[][];\n /**\n * Height of the \"wave\" curves, as a fraction of each edge. Defaults to 0.15, lowered for\n * the few types where that would make the tile overlap itself.\n */\n amount?: number;\n}\n\nexport interface JigsawSpec {\n type: \"jigsaw\";\n /** Target piece size; columns and rows are chosen so pieces fit the region exactly. */\n size: number;\n /** Seed for tab directions and positions. Defaults to 1. */\n seed?: number;\n}\n\n/**\n * A custom repeating tiling: the motif's polygons are copied to every point i·a + j·b.\n * Coordinates are in region units. Nothing checks that the copies fit together; use\n * `checkPeriodic` while designing one. Polygons may be non-convex but must be simple.\n */\nexport interface PeriodicSpec {\n type: \"periodic\";\n a: Vec;\n b: Vec;\n /** Tiles of one lattice cell. `protoTile` defaults to the tile's position in this list. */\n motif: { polygon: Polygon; protoTile?: number }[];\n}\n\n/**\n * Explicit tiles, used as given (in region units): nothing is generated, and `rotation`\n * and `origin` are ignored. The usual gap, margin, edge, rounding and neighbor handling\n * applies. Ids default to \"t0\", \"t1\", …; given ids must be unique.\n */\nexport interface TilesSpec {\n type: \"tiles\";\n tiles: { polygon: Polygon; id?: string; protoTile?: number }[];\n}\n\nexport interface MondrianSpec {\n type: \"mondrian\";\n /** No side is cut shorter than this. */\n minSize: number;\n /** Cells larger than this along either side are always split further (when possible). */\n maxSize: number;\n /** Chance (0–1) of splitting a cell that already fits within `maxSize`. Defaults to 0.4. */\n splitChance?: number;\n /** Seed for the deterministic random generator. Defaults to 1. */\n seed?: number;\n /** Snap split positions to multiples of this value (relative to each cell). */\n snap?: number;\n}\n\nexport type TilingSpec =\n | FlowSpec\n | GridSpec\n | RunningBondSpec\n | HerringboneSpec\n | BasketweaveSpec\n | HexagonalSpec\n | TriangularSpec\n | RhombilleSpec\n | OctagonSquareSpec\n | TrihexagonalSpec\n | RhombitrihexagonalSpec\n | CairoSpec\n | HopscotchSpec\n | PinwheelSpec\n | FlemishBondSpec\n | ChevronSpec\n | FishScaleSpec\n | VoronoiSpec\n | DelaunaySpec\n | AshlarSpec\n | PenroseSpec\n | HatSpec\n | SpectreSpec\n | IsohedralSpec\n | JigsawSpec\n | PeriodicSpec\n | TilesSpec\n | MondrianSpec;\n\nexport type TilingType = TilingSpec[\"type\"];\n\nexport const grid = (p: Omit<GridSpec, \"type\">): GridSpec => ({ type: \"grid\", ...p });\nexport const runningBond = (p: Omit<RunningBondSpec, \"type\">): RunningBondSpec => ({ type: \"runningBond\", ...p });\nexport const herringbone = (p: Omit<HerringboneSpec, \"type\">): HerringboneSpec => ({ type: \"herringbone\", ...p });\nexport const basketweave = (p: Omit<BasketweaveSpec, \"type\">): BasketweaveSpec => ({ type: \"basketweave\", ...p });\nexport const hexagonal = (p: Omit<HexagonalSpec, \"type\">): HexagonalSpec => ({ type: \"hexagonal\", ...p });\nexport const triangular = (p: Omit<TriangularSpec, \"type\">): TriangularSpec => ({ type: \"triangular\", ...p });\nexport const rhombille = (p: Omit<RhombilleSpec, \"type\">): RhombilleSpec => ({ type: \"rhombille\", ...p });\nexport const octagonSquare = (p: Omit<OctagonSquareSpec, \"type\">): OctagonSquareSpec => ({ type: \"octagonSquare\", ...p });\nexport const trihexagonal = (p: Omit<TrihexagonalSpec, \"type\">): TrihexagonalSpec => ({ type: \"trihexagonal\", ...p });\nexport const rhombitrihexagonal = (p: Omit<RhombitrihexagonalSpec, \"type\">): RhombitrihexagonalSpec => ({\n type: \"rhombitrihexagonal\",\n ...p,\n});\nexport const cairo = (p: Omit<CairoSpec, \"type\">): CairoSpec => ({ type: \"cairo\", ...p });\nexport const hopscotch = (p: Omit<HopscotchSpec, \"type\">): HopscotchSpec => ({ type: \"hopscotch\", ...p });\nexport const pinwheel = (p: Omit<PinwheelSpec, \"type\">): PinwheelSpec => ({ type: \"pinwheel\", ...p });\nexport const flemishBond = (p: Omit<FlemishBondSpec, \"type\">): FlemishBondSpec => ({ type: \"flemishBond\", ...p });\nexport const chevron = (p: Omit<ChevronSpec, \"type\">): ChevronSpec => ({ type: \"chevron\", ...p });\nexport const fishScale = (p: Omit<FishScaleSpec, \"type\">): FishScaleSpec => ({ type: \"fishScale\", ...p });\nexport const hat = (p: Omit<HatSpec, \"type\">): HatSpec => ({ type: \"hat\", ...p });\nexport const spectre = (p: Omit<SpectreSpec, \"type\">): SpectreSpec => ({ type: \"spectre\", ...p });\nexport const isohedral = (p: Omit<IsohedralSpec, \"type\">): IsohedralSpec => ({ type: \"isohedral\", ...p });\nexport const jigsaw = (p: Omit<JigsawSpec, \"type\">): JigsawSpec => ({ type: \"jigsaw\", ...p });\nexport const voronoi = (p: Omit<VoronoiSpec, \"type\">): VoronoiSpec => ({ type: \"voronoi\", ...p });\nexport const delaunay = (p: Omit<DelaunaySpec, \"type\">): DelaunaySpec => ({ type: \"delaunay\", ...p });\nexport const ashlar = (p: Omit<AshlarSpec, \"type\">): AshlarSpec => ({ type: \"ashlar\", ...p });\nexport const penrose = (p: Omit<PenroseSpec, \"type\">): PenroseSpec => ({ type: \"penrose\", ...p });\nexport const periodic = (p: Omit<PeriodicSpec, \"type\">): PeriodicSpec => ({ type: \"periodic\", ...p });\nexport const tiles = (p: Omit<TilesSpec, \"type\">): TilesSpec => ({ type: \"tiles\", ...p });\nexport const mondrian = (p: Omit<MondrianSpec, \"type\">): MondrianSpec => ({ type: \"mondrian\", ...p });\n/** Andamento: tesserae in rows following guide curves, centers or the region's outline. See `FlowSpec`. */\nexport const flow = (p: Omit<FlowSpec, \"type\">): FlowSpec => ({ type: \"flow\", ...p });\n\n/** A tile as produced by a generator, before gap/clipping is applied. */\nexport interface RawTile {\n /** Stable identifier, unique within one generated layout. */\n id: string;\n polygon: Polygon;\n /** Index of the prototile this tile is a copy of (e.g. herringbone: 0 = horizontal, 1 = vertical). */\n protoTile: number;\n}\n\nexport interface GenerateContext {\n /** Area that must be covered. */\n region: Polygon;\n /** Pattern rotation in degrees. */\n rotation: number;\n /** Where the pattern's local origin sits. */\n origin: Vec;\n /** Safety cap on the number of tiles generated. */\n maxTiles: number;\n /**\n * For generators that can vary their tile size smoothly (Voronoi, Delaunay): the size\n * wanted at a point, as a factor (at most 1) of the spec's size.\n */\n sizeAt?: (p: Vec) => number;\n /** The exact area to tile (outline and holes, less margin), for generators that follow it. */\n outline?: Polygon[];\n /** Layout units per generator unit (the pattern scale), for specs given in layout units. */\n unit?: number;\n}\n\n/**\n * A periodic tiling: a motif of prototiles repeated at every point\n * i·a + j·b of a lattice.\n */\nexport interface PeriodicDefinition {\n a: Vec;\n b: Vec;\n motif: { polygon: Polygon; protoTile: number }[];\n}\n\nfunction positive(name: string, value: number | undefined): number {\n if (value === undefined || !Number.isFinite(value) || value <= 0) {\n throw new RangeError(`${name} must be a positive number (got ${value})`);\n }\n return value;\n}\n\nconst deg = (d: number) => (d * Math.PI) / 180;\nconst polar = (r: number, degrees: number): Vec => vec(r * Math.cos(deg(degrees)), r * Math.sin(deg(degrees)));\n\n/** Regular polygon with `n` corners at circumradius `r` around the origin, first corner at `startDeg`. */\nfunction regular(n: number, r: number, startDeg: number): Polygon {\n return Array.from({ length: n }, (_, k) => polar(r, startDeg + (360 / n) * k));\n}\n\n/** Straight segments per quarter circle when curves are flattened. */\nconst FISH_SCALE_STEPS = 12;\n\n/** Cairo bar half-length (as a fraction of the grid size) that makes all pentagon sides equal. */\nconst CAIRO_BAR = (Math.sqrt(7) - 1) / 6;\n\n/** Tilings generated procedurally (seeded) rather than from a repeating motif. */\nexport type ProceduralSpec = MondrianSpec | VoronoiSpec | DelaunaySpec | AshlarSpec | JigsawSpec | FlowSpec;\n\nexport function periodicDefinition(spec: Exclude<TilingSpec, ProceduralSpec | PenroseSpec | HatSpec | SpectreSpec | IsohedralSpec | TilesSpec>): PeriodicDefinition {\n switch (spec.type) {\n case \"periodic\":\n return {\n a: vec(spec.a.x, spec.a.y),\n b: vec(spec.b.x, spec.b.y),\n motif: spec.motif.map((m, k) => ({ polygon: m.polygon.map((v) => vec(v.x, v.y)), protoTile: m.protoTile ?? k })),\n };\n case \"grid\": {\n const w = positive(\"grid.width\", spec.width);\n const h = positive(\"grid.height\", spec.height ?? spec.width);\n return { a: vec(w, 0), b: vec(0, h), motif: [{ polygon: rectPolygon(0, 0, w, h), protoTile: 0 }] };\n }\n case \"runningBond\": {\n const w = positive(\"runningBond.width\", spec.width);\n const h = positive(\"runningBond.height\", spec.height);\n const offset = spec.offset ?? 0.5;\n return {\n a: vec(w, 0),\n b: vec(offset * w, h),\n motif: [{ polygon: rectPolygon(0, 0, w, h), protoTile: 0 }],\n };\n }\n case \"herringbone\": {\n const L = positive(\"herringbone.length\", spec.length);\n const W = positive(\"herringbone.width\", spec.width);\n if (L <= W) throw new RangeError(\"herringbone.length must be greater than herringbone.width\");\n // A horizontal brick whose right end butts against the side of a vertical brick,\n // repeated along the (W, W) staircase and the (L, -L) diagonal.\n return {\n a: vec(W, W),\n b: vec(L, -L),\n motif: [\n { polygon: rectPolygon(0, 0, L, W), protoTile: 0 },\n { polygon: rectPolygon(L, W - L, W, L), protoTile: 1 },\n ],\n };\n }\n case \"basketweave\": {\n const L = positive(\"basketweave.length\", spec.length);\n const n = Math.round(positive(\"basketweave.strips\", spec.strips ?? 2));\n const t = L / n;\n const motif: PeriodicDefinition[\"motif\"] = [];\n for (let k = 0; k < n; k++) motif.push({ polygon: rectPolygon(0, k * t, L, t), protoTile: 0 });\n for (let k = 0; k < n; k++) motif.push({ polygon: rectPolygon(L + k * t, 0, t, L), protoTile: 1 });\n // Checkerboard of horizontal/vertical blocks.\n return { a: vec(2 * L, 0), b: vec(L, L), motif };\n }\n case \"hexagonal\": {\n const s = positive(\"hexagonal.size\", spec.size);\n const flat = spec.orientation === \"flat\";\n const start = flat ? 0 : 30;\n const hex: Polygon = [];\n for (let k = 0; k < 6; k++) {\n const ang = ((start + 60 * k) * Math.PI) / 180;\n hex.push(vec(s * Math.cos(ang), s * Math.sin(ang)));\n }\n const r3 = Math.sqrt(3);\n return flat\n ? { a: vec(1.5 * s, (r3 / 2) * s), b: vec(0, r3 * s), motif: [{ polygon: hex, protoTile: 0 }] }\n : { a: vec(r3 * s, 0), b: vec((r3 / 2) * s, 1.5 * s), motif: [{ polygon: hex, protoTile: 0 }] };\n }\n case \"triangular\": {\n const s = positive(\"triangular.size\", spec.size);\n const h = (Math.sqrt(3) / 2) * s;\n // A strip of alternating up/down triangles, repeated with a half-triangle shift per row.\n return {\n a: vec(s, 0),\n b: vec(s / 2, h),\n motif: [\n { polygon: [vec(0, h), vec(s / 2, 0), vec(s, h)], protoTile: 0 },\n { polygon: [vec(s / 2, 0), vec((3 * s) / 2, 0), vec(s, h)], protoTile: 1 },\n ],\n };\n }\n case \"rhombille\": {\n const s = positive(\"rhombille.size\", spec.size);\n const r3 = Math.sqrt(3);\n // A pointy hexagon split into three rhombi from its center: top, right and left faces of a cube.\n const v = regular(6, s, 30);\n const face = (k: number): Polygon => [vec(0, 0), v[k % 6]!, v[(k + 1) % 6]!, v[(k + 2) % 6]!];\n return {\n a: vec(r3 * s, 0),\n b: vec((r3 / 2) * s, 1.5 * s),\n motif: [\n { polygon: face(3), protoTile: 0 },\n { polygon: face(5), protoTile: 1 },\n { polygon: face(1), protoTile: 2 },\n ],\n };\n }\n case \"octagonSquare\": {\n const s = positive(\"octagonSquare.size\", spec.size);\n const c = s / Math.SQRT2;\n const w = s + 2 * c;\n const octagon = [vec(c, 0), vec(w - c, 0), vec(w, c), vec(w, w - c), vec(w - c, w), vec(c, w), vec(0, w - c), vec(0, c)];\n const diamond = [vec(c, 0), vec(0, c), vec(-c, 0), vec(0, -c)];\n return {\n a: vec(w, 0),\n b: vec(0, w),\n motif: [\n { polygon: octagon, protoTile: 0 },\n { polygon: diamond, protoTile: 1 },\n ],\n };\n }\n case \"trihexagonal\": {\n const s = positive(\"trihexagonal.size\", spec.size);\n const h = (Math.sqrt(3) / 2) * s;\n // Flat hexagons touching corner to corner, with triangles in the gaps.\n return {\n a: vec(2 * s, 0),\n b: vec(s, 2 * h),\n motif: [\n { polygon: regular(6, s, 0), protoTile: 0 },\n { polygon: [vec(s, 0), vec(1.5 * s, h), vec(0.5 * s, h)], protoTile: 1 },\n { polygon: [vec(s, 0), vec(0.5 * s, -h), vec(1.5 * s, -h)], protoTile: 2 },\n ],\n };\n }\n case \"rhombitrihexagonal\": {\n const s = positive(\"rhombitrihexagonal.size\", spec.size);\n const d = s * (1 + Math.sqrt(3));\n // Pointy hexagon; a square on each edge facing a neighbor (0°, 60°, 120°) and a\n // triangle in each corner between two of those squares (30°, 90°).\n const square = (dir: number): Polygon => {\n const p = polar(s, dir - 30);\n const q = polar(s, dir + 30);\n const n = polar(s, dir);\n return [p, q, vec(q.x + n.x, q.y + n.y), vec(p.x + n.x, p.y + n.y)];\n };\n const triangle = (corner: number): Polygon => {\n const v = polar(s, corner);\n const n1 = polar(s, corner - 30);\n const n2 = polar(s, corner + 30);\n return [v, vec(v.x + n1.x, v.y + n1.y), vec(v.x + n2.x, v.y + n2.y)];\n };\n return {\n a: vec(d, 0),\n b: vec(d / 2, (Math.sqrt(3) / 2) * d),\n motif: [\n { polygon: regular(6, s, 30), protoTile: 0 },\n { polygon: square(0), protoTile: 1 },\n { polygon: square(60), protoTile: 1 },\n { polygon: square(120), protoTile: 1 },\n { polygon: triangle(30), protoTile: 2 },\n { polygon: triangle(90), protoTile: 2 },\n ],\n };\n }\n case \"cairo\": {\n const L = positive(\"cairo.size\", spec.size);\n const h = L / 2;\n const u = CAIRO_BAR * L;\n // Checkerboard of squares holding alternately a horizontal and a vertical bar; each\n // bar end is joined to the two nearest corners. Every grid edge then separates two\n // pieces that merge into one pentagon. Listed here: the four around a horizontal-bar square.\n return {\n a: vec(L, L),\n b: vec(L, -L),\n motif: [\n { polygon: [vec(0, 0), vec(h, -h + u), vec(L, 0), vec(h + u, h), vec(h - u, h)], protoTile: 0 },\n { polygon: [vec(L, 0), vec(L + h, h - u), vec(L + h, h + u), vec(L, L), vec(h + u, h)], protoTile: 1 },\n { polygon: [vec(0, L), vec(h - u, h), vec(h + u, h), vec(L, L), vec(h, L + h - u)], protoTile: 0 },\n { polygon: [vec(0, 0), vec(h - u, h), vec(0, L), vec(-h, h + u), vec(-h, h - u)], protoTile: 1 },\n ],\n };\n }\n case \"hopscotch\": {\n const A = positive(\"hopscotch.large\", spec.large);\n const B = positive(\"hopscotch.small\", spec.small);\n if (B > A) throw new RangeError(\"hopscotch.small must not exceed hopscotch.large\");\n // Pythagorean tiling: each large square is stepped down by the small square's side.\n return {\n a: vec(A, B),\n b: vec(-B, A),\n motif: [\n { polygon: rectPolygon(0, 0, A, A), protoTile: 0 },\n { polygon: rectPolygon(A - B, A, B, B), protoTile: 1 },\n ],\n };\n }\n case \"pinwheel\": {\n const L = positive(\"pinwheel.length\", spec.length);\n const W = positive(\"pinwheel.width\", spec.width);\n if (L <= W) throw new RangeError(\"pinwheel.length must be greater than pinwheel.width\");\n // Four rectangles turning around a small square; neighboring pinwheels share rectangles.\n return {\n a: vec(L, -W),\n b: vec(W, L),\n motif: [\n { polygon: rectPolygon(0, 0, L, W), protoTile: 0 },\n { polygon: rectPolygon(L, 0, W, L), protoTile: 1 },\n { polygon: rectPolygon(W, W, L - W, L - W), protoTile: 2 },\n ],\n };\n }\n case \"flemishBond\": {\n const L = positive(\"flemishBond.length\", spec.length);\n const H = positive(\"flemishBond.height\", spec.height);\n const D = positive(\"flemishBond.header\", spec.header ?? L / 2);\n // Each course alternates stretcher and header; the next course is shifted so its\n // headers sit centerd over the stretchers below.\n return {\n a: vec(L + D, 0),\n b: vec((L + D) / 2, H),\n motif: [\n { polygon: rectPolygon(0, 0, L, H), protoTile: 0 },\n { polygon: rectPolygon(L, 0, D, H), protoTile: 1 },\n ],\n };\n }\n case \"fishScale\": {\n const r = positive(\"fishScale.size\", spec.size) / 2;\n // Each scale: the lower half of a circle, topped by the lower arcs of the two scales\n // above it, which meet in a point. Arcs are sampled at the same angles everywhere,\n // so neighboring scales share exactly the same boundary points.\n const q = FISH_SCALE_STEPS;\n const arc = (cx: number, cy: number, from: number, to: number, steps: number) =>\n Array.from({ length: steps }, (_, k) => polar(r, from + ((to - from) * k) / steps)).map((v) => vec(cx + v.x, cy + v.y));\n const scale: Polygon = [\n ...arc(0, 0, 180, 0, 2 * q), // own rounded bottom, left to right\n ...arc(r, -r, 90, 180, q), // up along the scale above-right\n ...arc(-r, -r, 0, 90, q), // down along the scale above-left\n ];\n return { a: vec(2 * r, 0), b: vec(r, r), motif: [{ polygon: scale, protoTile: 0 }] };\n }\n case \"chevron\": {\n const len = positive(\"chevron.length\", spec.length);\n const w = positive(\"chevron.width\", spec.width);\n const angle = spec.angle ?? 45;\n if (!(angle > 0 && angle < 90)) throw new RangeError(\"chevron.angle must be between 0 and 90 degrees\");\n const t = deg(angle);\n const c = len * Math.cos(t); // column width\n const rise = c * Math.tan(t);\n const step = w / Math.cos(t); // vertical spacing of planks within a column\n // Two columns of parallelograms with vertical ends, sloping up then down: ^ shapes.\n return {\n a: vec(2 * c, 0),\n b: vec(0, step),\n motif: [\n { polygon: [vec(0, 0), vec(c, -rise), vec(c, -rise + step), vec(0, step)], protoTile: 0 },\n { polygon: [vec(c, -rise), vec(2 * c, 0), vec(2 * c, step), vec(c, -rise + step)], protoTile: 1 },\n ],\n };\n }\n }\n}\n\n/** Enumerate every lattice copy of the motif that can touch `ctx.region`. */\nexport function generatePeriodic(def: PeriodicDefinition, ctx: GenerateContext): RawTile[] {\n const { a, b, motif } = def;\n const det = cross2(a, b);\n if (Math.abs(det) < 1e-12) throw new RangeError(\"Degenerate lattice\");\n const theta = (ctx.rotation * Math.PI) / 180;\n\n // Lattice coordinates (i, j) of a point in the pattern's local frame.\n const toLattice = (q: Vec) => ({ i: (q.x * b.y - q.y * b.x) / det, j: (a.x * q.y - a.y * q.x) / det });\n\n // The region, mapped into the pattern's local (unrotated, unshifted) frame.\n const local = transform(\n ctx.region.map((v) => vec(v.x - ctx.origin.x, v.y - ctx.origin.y)),\n -theta,\n vec(0, 0),\n );\n const range = (pts: Vec[]) => {\n let i0 = Infinity, i1 = -Infinity, j0 = Infinity, j1 = -Infinity;\n for (const p of pts) {\n const { i, j } = toLattice(p);\n i0 = Math.min(i0, i); i1 = Math.max(i1, i);\n j0 = Math.min(j0, j); j1 = Math.max(j1, j);\n }\n return { i0, i1, j0, j1 };\n };\n const reg = range(local);\n const mot = range(motif.flatMap((m) => m.polygon));\n\n const iMin = Math.floor(reg.i0 - mot.i1) - 1;\n const iMax = Math.ceil(reg.i1 - mot.i0) + 1;\n const jMin = Math.floor(reg.j0 - mot.j1) - 1;\n const jMax = Math.ceil(reg.j1 - mot.j0) + 1;\n\n const count = (iMax - iMin + 1) * (jMax - jMin + 1) * motif.length;\n if (count > ctx.maxTiles) {\n throw new RangeError(\n `Tiles are too small for this region (~${count} candidate tiles, limit ${ctx.maxTiles}). ` +\n \"Increase the tile size or raise maxTiles.\",\n );\n }\n\n const tiles: RawTile[] = [];\n const regionBox = bbox(local);\n for (let i = iMin; i <= iMax; i++) {\n for (let j = jMin; j <= jMax; j++) {\n const off = vec(i * a.x + j * b.x, i * a.y + j * b.y);\n motif.forEach((m, k) => {\n const placed = m.polygon.map((v) => vec(v.x + off.x, v.y + off.y));\n if (!overlapsBox(placed, regionBox)) return;\n tiles.push({ id: `${i},${j}:${k}`, polygon: transform(placed, theta, ctx.origin), protoTile: m.protoTile });\n });\n }\n }\n return tiles;\n}\n\nfunction cross2(a: Vec, b: Vec) {\n return a.x * b.y - a.y * b.x;\n}\n\nfunction overlapsBox(p: Polygon, r: Rect): boolean {\n const pb = bbox(p);\n return pb.x <= r.x + r.width && r.x <= pb.x + pb.width && pb.y <= r.y + r.height && r.y <= pb.y + pb.height;\n}\n\n/**\n * Random recursive guillotine partition of the region's bounding box.\n * Rotation and origin are ignored: Mondrian layouts are always axis-aligned to the region.\n */\nexport function generateMondrian(spec: MondrianSpec, ctx: GenerateContext): RawTile[] {\n const min = positive(\"mondrian.minSize\", spec.minSize);\n const max = positive(\"mondrian.maxSize\", spec.maxSize);\n const splitChance = spec.splitChance ?? 0.4;\n const snap = spec.snap && spec.snap > 0 ? spec.snap : 0;\n const rng = mulberry32(spec.seed ?? 1);\n const tiles: RawTile[] = [];\n\n const pickCut = (size: number): number | null => {\n const lo = min;\n const hi = size - min;\n if (hi < lo) return null;\n let cut = lo + rng() * (hi - lo);\n if (snap) {\n const sLo = Math.ceil(lo / snap) * snap;\n const sHi = Math.floor(hi / snap) * snap;\n if (sHi >= sLo) cut = Math.min(sHi, Math.max(sLo, Math.round(cut / snap) * snap));\n }\n return cut;\n };\n\n const split = (r: Rect, path: string) => {\n if (tiles.length >= ctx.maxTiles) {\n throw new RangeError(`Too many Mondrian cells (limit ${ctx.maxTiles}). Increase minSize or maxSize.`);\n }\n const canX = r.width >= 2 * min;\n const canY = r.height >= 2 * min;\n const fits = r.width <= max && r.height <= max;\n if ((!canX && !canY) || (fits && rng() >= splitChance)) {\n tiles.push({ id: `m${path}`, polygon: rectPolygon(r.x, r.y, r.width, r.height), protoTile: 0 });\n return;\n }\n // Prefer cutting across the longer side (and always cut an oversize side if possible).\n let vertical: boolean;\n if (canX && canY) {\n if (r.width > max && r.height <= max) vertical = true;\n else if (r.height > max && r.width <= max) vertical = false;\n else vertical = rng() < r.width / (r.width + r.height);\n } else {\n vertical = canX;\n }\n const cut = pickCut(vertical ? r.width : r.height)!;\n if (vertical) {\n split({ x: r.x, y: r.y, width: cut, height: r.height }, path + \"0\");\n split({ x: r.x + cut, y: r.y, width: r.width - cut, height: r.height }, path + \"1\");\n } else {\n split({ x: r.x, y: r.y, width: r.width, height: cut }, path + \"0\");\n split({ x: r.x, y: r.y + cut, width: r.width, height: r.height - cut }, path + \"1\");\n }\n };\n\n split(bbox(ctx.region), \"\");\n return tiles;\n}\n\nexport function generateTiles(spec: TilingSpec, ctx: GenerateContext): RawTile[] {\n switch (spec.type) {\n case \"tiles\":\n return spec.tiles.map((t, i) => ({ id: t.id ?? `t${i}`, polygon: t.polygon.map((v) => vec(v.x, v.y)), protoTile: t.protoTile ?? 0 }));\n case \"mondrian\":\n return generateMondrian(spec, ctx);\n case \"flow\":\n return generateFlow(spec, ctx);\n case \"voronoi\":\n return generateVoronoi(spec, ctx);\n case \"delaunay\":\n return generateDelaunay(spec, ctx);\n case \"ashlar\":\n return generateAshlar(spec, ctx);\n case \"jigsaw\":\n return generateJigsaw(spec, ctx);\n case \"hat\":\n return generateHat(positive(\"hat.size\", spec.size), ctx);\n case \"isohedral\":\n positive(\"isohedral.size\", spec.size);\n return generateIsohedral(spec, ctx);\n case \"spectre\":\n return generateSpectre(positive(\"spectre.size\", spec.size), ctx);\n case \"penrose\":\n return spec.variant === \"kitesAndDarts\"\n ? generateSubstitution(penroseKitesAndDarts, positive(\"penrose.size\", spec.size), ctx, \"Penrose\", \"k\")\n : generateSubstitution(penroseRhombs, positive(\"penrose.size\", spec.size), ctx, \"Penrose\", \"p\");\n }\n return generatePeriodic(periodicDefinition(spec), ctx);\n}\n\n/**\n * Shared plumbing for the monotile tilings: map the region into tile units around the\n * pattern's fixed center (`ctx.origin`), collect tiles there, and map them back.\n */\nfunction generateMonotile(\n size: number,\n width: number,\n ctx: GenerateContext,\n prefix: string,\n collect: (local: Polygon) => { polygon: Polygon; protoTile: number }[],\n): RawTile[] {\n const k = size / width;\n const theta = (ctx.rotation * Math.PI) / 180;\n const local = transform(\n ctx.region.map((v) => vec((v.x - ctx.origin.x) / k, (v.y - ctx.origin.y) / k)),\n -theta,\n vec(0, 0),\n );\n return collect(local).map((t) => {\n let cx = 0;\n let cy = 0;\n for (const v of t.polygon) {\n cx += v.x;\n cy += v.y;\n }\n const n = t.polygon.length;\n return {\n // Position in the pattern (tile units × 100), so ids don't depend on the region.\n id: `${prefix}${Math.round((cx / n) * 100)},${Math.round((cy / n) * 100)}`,\n protoTile: t.protoTile,\n polygon: transform(\n t.polygon.map((v) => vec(v.x * k, v.y * k)),\n theta,\n ctx.origin,\n ),\n };\n });\n}\n\nfunction generateHat(size: number, ctx: GenerateContext): RawTile[] {\n return generateMonotile(size, HAT_WIDTH, ctx, \"h\", (local) => {\n return hatsCovering(bbox(local), ctx.maxTiles).map((t) => ({ polygon: t.polygon, protoTile: LABEL_INDEX[t.label] }));\n });\n}\n\nfunction generateSpectre(size: number, ctx: GenerateContext): RawTile[] {\n return generateMonotile(size, SPECTRE_WIDTH, ctx, \"s\", (local) =>\n spectresCovering(bbox(local), ctx.maxTiles).map((t) => ({ polygon: t.polygon, protoTile: SPECTRE_LABEL_INDEX[t.label] })),\n );\n}\n\nexport interface PeriodicCheck {\n /** True when no gaps, overlaps or self-intersecting tiles were found. */\n ok: boolean;\n /** Area of one lattice cell, |a × b|, and the motif's total area (equal for a tiling). */\n cellArea: number;\n motifArea: number;\n /** Fraction of sample points covered by no tile, and by more than one. */\n gaps: number;\n overlaps: number;\n /** Motif indices whose outline crosses itself. */\n selfIntersecting: number[];\n}\n\n/**\n * Check a custom periodic tiling by sampling one lattice cell: every point should be\n * covered by exactly one copy of one motif tile. Sampling can miss slivers narrower than\n * the sample spacing (`samples` points per side, default 60).\n */\nexport function checkPeriodic(spec: PeriodicSpec | PeriodicDefinition, samples = 60): PeriodicCheck {\n const def = \"type\" in spec ? periodicDefinition(spec) : spec;\n const { a, b, motif } = def;\n const cellArea = Math.abs(a.x * b.y - a.y * b.x);\n const motifArea = motif.reduce((sum, m) => sum + area(m.polygon), 0);\n const selfIntersecting = motif.flatMap((m, k) => (splitSelfIntersections(m.polygon).length > 1 ? [k] : []));\n if (cellArea < 1e-12) return { ok: false, cellArea, motifArea, gaps: 1, overlaps: 0, selfIntersecting };\n\n // Copies whose lattice offset could reach the cell: the motif's extent in lattice units.\n const det = a.x * b.y - a.y * b.x;\n const toLattice = (p: Vec) => ({ i: (p.x * b.y - p.y * b.x) / det, j: (a.x * p.y - a.y * p.x) / det });\n let reach = 1;\n for (const m of motif) for (const v of m.polygon) {\n const l = toLattice(v);\n reach = Math.max(reach, Math.ceil(Math.abs(l.i)) + 1, Math.ceil(Math.abs(l.j)) + 1);\n }\n const copies: { polygon: Polygon; box: Rect }[] = [];\n for (let i = -reach; i <= reach; i++) {\n for (let j = -reach; j <= reach; j++) {\n for (const m of motif) {\n const polygon = m.polygon.map((v) => vec(v.x + i * a.x + j * b.x, v.y + i * a.y + j * b.y));\n copies.push({ polygon, box: bbox(polygon) });\n }\n }\n }\n\n let gaps = 0;\n let overlaps = 0;\n for (let u = 0; u < samples; u++) {\n for (let w = 0; w < samples; w++) {\n // Odd offsets keep samples off tile edges, which often run along lattice directions.\n const s = (u + 0.4142136) / samples;\n const t = (w + 0.7320508) / samples;\n const p = vec(s * a.x + t * b.x, s * a.y + t * b.y);\n let hits = 0;\n for (const c of copies) {\n if (p.x < c.box.x || p.y < c.box.y || p.x > c.box.x + c.box.width || p.y > c.box.y + c.box.height) continue;\n if (pointInPolygon(p, c.polygon)) hits++;\n }\n if (hits === 0) gaps++;\n else if (hits > 1) overlaps++;\n }\n }\n const n = samples * samples;\n return { ok: gaps === 0 && overlaps === 0 && selfIntersecting.length === 0, cellArea, motifArea, gaps: gaps / n, overlaps: overlaps / n, selfIntersecting };\n}\n","import { add, dot, length, scale, sub, type Polygon, type Vec } from \"./geometry\";\n\n/**\n * One corner of a polygon after rounding: the outline runs straight to `start`,\n * follows a circular arc of `radius` around `center` to `end`, then continues.\n * When `radius` is 0 (a straight-through or degenerate corner), start, end and\n * center are all the original vertex.\n */\nexport interface RoundedCorner {\n vertex: Vec;\n start: Vec;\n end: Vec;\n center: Vec;\n radius: number;\n /** Signed arc angle in radians, from start to end around center (atan2 convention, y down). */\n sweep: number;\n}\n\nconst unit = (v: Vec): Vec => {\n const l = length(v);\n return l > 0 ? scale(v, 1 / l) : v;\n};\n\n/**\n * Fit a circular arc of `radius` into every corner of `poly`. `radius` may instead give\n * each corner its own (0 keeps that corner sharp).\n *\n * Each corner's radius is reduced where needed so an arc never uses more than\n * half of either adjacent edge, so short edges and sharp corners stay valid and\n * neighboring arcs never overlap.\n */\nexport function roundCorners(poly: Polygon, radius: number | readonly number[]): RoundedCorner[] {\n const n = poly.length;\n return poly.map((v, i) => {\n const want = typeof radius === \"number\" ? radius : (radius[i] ?? 0);\n const prev = poly[(i - 1 + n) % n]!;\n const next = poly[(i + 1) % n]!;\n const flat: RoundedCorner = { vertex: v, start: v, end: v, center: v, radius: 0, sweep: 0 };\n if (!(want > 0) || n < 3) return flat;\n\n const toPrev = sub(prev, v);\n const toNext = sub(next, v);\n const lenPrev = length(toPrev);\n const lenNext = length(toNext);\n if (lenPrev === 0 || lenNext === 0) return flat;\n const u = scale(toPrev, 1 / lenPrev);\n const w = scale(toNext, 1 / lenNext);\n\n // Interior angle at the vertex; nothing to round on a straight line.\n const angle = Math.acos(Math.max(-1, Math.min(1, dot(u, w))));\n const half = angle / 2;\n if (half < 1e-9 || Math.PI - angle < 1e-9) return flat;\n\n // Distance from the vertex to where the arc meets each edge.\n let r = want;\n let t = r / Math.tan(half);\n const limit = Math.min(lenPrev, lenNext) / 2;\n if (t > limit) {\n t = limit;\n r = t * Math.tan(half);\n }\n\n const start = add(v, scale(u, t));\n const end = add(v, scale(w, t));\n const center = add(v, scale(unit(add(u, w)), r / Math.sin(half)));\n const a0 = Math.atan2(start.y - center.y, start.x - center.x);\n const a1 = Math.atan2(end.y - center.y, end.x - center.x);\n let sweep = a1 - a0;\n // Corner arcs always turn by less than half a circle.\n if (sweep > Math.PI) sweep -= 2 * Math.PI;\n if (sweep < -Math.PI) sweep += 2 * Math.PI;\n return { vertex: v, start, end, center, radius: r, sweep };\n });\n}\n\n/**\n * `poly` with its corners rounded, as a plain polygon: each arc is approximated\n * by straight segments of at most `maxStep` radians (default 10°). Useful where\n * curves aren't available, such as CSS `clip-path: polygon()`.\n */\nexport function roundedPolygon(poly: Polygon, radius: number | readonly number[], maxStep = Math.PI / 18): Polygon {\n if (typeof radius === \"number\" ? radius <= 0 : !radius.some((r) => r > 0)) return poly;\n const out: Polygon = [];\n for (const c of roundCorners(poly, radius)) {\n if (c.radius === 0) {\n out.push(c.vertex);\n continue;\n }\n const steps = Math.max(1, Math.ceil(Math.abs(c.sweep) / maxStep));\n const a0 = Math.atan2(c.start.y - c.center.y, c.start.x - c.center.x);\n out.push(c.start);\n for (let s = 1; s < steps; s++) {\n const a = a0 + (c.sweep * s) / steps;\n out.push({ x: c.center.x + c.radius * Math.cos(a), y: c.center.y + c.radius * Math.sin(a) });\n }\n out.push(c.end);\n }\n return out;\n}\n","import {\n area,\n bbox,\n centroid,\n clipConvex,\n containsPolygon,\n convexHull,\n ensurePositive,\n insetConvex,\n isConvex,\n rectPolygon,\n rectsOverlap,\n vec,\n type Polygon,\n type Rect,\n type Vec,\n} from \"./geometry\";\nimport { clipPolygonToConvex, insetPolygon, insetPolygonPieces, outsetPolygon, pointInPolygon, splitSelfIntersections } from \"./offset\";\nimport { inShapes, overlay, shapeArea, shapeCentroid, type Shape } from \"./overlay\";\nimport { generateTiles, type TilingSpec } from \"./tilings\";\nimport { fieldRange, refineTiles } from \"./density\";\n\n/**\n * How tiles at the edge of the region are treated.\n * - \"clip\": cut tiles to the region outline (a full-bleed look).\n * - \"inside\": keep only tiles that fit entirely inside the region.\n * - \"overflow\": keep every tile that touches the region, uncut.\n * - \"window\": tiles stay whole and the region is a window onto them: renderers shape,\n * round, bevel and fill each tile as the whole tile (`Cell.tile`) and hide\n * what falls outside the region (`Layout.view`). A cut edge is a straight\n * line through the tile, not a new corner.\n */\nexport type EdgeMode = \"clip\" | \"inside\" | \"overflow\" | \"window\";\n\nexport interface LayoutOptions {\n /**\n * The area to tile: a rectangle or any simple polygon (convex or not; it mustn't cross\n * itself), in your own units (cm, px, in…).\n */\n region: Rect | Polygon;\n /**\n * Areas inside the region to leave empty: windows, doors, sockets. Rectangles or\n * simple polygons; they may overlap each other or the region's edge. Tiles are cut\n * around them (or skipped, with `edges: \"inside\"`), and `margin` applies around them too.\n */\n holes?: (Rect | Polygon)[];\n tiling: TilingSpec;\n /** Space between neighboring tiles. Defaults to 0. */\n gap?: number;\n /** Empty border kept between the region outline (and any holes) and the tiles. Defaults to 0. */\n margin?: number;\n /** Pattern rotation in degrees (ignored by the random patterns: mondrian, voronoi, delaunay, ashlar, jigsaw). Defaults to 0. */\n rotation?: number;\n /**\n * Shifts the pattern (ignored by the random patterns). For penrose this is where the\n * ten-fold star at the pattern's center sits. Defaults to the top-left of the region.\n */\n origin?: Vec;\n /** Defaults to \"clip\". */\n edges?: EdgeMode;\n /**\n * Drop edge tiles that end up smaller than this fraction (0–1) of a full tile,\n * so you don't get slivers. Applies to \"clip\", \"overflow\" and \"window\". Defaults to 0.\n */\n minFill?: number;\n /**\n * Round every tile corner with this radius, in region units. Corners too small\n * for the full radius get the largest radius that fits. Defaults to 0 (sharp).\n * Rounding is applied when rendering; `Cell.polygon`, `area` and `centroid`\n * describe the sharp-cornered shape.\n */\n cornerRadius?: number;\n /**\n * Scale the whole pattern (every tile size in the tiling spec) by this factor, about\n * the pattern origin. Handy for fitting a tile count without knowing which size\n * parameters a pattern has; see `fitCount`. Defaults to 1.\n */\n tileScale?: number;\n /**\n * Featured tiles: groups of neighboring tiles merged into one bigger cell, e.g. for a\n * hero image. Merging happens before the gap and edge handling, so a featured cell gets\n * the same gap all round as any other. See `Feature`.\n */\n features?: Feature[];\n /**\n * Vary the tile size across the region: the size wanted at each point, as a factor of the\n * tiling's own size (1 as given, 0.5 half as big, 2 twice). Voronoi and Delaunay change\n * size smoothly; other tilings are generated at the largest size wanted and, where tiles\n * should be smaller, replaced by the same tiling at half the scale (again and again, down\n * to the smallest), cut to fit. Grids and other tilings that halve exactly nest without\n * cuts. See `radialSize`, `edgeSize` and `imageSize`.\n */\n sizeAt?: (point: Vec) => number;\n /** Safety cap on generated tiles. Defaults to 20000. */\n maxTiles?: number;\n}\n\n/**\n * A featured tile: `tiles` neighboring tiles merged into one cell. The group grows from\n * a tile near `at`, adding whichever neighbor keeps it most compact (so 4 grid tiles make\n * a 2 × 2 square, 7 hexagons a flower); several starting tiles are tried and the most\n * compact group kept, near `at` and avoiding tiles the region edge cuts. Features don't\n * share tiles: a later one grows among the tiles still free.\n */\nexport interface Feature {\n /** How many tiles to merge. Defaults to 4. Fewer are merged if the group runs out of room. */\n tiles?: number;\n /** Where the group starts, in region units. Defaults to the middle of the region. */\n at?: Vec;\n /**\n * Exact tile ids to merge instead (from a layout without features; ids are stable).\n * Overrides `tiles` and `at`. Tiles that aren't in the layout or are already taken are skipped.\n */\n ids?: string[];\n /**\n * Which content item (by position) goes in this featured cell. By default featured cells\n * take the first items, in `features` order. See `weightedLayout`.\n */\n item?: number;\n}\n\nexport interface Cell {\n /** Stable id derived from the tile's position in the pattern. */\n id: string;\n /** Position in reading order (top-to-bottom, then left-to-right). Use it to assign content to cells. */\n index: number;\n /** Visible shape: after gap and edge handling. */\n polygon: Polygon;\n /**\n * Holes in the visible shape, when a region hole lies wholly inside the tile. Absent\n * otherwise. `area` and `centroid` account for them.\n */\n holes?: Polygon[];\n /** The full pattern tile before gap and edge handling. */\n original: Polygon;\n /**\n * With `edges: \"window\"`, for a cell the region outline cuts: the whole tile (after the\n * gap), which renderers shape, round and fill, letting the region hide the rest. `polygon`\n * is still the visible part (its largest piece, when the outline cuts the tile in two).\n * See `cellShape` and `visibleShapes`.\n */\n tile?: Polygon;\n bbox: Rect;\n centroid: Vec;\n area: number;\n /** The tile crosses the region outline (it was cut in \"clip\" mode, or sticks out in \"overflow\"). */\n boundary: boolean;\n /** Which prototile this is a copy of (e.g. herringbone: 0 horizontal, 1 vertical). */\n protoTile: number;\n /** Ids of cells that share an edge with this one in the underlying pattern. */\n neighbors: string[];\n /** For a featured cell: its position in `features`. Featured cells get content first. */\n featured?: number;\n /** For a featured cell: the content item it's for, when its feature names one (`Feature.item`). */\n featuredItem?: number;\n /** For a featured cell: ids of the tiles merged into it. */\n merged?: string[];\n}\n\nexport interface Layout {\n /** The region outline (before margin). */\n region: Polygon;\n /** The region's holes (before margin), positively oriented. */\n holes: Polygon[];\n /** Bounding box of the region; a good SVG viewBox. */\n bounds: Rect;\n /** Corner radius renderers apply to every cell (0 for sharp corners). */\n cornerRadius: number;\n /**\n * With `edges: \"window\"`: the area tiles show in (the region less its margin and holes).\n * Renderers hide whatever part of a tile lies outside it.\n */\n view?: Shape[];\n cells: Cell[];\n}\n\nfunction toPolygon(region: Rect | Polygon): Polygon {\n if (Array.isArray(region)) return region.map((v) => vec(v.x, v.y));\n return rectPolygon(region.x, region.y, region.width, region.height);\n}\n\nexport function createLayout(options: LayoutOptions): Layout {\n const region = ensurePositive(toPolygon(options.region));\n if (region.length < 3) throw new RangeError(\"region needs at least 3 corners\");\n if (splitSelfIntersections(region).length > 1) throw new RangeError(\"region must not cross itself\");\n if (area(region) === 0) throw new RangeError(\"region has no area\");\n const holes: Polygon[] = [];\n for (const h of options.holes ?? []) {\n const hole = ensurePositive(toPolygon(h));\n if (hole.length >= 3 && splitSelfIntersections(hole).length > 1) throw new RangeError(\"holes must not cross themselves\");\n if (hole.length >= 3 && area(hole) > 0) holes.push(hole);\n }\n // Convex regions without holes take the fast path: clipping against a convex outline.\n const simple = holes.length === 0 && isConvex(region);\n const bounds = bbox(region);\n const scaleRef = Math.max(bounds.width, bounds.height);\n const tol = 1e-7 * scaleRef;\n\n const gap = Math.max(0, options.gap ?? 0);\n const margin = Math.max(0, options.margin ?? 0);\n const edges = options.edges ?? \"clip\";\n const minFill = Math.min(1, Math.max(0, options.minFill ?? 0));\n const cornerRadius = Math.max(0, options.cornerRadius ?? 0);\n\n const empty: Layout = { region, holes, bounds, cornerRadius, cells: [] };\n // The area tiles may cover: the region less its margin and the (grown) holes.\n let inner: Polygon;\n let usable: Shape[] = [];\n let loops: Polygon[] = [];\n if (simple) {\n inner = margin > 0 ? insetConvex(region, margin) : region;\n if (inner.length === 0) return empty;\n } else {\n const outers = margin > 0 ? insetPolygonPieces(region, margin) : [region];\n const grown = holes.map((h) => (margin > 0 ? outsetPolygon(h, margin) : h)).filter((h) => h.length >= 3);\n usable = overlay(\n [...outers, ...grown],\n (p) => outers.some((o) => pointInPolygon(p, o)) && !grown.some((h) => pointInPolygon(p, h)),\n scaleRef,\n );\n if (usable.length === 0) return empty;\n loops = usable.flatMap((s) => [s.outer, ...s.holes]);\n // Generators only need to cover this; tiles are cut to the exact area below.\n inner = convexHull(usable.flatMap((s) => s.outer));\n }\n const innerBox = bbox(inner);\n // Region edges with their boxes, to find the few that reach each tile.\n const edgesOf = loops.flatMap((l) => l.map((a, i) => [a, l[(i + 1) % l.length]!] as const));\n const edgeBoxes = edgesOf.map(([a, b]) => ({ x0: Math.min(a.x, b.x), y0: Math.min(a.y, b.y), x1: Math.max(a.x, b.x), y1: Math.max(a.y, b.y) }));\n\n const k = options.tileScale ?? 1;\n if (!(k > 0) || !Number.isFinite(k)) throw new RangeError(`tileScale must be a positive number (got ${k})`);\n const origin = options.origin ?? vec(bounds.x, bounds.y);\n // With sizeAt, the pattern starts at the largest size wanted.\n const field = options.sizeAt;\n const range = field ? fieldRange(field, innerBox) : { min: 1, max: 1 };\n const k0 = k * range.max;\n const smooth = options.tiling.type === \"voronoi\" || options.tiling.type === \"delaunay\";\n // Scaling the pattern by k0 = generating in a region shrunk by 1/k0, then scaling back up.\n const down = (v: Vec) => vec(v.x / k0, v.y / k0);\n let raw = generateTiles(options.tiling, {\n region: k0 === 1 ? inner : inner.map(down),\n rotation: options.rotation ?? 0,\n origin: k0 === 1 ? origin : down(origin),\n maxTiles: options.maxTiles ?? 20000,\n // The exact area to tile and the pattern scale, for generators that follow the outline.\n outline: (simple ? [inner] : loops).map((l) => (k0 === 1 ? l : l.map(down))),\n unit: k0,\n ...(field && smooth ? { sizeAt: (p: Vec) => Math.min(1, field(vec(p.x * k0, p.y * k0)) / range.max) } : {}),\n });\n if (k0 !== 1) raw = raw.map((t) => ({ ...t, polygon: t.polygon.map((v) => vec(v.x * k0, v.y * k0)) }));\n if (field && !smooth && options.tiling.type !== \"tiles\" && options.tiling.type !== \"flow\" && range.min < range.max / Math.SQRT2) {\n raw = refineTiles(raw, {\n spec: options.tiling,\n rotation: options.rotation ?? 0,\n origin,\n scale: k0,\n want: (p) => field(p) / range.max,\n levels: Math.min(6, Math.round(Math.log2(range.max / range.min))),\n maxTiles: options.maxTiles ?? 20000,\n scaleRef,\n tol,\n });\n }\n\n type Draft = Omit<Cell, \"index\" | \"neighbors\">;\n const drafts: Draft[] = [];\n const minArea = tol * scaleRef;\n\n /** Gap, edge handling and clipping for one pattern tile; its visible piece(s) as drafts. */\n const place = (original: Polygon, id: string, protoTile: number): Draft[] => {\n const convex = isConvex(original);\n // Each tile gives up half the gap on every side, so neighbors end up `gap` apart.\n const tile = gap <= 0 ? original : convex ? insetConvex(original, gap / 2) : insetPolygon(original, gap / 2);\n if (tile.length === 0) return [];\n const full = area(tile);\n\n let pieces: Shape[];\n let boundary: boolean;\n if (!simple) {\n const tb = bbox(tile);\n const pad = tol;\n const near: Polygon[] = [];\n edgeBoxes.forEach((e, i) => {\n if (e.x1 >= tb.x - pad && e.x0 <= tb.x + tb.width + pad && e.y1 >= tb.y - pad && e.y0 <= tb.y + tb.height + pad) {\n near.push([...edgesOf[i]!]);\n }\n });\n let cut: Shape[];\n if (near.length === 0) {\n // No region edge reaches the tile's box: it's wholly in or wholly out.\n cut = inShapes(tile[0]!, loops) ? [{ outer: tile, holes: [] }] : [];\n } else {\n cut = overlay([tile, ...near], (p) => pointInPolygon(p, tile) && inShapes(p, loops), scaleRef)\n .filter((q) => shapeArea(q) > minArea)\n .sort((a, b) => shapeArea(b) - shapeArea(a));\n }\n const visible = cut.reduce((sum, q) => sum + shapeArea(q), 0);\n boundary = visible < full - minArea;\n if (edges === \"inside\") {\n if (boundary || cut.length !== 1 || cut[0]!.holes.length > 0) return [];\n pieces = [{ outer: tile, holes: [] }];\n } else {\n if (visible <= minArea || visible < minFill * full) return [];\n pieces = edges === \"overflow\" ? [{ outer: tile, holes: [] }] : cut;\n }\n } else if (edges === \"inside\") {\n if (!containsPolygon(inner, tile, tol)) return [];\n pieces = [{ outer: tile, holes: [] }];\n boundary = false;\n } else {\n // The region edge can cut a non-convex tile into separate parts; those become\n // separate cells, largest first.\n const cut = convex\n ? [clipConvex(tile, inner)]\n : clipPolygonToConvex(tile, inner)\n .filter((q) => area(q) > minArea)\n .sort((a, b) => area(b) - area(a));\n const visible = cut.reduce((sum, q) => sum + (q.length ? area(q) : 0), 0);\n if (visible <= minArea || visible < minFill * full) return [];\n boundary = visible < full - minArea;\n pieces = (edges === \"overflow\" ? [tile] : cut).map((outer) => ({ outer, holes: [] }));\n }\n\n if (edges === \"window\" && boundary) {\n // One cell for the whole tile: its largest visible piece, with the tile to draw.\n const shape = pieces[0]!;\n const withHoles = shape.holes.length > 0;\n return [{\n id,\n polygon: shape.outer,\n ...(withHoles ? { holes: shape.holes.map((h) => ensurePositive(h)) } : {}),\n original,\n tile,\n bbox: bbox(shape.outer),\n centroid: withHoles ? shapeCentroid(shape) : centroid(shape.outer),\n area: withHoles ? shapeArea(shape) : area(shape.outer),\n boundary,\n protoTile,\n }];\n }\n\n return pieces.map((shape, k) => {\n const withHoles = shape.holes.length > 0;\n return {\n // Extra parts of a tile split by the region edge get \"~1\", \"~2\", ….\n id: k === 0 ? id : `${id}~${k}`,\n polygon: shape.outer,\n ...(withHoles ? { holes: shape.holes.map((h) => ensurePositive(h)) } : {}),\n original,\n bbox: bbox(shape.outer),\n centroid: withHoles ? shapeCentroid(shape) : centroid(shape.outer),\n area: withHoles ? shapeArea(shape) : area(shape.outer),\n boundary,\n protoTile,\n };\n });\n };\n\n for (const t of raw) {\n const original = ensurePositive(t.polygon);\n if (!rectsOverlap(bbox(original), innerBox)) continue;\n drafts.push(...place(original, t.id, t.protoTile));\n }\n\n if (options.features?.length) {\n const merged = mergeFeatures(drafts, options.features, region, scaleRef, Math.max(tol * 10, 1e-9));\n for (const m of merged) {\n const keep = new Set(m.members);\n const pieces = place(m.polygon, `feature${m.feature}`, m.protoTile).map((d) => ({\n ...d,\n featured: m.feature,\n ...(options.features![m.feature]!.item !== undefined ? { featuredItem: options.features![m.feature]!.item } : {}),\n merged: m.members,\n }));\n // Drop the merged tiles (and any extra parts of them) and add the featured cell.\n for (let i = drafts.length - 1; i >= 0; i--) if (keep.has(drafts[i]!.id.split(\"~\")[0]!)) drafts.splice(i, 1);\n drafts.push(...pieces);\n }\n }\n\n\n // Reading order: rows top-to-bottom, then left-to-right.\n const rowTol = 1e-6 * scaleRef;\n drafts.sort((p, q) => {\n const dy = p.centroid.y - q.centroid.y;\n return Math.abs(dy) > rowTol ? dy : p.centroid.x - q.centroid.x;\n });\n\n const neighbors = findNeighbors(\n drafts.map((d) => d.original),\n drafts.map((d) => !d.id.includes(\"~\")),\n Math.max(tol * 10, 1e-9),\n );\n const cells: Cell[] = drafts.map((d, index) => ({\n ...d,\n index,\n neighbors: neighbors[index]!.map((k) => drafts[k]!.id),\n }));\n const view = edges === \"window\" ? (simple ? [{ outer: inner, holes: [] }] : usable) : undefined;\n return { region, holes, bounds, cornerRadius, ...(view ? { view } : {}), cells };\n}\n\ntype FeatureDraft = { id: string; original: Polygon; boundary: boolean; protoTile: number; area: number };\n\n/**\n * Choose the tile groups for `features` among the laid-out tiles, and merge each group's\n * pattern tiles into one outline. Groups that would merge into something other than a\n * single outline without holes (a ring, say) are left unmerged.\n */\nfunction mergeFeatures(\n drafts: FeatureDraft[],\n features: Feature[],\n region: Polygon,\n scale: number,\n tol: number,\n): { feature: number; members: string[]; polygon: Polygon; protoTile: number }[] {\n // Whole tiles only (not the extra parts of a split one), with their pattern geometry.\n const tiles = drafts.filter((d) => !d.id.includes(\"~\"));\n const index = new Map(tiles.map((t, i) => [t.id, i]));\n const adj = findNeighbors(tiles.map((t) => t.original), tiles.map(() => true), tol);\n const cx = tiles.map((t) => centroid(t.original));\n const ar = tiles.map((t) => area(t.original));\n // How much of each tile is left inside the region; one that keeps most of itself (trimmed\n // by the margin, say) counts as whole.\n const kept = tiles.map((t, i) => (t.boundary ? Math.min(1, t.area / (ar[i]! || 1)) : 1));\n const cut = kept.map((k) => k < 0.6);\n const taken = new Uint8Array(tiles.length);\n const middle = centroid(region);\n const out: { feature: number; members: string[]; polygon: Polygon; protoTile: number }[] = [];\n\n features.forEach((f, k) => {\n let group: number[];\n if (f.ids) {\n group = f.ids.map((id) => index.get(id)).filter((i): i is number => i !== undefined && !taken[i]);\n } else {\n const want = Math.max(1, Math.floor(f.tiles ?? 4));\n const at = f.at ?? middle;\n // Score: (mostly) uncut tiles first, then distance to `to`, then distance to `at` (which keeps\n // the group centerd on `at` when several tiles are equally compact); then the earlier tile.\n const eps = 1e-9 * scale * scale;\n const d2 = (i: number, p: Vec) => (cx[i]!.x - p.x) ** 2 + (cx[i]!.y - p.y) ** 2;\n const better = (i: number, j: number, to: Vec) => {\n if (cut[i] !== cut[j]) return !cut[i];\n const a = d2(i, to) - d2(j, to);\n if (Math.abs(a) > eps) return a < 0;\n const b = d2(i, at) - d2(j, at);\n if (Math.abs(b) > eps) return b < 0;\n return i < j;\n };\n // Grow a group from each of the free tiles nearest `at`, and keep the best: the most\n // tiles, then the lowest cost (spread out, off-center from `at`, or cut by the edge).\n // Growing from the nearest tile alone can make a strip where a block fits a step away.\n const free: number[] = [];\n for (let i = 0; i < tiles.length; i++) if (!taken[i]) free.push(i);\n if (!free.length) return;\n free.sort((i, j) => (better(i, j, at) ? -1 : better(j, i, at) ? 1 : 0));\n const grow = (seed: number) => {\n const g = [seed];\n const inGroup = new Set(g);\n while (g.length < want) {\n // The group's center (area-weighted), and the free neighbor nearest it.\n let sx = 0, sy = 0, sw = 0;\n for (const i of g) { sx += cx[i]!.x * ar[i]!; sy += cx[i]!.y * ar[i]!; sw += ar[i]!; }\n const c = vec(sx / sw, sy / sw);\n let pick = -1;\n for (const i of g) {\n for (const j of adj[i]!) if (!taken[j] && !inGroup.has(j) && (pick < 0 || better(j, pick, c))) pick = j;\n }\n if (pick < 0) break;\n g.push(pick);\n inGroup.add(pick);\n }\n return g;\n };\n const cost = (g: number[]) => {\n let sx = 0, sy = 0, sw = 0, lost = 0;\n for (const i of g) { sx += cx[i]!.x * ar[i]!; sy += cx[i]!.y * ar[i]!; sw += ar[i]!; if (cut[i]) lost += (1 - kept[i]!) * ar[i]!; }\n if (!(sw > 0)) return Infinity;\n const c = vec(sx / sw, sy / sw);\n // Spread: the tiles' moment of inertia about the group's center over its area squared\n // (a 2 x 2 square of squares scores 1/8, an L 7/32, a 4 x 1 strip 5/16).\n let inertia = 0;\n for (const i of g) inertia += ar[i]! * d2(i, c);\n const spread = inertia / (sw * sw);\n // Distance from `at`, relative to the group's size; and the share cut off by the edge.\n const off = ((c.x - at.x) ** 2 + (c.y - at.y) ** 2) / sw;\n return spread + 0.15 * off + 0.6 * (lost / sw);\n };\n group = [];\n let bestCost = Infinity;\n for (const seed of free.slice(0, Math.max(8, 2 * want))) {\n const g = grow(seed);\n const gc = cost(g);\n if (g.length > group.length || (g.length === group.length && gc < bestCost - 1e-9)) {\n group = g;\n bestCost = gc;\n }\n }\n }\n if (group.length === 0) return;\n for (const i of group) taken[i] = 1;\n const polys = group.map((i) => tiles[i]!.original);\n const union = group.length === 1 ? [{ outer: polys[0]!, holes: [] }] : overlay(polys, (p) => polys.some((q) => pointInPolygon(p, q)), scale);\n if (union.length !== 1 || union[0]!.holes.length > 0) {\n for (const i of group) taken[i] = 0;\n return;\n }\n out.push({ feature: k, members: group.map((i) => tiles[i]!.id), polygon: union[0]!.outer, protoTile: tiles[group[0]!]!.protoTile });\n });\n return out;\n}\n\n/**\n * Edge-adjacency between polygons: two share an edge if they have overlapping boundary\n * segments on the same line (which also catches T-junctions, where one tile's edge runs\n * along part of another's). Edges are bucketed by their line, so the work grows with the\n * number of edges rather than with pairs of nearby tiles × their edges.\n */\nfunction findNeighbors(polys: Polygon[], primary: boolean[], tol: number): number[][] {\n // Line of each edge: direction angle in [0, π) and signed offset from the origin.\n const angleStep = 1e-6;\n const offsetStep = Math.max(tol * 10, 1e-9);\n type Seg = { poly: number; t0: number; t1: number };\n // Buckets keyed by a number packing (angle, offset) exactly; offsets are measured from a\n // point near the tiles so they stay small. Anything beyond the packable range (tiles\n // absurdly far away) falls back to string keys.\n const buckets = new Map<number | string, Seg[]>();\n const add = (ka: number, ko: number, seg: Seg) => {\n const key = Math.abs(ko) < 2 ** 30 ? (ka + 2) * 2 ** 31 + (ko + 2 ** 30) : `${ka},${ko}`;\n const list = buckets.get(key);\n if (list) list.push(seg);\n else buckets.set(key, [seg]);\n };\n const ref = polys.find((p) => p.length > 0)?.[0] ?? { x: 0, y: 0 };\n // Parts of one tile (split by the region edge) share the same original; its main part\n // (the one without a \"~n\" suffix) stands for the tile.\n const owners = new Map<Polygon, number>();\n polys.forEach((p, i) => {\n if (primary[i] || !owners.has(p)) owners.set(p, i);\n });\n polys.forEach((p, i) => {\n if (owners.get(p) !== i) return;\n for (let k = 0; k < p.length; k++) {\n const a = p[k]!;\n const b = p[(k + 1) % p.length]!;\n const len = Math.hypot(b.x - a.x, b.y - a.y);\n if (len <= tol) continue;\n let ux = (b.x - a.x) / len;\n let uy = (b.y - a.y) / len;\n if (uy < 0 || (uy === 0 && ux < 0)) {\n ux = -ux;\n uy = -uy;\n }\n // Directions just short of 180° are the same lines as those just past 0°.\n let angle = Math.atan2(uy, ux);\n if (angle > Math.PI - angleStep) {\n ux = -ux;\n uy = -uy;\n angle = Math.atan2(uy, ux);\n }\n const ax = a.x - ref.x, ay = a.y - ref.y;\n const ta = ux * ax + uy * ay;\n const tb = ux * (b.x - ref.x) + uy * (b.y - ref.y);\n const seg = { poly: i, t0: Math.min(ta, tb), t1: Math.max(ta, tb) };\n // Bucket by line. A value close to a rounding boundary also goes into the bucket on\n // the other side, so the same line computed with slightly different rounding still meets.\n const va = angle / angleStep;\n const vo = (ux * ay - uy * ax) / offsetStep;\n const ka = Math.round(va);\n const ko = Math.round(vo);\n const ea = va - ka > 0.49 ? 1 : va - ka < -0.49 ? -1 : 0;\n const eo = vo - ko > 0.49 ? 1 : vo - ko < -0.49 ? -1 : 0;\n add(ka, ko, seg);\n if (eo) add(ka, ko + eo, seg);\n if (ea) {\n add(ka + ea, ko, seg);\n if (eo) add(ka + ea, ko + eo, seg);\n }\n }\n });\n\n const pairs = new Set<string>();\n const result: number[][] = polys.map(() => []);\n const link = (i: number, j: number) => {\n const key = i < j ? `${i},${j}` : `${j},${i}`;\n if (pairs.has(key)) return;\n pairs.add(key);\n result[i]!.push(j);\n result[j]!.push(i);\n };\n for (const segs of buckets.values()) {\n // Sweep along the line: only segments whose intervals overlap are compared. (In a\n // lattice a whole row of tiles can put edges on one line, so pairwise would be slow.)\n segs.sort((a, b) => a.t0 - b.t0);\n const active: Seg[] = [];\n for (const s of segs) {\n for (let k = active.length - 1; k >= 0; k--) {\n if (active[k]!.t1 <= s.t0 + tol) active.splice(k, 1);\n }\n for (const o of active) {\n if (o.poly !== s.poly && Math.min(s.t1, o.t1) - Math.max(s.t0, o.t0) > tol) link(s.poly, o.poly);\n }\n active.push(s);\n }\n }\n // Parts of one tile get the same neighbors as the tile.\n polys.forEach((p, i) => {\n const owner = owners.get(p)!;\n if (owner !== i) result[i] = [...result[owner]!];\n });\n for (const list of result) list.sort((a, b) => a - b);\n return result;\n}\n\n/**\n * Greedy graph coloring over cell adjacency: neighboring cells get different\n * color indices. Handy for placeholder fills. Returns one index per cell (by cell.index).\n */\nexport function colorCells(layout: Layout, colors: number): number[] {\n const byId = new Map(layout.cells.map((c) => [c.id, c.index]));\n const out: number[] = new Array(layout.cells.length).fill(-1);\n for (const c of layout.cells) {\n const used = new Set<number>();\n for (const n of c.neighbors) {\n const k = byId.get(n);\n if (k !== undefined && out[k]! >= 0) used.add(out[k]!);\n }\n let pick = 0;\n // Rotate the starting color so large single-color runs are avoided.\n for (let s = 0; s < colors; s++) {\n const cand = (c.index + s) % colors;\n if (!used.has(cand)) {\n pick = cand;\n break;\n }\n }\n out[c.index] = pick;\n }\n return out;\n}\n","import { area, bbox, centroid, type Polygon, type Rect, type Vec } from \"./geometry\";\nimport type { Cell, Layout } from \"./layout\";\nimport { pointInPolygon } from \"./offset\";\nimport { inShapes, overlay, shapeArea, type Shape } from \"./overlay\";\nimport { roundedPolygon } from \"./rounding\";\n\n/** The shape a renderer draws for a cell, before the layout's `view` hides any of it. */\nexport interface CellShape {\n /** Sharp-cornered outline: `cell.tile` for a window cell, else `cell.polygon`. */\n outline: Polygon;\n holes: Polygon[];\n /** Bounding box of `outline`: where a renderer places the cell's element. */\n bbox: Rect;\n centroid: Vec;\n area: number;\n}\n\nconst shapes = new WeakMap<Cell, CellShape>();\n\n/**\n * The shape to draw for a cell: the whole tile for a cell an `edges: \"window\"` layout cuts\n * (`cell.tile`), otherwise the cell's own polygon and holes. Renderers round, bevel and\n * place content in this, then hide what lies outside `layout.view` (see `visibleShapes`).\n */\nexport function cellShape(cell: Cell): CellShape {\n let s = shapes.get(cell);\n if (!s) {\n s = cell.tile\n ? { outline: cell.tile, holes: [], bbox: bbox(cell.tile), centroid: centroid(cell.tile), area: area(cell.tile) }\n : { outline: cell.polygon, holes: cell.holes ?? [], bbox: cell.bbox, centroid: cell.centroid, area: cell.area };\n shapes.set(cell, s);\n }\n return s;\n}\n\nconst visible = new WeakMap<Cell, Map<number, Shape[]>>();\n\n/**\n * What of a cell shows, with the layout's rounded corners: its rounded shape (see\n * `cellShape`), less whatever lies outside `layout.view` in a window layout, where the cut\n * is sharp. One shape for most cells; a window cell the region outline cuts in two has\n * more, largest first.\n */\nexport function visibleShapes(cell: Cell, layout: Pick<Layout, \"cornerRadius\" | \"view\">): Shape[] {\n const r = layout.cornerRadius;\n let byRadius = visible.get(cell);\n if (!byRadius) visible.set(cell, (byRadius = new Map()));\n const hit = byRadius.get(r);\n if (hit) return hit;\n const s = cellShape(cell);\n const outer = roundedPolygon(s.outline, r);\n let result: Shape[] = [{ outer, holes: s.holes.map((h) => roundedPolygon(h, r)) }];\n if (cell.tile && layout.view?.length) {\n // The rounded whole tile, cut (sharply) to the view.\n const loops = layout.view.flatMap((v) => [v.outer, ...v.holes]);\n const b = s.bbox;\n const scale = Math.max(b.width, b.height) || 1;\n const cut = overlay([outer, ...loops], (p) => pointInPolygon(p, outer) && inShapes(p, loops), scale)\n .filter((q) => shapeArea(q) > 1e-9 * scale * scale)\n .sort((p, q) => shapeArea(q) - shapeArea(p));\n if (cut.length) result = cut;\n }\n byRadius.set(r, result);\n return result;\n}\n","import { bbox, type Polygon, type Rect, type Vec } from \"./geometry\";\nimport type { Cell, Layout } from \"./layout\";\nimport { shapeArea, shapeCentroid } from \"./overlay\";\nimport { roundedPolygon } from \"./rounding\";\nimport { cellShape, visibleShapes } from \"./shape\";\n\nexport interface SafeAreaOptions {\n /**\n * Width / height the area must have (an image or card of known shape, say). Omit for\n * the largest-area rectangle of any shape (for text and other content that reflows).\n */\n aspect?: number;\n /**\n * For a cell an `edges: \"window\"` layout cuts: \"tile\" (the default) fits the whole tile,\n * as if the region weren't there, so content near the edge is partly hidden like the\n * tile; \"visible\" fits the part that shows. Other cells are the same either way.\n */\n within?: \"tile\" | \"visible\";\n}\n\n/**\n * The largest axis-aligned rectangle that fits wholly inside a cell's shape (its outline,\n * holes and rounded corners), so content placed there isn't clipped. With `aspect`, the\n * largest rectangle of that shape. Among equally large positions it picks the one nearest\n * the cell's center. In layout coordinates; see `safeAreaCss` for CSS.\n *\n * Works for any shape, convex or not. Results are cached per cell.\n */\nexport function safeArea(cell: Cell, layout: Pick<Layout, \"cornerRadius\" | \"view\">, options: SafeAreaOptions = {}): Rect {\n const radius = layout.cornerRadius;\n const fixed = options.aspect !== undefined && options.aspect > 0 && Number.isFinite(options.aspect) ? options.aspect : undefined;\n const within = cell.tile && options.within === \"visible\" && layout.view ? \"visible\" : \"tile\";\n const key = `${radius}:${fixed ?? \"free\"}:${within}`;\n let cached = cache.get(cell);\n if (!cached) cache.set(cell, (cached = new Map()));\n const hit = cached.get(key);\n if (hit) return hit;\n let target: Target;\n if (within === \"visible\") {\n const piece = visibleShapes(cell, layout)[0]!;\n target = { outline: piece.outer, holes: piece.holes, rounded: true, bbox: bbox(piece.outer), centroid: shapeCentroid(piece), area: shapeArea(piece) };\n } else {\n const s = cellShape(cell);\n target = { outline: s.outline, holes: s.holes, rounded: false, bbox: s.bbox, centroid: s.centroid, area: s.area };\n }\n const result = compute(target, radius, fixed);\n cached.set(key, result);\n return result;\n}\n\nconst cache = new WeakMap<Cell, Map<string, Rect>>();\n\n/** The shape to fit in: an outline (sharp, or already rounded) with its holes. */\ninterface Target {\n outline: Polygon;\n holes: Polygon[];\n rounded: boolean;\n bbox: Rect;\n centroid: Vec;\n area: number;\n}\n\nfunction compute(cell: Target, radius: number, aspect: number | undefined): Rect {\n const b = cell.bbox;\n const r = cell.rounded ? 0 : radius;\n const outline = roundedPolygon(cell.outline, r);\n const holes = cell.holes.map((h) => roundedPolygon(h, r));\n const empty = { x: cell.centroid.x, y: cell.centroid.y, width: 0, height: 0 };\n if (outline.length < 3 || !(b.width > 0) || !(b.height > 0)) return empty;\n\n // An axis-aligned rectangle is its own answer.\n if (holes.length === 0 && outline.length === 4 && Math.abs(cell.area - b.width * b.height) <= 1e-9 * b.width * b.height) {\n if (aspect === undefined) return { ...b };\n const w = Math.min(b.width, b.height * aspect);\n const h = w / aspect;\n return { x: b.x + (b.width - w) / 2, y: b.y + (b.height - h) / 2, width: w, height: h };\n }\n\n const loops = [outline, ...holes];\n if (aspect !== undefined) return fitAspect(loops, cell, aspect, 1e-3).rect;\n // The search over aspects uses a coarser tolerance, then the winner is refined.\n const fit = (a: number) => fitAspect(loops, cell, a, 1e-2);\n\n // Any shape: search the aspect ratio for the largest area. A coarse scan around the\n // bounding box's shape, then golden-section refinement around the best sample.\n const mid = Math.log(b.width / b.height);\n const span = 2, steps = 8;\n const area = (la: number) => fit(Math.exp(la));\n let best = area(mid), bestLa = mid;\n for (let k = 0; k <= steps; k++) {\n const la = mid - span + (2 * span * k) / steps;\n const r = k === steps / 2 ? best : area(la);\n if (r.area > best.area) { best = r; bestLa = la; }\n }\n let lo = bestLa - (2 * span) / steps, hi = bestLa + (2 * span) / steps;\n const g = (Math.sqrt(5) - 1) / 2;\n let x1 = hi - g * (hi - lo), x2 = lo + g * (hi - lo);\n let f1 = area(x1), f2 = area(x2);\n for (let it = 0; it < 10; it++) {\n if (f1.area >= f2.area) { hi = x2; x2 = x1; f2 = f1; x1 = hi - g * (hi - lo); f1 = area(x1); }\n else { lo = x1; x1 = x2; f1 = f2; x2 = lo + g * (hi - lo); f2 = area(x2); }\n }\n if (f1.area > best.area) { best = f1; bestLa = x1; }\n if (f2.area > best.area) { best = f2; bestLa = x2; }\n return fitAspect(loops, cell, Math.exp(bestLa), 1e-3).rect;\n}\n\n/**\n * Largest rectangle of aspect `a`. Scaling x by 1/√a and y by √a turns it into the largest\n * square, i.e. the point farthest from the outline in the L∞ (chessboard) distance, which\n * a branch-and-bound over square cells finds (as polylabel does for circles).\n */\nfunction fitAspect(loops: Polygon[], cell: { centroid: Vec }, a: number, tolerance: number): { rect: Rect; area: number } {\n const sx = 1 / Math.sqrt(a), sy = Math.sqrt(a);\n // Segments in scaled space, flat: ax, ay, bx, by.\n const segs: number[] = [];\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n for (const loop of loops) {\n for (let i = 0, n = loop.length; i < n; i++) {\n const p = loop[i]!, q = loop[(i + 1) % n]!;\n segs.push(p.x * sx, p.y * sy, q.x * sx, q.y * sy);\n }\n }\n for (const p of loops[0]!) {\n minX = Math.min(minX, p.x * sx); maxX = Math.max(maxX, p.x * sx);\n minY = Math.min(minY, p.y * sy); maxY = Math.max(maxY, p.y * sy);\n }\n const tx = cell.centroid.x * sx, ty = cell.centroid.y * sy;\n const size = Math.min(maxX - minX, maxY - minY);\n const precision = size * tolerance;\n // Prefer the center among near-equal positions; small enough not to move a unique best.\n const lambda = 1e-2;\n\n /** Signed L∞ distance to the outline: positive inside. */\n const dist = (x: number, y: number) => {\n let inside = false;\n let d = Infinity;\n for (let s = 0; s < segs.length; s += 4) {\n const ax = segs[s]!, ay = segs[s + 1]!, bx = segs[s + 2]!, by = segs[s + 3]!;\n if (ay > y !== by > y && x < ((bx - ax) * (y - ay)) / (by - ay) + ax) inside = !inside;\n d = Math.min(d, chebyshevToSegment(ax - x, ay - y, bx - ax, by - ay));\n }\n return inside ? d : -d;\n };\n const score = (x: number, y: number, d: number) => d - lambda * Math.hypot(x - tx, y - ty);\n\n type Node = { x: number; y: number; h: number; d: number; bound: number };\n const node = (x: number, y: number, h: number): Node => {\n const d = dist(x, y);\n const off = Math.max(0, Math.hypot(x - tx, y - ty) - h * Math.SQRT2);\n return { x, y, h, d, bound: d + h - lambda * off };\n };\n\n const heap = new MaxHeap<Node>((n) => n.bound);\n const w = maxX - minX, hgt = maxY - minY;\n const cellSize = size;\n for (let x = minX; x < maxX; x += cellSize) {\n for (let y = minY; y < maxY; y += cellSize) heap.push(node(x + cellSize / 2, y + cellSize / 2, cellSize / 2));\n }\n let best = { x: tx, y: ty, d: dist(tx, ty) };\n let bestScore = score(best.x, best.y, best.d);\n const bboxCenter = { x: minX + w / 2, y: minY + hgt / 2 };\n const bd = dist(bboxCenter.x, bboxCenter.y);\n if (score(bboxCenter.x, bboxCenter.y, bd) > bestScore) { best = { ...bboxCenter, d: bd }; bestScore = score(best.x, best.y, bd); }\n\n for (let guard = 0; heap.size > 0 && guard < 20000; guard++) {\n const n = heap.pop()!;\n const s = score(n.x, n.y, n.d);\n if (s > bestScore) { best = n; bestScore = s; }\n if (n.bound - bestScore <= precision) continue;\n const h = n.h / 2;\n heap.push(node(n.x - h, n.y - h, h));\n heap.push(node(n.x + h, n.y - h, h));\n heap.push(node(n.x - h, n.y + h, h));\n heap.push(node(n.x + h, n.y + h, h));\n }\n\n const t = Math.max(0, best.d);\n const cx = best.x / sx, cy = best.y / sy;\n const hw = t / sx, hh = t / sy;\n return { rect: { x: cx - hw, y: cy - hh, width: 2 * hw, height: 2 * hh }, area: 4 * t * t };\n}\n\n/** min over u in [0, 1] of max(|px + u dx|, |py + u dy|): the L∞ distance from the origin to a segment. */\nfunction chebyshevToSegment(px: number, py: number, dx: number, dy: number): number {\n const at = (u: number) => Math.max(Math.abs(px + u * dx), Math.abs(py + u * dy));\n let d = Math.min(at(0), at(1));\n // The function is convex and piecewise linear; its kinks are where a coordinate is 0\n // or where |x| = |y|.\n const tryU = (num: number, den: number) => {\n if (den === 0) return;\n const u = num / den;\n if (u > 0 && u < 1) d = Math.min(d, at(u));\n };\n tryU(-px, dx);\n tryU(-py, dy);\n tryU(py - px, dx - dy);\n tryU(-px - py, dx + dy);\n return d;\n}\n\nclass MaxHeap<T> {\n private items: T[] = [];\n constructor(private key: (t: T) => number) {}\n get size() { return this.items.length; }\n push(t: T) {\n const a = this.items;\n a.push(t);\n for (let i = a.length - 1; i > 0; ) {\n const p = (i - 1) >> 1;\n if (this.key(a[p]!) >= this.key(a[i]!)) break;\n [a[p], a[i]] = [a[i]!, a[p]!];\n i = p;\n }\n }\n pop(): T | undefined {\n const a = this.items;\n if (a.length === 0) return undefined;\n const top = a[0]!;\n const last = a.pop()!;\n if (a.length > 0) {\n a[0] = last;\n for (let i = 0; ; ) {\n const l = 2 * i + 1, r = l + 1;\n let m = i;\n if (l < a.length && this.key(a[l]!) > this.key(a[m]!)) m = l;\n if (r < a.length && this.key(a[r]!) > this.key(a[m]!)) m = r;\n if (m === i) break;\n [a[m], a[i]] = [a[i]!, a[m]!];\n i = m;\n }\n }\n return top;\n }\n}\n","import { signedArea, type Polygon, type Rect, type Vec } from \"./geometry\";\nimport type { Cell, Layout } from \"./layout\";\nimport type { Shape } from \"./overlay\";\nimport { safeArea, type SafeAreaOptions } from \"./safe\";\nimport { roundCorners } from \"./rounding\";\nimport { ensurePositive } from \"./geometry\";\nimport { inShapes } from \"./overlay\";\nimport { cellShape, visibleShapes } from \"./shape\";\n\n/**\n * CSS placement for one cell, as percentages of the layout bounds, so the result\n * scales with whatever size the container is rendered at.\n *\n * Apply to an absolutely positioned element inside a `position: relative`\n * container whose aspect ratio matches `layout.bounds`\n * (see `boundsAspectRatio`). Works with any framework, or none.\n */\nexport interface CellCss {\n left: string;\n top: string;\n width: string;\n height: string;\n /** A `polygon(...)` clip path relative to the element's own box. */\n clipPath: string;\n}\n\nconst pct = (n: number, precision: number) => `${Number(n.toFixed(precision))}%`;\n\n/**\n * `polygon(...)` for `poly`, expressed as percentages of `box`. With `holes`, it's an\n * even–odd polygon that visits each hole from the outline's first point and comes back,\n * so the connecting lines cancel out.\n */\nexport function cssPolygon(poly: Polygon, box: Rect, precision = 4, holes: Polygon[] = []): string {\n const pt = (v: { x: number; y: number }) =>\n `${pct(box.width ? ((v.x - box.x) / box.width) * 100 : 0, precision)} ` +\n `${pct(box.height ? ((v.y - box.y) / box.height) * 100 : 0, precision)}`;\n const pts = poly.map(pt);\n if (holes.length === 0 || poly.length === 0) return `polygon(${pts.join(\", \")})`;\n const first = pt(poly[0]!);\n for (const h of holes) {\n if (h.length === 0) continue;\n pts.push(first, ...h.map(pt), pt(h[0]!));\n }\n pts.push(first);\n return `polygon(evenodd, ${pts.join(\", \")})`;\n}\n\n/**\n * `poly` with points added along its edges to make exactly `n`, keeping every original\n * vertex, so any two shapes can be morphed point by point (CSS transitions only interpolate\n * `polygon()` values with the same number of points). The points run the same way round\n * for every shape and start at the corner nearest the top left of `box`, so a shape\n * morphs into another without twisting. A polygon with more than `n` points is returned\n * as it is.\n */\nexport function resamplePolygon(poly: Polygon, n: number, box: Rect): Polygon {\n if (poly.length < 3 || poly.length > n) return poly;\n // In box-relative units, so tall and wide tiles start and spread their points alike.\n const w = box.width || 1, h = box.height || 1;\n let pts = poly.map((p) => ({ u: (p.x - box.x) / w, v: (p.y - box.y) / h, p }));\n if (signedArea(poly) < 0) pts = pts.reverse();\n let start = 0;\n for (let i = 1; i < pts.length; i++) if (pts[i]!.u + pts[i]!.v < pts[start]!.u + pts[start]!.v - 1e-9) start = i;\n pts = [...pts.slice(start), ...pts.slice(0, start)];\n const m = pts.length;\n const lens = pts.map((a, i) => Math.hypot(pts[(i + 1) % m]!.u - a.u, pts[(i + 1) % m]!.v - a.v));\n const total = lens.reduce((s, l) => s + l, 0) || 1;\n // Each edge keeps its start point; the extra points go to edges by length (largest remainder).\n const extra = n - m;\n const share = lens.map((l) => (l / total) * extra);\n const count = share.map(Math.floor);\n let left = extra - count.reduce((s, c) => s + c, 0);\n const order = share.map((s, i) => [s - Math.floor(s), i] as const).sort((a, b) => b[0] - a[0] || a[1] - b[1]);\n for (let k = 0; left > 0; k++, left--) count[order[k % m]![1]]! += 1;\n const out: Vec[] = [];\n for (let i = 0; i < m; i++) {\n const a = pts[i]!.p, b = pts[(i + 1) % m]!.p;\n out.push(a);\n for (let k = 1; k <= count[i]!; k++) {\n const t = k / (count[i]! + 1);\n out.push({ x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t });\n }\n }\n return out;\n}\n\n/**\n * `poly` with its corners rounded (by `radius`, or a radius per corner) as at least `n`\n * points, laid out the same way whatever the radius: each corner gets a fixed number of\n * points by how far the outline turns there (one per 10°, all on the vertex when it's sharp,\n * spread along the arc when it's rounded), and the rest go along the edges by the sharp\n * outline's edge lengths. So a tile morphs smoothly as its corner radius changes, as well as\n * into other shapes (see `resamplePolygon` for the start point and direction). Shapes with\n * too many corners for `n` (merged featured tiles, say) get more points: the next multiple\n * of 24 that fits, so most tiles share one count and can morph into each other.\n */\nexport function morphPolygon(poly: Polygon, radius: number | readonly number[], n: number, box: Rect): Polygon {\n const m = poly.length;\n if (m < 3) return poly;\n let pts = poly.map((p, i) => ({ p, r: typeof radius === \"number\" ? radius : (radius[i] ?? 0) }));\n if (signedArea(poly) < 0) pts = pts.reverse();\n const w = box.width || 1, h = box.height || 1;\n const key = (p: Vec) => (p.x - box.x) / w + (p.y - box.y) / h;\n let start = 0;\n for (let i = 1; i < m; i++) if (key(pts[i]!.p) < key(pts[start]!.p) - 1e-9) start = i;\n pts = [...pts.slice(start), ...pts.slice(0, start)];\n const sharp = pts.map((q) => q.p);\n const corners = roundCorners(sharp, pts.map((q) => q.r));\n // Points per corner: one per 10° the outline turns there, plus one (from the sharp shape,\n // so the same at any radius).\n const per = sharp.map((v, i) => {\n const a = sharp[(i - 1 + m) % m]!, b = sharp[(i + 1) % m]!;\n let turn = Math.atan2(b.y - v.y, b.x - v.x) - Math.atan2(v.y - a.y, v.x - a.x);\n turn = Math.abs(((turn + 3 * Math.PI) % (2 * Math.PI)) - Math.PI);\n return 1 + Math.ceil(turn / (Math.PI / 18) - 1e-6);\n });\n const onCorners = per.reduce((s, k) => s + k, 0);\n // At least one point along each edge, for morphing into shapes with corners there.\n if (onCorners + m > n) n = Math.ceil((onCorners + m) / 24) * 24;\n const lens = sharp.map((a, i) => Math.hypot(sharp[(i + 1) % m]!.x - a.x, sharp[(i + 1) % m]!.y - a.y));\n const total = lens.reduce((s, l) => s + l, 0) || 1;\n const extra = n - onCorners;\n const share = lens.map((l) => (l / total) * extra);\n const count = share.map(Math.floor);\n let left = extra - count.reduce((s, c) => s + c, 0);\n const order = share.map((s, i) => [s - Math.floor(s), i] as const).sort((a, b) => b[0] - a[0] || a[1] - b[1]);\n for (let k = 0; left > 0; k++, left--) count[order[k % m]![1]]! += 1;\n const out: Vec[] = [];\n for (let i = 0; i < m; i++) {\n const c = corners[i]!;\n out.push(...arcPoints(c, per[i]!));\n // Along the straight part of the edge, from this corner's arc to the next one's.\n const a = c.end, b = corners[(i + 1) % m]!.start;\n for (let k = 1; k <= count[i]!; k++) {\n const t = k / (count[i]! + 1);\n out.push({ x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t });\n }\n }\n return out;\n}\n\n/**\n * `pts` (a closed outline, positively oriented, as from `morphPolygon`) cut to `view`\n * without changing its point count: each run of points outside the view is laid along the\n * view's edge from where the outline leaves it to where it comes back, through the view's\n * corners on the way. Points inside stay put, so the result morphs as smoothly as `pts`.\n * Undefined when that can't describe the cut (nothing inside, or the outline leaving by one\n * loop of the view and coming back by another); draw the exact shape then.\n */\nfunction cutToView(pts: Vec[], view: readonly Shape[]): Vec[] | undefined {\n // Outlines with the view on their left, as the tile's: outers positive, holes negative.\n const loops = view.flatMap((v) => [ensurePositive(v.outer), ...v.holes.map((h) => ensurePositive(h).slice().reverse())]);\n const n = pts.length;\n // Points on the view's edge count as inside: they're on the cut shape's outline either way.\n let lo = Infinity, hi = -Infinity;\n for (const p of pts) { lo = Math.min(lo, p.x, p.y); hi = Math.max(hi, p.x, p.y); }\n const eps = 1e-7 * (hi - lo || 1);\n const inside = pts.map((p) => inShapes(p, loops) || nearEdge(p, loops, eps));\n const first = inside.indexOf(true);\n if (first < 0) return undefined;\n if (inside.every(Boolean)) return pts;\n const out = pts.slice();\n // Walk the runs of outside points, starting just after an inside one.\n for (let k = 1; k <= n; ) {\n const i = (first + k) % n;\n if (inside[i]) { k++; continue; }\n let len = 0;\n while (!inside[(i + len) % n]) len++;\n const before = pts[(i - 1 + n) % n]!, after = pts[(i + len) % n]!;\n const exit = crossing(before, pts[i]!, loops), entry = crossing(after, pts[(i + len - 1) % n]!, loops);\n if (!exit || !entry || exit.loop !== entry.loop) return undefined;\n const path = viewPath(loops[exit.loop]!, exit, entry);\n placeAlong(path, len).forEach((p, j) => (out[(i + j) % n] = p));\n k += len;\n }\n return out;\n}\n\nfunction nearEdge(p: Vec, loops: Polygon[], eps: number): boolean {\n for (const loop of loops) {\n for (let e = 0, m = loop.length; e < m; e++) {\n const a = loop[e]!, b = loop[(e + 1) % m]!;\n const dx = b.x - a.x, dy = b.y - a.y;\n const t = Math.max(0, Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / (dx * dx + dy * dy || 1)));\n if (Math.hypot(p.x - a.x - t * dx, p.y - a.y - t * dy) <= eps) return true;\n }\n }\n return false;\n}\n\ninterface Crossing { loop: number; edge: number; t: number; point: Vec }\n\n/** Where the segment from `from` (inside the view) towards `to` first meets the view's edge. */\nfunction crossing(from: Vec, to: Vec, loops: Polygon[]): Crossing | undefined {\n let best: Crossing | undefined, bestU = Infinity;\n const dx = to.x - from.x, dy = to.y - from.y;\n loops.forEach((loop, l) => {\n for (let e = 0, m = loop.length; e < m; e++) {\n const a = loop[e]!, b = loop[(e + 1) % m]!;\n const ex = b.x - a.x, ey = b.y - a.y;\n const den = dx * ey - dy * ex;\n if (den === 0) continue;\n const u = ((a.x - from.x) * ey - (a.y - from.y) * ex) / den;\n const t = ((a.x - from.x) * dy - (a.y - from.y) * dx) / den;\n if (u >= -1e-9 && u <= 1 + 1e-9 && t >= -1e-9 && t <= 1 + 1e-9 && u < bestU) {\n bestU = u;\n best = { loop: l, edge: e, t, point: { x: from.x + dx * u, y: from.y + dy * u } };\n }\n }\n });\n return best;\n}\n\n/** The view's edge from `exit` forwards to `entry`, through the corners between. */\nfunction viewPath(loop: Polygon, exit: Crossing, entry: Crossing): Vec[] {\n const path = [exit.point];\n if (exit.edge === entry.edge && entry.t >= exit.t) return [...path, entry.point];\n const m = loop.length;\n for (let e = exit.edge; ; e = (e + 1) % m) {\n path.push(loop[(e + 1) % m]!);\n if ((e + 1) % m === entry.edge) break;\n }\n return [...path, entry.point];\n}\n\n/**\n * `k` points along `path`: its ends and corners first (as many as fit), the rest spread\n * along its segments by length, so the cut keeps its sharp corners.\n */\nfunction placeAlong(path: Vec[], k: number): Vec[] {\n if (k === 1) return [path[0]!];\n let keep = path;\n if (keep.length > k) {\n // Not enough points for every corner: keep the ends and as many corners as fit, evenly.\n keep = Array.from({ length: k }, (_, j) => path[Math.round((j * (path.length - 1)) / (k - 1))]!);\n }\n const segs = keep.length - 1;\n const lens = keep.slice(1).map((p, j) => Math.hypot(p.x - keep[j]!.x, p.y - keep[j]!.y));\n const total = lens.reduce((s, l) => s + l, 0) || 1;\n const extra = k - keep.length;\n const share = lens.map((l) => (l / total) * extra);\n const count = share.map(Math.floor);\n let left = extra - count.reduce((s, c) => s + c, 0);\n const order = share.map((s, j) => [s - Math.floor(s), j] as const).sort((a, b) => b[0] - a[0] || a[1] - b[1]);\n for (let q = 0; left > 0; q++, left--) count[order[q % segs]![1]]! += 1;\n const out: Vec[] = [];\n for (let j = 0; j < segs; j++) {\n const a = keep[j]!, b = keep[j + 1]!;\n out.push(a);\n for (let q = 1; q <= count[j]!; q++) {\n const t = q / (count[j]! + 1);\n out.push({ x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t });\n }\n }\n out.push(keep[keep.length - 1]!);\n return out;\n}\n\n/** `k` points along a rounded corner's arc, start to end (all on the vertex when it's sharp). */\nfunction arcPoints(c: ReturnType<typeof roundCorners>[number], k: number): Vec[] {\n if (c.radius === 0) return Array.from({ length: k }, () => c.vertex);\n if (k === 1) {\n const a = Math.atan2(c.start.y - c.center.y, c.start.x - c.center.x) + c.sweep / 2;\n return [{ x: c.center.x + c.radius * Math.cos(a), y: c.center.y + c.radius * Math.sin(a) }];\n }\n const a0 = Math.atan2(c.start.y - c.center.y, c.start.x - c.center.x);\n return Array.from({ length: k }, (_, s) => {\n const a = a0 + (c.sweep * s) / (k - 1);\n return { x: c.center.x + c.radius * Math.cos(a), y: c.center.y + c.radius * Math.sin(a) };\n });\n}\n\n/** Options for `cellCss`. */\nexport interface CellCssOptions {\n /**\n * Give every clip path this many points (see `morphPolygon`), so CSS can animate one tile\n * shape into another. Shapes with many corners (merged featured tiles) get more, in steps\n * of 24; cells with holes keep their own.\n */\n points?: number;\n}\n\n/**\n * `polygon(...)` for several shapes (outlines with holes) at once: an even–odd polygon\n * that visits each extra loop from the first outline's first point and comes back.\n */\nexport function cssShapes(shapes: readonly Shape[], box: Rect, precision = 4): string {\n if (shapes.length === 0) return \"polygon(0 0)\";\n const [first, ...rest] = shapes;\n return cssPolygon(first!.outer, box, precision, [...first!.holes, ...rest.flatMap((s) => [s.outer, ...s.holes])]);\n}\n\n/**\n * CSS placement for `cell` within `layout`, including rounded corners if the layout has\n * them. A window cell (see `cellShape`) is placed over its whole tile and clipped to the\n * part of it inside `layout.view`.\n */\nexport function cellCss(cell: Cell, layout: Layout, precision = 4, options: CellCssOptions = {}): CellCss {\n const { bounds } = layout;\n const b = cellShape(cell).bbox;\n const shapes = visibleShapes(cell, layout);\n const single = shapes.length === 1 && shapes[0]!.holes.length === 0;\n let morph: Polygon | undefined;\n if (options.points && single) {\n const s = cellShape(cell);\n morph = morphPolygon(s.outline, layout.cornerRadius, options.points, b);\n // A window cell: the whole tile's points, with those outside the view moved onto its edge.\n if (cell.tile && layout.view) morph = cutToView(morph, layout.view);\n }\n return {\n left: pct(((b.x - bounds.x) / bounds.width) * 100, precision),\n top: pct(((b.y - bounds.y) / bounds.height) * 100, precision),\n width: pct((b.width / bounds.width) * 100, precision),\n height: pct((b.height / bounds.height) * 100, precision),\n clipPath:\n morph ? cssPolygon(morph, b, precision) : cssShapes(shapes, b, precision),\n };\n}\n\n/**\n * Placement, inside a cell's element (as positioned by `cellCss`), of a box covering the\n * whole layout bounds. Put the same content (an image with `object-fit: cover`, say) in\n * every cell at this placement and the cells together show it as one picture, each\n * through its own window.\n */\nexport function backdropCss(cell: Cell, layout: Layout, precision = 4): Omit<CellCss, \"clipPath\"> {\n const { bounds } = layout;\n const b = cellShape(cell).bbox;\n const w = b.width || 1;\n const h = b.height || 1;\n return {\n left: pct(((bounds.x - b.x) / w) * 100, precision),\n top: pct(((bounds.y - b.y) / h) * 100, precision),\n width: pct((bounds.width / w) * 100, precision),\n height: pct((bounds.height / h) * 100, precision),\n };\n}\n\n/**\n * Placement, inside a cell's element (as positioned by `cellCss`), of the cell's safe area\n * (see `safeArea`): the largest rectangle that isn't clipped by the tile's shape.\n */\nexport function safeAreaCss(cell: Cell, layout: Layout, options: SafeAreaOptions = {}, precision = 4): Omit<CellCss, \"clipPath\"> {\n const b = cellShape(cell).bbox;\n const s = safeArea(cell, layout, options);\n const w = b.width || 1;\n const h = b.height || 1;\n return {\n left: pct(((s.x - b.x) / w) * 100, precision),\n top: pct(((s.y - b.y) / h) * 100, precision),\n width: pct((s.width / w) * 100, precision),\n height: pct((s.height / h) * 100, precision),\n };\n}\n\n/** `polygon(...)` for the layout's region, with its holes, relative to the bounds. */\nexport function regionCss(layout: Layout, precision = 4): string {\n return cssPolygon(layout.region, layout.bounds, precision, layout.holes);\n}\n\n/**\n * `polygon(...)` for the area tiles show in, relative to the bounds: `layout.view` in a\n * window layout, else the region with its holes.\n */\nexport function viewCss(layout: Layout, precision = 4): string {\n return layout.view ? cssShapes(layout.view, layout.bounds, precision) : regionCss(layout, precision);\n}\n\n/** Value for the CSS `aspect-ratio` property of a container holding `layout`. */\nexport function boundsAspectRatio(layout: Layout): string {\n return `${layout.bounds.width} / ${layout.bounds.height}`;\n}\n","import { vec, type Polygon, type Vec } from \"./geometry\";\nimport type { Cell, Layout } from \"./layout\";\nimport { pointInPolygon } from \"./offset\";\nimport { roundCorners } from \"./rounding\";\nimport { cellShape, type CellShape } from \"./shape\";\n\n/**\n * Where light comes from, as a unit vector pointing from the surface towards the light.\n * `angle` is in degrees clockwise from the top, like CSS angles: 0 from above, 90 from the\n * right, 315 (the default) from the top left.\n */\nexport function lightVector(angle = 315): Vec {\n const a = (angle * Math.PI) / 180;\n return vec(Math.sin(a), -Math.cos(a));\n}\n\nexport interface BevelOptions {\n /** Width of the bevel, in layout units. Narrowed per cell where the shape is too thin. */\n width: number;\n /** Direction the light comes from: degrees clockwise from the top (default 315, top left). */\n light?: number;\n}\n\n/** One sloped face of a bevel. */\nexport interface BevelFacet {\n polygon: Polygon;\n /**\n * How much the face turns towards the light, from 1 (straight at it: draw a highlight)\n * through 0 to -1 (straight away: draw a shadow).\n */\n shade: number;\n}\n\n/**\n * The bevel round a cell's edges (outline, holes and rounded corners; the whole tile for a\n * window cell, see `cellShape`), as a band of\n * sloped faces `width` wide, each shaded by how it faces the light. Draw light faces with\n * translucent white and dark ones with translucent black over the cell, and the tile looks\n * raised, like a real tile or tessera. The band is narrowed where a cell is too thin for it.\n */\nexport function bevelFacets(cell: Cell, layout: Pick<Layout, \"cornerRadius\">, options: BevelOptions): BevelFacet[] {\n const want = Math.max(0, options.width);\n const shape = cellShape(cell);\n if (want === 0 || shape.outline.length < 3) return [];\n const loops = [shape.outline, ...shape.holes].map((p) => prepare(p, shape, layout.cornerRadius)).filter((l) => l.outer.length >= 3);\n if (loops.length === 0) return [];\n\n // Narrow the band until the inner outline is clean.\n let d = want;\n if (!valid(loops, d)) {\n let lo = 0, hi = want;\n for (let it = 0; it < 14; it++) {\n const mid = (lo + hi) / 2;\n if (valid(loops, mid)) lo = mid;\n else hi = mid;\n }\n d = lo;\n }\n if (d <= 0) return [];\n\n const light = lightVector(options.light);\n const facets: BevelFacet[] = [];\n for (const loop of loops) {\n const inner = innerLoop(loop, d);\n const { outer, normal } = loop;\n for (let i = 0, n = outer.length; i < n; i++) {\n const j = (i + 1) % n;\n const a = outer[i]!, b = outer[j]!;\n if (a.x === b.x && a.y === b.y) continue;\n // The face slopes down towards the outside: it faces the outward normal.\n const shade = -(normal[i]!.x * light.x + normal[i]!.y * light.y);\n facets.push({ polygon: [a, b, inner[j]!, inner[i]!], shade });\n }\n }\n return facets;\n}\n\n/**\n * A loop's outline points (as drawn, with rounded corners), the inward normal of the edge\n * from each point to the next, and how each point moves inwards as the band widens.\n */\ninterface Loop {\n outer: Vec[];\n normal: Vec[];\n /** Per point: a rounded-corner arc point (center, radius, convex) or a sharp corner. */\n kind: ({ arc: true; center: Vec; radius: number; convex: boolean; vertex: Vec; n1: Vec; n2: Vec } | { arc: false; n1: Vec; n2: Vec })[];\n}\n\nfunction prepare(poly: Polygon, cell: CellShape, radius: number): Loop {\n const corners = roundCorners(poly, radius);\n const n = poly.length;\n // Which side of the loop is the tile: test a point just left of the longest edge.\n let li = 0, ll = -1;\n for (let i = 0; i < n; i++) {\n const a = poly[i]!, b = poly[(i + 1) % n]!;\n const l = Math.hypot(b.x - a.x, b.y - a.y);\n if (l > ll) { ll = l; li = i; }\n }\n const a = poly[li]!, b = poly[(li + 1) % n]!;\n const eps = 1e-6 * Math.max(cell.bbox.width, cell.bbox.height, 1e-12);\n const left = vec(-(b.y - a.y) / ll, (b.x - a.x) / ll);\n const probe = vec((a.x + b.x) / 2 + left.x * eps, (a.y + b.y) / 2 + left.y * eps);\n const inside = pointInPolygon(probe, cell.outline) && !cell.holes.some((h) => pointInPolygon(probe, h));\n const side = inside ? 1 : -1;\n const inward = (p: Vec, q: Vec): Vec => {\n const l = Math.hypot(q.x - p.x, q.y - p.y) || 1;\n return vec((-(q.y - p.y) / l) * side, ((q.x - p.x) / l) * side);\n };\n\n const outer: Vec[] = [];\n const kind: Loop[\"kind\"] = [];\n for (let i = 0; i < n; i++) {\n const c = corners[i]!;\n // The nearest distinct neighbors: outlines can repeat a point.\n const same = (p: Vec, q: Vec) => Math.abs(p.x - q.x) <= eps * 1e-3 && Math.abs(p.y - q.y) <= eps * 1e-3;\n let prev = poly[(i - 1 + n) % n]!, next = poly[(i + 1) % n]!;\n for (let k = 2; k < n && same(prev, c.vertex); k++) prev = poly[(i - k + n) % n]!;\n for (let k = 2; k < n && same(next, c.vertex); k++) next = poly[(i + k) % n]!;\n const n1 = inward(prev, c.vertex), n2 = inward(c.vertex, next);\n if (c.radius === 0) {\n outer.push(c.vertex);\n kind.push({ arc: false, n1, n2 });\n continue;\n }\n // The same sampling as roundedPolygon, so the bevel lines up with the clip path.\n const steps = Math.max(1, Math.ceil(Math.abs(c.sweep) / (Math.PI / 18)));\n const a0 = Math.atan2(c.start.y - c.center.y, c.start.x - c.center.x);\n // Convex (seen from the tile) when the center is on the tile side of the edge.\n const convex = (c.center.x - c.vertex.x) * n1.x + (c.center.y - c.vertex.y) * n1.y > 0;\n for (let s = 0; s <= steps; s++) {\n const p = s === 0 ? c.start : s === steps ? c.end : vec(c.center.x + c.radius * Math.cos(a0 + (c.sweep * s) / steps), c.center.y + c.radius * Math.sin(a0 + (c.sweep * s) / steps));\n outer.push(p);\n kind.push({ arc: true, center: c.center, radius: c.radius, convex, vertex: c.vertex, n1, n2 });\n }\n }\n const normal = outer.map((p, i) => inward(p, outer[(i + 1) % outer.length]!));\n // Drop repeated points (an arc meeting the next corner's arc at an edge's midpoint).\n const keep = outer.map((p, i) => {\n const q = outer[(i + 1) % outer.length]!;\n return Math.hypot(q.x - p.x, q.y - p.y) > eps * 1e-3;\n });\n return {\n outer: outer.filter((_, i) => keep[i]),\n normal: normal.filter((_, i) => keep[i]),\n kind: kind.filter((_, i) => keep[i]),\n };\n}\n\n/** Where the two edges at a sharp corner meet once both have moved in by `d`. */\nconst miter = (v: Vec, n1: Vec, n2: Vec, d: number): Vec => {\n const k = d / Math.max(1e-9, 1 + n1.x * n2.x + n1.y * n2.y);\n return vec(v.x + (n1.x + n2.x) * k, v.y + (n1.y + n2.y) * k);\n};\n\nfunction innerLoop(loop: Loop, d: number): Vec[] {\n return loop.outer.map((p, i) => {\n const k = loop.kind[i]!;\n if (!k.arc) return miter(p, k.n1, k.n2, d);\n // Arcs offset to concentric arcs; a convex one narrower than the band becomes the\n // sharp corner where the straight edges' offsets meet.\n const r = k.convex ? k.radius - d : k.radius + d;\n if (r <= 0) return miter(k.vertex, k.n1, k.n2, d);\n const ux = p.x - k.center.x, uy = p.y - k.center.y;\n const l = Math.hypot(ux, uy) || 1;\n return vec(k.center.x + (ux / l) * r, k.center.y + (uy / l) * r);\n });\n}\n\n/** The inner outlines at width `d` keep every edge's direction and don't cross. */\nfunction valid(loops: Loop[], d: number): boolean {\n const segs: [Vec, Vec][] = [];\n for (const loop of loops) {\n const inner = innerLoop(loop, d);\n const n = inner.length;\n for (let i = 0; i < n; i++) {\n const a = loop.outer[i]!, b = loop.outer[(i + 1) % n]!;\n const p = inner[i]!, q = inner[(i + 1) % n]!;\n const len = Math.hypot(b.x - a.x, b.y - a.y);\n // An inner edge pointing backwards means the band folded over.\n if ((q.x - p.x) * (b.x - a.x) + (q.y - p.y) * (b.y - a.y) < -1e-9 * len * len) return false;\n if (Math.hypot(q.x - p.x, q.y - p.y) > 1e-9 * len) segs.push([p, q]);\n }\n }\n for (let i = 0; i < segs.length; i++) {\n for (let j = i + 1; j < segs.length; j++) {\n if (crosses(segs[i]![0], segs[i]![1], segs[j]![0], segs[j]![1])) return false;\n }\n }\n return true;\n}\n\n/** Proper crossing: each segment's ends strictly on opposite sides of the other. */\nfunction crosses(a: Vec, b: Vec, c: Vec, d: Vec): boolean {\n const o = (p: Vec, q: Vec, r: Vec) => (q.x - p.x) * (r.y - p.y) - (q.y - p.y) * (r.x - p.x);\n const s1 = Math.hypot(b.x - a.x, b.y - a.y), s2 = Math.hypot(d.x - c.x, d.y - c.y);\n const tol = 1e-9 * s1 * s2;\n const d1 = o(a, b, c), d2 = o(a, b, d), d3 = o(c, d, a), d4 = o(c, d, b);\n return ((d1 > tol && d2 < -tol) || (d1 < -tol && d2 > tol)) && ((d3 > tol && d4 < -tol) || (d3 < -tol && d4 > tol));\n}\n","import type { Cell, Layout } from \"./layout\";\n\nexport type Direction = \"up\" | \"down\" | \"left\" | \"right\";\n\nconst DIRS: Record<Direction, [number, number]> = { up: [0, -1], down: [0, 1], left: [-1, 0], right: [1, 0] };\n\n/**\n * The cell to move to from `from` in a direction, for arrow-key navigation over any tiling.\n *\n * Looks at cells whose center lies ahead (within 60° of the direction first, then anywhere\n * ahead) and picks the nearest, with sideways distance counting double, so moving keeps to\n * a \"row\" or \"column\" where the tiling has one. `accept` limits it to some cells (those\n * with content, say). Returns undefined at the edge.\n */\nexport function cellInDirection(layout: Layout, from: Cell, direction: Direction, accept: (cell: Cell) => boolean = () => true): Cell | undefined {\n const [dx, dy] = DIRS[direction];\n const size = Math.sqrt(Math.max(from.area, 1e-12));\n const eps = 1e-6 * size;\n const cone = Math.tan(Math.PI / 3);\n let best: Cell | undefined, bestScore = Infinity;\n let fallback: Cell | undefined, fallbackScore = Infinity;\n for (const c of layout.cells) {\n if (c === from || !accept(c)) continue;\n const ox = c.centroid.x - from.centroid.x, oy = c.centroid.y - from.centroid.y;\n const along = ox * dx + oy * dy;\n if (along <= eps) continue;\n const across = Math.abs(ox * dy - oy * dx);\n const score = along + 2 * across;\n if (across <= along * cone) {\n if (score < bestScore - eps || (Math.abs(score - bestScore) <= eps && best && c.index < best.index)) { best = c; bestScore = score; }\n } else if (score < fallbackScore - eps || (Math.abs(score - fallbackScore) <= eps && fallback && c.index < fallback.index)) {\n fallback = c;\n fallbackScore = score;\n }\n }\n return best ?? fallback;\n}\n","import { bbox, vec, type Polygon, type Rect, type Vec } from \"./geometry\";\nimport type { Cell, Layout } from \"./layout\";\nimport { inShapes } from \"./overlay\";\nimport { visibleShapes } from \"./shape\";\n\n/**\n * Hit testing: which cell is under a point, or near it, or inside a rectangle. Uses each\n * cell's visible shape (gap, rounded corners and holes included) and a spatial index built\n * once per layout, so lookups stay fast for tens of thousands of cells.\n */\n\ninterface Index {\n /** Visible outlines per cell (by position in `layout.cells`): every piece's outline and holes, even–odd. */\n loops: Polygon[][];\n /** Bounding box of each cell's visible shape. */\n boxes: Rect[];\n x0: number;\n y0: number;\n size: number;\n cols: number;\n rows: number;\n /** Cell positions per bucket. */\n buckets: number[][];\n}\n\nconst indexes = new WeakMap<Layout, Index>();\n\nfunction index(layout: Layout): Index {\n const hit = indexes.get(layout);\n if (hit) return hit;\n const cells = layout.cells;\n const loops = cells.map((c) => visibleShapes(c, layout).flatMap((s) => [s.outer, ...s.holes]));\n const boxes = loops.map((ls) => (ls.length ? bbox(ls.flat()) : { x: 0, y: 0, width: 0, height: 0 }));\n // Cells may stick out of the bounds (\"overflow\"), so index their own extent.\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const b of boxes) {\n x0 = Math.min(x0, b.x); y0 = Math.min(y0, b.y);\n x1 = Math.max(x1, b.x + b.width); y1 = Math.max(y1, b.y + b.height);\n }\n if (!cells.length) { x0 = y0 = 0; x1 = y1 = 1; }\n // Buckets about the size of a typical cell.\n const mean = boxes.reduce((s, b) => s + b.width * b.height, 0) / Math.max(1, cells.length);\n const size = Math.max(Math.sqrt(mean), (x1 - x0 + y1 - y0) / 2048, 1e-9);\n const cols = Math.max(1, Math.ceil((x1 - x0) / size)), rows = Math.max(1, Math.ceil((y1 - y0) / size));\n const buckets: number[][] = Array.from({ length: cols * rows }, () => []);\n boxes.forEach((b, i) => {\n const [ca, ra, cb, rb] = span(b, x0, y0, size, cols, rows);\n for (let r = ra; r <= rb; r++) for (let q = ca; q <= cb; q++) buckets[r * cols + q]!.push(i);\n });\n const built = { loops, boxes, x0, y0, size, cols, rows, buckets };\n indexes.set(layout, built);\n return built;\n}\n\n/** Bucket columns and rows a rectangle covers (clamped to the grid). */\nfunction span(r: Rect, x0: number, y0: number, size: number, cols: number, rows: number): [number, number, number, number] {\n const clamp = (v: number, n: number) => Math.min(n - 1, Math.max(0, v));\n return [\n clamp(Math.floor((r.x - x0) / size), cols),\n clamp(Math.floor((r.y - y0) / size), rows),\n clamp(Math.floor((r.x + r.width - x0) / size), cols),\n clamp(Math.floor((r.y + r.height - y0) / size), rows),\n ];\n}\n\n/** Cells whose bounding boxes might meet `r`, each once, in reading order. */\nfunction candidates(ix: Index, r: Rect): number[] {\n const [ca, ra, cb, rb] = span(r, ix.x0, ix.y0, ix.size, ix.cols, ix.rows);\n const out = new Set<number>();\n for (let row = ra; row <= rb; row++) for (let q = ca; q <= cb; q++) for (const i of ix.buckets[row * ix.cols + q]!) out.add(i);\n return [...out].sort((a, b) => a - b);\n}\n\nconst inLoops = (p: Vec, loops: Polygon[]) => inShapes(p, loops);\n\n/** Distance from `p` to the nearest edge of any of `loops`. */\nfunction edgeDistance(p: Vec, loops: Polygon[]): number {\n let best = Infinity;\n for (const loop of loops) {\n for (let i = 0, n = loop.length; i < n; i++) {\n const a = loop[i]!, b = loop[(i + 1) % n]!;\n const dx = b.x - a.x, dy = b.y - a.y;\n const t = Math.max(0, Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / (dx * dx + dy * dy || 1)));\n best = Math.min(best, Math.hypot(p.x - a.x - t * dx, p.y - a.y - t * dy));\n }\n }\n return best;\n}\n\nexport interface HitOptions {\n /**\n * Also count points this far outside a cell (in layout units): in the gap between\n * tiles, or just past a rounded corner. The nearest cell wins. Handy for touch. Default 0.\n */\n tolerance?: number;\n}\n\n/** The cell whose visible shape contains `point` (in layout units), or undefined. */\nexport function cellAt(layout: Layout, point: Vec, options: HitOptions = {}): Cell | undefined {\n const ix = index(layout);\n for (const i of candidates(ix, { x: point.x, y: point.y, width: 0, height: 0 })) {\n if (inLoops(point, ix.loops[i]!)) return layout.cells[i];\n }\n const tolerance = options.tolerance ?? 0;\n return tolerance > 0 ? nearestCell(layout, point, tolerance) : undefined;\n}\n\n/**\n * The cell nearest `point`: the one containing it, or else the one whose edge is closest.\n * With `maxDistance`, only cells within that distance count.\n */\nexport function nearestCell(layout: Layout, point: Vec, maxDistance = Infinity): Cell | undefined {\n const ix = index(layout);\n if (!layout.cells.length) return undefined;\n const at = cellAt(layout, point);\n if (at) return at;\n // Widen a square round the point bucket by bucket: once it reaches `reach` on every side,\n // any cell not yet seen is at least that far away.\n let best: number | undefined, bestD = Infinity;\n const seen = new Set<number>();\n const visit = (i: number) => {\n if (seen.has(i)) return;\n seen.add(i);\n const d = edgeDistance(point, ix.loops[i]!);\n if (d < bestD) { bestD = d; best = i; }\n };\n const inside = point.x >= ix.x0 && point.y >= ix.y0 && point.x <= ix.x0 + ix.cols * ix.size && point.y <= ix.y0 + ix.rows * ix.size;\n let done = false;\n if (inside) {\n for (let ring = 0; ring <= Math.max(ix.cols, ix.rows) + 1; ring++) {\n const reach = ring * ix.size;\n for (const i of candidates(ix, { x: point.x - reach, y: point.y - reach, width: 2 * reach, height: 2 * reach })) visit(i);\n if (reach >= Math.min(bestD, maxDistance)) { done = true; break; }\n }\n }\n // Points outside the indexed area (rare): check every cell.\n if (!done) layout.cells.forEach((_, i) => visit(i));\n return best !== undefined && bestD <= maxDistance ? layout.cells[best] : undefined;\n}\n\n/**\n * Cells meeting a rectangle (in layout units), in reading order: for marquee selection, or\n * finding what's in view. With `contain`, only cells wholly inside it.\n */\nexport function cellsInRect(layout: Layout, rect: Rect, options: { contain?: boolean } = {}): Cell[] {\n const ix = index(layout);\n const r = normalize(rect);\n const out: Cell[] = [];\n for (const i of candidates(ix, r)) {\n const c = layout.cells[i]!;\n const b = ix.boxes[i]!;\n if (b.x > r.x + r.width || b.x + b.width < r.x || b.y > r.y + r.height || b.y + b.height < r.y) continue;\n const loops = ix.loops[i]!;\n if (options.contain) {\n // Inside the rectangle when its outline is (holes lie within the outline).\n if (loops.every((l) => l.every((p) => p.x >= r.x && p.x <= r.x + r.width && p.y >= r.y && p.y <= r.y + r.height))) out.push(c);\n } else if (meets(loops, r)) out.push(c);\n }\n return out;\n}\n\nfunction normalize(r: Rect): Rect {\n const x = Math.min(r.x, r.x + r.width), y = Math.min(r.y, r.y + r.height);\n return { x, y, width: Math.abs(r.width), height: Math.abs(r.height) };\n}\n\n/** A shape and a rectangle overlap: a point of one inside the other, or edges crossing. */\nfunction meets(loops: Polygon[], r: Rect): boolean {\n const inRect = (p: Vec) => p.x >= r.x && p.x <= r.x + r.width && p.y >= r.y && p.y <= r.y + r.height;\n if (loops.some((l) => l.some(inRect))) return true;\n const corners = [vec(r.x, r.y), vec(r.x + r.width, r.y), vec(r.x + r.width, r.y + r.height), vec(r.x, r.y + r.height)];\n if (corners.some((p) => inLoops(p, loops))) return true;\n // Edges crossing the rectangle's sides (e.g. a thin sliver passing through it).\n for (const loop of loops) {\n for (let i = 0, n = loop.length; i < n; i++) {\n const a = loop[i]!, b = loop[(i + 1) % n]!;\n for (let k = 0; k < 4; k++) if (segmentsCross(a, b, corners[k]!, corners[(k + 1) % 4]!)) return true;\n }\n }\n return false;\n}\n\nfunction segmentsCross(a: Vec, b: Vec, c: Vec, d: Vec): boolean {\n const o = (p: Vec, q: Vec, s: Vec) => Math.sign((q.x - p.x) * (s.y - p.y) - (q.y - p.y) * (s.x - p.x));\n return o(a, b, c) !== o(a, b, d) && o(c, d, a) !== o(c, d, b);\n}\n\n/** The on-screen box of the element showing a layout (e.g. from `getBoundingClientRect()`). */\nexport interface ScreenBox {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\n/**\n * Convert a screen point (e.g. a pointer event's `clientX`, `clientY`) to layout units,\n * given the box of the element the layout fills: a `<TileLayout>` container, an `<svg>`\n * with the layout's viewBox, or a canvas you drew it on. Like SVG's default\n * `preserveAspectRatio`, the layout is taken to be scaled to fit the box and centerd.\n */\nexport function screenToLayout(layout: Layout, box: ScreenBox, clientX: number, clientY: number): Vec {\n const b = layout.bounds;\n const scale = Math.min(box.width / (b.width || 1), box.height / (b.height || 1)) || 1;\n const ox = box.left + (box.width - b.width * scale) / 2;\n const oy = box.top + (box.height - b.height * scale) / 2;\n return vec(b.x + (clientX - ox) / scale, b.y + (clientY - oy) / scale);\n}\n","import { centroid } from \"./geometry\";\nimport { cellShape } from \"./shape\";\nimport type { Cell, Layout } from \"./layout\";\n\n/**\n * Which cells may hold content:\n * - \"all\": every cell.\n * - \"whole\": only cells shown in full (not cut by the region outline; see `Cell.boundary`).\n * - a function: your own test.\n */\nexport type ContentCells = \"all\" | \"whole\" | ((cell: Cell) => boolean);\n\n/**\n * Where content goes when there are fewer items than cells that may hold content:\n * - \"reading\": the first cells in reading order (content packs to the top left).\n * - \"center\": the cells nearest the middle of the region.\n * - \"spread\": cells spread evenly over the region.\n * Items always fill the chosen cells in reading order.\n */\nexport type ContentPlacement = \"reading\" | \"center\" | \"spread\";\n\nexport interface ContentOptions {\n cells?: ContentCells;\n placement?: ContentPlacement;\n}\n\n/**\n * Assign `count` content items to cells. Featured cells (see `LayoutOptions.features`)\n * take the items their features name (`Feature.item`), or else the first items, in feature\n * order; the rest follow `placement`, in item order and reading order.\n * Returns one entry per cell (by `cell.index`):\n * the index of the item it holds, or -1 for an empty cell. Pass `Infinity` to number\n * every cell that may hold content.\n */\nexport function contentSlots(layout: Layout, count: number, options: ContentOptions = {}): number[] {\n const { cells = \"all\", placement = \"reading\" } = options;\n const accept = cells === \"all\" ? () => true : cells === \"whole\" ? (c: Cell) => !c.boundary : cells;\n const out: number[] = new Array(layout.cells.length).fill(-1);\n const total = Math.max(0, Math.floor(count));\n // Featured cells come first: the items they name, else the first items in `features` order.\n const used = featuredItems(layout, total, accept);\n for (const [cell, item] of used) out[cell] = item;\n\n // layout.cells is in reading order, so filtering keeps it.\n const eligible = layout.cells.filter((c) => out[c.index] === -1 && accept(c));\n const rest = remainingItems(total, used, eligible.length);\n const n = Math.max(0, Math.min(rest.length, eligible.length));\n\n let chosen: Cell[];\n if (n === eligible.length) chosen = eligible;\n else if (placement === \"center\") chosen = nearestToCenter(layout, eligible, n);\n else if (placement === \"spread\") chosen = spread(eligible, n);\n else chosen = eligible.slice(0, n);\n\n chosen.sort((a, b) => a.index - b.index).forEach((c, k) => (out[c.index] = rest[k]!));\n return out;\n}\n\n/**\n * Featured cells' items (cell index → item): the item each feature names, or the next item\n * not named by any. A tile cut in two only puts its item in its first part; features whose\n * item is past `total` stay empty (and free for other items).\n */\nfunction featuredItems(layout: Layout, total: number, accept: (c: Cell) => boolean): Map<number, number> {\n const cells = layout.cells\n .filter((c) => c.featured !== undefined && accept(c))\n .sort((a, b) => a.featured! - b.featured! || a.index - b.index);\n const named = new Set(cells.map((c) => c.featuredItem).filter((i): i is number => i !== undefined));\n const out = new Map<number, number>();\n const taken = new Set<number>();\n const seen = new Set<number>();\n let next = 0;\n for (const c of cells) {\n if (seen.has(c.featured!)) continue;\n let item = c.featuredItem;\n if (item === undefined) {\n while (named.has(next) || taken.has(next)) next++;\n item = next;\n }\n if (item < 0 || item >= total || taken.has(item)) continue;\n seen.add(c.featured!);\n taken.add(item);\n out.set(c.index, item);\n }\n return out;\n}\n\n/** The first `max` of items 0 … total - 1 not already in a featured cell, in order. */\nfunction remainingItems(total: number, used: Map<number, number>, max: number): number[] {\n const taken = new Set(used.values());\n const rest: number[] = [];\n for (let i = 0; i < total && rest.length < max; i++) if (!taken.has(i)) rest.push(i);\n return rest;\n}\n\nexport interface MatchOptions extends ContentOptions {\n /**\n * Which cells get items:\n * - \"placement\" (default): the same cells as without matching (`placement`); matching\n * only decides which item goes where among them.\n * - \"shape\": the cells whose shapes suit the items best, wherever they are (portrait\n * photos into the vertical bricks of a herringbone, say). Ignores `placement`.\n */\n choose?: \"placement\" | \"shape\";\n}\n\n/**\n * Like `contentSlots`, but puts each item in a cell of similar shape, so content shown with\n * `object-fit: cover` loses as little as possible to cropping. `aspects` gives each item's\n * width / height (one per item, in item order); a cell's shape is its bounding box, which\n * is what content is laid out in.\n *\n * Featured cells still take their items first (see `contentSlots`). The rest are matched to\n * minimize the total crop (measured as the difference in log aspect ratio, which is optimal\n * to match by sorting both sides). Returns the item index per cell (by `cell.index`), or -1.\n */\nexport function matchSlots(layout: Layout, aspects: readonly number[], options: MatchOptions = {}): number[] {\n const { cells = \"all\", choose = \"placement\" } = options;\n const accept = cells === \"all\" ? () => true : cells === \"whole\" ? (c: Cell) => !c.boundary : cells;\n const logAspect = (a: number) => (a > 0 && Number.isFinite(a) ? Math.log(a) : 0);\n const cellLog = (c: Cell) => { const b = cellShape(c).bbox; return logAspect(b.width / (b.height || 1)); };\n\n // Featured cells and (for \"placement\") the cells to use come from contentSlots.\n const base = contentSlots(layout, aspects.length, options);\n const out: number[] = new Array(layout.cells.length).fill(-1);\n const used = featuredItems(layout, aspects.length, accept);\n for (const [cell, item] of used) out[cell] = item;\n const rest = remainingItems(aspects.length, used, Infinity);\n\n let pool: Cell[];\n if (choose === \"shape\") pool = layout.cells.filter((c) => out[c.index] === -1 && accept(c));\n else pool = layout.cells.filter((c) => out[c.index] === -1 && base[c.index]! >= 0);\n // Items beyond the cells available stay out, as with contentSlots: the first ones are kept.\n const k = Math.min(rest.length, pool.length);\n if (k <= 0) return out;\n const items = rest.slice(0, k).sort((a, b) => logAspect(aspects[a]!) - logAspect(aspects[b]!) || a - b);\n const sorted = [...pool].sort((a, b) => cellLog(a) - cellLog(b) || a.index - b.index);\n\n let picked: Cell[];\n if (k === sorted.length) picked = sorted;\n else picked = bestSubset(items.map((i) => logAspect(aspects[i]!)), sorted.map(cellLog)).map((j) => sorted[j]!);\n items.forEach((item, i) => (out[picked[i]!.index] = item));\n return out;\n}\n\n/**\n * Choose `a.length` of the (sorted) values `c` to pair, in order, with the (sorted) values\n * `a`, minimizing the total |a - c|. Order-preserving pairings are optimal for this cost,\n * so a dynamic program over (items, cells) finds the best. Returns the chosen indices of `c`.\n */\nfunction bestSubset(a: number[], c: number[]): number[] {\n const n = a.length, m = c.length;\n // take bit (i, j): item i-1 pairs with cell j-1 in the best solution of the subproblem.\n const take = new Uint8Array(Math.ceil((n * (m + 1)) / 8) + 1);\n const setBit = (i: number, j: number) => {\n const b = (i - 1) * (m + 1) + j;\n take[b >> 3]! |= 1 << (b & 7);\n };\n const bit = (i: number, j: number) => {\n const b = (i - 1) * (m + 1) + j;\n return (take[b >> 3]! >> (b & 7)) & 1;\n };\n let prev = new Float64Array(m + 1); // row i - 1 (row 0: no items, cost 0)\n let cur = new Float64Array(m + 1);\n for (let i = 1; i <= n; i++) {\n cur.fill(Infinity, 0, i);\n for (let j = i; j <= m; j++) {\n const skip = cur[j - 1]!;\n const pair = prev[j - 1]! + Math.abs(a[i - 1]! - c[j - 1]!);\n if (pair <= skip) {\n cur[j] = pair;\n setBit(i, j);\n } else cur[j] = skip;\n }\n [prev, cur] = [cur, prev];\n }\n const chosen: number[] = [];\n for (let i = n, j = m; i > 0; j--) {\n if (bit(i, j)) {\n chosen.push(j - 1);\n i--;\n }\n }\n return chosen.reverse();\n}\n\nfunction nearestToCenter(layout: Layout, cells: Cell[], n: number): Cell[] {\n const mid = centroid(layout.region);\n const d = (c: Cell) => (c.centroid.x - mid.x) ** 2 + (c.centroid.y - mid.y) ** 2;\n return cells\n .map((c) => ({ c, d: d(c) }))\n .sort((a, b) => a.d - b.d || a.c.index - b.c.index)\n .slice(0, n)\n .map((e) => e.c);\n}\n\n/**\n * `n` cells spread evenly: k-means on cell centers (seeded by farthest-point sampling, so\n * it's deterministic), then the cell nearest each cluster center. The iteration count is\n * capped so very large layouts stay fast; the seeding alone is already well spread.\n */\nfunction spread(cells: Cell[], n: number): Cell[] {\n if (n === 0) return [];\n const m = cells.length;\n const xs = Float64Array.from(cells, (c) => c.centroid.x);\n const ys = Float64Array.from(cells, (c) => c.centroid.y);\n const ws = Float64Array.from(cells, (c) => c.area);\n\n // Farthest-point seeding, starting from the cell nearest the overall (area-weighted) center.\n let sx = 0, sy = 0, sw = 0;\n for (let i = 0; i < m; i++) { sx += xs[i]! * ws[i]!; sy += ys[i]! * ws[i]!; sw += ws[i]!; }\n sx /= sw || 1; sy /= sw || 1;\n const best = new Float64Array(m).fill(Infinity);\n const cx = new Float64Array(n);\n const cy = new Float64Array(n);\n let next = 0;\n for (let j = 0, bd = Infinity; j < m; j++) {\n const d = (xs[j]! - sx) ** 2 + (ys[j]! - sy) ** 2;\n if (d < bd) { bd = d; next = j; }\n }\n for (let k = 0; k < n; k++) {\n cx[k] = xs[next]!; cy[k] = ys[next]!;\n let far = -1, fi = 0;\n for (let j = 0; j < m; j++) {\n const d = (xs[j]! - cx[k]!) ** 2 + (ys[j]! - cy[k]!) ** 2;\n if (d < best[j]!) best[j] = d;\n if (best[j]! > far) { far = best[j]!; fi = j; }\n }\n next = fi;\n }\n\n // Lloyd iterations.\n const assign = new Int32Array(m);\n const iterations = Math.min(20, Math.floor(3e7 / (m * n)));\n for (let it = 0; it < iterations; it++) {\n for (let j = 0; j < m; j++) {\n let bd = Infinity, bk = 0;\n for (let k = 0; k < n; k++) {\n const d = (xs[j]! - cx[k]!) ** 2 + (ys[j]! - cy[k]!) ** 2;\n if (d < bd) { bd = d; bk = k; }\n }\n assign[j] = bk;\n }\n const ax = new Float64Array(n), ay = new Float64Array(n), aw = new Float64Array(n);\n for (let j = 0; j < m; j++) {\n const k = assign[j]!;\n ax[k] += xs[j]! * ws[j]!; ay[k] += ys[j]! * ws[j]!; aw[k] += ws[j]!;\n }\n let moved = false;\n for (let k = 0; k < n; k++) {\n if (aw[k]! === 0) continue;\n const nx = ax[k]! / aw[k]!, ny = ay[k]! / aw[k]!;\n if (nx !== cx[k] || ny !== cy[k]) moved = true;\n cx[k] = nx; cy[k] = ny;\n }\n if (!moved) break;\n }\n\n // The nearest still-free cell to each center.\n const taken = new Uint8Array(m);\n const chosen: Cell[] = [];\n for (let k = 0; k < n; k++) {\n let bd = Infinity, bj = -1;\n for (let j = 0; j < m; j++) {\n if (taken[j]) continue;\n const d = (xs[j]! - cx[k]!) ** 2 + (ys[j]! - cy[k]!) ** 2;\n if (d < bd) { bd = d; bj = j; }\n }\n taken[bj] = 1;\n chosen.push(cells[bj]!);\n }\n return chosen;\n}\n","import { colorCells, type Cell, type Layout } from \"./layout\";\nimport { pointInPolygon } from \"./offset\";\nimport { mulberry32 } from \"./random\";\n\n/**\n * A color per cell. Renderers' `fill` props accept these; they're plain functions, so\n * you can also call them yourself (`fill(cell, layout)`) for other renderers.\n */\nexport type CellFill = (cell: Cell, layout: Layout) => string;\n\n/** Neighboring cells get different colors from `colors` (as far as the palette allows). */\nexport function paletteFill(colors: readonly string[]): CellFill {\n if (colors.length === 0) throw new RangeError(\"paletteFill needs at least one color\");\n const cache = new WeakMap<Layout, number[]>();\n return (cell, layout) => {\n let indices = cache.get(layout);\n if (!indices) {\n indices = colorCells(layout, colors.length);\n cache.set(layout, indices);\n }\n return colors[indices[cell.index] ?? 0]!;\n };\n}\n\n/** One color per prototile, e.g. herringbone's horizontal and vertical bricks. */\nexport function protoTileFill(colors: readonly string[]): CellFill {\n if (colors.length === 0) throw new RangeError(\"protoTileFill needs at least one color\");\n return (cell) => colors[cell.protoTile % colors.length]!;\n}\n\n/**\n * A random color per cell. The choice depends only on the cell's id and `seed`, so a tile\n * keeps its color when the layout is resized or the region changes.\n */\nexport function randomFill(colors: readonly string[], seed = 1): CellFill {\n if (colors.length === 0) throw new RangeError(\"randomFill needs at least one color\");\n return (cell) => colors[Math.floor(mulberry32(hashString(cell.id) ^ Math.imul(seed, 0x9e3779b1))() * colors.length)]!;\n}\n\nexport interface GradientOptions {\n /**\n * Direction of a linear gradient in degrees: 0 runs left to right, 90 top to bottom\n * (y grows downward). Defaults to 0.\n */\n angle?: number;\n /** \"radial\" runs from the region's center (first stop) out to its corners (last stop). */\n shape?: \"linear\" | \"radial\";\n}\n\n/**\n * Color by position: each cell takes the gradient's color at its centroid. Stops are hex\n * colors (#rgb or #rrggbb), spaced evenly and blended in the OKLab color space, which\n * keeps the middle of the gradient from going muddy.\n */\nexport function gradientFill(stops: readonly string[], options: GradientOptions = {}): CellFill {\n if (stops.length === 0) throw new RangeError(\"gradientFill needs at least one color\");\n const labs = stops.map((s) => srgbToOklab(parseHex(s)));\n const { angle = 0, shape = \"linear\" } = options;\n const dx = Math.cos((angle * Math.PI) / 180);\n const dy = Math.sin((angle * Math.PI) / 180);\n return (cell, layout) => {\n const b = layout.bounds;\n const cx = b.x + b.width / 2;\n const cy = b.y + b.height / 2;\n const px = cell.centroid.x - cx;\n const py = cell.centroid.y - cy;\n let t: number;\n if (shape === \"radial\") {\n t = Math.hypot(px, py) / (Math.hypot(b.width, b.height) / 2 || 1);\n } else {\n // Project onto the direction; the region's corners map to 0 and 1.\n const half = (Math.abs(dx) * b.width + Math.abs(dy) * b.height) / 2 || 1;\n t = ((px * dx + py * dy) / half + 1) / 2;\n }\n return toHex(oklabToSrgb(sample(labs, Math.min(1, Math.max(0, t)))));\n };\n}\n\ntype Triple = [number, number, number];\n\nfunction sample(stops: Triple[], t: number): Triple {\n if (stops.length === 1) return stops[0]!;\n const x = t * (stops.length - 1);\n const i = Math.min(stops.length - 2, Math.floor(x));\n const f = x - i;\n const a = stops[i]!;\n const b = stops[i + 1]!;\n return [a[0] + (b[0] - a[0]) * f, a[1] + (b[1] - a[1]) * f, a[2] + (b[2] - a[2]) * f];\n}\n\nfunction hashString(s: string): number {\n let h = 2166136261;\n for (let i = 0; i < s.length; i++) h = Math.imul(h ^ s.charCodeAt(i), 16777619);\n return h >>> 0;\n}\n\nfunction parseHex(s: string, who = \"gradientFill\"): Triple {\n const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(s.trim());\n if (!m) throw new RangeError(`${who} needs hex colors like \"#e9d8a6\" (got ${JSON.stringify(s)})`);\n const h = m[1]!.length === 3 ? [...m[1]!].map((c) => c + c).join(\"\") : m[1]!;\n return [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16) / 255) as Triple;\n}\n\nfunction toHex(c: Triple): string {\n return \"#\" + c.map((v) => Math.round(Math.min(1, Math.max(0, v)) * 255).toString(16).padStart(2, \"0\")).join(\"\");\n}\n\nconst toLinear = (v: number) => (v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);\nconst fromLinear = (v: number) => (v <= 0.0031308 ? v * 12.92 : 1.055 * v ** (1 / 2.4) - 0.055);\n\nfunction srgbToOklab(c: Triple): Triple {\n const [r, g, b] = c.map(toLinear) as Triple;\n const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);\n const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);\n const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);\n return [\n 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,\n 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,\n 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,\n ];\n}\n\nfunction oklabToSrgb([L, a, b]: Triple): Triple {\n const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;\n const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;\n const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;\n return [\n 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,\n ].map((v) => fromLinear(Math.max(0, v))) as Triple;\n}\n\n/** Pixels as RGBA bytes, row by row: what a canvas's `getImageData` returns. */\nexport interface Pixels {\n width: number;\n height: number;\n data: ArrayLike<number>;\n}\n\nexport interface ImageFillOptions {\n /**\n * How the image is laid over the layout bounds: \"cover\" (default; cropped to fill them,\n * centerd, like the `backdrop` prop), \"contain\" (whole image, centerd) or \"stretch\".\n */\n fit?: \"cover\" | \"contain\" | \"stretch\";\n /**\n * Snap each tile's color to the nearest of these hex colors (judged in OKLab), as if\n * choosing from a box of real mosaic tiles. Omit for the exact average.\n */\n palette?: readonly string[];\n /** Color for tiles with no image under them (with \"contain\", or a transparent image). */\n fallback?: string;\n /** Most pixels sampled per tile; more is smoother but slower. Defaults to 256. */\n samples?: number;\n}\n\n/**\n * Color each tile with the average color of the image under it, for a mosaic. Averages are\n * taken in linear light (as the eye would mix the colors from a distance) and weighted by\n * alpha. Colors are computed once per layout, on first use.\n *\n * `pixels` is plain RGBA data, so this works anywhere; in a browser, `loadImagePixels` gets\n * it from a URL.\n */\nexport function imageFill(pixels: Pixels, options: ImageFillOptions = {}): CellFill {\n const { fit = \"cover\", fallback = \"#d6d3d1\", samples = 256 } = options;\n const palette = options.palette?.map((c) => ({ hex: toHex(parseHex(c, \"imageFill\")), lab: srgbToOklab(parseHex(c, \"imageFill\")) }));\n const lin = Array.from({ length: 256 }, (_, i) => toLinear(i / 255));\n const { width: iw, height: ih, data } = pixels;\n const cache = new WeakMap<Layout, string[]>();\n\n const colorsFor = (layout: Layout): string[] => {\n const b = layout.bounds;\n // Layout point → image pixel: x' = (x - b.x) * sx + ox.\n let sx = iw / (b.width || 1), sy = ih / (b.height || 1);\n if (fit !== \"stretch\") {\n const k = fit === \"cover\" ? Math.min(sx, sy) : Math.max(sx, sy);\n sx = sy = k;\n }\n const ox = (iw - b.width * sx) / 2, oy = (ih - b.height * sy) / 2;\n\n return layout.cells.map((cell) => {\n const bb = cell.bbox;\n const pxW = bb.width * sx, pxH = bb.height * sy;\n // Sample a grid over the cell's box, at most `samples` points, at least 1 pixel apart.\n const step = Math.max(1, Math.sqrt((pxW * pxH) / Math.max(1, samples)));\n let r = 0, g = 0, bl = 0, w = 0;\n const add = (x: number, y: number) => {\n const px = Math.floor((x - b.x) * sx + ox), py = Math.floor((y - b.y) * sy + oy);\n if (px < 0 || py < 0 || px >= iw || py >= ih) return;\n const i = (py * iw + px) * 4;\n const a = data[i + 3]! / 255;\n if (a <= 0) return;\n r += lin[data[i]!]! * a;\n g += lin[data[i + 1]!]! * a;\n bl += lin[data[i + 2]!]! * a;\n w += a;\n };\n const inside = (x: number, y: number) =>\n pointInPolygon({ x, y }, cell.polygon) && !(cell.holes ?? []).some((h) => pointInPolygon({ x, y }, h));\n const nx = Math.max(1, Math.round(pxW / step)), ny = Math.max(1, Math.round(pxH / step));\n for (let i = 0; i < nx; i++) {\n for (let j = 0; j < ny; j++) {\n const x = bb.x + ((i + 0.5) / nx) * bb.width, y = bb.y + ((j + 0.5) / ny) * bb.height;\n if (inside(x, y)) add(x, y);\n }\n }\n // A tile too thin for the grid to land in: use its center.\n if (w === 0) add(cell.centroid.x, cell.centroid.y);\n if (w === 0) return fallback;\n const avg: Triple = [fromLinear(r / w), fromLinear(g / w), fromLinear(bl / w)];\n if (!palette?.length) return toHex(avg);\n const lab = srgbToOklab(avg);\n let best = palette[0]!, bd = Infinity;\n for (const p of palette) {\n const d = (p.lab[0] - lab[0]) ** 2 + (p.lab[1] - lab[1]) ** 2 + (p.lab[2] - lab[2]) ** 2;\n if (d < bd) { bd = d; best = p; }\n }\n return best.hex;\n });\n };\n\n return (cell, layout) => {\n let colors = cache.get(layout);\n if (!colors) {\n colors = colorsFor(layout);\n cache.set(layout, colors);\n }\n return colors[cell.index] ?? fallback;\n };\n}\n\n/**\n * Browser helper: load an image and read its pixels, scaled down so the longer side is at\n * most `maxSize` (plenty for averaging, and fast). The image must be same-origin, a data\n * URL, or served with CORS headers; otherwise the browser refuses to read its pixels.\n */\nexport async function loadImagePixels(src: string, maxSize = 256): Promise<Pixels> {\n const doc = (globalThis as { document?: Document }).document;\n if (!doc) throw new Error(\"loadImagePixels needs a browser; elsewhere, decode the image yourself and pass its RGBA pixels\");\n const img = new Image();\n img.crossOrigin = \"anonymous\";\n img.decoding = \"async\";\n await new Promise<void>((resolve, reject) => {\n img.onload = () => resolve();\n img.onerror = () => reject(new Error(`Couldn't load image ${src.slice(0, 80)}`));\n img.src = src;\n });\n const k = Math.min(1, maxSize / Math.max(img.naturalWidth || 1, img.naturalHeight || 1));\n const w = Math.max(1, Math.round((img.naturalWidth || maxSize) * k));\n const h = Math.max(1, Math.round((img.naturalHeight || maxSize) * k));\n const canvas = doc.createElement(\"canvas\");\n canvas.width = w;\n canvas.height = h;\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) throw new Error(\"loadImagePixels: no 2D canvas available\");\n ctx.drawImage(img, 0, 0, w, h);\n return ctx.getImageData(0, 0, w, h);\n}\n","import type { ContentCells } from \"./content\";\nimport { createLayout, type Cell, type Layout, type LayoutOptions } from \"./layout\";\n\nexport interface FitOptions {\n /** Which cells count: \"all\" (default), \"whole\" (not cut by the region outline) or a test. */\n cells?: ContentCells;\n /**\n * \"atLeast\" (default): the largest tiles that still give at least `count` cells, so\n * every item has a tile. \"nearest\": whichever tile size gets closest to `count`.\n */\n mode?: \"atLeast\" | \"nearest\";\n}\n\nexport interface FitResult {\n /** The input options with `tileScale` set. */\n options: LayoutOptions;\n layout: Layout;\n tileScale: number;\n /** Number of cells that count (by `cells`) in `layout`. */\n count: number;\n}\n\n/**\n * Find a tile size giving about `count` usable cells: scales the pattern (`tileScale`)\n * and searches, laying out a few dozen times. The tile count changes in steps, and not\n * always monotonically (tiles at the edge come and go), so for random and aperiodic\n * patterns, or \"whole\" cells, the result may land a little above `count`.\n */\nexport function fitCount(options: LayoutOptions, count: number, fit: FitOptions = {}): FitResult {\n if (!(count >= 1) || !Number.isFinite(count)) throw new RangeError(`fitCount needs a count of at least 1 (got ${count})`);\n const n = Math.floor(count);\n const { cells = \"all\", mode = \"atLeast\" } = fit;\n const accept = cells === \"all\" ? () => true : cells === \"whole\" ? (c: Cell) => !c.boundary : cells;\n\n type Probe = { k: number; layout?: Layout; count: number; error?: unknown };\n const probe = (k: number): Probe => {\n try {\n const layout = createLayout({ ...options, tileScale: k });\n return { k, layout, count: layout.cells.filter((c) => accept(c)).length };\n } catch (error) {\n // Too many tiles for maxTiles: count as \"plenty\", but remember why.\n if (error instanceof RangeError && /maxTiles|limit/.test(error.message)) return { k, count: Infinity, error };\n throw error;\n }\n };\n\n // Bracket: lo has at least n cells, hi fewer. Counts scale roughly with 1/k².\n let p = probe(options.tileScale ?? 1);\n let lo: Probe | undefined;\n let hi: Probe | undefined;\n for (let i = 0; i < 60 && !(lo && hi); i++) {\n if (p.count >= n) lo = !lo || p.k > lo.k ? p : lo;\n else hi = !hi || p.k < hi.k ? p : hi;\n if (lo && hi) break;\n const guess = p.count > 0 && Number.isFinite(p.count) ? p.k * Math.sqrt(p.count / n) : p.k;\n // Always move by at least 25% so the bracket grows even when the guess is off.\n const next = p.count >= n ? Math.max(guess, p.k * 1.25) : Math.min(guess, p.k / 1.25);\n p = probe(next);\n }\n if (!lo || !hi) {\n if (lo?.layout) return result(options, lo);\n throw new RangeError(`fitCount: couldn't find a tile size giving ${n} cells`);\n }\n\n // Bisect (in log scale) for the largest tiles that still give at least n cells.\n for (let i = 0; i < 30 && hi.k / lo.k > 1.0005; i++) {\n const mid = probe(Math.sqrt(lo.k * hi.k));\n if (mid.count >= n) lo = mid;\n else hi = mid;\n }\n if (!lo.layout) throw lo.error;\n const pick = mode === \"nearest\" && hi.count > 0 && n - hi.count < lo.count - n ? hi : lo;\n return result(options, pick);\n}\n\nfunction result(options: LayoutOptions, p: { k: number; layout?: Layout; count: number }): FitResult {\n return { options: { ...options, tileScale: p.k }, layout: p.layout!, tileScale: p.k, count: p.count };\n}\n","import type { Rect, Vec } from \"./geometry\";\nimport type { Cell, Layout } from \"./layout\";\nimport type { Pixels } from \"./fills\";\nimport { safeArea } from \"./safe\";\nimport { cellShape } from \"./shape\";\n\n/**\n * A point in an image to keep in view, as fractions of its width and height ({ x: 0, y: 0 }\n * is the top left), and optionally the image's shape, so renderers can place it exactly\n * without being told the image's aspect elsewhere.\n */\nexport interface Focus {\n x: number;\n y: number;\n /** The image's width / height. */\n aspect?: number;\n}\n\nexport interface CoverOptions {\n /** The image's width / height (defaults to `focus.aspect`, else square). */\n aspect?: number;\n /** What to keep in view. Defaults to the middle, { x: 0.5, y: 0.5 }. */\n focus?: Focus;\n /**\n * Where the focus should land: the middle of the part of the cell that shows (\"visible\",\n * the default), or of the whole tile (\"tile\"), for a cell an `edges: \"window\"` layout cuts.\n * Either way it's the middle of the cell's safe area, so it's well inside the shape.\n */\n within?: \"tile\" | \"visible\";\n}\n\n/**\n * Where to draw an image (in layout units) so it covers a cell's box, like CSS\n * `object-fit: cover`, with its focal point as near as it can get to the middle of what\n * shows of the cell. A cut tile, a triangle or a tall thin tile then shows a photo's\n * subject rather than whatever was in the middle of the photo. Clip the image to the cell\n * as usual.\n */\nexport function coverRect(cell: Cell, layout: Pick<Layout, \"cornerRadius\" | \"view\">, options: CoverOptions): Rect {\n const box = cellShape(cell).bbox;\n const given = options.aspect ?? options.focus?.aspect;\n const aspect = given !== undefined && given > 0 && Number.isFinite(given) ? given : 1;\n const scale = Math.max(box.width / aspect, box.height);\n const width = scale * aspect, height = scale;\n const f = options.focus ?? { x: 0.5, y: 0.5 };\n const t = focusTarget(cell, layout, options.within);\n const clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));\n return {\n x: clamp(t.x - clamp(f.x, 0, 1) * width, box.x + box.width - width, box.x),\n y: clamp(t.y - clamp(f.y, 0, 1) * height, box.y + box.height - height, box.y),\n width,\n height,\n };\n}\n\n/**\n * CSS `object-position` for an image filling a cell's element with `object-fit: cover`\n * (as `coverStyle` does), placing it as `coverRect` does.\n */\nexport function objectPosition(cell: Cell, layout: Pick<Layout, \"cornerRadius\" | \"view\">, options: CoverOptions): string {\n const box = cellShape(cell).bbox;\n const r = coverRect(cell, layout, options);\n const pos = (spare: number, offset: number) => (spare > 1e-9 * (r.width + r.height) ? Number(((offset / spare) * 100).toFixed(3)) : 50);\n return `${pos(r.width - box.width, box.x - r.x)}% ${pos(r.height - box.height, box.y - r.y)}%`;\n}\n\n/** The middle of the cell's safe area: where a focal point should land. */\nfunction focusTarget(cell: Cell, layout: Pick<Layout, \"cornerRadius\" | \"view\">, within: \"tile\" | \"visible\" = \"visible\"): Vec {\n const s = safeArea(cell, layout, { within });\n return { x: s.x + s.width / 2, y: s.y + s.height / 2 };\n}\n\n/**\n * A guess at what a photo is of: the most eye-catching spot, where color and brightness\n * stand out most from their surroundings, with a slight preference for the middle. Good\n * for a subject against a plainer background (a face, a flower, a sun); for busy pictures\n * give the focus yourself. Pass small pixels (`loadImagePixels` gives at most 256 a side).\n * The result includes the image's `aspect`.\n */\nexport function estimateFocus(pixels: Pixels): Focus {\n const { width, height, data } = pixels;\n if (!(width > 0) || !(height > 0)) return { x: 0.5, y: 0.5 };\n const aspect = width / height;\n // Work at most 64 pixels a side.\n const step = Math.max(1, Math.ceil(Math.max(width, height) / 64));\n const w = Math.ceil(width / step), h = Math.ceil(height / step);\n const L = new Float64Array(w * h), A = new Float64Array(w * h), B = new Float64Array(w * h);\n for (let y = 0; y < h; y++) {\n for (let x = 0; x < w; x++) {\n let r = 0, g = 0, b = 0, n = 0;\n for (let yy = y * step; yy < Math.min(height, (y + 1) * step); yy++) {\n for (let xx = x * step; xx < Math.min(width, (x + 1) * step); xx++) {\n const k = (yy * width + xx) * 4;\n const alpha = (data[k + 3] ?? 255) / 255;\n // Transparent pixels count as white.\n r += (data[k]! * alpha + 255 * (1 - alpha)); g += (data[k + 1]! * alpha + 255 * (1 - alpha)); b += (data[k + 2]! * alpha + 255 * (1 - alpha)); n++;\n }\n }\n r /= n * 255; g /= n * 255; b /= n * 255;\n // A rough opponent color space: brightness and two color axes.\n const i = y * w + x;\n L[i] = 0.299 * r + 0.587 * g + 0.114 * b;\n A[i] = r - g;\n B[i] = (r + g) / 2 - b;\n }\n }\n // How much each spot differs from its surroundings (center minus surround), at two scales.\n const size = Math.max(w, h);\n const near = Math.max(1, Math.round(size / 32)), far = Math.max(2, Math.round(size / 6));\n const blur = (src: Float64Array, r: number) => boxBlur(boxBlur(src, w, h, r), w, h, r);\n const sal = new Float64Array(w * h);\n for (const [chan, weight] of [[L, 1], [A, 1.5], [B, 1.5]] as const) {\n const c = blur(chan, near), s = blur(chan, far);\n for (let i = 0; i < sal.length; i++) sal[i]! += weight * Math.abs(c[i]! - s[i]!);\n }\n // Favor a blob over a thin line: smooth, then pick the peak, leaning a little to the middle.\n const smooth = blur(sal, Math.max(1, Math.round(size / 16)));\n let best = -1, bx = w / 2, by = h / 2;\n for (let y = 0; y < h; y++) {\n for (let x = 0; x < w; x++) {\n const d = Math.hypot((x + 0.5) / w - 0.5, (y + 0.5) / h - 0.5);\n const v = smooth[y * w + x]! * (1 - 0.4 * d);\n if (v > best) { best = v; bx = x + 0.5; by = y + 0.5; }\n }\n }\n return best > 1e-6 ? { x: Math.min(1, (bx * step) / width), y: Math.min(1, (by * step) / height), aspect } : { x: 0.5, y: 0.5, aspect };\n}\n\n/** Box blur of radius `r`, along rows then columns, with edges extended. */\nfunction boxBlur(src: Float64Array, w: number, h: number, r: number): Float64Array {\n const tmp = new Float64Array(src.length), out = new Float64Array(src.length);\n const pass = (from: Float64Array, to: Float64Array, len: number, lines: number, at: (line: number, k: number) => number) => {\n for (let line = 0; line < lines; line++) {\n let sum = 0;\n for (let k = -r; k <= r; k++) sum += from[at(line, Math.min(len - 1, Math.max(0, k)))]!;\n for (let k = 0; k < len; k++) {\n to[at(line, k)] = sum / (2 * r + 1);\n sum += from[at(line, Math.min(len - 1, k + r + 1))]! - from[at(line, Math.max(0, k - r))]!;\n }\n }\n };\n pass(src, tmp, w, h, (y, x) => y * w + x);\n pass(tmp, out, h, w, (x, y) => y * w + x);\n return out;\n}\n","import { area, centroid, vec, type Vec } from \"./geometry\";\nimport { contentSlots, type ContentCells, type ContentPlacement } from \"./content\";\nimport { fitCount } from \"./fit\";\nimport { createLayout, type Cell, type Feature, type Layout, type LayoutOptions } from \"./layout\";\n\nexport interface WeightOptions {\n /** Which cells may hold items: \"all\" (default), \"whole\" (not cut by the outline) or a test. */\n cells?: ContentCells;\n /** Where items go when there are fewer than cells: \"reading\" (default), \"center\" or \"spread\". */\n placement?: ContentPlacement;\n}\n\n/** The tiles each item spans: its weight, rounded, and at least 1. */\nexport const tileSpans = (weights: readonly number[]): number[] =>\n weights.map((w) => (Number.isFinite(w) ? Math.max(1, Math.round(w)) : 1));\n\n/**\n * Featured tiles for items of different importance. `weights` gives how many tiles each\n * item should span (1 for an ordinary item; rounded); each item over 1 gets a feature of\n * that many merged tiles, for it (`Feature.item`), centerd where its tiles would be if every\n * item took its share of `layout`'s cells in order (so the reading order of the items is\n * kept). Bigger features come first, so they get room. `layout` should have no features\n * of its own. See `weightedLayout` for the whole job.\n */\nexport function weightedFeatures(layout: Layout, weights: readonly number[], options: WeightOptions = {}): Feature[] {\n const spans = tileSpans(weights);\n const total = spans.reduce((s, w) => s + w, 0);\n if (!spans.some((w) => w > 1)) return [];\n // The cells the items would fill, one tile at a time, in order.\n const slots = contentSlots(layout, total, options);\n const byTile: Cell[] = [];\n slots.forEach((slot, i) => {\n if (slot >= 0) byTile[slot] = layout.cells[i]!;\n });\n const features: Feature[] = [];\n let start = 0;\n spans.forEach((w, item) => {\n if (w > 1) {\n // Items past the last cell have nowhere to go, so get no feature.\n const cells = byTile.slice(start, start + w).filter(Boolean);\n if (cells.length) features.push({ tiles: w, at: middle(cells), item });\n }\n start += w;\n });\n return features.sort((a, b) => b.tiles! - a.tiles! || a.item! - b.item!);\n}\n\n/** Area-weighted center of some cells. */\nfunction middle(cells: Cell[]): Vec {\n let x = 0, y = 0, w = 0;\n for (const c of cells) {\n const a = c.area || area(c.polygon);\n const m = c.centroid ?? centroid(c.polygon);\n x += m.x * a; y += m.y * a; w += a;\n }\n return vec(x / (w || 1), y / (w || 1));\n}\n\nexport interface WeightedLayoutOptions extends WeightOptions {\n /**\n * Size the tiles so the items fit, counting each item's weight in tiles (see `fitCount`):\n * `true` / \"atLeast\" for the largest tiles that fit everything, \"nearest\" for the closest\n * count.\n */\n fit?: boolean | \"atLeast\" | \"nearest\";\n}\n\nexport interface WeightedLayoutResult {\n /** The options used: `tileScale` from `fit`, and `features` with the weighted ones added. */\n options: LayoutOptions;\n layout: Layout;\n /** The features made for the weighted items (also in `options.features`). */\n features: Feature[];\n}\n\n/**\n * A layout for items of different importance: `weights` gives how many tiles each item\n * spans (1 for ordinary items), and each heavier item gets a featured tile that big, where\n * it falls in the items' reading order (see `weightedFeatures`). With `fit`, the tiles are\n * sized so all the items fit. `contentSlots` and `matchSlots` on the result put each item\n * in its own featured cell. Features already in `options` are kept, before the weighted ones.\n */\nexport function weightedLayout(options: LayoutOptions, weights: readonly number[], settings: WeightedLayoutOptions = {}): WeightedLayoutResult {\n const { fit, ...content } = settings;\n const spans = tileSpans(weights);\n const total = spans.reduce((s, w) => s + w, 0);\n const plain: LayoutOptions = { ...options, features: undefined };\n let base: LayoutOptions = options;\n let baseLayout: Layout | undefined;\n if (fit && total >= 1) {\n const r = fitCount(plain, total, { cells: content.cells, mode: fit === \"nearest\" ? \"nearest\" : \"atLeast\" });\n base = { ...options, tileScale: r.tileScale };\n baseLayout = r.layout;\n }\n const features = spans.some((w) => w > 1) ? weightedFeatures(baseLayout ?? createLayout({ ...base, features: undefined }), weights, content) : [];\n const all = [...(options.features ?? []), ...features];\n const final: LayoutOptions = { ...base };\n if (all.length) final.features = all;\n else delete final.features;\n const layout = !features.length && baseLayout && !options.features?.length ? baseLayout : createLayout(final);\n return { options: final, layout, features };\n}\n"],"mappings":";AA4BO,IAAM,MAAM,CAAC,GAAW,OAAoB,EAAE,GAAG,EAAE;AAEnD,IAAM,MAAM,CAAC,GAAQ,OAAiB,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,EAAE;AACnE,IAAM,MAAM,CAAC,GAAQ,OAAiB,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,EAAE;AACnE,IAAM,QAAQ,CAAC,GAAQ,OAAoB,EAAE,GAAG,EAAE,IAAI,GAAG,GAAG,EAAE,IAAI,EAAE;AACpE,IAAM,MAAM,CAAC,GAAQ,MAAmB,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;AAC5D,IAAM,QAAQ,CAAC,GAAQ,MAAmB,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;AAC9D,IAAM,SAAS,CAAC,MAAmB,KAAK,MAAM,EAAE,GAAG,EAAE,CAAC;AAGtD,SAAS,YAAY,GAAW,GAAW,OAAe,QAAyB;AACxF,SAAO,CAAC,IAAI,GAAG,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,GAAG,IAAI,MAAM,CAAC;AACtF;AAGO,SAAS,WAAW,GAAoB;AAC7C,MAAI,IAAI;AACR,WAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,IAAI,GAAG,KAAK;AAC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C,MAAM,IAAI,CAAC,IAAI,iBAAiB,cAAc,aAAa,EAAE,GAAG,MAAM,UAAU,OAAU,CAAC,GAAG,SAAS,OAAO,IAAI,CAAC;AAChJ,QAAM,MAAM,CAAC,GAAI,QAAQ,YAAY,CAAC,GAAI,GAAG,QAAQ;AACrD,QAAM,QAAuB,EAAE,GAAG,KAAK;AACvC,MAAI,IAAI,OAAQ,OAAM,WAAW;AAAA,MAC5B,QAAO,MAAM;AAClB,QAAM,SAAS,CAAC,SAAS,UAAU,cAAc,CAAC,QAAQ,UAAU,SAAS,aAAa,aAAa,KAAK;AAC5G,SAAO,EAAE,SAAS,OAAO,QAAQ,SAAS;AAC5C;","names":["t","k","cross","scale","scale","add","shapes","grid","n","tiles","rest","unit","scale","tiles","deg","tiles","grid","grow","shapes","tiles","x0","y0","x1","y1","placed","grow","mul","matchSeg","mul","matchSeg","A","B","C","D","tiles","placed","deg","placed","sub","ANCHOR","grow","scale","shapes","a","middle","t","positive","unit","g","scale","candidates","shapes","cross","hat","positive","scale","tiles","placed","overlaps","visible","k","index","scale","tiles","middle","grow","spread","add","result","result","scale","result","span","area","r","crossing","shapes","a","b","scale","cache","add","scale"]}
|
|
1
|
+
{"version":3,"sources":["../src/layout.ts","../src/relief.ts","../src/navigation.ts","../src/hit.ts","../src/content.ts","../src/fills.ts","../src/fit.ts","../src/focus.ts","../src/weights.ts"],"sourcesContent":["import {\n area,\n bbox,\n centroid,\n clipConvex,\n containsPolygon,\n convexHull,\n ensurePositive,\n insetConvex,\n isConvex,\n rectPolygon,\n rectsOverlap,\n vec,\n type Polygon,\n type Rect,\n type Vec,\n} from \"./geometry\";\nimport { clipPolygonToConvex, insetPolygon, insetPolygonPieces, outsetPolygon, pointInPolygon, splitSelfIntersections } from \"./offset\";\nimport { inShapes, overlay, shapeArea, shapeCentroid, type Shape } from \"./overlay\";\nimport { generateTiles, type TilingSpec } from \"./tilings\";\nimport { fieldRange, refineTiles } from \"./density\";\n\n/**\n * How tiles at the edge of the region are treated.\n * - \"clip\": cut tiles to the region outline (a full-bleed look).\n * - \"inside\": keep only tiles that fit entirely inside the region.\n * - \"overflow\": keep every tile that touches the region, uncut.\n * - \"window\": tiles stay whole and the region is a window onto them: renderers shape,\n * round, bevel and fill each tile as the whole tile (`Cell.tile`) and hide\n * what falls outside the region (`Layout.view`). A cut edge is a straight\n * line through the tile, not a new corner.\n */\nexport type EdgeMode = \"clip\" | \"inside\" | \"overflow\" | \"window\";\n\nexport interface LayoutOptions {\n /**\n * The area to tile: a rectangle or any simple polygon (convex or not; it mustn't cross\n * itself), in your own units (cm, px, in…).\n */\n region: Rect | Polygon;\n /**\n * Areas inside the region to leave empty: windows, doors, sockets. Rectangles or\n * simple polygons; they may overlap each other or the region's edge. Tiles are cut\n * around them (or skipped, with `edges: \"inside\"`), and `margin` applies around them too.\n */\n holes?: (Rect | Polygon)[];\n tiling: TilingSpec;\n /** Space between neighboring tiles. Defaults to 0. */\n gap?: number;\n /** Empty border kept between the region outline (and any holes) and the tiles. Defaults to 0. */\n margin?: number;\n /** Pattern rotation in degrees (ignored by the random patterns: mondrian, voronoi, delaunay, ashlar, jigsaw). Defaults to 0. */\n rotation?: number;\n /**\n * Shifts the pattern (ignored by the random patterns). For penrose this is where the\n * ten-fold star at the pattern's center sits. Defaults to the top-left of the region.\n */\n origin?: Vec;\n /** Defaults to \"clip\". */\n edges?: EdgeMode;\n /**\n * Drop edge tiles that end up smaller than this fraction (0–1) of a full tile,\n * so you don't get slivers. Applies to \"clip\", \"overflow\" and \"window\". Defaults to 0.\n */\n minFill?: number;\n /**\n * Round every tile corner with this radius, in region units. Corners too small\n * for the full radius get the largest radius that fits. Defaults to 0 (sharp).\n * Rounding is applied when rendering; `Cell.polygon`, `area` and `centroid`\n * describe the sharp-cornered shape.\n */\n cornerRadius?: number;\n /**\n * Scale the whole pattern (every tile size in the tiling spec) by this factor, about\n * the pattern origin. Handy for fitting a tile count without knowing which size\n * parameters a pattern has; see `fitCount`. Defaults to 1.\n */\n tileScale?: number;\n /**\n * Featured tiles: groups of neighboring tiles merged into one bigger cell, e.g. for a\n * hero image. Merging happens before the gap and edge handling, so a featured cell gets\n * the same gap all round as any other. See `Feature`.\n */\n features?: Feature[];\n /**\n * Vary the tile size across the region: the size wanted at each point, as a factor of the\n * tiling's own size (1 as given, 0.5 half as big, 2 twice). Voronoi and Delaunay change\n * size smoothly; other tilings are generated at the largest size wanted and, where tiles\n * should be smaller, replaced by the same tiling at half the scale (again and again, down\n * to the smallest), cut to fit. Grids and other tilings that halve exactly nest without\n * cuts. See `radialSize`, `edgeSize` and `imageSize`.\n */\n sizeAt?: (point: Vec) => number;\n /** Safety cap on generated tiles. Defaults to 20000. */\n maxTiles?: number;\n}\n\n/**\n * A featured tile: `tiles` neighboring tiles merged into one cell. The group grows from\n * a tile near `at`, adding whichever neighbor keeps it most compact (so 4 grid tiles make\n * a 2 × 2 square, 7 hexagons a flower); several starting tiles are tried and the most\n * compact group kept, near `at` and avoiding tiles the region edge cuts. Features don't\n * share tiles: a later one grows among the tiles still free.\n */\nexport interface Feature {\n /** How many tiles to merge. Defaults to 4. Fewer are merged if the group runs out of room. */\n tiles?: number;\n /** Where the group starts, in region units. Defaults to the middle of the region. */\n at?: Vec;\n /**\n * Exact tile ids to merge instead (from a layout without features; ids are stable).\n * Overrides `tiles` and `at`. Tiles that aren't in the layout or are already taken are skipped.\n */\n ids?: string[];\n /**\n * Which content item (by position) goes in this featured cell. By default featured cells\n * take the first items, in `features` order. See `weightedLayout`.\n */\n item?: number;\n}\n\nexport interface Cell {\n /** Stable id derived from the tile's position in the pattern. */\n id: string;\n /** Position in reading order (top-to-bottom, then left-to-right). Use it to assign content to cells. */\n index: number;\n /** Visible shape: after gap and edge handling. */\n polygon: Polygon;\n /**\n * Holes in the visible shape, when a region hole lies wholly inside the tile. Absent\n * otherwise. `area` and `centroid` account for them.\n */\n holes?: Polygon[];\n /** The full pattern tile before gap and edge handling. */\n original: Polygon;\n /**\n * With `edges: \"window\"`, for a cell the region outline cuts: the whole tile (after the\n * gap), which renderers shape, round and fill, letting the region hide the rest. `polygon`\n * is still the visible part (its largest piece, when the outline cuts the tile in two).\n * See `cellShape` and `visibleShapes`.\n */\n tile?: Polygon;\n bbox: Rect;\n centroid: Vec;\n area: number;\n /** The tile crosses the region outline (it was cut in \"clip\" mode, or sticks out in \"overflow\"). */\n boundary: boolean;\n /** Which prototile this is a copy of (e.g. herringbone: 0 horizontal, 1 vertical). */\n protoTile: number;\n /** Ids of cells that share an edge with this one in the underlying pattern. */\n neighbors: string[];\n /** For a featured cell: its position in `features`. Featured cells get content first. */\n featured?: number;\n /** For a featured cell: the content item it's for, when its feature names one (`Feature.item`). */\n featuredItem?: number;\n /** For a featured cell: ids of the tiles merged into it. */\n merged?: string[];\n}\n\nexport interface Layout {\n /** The region outline (before margin). */\n region: Polygon;\n /** The region's holes (before margin), positively oriented. */\n holes: Polygon[];\n /** Bounding box of the region; a good SVG viewBox. */\n bounds: Rect;\n /** Corner radius renderers apply to every cell (0 for sharp corners). */\n cornerRadius: number;\n /**\n * With `edges: \"window\"`: the area tiles show in (the region less its margin and holes).\n * Renderers hide whatever part of a tile lies outside it.\n */\n view?: Shape[];\n cells: Cell[];\n}\n\nfunction toPolygon(region: Rect | Polygon): Polygon {\n if (Array.isArray(region)) return region.map((v) => vec(v.x, v.y));\n return rectPolygon(region.x, region.y, region.width, region.height);\n}\n\nexport function createLayout(options: LayoutOptions): Layout {\n const region = ensurePositive(toPolygon(options.region));\n if (region.length < 3) throw new RangeError(\"region needs at least 3 corners\");\n if (splitSelfIntersections(region).length > 1) throw new RangeError(\"region must not cross itself\");\n if (area(region) === 0) throw new RangeError(\"region has no area\");\n const holes: Polygon[] = [];\n for (const h of options.holes ?? []) {\n const hole = ensurePositive(toPolygon(h));\n if (hole.length >= 3 && splitSelfIntersections(hole).length > 1) throw new RangeError(\"holes must not cross themselves\");\n if (hole.length >= 3 && area(hole) > 0) holes.push(hole);\n }\n // Convex regions without holes take the fast path: clipping against a convex outline.\n const simple = holes.length === 0 && isConvex(region);\n const bounds = bbox(region);\n const scaleRef = Math.max(bounds.width, bounds.height);\n const tol = 1e-7 * scaleRef;\n\n const gap = Math.max(0, options.gap ?? 0);\n const margin = Math.max(0, options.margin ?? 0);\n const edges = options.edges ?? \"clip\";\n const minFill = Math.min(1, Math.max(0, options.minFill ?? 0));\n const cornerRadius = Math.max(0, options.cornerRadius ?? 0);\n\n const empty: Layout = { region, holes, bounds, cornerRadius, cells: [] };\n // The area tiles may cover: the region less its margin and the (grown) holes.\n let inner: Polygon;\n let usable: Shape[] = [];\n let loops: Polygon[] = [];\n if (simple) {\n inner = margin > 0 ? insetConvex(region, margin) : region;\n if (inner.length === 0) return empty;\n } else {\n const outers = margin > 0 ? insetPolygonPieces(region, margin) : [region];\n const grown = holes.map((h) => (margin > 0 ? outsetPolygon(h, margin) : h)).filter((h) => h.length >= 3);\n usable = overlay(\n [...outers, ...grown],\n (p) => outers.some((o) => pointInPolygon(p, o)) && !grown.some((h) => pointInPolygon(p, h)),\n scaleRef,\n );\n if (usable.length === 0) return empty;\n loops = usable.flatMap((s) => [s.outer, ...s.holes]);\n // Generators only need to cover this; tiles are cut to the exact area below.\n inner = convexHull(usable.flatMap((s) => s.outer));\n }\n const innerBox = bbox(inner);\n // Region edges with their boxes, to find the few that reach each tile.\n const edgesOf = loops.flatMap((l) => l.map((a, i) => [a, l[(i + 1) % l.length]!] as const));\n const edgeBoxes = edgesOf.map(([a, b]) => ({ x0: Math.min(a.x, b.x), y0: Math.min(a.y, b.y), x1: Math.max(a.x, b.x), y1: Math.max(a.y, b.y) }));\n\n const k = options.tileScale ?? 1;\n if (!(k > 0) || !Number.isFinite(k)) throw new RangeError(`tileScale must be a positive number (got ${k})`);\n const origin = options.origin ?? vec(bounds.x, bounds.y);\n // With sizeAt, the pattern starts at the largest size wanted.\n const field = options.sizeAt;\n const range = field ? fieldRange(field, innerBox) : { min: 1, max: 1 };\n const k0 = k * range.max;\n const smooth = options.tiling.type === \"voronoi\" || options.tiling.type === \"delaunay\";\n // Scaling the pattern by k0 = generating in a region shrunk by 1/k0, then scaling back up.\n const down = (v: Vec) => vec(v.x / k0, v.y / k0);\n let raw = generateTiles(options.tiling, {\n region: k0 === 1 ? inner : inner.map(down),\n rotation: options.rotation ?? 0,\n origin: k0 === 1 ? origin : down(origin),\n maxTiles: options.maxTiles ?? 20000,\n // The exact area to tile and the pattern scale, for generators that follow the outline.\n outline: (simple ? [inner] : loops).map((l) => (k0 === 1 ? l : l.map(down))),\n unit: k0,\n ...(field && smooth ? { sizeAt: (p: Vec) => Math.min(1, field(vec(p.x * k0, p.y * k0)) / range.max) } : {}),\n });\n if (k0 !== 1) raw = raw.map((t) => ({ ...t, polygon: t.polygon.map((v) => vec(v.x * k0, v.y * k0)) }));\n if (field && !smooth && options.tiling.type !== \"tiles\" && options.tiling.type !== \"flow\" && range.min < range.max / Math.SQRT2) {\n raw = refineTiles(raw, {\n spec: options.tiling,\n rotation: options.rotation ?? 0,\n origin,\n scale: k0,\n want: (p) => field(p) / range.max,\n levels: Math.min(6, Math.round(Math.log2(range.max / range.min))),\n maxTiles: options.maxTiles ?? 20000,\n scaleRef,\n tol,\n });\n }\n\n type Draft = Omit<Cell, \"index\" | \"neighbors\">;\n const drafts: Draft[] = [];\n const minArea = tol * scaleRef;\n\n /** Gap, edge handling and clipping for one pattern tile; its visible piece(s) as drafts. */\n const place = (original: Polygon, id: string, protoTile: number): Draft[] => {\n const convex = isConvex(original);\n // Each tile gives up half the gap on every side, so neighbors end up `gap` apart.\n const tile = gap <= 0 ? original : convex ? insetConvex(original, gap / 2) : insetPolygon(original, gap / 2);\n if (tile.length === 0) return [];\n const full = area(tile);\n\n let pieces: Shape[];\n let boundary: boolean;\n if (!simple) {\n const tb = bbox(tile);\n const pad = tol;\n const near: Polygon[] = [];\n edgeBoxes.forEach((e, i) => {\n if (e.x1 >= tb.x - pad && e.x0 <= tb.x + tb.width + pad && e.y1 >= tb.y - pad && e.y0 <= tb.y + tb.height + pad) {\n near.push([...edgesOf[i]!]);\n }\n });\n let cut: Shape[];\n if (near.length === 0) {\n // No region edge reaches the tile's box: it's wholly in or wholly out.\n cut = inShapes(tile[0]!, loops) ? [{ outer: tile, holes: [] }] : [];\n } else {\n cut = overlay([tile, ...near], (p) => pointInPolygon(p, tile) && inShapes(p, loops), scaleRef)\n .filter((q) => shapeArea(q) > minArea)\n .sort((a, b) => shapeArea(b) - shapeArea(a));\n }\n const visible = cut.reduce((sum, q) => sum + shapeArea(q), 0);\n boundary = visible < full - minArea;\n if (edges === \"inside\") {\n if (boundary || cut.length !== 1 || cut[0]!.holes.length > 0) return [];\n pieces = [{ outer: tile, holes: [] }];\n } else {\n if (visible <= minArea || visible < minFill * full) return [];\n pieces = edges === \"overflow\" ? [{ outer: tile, holes: [] }] : cut;\n }\n } else if (edges === \"inside\") {\n if (!containsPolygon(inner, tile, tol)) return [];\n pieces = [{ outer: tile, holes: [] }];\n boundary = false;\n } else {\n // The region edge can cut a non-convex tile into separate parts; those become\n // separate cells, largest first.\n const cut = convex\n ? [clipConvex(tile, inner)]\n : clipPolygonToConvex(tile, inner)\n .filter((q) => area(q) > minArea)\n .sort((a, b) => area(b) - area(a));\n const visible = cut.reduce((sum, q) => sum + (q.length ? area(q) : 0), 0);\n if (visible <= minArea || visible < minFill * full) return [];\n boundary = visible < full - minArea;\n pieces = (edges === \"overflow\" ? [tile] : cut).map((outer) => ({ outer, holes: [] }));\n }\n\n if (edges === \"window\" && boundary) {\n // One cell for the whole tile: its largest visible piece, with the tile to draw.\n const shape = pieces[0]!;\n const withHoles = shape.holes.length > 0;\n return [{\n id,\n polygon: shape.outer,\n ...(withHoles ? { holes: shape.holes.map((h) => ensurePositive(h)) } : {}),\n original,\n tile,\n bbox: bbox(shape.outer),\n centroid: withHoles ? shapeCentroid(shape) : centroid(shape.outer),\n area: withHoles ? shapeArea(shape) : area(shape.outer),\n boundary,\n protoTile,\n }];\n }\n\n return pieces.map((shape, k) => {\n const withHoles = shape.holes.length > 0;\n return {\n // Extra parts of a tile split by the region edge get \"~1\", \"~2\", ….\n id: k === 0 ? id : `${id}~${k}`,\n polygon: shape.outer,\n ...(withHoles ? { holes: shape.holes.map((h) => ensurePositive(h)) } : {}),\n original,\n bbox: bbox(shape.outer),\n centroid: withHoles ? shapeCentroid(shape) : centroid(shape.outer),\n area: withHoles ? shapeArea(shape) : area(shape.outer),\n boundary,\n protoTile,\n };\n });\n };\n\n for (const t of raw) {\n const original = ensurePositive(t.polygon);\n if (!rectsOverlap(bbox(original), innerBox)) continue;\n drafts.push(...place(original, t.id, t.protoTile));\n }\n\n if (options.features?.length) {\n const merged = mergeFeatures(drafts, options.features, region, scaleRef, Math.max(tol * 10, 1e-9));\n for (const m of merged) {\n const keep = new Set(m.members);\n const pieces = place(m.polygon, `feature${m.feature}`, m.protoTile).map((d) => ({\n ...d,\n featured: m.feature,\n ...(options.features![m.feature]!.item !== undefined ? { featuredItem: options.features![m.feature]!.item } : {}),\n merged: m.members,\n }));\n // Drop the merged tiles (and any extra parts of them) and add the featured cell.\n for (let i = drafts.length - 1; i >= 0; i--) if (keep.has(drafts[i]!.id.split(\"~\")[0]!)) drafts.splice(i, 1);\n drafts.push(...pieces);\n }\n }\n\n\n // Reading order: rows top-to-bottom, then left-to-right.\n const rowTol = 1e-6 * scaleRef;\n drafts.sort((p, q) => {\n const dy = p.centroid.y - q.centroid.y;\n return Math.abs(dy) > rowTol ? dy : p.centroid.x - q.centroid.x;\n });\n\n const neighbors = findNeighbors(\n drafts.map((d) => d.original),\n drafts.map((d) => !d.id.includes(\"~\")),\n Math.max(tol * 10, 1e-9),\n );\n const cells: Cell[] = drafts.map((d, index) => ({\n ...d,\n index,\n neighbors: neighbors[index]!.map((k) => drafts[k]!.id),\n }));\n const view = edges === \"window\" ? (simple ? [{ outer: inner, holes: [] }] : usable) : undefined;\n return { region, holes, bounds, cornerRadius, ...(view ? { view } : {}), cells };\n}\n\ntype FeatureDraft = { id: string; original: Polygon; boundary: boolean; protoTile: number; area: number };\n\n/**\n * Choose the tile groups for `features` among the laid-out tiles, and merge each group's\n * pattern tiles into one outline. Groups that would merge into something other than a\n * single outline without holes (a ring, say) are left unmerged.\n */\nfunction mergeFeatures(\n drafts: FeatureDraft[],\n features: Feature[],\n region: Polygon,\n scale: number,\n tol: number,\n): { feature: number; members: string[]; polygon: Polygon; protoTile: number }[] {\n // Whole tiles only (not the extra parts of a split one), with their pattern geometry.\n const tiles = drafts.filter((d) => !d.id.includes(\"~\"));\n const index = new Map(tiles.map((t, i) => [t.id, i]));\n const adj = findNeighbors(tiles.map((t) => t.original), tiles.map(() => true), tol);\n const cx = tiles.map((t) => centroid(t.original));\n const ar = tiles.map((t) => area(t.original));\n // How much of each tile is left inside the region; one that keeps most of itself (trimmed\n // by the margin, say) counts as whole.\n const kept = tiles.map((t, i) => (t.boundary ? Math.min(1, t.area / (ar[i]! || 1)) : 1));\n const cut = kept.map((k) => k < 0.6);\n const taken = new Uint8Array(tiles.length);\n const middle = centroid(region);\n const out: { feature: number; members: string[]; polygon: Polygon; protoTile: number }[] = [];\n\n features.forEach((f, k) => {\n let group: number[];\n if (f.ids) {\n group = f.ids.map((id) => index.get(id)).filter((i): i is number => i !== undefined && !taken[i]);\n } else {\n const want = Math.max(1, Math.floor(f.tiles ?? 4));\n const at = f.at ?? middle;\n // Score: (mostly) uncut tiles first, then distance to `to`, then distance to `at` (which keeps\n // the group centerd on `at` when several tiles are equally compact); then the earlier tile.\n const eps = 1e-9 * scale * scale;\n const d2 = (i: number, p: Vec) => (cx[i]!.x - p.x) ** 2 + (cx[i]!.y - p.y) ** 2;\n const better = (i: number, j: number, to: Vec) => {\n if (cut[i] !== cut[j]) return !cut[i];\n const a = d2(i, to) - d2(j, to);\n if (Math.abs(a) > eps) return a < 0;\n const b = d2(i, at) - d2(j, at);\n if (Math.abs(b) > eps) return b < 0;\n return i < j;\n };\n // Grow a group from each of the free tiles nearest `at`, and keep the best: the most\n // tiles, then the lowest cost (spread out, off-center from `at`, or cut by the edge).\n // Growing from the nearest tile alone can make a strip where a block fits a step away.\n const free: number[] = [];\n for (let i = 0; i < tiles.length; i++) if (!taken[i]) free.push(i);\n if (!free.length) return;\n free.sort((i, j) => (better(i, j, at) ? -1 : better(j, i, at) ? 1 : 0));\n const grow = (seed: number) => {\n const g = [seed];\n const inGroup = new Set(g);\n while (g.length < want) {\n // The group's center (area-weighted), and the free neighbor nearest it.\n let sx = 0, sy = 0, sw = 0;\n for (const i of g) { sx += cx[i]!.x * ar[i]!; sy += cx[i]!.y * ar[i]!; sw += ar[i]!; }\n const c = vec(sx / sw, sy / sw);\n let pick = -1;\n for (const i of g) {\n for (const j of adj[i]!) if (!taken[j] && !inGroup.has(j) && (pick < 0 || better(j, pick, c))) pick = j;\n }\n if (pick < 0) break;\n g.push(pick);\n inGroup.add(pick);\n }\n return g;\n };\n const cost = (g: number[]) => {\n let sx = 0, sy = 0, sw = 0, lost = 0;\n for (const i of g) { sx += cx[i]!.x * ar[i]!; sy += cx[i]!.y * ar[i]!; sw += ar[i]!; if (cut[i]) lost += (1 - kept[i]!) * ar[i]!; }\n if (!(sw > 0)) return Infinity;\n const c = vec(sx / sw, sy / sw);\n // Spread: the tiles' moment of inertia about the group's center over its area squared\n // (a 2 x 2 square of squares scores 1/8, an L 7/32, a 4 x 1 strip 5/16).\n let inertia = 0;\n for (const i of g) inertia += ar[i]! * d2(i, c);\n const spread = inertia / (sw * sw);\n // Distance from `at`, relative to the group's size; and the share cut off by the edge.\n const off = ((c.x - at.x) ** 2 + (c.y - at.y) ** 2) / sw;\n return spread + 0.15 * off + 0.6 * (lost / sw);\n };\n group = [];\n let bestCost = Infinity;\n for (const seed of free.slice(0, Math.max(8, 2 * want))) {\n const g = grow(seed);\n const gc = cost(g);\n if (g.length > group.length || (g.length === group.length && gc < bestCost - 1e-9)) {\n group = g;\n bestCost = gc;\n }\n }\n }\n if (group.length === 0) return;\n for (const i of group) taken[i] = 1;\n const polys = group.map((i) => tiles[i]!.original);\n const union = group.length === 1 ? [{ outer: polys[0]!, holes: [] }] : overlay(polys, (p) => polys.some((q) => pointInPolygon(p, q)), scale);\n if (union.length !== 1 || union[0]!.holes.length > 0) {\n for (const i of group) taken[i] = 0;\n return;\n }\n out.push({ feature: k, members: group.map((i) => tiles[i]!.id), polygon: union[0]!.outer, protoTile: tiles[group[0]!]!.protoTile });\n });\n return out;\n}\n\n/**\n * Edge-adjacency between polygons: two share an edge if they have overlapping boundary\n * segments on the same line (which also catches T-junctions, where one tile's edge runs\n * along part of another's). Edges are bucketed by their line, so the work grows with the\n * number of edges rather than with pairs of nearby tiles × their edges.\n */\nfunction findNeighbors(polys: Polygon[], primary: boolean[], tol: number): number[][] {\n // Line of each edge: direction angle in [0, π) and signed offset from the origin.\n const angleStep = 1e-6;\n const offsetStep = Math.max(tol * 10, 1e-9);\n type Seg = { poly: number; t0: number; t1: number };\n // Buckets keyed by a number packing (angle, offset) exactly; offsets are measured from a\n // point near the tiles so they stay small. Anything beyond the packable range (tiles\n // absurdly far away) falls back to string keys.\n const buckets = new Map<number | string, Seg[]>();\n const add = (ka: number, ko: number, seg: Seg) => {\n const key = Math.abs(ko) < 2 ** 30 ? (ka + 2) * 2 ** 31 + (ko + 2 ** 30) : `${ka},${ko}`;\n const list = buckets.get(key);\n if (list) list.push(seg);\n else buckets.set(key, [seg]);\n };\n const ref = polys.find((p) => p.length > 0)?.[0] ?? { x: 0, y: 0 };\n // Parts of one tile (split by the region edge) share the same original; its main part\n // (the one without a \"~n\" suffix) stands for the tile.\n const owners = new Map<Polygon, number>();\n polys.forEach((p, i) => {\n if (primary[i] || !owners.has(p)) owners.set(p, i);\n });\n polys.forEach((p, i) => {\n if (owners.get(p) !== i) return;\n for (let k = 0; k < p.length; k++) {\n const a = p[k]!;\n const b = p[(k + 1) % p.length]!;\n const len = Math.hypot(b.x - a.x, b.y - a.y);\n if (len <= tol) continue;\n let ux = (b.x - a.x) / len;\n let uy = (b.y - a.y) / len;\n if (uy < 0 || (uy === 0 && ux < 0)) {\n ux = -ux;\n uy = -uy;\n }\n // Directions just short of 180° are the same lines as those just past 0°.\n let angle = Math.atan2(uy, ux);\n if (angle > Math.PI - angleStep) {\n ux = -ux;\n uy = -uy;\n angle = Math.atan2(uy, ux);\n }\n const ax = a.x - ref.x, ay = a.y - ref.y;\n const ta = ux * ax + uy * ay;\n const tb = ux * (b.x - ref.x) + uy * (b.y - ref.y);\n const seg = { poly: i, t0: Math.min(ta, tb), t1: Math.max(ta, tb) };\n // Bucket by line. A value close to a rounding boundary also goes into the bucket on\n // the other side, so the same line computed with slightly different rounding still meets.\n const va = angle / angleStep;\n const vo = (ux * ay - uy * ax) / offsetStep;\n const ka = Math.round(va);\n const ko = Math.round(vo);\n const ea = va - ka > 0.49 ? 1 : va - ka < -0.49 ? -1 : 0;\n const eo = vo - ko > 0.49 ? 1 : vo - ko < -0.49 ? -1 : 0;\n add(ka, ko, seg);\n if (eo) add(ka, ko + eo, seg);\n if (ea) {\n add(ka + ea, ko, seg);\n if (eo) add(ka + ea, ko + eo, seg);\n }\n }\n });\n\n const pairs = new Set<string>();\n const result: number[][] = polys.map(() => []);\n const link = (i: number, j: number) => {\n const key = i < j ? `${i},${j}` : `${j},${i}`;\n if (pairs.has(key)) return;\n pairs.add(key);\n result[i]!.push(j);\n result[j]!.push(i);\n };\n for (const segs of buckets.values()) {\n // Sweep along the line: only segments whose intervals overlap are compared. (In a\n // lattice a whole row of tiles can put edges on one line, so pairwise would be slow.)\n segs.sort((a, b) => a.t0 - b.t0);\n const active: Seg[] = [];\n for (const s of segs) {\n for (let k = active.length - 1; k >= 0; k--) {\n if (active[k]!.t1 <= s.t0 + tol) active.splice(k, 1);\n }\n for (const o of active) {\n if (o.poly !== s.poly && Math.min(s.t1, o.t1) - Math.max(s.t0, o.t0) > tol) link(s.poly, o.poly);\n }\n active.push(s);\n }\n }\n // Parts of one tile get the same neighbors as the tile, and are their neighbors too.\n const ownNeighbors = result.map((list) => [...list]);\n polys.forEach((p, i) => {\n const owner = owners.get(p)!;\n if (owner === i) return;\n result[i] = [...ownNeighbors[owner]!];\n for (const j of ownNeighbors[owner]!) result[j]!.push(i);\n });\n for (const list of result) list.sort((a, b) => a - b);\n return result;\n}\n\n/**\n * Greedy graph coloring over cell adjacency: neighboring cells get different\n * color indices. Handy for placeholder fills. Returns one index per cell (by cell.index).\n */\nexport function colorCells(layout: Layout, colors: number): number[] {\n const byId = new Map(layout.cells.map((c) => [c.id, c.index]));\n const out: number[] = new Array(layout.cells.length).fill(-1);\n for (const c of layout.cells) {\n const used = new Set<number>();\n for (const n of c.neighbors) {\n const k = byId.get(n);\n if (k !== undefined && out[k]! >= 0) used.add(out[k]!);\n }\n let pick = 0;\n // Rotate the starting color so large single-color runs are avoided.\n for (let s = 0; s < colors; s++) {\n const cand = (c.index + s) % colors;\n if (!used.has(cand)) {\n pick = cand;\n break;\n }\n }\n out[c.index] = pick;\n }\n return out;\n}\n","import { vec, type Polygon, type Vec } from \"./geometry\";\nimport type { Cell, Layout } from \"./layout\";\nimport { pointInPolygon } from \"./offset\";\nimport { roundCorners } from \"./rounding\";\nimport { cellShape, type CellShape } from \"./shape\";\n\n/**\n * Where light comes from, as a unit vector pointing from the surface towards the light.\n * `angle` is in degrees clockwise from the top, like CSS angles: 0 from above, 90 from the\n * right, 315 (the default) from the top left.\n */\nexport function lightVector(angle = 315): Vec {\n const a = (angle * Math.PI) / 180;\n return vec(Math.sin(a), -Math.cos(a));\n}\n\nexport interface BevelOptions {\n /** Width of the bevel, in layout units. Narrowed per cell where the shape is too thin. */\n width: number;\n /** Direction the light comes from: degrees clockwise from the top (default 315, top left). */\n light?: number;\n}\n\n/** One sloped face of a bevel. */\nexport interface BevelFacet {\n polygon: Polygon;\n /**\n * How much the face turns towards the light, from 1 (straight at it: draw a highlight)\n * through 0 to -1 (straight away: draw a shadow).\n */\n shade: number;\n}\n\n/**\n * The bevel round a cell's edges (outline, holes and rounded corners; the whole tile for a\n * window cell, see `cellShape`), as a band of\n * sloped faces `width` wide, each shaded by how it faces the light. Draw light faces with\n * translucent white and dark ones with translucent black over the cell, and the tile looks\n * raised, like a real tile or tessera. The band is narrowed where a cell is too thin for it.\n */\nexport function bevelFacets(cell: Cell, layout: Pick<Layout, \"cornerRadius\">, options: BevelOptions): BevelFacet[] {\n const want = Math.max(0, options.width);\n const shape = cellShape(cell);\n if (want === 0 || shape.outline.length < 3) return [];\n const loops = [shape.outline, ...shape.holes].map((p) => prepare(p, shape, layout.cornerRadius)).filter((l) => l.outer.length >= 3);\n if (loops.length === 0) return [];\n\n // Narrow the band until the inner outline is clean.\n let d = want;\n if (!valid(loops, d)) {\n let lo = 0, hi = want;\n for (let it = 0; it < 14; it++) {\n const mid = (lo + hi) / 2;\n if (valid(loops, mid)) lo = mid;\n else hi = mid;\n }\n d = lo;\n }\n if (d <= 0) return [];\n\n const light = lightVector(options.light);\n const facets: BevelFacet[] = [];\n for (const loop of loops) {\n const inner = innerLoop(loop, d);\n const { outer, normal } = loop;\n for (let i = 0, n = outer.length; i < n; i++) {\n const j = (i + 1) % n;\n const a = outer[i]!, b = outer[j]!;\n if (a.x === b.x && a.y === b.y) continue;\n // The face slopes down towards the outside: it faces the outward normal.\n const shade = -(normal[i]!.x * light.x + normal[i]!.y * light.y);\n facets.push({ polygon: [a, b, inner[j]!, inner[i]!], shade });\n }\n }\n return facets;\n}\n\n/**\n * A loop's outline points (as drawn, with rounded corners), the inward normal of the edge\n * from each point to the next, and how each point moves inwards as the band widens.\n */\ninterface Loop {\n outer: Vec[];\n normal: Vec[];\n /** Per point: a rounded-corner arc point (center, radius, convex) or a sharp corner. */\n kind: ({ arc: true; center: Vec; radius: number; convex: boolean; vertex: Vec; n1: Vec; n2: Vec } | { arc: false; n1: Vec; n2: Vec })[];\n}\n\nfunction prepare(poly: Polygon, cell: CellShape, radius: number): Loop {\n const corners = roundCorners(poly, radius);\n const n = poly.length;\n // Which side of the loop is the tile: test a point just left of the longest edge.\n let li = 0, ll = -1;\n for (let i = 0; i < n; i++) {\n const a = poly[i]!, b = poly[(i + 1) % n]!;\n const l = Math.hypot(b.x - a.x, b.y - a.y);\n if (l > ll) { ll = l; li = i; }\n }\n const a = poly[li]!, b = poly[(li + 1) % n]!;\n const eps = 1e-6 * Math.max(cell.bbox.width, cell.bbox.height, 1e-12);\n const left = vec(-(b.y - a.y) / ll, (b.x - a.x) / ll);\n const probe = vec((a.x + b.x) / 2 + left.x * eps, (a.y + b.y) / 2 + left.y * eps);\n const inside = pointInPolygon(probe, cell.outline) && !cell.holes.some((h) => pointInPolygon(probe, h));\n const side = inside ? 1 : -1;\n const inward = (p: Vec, q: Vec): Vec => {\n const l = Math.hypot(q.x - p.x, q.y - p.y) || 1;\n return vec((-(q.y - p.y) / l) * side, ((q.x - p.x) / l) * side);\n };\n\n const outer: Vec[] = [];\n const kind: Loop[\"kind\"] = [];\n for (let i = 0; i < n; i++) {\n const c = corners[i]!;\n // The nearest distinct neighbors: outlines can repeat a point.\n const same = (p: Vec, q: Vec) => Math.abs(p.x - q.x) <= eps * 1e-3 && Math.abs(p.y - q.y) <= eps * 1e-3;\n let prev = poly[(i - 1 + n) % n]!, next = poly[(i + 1) % n]!;\n for (let k = 2; k < n && same(prev, c.vertex); k++) prev = poly[(i - k + n) % n]!;\n for (let k = 2; k < n && same(next, c.vertex); k++) next = poly[(i + k) % n]!;\n const n1 = inward(prev, c.vertex), n2 = inward(c.vertex, next);\n if (c.radius === 0) {\n outer.push(c.vertex);\n kind.push({ arc: false, n1, n2 });\n continue;\n }\n // The same sampling as roundedPolygon, so the bevel lines up with the clip path.\n const steps = Math.max(1, Math.ceil(Math.abs(c.sweep) / (Math.PI / 18)));\n const a0 = Math.atan2(c.start.y - c.center.y, c.start.x - c.center.x);\n // Convex (seen from the tile) when the center is on the tile side of the edge.\n const convex = (c.center.x - c.vertex.x) * n1.x + (c.center.y - c.vertex.y) * n1.y > 0;\n for (let s = 0; s <= steps; s++) {\n const p = s === 0 ? c.start : s === steps ? c.end : vec(c.center.x + c.radius * Math.cos(a0 + (c.sweep * s) / steps), c.center.y + c.radius * Math.sin(a0 + (c.sweep * s) / steps));\n outer.push(p);\n kind.push({ arc: true, center: c.center, radius: c.radius, convex, vertex: c.vertex, n1, n2 });\n }\n }\n const normal = outer.map((p, i) => inward(p, outer[(i + 1) % outer.length]!));\n // Drop repeated points (an arc meeting the next corner's arc at an edge's midpoint).\n const keep = outer.map((p, i) => {\n const q = outer[(i + 1) % outer.length]!;\n return Math.hypot(q.x - p.x, q.y - p.y) > eps * 1e-3;\n });\n return {\n outer: outer.filter((_, i) => keep[i]),\n normal: normal.filter((_, i) => keep[i]),\n kind: kind.filter((_, i) => keep[i]),\n };\n}\n\n/** Where the two edges at a sharp corner meet once both have moved in by `d`. */\nconst miter = (v: Vec, n1: Vec, n2: Vec, d: number): Vec => {\n const k = d / Math.max(1e-9, 1 + n1.x * n2.x + n1.y * n2.y);\n return vec(v.x + (n1.x + n2.x) * k, v.y + (n1.y + n2.y) * k);\n};\n\nfunction innerLoop(loop: Loop, d: number): Vec[] {\n return loop.outer.map((p, i) => {\n const k = loop.kind[i]!;\n if (!k.arc) return miter(p, k.n1, k.n2, d);\n // Arcs offset to concentric arcs; a convex one narrower than the band becomes the\n // sharp corner where the straight edges' offsets meet.\n const r = k.convex ? k.radius - d : k.radius + d;\n if (r <= 0) return miter(k.vertex, k.n1, k.n2, d);\n const ux = p.x - k.center.x, uy = p.y - k.center.y;\n const l = Math.hypot(ux, uy) || 1;\n return vec(k.center.x + (ux / l) * r, k.center.y + (uy / l) * r);\n });\n}\n\n/** The inner outlines at width `d` keep every edge's direction and don't cross. */\nfunction valid(loops: Loop[], d: number): boolean {\n const segs: [Vec, Vec][] = [];\n for (const loop of loops) {\n const inner = innerLoop(loop, d);\n const n = inner.length;\n for (let i = 0; i < n; i++) {\n const a = loop.outer[i]!, b = loop.outer[(i + 1) % n]!;\n const p = inner[i]!, q = inner[(i + 1) % n]!;\n const len = Math.hypot(b.x - a.x, b.y - a.y);\n // An inner edge pointing backwards means the band folded over.\n if ((q.x - p.x) * (b.x - a.x) + (q.y - p.y) * (b.y - a.y) < -1e-9 * len * len) return false;\n if (Math.hypot(q.x - p.x, q.y - p.y) > 1e-9 * len) segs.push([p, q]);\n }\n }\n for (let i = 0; i < segs.length; i++) {\n for (let j = i + 1; j < segs.length; j++) {\n if (crosses(segs[i]![0], segs[i]![1], segs[j]![0], segs[j]![1])) return false;\n }\n }\n return true;\n}\n\n/** Proper crossing: each segment's ends strictly on opposite sides of the other. */\nfunction crosses(a: Vec, b: Vec, c: Vec, d: Vec): boolean {\n const o = (p: Vec, q: Vec, r: Vec) => (q.x - p.x) * (r.y - p.y) - (q.y - p.y) * (r.x - p.x);\n const s1 = Math.hypot(b.x - a.x, b.y - a.y), s2 = Math.hypot(d.x - c.x, d.y - c.y);\n const tol = 1e-9 * s1 * s2;\n const d1 = o(a, b, c), d2 = o(a, b, d), d3 = o(c, d, a), d4 = o(c, d, b);\n return ((d1 > tol && d2 < -tol) || (d1 < -tol && d2 > tol)) && ((d3 > tol && d4 < -tol) || (d3 < -tol && d4 > tol));\n}\n","import type { Cell, Layout } from \"./layout\";\n\nexport type Direction = \"up\" | \"down\" | \"left\" | \"right\";\n\nconst DIRS: Record<Direction, [number, number]> = { up: [0, -1], down: [0, 1], left: [-1, 0], right: [1, 0] };\n\nexport interface DirectionOptions {\n /** Only land on cells this accepts (those with content, say). Others are passed over. */\n accept?: (cell: Cell) => boolean;\n /**\n * The cross-axis coordinate to keep to: x when moving up or down, y when moving left or\n * right. Pass the value from the start of a run of presses, and\n * repeated moves zigzag along a column of a hexagon or brick tiling instead of drifting\n * to one side. Defaults to `from`'s center.\n */\n lane?: number;\n}\n\nconst byId = new WeakMap<Layout, Map<string, Cell>>();\nfunction cellsById(layout: Layout): Map<string, Cell> {\n let m = byId.get(layout);\n if (!m) byId.set(layout, (m = new Map(layout.cells.map((c) => [c.id, c]))));\n return m;\n}\n\n/**\n * The cell to move to from `from` in a direction, for arrow-key navigation over any tiling.\n *\n * Moves to a tile that shares an edge with `from` and lies ahead (its center within 60° of\n * the direction), so no row is ever skipped; among those it takes the one nearest the\n * `lane`. If no touching tile qualifies (at a hole, or because `accept` passes them over),\n * it looks further: the nearest accepted cell ahead, distance from the lane counting double.\n * Returns undefined at the edge.\n */\nexport function cellInDirection(\n layout: Layout,\n from: Cell,\n direction: Direction,\n options: DirectionOptions | ((cell: Cell) => boolean) = {},\n): Cell | undefined {\n const { accept = () => true, lane: laneOption } = typeof options === \"function\" ? { accept: options } : options;\n const [dx, dy] = DIRS[direction];\n const size = Math.sqrt(Math.max(from.area, 1e-12));\n const eps = 1e-6 * size;\n const cone = Math.tan(Math.PI / 3);\n const cross = (c: Cell) => (dx ? c.centroid.y : c.centroid.x);\n const lane = laneOption ?? cross(from);\n const place = (c: Cell) => {\n const ox = c.centroid.x - from.centroid.x, oy = c.centroid.y - from.centroid.y;\n return { along: ox * dx + oy * dy, across: Math.abs(ox * dy - oy * dx), off: Math.abs(cross(c) - lane) };\n };\n const pick = (cells: Iterable<Cell>, score: (p: ReturnType<typeof place>) => number, inCone: boolean) => {\n let best: Cell | undefined, bestScore = Infinity;\n for (const c of cells) {\n if (c === from || !accept(c)) continue;\n const p = place(c);\n if (p.along <= eps || (inCone && p.across > p.along * cone)) continue;\n const s = score(p);\n if (s < bestScore - eps || (Math.abs(s - bestScore) <= eps && best && c.index < best.index)) { best = c; bestScore = s; }\n }\n return best;\n };\n\n // Touching tiles ahead: nearest the lane, then the most nearly straight ahead.\n const ids = cellsById(layout);\n const touching = from.neighbors.map((id) => ids.get(id)).filter((c): c is Cell => !!c);\n const near = (p: ReturnType<typeof place>) => p.off + 0.25 * p.across;\n // Further away, through cells `accept` passes over or across a hole.\n const far = (p: ReturnType<typeof place>) => p.along + 2 * p.off;\n return pick(touching, near, true) ?? pick(layout.cells, far, true) ?? pick(touching, near, false) ?? pick(layout.cells, far, false);\n}\n","import { bbox, vec, type Polygon, type Rect, type Vec } from \"./geometry\";\nimport type { Cell, Layout } from \"./layout\";\nimport { inShapes } from \"./overlay\";\nimport { visibleShapes } from \"./shape\";\n\n/**\n * Hit testing: which cell is under a point, or near it, or inside a rectangle. Uses each\n * cell's visible shape (gap, rounded corners and holes included) and a spatial index built\n * once per layout, so lookups stay fast for tens of thousands of cells.\n */\n\ninterface Index {\n /** Visible outlines per cell (by position in `layout.cells`): every piece's outline and holes, even–odd. */\n loops: Polygon[][];\n /** Bounding box of each cell's visible shape. */\n boxes: Rect[];\n x0: number;\n y0: number;\n size: number;\n cols: number;\n rows: number;\n /** Cell positions per bucket. */\n buckets: number[][];\n}\n\nconst indexes = new WeakMap<Layout, Index>();\n\nfunction index(layout: Layout): Index {\n const hit = indexes.get(layout);\n if (hit) return hit;\n const cells = layout.cells;\n const loops = cells.map((c) => visibleShapes(c, layout).flatMap((s) => [s.outer, ...s.holes]));\n const boxes = loops.map((ls) => (ls.length ? bbox(ls.flat()) : { x: 0, y: 0, width: 0, height: 0 }));\n // Cells may stick out of the bounds (\"overflow\"), so index their own extent.\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const b of boxes) {\n x0 = Math.min(x0, b.x); y0 = Math.min(y0, b.y);\n x1 = Math.max(x1, b.x + b.width); y1 = Math.max(y1, b.y + b.height);\n }\n if (!cells.length) { x0 = y0 = 0; x1 = y1 = 1; }\n // Buckets about the size of a typical cell.\n const mean = boxes.reduce((s, b) => s + b.width * b.height, 0) / Math.max(1, cells.length);\n const size = Math.max(Math.sqrt(mean), (x1 - x0 + y1 - y0) / 2048, 1e-9);\n const cols = Math.max(1, Math.ceil((x1 - x0) / size)), rows = Math.max(1, Math.ceil((y1 - y0) / size));\n const buckets: number[][] = Array.from({ length: cols * rows }, () => []);\n boxes.forEach((b, i) => {\n const [ca, ra, cb, rb] = span(b, x0, y0, size, cols, rows);\n for (let r = ra; r <= rb; r++) for (let q = ca; q <= cb; q++) buckets[r * cols + q]!.push(i);\n });\n const built = { loops, boxes, x0, y0, size, cols, rows, buckets };\n indexes.set(layout, built);\n return built;\n}\n\n/** Bucket columns and rows a rectangle covers (clamped to the grid). */\nfunction span(r: Rect, x0: number, y0: number, size: number, cols: number, rows: number): [number, number, number, number] {\n const clamp = (v: number, n: number) => Math.min(n - 1, Math.max(0, v));\n return [\n clamp(Math.floor((r.x - x0) / size), cols),\n clamp(Math.floor((r.y - y0) / size), rows),\n clamp(Math.floor((r.x + r.width - x0) / size), cols),\n clamp(Math.floor((r.y + r.height - y0) / size), rows),\n ];\n}\n\n/** Cells whose bounding boxes might meet `r`, each once, in reading order. */\nfunction candidates(ix: Index, r: Rect): number[] {\n const [ca, ra, cb, rb] = span(r, ix.x0, ix.y0, ix.size, ix.cols, ix.rows);\n const out = new Set<number>();\n for (let row = ra; row <= rb; row++) for (let q = ca; q <= cb; q++) for (const i of ix.buckets[row * ix.cols + q]!) out.add(i);\n return [...out].sort((a, b) => a - b);\n}\n\nconst inLoops = (p: Vec, loops: Polygon[]) => inShapes(p, loops);\n\n/** Distance from `p` to the nearest edge of any of `loops`. */\nfunction edgeDistance(p: Vec, loops: Polygon[]): number {\n let best = Infinity;\n for (const loop of loops) {\n for (let i = 0, n = loop.length; i < n; i++) {\n const a = loop[i]!, b = loop[(i + 1) % n]!;\n const dx = b.x - a.x, dy = b.y - a.y;\n const t = Math.max(0, Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / (dx * dx + dy * dy || 1)));\n best = Math.min(best, Math.hypot(p.x - a.x - t * dx, p.y - a.y - t * dy));\n }\n }\n return best;\n}\n\nexport interface HitOptions {\n /**\n * Also count points this far outside a cell (in layout units): in the gap between\n * tiles, or just past a rounded corner. The nearest cell wins. Handy for touch. Default 0.\n */\n tolerance?: number;\n}\n\n/** The cell whose visible shape contains `point` (in layout units), or undefined. */\nexport function cellAt(layout: Layout, point: Vec, options: HitOptions = {}): Cell | undefined {\n const ix = index(layout);\n for (const i of candidates(ix, { x: point.x, y: point.y, width: 0, height: 0 })) {\n if (inLoops(point, ix.loops[i]!)) return layout.cells[i];\n }\n const tolerance = options.tolerance ?? 0;\n return tolerance > 0 ? nearestCell(layout, point, tolerance) : undefined;\n}\n\n/**\n * The cell nearest `point`: the one containing it, or else the one whose edge is closest.\n * With `maxDistance`, only cells within that distance count.\n */\nexport function nearestCell(layout: Layout, point: Vec, maxDistance = Infinity): Cell | undefined {\n const ix = index(layout);\n if (!layout.cells.length) return undefined;\n const at = cellAt(layout, point);\n if (at) return at;\n // Widen a square round the point bucket by bucket: once it reaches `reach` on every side,\n // any cell not yet seen is at least that far away.\n let best: number | undefined, bestD = Infinity;\n const seen = new Set<number>();\n const visit = (i: number) => {\n if (seen.has(i)) return;\n seen.add(i);\n const d = edgeDistance(point, ix.loops[i]!);\n if (d < bestD) { bestD = d; best = i; }\n };\n const inside = point.x >= ix.x0 && point.y >= ix.y0 && point.x <= ix.x0 + ix.cols * ix.size && point.y <= ix.y0 + ix.rows * ix.size;\n let done = false;\n if (inside) {\n for (let ring = 0; ring <= Math.max(ix.cols, ix.rows) + 1; ring++) {\n const reach = ring * ix.size;\n for (const i of candidates(ix, { x: point.x - reach, y: point.y - reach, width: 2 * reach, height: 2 * reach })) visit(i);\n if (reach >= Math.min(bestD, maxDistance)) { done = true; break; }\n }\n }\n // Points outside the indexed area (rare): check every cell.\n if (!done) layout.cells.forEach((_, i) => visit(i));\n return best !== undefined && bestD <= maxDistance ? layout.cells[best] : undefined;\n}\n\n/**\n * Cells meeting a rectangle (in layout units), in reading order: for marquee selection, or\n * finding what's in view. With `contain`, only cells wholly inside it.\n */\nexport function cellsInRect(layout: Layout, rect: Rect, options: { contain?: boolean } = {}): Cell[] {\n const ix = index(layout);\n const r = normalize(rect);\n const out: Cell[] = [];\n for (const i of candidates(ix, r)) {\n const c = layout.cells[i]!;\n const b = ix.boxes[i]!;\n if (b.x > r.x + r.width || b.x + b.width < r.x || b.y > r.y + r.height || b.y + b.height < r.y) continue;\n const loops = ix.loops[i]!;\n if (options.contain) {\n // Inside the rectangle when its outline is (holes lie within the outline).\n if (loops.every((l) => l.every((p) => p.x >= r.x && p.x <= r.x + r.width && p.y >= r.y && p.y <= r.y + r.height))) out.push(c);\n } else if (meets(loops, r)) out.push(c);\n }\n return out;\n}\n\nfunction normalize(r: Rect): Rect {\n const x = Math.min(r.x, r.x + r.width), y = Math.min(r.y, r.y + r.height);\n return { x, y, width: Math.abs(r.width), height: Math.abs(r.height) };\n}\n\n/** A shape and a rectangle overlap: a point of one inside the other, or edges crossing. */\nfunction meets(loops: Polygon[], r: Rect): boolean {\n const inRect = (p: Vec) => p.x >= r.x && p.x <= r.x + r.width && p.y >= r.y && p.y <= r.y + r.height;\n if (loops.some((l) => l.some(inRect))) return true;\n const corners = [vec(r.x, r.y), vec(r.x + r.width, r.y), vec(r.x + r.width, r.y + r.height), vec(r.x, r.y + r.height)];\n if (corners.some((p) => inLoops(p, loops))) return true;\n // Edges crossing the rectangle's sides (e.g. a thin sliver passing through it).\n for (const loop of loops) {\n for (let i = 0, n = loop.length; i < n; i++) {\n const a = loop[i]!, b = loop[(i + 1) % n]!;\n for (let k = 0; k < 4; k++) if (segmentsCross(a, b, corners[k]!, corners[(k + 1) % 4]!)) return true;\n }\n }\n return false;\n}\n\nfunction segmentsCross(a: Vec, b: Vec, c: Vec, d: Vec): boolean {\n const o = (p: Vec, q: Vec, s: Vec) => Math.sign((q.x - p.x) * (s.y - p.y) - (q.y - p.y) * (s.x - p.x));\n return o(a, b, c) !== o(a, b, d) && o(c, d, a) !== o(c, d, b);\n}\n\n/** The on-screen box of the element showing a layout (e.g. from `getBoundingClientRect()`). */\nexport interface ScreenBox {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\n/**\n * Convert a screen point (e.g. a pointer event's `clientX`, `clientY`) to layout units,\n * given the box of the element the layout fills: a `<TileLayout>` container, an `<svg>`\n * with the layout's viewBox, or a canvas you drew it on. Like SVG's default\n * `preserveAspectRatio`, the layout is taken to be scaled to fit the box and centerd.\n */\nexport function screenToLayout(layout: Layout, box: ScreenBox, clientX: number, clientY: number): Vec {\n const b = layout.bounds;\n const scale = Math.min(box.width / (b.width || 1), box.height / (b.height || 1)) || 1;\n const ox = box.left + (box.width - b.width * scale) / 2;\n const oy = box.top + (box.height - b.height * scale) / 2;\n return vec(b.x + (clientX - ox) / scale, b.y + (clientY - oy) / scale);\n}\n","import { centroid } from \"./geometry\";\nimport { cellShape } from \"./shape\";\nimport type { Cell, Layout } from \"./layout\";\n\n/**\n * Which cells may hold content:\n * - \"all\": every cell.\n * - \"whole\": only cells shown in full (not cut by the region outline; see `Cell.boundary`).\n * - a function: your own test.\n */\nexport type ContentCells = \"all\" | \"whole\" | ((cell: Cell) => boolean);\n\n/**\n * Where content goes when there are fewer items than cells that may hold content:\n * - \"reading\": the first cells in reading order (content packs to the top left).\n * - \"center\": the cells nearest the middle of the region.\n * - \"spread\": cells spread evenly over the region.\n * Items always fill the chosen cells in reading order.\n */\nexport type ContentPlacement = \"reading\" | \"center\" | \"spread\";\n\nexport interface ContentOptions {\n cells?: ContentCells;\n placement?: ContentPlacement;\n}\n\n/**\n * Assign `count` content items to cells. Featured cells (see `LayoutOptions.features`)\n * take the items their features name (`Feature.item`), or else the first items, in feature\n * order; the rest follow `placement`, in item order and reading order.\n * Returns one entry per cell (by `cell.index`):\n * the index of the item it holds, or -1 for an empty cell. Pass `Infinity` to number\n * every cell that may hold content.\n */\nexport function contentSlots(layout: Layout, count: number, options: ContentOptions = {}): number[] {\n const { cells = \"all\", placement = \"reading\" } = options;\n const accept = cells === \"all\" ? () => true : cells === \"whole\" ? (c: Cell) => !c.boundary : cells;\n const out: number[] = new Array(layout.cells.length).fill(-1);\n const total = Math.max(0, Math.floor(count));\n // Featured cells come first: the items they name, else the first items in `features` order.\n const used = featuredItems(layout, total, accept);\n for (const [cell, item] of used) out[cell] = item;\n\n // layout.cells is in reading order, so filtering keeps it.\n const eligible = layout.cells.filter((c) => out[c.index] === -1 && accept(c));\n const rest = remainingItems(total, used, eligible.length);\n const n = Math.max(0, Math.min(rest.length, eligible.length));\n\n let chosen: Cell[];\n if (n === eligible.length) chosen = eligible;\n else if (placement === \"center\") chosen = nearestToCenter(layout, eligible, n);\n else if (placement === \"spread\") chosen = spread(eligible, n);\n else chosen = eligible.slice(0, n);\n\n chosen.sort((a, b) => a.index - b.index).forEach((c, k) => (out[c.index] = rest[k]!));\n return out;\n}\n\n/**\n * Featured cells' items (cell index → item): the item each feature names, or the next item\n * not named by any. A tile cut in two only puts its item in its first part; features whose\n * item is past `total` stay empty (and free for other items).\n */\nfunction featuredItems(layout: Layout, total: number, accept: (c: Cell) => boolean): Map<number, number> {\n const cells = layout.cells\n .filter((c) => c.featured !== undefined && accept(c))\n .sort((a, b) => a.featured! - b.featured! || a.index - b.index);\n const named = new Set(cells.map((c) => c.featuredItem).filter((i): i is number => i !== undefined));\n const out = new Map<number, number>();\n const taken = new Set<number>();\n const seen = new Set<number>();\n let next = 0;\n for (const c of cells) {\n if (seen.has(c.featured!)) continue;\n let item = c.featuredItem;\n if (item === undefined) {\n while (named.has(next) || taken.has(next)) next++;\n item = next;\n }\n if (item < 0 || item >= total || taken.has(item)) continue;\n seen.add(c.featured!);\n taken.add(item);\n out.set(c.index, item);\n }\n return out;\n}\n\n/** The first `max` of items 0 … total - 1 not already in a featured cell, in order. */\nfunction remainingItems(total: number, used: Map<number, number>, max: number): number[] {\n const taken = new Set(used.values());\n const rest: number[] = [];\n for (let i = 0; i < total && rest.length < max; i++) if (!taken.has(i)) rest.push(i);\n return rest;\n}\n\nexport interface MatchOptions extends ContentOptions {\n /**\n * Which cells get items:\n * - \"placement\" (default): the same cells as without matching (`placement`); matching\n * only decides which item goes where among them.\n * - \"shape\": the cells whose shapes suit the items best, wherever they are (portrait\n * photos into the vertical bricks of a herringbone, say). Ignores `placement`.\n */\n choose?: \"placement\" | \"shape\";\n}\n\n/**\n * Like `contentSlots`, but puts each item in a cell of similar shape, so content shown with\n * `object-fit: cover` loses as little as possible to cropping. `aspects` gives each item's\n * width / height (one per item, in item order); a cell's shape is its bounding box, which\n * is what content is laid out in.\n *\n * Featured cells still take their items first (see `contentSlots`). The rest are matched to\n * minimize the total crop (measured as the difference in log aspect ratio, which is optimal\n * to match by sorting both sides). Returns the item index per cell (by `cell.index`), or -1.\n */\nexport function matchSlots(layout: Layout, aspects: readonly number[], options: MatchOptions = {}): number[] {\n const { cells = \"all\", choose = \"placement\" } = options;\n const accept = cells === \"all\" ? () => true : cells === \"whole\" ? (c: Cell) => !c.boundary : cells;\n const logAspect = (a: number) => (a > 0 && Number.isFinite(a) ? Math.log(a) : 0);\n const cellLog = (c: Cell) => { const b = cellShape(c).bbox; return logAspect(b.width / (b.height || 1)); };\n\n // Featured cells and (for \"placement\") the cells to use come from contentSlots.\n const base = contentSlots(layout, aspects.length, options);\n const out: number[] = new Array(layout.cells.length).fill(-1);\n const used = featuredItems(layout, aspects.length, accept);\n for (const [cell, item] of used) out[cell] = item;\n const rest = remainingItems(aspects.length, used, Infinity);\n\n let pool: Cell[];\n if (choose === \"shape\") pool = layout.cells.filter((c) => out[c.index] === -1 && accept(c));\n else pool = layout.cells.filter((c) => out[c.index] === -1 && base[c.index]! >= 0);\n // Items beyond the cells available stay out, as with contentSlots: the first ones are kept.\n const k = Math.min(rest.length, pool.length);\n if (k <= 0) return out;\n const items = rest.slice(0, k).sort((a, b) => logAspect(aspects[a]!) - logAspect(aspects[b]!) || a - b);\n const sorted = [...pool].sort((a, b) => cellLog(a) - cellLog(b) || a.index - b.index);\n\n let picked: Cell[];\n if (k === sorted.length) picked = sorted;\n else picked = bestSubset(items.map((i) => logAspect(aspects[i]!)), sorted.map(cellLog)).map((j) => sorted[j]!);\n items.forEach((item, i) => (out[picked[i]!.index] = item));\n return out;\n}\n\n/**\n * Choose `a.length` of the (sorted) values `c` to pair, in order, with the (sorted) values\n * `a`, minimizing the total |a - c|. Order-preserving pairings are optimal for this cost,\n * so a dynamic program over (items, cells) finds the best. Returns the chosen indices of `c`.\n */\nfunction bestSubset(a: number[], c: number[]): number[] {\n const n = a.length, m = c.length;\n // take bit (i, j): item i-1 pairs with cell j-1 in the best solution of the subproblem.\n const take = new Uint8Array(Math.ceil((n * (m + 1)) / 8) + 1);\n const setBit = (i: number, j: number) => {\n const b = (i - 1) * (m + 1) + j;\n take[b >> 3]! |= 1 << (b & 7);\n };\n const bit = (i: number, j: number) => {\n const b = (i - 1) * (m + 1) + j;\n return (take[b >> 3]! >> (b & 7)) & 1;\n };\n let prev = new Float64Array(m + 1); // row i - 1 (row 0: no items, cost 0)\n let cur = new Float64Array(m + 1);\n for (let i = 1; i <= n; i++) {\n cur.fill(Infinity, 0, i);\n for (let j = i; j <= m; j++) {\n const skip = cur[j - 1]!;\n const pair = prev[j - 1]! + Math.abs(a[i - 1]! - c[j - 1]!);\n if (pair <= skip) {\n cur[j] = pair;\n setBit(i, j);\n } else cur[j] = skip;\n }\n [prev, cur] = [cur, prev];\n }\n const chosen: number[] = [];\n for (let i = n, j = m; i > 0; j--) {\n if (bit(i, j)) {\n chosen.push(j - 1);\n i--;\n }\n }\n return chosen.reverse();\n}\n\nfunction nearestToCenter(layout: Layout, cells: Cell[], n: number): Cell[] {\n const mid = centroid(layout.region);\n const d = (c: Cell) => (c.centroid.x - mid.x) ** 2 + (c.centroid.y - mid.y) ** 2;\n return cells\n .map((c) => ({ c, d: d(c) }))\n .sort((a, b) => a.d - b.d || a.c.index - b.c.index)\n .slice(0, n)\n .map((e) => e.c);\n}\n\n/**\n * `n` cells spread evenly: k-means on cell centers (seeded by farthest-point sampling, so\n * it's deterministic), then the cell nearest each cluster center. The iteration count is\n * capped so very large layouts stay fast; the seeding alone is already well spread.\n */\nfunction spread(cells: Cell[], n: number): Cell[] {\n if (n === 0) return [];\n const m = cells.length;\n const xs = Float64Array.from(cells, (c) => c.centroid.x);\n const ys = Float64Array.from(cells, (c) => c.centroid.y);\n const ws = Float64Array.from(cells, (c) => c.area);\n\n // Farthest-point seeding, starting from the cell nearest the overall (area-weighted) center.\n let sx = 0, sy = 0, sw = 0;\n for (let i = 0; i < m; i++) { sx += xs[i]! * ws[i]!; sy += ys[i]! * ws[i]!; sw += ws[i]!; }\n sx /= sw || 1; sy /= sw || 1;\n const best = new Float64Array(m).fill(Infinity);\n const cx = new Float64Array(n);\n const cy = new Float64Array(n);\n let next = 0;\n for (let j = 0, bd = Infinity; j < m; j++) {\n const d = (xs[j]! - sx) ** 2 + (ys[j]! - sy) ** 2;\n if (d < bd) { bd = d; next = j; }\n }\n for (let k = 0; k < n; k++) {\n cx[k] = xs[next]!; cy[k] = ys[next]!;\n let far = -1, fi = 0;\n for (let j = 0; j < m; j++) {\n const d = (xs[j]! - cx[k]!) ** 2 + (ys[j]! - cy[k]!) ** 2;\n if (d < best[j]!) best[j] = d;\n if (best[j]! > far) { far = best[j]!; fi = j; }\n }\n next = fi;\n }\n\n // Lloyd iterations.\n const assign = new Int32Array(m);\n const iterations = Math.min(20, Math.floor(3e7 / (m * n)));\n for (let it = 0; it < iterations; it++) {\n for (let j = 0; j < m; j++) {\n let bd = Infinity, bk = 0;\n for (let k = 0; k < n; k++) {\n const d = (xs[j]! - cx[k]!) ** 2 + (ys[j]! - cy[k]!) ** 2;\n if (d < bd) { bd = d; bk = k; }\n }\n assign[j] = bk;\n }\n const ax = new Float64Array(n), ay = new Float64Array(n), aw = new Float64Array(n);\n for (let j = 0; j < m; j++) {\n const k = assign[j]!;\n ax[k] += xs[j]! * ws[j]!; ay[k] += ys[j]! * ws[j]!; aw[k] += ws[j]!;\n }\n let moved = false;\n for (let k = 0; k < n; k++) {\n if (aw[k]! === 0) continue;\n const nx = ax[k]! / aw[k]!, ny = ay[k]! / aw[k]!;\n if (nx !== cx[k] || ny !== cy[k]) moved = true;\n cx[k] = nx; cy[k] = ny;\n }\n if (!moved) break;\n }\n\n // The nearest still-free cell to each center.\n const taken = new Uint8Array(m);\n const chosen: Cell[] = [];\n for (let k = 0; k < n; k++) {\n let bd = Infinity, bj = -1;\n for (let j = 0; j < m; j++) {\n if (taken[j]) continue;\n const d = (xs[j]! - cx[k]!) ** 2 + (ys[j]! - cy[k]!) ** 2;\n if (d < bd) { bd = d; bj = j; }\n }\n taken[bj] = 1;\n chosen.push(cells[bj]!);\n }\n return chosen;\n}\n","import { colorCells, type Cell, type Layout } from \"./layout\";\nimport { pointInPolygon } from \"./offset\";\nimport { mulberry32 } from \"./random\";\n\n/**\n * A color per cell. Renderers' `fill` props accept these; they're plain functions, so\n * you can also call them yourself (`fill(cell, layout)`) for other renderers.\n */\nexport type CellFill = (cell: Cell, layout: Layout) => string;\n\n/** Neighboring cells get different colors from `colors` (as far as the palette allows). */\nexport function paletteFill(colors: readonly string[]): CellFill {\n if (colors.length === 0) throw new RangeError(\"paletteFill needs at least one color\");\n const cache = new WeakMap<Layout, number[]>();\n return (cell, layout) => {\n let indices = cache.get(layout);\n if (!indices) {\n indices = colorCells(layout, colors.length);\n cache.set(layout, indices);\n }\n return colors[indices[cell.index] ?? 0]!;\n };\n}\n\n/** One color per prototile, e.g. herringbone's horizontal and vertical bricks. */\nexport function protoTileFill(colors: readonly string[]): CellFill {\n if (colors.length === 0) throw new RangeError(\"protoTileFill needs at least one color\");\n return (cell) => colors[cell.protoTile % colors.length]!;\n}\n\n/**\n * A random color per cell. The choice depends only on the cell's id and `seed`, so a tile\n * keeps its color when the layout is resized or the region changes.\n */\nexport function randomFill(colors: readonly string[], seed = 1): CellFill {\n if (colors.length === 0) throw new RangeError(\"randomFill needs at least one color\");\n return (cell) => colors[Math.floor(mulberry32(hashString(cell.id) ^ Math.imul(seed, 0x9e3779b1))() * colors.length)]!;\n}\n\nexport interface GradientOptions {\n /**\n * Direction of a linear gradient in degrees: 0 runs left to right, 90 top to bottom\n * (y grows downward). Defaults to 0.\n */\n angle?: number;\n /** \"radial\" runs from the region's center (first stop) out to its corners (last stop). */\n shape?: \"linear\" | \"radial\";\n}\n\n/**\n * Color by position: each cell takes the gradient's color at its centroid. Stops are hex\n * colors (#rgb or #rrggbb), spaced evenly and blended in the OKLab color space, which\n * keeps the middle of the gradient from going muddy.\n */\nexport function gradientFill(stops: readonly string[], options: GradientOptions = {}): CellFill {\n if (stops.length === 0) throw new RangeError(\"gradientFill needs at least one color\");\n const labs = stops.map((s) => srgbToOklab(parseHex(s)));\n const { angle = 0, shape = \"linear\" } = options;\n const dx = Math.cos((angle * Math.PI) / 180);\n const dy = Math.sin((angle * Math.PI) / 180);\n return (cell, layout) => {\n const b = layout.bounds;\n const cx = b.x + b.width / 2;\n const cy = b.y + b.height / 2;\n const px = cell.centroid.x - cx;\n const py = cell.centroid.y - cy;\n let t: number;\n if (shape === \"radial\") {\n t = Math.hypot(px, py) / (Math.hypot(b.width, b.height) / 2 || 1);\n } else {\n // Project onto the direction; the region's corners map to 0 and 1.\n const half = (Math.abs(dx) * b.width + Math.abs(dy) * b.height) / 2 || 1;\n t = ((px * dx + py * dy) / half + 1) / 2;\n }\n return toHex(oklabToSrgb(sample(labs, Math.min(1, Math.max(0, t)))));\n };\n}\n\ntype Triple = [number, number, number];\n\nfunction sample(stops: Triple[], t: number): Triple {\n if (stops.length === 1) return stops[0]!;\n const x = t * (stops.length - 1);\n const i = Math.min(stops.length - 2, Math.floor(x));\n const f = x - i;\n const a = stops[i]!;\n const b = stops[i + 1]!;\n return [a[0] + (b[0] - a[0]) * f, a[1] + (b[1] - a[1]) * f, a[2] + (b[2] - a[2]) * f];\n}\n\nfunction hashString(s: string): number {\n let h = 2166136261;\n for (let i = 0; i < s.length; i++) h = Math.imul(h ^ s.charCodeAt(i), 16777619);\n return h >>> 0;\n}\n\nfunction parseHex(s: string, who = \"gradientFill\"): Triple {\n const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(s.trim());\n if (!m) throw new RangeError(`${who} needs hex colors like \"#e9d8a6\" (got ${JSON.stringify(s)})`);\n const h = m[1]!.length === 3 ? [...m[1]!].map((c) => c + c).join(\"\") : m[1]!;\n return [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16) / 255) as Triple;\n}\n\nfunction toHex(c: Triple): string {\n return \"#\" + c.map((v) => Math.round(Math.min(1, Math.max(0, v)) * 255).toString(16).padStart(2, \"0\")).join(\"\");\n}\n\nconst toLinear = (v: number) => (v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);\nconst fromLinear = (v: number) => (v <= 0.0031308 ? v * 12.92 : 1.055 * v ** (1 / 2.4) - 0.055);\n\nfunction srgbToOklab(c: Triple): Triple {\n const [r, g, b] = c.map(toLinear) as Triple;\n const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);\n const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);\n const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);\n return [\n 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,\n 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,\n 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,\n ];\n}\n\nfunction oklabToSrgb([L, a, b]: Triple): Triple {\n const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;\n const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;\n const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;\n return [\n 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,\n ].map((v) => fromLinear(Math.max(0, v))) as Triple;\n}\n\n/** Pixels as RGBA bytes, row by row: what a canvas's `getImageData` returns. */\nexport interface Pixels {\n width: number;\n height: number;\n data: ArrayLike<number>;\n}\n\nexport interface ImageFillOptions {\n /**\n * How the image is laid over the layout bounds: \"cover\" (default; cropped to fill them,\n * centerd, like the `backdrop` prop), \"contain\" (whole image, centerd) or \"stretch\".\n */\n fit?: \"cover\" | \"contain\" | \"stretch\";\n /**\n * Snap each tile's color to the nearest of these hex colors (judged in OKLab), as if\n * choosing from a box of real mosaic tiles. Omit for the exact average.\n */\n palette?: readonly string[];\n /** Color for tiles with no image under them (with \"contain\", or a transparent image). */\n fallback?: string;\n /** Most pixels sampled per tile; more is smoother but slower. Defaults to 256. */\n samples?: number;\n}\n\n/**\n * Color each tile with the average color of the image under it, for a mosaic. Averages are\n * taken in linear light (as the eye would mix the colors from a distance) and weighted by\n * alpha. Colors are computed once per layout, on first use.\n *\n * `pixels` is plain RGBA data, so this works anywhere; in a browser, `loadImagePixels` gets\n * it from a URL.\n */\nexport function imageFill(pixels: Pixels, options: ImageFillOptions = {}): CellFill {\n const { fit = \"cover\", fallback = \"#d6d3d1\", samples = 256 } = options;\n const palette = options.palette?.map((c) => ({ hex: toHex(parseHex(c, \"imageFill\")), lab: srgbToOklab(parseHex(c, \"imageFill\")) }));\n const lin = Array.from({ length: 256 }, (_, i) => toLinear(i / 255));\n const { width: iw, height: ih, data } = pixels;\n const cache = new WeakMap<Layout, string[]>();\n\n const colorsFor = (layout: Layout): string[] => {\n const b = layout.bounds;\n // Layout point → image pixel: x' = (x - b.x) * sx + ox.\n let sx = iw / (b.width || 1), sy = ih / (b.height || 1);\n if (fit !== \"stretch\") {\n const k = fit === \"cover\" ? Math.min(sx, sy) : Math.max(sx, sy);\n sx = sy = k;\n }\n const ox = (iw - b.width * sx) / 2, oy = (ih - b.height * sy) / 2;\n\n return layout.cells.map((cell) => {\n const bb = cell.bbox;\n const pxW = bb.width * sx, pxH = bb.height * sy;\n // Sample a grid over the cell's box, at most `samples` points, at least 1 pixel apart.\n const step = Math.max(1, Math.sqrt((pxW * pxH) / Math.max(1, samples)));\n let r = 0, g = 0, bl = 0, w = 0;\n const add = (x: number, y: number) => {\n const px = Math.floor((x - b.x) * sx + ox), py = Math.floor((y - b.y) * sy + oy);\n if (px < 0 || py < 0 || px >= iw || py >= ih) return;\n const i = (py * iw + px) * 4;\n const a = data[i + 3]! / 255;\n if (a <= 0) return;\n r += lin[data[i]!]! * a;\n g += lin[data[i + 1]!]! * a;\n bl += lin[data[i + 2]!]! * a;\n w += a;\n };\n const inside = (x: number, y: number) =>\n pointInPolygon({ x, y }, cell.polygon) && !(cell.holes ?? []).some((h) => pointInPolygon({ x, y }, h));\n const nx = Math.max(1, Math.round(pxW / step)), ny = Math.max(1, Math.round(pxH / step));\n for (let i = 0; i < nx; i++) {\n for (let j = 0; j < ny; j++) {\n const x = bb.x + ((i + 0.5) / nx) * bb.width, y = bb.y + ((j + 0.5) / ny) * bb.height;\n if (inside(x, y)) add(x, y);\n }\n }\n // A tile too thin for the grid to land in: use its center.\n if (w === 0) add(cell.centroid.x, cell.centroid.y);\n if (w === 0) return fallback;\n const avg: Triple = [fromLinear(r / w), fromLinear(g / w), fromLinear(bl / w)];\n if (!palette?.length) return toHex(avg);\n const lab = srgbToOklab(avg);\n let best = palette[0]!, bd = Infinity;\n for (const p of palette) {\n const d = (p.lab[0] - lab[0]) ** 2 + (p.lab[1] - lab[1]) ** 2 + (p.lab[2] - lab[2]) ** 2;\n if (d < bd) { bd = d; best = p; }\n }\n return best.hex;\n });\n };\n\n return (cell, layout) => {\n let colors = cache.get(layout);\n if (!colors) {\n colors = colorsFor(layout);\n cache.set(layout, colors);\n }\n return colors[cell.index] ?? fallback;\n };\n}\n\n/**\n * Browser helper: load an image and read its pixels, scaled down so the longer side is at\n * most `maxSize` (plenty for averaging, and fast). The image must be same-origin, a data\n * URL, or served with CORS headers; otherwise the browser refuses to read its pixels.\n */\nexport async function loadImagePixels(src: string, maxSize = 256): Promise<Pixels> {\n const doc = (globalThis as { document?: Document }).document;\n if (!doc) throw new Error(\"loadImagePixels needs a browser; elsewhere, decode the image yourself and pass its RGBA pixels\");\n const img = new Image();\n img.crossOrigin = \"anonymous\";\n img.decoding = \"async\";\n await new Promise<void>((resolve, reject) => {\n img.onload = () => resolve();\n img.onerror = () => reject(new Error(`Couldn't load image ${src.slice(0, 80)}`));\n img.src = src;\n });\n const k = Math.min(1, maxSize / Math.max(img.naturalWidth || 1, img.naturalHeight || 1));\n const w = Math.max(1, Math.round((img.naturalWidth || maxSize) * k));\n const h = Math.max(1, Math.round((img.naturalHeight || maxSize) * k));\n const canvas = doc.createElement(\"canvas\");\n canvas.width = w;\n canvas.height = h;\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) throw new Error(\"loadImagePixels: no 2D canvas available\");\n ctx.drawImage(img, 0, 0, w, h);\n return ctx.getImageData(0, 0, w, h);\n}\n","import type { ContentCells } from \"./content\";\nimport { createLayout, type Cell, type Layout, type LayoutOptions } from \"./layout\";\n\nexport interface FitOptions {\n /** Which cells count: \"all\" (default), \"whole\" (not cut by the region outline) or a test. */\n cells?: ContentCells;\n /**\n * \"atLeast\" (default): the largest tiles that still give at least `count` cells, so\n * every item has a tile. \"nearest\": whichever tile size gets closest to `count`.\n */\n mode?: \"atLeast\" | \"nearest\";\n}\n\nexport interface FitResult {\n /** The input options with `tileScale` set. */\n options: LayoutOptions;\n layout: Layout;\n tileScale: number;\n /** Number of cells that count (by `cells`) in `layout`. */\n count: number;\n}\n\n/**\n * Find a tile size giving about `count` usable cells: scales the pattern (`tileScale`)\n * and searches, laying out a few dozen times. The tile count changes in steps, and not\n * always monotonically (tiles at the edge come and go), so for random and aperiodic\n * patterns, or \"whole\" cells, the result may land a little above `count`.\n */\nexport function fitCount(options: LayoutOptions, count: number, fit: FitOptions = {}): FitResult {\n if (!(count >= 1) || !Number.isFinite(count)) throw new RangeError(`fitCount needs a count of at least 1 (got ${count})`);\n const n = Math.floor(count);\n const { cells = \"all\", mode = \"atLeast\" } = fit;\n const accept = cells === \"all\" ? () => true : cells === \"whole\" ? (c: Cell) => !c.boundary : cells;\n\n type Probe = { k: number; layout?: Layout; count: number; error?: unknown };\n const probe = (k: number): Probe => {\n try {\n const layout = createLayout({ ...options, tileScale: k });\n return { k, layout, count: layout.cells.filter((c) => accept(c)).length };\n } catch (error) {\n // Too many tiles for maxTiles: count as \"plenty\", but remember why.\n if (error instanceof RangeError && /maxTiles|limit/.test(error.message)) return { k, count: Infinity, error };\n throw error;\n }\n };\n\n // Bracket: lo has at least n cells, hi fewer. Counts scale roughly with 1/k².\n let p = probe(options.tileScale ?? 1);\n let lo: Probe | undefined;\n let hi: Probe | undefined;\n for (let i = 0; i < 60 && !(lo && hi); i++) {\n if (p.count >= n) lo = !lo || p.k > lo.k ? p : lo;\n else hi = !hi || p.k < hi.k ? p : hi;\n if (lo && hi) break;\n const guess = p.count > 0 && Number.isFinite(p.count) ? p.k * Math.sqrt(p.count / n) : p.k;\n // Always move by at least 25% so the bracket grows even when the guess is off.\n const next = p.count >= n ? Math.max(guess, p.k * 1.25) : Math.min(guess, p.k / 1.25);\n p = probe(next);\n }\n if (!lo || !hi) {\n if (lo?.layout) return result(options, lo);\n throw new RangeError(`fitCount: couldn't find a tile size giving ${n} cells`);\n }\n\n // Bisect (in log scale) for the largest tiles that still give at least n cells.\n for (let i = 0; i < 30 && hi.k / lo.k > 1.0005; i++) {\n const mid = probe(Math.sqrt(lo.k * hi.k));\n if (mid.count >= n) lo = mid;\n else hi = mid;\n }\n if (!lo.layout) throw lo.error;\n const pick = mode === \"nearest\" && hi.count > 0 && n - hi.count < lo.count - n ? hi : lo;\n return result(options, pick);\n}\n\nfunction result(options: LayoutOptions, p: { k: number; layout?: Layout; count: number }): FitResult {\n return { options: { ...options, tileScale: p.k }, layout: p.layout!, tileScale: p.k, count: p.count };\n}\n","import type { Rect, Vec } from \"./geometry\";\nimport type { Cell, Layout } from \"./layout\";\nimport type { Pixels } from \"./fills\";\nimport { safeArea } from \"./safe\";\nimport { cellShape } from \"./shape\";\n\n/**\n * A point in an image to keep in view, as fractions of its width and height ({ x: 0, y: 0 }\n * is the top left), and optionally the image's shape, so renderers can place it exactly\n * without being told the image's aspect elsewhere.\n */\nexport interface Focus {\n x: number;\n y: number;\n /** The image's width / height. */\n aspect?: number;\n}\n\nexport interface CoverOptions {\n /** The image's width / height (defaults to `focus.aspect`, else square). */\n aspect?: number;\n /** What to keep in view. Defaults to the middle, { x: 0.5, y: 0.5 }. */\n focus?: Focus;\n /**\n * Where the focus should land: the middle of the part of the cell that shows (\"visible\",\n * the default), or of the whole tile (\"tile\"), for a cell an `edges: \"window\"` layout cuts.\n * Either way it's the middle of the cell's safe area, so it's well inside the shape.\n */\n within?: \"tile\" | \"visible\";\n}\n\n/**\n * Where to draw an image (in layout units) so it covers a cell's box, like CSS\n * `object-fit: cover`, with its focal point as near as it can get to the middle of what\n * shows of the cell. A cut tile, a triangle or a tall thin tile then shows a photo's\n * subject rather than whatever was in the middle of the photo. Clip the image to the cell\n * as usual.\n */\nexport function coverRect(cell: Cell, layout: Pick<Layout, \"cornerRadius\" | \"view\">, options: CoverOptions): Rect {\n const box = cellShape(cell).bbox;\n const given = options.aspect ?? options.focus?.aspect;\n const aspect = given !== undefined && given > 0 && Number.isFinite(given) ? given : 1;\n const scale = Math.max(box.width / aspect, box.height);\n const width = scale * aspect, height = scale;\n const f = options.focus ?? { x: 0.5, y: 0.5 };\n const t = focusTarget(cell, layout, options.within);\n const clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));\n return {\n x: clamp(t.x - clamp(f.x, 0, 1) * width, box.x + box.width - width, box.x),\n y: clamp(t.y - clamp(f.y, 0, 1) * height, box.y + box.height - height, box.y),\n width,\n height,\n };\n}\n\n/**\n * CSS `object-position` for an image filling a cell's element with `object-fit: cover`\n * (as `coverStyle` does), placing it as `coverRect` does.\n */\nexport function objectPosition(cell: Cell, layout: Pick<Layout, \"cornerRadius\" | \"view\">, options: CoverOptions): string {\n const box = cellShape(cell).bbox;\n const r = coverRect(cell, layout, options);\n const pos = (spare: number, offset: number) => (spare > 1e-9 * (r.width + r.height) ? Number(((offset / spare) * 100).toFixed(3)) : 50);\n return `${pos(r.width - box.width, box.x - r.x)}% ${pos(r.height - box.height, box.y - r.y)}%`;\n}\n\n/** The middle of the cell's safe area: where a focal point should land. */\nfunction focusTarget(cell: Cell, layout: Pick<Layout, \"cornerRadius\" | \"view\">, within: \"tile\" | \"visible\" = \"visible\"): Vec {\n const s = safeArea(cell, layout, { within });\n return { x: s.x + s.width / 2, y: s.y + s.height / 2 };\n}\n\n/**\n * A guess at what a photo is of: the most eye-catching spot, where color and brightness\n * stand out most from their surroundings, with a slight preference for the middle. Good\n * for a subject against a plainer background (a face, a flower, a sun); for busy pictures\n * give the focus yourself. Pass small pixels (`loadImagePixels` gives at most 256 a side).\n * The result includes the image's `aspect`.\n */\nexport function estimateFocus(pixels: Pixels): Focus {\n const { width, height, data } = pixels;\n if (!(width > 0) || !(height > 0)) return { x: 0.5, y: 0.5 };\n const aspect = width / height;\n // Work at most 64 pixels a side.\n const step = Math.max(1, Math.ceil(Math.max(width, height) / 64));\n const w = Math.ceil(width / step), h = Math.ceil(height / step);\n const L = new Float64Array(w * h), A = new Float64Array(w * h), B = new Float64Array(w * h);\n for (let y = 0; y < h; y++) {\n for (let x = 0; x < w; x++) {\n let r = 0, g = 0, b = 0, n = 0;\n for (let yy = y * step; yy < Math.min(height, (y + 1) * step); yy++) {\n for (let xx = x * step; xx < Math.min(width, (x + 1) * step); xx++) {\n const k = (yy * width + xx) * 4;\n const alpha = (data[k + 3] ?? 255) / 255;\n // Transparent pixels count as white.\n r += (data[k]! * alpha + 255 * (1 - alpha)); g += (data[k + 1]! * alpha + 255 * (1 - alpha)); b += (data[k + 2]! * alpha + 255 * (1 - alpha)); n++;\n }\n }\n r /= n * 255; g /= n * 255; b /= n * 255;\n // A rough opponent color space: brightness and two color axes.\n const i = y * w + x;\n L[i] = 0.299 * r + 0.587 * g + 0.114 * b;\n A[i] = r - g;\n B[i] = (r + g) / 2 - b;\n }\n }\n // How much each spot differs from its surroundings (center minus surround), at two scales.\n const size = Math.max(w, h);\n const near = Math.max(1, Math.round(size / 32)), far = Math.max(2, Math.round(size / 6));\n const blur = (src: Float64Array, r: number) => boxBlur(boxBlur(src, w, h, r), w, h, r);\n const sal = new Float64Array(w * h);\n for (const [chan, weight] of [[L, 1], [A, 1.5], [B, 1.5]] as const) {\n const c = blur(chan, near), s = blur(chan, far);\n for (let i = 0; i < sal.length; i++) sal[i]! += weight * Math.abs(c[i]! - s[i]!);\n }\n // Favor a blob over a thin line: smooth, then pick the peak, leaning a little to the middle.\n const smooth = blur(sal, Math.max(1, Math.round(size / 16)));\n let best = -1, bx = w / 2, by = h / 2;\n for (let y = 0; y < h; y++) {\n for (let x = 0; x < w; x++) {\n const d = Math.hypot((x + 0.5) / w - 0.5, (y + 0.5) / h - 0.5);\n const v = smooth[y * w + x]! * (1 - 0.4 * d);\n if (v > best) { best = v; bx = x + 0.5; by = y + 0.5; }\n }\n }\n return best > 1e-6 ? { x: Math.min(1, (bx * step) / width), y: Math.min(1, (by * step) / height), aspect } : { x: 0.5, y: 0.5, aspect };\n}\n\n/** Box blur of radius `r`, along rows then columns, with edges extended. */\nfunction boxBlur(src: Float64Array, w: number, h: number, r: number): Float64Array {\n const tmp = new Float64Array(src.length), out = new Float64Array(src.length);\n const pass = (from: Float64Array, to: Float64Array, len: number, lines: number, at: (line: number, k: number) => number) => {\n for (let line = 0; line < lines; line++) {\n let sum = 0;\n for (let k = -r; k <= r; k++) sum += from[at(line, Math.min(len - 1, Math.max(0, k)))]!;\n for (let k = 0; k < len; k++) {\n to[at(line, k)] = sum / (2 * r + 1);\n sum += from[at(line, Math.min(len - 1, k + r + 1))]! - from[at(line, Math.max(0, k - r))]!;\n }\n }\n };\n pass(src, tmp, w, h, (y, x) => y * w + x);\n pass(tmp, out, h, w, (x, y) => y * w + x);\n return out;\n}\n","import { area, centroid, vec, type Vec } from \"./geometry\";\nimport { contentSlots, type ContentCells, type ContentPlacement } from \"./content\";\nimport { fitCount } from \"./fit\";\nimport { createLayout, type Cell, type Feature, type Layout, type LayoutOptions } from \"./layout\";\n\nexport interface WeightOptions {\n /** Which cells may hold items: \"all\" (default), \"whole\" (not cut by the outline) or a test. */\n cells?: ContentCells;\n /** Where items go when there are fewer than cells: \"reading\" (default), \"center\" or \"spread\". */\n placement?: ContentPlacement;\n}\n\n/** The tiles each item spans: its weight, rounded, and at least 1. */\nexport const tileSpans = (weights: readonly number[]): number[] =>\n weights.map((w) => (Number.isFinite(w) ? Math.max(1, Math.round(w)) : 1));\n\n/**\n * Featured tiles for items of different importance. `weights` gives how many tiles each\n * item should span (1 for an ordinary item; rounded); each item over 1 gets a feature of\n * that many merged tiles, for it (`Feature.item`), centerd where its tiles would be if every\n * item took its share of `layout`'s cells in order (so the reading order of the items is\n * kept). Bigger features come first, so they get room. `layout` should have no features\n * of its own. See `weightedLayout` for the whole job.\n */\nexport function weightedFeatures(layout: Layout, weights: readonly number[], options: WeightOptions = {}): Feature[] {\n const spans = tileSpans(weights);\n const total = spans.reduce((s, w) => s + w, 0);\n if (!spans.some((w) => w > 1)) return [];\n // The cells the items would fill, one tile at a time, in order.\n const slots = contentSlots(layout, total, options);\n const byTile: Cell[] = [];\n slots.forEach((slot, i) => {\n if (slot >= 0) byTile[slot] = layout.cells[i]!;\n });\n const features: Feature[] = [];\n let start = 0;\n spans.forEach((w, item) => {\n if (w > 1) {\n // Items past the last cell have nowhere to go, so get no feature.\n const cells = byTile.slice(start, start + w).filter(Boolean);\n if (cells.length) features.push({ tiles: w, at: middle(cells), item });\n }\n start += w;\n });\n return features.sort((a, b) => b.tiles! - a.tiles! || a.item! - b.item!);\n}\n\n/** Area-weighted center of some cells. */\nfunction middle(cells: Cell[]): Vec {\n let x = 0, y = 0, w = 0;\n for (const c of cells) {\n const a = c.area || area(c.polygon);\n const m = c.centroid ?? centroid(c.polygon);\n x += m.x * a; y += m.y * a; w += a;\n }\n return vec(x / (w || 1), y / (w || 1));\n}\n\nexport interface WeightedLayoutOptions extends WeightOptions {\n /**\n * Size the tiles so the items fit, counting each item's weight in tiles (see `fitCount`):\n * `true` / \"atLeast\" for the largest tiles that fit everything, \"nearest\" for the closest\n * count.\n */\n fit?: boolean | \"atLeast\" | \"nearest\";\n}\n\nexport interface WeightedLayoutResult {\n /** The options used: `tileScale` from `fit`, and `features` with the weighted ones added. */\n options: LayoutOptions;\n layout: Layout;\n /** The features made for the weighted items (also in `options.features`). */\n features: Feature[];\n}\n\n/**\n * A layout for items of different importance: `weights` gives how many tiles each item\n * spans (1 for ordinary items), and each heavier item gets a featured tile that big, where\n * it falls in the items' reading order (see `weightedFeatures`). With `fit`, the tiles are\n * sized so all the items fit. `contentSlots` and `matchSlots` on the result put each item\n * in its own featured cell. Features already in `options` are kept, before the weighted ones.\n */\nexport function weightedLayout(options: LayoutOptions, weights: readonly number[], settings: WeightedLayoutOptions = {}): WeightedLayoutResult {\n const { fit, ...content } = settings;\n const spans = tileSpans(weights);\n const total = spans.reduce((s, w) => s + w, 0);\n const plain: LayoutOptions = { ...options, features: undefined };\n let base: LayoutOptions = options;\n let baseLayout: Layout | undefined;\n if (fit && total >= 1) {\n const r = fitCount(plain, total, { cells: content.cells, mode: fit === \"nearest\" ? \"nearest\" : \"atLeast\" });\n base = { ...options, tileScale: r.tileScale };\n baseLayout = r.layout;\n }\n const features = spans.some((w) => w > 1) ? weightedFeatures(baseLayout ?? createLayout({ ...base, features: undefined }), weights, content) : [];\n const all = [...(options.features ?? []), ...features];\n const final: LayoutOptions = { ...base };\n if (all.length) final.features = all;\n else delete final.features;\n const layout = !features.length && baseLayout && !options.features?.length ? baseLayout : createLayout(final);\n return { options: final, layout, features };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgLA,SAAS,UAAU,QAAiC;AAClD,MAAI,MAAM,QAAQ,MAAM,EAAG,QAAO,OAAO,IAAI,CAAC,MAAM,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;AACjE,SAAO,YAAY,OAAO,GAAG,OAAO,GAAG,OAAO,OAAO,OAAO,MAAM;AACpE;AAEO,SAAS,aAAa,SAAgC;AAC3D,QAAM,SAAS,eAAe,UAAU,QAAQ,MAAM,CAAC;AACv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