@logomarks/generate 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/CHANGELOG.md CHANGED
@@ -1,6 +1,32 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.0 (2026-11-26)
3
+ ## 0.2.0 (2026-11-26)
4
+
5
+ Everything below came after 0.1.0 went to npm the same day: the quality pass (nine recipes removed, tuned shuffles,
6
+ `qualityOf`, `shuffled`, the weighted mix, `MAIN`) and fifteen new recipes. Removing recipes is a breaking change, hence
7
+ the minor version.
8
+
9
+
10
+ - Fifteen recipes after live house families (40 in all), each judged on sheets of its shuffles: `arcstep` (Arc Step),
11
+ `halfsq` (Half Square), `invert` (Inverted Rings), `leaves` (Leaf Tiles), `lobes` (Soft Pieces), `loops` (Petal
12
+ Loop), `trine` (three parts past the centre, never through it), `strips` (tape strips woven by the gap), `bite`
13
+ (Bite Link, its points rounded by exact arcs, no offsetting), `blades` (Blade Sweep), `wavecut` (Squiggle), `capsules`
14
+ (Capsule), `flare` (rays from a corner or a foot), `pixelarc` (Pixel Curve, one band) and `seam` (Notched Block: a
15
+ block parted by a seam with a joint). Each has its `TUNING`, `MAIN` and `MIX_WEIGHT`; five presets (29). Tried and
16
+ left out: Wedge (every keeper was one flat chevron, which `chevrons` draws), Dot Burst (sparse, a texture), Cross
17
+ Stripes (ragged once the edge crumbs go; its chevron divide is an envelope) and Bent Lines (too light at this
18
+ weight). Covered already: Stripe Shift (`stripes`), Chevron Stack (`chevrons`), Arch Nest and the Modernist corner
19
+ bands (`arcs`), Twin Turn (`twin`), Notched Block's single cuts (`cut`). Not drawn: Taper Lines, Dash Field (thin or
20
+ Morse), Ring Wave (a known symbol), Bead Wave.
21
+
22
+ - The quality pass (before release): nine recipes whose shuffles rarely gave a mark worth keeping are gone (`line`,
23
+ `orbit`, `blobs`, `dots`, `pixel`, `dashes`, `fan`, `fold`, and `tri`, whose three-diamond layouts read as a known
24
+ logo; 25 remain). `TUNING` (per recipe: `random` ranges and
25
+ options, `rare` second moves) makes a shuffle draw heavy, simple, one-move marks while the sliders keep their range;
26
+ `qualityOf()` scores a shape (ink, box, pieces, thin parts, thin gaps, balance, calm outline); `shuffled()` keeps the
27
+ best of a few draws; `variations()` and `mix()` use it, `mix()` weighted by `MIX_WEIGHT`, no recipe twice running, no
28
+ drawing twice. `MAIN` lists each recipe's main controls. `PRESETS` is 24 marks picked by eye from ranked sheets. The
29
+ same params now always draw the same bytes (the booleans' retry jitter is seeded from the params).
4
30
 
5
31
  - First release (32 recipes, then the study's top 12, `line`, 18 presets; then `letter`, containers, pieces): the recipes `bars`, `bands`, `twin`, `stack` (primitives stacked, overlapped or nested, combined by
6
32
  gap, over, cut, merge or xor), `shear`, `turns`, `burst`, `tiles`, `route`, `arcs`, `rings`, `stripes`, `dots`, `pixel`, `chevrons`, `waves`, `cut`, `split`, `venn`, `blobs`, `dashes`, `fan`, `fold`,
@@ -23,3 +49,8 @@
23
49
  a layout that makes the three-triangle emblem or the trefoil, and lost its hexagon silhouette (hexagrams and nuts);
24
50
  rings' `turn`, steps' `round` and tri's `outline` were overwritten by the finish's keys of the same name: now `spin`,
25
51
  `roundTreads` and gone (a test checks no recipe repeats a key).
52
+
53
+ ## 0.1.0 (2026-11-26)
54
+
55
+ - The first release: 34 recipes, the finish, the guard, `generate`, `randomParams`, `variations`, `nearby`, `similar`,
56
+ `mix`, `svgOf` and the presets.
package/README.md CHANGED
@@ -1,14 +1,19 @@
1
1
  # @logomarks/generate
2
2
 
3
- Abstract logomarks from rules and controls, no AI. Each recipe is one construction (34 of them: bars, bands, twin,
4
- stack, shear, turns, burst, tiles, route, arcs, rings, stripes, dots, pixel, chevrons, waves, cut, split, venn, blobs,
5
- dashes, fan, fold, spiral, orbit, bloom, links, horizon, steps, hex, tri, iso, line and letter) that lists its controls
3
+ Abstract logomarks from rules and controls, no AI. Each recipe is one construction (40 of them: bars, bands, twin,
4
+ stack, shear, turns, burst, tiles, route, arcs, rings, stripes, chevrons, waves, cut, split, venn, spiral, bloom, links,
5
+ horizon, steps, hex, iso and letter, then fifteen after live house families: arcstep, halfsq, invert, leaves, lobes, loops, trine, strips, bite, blades, wavecut, capsules, flare, pixelarc, seam) that lists its controls
6
6
  and draws a mark from them, fitted to the Logomarks standard: a 512 canvas, the longest side 448, centred,
7
7
  `currentColor`, the house gap. Every recipe also takes the finish controls (turn, mirror, round corners, outline, an
8
8
  accent dot, a container: badge or clip). Each mark comes with its `pieces`, and `svgOf()` draws them in two colours. A
9
9
  quality guard skips draws with specks, slivers, thin necks, hairline holes, a bare primitive or too little ink. Runs in
10
10
  the browser and in Node.
11
11
 
12
+ A shuffle is curated, not uniform: each recipe's `TUNING` keeps random draws to the settings that give a mark worth
13
+ keeping and makes one move at a time (`random`, `rare` on a control; a hand still has every slider's whole range);
14
+ `shuffled()` keeps the best of a few draws by `qualityOf()` (ink, pieces, thin parts, thin gaps, balance, a calm
15
+ outline), and `mix()` weights the strongest recipes (`MIX_WEIGHT`). `MAIN` names the controls a page shows first.
16
+
12
17
  ## Install
13
18
 
14
19
  ```sh
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logomarks/generate",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Abstract logomarks from rules and controls, no AI: 34 recipes (bars, bands, twin, stack, shear, turns, burst, tiles, route, arcs, rings, stripes, dots, pixel, chevrons, waves, cut, split, venn, blobs, dashes, fan, fold, spiral, orbit, bloom, links, horizon, steps, hex, tri, iso, line, letter) that each list their controls and draw a mark from them and a seed, fitted to the Logomarks standard (512 canvas, 448 fit, the house gap), a shared finish (rounding, outline, an accent dot, a container), two-colour pieces, seeded variations and presets. Runs in the browser and in Node.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/controls.js CHANGED
@@ -26,9 +26,16 @@ export function resolve(controls, params = {}) {
26
26
  return Object.fromEntries(controls.map((c) => [c.key, c.key in params ? clampTo(c, params[c.key]) : c.value]));
27
27
  }
28
28
 
29
- /** A random value for a control, from `r` (a random function). */
29
+ /**
30
+ * A random value for a control, from `r` (a random function; two draws, always). A control may narrow what a shuffle
31
+ * draws without narrowing what a hand can set: `random` ([min, max] of a range, or some of a choice's options), and
32
+ * `rare` (the chance, 0–1, that a shuffle moves it off its default at all: the second moves a mark can take, a slant,
33
+ * a taper, a twist, stay home most of the time, so a shuffled mark makes one move, not five).
34
+ */
30
35
  export function randomValue(control, r) {
31
- if (control.type === 'range') return clampTo(control, control.min + r() * (control.max - control.min));
32
- if (control.type === 'choice') return control.options[Math.floor(r() * control.options.length)];
33
- return r() < 0.5;
36
+ const a = r(), b = r();
37
+ if (control.rare !== undefined && b >= control.rare) return control.value;
38
+ if (control.type === 'range') { const [lo, hi] = control.random || [control.min, control.max]; return clampTo(control, lo + a * (hi - lo)); }
39
+ if (control.type === 'choice') { const o = control.random || control.options; return o[Math.floor(a * o.length)]; }
40
+ return a < 0.5;
34
41
  }
package/src/generate.js CHANGED
@@ -7,6 +7,7 @@ import { RECIPES } from './recipes/index.js';
7
7
  import { resolve, randomValue } from './controls.js';
8
8
  import { rng, seedOf } from './random.js';
9
9
  import { problems } from './guard.js';
10
+ import { fill, thinShareBits } from './raster.js';
10
11
 
11
12
  robust();
12
13
 
@@ -17,17 +18,88 @@ export function recipe(id) {
17
18
  return r;
18
19
  }
19
20
 
21
+ /** The recipe's shape for params, its problems, and the mark (see `generate()`). */
22
+ function draw(id, params) {
23
+ const r = recipe(id), p = resolve(r.controls, params);
24
+ // core's robust booleans retry a failed operation with a tiny jitter read from Math.random: seeded from the params
25
+ // while the mark is built, so the same params always draw the same bytes
26
+ const random = Math.random;
27
+ let shape;
28
+ Math.random = rng(`${id}:${JSON.stringify(p)}`);
29
+ try { shape = r.build(p); } finally { Math.random = random; }
30
+ const found = problems(shape, r.guard);
31
+ if (found.includes('nothing drawn')) return { shape: null, g: { recipe: id, params: p, svg: '', problems: found } };
32
+ const { svg } = fitMark(toSvg(shape));
33
+ return { shape, g: { recipe: id, params: p, svg, pieces: piecesOf(shape), problems: found } };
34
+ }
35
+
20
36
  /**
21
37
  * A mark from a recipe and its params, fitted to the Logomarks standard (512 canvas, longest side 448, centred,
22
38
  * currentColor). Missing params take their defaults; out-of-range ones are clamped.
23
39
  */
24
40
  export function generate(id, params = {}) {
25
- const r = recipe(id), p = resolve(r.controls, params);
26
- const shape = r.build(p);
27
- const found = problems(shape, r.guard);
28
- if (found.includes('nothing drawn')) return { recipe: id, params: p, svg: '', problems: found };
29
- const { svg } = fitMark(toSvg(shape));
30
- return { recipe: id, params: p, svg, pieces: piecesOf(shape), problems: found };
41
+ return draw(id, params).g;
42
+ }
43
+
44
+ /** 1 inside [a, b], falling in a straight line to 0 at `lo` below and `hi` above. */
45
+ const band = (v, lo, a, b, hi) => (v < a ? Math.max(0, (v - lo) / (a - lo)) : v > b ? Math.max(0, (hi - v) / (hi - b)) : 1);
46
+
47
+ /**
48
+ * How good a drawn shape is as a mark, 0–1, measured on a small bitmap of it fitted to the house box: enough ink (about
49
+ * a third to three fifths of the box: neither spindly nor a slab), a box near square, few pieces, nothing thinner than
50
+ * the house gap, no gaps thinner than it either, the ink's weight near the middle, and an outline that isn't busy.
51
+ * Returns the score and its parts.
52
+ */
53
+ export function qualityOf(shape) {
54
+ const polys = !shape || !shape.length ? [] : typeof shape[0][0][0] === 'number' ? [shape] : shape;
55
+ if (!polys.length) return { score: 0 };
56
+ let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
57
+ for (const poly of polys) for (const [x, y] of poly[0]) { x0 = Math.min(x0, x); y0 = Math.min(y0, y); x1 = Math.max(x1, x); y1 = Math.max(y1, y); }
58
+ const k = 448 / Math.max(x1 - x0, y1 - y0, 1e-9), mx = (x0 + x1) / 2, my = (y0 + y1) / 2;
59
+ const N = 128, px = 512 / N, bits = fill(polys.map((poly) => mapPts(poly, ([x, y]) => [256 + (x - mx) * k, 256 + (y - my) * k])), N);
60
+ let ink = 0, sx = 0, sy = 0, edges = 0;
61
+ const back = new Uint8Array(N * N);
62
+ for (let y = 0; y < N; y++) for (let x = 0; x < N; x++) {
63
+ const v = bits[y * N + x];
64
+ back[y * N + x] = 1 - v;
65
+ if (!v) continue;
66
+ ink++; sx += x; sy += y;
67
+ if (!x || !bits[y * N + x - 1]) edges++;
68
+ if (!y || !bits[(y - 1) * N + x]) edges++;
69
+ }
70
+ if (!ink) return { score: 0 };
71
+ let ground = 0;
72
+ for (let i = 0; i < back.length; i++) ground += back[i];
73
+ const inkShare = (ink * px * px) / (448 * 448);
74
+ const parts = {
75
+ ink: band(inkShare, 0.14, 0.3, 0.6, 0.88),
76
+ square: band(Math.min(x1 - x0, y1 - y0) / Math.max(x1 - x0, y1 - y0), 0.3, 0.68, 1, 2),
77
+ pieces: band(polys.length, -1, 1, 6, 16),
78
+ thin: 1 - Math.min(1, thinShareBits(bits, N, 3) / 0.2),
79
+ gaps: 1 - Math.min(1, (thinShareBits(back, N, 2) * ground) / ink / 0.1),
80
+ balance: 1 - Math.min(1, Math.hypot(sx / ink - (N - 1) / 2, sy / ink - (N - 1) / 2) / (0.14 * N)),
81
+ calm: band((edges * 2 * px) / 448, 0, 0, 9, 22),
82
+ };
83
+ const score = 0.24 * parts.ink + 0.08 * parts.square + 0.14 * parts.pieces + 0.16 * parts.thin + 0.14 * parts.gaps + 0.1 * parts.balance + 0.14 * parts.calm;
84
+ return { score, ...parts };
85
+ }
86
+
87
+ /**
88
+ * The best of a few shuffles: `tries` random params from `seed` on (see `randomParams()`), each drawn; the one that
89
+ * passes the guard with the highest quality (`qualityOf`) is returned with its `seed` and `quality`, or null if none
90
+ * passes. What a Shuffle button and a random grid should call, rather than taking the first draw that passes.
91
+ */
92
+ export function shuffled(id, seed, { tries = 4, base = {}, locked = [], finish = false } = {}) {
93
+ let best = null;
94
+ for (let i = 0, s = seedOf(seed); i < tries; i++, s = (s + 1) >>> 0) {
95
+ try {
96
+ const { shape, g } = draw(id, randomParams(id, s, { base, locked, finish }));
97
+ if (g.problems.length || !g.svg) continue;
98
+ const quality = qualityOf(shape).score;
99
+ if (!best || quality > best.quality) best = { ...g, seed: s, quality };
100
+ } catch { /* the next seed */ }
101
+ }
102
+ return best;
31
103
  }
32
104
 
33
105
  /**
@@ -125,18 +197,14 @@ export function randomParams(id, seed, { base = {}, locked = [], finish = false
125
197
  }
126
198
 
127
199
  /**
128
- * `count` marks from a recipe, each from its own seed (`seed`, `seed`+1 …), the `locked` controls held at `base`.
129
- * A draw that fails (the guard finds a speck or a sliver, or the booleans give up) is skipped for the next seed, up to
130
- * `count` × 4 tries.
200
+ * `count` marks from a recipe, each the best of three shuffles (`shuffled()`), from seeds `seed` on, the `locked`
201
+ * controls held at `base`; no two the same drawing. Slots where nothing passes the guard are skipped, up to `count` × 4.
131
202
  */
132
- export function variations(id, { count = 24, seed = 1, base = {}, locked = [], finish = false } = {}) {
133
- const out = [];
134
- for (let i = 0, s = seedOf(seed); out.length < count && i < count * 4; i++, s = (s + 1) >>> 0) {
135
- try {
136
- const params = randomParams(id, s, { base, locked, finish });
137
- const g = generate(id, params);
138
- if (!g.problems.length) out.push({ ...g, seed: s });
139
- } catch { /* the next seed */ }
203
+ export function variations(id, { count = 24, seed = 1, base = {}, locked = [], finish = false, tries = 3 } = {}) {
204
+ const out = [], drawn = new Set();
205
+ for (let i = 0, s = seedOf(seed); out.length < count && i < count * 4; i++, s = (s + tries) >>> 0) {
206
+ const g = shuffled(id, s, { tries, base, locked, finish });
207
+ if (g && !drawn.has(g.svg)) { drawn.add(g.svg); out.push(g); }
140
208
  }
141
209
  return out;
142
210
  }
@@ -178,17 +246,29 @@ export function similar(id, params, { count = 12, seed = 1, amount = 0.15, locke
178
246
  }
179
247
 
180
248
  /**
181
- * `count` marks from ANY recipe: each from its own seed, its recipe picked by that seed (from `ids`, every recipe by
182
- * default), random params with the finish at its defaults, failed draws skipped. For a bulk "random mix" grid.
249
+ * How often each recipe comes up in `mix()`, relative to 1: the ones whose shuffles most often give a mark worth
250
+ * keeping lead; the textured ones (iso, hex, tiles) come up less.
183
251
  */
184
- export function mix({ count = 48, seed = 1, ids = Object.keys(RECIPES) } = {}) {
185
- const out = [];
186
- for (let i = 0, s = seedOf(seed); out.length < count && i < count * 4; i++, s = (s + 1) >>> 0) {
187
- const id = ids[Math.floor(rng(`mix:${s}`)() * ids.length)];
188
- try {
189
- const g = generate(id, randomParams(id, s));
190
- if (!g.problems.length && g.svg) out.push({ ...g, seed: s });
191
- } catch { /* the next seed */ }
252
+ export const MIX_WEIGHT = { twin: 1.6, cut: 1.6, split: 1.4, chevrons: 1.3, spiral: 1.2, links: 1.2, arcs: 1.2, bands: 1.2, stripes: 1.2, rings: 0.8, turns: 1.1, bloom: 1, burst: 1, bars: 1, waves: 0.9, stack: 0.8, steps: 0.8, letter: 0.8, shear: 0.6, venn: 0.5, route: 0.5, horizon: 0.5, tiles: 0.6, hex: 0.5, iso: 0.5, arcstep: 1.4, leaves: 1.3, seam: 1.3, trine: 1.2, blades: 1.1, invert: 1, wavecut: 1, capsules: 1, bite: 0.9, loops: 0.8, strips: 0.8, flare: 0.8, lobes: 0.7, halfsq: 0.7, pixelarc: 0.5 };
253
+
254
+ /**
255
+ * `count` marks from ANY recipe: each slot picks a recipe by its seed (from `ids`, every recipe by default, weighted by
256
+ * `MIX_WEIGHT`, never the one before it) and keeps the best of `tries` shuffles of it (`shuffled()`); no two the same
257
+ * drawing. Each has its `seed` and `quality`. For a bulk "random mix" grid.
258
+ */
259
+ export function mix({ count = 48, seed = 1, ids = Object.keys(RECIPES), tries = 4 } = {}) {
260
+ const out = [], drawn = new Set(), total = ids.reduce((t, id) => t + (MIX_WEIGHT[id] ?? 1), 0);
261
+ let last = '';
262
+ for (let i = 0, s = seedOf(seed); out.length < count && i < count * 4; i++, s = (s + tries) >>> 0) {
263
+ const rand = rng(`mix:${s}`);
264
+ let id = ids[0];
265
+ for (let t = 0; t < 3; t++) {
266
+ let at = rand() * total;
267
+ for (const c of ids) { at -= MIX_WEIGHT[c] ?? 1; if (at <= 0) { id = c; break; } }
268
+ if (id !== last || ids.length < 2) break;
269
+ }
270
+ const g = shuffled(id, s, { tries });
271
+ if (g && !drawn.has(g.svg)) { drawn.add(g.svg); out.push(g); last = id; }
192
272
  }
193
273
  return out;
194
274
  }
package/src/index.d.ts CHANGED
@@ -6,6 +6,10 @@ export type Control = (
6
6
  ) & {
7
7
  /** 'finish' for the shared finish controls (turn, mirror, round, outline); none for the recipe's own. */
8
8
  group?: 'finish';
9
+ /** What a shuffle draws, narrower than what a hand can set: [min, max] of a range, or some of a choice's options. */
10
+ random?: [number, number] | string[];
11
+ /** The chance, 0–1, that a shuffle moves this control off its default at all (a second move: a slant, a twist). */
12
+ rare?: number;
9
13
  };
10
14
 
11
15
  /** Param values by control key. */
@@ -40,8 +44,9 @@ export interface Generated {
40
44
  seed?: number;
41
45
  }
42
46
 
43
- /** Every recipe, by id: bars, bands, twin, stack, shear, turns, burst, tiles, route, arcs, rings, stripes, dots, pixel,
44
- * chevrons, waves. */
47
+ /** Every recipe, by id: bars, bands, twin, stack, shear, turns, burst, tiles, route, arcs, rings, stripes, chevrons, waves,
48
+ * cut, split, venn, spiral, bloom, links, horizon, steps, hex, iso, letter, arcstep, halfsq, invert, leaves, lobes, loops, trine, strips, bite, blades, wavecut,
49
+ * capsules, flare, pixelarc and seam. */
45
50
  export const RECIPES: Record<string, Recipe>;
46
51
  /** A recipe by id; throws for an unknown one. */
47
52
  export function recipe(id: string): Recipe;
@@ -50,14 +55,24 @@ export function generate(id: string, params?: Params): Generated;
50
55
  /** Random params from a seed, keeping `locked` keys at `base`. */
51
56
  export function randomParams(id: string, seed: number | string, o?: { base?: Params; locked?: string[]; finish?: boolean }): Params;
52
57
  /** `count` marks from consecutive seeds, `locked` controls held at `base`; failed draws are skipped. */
53
- export function variations(id: string, o?: { count?: number; seed?: number | string; base?: Params; locked?: string[]; finish?: boolean }): Generated[];
58
+ export function variations(id: string, o?: { count?: number; seed?: number | string; base?: Params; locked?: string[]; finish?: boolean; tries?: number }): Generated[];
54
59
  /** Params close to `params`: ranges nudged by up to `amount` of their span, a choice swapped now and then; toggles, the
55
60
  * finish and `locked` keys kept. */
56
61
  export function nearby(id: string, params: Params, o?: { seed?: number | string; amount?: number; locked?: string[] }): Params;
57
62
  /** `count` marks close to `params`, failed draws skipped, none repeated. */
58
63
  export function similar(id: string, params: Params, o?: { count?: number; seed?: number | string; amount?: number; locked?: string[] }): Generated[];
59
- /** `count` marks from any recipe (picked per seed from `ids`), random params, failed draws skipped: a bulk random mix. */
60
- export function mix(o?: { count?: number; seed?: number | string; ids?: string[] }): Generated[];
64
+ /** `count` marks from any recipe (weighted by MIX_WEIGHT, never the same twice running), each the best of `tries` shuffles; none the same drawing. */
65
+ export function mix(o?: { count?: number; seed?: number | string; ids?: string[]; tries?: number }): (Generated & { seed: number; quality: number })[];
66
+ /** The best of `tries` shuffles of a recipe from `seed` on, by `qualityOf`, with its `seed` and `quality`; null when none passes the guard. */
67
+ export function shuffled(id: string, seed: number | string, o?: { tries?: number; base?: Params; locked?: string[]; finish?: boolean }): (Generated & { seed: number; quality: number }) | null;
68
+ /** How good a drawn shape is as a mark, 0–1, and the parts of the score (ink, square, pieces, thin, gaps, balance, calm). */
69
+ export function qualityOf(shape: unknown): { score: number; ink?: number; square?: number; pieces?: number; thin?: number; gaps?: number; balance?: number; calm?: number };
70
+ /** How often each recipe comes up in `mix()`, relative to 1. */
71
+ export const MIX_WEIGHT: Record<string, number>;
72
+ /** Per recipe and control key: what a shuffle draws (`random`, `rare`) and any default it replaces (`value`). */
73
+ export const TUNING: Record<string, Record<string, { random?: [number, number] | string[]; rare?: number; value?: number | string | boolean }>>;
74
+ /** Per recipe: the keys of the controls a page shows first. */
75
+ export const MAIN: Record<string, string[]>;
61
76
  /** Every control's default. */
62
77
  export function defaults(controls: Control[]): Params;
63
78
  /** Every control's value from params, clamped, defaults for missing ones. */
package/src/index.js CHANGED
@@ -2,8 +2,9 @@
2
2
  * @logomarks/generate: abstract logomarks from rules and controls, no AI.
3
3
  */
4
4
  export { RECIPES } from './recipes/index.js';
5
- export { recipe, generate, randomParams, variations, nearby, similar, mix, piecesOf, svgOf, PATTERNS } from './generate.js';
5
+ export { recipe, generate, randomParams, variations, nearby, similar, mix, shuffled, qualityOf, MIX_WEIGHT, piecesOf, svgOf, PATTERNS } from './generate.js';
6
6
  export { defaults, resolve, clampTo, randomValue } from './controls.js';
7
7
  export { rng, seedOf } from './random.js';
8
8
  export { GUARD, problems } from './guard.js';
9
+ export { TUNING, MAIN } from './tuning.js';
9
10
  export { PRESETS } from './presets.js';
package/src/presets.js CHANGED
@@ -1,26 +1,37 @@
1
1
  /**
2
- * Presets: the combinations the owner's references use most (generator-study.md, "Combinations"), each a recipe and its
3
- * settings, so a page can offer them as one-click starting points. Every one draws and passes the guard (tested).
2
+ * Presets: a hand-picked set of marks, each a recipe and its settings, chosen by eye from ranked sheets of shuffles for
3
+ * a page to offer as one-click starting points. Every one draws and passes the guard (tested).
4
4
  */
5
5
 
6
6
  /** @type {import('./index.js').Preset[]} */
7
7
  export const PRESETS = [
8
- { id: 'speed-bands', name: 'Speed bands', recipe: 'bands', params: { count: 3, join: 'slant', joinWidth: 0.2, ends: 'square', extra: 'both' }, note: 'Three bands climbing through a slanted step.' },
9
- { id: 'corner-arrow', name: 'Corner arrow', recipe: 'arcs', params: { sweep: 'quarter', count: 2, legs: 0.35, move: 'arrow', corner: 'square' }, note: 'Nested corner bands cut by a diagonal arrow.' },
10
- { id: 'slab-pair', name: 'Slab pair', recipe: 'shear', params: { rows: 2, cols: 2, lean: 'same', angle: 30, lengths: 'alternate', slide: 0.25 }, note: 'Four slanted slabs, long and short, slid a row.' },
11
- { id: 'cut-h', name: 'Cut H', recipe: 'bars', params: { count: 3, cut: 'middle', cutSize: 0.18, cutAngle: 35 }, note: 'Three bars, the middle one cut on a slant.' },
12
- { id: 'skyline', name: 'Skyline', recipe: 'bars', params: { count: 4, cut: 'none', lengths: 'arch', ends: 'square', weight: 0.72 }, note: 'Four towers, tallest in the middle.' },
13
- { id: 'half-pills', name: 'Half pills', recipe: 'bars', params: { count: 3, cut: 'none', level: true, lengths: 'rising', round: 40, roundWhich: 'each-right' }, note: 'Stacked bars, flat on the left and round on the right.' },
14
- { id: 'twin-slant', name: 'Twin slant', recipe: 'twin', params: { piece: 'L', slant: 20, corner: 'cut', ends: 'angled' }, note: 'Two Ls turned about the centre, leaning.' },
15
- { id: 'six-ray', name: 'Six-ray asterisk', recipe: 'burst', params: { rays: 6, ray: 'bar', inner: 0.12, width: 0.13, move: 'none' }, note: 'Six heavy bars round an open centre.' },
16
- { id: 'striped-disc', name: 'Striped disc', recipe: 'stripes', params: { shape: 'circle', angle: 45, move: 'shift' }, note: 'A disc of diagonal stripes, every other one slid.' },
17
- { id: 'diagonal-slot', name: 'Diagonal slot', recipe: 'cut', params: { body: 'square', cut: 'slot', angle: '45' }, note: 'A square with one slot run in from the corner.' },
18
- { id: 'split-diamond', name: 'Split diamond', recipe: 'split', params: { shape: 'diamond', cuts: 2, slide: 0.2 }, note: 'A diamond in three slid parts.' },
19
- { id: 'soft-steps', name: 'Soft steps', recipe: 'tiles', params: { round: 20, roundWhich: 'alternate' }, note: 'A grid of tiles, every other one softened.' },
20
- { id: 'arrow-stack', name: 'Arrow stack', recipe: 'chevrons', params: { count: 3, point: 'right', grow: 0, tip: 'flat' }, note: 'Three flat-tipped chevrons pointing right.' },
21
- { id: 'facing-halves', name: 'Facing halves', recipe: 'stack', params: { layout: 'row', count: 2, shapeA: 'half', shapeB: 'half', turnA: '90', turnB: '270', combine: 'gap' }, note: 'Two half discs back to back.' },
22
- { id: 'round-meander', name: 'Round meander', recipe: 'route', params: { frame: 'open', turns: 'round', diagonals: false, node: 'none', ends: 'square', tracks: 1, steps: 3 }, note: 'One band meandering inside an open frame, soft turns.' },
23
- { id: 'three-chevrons', name: 'Three chevrons', recipe: 'turns', params: { unit: 'chevron', count: '3', join: 'gap', face: '180', size: 0.44, radius: 0.1 }, note: 'Three chevrons pointing in round the centre.' },
24
- { id: 'dash-columns', name: 'Dash columns', recipe: 'dashes', params: { rows: 3, rhythm: 'halves', align: 'left' }, note: 'Three rows of paired dashes.' },
25
- { id: 'outlined-frames', name: 'Outlined frames', recipe: 'stack', params: { layout: 'nest', count: 3, shapeA: 'square', shapeB: 'square', combine: 'over', outline: 30 }, note: 'Nested squares drawn as outlines.' },
8
+ { id: 'round-twin', name: 'Round twin', recipe: 'twin', params: { arm: 0.85, thickness: 0.33, stem: 0.63, corner: 'cut', ends: 'round' }, note: 'Two rounded hooks turned about the centre.' },
9
+ { id: 'twin-s', name: 'Twin S', recipe: 'twin', params: { piece: 'arc', arm: 0.83, thickness: 0.34, stem: 0.52, corner: 'cut', ends: 'round' }, note: 'Two bands that read as one S.' },
10
+ { id: 'cut-twin', name: 'Cut twin', recipe: 'twin', params: { piece: 'hook', arm: 0.99, stem: 0.61, corner: 'cut', ends: 'angled', slant: -4 }, note: 'Two angular hooks, corners cut.' },
11
+ { id: 'split-disc', name: 'Split disc', recipe: 'split', params: { cuts: 1, angle: -9, spacing: 1.7, slide: 0.27, spread: 0.5 }, note: 'A disc cut once, the halves slid.' },
12
+ { id: 'split-hexagon', name: 'Split hexagon', recipe: 'split', params: { shape: 'hexagon', cuts: 1, angle: 1, spacing: 1.5, slide: 0.02, spread: 0.43 }, note: 'A hexagon in two slid halves.' },
13
+ { id: 'slashed-disc', name: 'Slashed disc', recipe: 'split', params: { cuts: 1, angle: -49, spacing: 1.9, slide: 0.19, twist: 3.5, spread: 0.4 }, note: 'A disc with one diagonal slot.' },
14
+ { id: 'six-petals', name: 'Six petals', recipe: 'bloom', params: { petal: 'ellipse', width: 0.69, inner: 0.3, join: 'tuck' }, note: 'Six petals round an open centre.' },
15
+ { id: 'four-discs', name: 'Four discs', recipe: 'turns', params: { unit: 'circle', count: '4', radius: 0.11, face: '180', join: 'tuck' }, note: 'Four discs turned about a centre.' },
16
+ { id: 'four-leaves', name: 'Four leaves', recipe: 'turns', params: { unit: 'leaf', count: '4', size: 0.45, radius: 0.14, face: '270' }, note: 'Four leaves turned like a pinwheel.' },
17
+ { id: 'hex-pinwheel', name: 'Hex pinwheel', recipe: 'turns', params: { unit: 'triangle', count: '6', size: 0.37, stretch: 1.3, radius: 0.1, face: '180', join: 'tuck' }, note: 'Six triangles turned inside a hexagon.' },
18
+ { id: 'speed-bands', name: 'Speed bands', recipe: 'bands', params: { count: 3, weight: 0.75, joinAt: 0.38, joinWidth: 0.23, extra: 'none', ends: 'round' }, note: 'Bands climbing through one bend.' },
19
+ { id: 'stepped-bands', name: 'Stepped bands', recipe: 'bands', params: { weight: 0.6, joinAt: 0.42, extra: 'none' }, note: 'Two bands through one slanted step.' },
20
+ { id: 'asterisk', name: 'Asterisk', recipe: 'burst', params: { rays: 6, ray: 'pill', width: 0.155, inner: 0.28 }, note: 'Rounded rays round an open centre.' },
21
+ { id: 'two-links', name: 'Two links', recipe: 'links', params: { weight: 0.125, overlap: 0.24, corner: 0.41 }, note: 'Two rounded loops woven like a chain.' },
22
+ { id: 'double-chevron', name: 'Double chevron', recipe: 'chevrons', params: { count: 2, angle: 111, weight: 0.52, point: 'down' }, note: 'Two heavy chevrons pointing down.' },
23
+ { id: 'back-chevrons', name: 'Back chevrons', recipe: 'chevrons', params: { angle: 117, weight: 0.74, tip: 'flat', grow: 0.36, point: 'left' }, note: 'Chevrons pointing left, the first an arrowhead.' },
24
+ { id: 'bitten-hexagon', name: 'Bitten hexagon', recipe: 'cut', params: { body: 'hexagon', cut: 'arc', side: 'left', at: 0.31, size: 0.45, width: 1.1 }, note: 'A hexagon with one round bite.' },
25
+ { id: 'bitten-disc', name: 'Bitten disc', recipe: 'cut', params: { body: 'circle', side: 'left', at: 0.51, size: 0.21, width: 2.5, second: 'opposite' }, note: 'A disc with one deep bite.' },
26
+ { id: 'coil', name: 'Coil', recipe: 'spiral', params: { turns: 1.5, weight: 0.46, start: 'square', squash: 0.81, spin: 120 }, note: 'One round band coiled once and a half.' },
27
+ { id: 'arch', name: 'Arch', recipe: 'arcs', params: { count: 2, weight: 0.7, legs: 0.35, chamfer: 0.33 }, note: 'Two nested half rings on short legs.' },
28
+ { id: 'corner-arcs', name: 'Corner arcs', recipe: 'arcs', params: { count: 2, sweep: 'quarter', weight: 0.56, legs: 0.18, chamfer: 0.38 }, note: 'Two quarter rings from a corner.' },
29
+ { id: 'striped-arch', name: 'Striped arch', recipe: 'stripes', params: { shape: 'arch', stripes: 5, weight: 0.65, angle: 20, move: 'shift', amount: 0.02 }, note: 'An arch drawn in slanted stripes.' },
30
+ { id: 'striped-hexagon', name: 'Striped hexagon', recipe: 'stripes', params: { shape: 'hexagon', stripes: 6, weight: 0.53, angle: 25, move: 'taper', amount: 0.47 }, note: 'A hexagon drawn in diagonal stripes.' },
31
+ { id: 'wave-tile', name: 'Wave tile', recipe: 'waves', params: { weight: 0.64, amplitude: 0.095, waves: 1.25, clip: 'circle' }, note: 'Three wavy bands cut to a square.' },
32
+ { id: 'arc-step', name: 'Arc step', recipe: 'arcstep', params: { layout: 'stair', steps: 1, weight: 0.8, corners: 'round' }, note: 'One heavy band through two quarter arcs.' },
33
+ { id: 'leaf-tiles', name: 'Leaf tiles', recipe: 'leaves', params: { tile: 'leaf', order: 'outward' }, note: 'Four leaves, their points to the middle.' },
34
+ { id: 'tenon-block', name: 'Tenon block', recipe: 'seam', params: { joint: 'tenon', body: 'square' }, note: 'A block in two halves, joined by a tenon.' },
35
+ { id: 'shutter', name: 'Shutter', recipe: 'trine', params: { body: 'disc', offset: 0.22 }, note: 'A disc in three parts turning round an open middle.' },
36
+ { id: 'blade-sweep', name: 'Blade sweep', recipe: 'blades', params: { count: 3, grow: 0.5, width: 1.6 }, note: 'Three blades, each taller than the last.' },
26
37
  ];
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Arc Step: one heavy band that runs level, turns up or down through a quarter arc and runs on, as a stair, a wave or
3
+ * a coil. The corners are round, square or one of each in turn (the step beside the arc is the family's signature).
4
+ */
5
+ import { fillet, stroke, U, circle } from '@logomarks/core/geometry';
6
+ import { BOX } from '../draw.js';
7
+
8
+ /** @type {import('../index.js').Control[]} */
9
+ export const controls = [
10
+ { key: 'layout', label: 'Path', type: 'choice', options: ['stair', 'wave', 'coil'], value: 'wave' },
11
+ { key: 'steps', label: 'Steps', type: 'range', min: 1, max: 4, step: 1, value: 2 },
12
+ { key: 'weight', label: 'Weight', type: 'range', min: 0.5, max: 0.9, step: 0.01, value: 0.72 },
13
+ { key: 'corners', label: 'Corners', type: 'choice', options: ['round', 'alternate', 'square'], value: 'alternate' },
14
+ { key: 'rise', label: 'Rise', type: 'range', min: 0.6, max: 1.6, step: 0.05, value: 1 },
15
+ { key: 'ends', label: 'Ends', type: 'choice', options: ['square', 'round'], value: 'square' },
16
+ ];
17
+
18
+ /** The path's corners on a unit grid (x right, y down). */
19
+ function path(p) {
20
+ const n = p.steps, pts = [];
21
+ if (p.layout === 'stair') for (let k = 0; k <= n; k++) pts.push([k, n - k], [k + 1, n - k]);
22
+ else if (p.layout === 'wave') for (let k = 0; k <= n; k++) pts.push([k, k % 2 ? 0 : 1], [k + 1, k % 2 ? 0 : 1]);
23
+ else {
24
+ // a square coil: out along the top, down, back, and in, each run a cell shorter after two turns
25
+ let x = 0, y = 0, len = Math.min(n, 2) + 1, d = 0;
26
+ pts.push([0, 0]);
27
+ const dirs = [[1, 0], [0, 1], [-1, 0], [0, -1]];
28
+ for (let k = 0; k < Math.min(n, 2) + 2; k++) { x += dirs[d][0] * len; y += dirs[d][1] * len; pts.push([x, y]); d = (d + 1) % 4; if (k % 2) len -= 1; if (len <= 0) break; }
29
+ }
30
+ return pts;
31
+ }
32
+
33
+ /** The mark for resolved params. */
34
+ export function build(p) {
35
+ const raw = path(p), cols = Math.max(...raw.map((q) => q[0])) - Math.min(...raw.map((q) => q[0])) || 1;
36
+ const cell = BOX.size / (cols + 1), w = cell * p.weight, ry = p.layout === 'coil' ? 1 : p.rise;
37
+ const pts = raw.map(([x, y]) => [BOX.x0 + x * cell, BOX.y0 + y * cell * ry]);
38
+ // a round corner turns on the band's own outer edge, so its inner edge stays a true arc
39
+ const r = Math.min(cell, cell * ry) / 2;
40
+ const rs = pts.map((_, i) => (p.corners === 'square' ? 0 : p.corners === 'round' || i % 2 ? r : 0));
41
+ const line = fillet(pts, rs);
42
+ let s = stroke(line, w, { chunk: 8 });
43
+ if (p.ends === 'round') s = U(s, circle(...line[0], w / 2, 64), circle(...line.at(-1), w / 2, 64));
44
+ return s;
45
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Bite Link: one soft block with round bites taken out of its sides, placed by a rule: facing each other (a bone),
3
+ * set off on opposite sides (an S), all four sides (a soft four-leaf), or two on one side. Where a bite meets a side
4
+ * the point is rounded off, so the block stays soft all the way round.
5
+ */
6
+ import { D, U, rr, circle, poly } from '@logomarks/core/geometry';
7
+ import { BOX, tidy } from '../draw.js';
8
+
9
+ /** @type {import('../index.js').Control[]} */
10
+ export const controls = [
11
+ { key: 'place', label: 'Bites', type: 'choice', options: ['facing', 'offset', 'four', 'side'], value: 'offset' },
12
+ { key: 'size', label: 'Bite size', type: 'range', min: 0.12, max: 0.24, step: 0.01, value: 0.18 },
13
+ { key: 'depth', label: 'Bite depth', type: 'range', min: 0.5, max: 1, step: 0.01, value: 0.8 },
14
+ { key: 'slide', label: 'Set off', type: 'range', min: 0.1, max: 0.2, step: 0.01, value: 0.16 },
15
+ { key: 'body', label: 'Body', type: 'choice', options: ['square', 'tall', 'wide'], value: 'square' },
16
+ { key: 'softness', label: 'Roundness', type: 'range', min: 0.12, max: 0.3, step: 0.01, value: 0.22 },
17
+ { key: 'axis', label: 'Sides', type: 'choice', options: ['left-right', 'top-bottom'], value: 'left-right' },
18
+ ];
19
+
20
+ /**
21
+ * A bite on a side: the side runs from E along the unit tangent T, the block lies on the N side of it. The bite's
22
+ * centre is `a` along the side and `d` outside it, radius r. Returns the bite and, for each of its two points, the
23
+ * offcut to take away so the point becomes an arc of radius f.
24
+ */
25
+ function biteOn(E, T, N, a, d, r, f) {
26
+ const P = (u, v) => [E[0] + T[0] * u + N[0] * v, E[1] + T[1] * u + N[1] * v];
27
+ const bc = P(a, -d), half = Math.sqrt(Math.max(0, r * r - d * d)), run = Math.sqrt(Math.max(0, (r + f) ** 2 - (f + d) ** 2));
28
+ const trims = [-1, 1].map((sg) => {
29
+ const fc = P(a + sg * run, f), cusp = P(a + sg * half, 0), t1 = P(a + sg * run, 0);
30
+ const k = r / (r + f), t2 = [bc[0] + (fc[0] - bc[0]) * k, bc[1] + (fc[1] - bc[1]) * k];
31
+ return D(poly([cusp, t1, t2]), circle(fc[0], fc[1], f, 48));
32
+ });
33
+ return { cut: circle(bc[0], bc[1], r, 96), trims };
34
+ }
35
+
36
+ /** The mark for resolved params. */
37
+ export function build(p) {
38
+ const { cx, cy, size } = BOX, w = size * (p.body === 'tall' ? 0.74 : 1), h = size * (p.body === 'wide' ? 0.74 : 1);
39
+ const x0 = cx - w / 2, y0 = cy - h / 2;
40
+ const [s1, s2] = p.axis === 'top-bottom' ? ['top', 'bottom'] : ['left', 'right'];
41
+ const lenOf = (name) => (name === 'left' || name === 'right' ? h : w), len = lenOf(s1), short = Math.min(w, h);
42
+ // a bite and the arcs that round its two points take `run` of the side each way: the bite is kept small enough
43
+ // that they fit on the side's straight run (two of them, side by side, on a side that holds two)
44
+ const fit = (r) => { const d = r * (1 - p.depth), f = Math.min(r * 0.4, 24); return { r, d, f, run: Math.sqrt((r + f) ** 2 - (f + d) ** 2) }; };
45
+ let b = fit(p.size * size);
46
+ const room = p.place === 'side' ? len / 4 - 10 : p.place === 'four' ? short / 2 - 30 : len / 2 - 24;
47
+ if (b.run > room) b = fit((p.size * size * room) / b.run);
48
+ const { r, d, f, run } = b;
49
+ const off = p.place === 'offset' ? Math.min(p.slide * size, len / 2 - run - 14) : 0, q = Math.max(run + 8, len * 0.25);
50
+ // the block's corners take what the bites leave
51
+ const reach = p.place === 'side' ? q + run : p.place === 'offset' ? off + run : run;
52
+ const cr = Math.max(8, Math.min(short * p.softness, (p.place === 'four' ? short : len) / 2 - reach - 2));
53
+ const body = rr(x0, y0, w, h, cr);
54
+ // the four sides, each from its start corner along its tangent, the block on its normal's side
55
+ const side = { left: [[x0, y0], [0, 1], [1, 0]], right: [[x0 + w, y0 + h], [0, -1], [-1, 0]], top: [[x0 + w, y0], [-1, 0], [0, 1]], bottom: [[x0, y0 + h], [1, 0], [0, -1]] };
56
+ const on = (name, shift) => { const [E, T, N] = side[name]; return biteOn(E, T, N, lenOf(name) / 2 + shift, d, r, f); };
57
+ let bites;
58
+ if (p.place === 'facing') bites = [on(s1, 0), on(s2, 0)];
59
+ else if (p.place === 'offset') bites = [on(s1, -off), on(s2, -off)]; // each side's own run: the two end up set off opposite ways
60
+ else if (p.place === 'four') bites = ['left', 'right', 'top', 'bottom'].map((n) => on(n, 0));
61
+ else bites = [on(s1, -q), on(s1, q)];
62
+ let s = D(body, U(...bites.map((x) => x.cut)));
63
+ for (const x of bites) for (const t of x.trims) s = D(s, t);
64
+ return tidy(s); // the trims leave hairs on the side's own line
65
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Blade Sweep: two to four curved blades side by side, each taller than the last, each tucked behind the next with the
3
+ * house gap: a fin's curve on one side, a straight edge on the other.
4
+ */
5
+ import { U, I, D, ellipse, rect, over, mapPts } from '@logomarks/core/geometry';
6
+ import { BOX, GAP, tidy, shear } from '../draw.js';
7
+
8
+ /** @type {import('../index.js').Control[]} */
9
+ export const controls = [
10
+ { key: 'count', label: 'Blades', type: 'range', min: 2, max: 4, step: 1, value: 3 },
11
+ { key: 'grow', label: 'Growth', type: 'range', min: 0, max: 0.7, step: 0.01, value: 0.5 },
12
+ { key: 'width', label: 'Blade width', type: 'range', min: 1, max: 2.4, step: 0.05, value: 1.6 },
13
+ { key: 'belly', label: 'Curve', type: 'range', min: 0.5, max: 1, step: 0.01, value: 0.8 },
14
+ { key: 'edge', label: 'Back edge', type: 'choice', options: ['straight', 'hollow'], value: 'straight' },
15
+ { key: 'lean', label: 'Lean', type: 'range', min: -20, max: 20, step: 1, value: 0 },
16
+ { key: 'facing', label: 'Facing', type: 'choice', options: ['right', 'left'], value: 'right' },
17
+ ];
18
+
19
+ /** One blade: its foot from x to x + w on the base line y1, its tip at (x + w, y1 − h); the curve is a quarter of a superellipse. */
20
+ function blade(x, w, h, y1, belly, hollow) {
21
+ const n = 48, e = 2 / (0.6 + belly * 1.4), pts = [];
22
+ for (let k = 0; k <= n; k++) { const t = (k / n) * (Math.PI / 2); pts.push([x + w - w * Math.cos(t) ** e, y1 - h * Math.sin(t) ** e]); }
23
+ let s = [[...pts, [x + w, y1]]];
24
+ if (hollow) s = D(s, ellipse(x + w * 1.55, y1 - h * 0.1, w * 0.62, h * 0.82, 0, 96));
25
+ return s;
26
+ }
27
+
28
+ /** The mark for resolved params. */
29
+ export function build(p) {
30
+ const { x0, y1, size } = BOX, n = p.count, step = size / (n + p.width - 1), w = step * p.width;
31
+ let s = null;
32
+ for (let k = 0; k < n; k++) {
33
+ const h = size * (1 - p.grow * (1 - (k + 1) / n) * 1.1), b = blade(x0 + k * step, w, Math.max(size * 0.3, h), y1, p.belly, p.edge === 'hollow');
34
+ s = s ? over(s, b, GAP) : b;
35
+ }
36
+ if (p.facing === 'left') s = mapPts(s, ([x, y]) => [2 * BOX.cx - x, y]);
37
+ return tidy(p.lean ? shear(s, p.lean) : s);
38
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Capsule: two to four heavy slanted capsules stacked with the house gap, their lengths set by one rule (growing,
3
+ * staggered, long in the middle), sometimes one of them cut in two.
4
+ */
5
+ import { U, D, rr, rect } from '@logomarks/core/geometry';
6
+ import { BOX, GAP, tidy, shear } from '../draw.js';
7
+
8
+ /** @type {import('../index.js').Control[]} */
9
+ export const controls = [
10
+ { key: 'count', label: 'Capsules', type: 'range', min: 2, max: 4, step: 1, value: 3 },
11
+ { key: 'lengths', label: 'Lengths', type: 'choice', options: ['stagger', 'grow', 'middle', 'even'], value: 'stagger' },
12
+ { key: 'lean', label: 'Lean', type: 'range', min: 0, max: 35, step: 1, value: 22 },
13
+ { key: 'short', label: 'Shortest', type: 'range', min: 0.4, max: 0.85, step: 0.01, value: 0.62 },
14
+ { key: 'softness', label: 'Roundness', type: 'range', min: 0.3, max: 1, step: 0.01, value: 1 },
15
+ { key: 'cut', label: 'Cut one', type: 'choice', options: ['none', 'first', 'last'], value: 'none' },
16
+ { key: 'spacing', label: 'Gap', type: 'range', min: 1, max: 2, step: 0.1, value: 1 },
17
+ ];
18
+
19
+ /** The mark for resolved params. */
20
+ export function build(p) {
21
+ const { x0, y0, size } = BOX, n = p.count, g = GAP * p.spacing, h = (size * (n === 2 ? 0.8 : 1) - (n - 1) * g) / n, parts = [];
22
+ const top = y0 + (size - (n * h + (n - 1) * g)) / 2;
23
+ for (let k = 0; k < n; k++) {
24
+ const t = n === 1 ? 0 : k / (n - 1);
25
+ // each capsule's length as a share of the row, and where it sits in it (0 left, 1 right)
26
+ let len = 1, side = 0;
27
+ if (p.lengths === 'grow') len = p.short + (1 - p.short) * t;
28
+ if (p.lengths === 'stagger') { len = p.short + (1 - p.short) * 0.5; side = k % 2; }
29
+ if (p.lengths === 'middle') { len = p.short + (1 - p.short) * (1 - Math.abs(2 * t - 1)); side = 0.5; }
30
+ const w = Math.max(h * 1.25, size * len), x = x0 + (size - w) * side, y = top + k * (h + g);
31
+ let c = rr(x, y, w, h, (h / 2) * p.softness * 0.999);
32
+ if ((p.cut === 'first' && k === 0) || (p.cut === 'last' && k === n - 1)) { const at = x + w * (p.cut === 'first' ? 0.68 : 0.32); if (w > h * 2.6) c = D(c, rect(at - g / 2, y - 2, g, h + 4)); }
33
+ parts.push(c);
34
+ }
35
+ return tidy(shear(U(...parts), p.lean));
36
+ }