@labmgm/patterns 0.1.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/README.md +66 -0
- package/dist/generator-URuC3uDY.d.cts +179 -0
- package/dist/generator-URuC3uDY.d.ts +179 -0
- package/dist/generator.cjs +826 -0
- package/dist/generator.cjs.map +1 -0
- package/dist/generator.d.cts +1 -0
- package/dist/generator.d.ts +1 -0
- package/dist/generator.js +823 -0
- package/dist/generator.js.map +1 -0
- package/dist/index.cjs +1003 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +119 -0
- package/dist/index.d.ts +119 -0
- package/dist/index.js +982 -0
- package/dist/index.js.map +1 -0
- package/package.json +73 -0
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# @labmgm/patterns
|
|
2
|
+
|
|
3
|
+
The signature geometric pattern engine for the MGM Laboratory Design System — deterministic seeded composition with algorithmic adjacency colour-graph enforcement.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @labmgm/patterns react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Use
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Pattern, Logo, Wordmark } from "@labmgm/patterns";
|
|
15
|
+
|
|
16
|
+
// Corner cluster, default 3×3 at 40 px per cell.
|
|
17
|
+
<Pattern variant="corner" seed={42} />
|
|
18
|
+
|
|
19
|
+
// Vertical auth-page banner.
|
|
20
|
+
<Pattern variant="edge-strip" grid="9x2" cellSize={40} seed={1} />
|
|
21
|
+
|
|
22
|
+
// The 8 px footer dado (brand spec §7.8) — strict colour cycle, no shapes.
|
|
23
|
+
<Pattern variant="dado-footer" />
|
|
24
|
+
|
|
25
|
+
// Tile-driven mode — use one of the curated SVGs in ./patterns as the cell.
|
|
26
|
+
<Pattern variant="corner" seed={42} base="p-1" />
|
|
27
|
+
<Pattern variant="corner" seed={42} pool={["p-1", "p-2", "p-10"]} />
|
|
28
|
+
|
|
29
|
+
// Wordmark + signature mark.
|
|
30
|
+
<Wordmark size={32} />
|
|
31
|
+
<Logo size={24} />
|
|
32
|
+
<Logo size={24} monochrome />
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## What the engine guarantees
|
|
36
|
+
|
|
37
|
+
- **Deterministic by seed.** `(variant, grid, seed, cellSize, base | pool)` → byte-identical SVG every time.
|
|
38
|
+
- **Adjacency constraint enforced.** No two 4-connected cells share a background colour. Implemented with greedy graph-colouring + backtracking over a 5-colour palette (brand-blue / yellow / red / green + white). Verified by a Vitest suite that runs 100 seeds × 5 grid shapes per build.
|
|
39
|
+
- **Brand-spec colour rules.** White-background cells get a coloured shape; coloured-background cells get a white shape (brand spec §5.2). The dado variant cycles strictly through blue → yellow → red → green and uses no shapes.
|
|
40
|
+
- **Tile catalog.** 80 curated SVG tiles live in `./patterns`. The build script `pnpm gen:tiles` parses them into `src/tiles-catalog.ts`; the generator can render any cell from a named tile (`base`) or pick from a sub-pool (`pool`). Tile shapes are recoloured per cell so adjacency still holds.
|
|
41
|
+
|
|
42
|
+
## Variants
|
|
43
|
+
|
|
44
|
+
| Variant | Default grid | Default cell | Where to use |
|
|
45
|
+
| --------------- | ------------ | ------------ | -------------------------------------------------- |
|
|
46
|
+
| `corner` | 3 × 3 | 40 px | Top-left / top-right corner of a hero (≤ 30% area) |
|
|
47
|
+
| `edge-strip` | 9 × 2 | 40 px | Auth-page vertical banner (brand spec §10.2) |
|
|
48
|
+
| `divider-strip` | 1 × 12 | 32 px | Section dividers between two major sections |
|
|
49
|
+
| `dado-footer` | 1 × 32 | 8 px | Brand-spec §7.8 — 8 px alternating footer band |
|
|
50
|
+
| `full-scene` | 5 × 6 | 80 px | 404 / empty-state asymmetric 5/7 illustration |
|
|
51
|
+
|
|
52
|
+
## API
|
|
53
|
+
|
|
54
|
+
| Export | Description |
|
|
55
|
+
| ----------------------- | ------------------------------------------------------------------------ |
|
|
56
|
+
| `<Pattern>` | React component. Decorative by default (`aria-hidden`). |
|
|
57
|
+
| `<Logo>` / `<Wordmark>` | The brand mark + wordmark (brand spec §5.5). `monochrome` for one-tone. |
|
|
58
|
+
| `generatePatternData()` | Pure function — returns the structured cell list. Use for custom render. |
|
|
59
|
+
| `generatePatternSvg()` | Pure function — returns a paste-ready standalone SVG string. |
|
|
60
|
+
| `colourGrid()` | Standalone adjacency solver (returned colours; no shapes). |
|
|
61
|
+
| `SHAPES` / `PALETTE` | The fixed shape vocabulary + 5-colour palette. |
|
|
62
|
+
| `TILES` / `TILE_BY_ID` | Auto-generated catalog of the curated SVG tiles in `./patterns`. |
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
MIT © MGM Laboratory.
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fixed 5-colour palette used by every pattern block.
|
|
3
|
+
*
|
|
4
|
+
* Brand spec §5.2: "Use all four brand colors plus white. Never substitute
|
|
5
|
+
* or omit one." The colours themselves come from spec §2.1.
|
|
6
|
+
*/
|
|
7
|
+
type PaletteColor = "blue" | "yellow" | "red" | "green" | "white";
|
|
8
|
+
declare const PALETTE: readonly PaletteColor[];
|
|
9
|
+
/** CSS-variable hooks so the palette switches with the active theme. */
|
|
10
|
+
declare const PALETTE_VAR: Record<PaletteColor, string>;
|
|
11
|
+
/** Hard-coded hex for stand-alone SVG (no CSS-var support). */
|
|
12
|
+
declare const PALETTE_HEX: Record<PaletteColor, string>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Adjacency colour-graph solver.
|
|
16
|
+
*
|
|
17
|
+
* Brand spec §5.2: "No two adjacent cells share the same dominant color."
|
|
18
|
+
*
|
|
19
|
+
* Given a grid of cells (4-connected) and a palette of 5 colours, we want
|
|
20
|
+
* to assign every cell a background colour so no neighbour matches. With
|
|
21
|
+
* 5 colours on a rectangular grid this is always solvable — but we want
|
|
22
|
+
* the assignment to be *deterministic by seed* so the same `(grid, seed)`
|
|
23
|
+
* always renders identically.
|
|
24
|
+
*
|
|
25
|
+
* Algorithm: greedy with backtracking.
|
|
26
|
+
* 1. Visit cells in a seed-shuffled order.
|
|
27
|
+
* 2. Try each palette colour, also in seed-shuffled order.
|
|
28
|
+
* 3. Skip colours that match any already-assigned neighbour.
|
|
29
|
+
* 4. If no colour fits, backtrack to the previous cell and pick the next
|
|
30
|
+
* candidate. With 5 colours and ≤ 4 neighbours, a fit is always
|
|
31
|
+
* reachable from any prefix — we still cap recursion at `MAX_DEPTH`
|
|
32
|
+
* to guard against pathological inputs.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
interface GridCell {
|
|
36
|
+
row: number;
|
|
37
|
+
col: number;
|
|
38
|
+
}
|
|
39
|
+
interface ColouredCell extends GridCell {
|
|
40
|
+
background: PaletteColor;
|
|
41
|
+
}
|
|
42
|
+
interface SolverOptions {
|
|
43
|
+
rows: number;
|
|
44
|
+
cols: number;
|
|
45
|
+
seed: number;
|
|
46
|
+
}
|
|
47
|
+
declare function colourGrid({ rows, cols, seed }: SolverOptions): ColouredCell[];
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The geometric shape vocabulary — brand spec §5.1.
|
|
51
|
+
*
|
|
52
|
+
* Each shape is a pure SVG body function returning the inner markup for a
|
|
53
|
+
* single cell of size `cellSize`. The cell's background is rendered by the
|
|
54
|
+
* pattern composer; shapes draw on top in `shapeColor`.
|
|
55
|
+
*/
|
|
56
|
+
type ShapeName = "circle" | "circle-ring" | "square" | "square-inset" | "triangle" | "x" | "plus" | "quarter-disc" | "half-disc" | "flower" | "diamond";
|
|
57
|
+
declare const SHAPES: readonly ShapeName[];
|
|
58
|
+
interface RenderArgs {
|
|
59
|
+
/** Cell side in user units (the cell origin is at 0,0). */
|
|
60
|
+
size: number;
|
|
61
|
+
/** Fill / stroke colour for the shape. */
|
|
62
|
+
color: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns the inner SVG markup for the named shape, sized to `size`.
|
|
66
|
+
* Coordinates are local to the cell — the composer translates the result
|
|
67
|
+
* to its final grid position.
|
|
68
|
+
*/
|
|
69
|
+
declare function renderShape(name: ShapeName, args: RenderArgs): string;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Auto-generated tile catalog. Do not edit by hand — run `pnpm gen:tiles`.
|
|
73
|
+
*
|
|
74
|
+
* Each entry maps a file in ./patterns/ to the data the generator needs:
|
|
75
|
+
* - `background` — palette name of the tile's original background.
|
|
76
|
+
* - `shapeColor` — palette name of the tile's original shape colour.
|
|
77
|
+
* - `shapeMarkup` — the inner SVG (paths/circles/rects) with the original
|
|
78
|
+
* background <rect> removed and every occurrence of the original shape
|
|
79
|
+
* colour replaced by the placeholder `{{SHAPE_COLOR}}`. Renderers
|
|
80
|
+
* substitute a contrast-aware palette colour at composition time.
|
|
81
|
+
*
|
|
82
|
+
* All tiles share the same 100×100 viewBox.
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
interface Tile {
|
|
86
|
+
id: string;
|
|
87
|
+
background: PaletteColor;
|
|
88
|
+
shapeColor: PaletteColor;
|
|
89
|
+
shapeMarkup: string;
|
|
90
|
+
}
|
|
91
|
+
declare const TILE_VIEWBOX_SIZE = 100;
|
|
92
|
+
declare const TILES: readonly Tile[];
|
|
93
|
+
declare const TILE_BY_ID: Readonly<Record<string, Tile>>;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Shape variants — the placement contexts brand spec §5.3 allows.
|
|
97
|
+
*
|
|
98
|
+
* - `corner` — square / rectangular cluster anchored at a corner.
|
|
99
|
+
* - `edge-strip` — vertical strip along one side (auth-page banner).
|
|
100
|
+
* - `divider-strip`— horizontal strip between two sections.
|
|
101
|
+
* - `dado-footer` — the 8 px alternating row at the bottom of every page.
|
|
102
|
+
* - `full-scene` — 404 / empty-state illustration (left half of asymmetric 5/7).
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
type PatternVariant = "corner" | "edge-strip" | "divider-strip" | "dado-footer" | "full-scene";
|
|
106
|
+
type GridShape = `${number}x${number}`;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Pattern SVG generator.
|
|
110
|
+
*
|
|
111
|
+
* Two render modes share the same adjacency-safe colour-graph backbone:
|
|
112
|
+
*
|
|
113
|
+
* 1. **Procedural shape mode** (default) — picks a shape from `SHAPES` per
|
|
114
|
+
* cell and renders it via `renderShape()`. The historical behaviour.
|
|
115
|
+
*
|
|
116
|
+
* 2. **Tile mode** — when the caller supplies `base` (single id) or `pool`
|
|
117
|
+
* (list of ids), every cell renders one of those tiles from the
|
|
118
|
+
* auto-generated catalog (./tiles-catalog.ts, sourced from
|
|
119
|
+
* ./patterns/*.svg). The tile's shape markup is recoloured to contrast
|
|
120
|
+
* against the cell's assigned background.
|
|
121
|
+
*
|
|
122
|
+
* Output is deterministic by `(variant, grid, seed, cellSize, base | pool)`.
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
interface PatternOptions {
|
|
126
|
+
variant: PatternVariant;
|
|
127
|
+
/** Override the default grid dimensions for the variant. */
|
|
128
|
+
grid?: GridShape;
|
|
129
|
+
/** Override the cell side in pixels. */
|
|
130
|
+
cellSize?: number;
|
|
131
|
+
/** Determinism seed. */
|
|
132
|
+
seed?: number;
|
|
133
|
+
/** Use raw hex (`#3a6dc5`) instead of CSS variables — useful when the SVG is exported. */
|
|
134
|
+
useHex?: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Render every cell from the named tile in ./patterns (e.g. `"p-1"`).
|
|
137
|
+
* The tile's shape is recoloured per-cell so it contrasts the adjacency-safe
|
|
138
|
+
* background the colour-graph picks.
|
|
139
|
+
*/
|
|
140
|
+
base?: string;
|
|
141
|
+
/**
|
|
142
|
+
* Like `base` but the generator picks one of the listed tiles per cell.
|
|
143
|
+
* Ignored when `base` is also supplied.
|
|
144
|
+
*/
|
|
145
|
+
pool?: readonly string[];
|
|
146
|
+
}
|
|
147
|
+
interface PatternCell extends ColouredCell {
|
|
148
|
+
shape: ShapeName | null;
|
|
149
|
+
shapeColor: string;
|
|
150
|
+
backgroundColor: string;
|
|
151
|
+
/** Set when the cell was rendered from a tile (tile mode). */
|
|
152
|
+
tile: Tile | null;
|
|
153
|
+
/** Inline SVG markup for the tile's shape, recoloured. Empty in procedural mode. */
|
|
154
|
+
tileMarkup: string;
|
|
155
|
+
}
|
|
156
|
+
interface PatternData {
|
|
157
|
+
cells: PatternCell[];
|
|
158
|
+
width: number;
|
|
159
|
+
height: number;
|
|
160
|
+
rows: number;
|
|
161
|
+
cols: number;
|
|
162
|
+
cellSize: number;
|
|
163
|
+
viewBox: string;
|
|
164
|
+
/** True when cells were rendered from the tile catalog. */
|
|
165
|
+
tileMode: boolean;
|
|
166
|
+
/** When `tileMode` is true, the tile viewBox edge length (always 100). */
|
|
167
|
+
tileViewBox: number;
|
|
168
|
+
}
|
|
169
|
+
declare function generatePatternData(options: PatternOptions): PatternData;
|
|
170
|
+
/**
|
|
171
|
+
* Render the pattern to a standalone SVG string.
|
|
172
|
+
*
|
|
173
|
+
* Useful for the docs site's "Copy SVG" affordance — produces a paste-ready
|
|
174
|
+
* `<svg>` block with hex colours baked in (`useHex: true`) so the artwork
|
|
175
|
+
* renders without our CSS variables.
|
|
176
|
+
*/
|
|
177
|
+
declare function generatePatternSvg(options: PatternOptions): string;
|
|
178
|
+
|
|
179
|
+
export { type ColouredCell as C, type GridShape as G, PALETTE as P, SHAPES as S, TILES as T, PALETTE_HEX as a, PALETTE_VAR as b, type PaletteColor as c, type PatternCell as d, type PatternData as e, type PatternOptions as f, type PatternVariant as g, type ShapeName as h, TILE_BY_ID as i, TILE_VIEWBOX_SIZE as j, type Tile as k, colourGrid as l, generatePatternData as m, generatePatternSvg as n, renderShape as r };
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fixed 5-colour palette used by every pattern block.
|
|
3
|
+
*
|
|
4
|
+
* Brand spec §5.2: "Use all four brand colors plus white. Never substitute
|
|
5
|
+
* or omit one." The colours themselves come from spec §2.1.
|
|
6
|
+
*/
|
|
7
|
+
type PaletteColor = "blue" | "yellow" | "red" | "green" | "white";
|
|
8
|
+
declare const PALETTE: readonly PaletteColor[];
|
|
9
|
+
/** CSS-variable hooks so the palette switches with the active theme. */
|
|
10
|
+
declare const PALETTE_VAR: Record<PaletteColor, string>;
|
|
11
|
+
/** Hard-coded hex for stand-alone SVG (no CSS-var support). */
|
|
12
|
+
declare const PALETTE_HEX: Record<PaletteColor, string>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Adjacency colour-graph solver.
|
|
16
|
+
*
|
|
17
|
+
* Brand spec §5.2: "No two adjacent cells share the same dominant color."
|
|
18
|
+
*
|
|
19
|
+
* Given a grid of cells (4-connected) and a palette of 5 colours, we want
|
|
20
|
+
* to assign every cell a background colour so no neighbour matches. With
|
|
21
|
+
* 5 colours on a rectangular grid this is always solvable — but we want
|
|
22
|
+
* the assignment to be *deterministic by seed* so the same `(grid, seed)`
|
|
23
|
+
* always renders identically.
|
|
24
|
+
*
|
|
25
|
+
* Algorithm: greedy with backtracking.
|
|
26
|
+
* 1. Visit cells in a seed-shuffled order.
|
|
27
|
+
* 2. Try each palette colour, also in seed-shuffled order.
|
|
28
|
+
* 3. Skip colours that match any already-assigned neighbour.
|
|
29
|
+
* 4. If no colour fits, backtrack to the previous cell and pick the next
|
|
30
|
+
* candidate. With 5 colours and ≤ 4 neighbours, a fit is always
|
|
31
|
+
* reachable from any prefix — we still cap recursion at `MAX_DEPTH`
|
|
32
|
+
* to guard against pathological inputs.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
interface GridCell {
|
|
36
|
+
row: number;
|
|
37
|
+
col: number;
|
|
38
|
+
}
|
|
39
|
+
interface ColouredCell extends GridCell {
|
|
40
|
+
background: PaletteColor;
|
|
41
|
+
}
|
|
42
|
+
interface SolverOptions {
|
|
43
|
+
rows: number;
|
|
44
|
+
cols: number;
|
|
45
|
+
seed: number;
|
|
46
|
+
}
|
|
47
|
+
declare function colourGrid({ rows, cols, seed }: SolverOptions): ColouredCell[];
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The geometric shape vocabulary — brand spec §5.1.
|
|
51
|
+
*
|
|
52
|
+
* Each shape is a pure SVG body function returning the inner markup for a
|
|
53
|
+
* single cell of size `cellSize`. The cell's background is rendered by the
|
|
54
|
+
* pattern composer; shapes draw on top in `shapeColor`.
|
|
55
|
+
*/
|
|
56
|
+
type ShapeName = "circle" | "circle-ring" | "square" | "square-inset" | "triangle" | "x" | "plus" | "quarter-disc" | "half-disc" | "flower" | "diamond";
|
|
57
|
+
declare const SHAPES: readonly ShapeName[];
|
|
58
|
+
interface RenderArgs {
|
|
59
|
+
/** Cell side in user units (the cell origin is at 0,0). */
|
|
60
|
+
size: number;
|
|
61
|
+
/** Fill / stroke colour for the shape. */
|
|
62
|
+
color: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns the inner SVG markup for the named shape, sized to `size`.
|
|
66
|
+
* Coordinates are local to the cell — the composer translates the result
|
|
67
|
+
* to its final grid position.
|
|
68
|
+
*/
|
|
69
|
+
declare function renderShape(name: ShapeName, args: RenderArgs): string;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Auto-generated tile catalog. Do not edit by hand — run `pnpm gen:tiles`.
|
|
73
|
+
*
|
|
74
|
+
* Each entry maps a file in ./patterns/ to the data the generator needs:
|
|
75
|
+
* - `background` — palette name of the tile's original background.
|
|
76
|
+
* - `shapeColor` — palette name of the tile's original shape colour.
|
|
77
|
+
* - `shapeMarkup` — the inner SVG (paths/circles/rects) with the original
|
|
78
|
+
* background <rect> removed and every occurrence of the original shape
|
|
79
|
+
* colour replaced by the placeholder `{{SHAPE_COLOR}}`. Renderers
|
|
80
|
+
* substitute a contrast-aware palette colour at composition time.
|
|
81
|
+
*
|
|
82
|
+
* All tiles share the same 100×100 viewBox.
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
interface Tile {
|
|
86
|
+
id: string;
|
|
87
|
+
background: PaletteColor;
|
|
88
|
+
shapeColor: PaletteColor;
|
|
89
|
+
shapeMarkup: string;
|
|
90
|
+
}
|
|
91
|
+
declare const TILE_VIEWBOX_SIZE = 100;
|
|
92
|
+
declare const TILES: readonly Tile[];
|
|
93
|
+
declare const TILE_BY_ID: Readonly<Record<string, Tile>>;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Shape variants — the placement contexts brand spec §5.3 allows.
|
|
97
|
+
*
|
|
98
|
+
* - `corner` — square / rectangular cluster anchored at a corner.
|
|
99
|
+
* - `edge-strip` — vertical strip along one side (auth-page banner).
|
|
100
|
+
* - `divider-strip`— horizontal strip between two sections.
|
|
101
|
+
* - `dado-footer` — the 8 px alternating row at the bottom of every page.
|
|
102
|
+
* - `full-scene` — 404 / empty-state illustration (left half of asymmetric 5/7).
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
type PatternVariant = "corner" | "edge-strip" | "divider-strip" | "dado-footer" | "full-scene";
|
|
106
|
+
type GridShape = `${number}x${number}`;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Pattern SVG generator.
|
|
110
|
+
*
|
|
111
|
+
* Two render modes share the same adjacency-safe colour-graph backbone:
|
|
112
|
+
*
|
|
113
|
+
* 1. **Procedural shape mode** (default) — picks a shape from `SHAPES` per
|
|
114
|
+
* cell and renders it via `renderShape()`. The historical behaviour.
|
|
115
|
+
*
|
|
116
|
+
* 2. **Tile mode** — when the caller supplies `base` (single id) or `pool`
|
|
117
|
+
* (list of ids), every cell renders one of those tiles from the
|
|
118
|
+
* auto-generated catalog (./tiles-catalog.ts, sourced from
|
|
119
|
+
* ./patterns/*.svg). The tile's shape markup is recoloured to contrast
|
|
120
|
+
* against the cell's assigned background.
|
|
121
|
+
*
|
|
122
|
+
* Output is deterministic by `(variant, grid, seed, cellSize, base | pool)`.
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
interface PatternOptions {
|
|
126
|
+
variant: PatternVariant;
|
|
127
|
+
/** Override the default grid dimensions for the variant. */
|
|
128
|
+
grid?: GridShape;
|
|
129
|
+
/** Override the cell side in pixels. */
|
|
130
|
+
cellSize?: number;
|
|
131
|
+
/** Determinism seed. */
|
|
132
|
+
seed?: number;
|
|
133
|
+
/** Use raw hex (`#3a6dc5`) instead of CSS variables — useful when the SVG is exported. */
|
|
134
|
+
useHex?: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Render every cell from the named tile in ./patterns (e.g. `"p-1"`).
|
|
137
|
+
* The tile's shape is recoloured per-cell so it contrasts the adjacency-safe
|
|
138
|
+
* background the colour-graph picks.
|
|
139
|
+
*/
|
|
140
|
+
base?: string;
|
|
141
|
+
/**
|
|
142
|
+
* Like `base` but the generator picks one of the listed tiles per cell.
|
|
143
|
+
* Ignored when `base` is also supplied.
|
|
144
|
+
*/
|
|
145
|
+
pool?: readonly string[];
|
|
146
|
+
}
|
|
147
|
+
interface PatternCell extends ColouredCell {
|
|
148
|
+
shape: ShapeName | null;
|
|
149
|
+
shapeColor: string;
|
|
150
|
+
backgroundColor: string;
|
|
151
|
+
/** Set when the cell was rendered from a tile (tile mode). */
|
|
152
|
+
tile: Tile | null;
|
|
153
|
+
/** Inline SVG markup for the tile's shape, recoloured. Empty in procedural mode. */
|
|
154
|
+
tileMarkup: string;
|
|
155
|
+
}
|
|
156
|
+
interface PatternData {
|
|
157
|
+
cells: PatternCell[];
|
|
158
|
+
width: number;
|
|
159
|
+
height: number;
|
|
160
|
+
rows: number;
|
|
161
|
+
cols: number;
|
|
162
|
+
cellSize: number;
|
|
163
|
+
viewBox: string;
|
|
164
|
+
/** True when cells were rendered from the tile catalog. */
|
|
165
|
+
tileMode: boolean;
|
|
166
|
+
/** When `tileMode` is true, the tile viewBox edge length (always 100). */
|
|
167
|
+
tileViewBox: number;
|
|
168
|
+
}
|
|
169
|
+
declare function generatePatternData(options: PatternOptions): PatternData;
|
|
170
|
+
/**
|
|
171
|
+
* Render the pattern to a standalone SVG string.
|
|
172
|
+
*
|
|
173
|
+
* Useful for the docs site's "Copy SVG" affordance — produces a paste-ready
|
|
174
|
+
* `<svg>` block with hex colours baked in (`useHex: true`) so the artwork
|
|
175
|
+
* renders without our CSS variables.
|
|
176
|
+
*/
|
|
177
|
+
declare function generatePatternSvg(options: PatternOptions): string;
|
|
178
|
+
|
|
179
|
+
export { type ColouredCell as C, type GridShape as G, PALETTE as P, SHAPES as S, TILES as T, PALETTE_HEX as a, PALETTE_VAR as b, type PaletteColor as c, type PatternCell as d, type PatternData as e, type PatternOptions as f, type PatternVariant as g, type ShapeName as h, TILE_BY_ID as i, TILE_VIEWBOX_SIZE as j, type Tile as k, colourGrid as l, generatePatternData as m, generatePatternSvg as n, renderShape as r };
|