@logomarks/generate 0.4.0 → 0.4.1

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,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.1 (2026-11-27)
4
+
5
+ - **Safe turns.** `TURNS` gives each of the 55 recipes the turns and mirror a shuffle may apply, and about one shuffle in
6
+ three (`TURN_SHARE`) now turns or mirrors its mark by them, through the existing Turn and Mirror finish controls (so
7
+ nothing new shows, and saved settings keep working). Every mark is refitted, so the grid holds; the lists keep out the
8
+ turns that change what a mark reads as. No turns: letter, mosaic, horizon, chevrons and notch (arrows, a play button),
9
+ iso (its light), arcs (upside down, a magnet), and rings, burst, bloom, loops, nodes, turns (the same every quarter
10
+ turn). Mirror only: stack, bars and shear (on their side, a menu icon), leaves, trine. Steps a half turn only (on their
11
+ side, signal bars) and ribbon a half turn only (its wave on its side is an S), flare no half turn (from a foot, turned
12
+ over, a rising sun). Two presets added (Creased ribbon, Four-way emblem; 47), Slotted ribbon now a step. A locked Turn or Mirror stays; with
13
+ `finish: true` a drawn turn outside the list falls back to none. Of 48 shuffles of each of the 42 recipes that gained
14
+ turns, the marks that look different as drawn went from 691 to 802. (The house similarity measure folds turns and
15
+ mirrors together, so distinct-per-130 by it doesn't move.)
16
+ - **Ribbon, widened** (it gave only N and Z): figures `step`, `stairs` (two steps), `flight` (three) and `wave` (one
17
+ swing); turns round or creased (folded flat, a mitre opened by the gap; `turns`); slots none, one or two (`slots`);
18
+ ends cut by the box, round or angled (`ends`); a slant (`slant`); the middle run's place (`reach`). Shuffles draw only
19
+ `SHUFFLE_FIGURES`; n, z, hook and hairpin stay by hand. Drawn and dropped from sheets: a loop over itself (a P), a
20
+ square spiral (an a), a frame round a square (a Q) or a triangle (a muddle), a serpent of upright runs (n, N, M), a
21
+ pleat of level runs (2, 3), two wave swings (an M), a hairpin stepping out (ru). Distinct per 130 shuffles: 4 → 17.
22
+ - **Mirror, widened** (it was one emblem): `symmetry` two or four ways (bands from all four sides, each kept to its
23
+ quarter, a gap along the diagonals), `bands` one to three a side, `centre` the meeting bands, a diamond, a square or
24
+ none, `ground` ink or cut out of a solid body with a rim, bodies octagon and (four ways) disc added. Two ways a centre
25
+ piece draws the meeting bands instead (between bands above and below it is a face), with nothing between the slots are
26
+ always cut out of a hexagon or octagon (loose arcs are lips; in a rounded square, a screen), and no round body (the
27
+ reference). Settings saved under 0.4.0 draw the same bytes. Every hand setting scores under 0.65 against R19 (a test
28
+ over the whole choice grid); the default and 200 shuffles top out at 0.631. Distinct per 130 shuffles: 2 → 17.
29
+
3
30
  ## 0.4.0 (2026-11-27)
4
31
 
5
32
  The owner's reference styles, from the coverage audit of his 23 references (`drop68-brief.md` in the site repo): 55
package/README.md CHANGED
@@ -15,6 +15,9 @@ A shuffle is curated, not uniform: each recipe's `TUNING` keeps random draws to
15
15
  keeping and makes one move at a time (`random`, `rare` on a control; a hand still has every slider's whole range);
16
16
  `shuffled()` keeps the best of a few draws by `qualityOf()` (ink, pieces, thin parts, thin gaps, balance, a calm
17
17
  outline), and `mix()` weights the strongest recipes (`MIX_WEIGHT`). `MAIN` names the controls a page shows first.
18
+ `TURNS` gives each recipe the turns and mirror that keep its marks what they are: about one shuffle in three turns or
19
+ mirrors a mark by it (`TURN_SHARE`), never outside it, and a locked Turn or Mirror stays. Letters, the sun, chevrons
20
+ (arrows), arcs (a magnet), bars and shear (a menu icon) and the styles already the same every quarter turn never turn.
18
21
 
19
22
  ## Install
20
23
 
@@ -91,11 +94,15 @@ in the build (and tested on 200 shuffles):
91
94
  soft neck, every join a concave fillet (a smooth union of distance fields); never a centre disc (a face, a figure),
92
95
  never three nodes (a fidget spinner, near the biohazard sign) or six (a cog).
93
96
  - `xband`: an X of two bent bands meeting a gap apart; never two straight bars crossing (a close icon).
94
- - `mirror`: a bold emblem symmetric both ways, cut to a hexagon on its point or a rounded square: two heavy bowed bands
95
- meeting in the middle, one thick band above and below bowed in; one band each side and always thick (thin stacked
96
- arcs are a Wi-Fi icon), never bowed out (a lens with two slits, an eye), no caps or dots. Its default and 200 shuffles score under 0.65 against the R19
97
- reference by the house outline measure (a test, `tests/fixtures/r19.json`).
98
- - `ribbon`: one thick band folding back with round turns and a slot.
97
+ - `mirror`: a family of bold symmetric emblems in few heavy pieces, cut by a body: two ways (one thick band each side
98
+ bowed in, two meeting in the middle) or four ways (bands from all four sides round a diamond, a square or nothing),
99
+ one to three bands each side four ways, the bands as ink or cut out of a solid body with a rim; the body a hexagon on
100
+ its point, a rounded square, an octagon or (four ways) a disc. Two ways never takes a centre piece (between bands
101
+ above and below it is a face), loose arcs (lips) or a round body (the reference itself). Every setting scores under
102
+ 0.65 against the R19 reference by the house outline measure (tests, `tests/fixtures/r19.json`).
103
+ - `ribbon`: one thick band folding back on itself: one, two or three steps or one wave swing, the turns round or creased
104
+ (folded flat: a mitre opened by the gap), none, one or two slots, ends cut by the box, rounded or angled, slanted. N, Z,
105
+ a hook and a hairpin draw by hand; a shuffle never draws a figure that reads as a letter (`SHUFFLE_FIGURES`).
99
106
  - `field`: upright bars broken by one stepped line, the lower parts jogged.
100
107
  - `zigzag`: a striped shape broken by a zigzag, one side slid.
101
108
  - `halfstripe`: a shape half solid, half bars stepping down; never a diamond (a speaker, a play button).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logomarks/generate",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
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/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 { TURNS, TURN_SHARE } from './tuning.js';
10
11
  import { fill, thinShareBits } from './raster.js';
11
12
 
12
13
  robust();
@@ -193,6 +194,18 @@ export function randomParams(id, seed, { base = {}, locked = [], finish = false
193
194
  const v = randomValue(c, rand); // drawn even when kept, so a seed draws the same construction whatever is locked
194
195
  out[c.key] = keep ? base[c.key] : c.group === 'finish' && !finish ? c.value : v;
195
196
  }
197
+ // about one shuffle in three turns or mirrors the mark, by the recipe's safe turns (never outside them); a locked Turn
198
+ // or Mirror stays. With `finish`, the turn and mirror drawn above are kept to the safe ones too
199
+ const safe = TURNS[id] || { turns: ['0'], mirror: false }, rt = rng(`${seedOf(seed)}:turn`);
200
+ const roll = rt(), pickTurn = safe.turns[Math.floor(rt() * safe.turns.length)], pickMirror = safe.mirror && rt() < 0.5;
201
+ if (!locked.includes('turn')) {
202
+ if (finish) { if (!safe.turns.includes(String(out.turn))) out.turn = '0'; }
203
+ else if (roll < TURN_SHARE) out.turn = pickTurn;
204
+ }
205
+ if (!locked.includes('mirror')) {
206
+ if (finish) { if (out.mirror && !safe.mirror) out.mirror = false; }
207
+ else if (roll < TURN_SHARE) out.mirror = pickMirror;
208
+ }
196
209
  return resolve(r.controls, out);
197
210
  }
198
211
 
package/src/index.d.ts CHANGED
@@ -74,6 +74,10 @@ export const MIX_WEIGHT: Record<string, number>;
74
74
  export const TUNING: Record<string, Record<string, { random?: [number, number] | string[]; rare?: number; value?: number | string | boolean }>>;
75
75
  /** Per recipe: the keys of the controls a page shows first. */
76
76
  export const MAIN: Record<string, string[]>;
77
+ /** Each recipe's safe turns: the Turn values and whether Mirror is allowed in a shuffle. */
78
+ export const TURNS: Record<string, { turns: ('0' | '90' | '180' | '270')[]; mirror: boolean }>;
79
+ /** The share of shuffles that turn or mirror a mark. */
80
+ export const TURN_SHARE: number;
77
81
  /** Every control's default. */
78
82
  export function defaults(controls: Control[]): Params;
79
83
  /** Every control's value from params, clamped, defaults for missing ones. */
package/src/index.js CHANGED
@@ -6,6 +6,6 @@ export { recipe, generate, randomParams, variations, nearby, similar, mix, shuff
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
+ export { TUNING, MAIN, TURNS, TURN_SHARE } from './tuning.js';
10
10
  export { PRESETS } from './presets.js';
11
11
  export { PRIMS, prim, alike, banned, unlike, unlikePair, unlikeTriple, BANNED } from './primitives.js';
package/src/presets.js CHANGED
@@ -46,7 +46,9 @@ export const PRESETS = [
46
46
  { id: 'soft-nodes', name: 'Soft nodes', recipe: 'nodes', params: { nodes: 4, size: 0.19, hole: 0.3, neck: 0.6 }, note: 'Four soft nodes on the diagonals, joined by necks to a ring round a hole.' },
47
47
  { id: 'bent-x', name: 'Bent X', recipe: 'xband', params: { angle: 48, bend: 'flat', double: false }, note: 'An X of two bent bands meeting a gap apart.' },
48
48
  { id: 'arch-emblem', name: 'Arch emblem', recipe: 'mirror', params: { body: 'hexagon', weight: 0.28 }, note: 'Two heavy bowed bands meeting in the middle, a thick bowl above and below, cut to a hexagon.' },
49
- { id: 'slotted-ribbon', name: 'Slotted ribbon', recipe: 'ribbon', params: { path: 'n', weight: 0.27 }, note: 'One band folding back with round turns and a slot.' },
49
+ { id: 'slotted-ribbon', name: 'Slotted ribbon', recipe: 'ribbon', params: { path: 'step', weight: 0.27 }, note: 'One band stepping across with round turns and a slot.' },
50
+ { id: 'creased-ribbon', name: 'Creased ribbon', recipe: 'ribbon', params: { path: 'stairs', turns: 'crease', weight: 0.27 }, note: 'One band folded flat twice, each crease a gap along the mitre.' },
51
+ { id: 'four-way-emblem', name: 'Four-way emblem', recipe: 'mirror', params: { symmetry: 'four', centre: 'diamond', bands: 2, body: 'octagon' }, note: 'Bands pressing in from all four sides round a diamond, cut to an octagon.' },
50
52
  { id: 'woven-ring', name: 'Woven ring', recipe: 'weave', params: { strands: 2, swells: 2, height: 0.5, ring: 'ring' }, note: 'Two curves woven over and under in a ring.' },
51
53
  { id: 'zigzag-disc', name: 'Zigzag disc', recipe: 'zigzag', params: { shape: 'circle', stripes: 5, teeth: 2 }, note: 'A striped disc broken by a zigzag, one side slid.' },
52
54
  { id: 'half-bars', name: 'Half bars', recipe: 'halfstripe', params: { shape: 'hexagon', bars: 4, step: 0.1 }, note: 'A hexagon half solid, half bars stepping down.' },
@@ -1,43 +1,108 @@
1
1
  /**
2
- * Mirror: a bold emblem symmetric both ways, in few heavy pieces cut by a body (a hexagon on its point or a rounded
3
- * square): across the middle two thick bowed bands that meet at the centre and part towards the sides in a V; above and
4
- * below, one thick band bowed in towards the middle, a gap between.
5
- * After the arch emblems of the owner's references, made a family of its own rather than one of them: no end caps, the
6
- * body and the bands vary. One band each side and always thick (thin arcs stacked are a Wi-Fi icon), no dots (a face).
2
+ * Mirror: a family of bold symmetric emblems in few heavy pieces, cut by a body. Symmetric two ways (bands pressing in
3
+ * from above and below) or four ways (from all four sides); one to three bands each side at stepping radii, bowed in;
4
+ * across the middle two bowed bands meeting at the centre, or (four ways) a centre piece (a diamond or a square);
5
+ * the bands as ink, or cut out of a solid body; the body a hexagon on its point, a rounded square, an octagon, or (four
6
+ * ways only) a disc. Cut, the bands are slots in a solid body with a rim.
7
+ * After the arch emblems of the owner's references and kept clear of the one it came from (R19, someone else's logo:
8
+ * under 0.65 by the house outline measure, a test holds it): no end caps, no two-way disc. Always thick bands (thin arcs
9
+ * stacked are a Wi-Fi icon), never a dot (a face), never a bar across the middle (a divide sign; in a lens, a theta or an
10
+ * eye), never bands bowed out round a lens (an eye).
7
11
  */
8
- import { U, I, arcBand, mapPts, rr, regular } from '@logomarks/core/geometry';
12
+ import { U, D, I, arcBand, mapPts, rr, regular, rot, grow, poly } from '@logomarks/core/geometry';
9
13
  import { BOX, GAP, tidy } from '../draw.js';
10
14
 
11
15
  /** @type {import('../index.js').Control[]} */
12
16
  export const controls = [
13
- { key: 'body', label: 'Body', type: 'choice', options: ['hexagon', 'square'], value: 'hexagon' },
17
+ { key: 'body', label: 'Body', type: 'choice', options: ['hexagon', 'square', 'octagon', 'disc'], value: 'hexagon' },
14
18
  { key: 'weight', label: 'Weight', type: 'range', min: 0.22, max: 0.34, step: 0.005, value: 0.28 },
15
19
  { key: 'bow', label: 'Middle curve', type: 'range', min: 1, max: 1.8, step: 0.05, value: 1.3 },
16
20
  { key: 'bowl', label: 'Band curve', type: 'range', min: 0.7, max: 1.1, step: 0.01, value: 0.78 },
21
+ { key: 'symmetry', label: 'Symmetry', type: 'choice', options: ['two', 'four'], value: 'two' },
22
+ { key: 'bands', label: 'Bands each side', type: 'range', min: 1, max: 3, step: 1, value: 1 },
23
+ { key: 'centre', label: 'Centre', type: 'choice', options: ['bands', 'diamond', 'square', 'none'], value: 'bands' },
24
+ { key: 'ground', label: 'Ground', type: 'choice', options: ['ink', 'cut'], value: 'ink' },
17
25
  ];
18
26
 
19
27
  /** The body, filling the box. */
20
- function body(kind) {
28
+ function body(kind, four) {
21
29
  const { cx, cy, x0, y0, size } = BOX;
22
- // a hexagon standing on a point (on its side, points left and right, the silhouette is the reference's own) or a
23
- // rounded square; never a disc (with these bands, the reference itself)
30
+ // a hexagon standing on a point, a rounded square or an octagon; a disc only four ways (two ways, with these bands, the
31
+ // reference itself)
24
32
  if (kind === 'hexagon') return regular(cx, cy, size / 2, 6, -90);
33
+ if (kind === 'octagon') return regular(cx, cy, size / 2 / Math.cos(Math.PI / 8), 8, 22.5);
34
+ if (kind === 'disc' && four) return regular(cx, cy, size / 2, 96, 0);
25
35
  return rr(x0, y0, size, size, size * 0.2);
26
36
  }
27
37
 
38
+ /**
39
+ * The centre piece, `r` the room it has (a half width): a diamond, or a rounded square on its side. Never a lens: between
40
+ * bands above and below it is an eye.
41
+ */
42
+ function centrePiece(kind, r) {
43
+ const { cx, cy } = BOX;
44
+ if (kind === 'square') return rr(cx - r * 0.7, cy - r * 0.7, r * 1.4, r * 1.4, r * 0.22);
45
+ return regular(cx, cy, r, 4, 0);
46
+ }
47
+
48
+ /** The bands pressing in from above: `n` of them, the innermost `edge` above the centre, each bowed in. */
49
+ function bandsAbove(n, edge, T, bowl, R) {
50
+ const { cx } = BOX, out = [];
51
+ for (let i = 0; i < n; i++) {
52
+ const e = edge - i * (T + GAP), r2 = R * bowl * (1.4 + i * 0.35);
53
+ out.push(arcBand(cx, e - T / 2 - r2, r2, T, 5, 175));
54
+ }
55
+ return out.length > 1 ? U(...out) : out[0];
56
+ }
57
+
28
58
  /** The mark for resolved params. */
29
59
  export function build(p) {
30
- const R = BOX.size / 2, T = p.weight * R, { cx, cy } = BOX;
31
- // the middle: a band sagging from above and its mirror rising from below, meeting at the centre (never a straight bar:
32
- // with a band either side, a divide sign; inside a lens, a theta or an eye)
33
- const Rc = R * p.bow, middle = arcBand(cx, cy - Rc, Rc, T, 5, 175);
34
- // the band above, a gap over the middle's top edge, bowed in (a bowl, its low point over the centre). Never bowed out:
35
- // with the middle it closes into a lens with two slits, an eye
36
- const edge = cy - T / 2 - GAP * 1.5, r2 = R * p.bowl * 1.4;
37
- const band = arcBand(cx, edge - T / 2 - r2, r2, T, 5, 175);
38
- const above = U(middle, band), below = mapPts(above, ([x, y]) => [x, 2 * cy - y]);
39
- return tidy(I(U(above, below), body(p.body)));
60
+ const R = BOX.size / 2, { cx, cy } = BOX, four = p.symmetry === 'four';
61
+ // two ways a centre piece between bands above and below is a face (brows, a nose, a mouth), so it takes the bands; the
62
+ // meeting bands take one a side (more stack into lips or a Wi-Fi fan); with nothing between, two or three slots cut in a
63
+ // solid hexagon or octagon (one is a bare smile and frown; in a rounded square they make a screen)
64
+ const centre = four ? p.centre : p.centre === 'none' ? 'none' : 'bands';
65
+ const n = !four && centre === 'bands' ? 1 : !four ? Math.max(2, Math.round(p.bands)) : Math.round(p.bands);
66
+ // more bands each side are thinner, so the gaps keep the house width and nothing crowds
67
+ const T = p.weight * R * (n === 1 ? 1 : n === 2 ? 0.78 : 0.62);
68
+ let middle = [], edge;
69
+ // two ways, slots with nothing between are always cut out of a body (bare arcs are lips)
70
+ const cut = four ? p.ground === 'cut' : centre === 'none' || p.ground === 'cut';
71
+ // two ways the reference's own round silhouette is out: no disc, and no octagon unless the bands are cut out of it
72
+ const kind = four ? p.body : cut ? (p.body === 'square' || p.body === 'disc' ? 'octagon' : p.body) : p.body === 'octagon' || p.body === 'disc' ? 'hexagon' : p.body;
73
+ const b = body(kind, four);
74
+ if (centre === 'bands' && !four) {
75
+ // a band sagging from above and its mirror rising from below, meeting at the centre
76
+ const Rc = R * p.bow;
77
+ middle = arcBand(cx, cy - Rc, Rc, T, 5, 175);
78
+ edge = cy - T / 2 - GAP * 1.5;
79
+ } else {
80
+ // a centre piece (or none): the bands start a gap clear of it
81
+ const room = R * (four ? 0.26 : 0.3) * (centre === 'none' ? 0.6 : 1);
82
+ edge = cy - room - GAP;
83
+ if (centre !== 'none' && centre !== 'bands') middle = centrePiece(centre, room);
84
+ }
85
+ let above = bandsAbove(n, edge, T, p.bowl, R);
86
+ if (!four && centre === 'bands' && n === 1 && p.ground === 'ink') {
87
+ // the 0.4.0 emblem, built in its own order so settings saved then draw the same bytes
88
+ const top = U(middle, above), bottom = mapPts(top, ([x, y]) => [x, 2 * cy - y]);
89
+ return tidy(I(U(top, bottom), b));
90
+ }
91
+ let sides;
92
+ if (four) {
93
+ // the same bands from all four sides, each kept to its quarter (a wedge from the centre), a gap along the diagonals
94
+ const wedge = grow(poly([[cx, cy], [cx - R * 3, cy - R * 3], [cx + R * 3, cy - R * 3]]), -GAP / 2);
95
+ above = I(above, wedge);
96
+ sides = U(above, rot(above, 90, cx, cy), rot(above, 180, cx, cy), rot(above, 270, cx, cy));
97
+ } else {
98
+ const below = mapPts(above, ([x, y]) => [x, 2 * cy - y]);
99
+ sides = U(above, below);
100
+ }
101
+ const art = middle.length ? U(sides, middle) : sides;
102
+ // cut: the bands (and the centre) taken out of a solid body, a rim of the body kept round them
103
+ if (cut) return tidy(D(b, I(art, grow(b, -GAP * 1.6))));
104
+ return tidy(I(art, b));
40
105
  }
41
106
 
42
- /** Four to six heavy pieces. */
107
+ /** Four to fifteen heavy pieces. */
43
108
  export const guard = {};
@@ -1,26 +1,52 @@
1
1
  /**
2
- * Ribbon: one thick band that folds back on itself, its turns round, a slot (a round-ended gap) along its longest run,
3
- * one end square and the other cut by the box. After the folded S of the owner's references. Unlike a plain letter (the
4
- * dropped Fold, mitred, read as blocky L, U, S): the round turns, the slot and the weight are always there.
2
+ * Ribbon: one thick band that folds back on itself, its turns round, slots (round-ended gaps) along its runs, its ends
3
+ * cut by the box, rounded or angled. After the folded S of the owner's references, widened into a family: one, two or
4
+ * three steps, a wave of one swing, the turns round or creased (paper folded flat: a mitre opened by the gap), one or
5
+ * two slots or none, the whole slanted. Unlike a plain letter (the dropped Fold, mitred, read as
6
+ * blocky L, U, S): the round turns and the weight are always there, and the figures that read as a letter (N, Z) are by
7
+ * hand only; a shuffle never draws them.
5
8
  */
6
- import { D, I, rect, stroke, pill, grow } from '@logomarks/core/geometry';
7
- import { BOX, GAP, tidy } from '../draw.js';
9
+ import { D, I, rect, stroke, pill, regular } from '@logomarks/core/geometry';
10
+ import { BOX, GAP, tidy, shear } from '../draw.js';
8
11
 
9
- /** The paths, in a unit box (0–1 across and down). */
10
- const PATHS = {
11
- n: [[0, 1], [0, 0], [1, 1], [1, 0]],
12
- z: [[0, 0], [1, 0], [0, 1], [1, 1]],
13
- hook: [[1, 0], [0.3, 0], [1, 0.85], [0.1, 0.85]],
14
- hairpin: [[0, 1], [0, 0], [1, 1], [1, 0.45]],
12
+ /**
13
+ * The figures, in a unit box (0–1 across and down): the path's corners, the band's weight as a share of the plain one
14
+ * (a figure with more runs side by side needs a thinner band to keep the gaps), and `over`: the run that passes over
15
+ * another ([over, under] run indices), the under run cut by a gap either side of it.
16
+ */
17
+ const FIGURES = {
18
+ n: { pts: [[0, 1], [0, 0], [1, 1], [1, 0]] },
19
+ z: { pts: [[0, 0], [1, 0], [0, 1], [1, 1]] },
20
+ hook: { pts: [[1, 0], [0.3, 0], [1, 0.85], [0.1, 0.85]] },
21
+ hairpin: { pts: [[0, 1], [0, 0], [1, 1], [1, 0.45]] },
22
+ // a stair of two folds, the runs level and upright, the middle run at `reach`
23
+ step: { pts: [[0, 1], [0, (r) => r], [1, (r) => r], [1, 0]], k: 1 },
24
+ // two steps: down and across twice
25
+ stairs: { pts: [[0, 1], [0, 0.55], [0.5, 0.55], [0.5, 0], [1, 0]], k: 0.8 },
26
+ // a wave: the band swinging across and back, its turns wide and round (`reach` sets how deep)
27
+ wave: { pts: [[0, 0.5], [0.25, (r) => 0.5 - r * 0.5], [0.75, (r) => 0.5 + r * 0.5], [1, 0.5]], k: 0.92, wave: true },
28
+ // three steps, a flight
29
+ flight: { pts: [[0, 1], [0, 0.68], [0.34, 0.68], [0.34, 0.34], [0.68, 0.34], [0.68, 0], [1, 0]], k: 0.62 },
15
30
  };
31
+ /**
32
+ * The figures a shuffle draws: never one whose main read is a letter. Drawn and dropped (2026-11-27, from sheets): a
33
+ * loop over itself (a P), a square spiral (an a), a frame round a square (a Q), one round a triangle (a muddle), a
34
+ * serpent of upright runs (n, N, M), a pleat of level runs (the numerals 2 and 3), a wave of two swings (an M) and a hairpin that steps out (ru).
35
+ */
36
+ export const SHUFFLE_FIGURES = ['step', 'stairs', 'flight', 'wave'];
16
37
 
17
38
  /** @type {import('../index.js').Control[]} */
18
39
  export const controls = [
19
- { key: 'path', label: 'Fold', type: 'choice', options: Object.keys(PATHS), value: 'n' },
40
+ { key: 'path', label: 'Fold', type: 'choice', options: Object.keys(FIGURES), value: 'step' },
20
41
  { key: 'weight', label: 'Weight', type: 'range', min: 0.2, max: 0.34, step: 0.005, value: 0.27 },
21
42
  { key: 'bend', label: 'Turn radius', type: 'range', min: 0.6, max: 1.4, step: 0.05, value: 1 },
22
43
  { key: 'slot', label: 'Slot length', type: 'range', min: 0.35, max: 0.75, step: 0.01, value: 0.55 },
23
44
  { key: 'width', label: 'Width', type: 'range', min: 0.7, max: 1, step: 0.01, value: 0.86 },
45
+ { key: 'reach', label: 'Reach', type: 'range', min: 0.3, max: 0.7, step: 0.01, value: 0.5 },
46
+ { key: 'slots', label: 'Slots', type: 'choice', options: ['one', 'two', 'none'], value: 'one' },
47
+ { key: 'ends', label: 'Ends', type: 'choice', options: ['box', 'round', 'angled'], value: 'box' },
48
+ { key: 'turns', label: 'Turns', type: 'choice', options: ['round', 'crease'], value: 'round' },
49
+ { key: 'slant', label: 'Slant', type: 'range', min: -25, max: 25, step: 1, value: 0 },
24
50
  ];
25
51
 
26
52
  /** A polyline with each inner corner rounded: a circular-ish quadratic `r` back along both legs. */
@@ -36,26 +62,67 @@ function fillet(pts, r) {
36
62
  return out;
37
63
  }
38
64
 
65
+ const len = (a, b) => Math.hypot(b[0] - a[0], b[1] - a[1]);
66
+ /** A point `d` along from `a` towards `b`. */
67
+ const along = (a, b, d) => { const l = len(a, b) || 1; return [a[0] + ((b[0] - a[0]) * d) / l, a[1] + ((b[1] - a[1]) * d) / l]; };
68
+
39
69
  /** The mark for resolved params. */
40
70
  export function build(p) {
41
- const T = p.weight * BOX.size, W = BOX.size * p.width - T, H = BOX.size - T;
71
+ const fig = FIGURES[p.path] || FIGURES.step;
72
+ const kW = fig.k ?? 1;
73
+ const T = p.weight * BOX.size * kW, W = BOX.size * p.width - T, H = BOX.size - T;
42
74
  const x0 = BOX.cx - W / 2, y0 = BOX.y0 + T / 2;
43
- const pts = PATHS[p.path].map(([u, v]) => [x0 + u * W, y0 + v * H]);
44
- // the ends run a little past the box so the box's edge squares them off
45
- const ext = (a, b) => { const l = Math.hypot(b[0] - a[0], b[1] - a[1]); return [b[0] + ((b[0] - a[0]) / l) * T, b[1] + ((b[1] - a[1]) / l) * T]; };
46
- pts[0] = ext(pts[1], pts[0]);
47
- pts[pts.length - 1] = ext(pts.at(-2), pts.at(-1));
48
- let s = stroke(fillet(pts, T * p.bend), T, {});
49
- // the slot: a round-ended gap along the middle of the longest run
50
- let best = 1, bl = 0;
51
- for (let k = 1; k < pts.length - 2; k++) { const l = Math.hypot(pts[k + 1][0] - pts[k][0], pts[k + 1][1] - pts[k][1]); if (l > bl) { bl = l; best = k; } }
52
- if (pts.length === 4) best = 1; // the middle run of a three-run fold
53
- const [a, b] = [pts[best], pts[best + 1]], m = [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2], h = p.slot / 2;
54
- const sa = [m[0] + (a[0] - m[0]) * h * 2 * 0.5, m[1] + (a[1] - m[1]) * h * 2 * 0.5], sb = [m[0] + (b[0] - m[0]) * h * 2 * 0.5, m[1] + (b[1] - m[1]) * h * 2 * 0.5];
55
- s = D(s, pill(sa, sb, GAP));
56
- return tidy(I(s, rect(BOX.x0, BOX.y0, BOX.size, BOX.size)));
75
+ const at = (v) => (typeof v === 'function' ? v(p.reach) : v);
76
+ const unit = fig.pts;
77
+ const pts = unit.map(([u, v]) => [x0 + at(u) * W, y0 + at(v) * H]);
78
+ // creased turns need runs long enough to hold a mitre and its gap; a flight's short runs keep round turns
79
+ const crease = p.turns === 'crease' && !fig.wave && pts.slice(2, -1).every((q, k) => len(pts[k + 1], q) > T * 1.5);
80
+ // the ends: run past the box and cut square by it, or stop short and round, or stop short and cut on the slant
81
+ const ext = (a, b, d) => [b[0] + ((b[0] - a[0]) / len(a, b)) * d, b[1] + ((b[1] - a[1]) / len(a, b)) * d];
82
+ if (p.ends === 'box') { pts[0] = ext(pts[1], pts[0], T); pts[pts.length - 1] = ext(pts.at(-2), pts.at(-1), T); }
83
+ else if (p.ends === 'angled') { pts[0] = ext(pts[1], pts[0], T * 0.5); pts[pts.length - 1] = ext(pts.at(-2), pts.at(-1), T * 0.5); }
84
+ let s = stroke(crease ? pts : fillet(pts, T * p.bend * (fig.wave ? 3 : 1)), T, { roundCaps: p.ends === 'round' });
85
+ if (crease) {
86
+ // each corner a crease: the mitre line from the inner corner to the outer one, opened by the gap
87
+ for (let k = 1; k < pts.length - 1; k++) {
88
+ const a = pts[k - 1], v = pts[k], b = pts[k + 1];
89
+ const ua = [(a[0] - v[0]) / len(a, v), (a[1] - v[1]) / len(a, v)], ub = [(b[0] - v[0]) / len(b, v), (b[1] - v[1]) / len(b, v)];
90
+ const bis = [ua[0] + ub[0], ua[1] + ub[1]], bl = Math.hypot(bis[0], bis[1]) || 1, d = (T / 2) * Math.SQRT2 * 1.2;
91
+ const inner = [v[0] + (bis[0] / bl) * d, v[1] + (bis[1] / bl) * d], outer = [v[0] - (bis[0] / bl) * d, v[1] - (bis[1] / bl) * d];
92
+ s = D(s, pill(inner, outer, GAP));
93
+ }
94
+ }
95
+ if (p.ends === 'angled') {
96
+ // each end sliced at 45° across the band: everything past the line through the tip's middle at 45° goes
97
+ for (const [a, b] of [[pts[1], pts[0]], [pts.at(-2), pts.at(-1)]]) {
98
+ const u = [(b[0] - a[0]) / len(a, b), (b[1] - a[1]) / len(a, b)], n = [-u[1], u[0]], F = T * 2;
99
+ const c = [b[0] - u[0] * T * 0.25, b[1] - u[1] * T * 0.25], l = [u[0] - n[0], u[1] - n[1]], o = [u[0] + n[0], u[1] + n[1]];
100
+ // only near the tip: a fold that comes back close by must not lose a corner to it
101
+ const near = regular(b[0], b[1], T * 0.95, 32, 0);
102
+ s = D(s, I([[[c[0] + l[0] * F, c[1] + l[1] * F], [c[0] - l[0] * F, c[1] - l[1] * F], [c[0] - l[0] * F + o[0] * F, c[1] - l[1] * F + o[1] * F], [c[0] + l[0] * F + o[0] * F, c[1] + l[1] * F + o[1] * F]]], near));
103
+ }
104
+ }
105
+ // the slots: round-ended gaps along the longest runs (none, one, or two), each kept to the run's straight middle: an end
106
+ // run counts only up to the box (its extension is cut away), a turn's curve takes `bend` × the weight off each end
107
+ const inBox = ([x, y]) => [Math.min(BOX.x1, Math.max(BOX.x0, x)), Math.min(BOX.y1, Math.max(BOX.y0, y))];
108
+ const runs = [];
109
+ for (let k = 0; k < pts.length - 1; k++) {
110
+ const a = k === 0 ? inBox(pts[0]) : pts[k], b = k === pts.length - 2 ? inBox(pts[k + 1]) : pts[k + 1];
111
+ // a wave is all curve but for the swing's middle, where it crosses straight: there a short slot fits
112
+ const curve = (k === 0 ? 0 : 1) + (k === pts.length - 2 ? 0 : 1), straight = fig.wave ? (k === 1 ? len(a, b) * 0.3 : 0) : len(a, b) - curve * T * p.bend * 0.9 - T * 0.3;
113
+ runs.push([straight, a, b]);
114
+ }
115
+ runs.sort((x, y) => y[0] - x[0]);
116
+ const want = p.slots === 'none' ? 0 : p.slots === 'two' ? 2 : 1;
117
+ for (const [straight, a, b] of runs.slice(0, want)) {
118
+ const h = (straight * p.slot) / 2;
119
+ if (h < GAP * 0.6) continue;
120
+ const m = [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];
121
+ s = D(s, pill(along(m, a, h), along(m, b, h), GAP));
122
+ }
123
+ s = I(s, rect(BOX.x0, BOX.y0, BOX.size, BOX.size));
124
+ return tidy(p.slant ? shear(s, p.slant) : s);
57
125
  }
58
126
 
59
- /** One band with a slot: its turns are its only curves. */
127
+ /** One band: its turns are its only curves. */
60
128
  export const guard = {};
61
- void grow;
package/src/tuning.js CHANGED
@@ -70,8 +70,8 @@ export const TUNING = {
70
70
  notch: { depth: R(0.28, 0.42), mouth: R(0.52, 0.74), seat: of('diamond', 'diamond', 'diamond', 'none'), width: R(0.72, 0.98), height: R(0.52, 0.95) },
71
71
  nodes: { nodes: R(4, 5), size: R(0.15, 0.22), ring: R(0.12, 0.2), hole: R(0.22, 0.36), neck: R(0.45, 0.85), shape: of('round', 'round', 'square'), sizes: { rare: 0.25 }, spin: R(0, 45) },
72
72
  xband: { angle: R(42, 56), weight: R(0.12, 0.17), bend: of('flat', 'flat', 'round'), double: { rare: 0.3 }, waist: R(1.1, 1.8), flat: R(0.1, 0.2) },
73
- mirror: { body: of('hexagon', 'square'), weight: R(0.24, 0.32), bow: R(1.1, 1.6), bowl: R(0.74, 1) },
74
- ribbon: { weight: R(0.23, 0.31), bend: R(0.8, 1.2), slot: R(0.45, 0.65), width: R(0.78, 0.92) },
73
+ mirror: { body: of('hexagon', 'square', 'octagon', 'disc'), weight: R(0.24, 0.32), bow: R(1.1, 1.6), bowl: R(0.74, 1), symmetry: of('two', 'four', 'four'), bands: R(1, 3), centre: of('bands', 'diamond', 'square', 'none'), ground: of('ink', 'ink', 'cut') },
74
+ ribbon: { path: of('step', 'stairs', 'flight', 'wave'), weight: R(0.23, 0.31), bend: R(0.8, 1.2), slot: R(0.45, 0.65), width: R(0.78, 0.92), reach: R(0.32, 0.68), slots: of('one', 'one', 'two', 'none'), ends: of('box', 'round'), turns: of('round', 'crease'), slant: rare(0.35, -22, 22) },
75
75
  field: { bars: R(6, 9), weight: R(0.58, 0.72), depth: R(0.3, 0.55), slide: R(0.15, 0.35), drop: R(0.4, 1.4) },
76
76
  zigzag: { stripes: R(4, 6), weight: R(0.55, 0.7), teeth: R(1, 2), swing: R(0.14, 0.24), at: R(0.4, 0.6), slide: R(0.4, 0.6) },
77
77
  halfstripe: { bars: R(3, 5), solid: R(0.44, 0.58), step: R(0.05, 0.14), weight: R(0.5, 0.7) },
@@ -94,6 +94,41 @@ export const MAIN = {
94
94
  corners: ['nw', 'ne', 'se', 'sw'],
95
95
  offset: ['shape', 'way', 'dir', 'shift'], quarters: ['a', 'b', 'pattern', 'rule'],
96
96
  mosaic: ['char', 'tiles', 'parted'], weave: ['strands', 'swells', 'height', 'ring'], notch: ['body', 'depth', 'seat', 'split'], nodes: ['nodes', 'size', 'hole', 'neck'],
97
- xband: ['angle', 'weight', 'bend', 'double'], mirror: ['body', 'weight', 'bow', 'bowl'], ribbon: ['path', 'weight', 'slot'], field: ['bars', 'profile', 'slide', 'widths'],
97
+ xband: ['angle', 'weight', 'bend', 'double'], mirror: ['symmetry', 'bands', 'centre', 'body'], ribbon: ['path', 'turns', 'ends', 'slots'], field: ['bars', 'profile', 'slide', 'widths'],
98
98
  zigzag: ['shape', 'stripes', 'teeth', 'slide'], halfstripe: ['shape', 'bars', 'step'],
99
99
  };
100
+
101
+ /**
102
+ * Safe turns: the turns and mirror a shuffle may give each recipe's mark, about one shuffle in three (the Turn and Mirror
103
+ * finish controls, so nothing new shows and saved settings keep working). Every mark is refitted after turning, so a turn
104
+ * never breaks the grid; what it can do is change what a mark reads as, so each list is only the turns that keep it what
105
+ * it was, judged from sheets of turned shuffles (2026-11-27). Left without turns:
106
+ * - letters and the sun stay upright: letter, mosaic, horizon;
107
+ * - turned they point, an arrow, a play button or a skip icon: chevrons, notch;
108
+ * - iso keeps its light from one side: iso;
109
+ * - turned they are another sign: bars or slanted bars on their side (a menu icon), arcs upside down (a magnet);
110
+ * - already the same every quarter turn, a turn adds nothing: rings, burst, bloom, loops, nodes, turns.
111
+ * Stack, Bars, Shear, Leaf Tiles and Trine take the mirror only (a stack turned is a figure the other way up; shear on
112
+ * its side is a menu icon; the others are symmetric under quarter turns). Steps and Ribbon take a half turn only (steps on their
113
+ * side are signal bars; a ribbon's wave on its side is an S), Flare no half turn (from a foot, turned over, a rising sun).
114
+ */
115
+ const Q = { turns: ['0', '90', '180', '270'], mirror: true };
116
+ const HALF = { turns: ['0', '90'], mirror: false };
117
+ const HALF_M = { turns: ['0', '90'], mirror: true };
118
+ const MIRROR = { turns: ['0'], mirror: true };
119
+ const NONE = { turns: ['0'], mirror: false };
120
+ export const TURNS = {
121
+ twin: Q, cut: Q, split: Q, arcstep: Q, seam: Q, bands: Q, stripes: Q, spiral: Q, blades: Q,
122
+ halfsq: Q, quarters: Q, merge: Q, pair: Q, offset: Q, overlap: Q, counter: Q, corners: Q, capsules: Q,
123
+ // steps on their side are signal bars; flare from a foot turned over is a rising sun
124
+ steps: { turns: ['0', '180'], mirror: true }, flare: { turns: ['0', '90', '270'], mirror: true },
125
+ wavecut: Q, halfstripe: Q,
126
+ // a ribbon's wave on its side is an S
127
+ ribbon: { turns: ['0', '180'], mirror: true }, invert: Q, route: Q, bite: Q, lobes: Q, tiles: Q,
128
+ mirror: HALF, xband: HALF, zigzag: HALF_M, field: HALF_M, weave: HALF, hex: HALF, links: HALF_M, strips: HALF_M, waves: HALF_M,
129
+ stack: MIRROR, bars: MIRROR, leaves: MIRROR, trine: MIRROR, shear: MIRROR,
130
+ letter: NONE, mosaic: NONE, horizon: NONE, chevrons: NONE, notch: NONE, iso: NONE, arcs: NONE,
131
+ rings: NONE, burst: NONE, bloom: NONE, loops: NONE, nodes: NONE, turns: NONE,
132
+ };
133
+ /** How often a shuffle turns or mirrors a mark (of the turns its recipe allows). */
134
+ export const TURN_SHARE = 1 / 3;