@logomarks/generate 0.2.0 → 0.3.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,5 +1,51 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.0 (2026-11-27)
4
+
5
+ Recipes that combine UNLIKE shapes (the owner: "there isn't enough variation… most shapes are combined different shapes
6
+ together"). 45 recipes: seven added, two removed (a breaking change, hence the minor version).
7
+
8
+ - `src/primitives.js` (exported: `PRIMS`, `prim`, `alike`, `banned`, `unlike`, `unlikePair`, `unlikeTriple`, `BANNED`):
9
+ fourteen basic shapes drawn in a box, pickers that never pair two that read alike, and per recipe the pairings banned
10
+ because the combination is an object (a person, a play button, an eye, a house, an arrow, a pin, a camera, a nut).
11
+ - Seven recipes on it: `merge`, `overlap`, `counter`, `pair` (Split pair), `corners`, `offset`, `quarters`. Each steers
12
+ its independent shape controls with `unlike()` and exports `shapesOf(params)` (corners: `cornersOf`), the shapes as
13
+ drawn. Seven presets (36).
14
+ - `stack` rebuilt as a totem: a third shape (`shapeC`, `turnC`, the `ABC` order), neighbours steered off the banned
15
+ pairs, and its shuffles keep to a stack, a row or a stagger with the gap between (the nests and overlaps that threw a
16
+ bare outline, an eye and a bust in the bulk run are by hand only). Old settings still draw.
17
+ - Removed: `pixelarc` (the weakest style, blocky and repetitive) and `venn` (two distinct marks in a bulk run of 130;
18
+ `overlap` draws what it did, with unlike shapes). Settings saved for either no longer draw.
19
+ - Tried and left out: Fold (a band with gaps at its creases reads as blocky letters), Interlock (what `links` draws, with
20
+ arrow-like nicks and half its draws failing), Satellite (a small shape set in a big one reads as an icon in a tile),
21
+ and a notch recipe (`cut` and `bite` already take one shape out of another's edge).
22
+ - How distinct the new recipes are, by the bulk pipeline's measure (130 shuffles each, mutually under 0.72 by outline,
23
+ then clear of the 6,072 live marks): stack 45 then 35, overlap 37 then 17, quarters 25 then 17, pair 18 then 12, offset
24
+ 26 then 10; merge 10, counter 5 and corners 6 distinct, none clear of the live set (heavy solids all score close to
25
+ the live blocks, though they look unlike them).
26
+
27
+ ## 0.2.1 (2026-11-26)
28
+
29
+ Five recipes reworked from sheets of their shuffles (ids and count unchanged, 40; settings saved from 0.2.0 still draw):
30
+
31
+ - `halfsq`: the cells stay a house gap apart and follow ONE rule (`rule`: rows turned about, all the same, a checker
32
+ with whole squares, a zigzag, a diagonal; `facing`; `grid` as '2x2', '3x2', '2x3', '3x3'). Merged into one solid they
33
+ fell into arrows, crowns, houses and envelopes: every one-solid arrangement on 2 × 2 and 3 × 2 was drawn and looked at.
34
+ A shuffle stays on 2 × 2 (a triangle's tips are thin on a finer grid).
35
+ - `lobes` (Soft): a soft block (pebble, disc or soft square) parted into two to four pebbles of unlike size by curved
36
+ gaps, every corner rounded (`body`, `pieces`, `cuts`, `bend`, `balance`, `angle`, `soften`). The lobed solid with a
37
+ round hole was a cog, the settings icon. A shuffle draws two or three pieces by the tee cut (parallel slices read as
38
+ sound waves, four pieces as a cross of gaps).
39
+ - `strips`: the woven triangle is gone (a known mark, and the recycling sign); the woven square turns between 12° and
40
+ 45° (`angle`), and one strip leans on another (`lean`), two hinge at the foot (`vee`) or one folds back (`fold`);
41
+ `flip`. The bridge over two rails (a not-equal sign) and the chevrons (the chevrons recipe's) are by hand only.
42
+ - `trine`: three slits that pass the centre and stop short of each other, of unlike depth by default (`depth`, `even`),
43
+ so the body stays whole and there is no triangle in the middle (a play button, a camera shutter); a soft square body.
44
+ The preset Shutter is now Rotor.
45
+ - `pixelarc`: new figures, `twin` (two stepped arcs back to back, the default), `wave`, `cee` (an open ring, facing
46
+ left or right only: opening up it is the power sign) and `spiral`; one band only. A shuffle draws twin, wave, hook or arch; the
47
+ open ring (on a coarse grid its hole is a plus), the S and the spiral are by hand.
48
+
3
49
  ## 0.2.0 (2026-11-26)
4
50
 
5
51
  Everything below came after 0.1.0 went to npm the same day: the quality pass (nine recipes removed, tuned shuffles,
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # @logomarks/generate
2
2
 
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
3
+ Abstract logomarks from rules and controls, no AI. Each recipe is one construction (45 of them: bars, bands, twin,
4
+ stack, shear, turns, burst, tiles, route, arcs, rings, stripes, chevrons, waves, cut, split, spiral, bloom, links,
5
+ horizon, steps, hex, iso and letter; fourteen after live house families: arcstep, halfsq, invert, leaves, lobes, loops,
6
+ trine, strips, bite, blades, wavecut, capsules, flare, seam; and seven that combine unlike shapes: merge, overlap,
7
+ counter, pair, corners, offset, quarters) that lists its controls
6
8
  and draws a mark from them, fitted to the Logomarks standard: a 512 canvas, the longest side 448, centred,
7
9
  `currentColor`, the house gap. Every recipe also takes the finish controls (turn, mirror, round corners, outline, an
8
10
  accent dot, a container: badge or clip). Each mark comes with its `pieces`, and `svgOf()` draws them in two colours. A
@@ -45,3 +47,27 @@ const twoTone = svgOf(mark.pieces, { colors: ['#0b0b0b', '#c8ff00'], pattern: 'r
45
47
  ## Licence
46
48
 
47
49
  MIT © ArrayPress Limited. What you generate is yours to use.
50
+
51
+ ## Combining unlike shapes
52
+
53
+ Seven recipes (and `stack`, a totem) build a mark from DIFFERENT basic shapes, drawn by `src/primitives.js`:
54
+
55
+ - `PRIMS`: disc, square, rsquare, triangle, wedge, half, quarter, arch, leaf, pill, diamond, hexagon, ring, bar.
56
+ `prim(type, [x, y, w, h], turn, mirror)` draws one in a box, turned by quarter turns.
57
+ - `alike(a, b)`: two shapes that read the same (a disc and a ring, a square and a rounded square) are never paired.
58
+ - `BANNED[recipe]`: the pairings a recipe never draws, each with the read it avoids (a disc over a block is a person, a
59
+ triangle in a tile a play button, a disc in a leaf an eye). `banned(recipe, a, b)` gives the reason, or ''.
60
+ - `unlike(recipe, a, b, pool)`: `b` if it may go with `a`, else the next shape of the pool that may. A recipe draws its
61
+ shapes from independent controls and steers them with this, so a banned pair is never drawn (each recipe's
62
+ `shapesOf(params)` gives the shapes as drawn). `unlikePair(rand, pool, recipe)` and `unlikeTriple` pick from a random
63
+ source.
64
+
65
+ | Recipe | What it draws |
66
+ |---|---|
67
+ | `merge` | two unlike shapes fused flat side to flat side into one solid, the second narrower and set to one side |
68
+ | `overlap` | two unlike shapes crossing: one over the other, the overlap knocked out, or the overlap kept as a piece |
69
+ | `counter` | a solid whose hole is a different shape |
70
+ | `pair` | a block split in two, each half a different shape, flat sides to the split |
71
+ | `corners` | one block, each corner square, rounded, cut, scooped or notched (never a cross, a star or an arrow) |
72
+ | `offset` | a shape and its copy slid aside: a hard shadow, the overlap knocked out or kept |
73
+ | `quarters` | four big cells, each a different shape, turned by one rule; never a plus-shaped gap |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logomarks/generate",
3
- "version": "0.2.0",
3
+ "version": "0.3.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/generate.js CHANGED
@@ -249,7 +249,7 @@ export function similar(id, params, { count = 12, seed = 1, amount = 0.15, locke
249
249
  * How often each recipe comes up in `mix()`, relative to 1: the ones whose shuffles most often give a mark worth
250
250
  * keeping lead; the textured ones (iso, hex, tiles) come up less.
251
251
  */
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 };
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, 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.1, blades: 1.1, invert: 1, wavecut: 1, capsules: 1, bite: 0.9, loops: 0.8, strips: 0.7, flare: 0.8, lobes: 0.9, halfsq: 0.8, pixelarc: 0.4 , merge: 1.3, overlap: 1.3, counter: 1.2, pair: 1.3, corners: 1.2, offset: 1.1, quarters: 1.1 };
253
253
 
254
254
  /**
255
255
  * `count` marks from ANY recipe: each slot picks a recipe by its seed (from `ids`, every recipe by default, weighted by
package/src/index.d.ts CHANGED
@@ -109,3 +109,20 @@ export function piecesOf(shape: unknown): string[];
109
109
  export function svgOf(pieces: string[], o?: { colors?: [string, string]; pattern?: 'alternate' | 'first' | 'last' | 'rows' | 'size' | 'smallest' | 'inner' | 'outer' | 'left' | 'top' | 'gradient' }): string;
110
110
  /** The colour patterns `svgOf` knows, in a picker's order. */
111
111
  export const PATTERNS: readonly string[];
112
+
113
+ /** The primitives the composition recipes combine, in a picker's order. */
114
+ export const PRIMS: string[];
115
+ /** Primitive `type` in a box ([x, y, w, h]), turned `turn` quarter turns and, with `mirror`, flipped left to right. */
116
+ export function prim(type: string, box: [number, number, number, number], turn?: number, mirror?: boolean): unknown;
117
+ /** Whether two primitives are the same or read alike. */
118
+ export function alike(a: string, b: string): boolean;
119
+ /** Why `recipe` never draws `a` with `b` (the read it avoids), or '' when it may. */
120
+ export function banned(recipe: string, a: string, b: string): string;
121
+ /** `b` if it may go with `a` in `recipe` (and with `also`), else the next shape of `pool` that may. */
122
+ export function unlike(recipe: string, a: string, b: string, pool?: string[], also?: string[]): string;
123
+ /** Two primitives of `pool`, neither alike nor banned together in `recipe`. */
124
+ export function unlikePair(rand: () => number, pool?: string[], recipe?: string): [string, string];
125
+ /** Three primitives of `pool`, no two alike or banned together. */
126
+ export function unlikeTriple(rand: () => number, pool?: string[], recipe?: string): [string, string, string];
127
+ /** Per recipe, the pairings it never draws: [a, b, the read avoided]. */
128
+ export const BANNED: Record<string, [string, string, string][]>;
package/src/index.js CHANGED
@@ -8,3 +8,4 @@ export { rng, seedOf } from './random.js';
8
8
  export { GUARD, problems } from './guard.js';
9
9
  export { TUNING, MAIN } from './tuning.js';
10
10
  export { PRESETS } from './presets.js';
11
+ export { PRIMS, prim, alike, banned, unlike, unlikePair, unlikeTriple, BANNED } from './primitives.js';
package/src/presets.js CHANGED
@@ -32,6 +32,13 @@ export const PRESETS = [
32
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
33
  { id: 'leaf-tiles', name: 'Leaf tiles', recipe: 'leaves', params: { tile: 'leaf', order: 'outward' }, note: 'Four leaves, their points to the middle.' },
34
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.' },
35
+ { id: 'shutter', name: 'Rotor', recipe: 'trine', params: { body: 'disc', offset: 0.3, depth: 0.8 }, note: 'A disc with three slits of unlike depth that pass the centre and stop short.' },
36
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.' },
37
+ { id: 'dome-wedge', name: 'Dome and wedge', recipe: 'merge', params: { a: 'half', b: 'wedge', width: 0.62 }, note: 'A dome fused to a wedge set to one side: one solid.' },
38
+ { id: 'four-corners', name: 'Four corners', recipe: 'corners', params: { nw: 'round', ne: 'square', se: 'scoop', sw: 'cut', reach: 0.4 }, note: 'One block, each corner treated a different way.' },
39
+ { id: 'leaf-window', name: 'Leaf window', recipe: 'counter', params: { body: 'square', hole: 'leaf', size: 0.44 }, note: 'A square with a leaf-shaped hole.' },
40
+ { id: 'facing-halves', name: 'Facing halves', recipe: 'pair', params: { a: 'half', b: 'quarter' }, note: 'A half disc and a quarter disc, flat sides to the split.' },
41
+ { id: 'disc-on-square', name: 'Disc over square', recipe: 'overlap', params: { a: 'disc', b: 'square', way: 'over' }, note: 'A square laid over a disc, cut free by the gap.' },
42
+ { id: 'dome-shadow', name: 'Dome shadow', recipe: 'offset', params: { shape: 'half', way: 'shadow', dir: 'se', shift: 0.28 }, note: 'A dome and its copy slid behind it.' },
43
+ { id: 'four-shapes', name: 'Four shapes', recipe: 'quarters', params: { a: 'quarter', b: 'wedge', c: 'disc', d: 'leaf', rule: 'rotate' }, note: 'Four unlike shapes, each a quarter turn on from the last.' },
37
44
  ];
@@ -0,0 +1,100 @@
1
+ /**
2
+ * The primitives the composition recipes combine: fourteen basic shapes, each drawn in a box and placed by a turn and a
3
+ * mirror, with pickers that never pair two shapes that read alike, and the pairings each recipe bans because the
4
+ * combination reads as an object (a disc over a block is a person, a triangle in a disc a play button). A recipe draws
5
+ * its shapes from independent controls, then steers them with `unlike()`, so no banned pair is ever drawn.
6
+ */
7
+ import { U, D, I, rect, poly, circle, ellipse, rr, rot, mapPts } from '@logomarks/core/geometry';
8
+
9
+ /** Every primitive, in the order a picker lists them. */
10
+ export const PRIMS = ['disc', 'square', 'rsquare', 'triangle', 'wedge', 'half', 'quarter', 'arch', 'leaf', 'pill', 'diamond', 'hexagon', 'ring', 'bar'];
11
+
12
+ /** Points of an arc round (cx, cy), radii (rx, ry), from a0 to a1 degrees. */
13
+ const arc = (cx, cy, rx, ry, a0, a1, n = 40) => Array.from({ length: n + 1 }, (_, i) => { const a = ((a0 + ((a1 - a0) * i) / n) * Math.PI) / 180; return [cx + rx * Math.cos(a), cy + ry * Math.sin(a)]; });
14
+ const oval = (x, y, w, h) => (Math.abs(w - h) < 0.5 ? circle(x + w / 2, y + h / 2, w / 2, 96) : ellipse(x + w / 2, y + h / 2, w / 2, h / 2, 0, 96));
15
+
16
+ /** The primitive unturned: flat sides down (a half's dome and a triangle's point are up, a quarter's corner bottom left). */
17
+ function draw(type, x, y, w, h) {
18
+ const x1 = x + w, y1 = y + h, cx = x + w / 2, cy = y + h / 2, m = Math.min(w, h);
19
+ switch (type) {
20
+ case 'disc': return oval(x, y, w, h);
21
+ case 'rsquare': return rr(x, y, w, h, m * 0.26);
22
+ case 'triangle': return poly([[x, y1], [cx, y], [x1, y1]]);
23
+ case 'wedge': return poly([[x, y], [x1, y1], [x, y1]]);
24
+ case 'half': return poly([...arc(cx, y1, w / 2, h, 180, 360)]);
25
+ case 'quarter': return poly([[x, y1], ...arc(x, y1, w, h, 270, 360)]);
26
+ case 'arch': { const t = m * 0.36; return poly([...arc(cx, y1, w / 2, h, 180, 360), ...arc(cx, y1, w / 2 - t, h - t, 360, 180)]); }
27
+ case 'leaf': return I(circle(x1, y1, Math.max(w, h), 128), circle(x, y, Math.max(w, h), 128), rect(x, y, w, h));
28
+ // in a square box a pill would be a disc: it lies level across the middle instead
29
+ case 'pill': return Math.abs(w - h) < m * 0.2 ? rr(x, cy - h * 0.29, w, h * 0.58, h * 0.29 - 0.01) : rr(x, y, w, h, m / 2 - 0.01);
30
+ case 'diamond': return poly([[cx, y], [x1, cy], [cx, y1], [x, cy]]);
31
+ case 'hexagon': return poly([[x + w * 0.25, y], [x + w * 0.75, y], [x1, cy], [x + w * 0.75, y1], [x + w * 0.25, y1], [x, cy]]);
32
+ case 'ring': { const t = m * 0.3; return D(oval(x, y, w, h), oval(x + t, y + t, w - 2 * t, h - 2 * t)); }
33
+ case 'bar': return rect(x, cy - h * 0.22, w, h * 0.44);
34
+ default: return rect(x, y, w, h);
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Primitive `type` in `box` ([x, y, w, h]), turned `turn` quarter turns clockwise about the box's centre (squashed back
40
+ * into a box that isn't square) and, with `mirror`, flipped left to right first.
41
+ */
42
+ export function prim(type, [x, y, w, h], turn = 0, mirror = false) {
43
+ const cx = x + w / 2, cy = y + h / 2, t = ((turn % 4) + 4) % 4, side = t % 2 === 1 && Math.abs(w - h) > 0.5;
44
+ // drawn in the box it will fill once turned, so a turned half is a true half of that box
45
+ let s = side ? draw(type, cx - h / 2, cy - w / 2, h, w) : draw(type, x, y, w, h);
46
+ if (mirror) s = mapPts(s, ([px, py]) => [2 * cx - px, py]);
47
+ return t ? rot(s, 90 * t, cx, cy) : s;
48
+ }
49
+
50
+ /** Shapes that read alike: never paired. */
51
+ const ALIKE = [['disc', 'ring'], ['square', 'rsquare'], ['square', 'bar'], ['pill', 'bar'], ['pill', 'rsquare'], ['half', 'arch'], ['triangle', 'wedge']];
52
+ /** Whether two primitives are the same or read alike. */
53
+ export const alike = (a, b) => a === b || ALIKE.some(([p, q]) => (p === a && q === b) || (p === b && q === a));
54
+
55
+ /**
56
+ * The pairings each recipe never draws, with the read each avoids. A pair is banned either way round.
57
+ */
58
+ export const BANNED = {
59
+ merge: [['disc', 'square', 'a person'], ['disc', 'rsquare', 'a person'], ['disc', 'pill', 'a person'], ['disc', 'half', 'a person'], ['disc', 'bar', 'a person'], ['disc', 'triangle', 'a pin'], ['disc', 'wedge', 'a pin'], ['disc', 'diamond', 'a pin'], ['triangle', 'square', 'a house'], ['triangle', 'rsquare', 'a house'], ['triangle', 'pill', 'an arrow'], ['triangle', 'bar', 'an arrow'], ['triangle', 'half', 'a cone'], ['diamond', 'half', 'a cone'], ['leaf', 'disc', 'a flame'], ['hexagon', 'triangle', 'a pencil'], ['square', 'half', 'a tombstone'], ['rsquare', 'half', 'a tombstone'], ['pill', 'half', 'a mushroom']],
60
+ overlap: [['disc', 'triangle', 'a play button'], ['ring', 'bar', 'a no-entry sign'], ['ring', 'pill', 'a no-entry sign'], ['disc', 'bar', 'a no-entry sign'], ['ring', 'triangle', 'a play button'], ['ring', 'square', 'a magnifier'], ['ring', 'rsquare', 'a magnifier'], ['ring', 'diamond', 'a key'], ['disc', 'half', 'a person'], ['triangle', 'square', 'a house'], ['triangle', 'rsquare', 'a house']],
61
+ counter: [['disc', 'triangle', 'a play button'], ['rsquare', 'triangle', 'a play button'], ['square', 'triangle', 'a play button'], ['hexagon', 'triangle', 'a play button'], ['disc', 'wedge', 'a play button'], ['rsquare', 'wedge', 'a play button'], ['hexagon', 'disc', 'a nut'], ['triangle', 'disc', 'an eye in a triangle'], ['leaf', 'disc', 'an eye'], ['disc', 'leaf', 'an eye'], ['disc', 'square', 'a stop button'], ['disc', 'rsquare', 'a stop button'], ['rsquare', 'disc', 'a camera'], ['square', 'disc', 'a camera'], ['half', 'disc', 'an eye'], ['diamond', 'disc', 'an eye'], ['disc', 'pill', 'a no-entry sign'], ['disc', 'bar', 'a no-entry sign'], ['rsquare', 'pill', 'a battery'], ['hexagon', 'pill', 'a screw head'], ['disc', 'half', 'a face'], ['rsquare', 'half', 'a face'], ['square', 'half', 'a door'], ['square', 'arch', 'a door'], ['rsquare', 'arch', 'a door']],
62
+ pair: [['triangle', 'square', 'an arrow'], ['triangle', 'rsquare', 'an arrow'], ['triangle', 'pill', 'an arrow'], ['wedge', 'square', 'an arrow'], ['triangle', 'bar', 'an arrow'], ['half', 'triangle', 'a play button']],
63
+ stack: [['half', 'square', 'a burger'], ['half', 'pill', 'a burger'], ['circle', 'square', 'a person'], ['circle', 'pill', 'a person'], ['circle', 'half', 'a person'], ['circle', 'arch', 'a person'], ['circle', 'triangle', 'a pin'], ['circle', 'chevron', 'a person'], ['circle', 'ring', 'an eye'], ['ring', 'half', 'an eye'], ['ring', 'pill', 'an eye'], ['ring', 'square', 'a person'], ['ring', 'triangle', 'a pin'], ['triangle', 'square', 'a house'], ['triangle', 'pill', 'an arrow'], ['chevron', 'square', 'a house'], ['triangle', 'half', 'a cone'], ['diamond', 'half', 'a cone']],
64
+ offset: [],
65
+ quarters: [],
66
+ };
67
+
68
+ /** Why a recipe never draws `a` with `b`, or '' when it may. */
69
+ export function banned(recipe, a, b) {
70
+ if (alike(a, b)) return 'two alike';
71
+ const hit = (BANNED[recipe] || []).find(([p, q]) => (p === a && q === b) || (p === b && q === a));
72
+ return hit ? hit[2] : '';
73
+ }
74
+
75
+ /**
76
+ * `b` if it may go with `a` in `recipe` (and with `also`, shapes already chosen), else the next shape of `pool` after
77
+ * it that may: how a recipe steers independent controls away from a banned pair.
78
+ */
79
+ export function unlike(recipe, a, b, pool = PRIMS, also = []) {
80
+ const ok = (c) => !banned(recipe, a, c) && also.every((d) => !banned(recipe, d, c));
81
+ if (ok(b)) return b;
82
+ const i = Math.max(0, pool.indexOf(b));
83
+ for (let k = 1; k <= pool.length; k++) { const c = pool[(i + k) % pool.length]; if (ok(c)) return c; }
84
+ return b;
85
+ }
86
+
87
+ /** Two primitives of `pool` that neither read alike nor are banned in `recipe`, from a random source (0–1). */
88
+ export function unlikePair(rand, pool = PRIMS, recipe = '') {
89
+ const a = pool[Math.floor(rand() * pool.length)];
90
+ return [a, unlike(recipe, a, pool[Math.floor(rand() * pool.length)], pool)];
91
+ }
92
+
93
+ /** Three primitives of `pool`, no two alike or banned together in `recipe`. */
94
+ export function unlikeTriple(rand, pool = PRIMS, recipe = '') {
95
+ const [a, b] = unlikePair(rand, pool, recipe);
96
+ return [a, b, unlike(recipe, b, pool[Math.floor(rand() * pool.length)], pool, [a])];
97
+ }
98
+
99
+ /** The union of shapes, skipping empty ones. */
100
+ export const join = (...shapes) => { const s = shapes.filter((x) => x && x.length); return s.length > 1 ? U(...s) : s[0] || []; };
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Corners: one block whose four corners are each treated a different way: left square, rounded, cut at 45°, scooped
3
+ * (a quarter circle taken out) or notched (a square taken out). Never four notches (a cross), four scoops (a
4
+ * four-point star) or four cuts (an octagon): the fourth of a kind is rounded instead.
5
+ */
6
+ import { D, U, I, rect, poly, circle } from '@logomarks/core/geometry';
7
+ import { BOX, tidy } from '../draw.js';
8
+
9
+ const KINDS = ['square', 'round', 'cut', 'scoop', 'notch'];
10
+
11
+ /** @type {import('../index.js').Control[]} */
12
+ export const controls = [
13
+ { key: 'nw', label: 'Top left', type: 'choice', options: KINDS, value: 'round' },
14
+ { key: 'ne', label: 'Top right', type: 'choice', options: KINDS, value: 'square' },
15
+ { key: 'se', label: 'Bottom right', type: 'choice', options: KINDS, value: 'scoop' },
16
+ { key: 'sw', label: 'Bottom left', type: 'choice', options: KINDS, value: 'cut' },
17
+ { key: 'reach', label: 'Corner size', type: 'range', min: 0.2, max: 0.5, step: 0.01, value: 0.4 },
18
+ { key: 'second', label: 'Second size', type: 'range', min: 0.5, max: 1, step: 0.01, value: 1 },
19
+ { key: 'shape', label: 'Block', type: 'choice', options: ['square', 'wide', 'tall'], value: 'square' },
20
+ ];
21
+
22
+ /**
23
+ * The four treatments as drawn, clockwise from the top left. A corner past these limits is rounded instead: one notch
24
+ * at most (two are a T or an arrow's tail), two corners taken out in all (a notch or a scoop: more is a cross), two
25
+ * cuts, and never side by side (a house, an arrow's head), three left square.
26
+ */
27
+ export function cornersOf(p) {
28
+ const out = [];
29
+ for (const k of [p.nw, p.ne, p.se, p.sw]) {
30
+ const n = (x) => out.filter((o) => o === x).length, taken = n('notch') + n('scoop'), i = out.length;
31
+ const beside = (x) => out[i - 1] === x || (i === 3 && out[0] === x);
32
+ let v = k;
33
+ if (k === 'notch' && (n('notch') >= 1 || taken >= 2)) v = 'round';
34
+ else if (k === 'scoop' && taken >= 2) v = 'round';
35
+ else if (k === 'cut' && (n('cut') >= 2 || beside('cut'))) v = 'round';
36
+ else if (k === 'square' && n('square') >= 3) v = 'round';
37
+ out.push(v);
38
+ }
39
+ return out;
40
+ }
41
+
42
+ /** The mark for resolved params. */
43
+ export function build(p) {
44
+ const { x0, y0, size, cx, cy } = BOX, w = p.shape === 'tall' ? size * 0.74 : size, h = p.shape === 'wide' ? size * 0.74 : size;
45
+ const bx = cx - w / 2, by = cy - h / 2, m = Math.min(w, h), kinds = cornersOf(p);
46
+ let s = rect(bx, by, w, h);
47
+ // corner i: its point, and the directions along its two edges into the block
48
+ const C = [[bx, by, 1, 1], [bx + w, by, -1, 1], [bx + w, by + h, -1, -1], [bx, by + h, 1, -1]];
49
+ C.forEach(([px, py, sx, sy], i) => {
50
+ const r = m * p.reach * (i % 2 ? p.second : 1), k = kinds[i], sq = rect(Math.min(px, px + sx * r), Math.min(py, py + sy * r), r, r);
51
+ if (k === 'round') s = U(D(s, sq), I(circle(px + sx * r, py + sy * r, r, 96), sq));
52
+ else if (k === 'cut') s = D(s, poly([[px, py], [px + sx * r, py], [px, py + sy * r]]));
53
+ else if (k === 'scoop') s = D(s, circle(px, py, r, 96));
54
+ else if (k === 'notch') s = D(s, rect(Math.min(px, px + sx * r * 0.8), Math.min(py, py + sy * r * 0.8), r * 0.8, r * 0.8));
55
+ });
56
+ return tidy(s);
57
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Counter: one solid whose hole is a DIFFERENT shape (a square with a leaf-shaped hole, a disc with a diamond one), the
3
+ * hole set in the middle or off towards a corner or a side. Never a round hole in a round body (a target), a triangle
4
+ * in a disc or a tile (a play button), or a disc in a leaf (an eye).
5
+ */
6
+ import { D, rot } from '@logomarks/core/geometry';
7
+ import { BOX, tidy } from '../draw.js';
8
+ import { prim, unlike } from '../primitives.js';
9
+
10
+ // the bodies with room for a hole that reads: a diamond, a leaf or a triangle leaves only a speck of one
11
+ // (and a disc takes almost no hole that isn't a sign: a pie chart, a stop button, an eye)
12
+ export const BODIES = ['square', 'rsquare', 'hexagon', 'half', 'quarter'];
13
+ export const HOLES = ['leaf', 'diamond', 'quarter', 'square', 'half', 'hexagon', 'pill', 'wedge', 'triangle', 'disc'];
14
+ /** Each body: where a hole sits (the body's middle, as shares of the box), how far it may move, and how big it may be. */
15
+ const ROOM = {
16
+ square: [0.5, 0.5, 0.17, 0.5], rsquare: [0.5, 0.5, 0.14, 0.48], hexagon: [0.5, 0.5, 0.08, 0.44],
17
+ half: [0.5, 0.6, 0.05, 0.38], quarter: [0.38, 0.62, 0.05, 0.4],
18
+ };
19
+ const MOVE = { centre: [0, 0], corner: [1, 1], side: [1, 0], low: [0, 1], high: [-1, -1] };
20
+
21
+ /** @type {import('../index.js').Control[]} */
22
+ export const controls = [
23
+ { key: 'body', label: 'Body', type: 'choice', options: BODIES, value: 'square' },
24
+ { key: 'hole', label: 'Hole', type: 'choice', options: HOLES, value: 'leaf' },
25
+ { key: 'size', label: 'Hole size', type: 'range', min: 0.24, max: 0.5, step: 0.01, value: 0.44 },
26
+ { key: 'place', label: 'Hole position', type: 'choice', options: ['centre', 'corner', 'side', 'low', 'high'], value: 'centre' },
27
+ { key: 'holeTurn', label: 'Turn hole', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
28
+ { key: 'spin', label: 'Turn body', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
29
+ ];
30
+
31
+ export const shapesOf = (p) => [p.body, unlike('counter', p.body, p.hole, HOLES)];
32
+
33
+ /** The mark for resolved params. */
34
+ export function build(p) {
35
+ const { x0, y0, size, cx, cy } = BOX, [body, hole] = shapesOf(p), [mx, my, reach, most] = ROOM[body] || ROOM.square;
36
+ const s = size * Math.min(p.size, most), [dx, dy] = MOVE[p.place] || MOVE.centre;
37
+ const hx = x0 + size * (mx + dx * reach) - s / 2, hy = y0 + size * (my + dy * reach) - s / 2;
38
+ const cut = D(prim(body, [x0, y0, size, size]), prim(hole, [hx, hy, s, s], Number(p.holeTurn) / 90));
39
+ return tidy(rot(cut, Number(p.spin), cx, cy));
40
+ }
@@ -1,53 +1,49 @@
1
1
  /**
2
- * Half Square: a small grid of whole squares and half squares (a square cut corner to corner), merged into one heavy
3
- * angular solid, mirrored so it reads as built. Layouts are numbered: each number is one arrangement.
2
+ * Half Square: a small grid of half squares (a square cut corner to corner) and whole squares, each a house gap from
3
+ * the next, set by ONE rule: every half the same way, rows turned about, halves and squares in a checker, or a zigzag.
4
+ * A quilt block, read as built. Merged into one solid the same cells fall into arrows, crowns, houses and envelopes
5
+ * (every one-solid arrangement on 2 × 2 and 3 × 2 was drawn and looked at), so the cells stay parted.
4
6
  */
5
- import { U, rect, poly } from '@logomarks/core/geometry';
6
- import { BOX, GAP, tidy } from '../draw.js';
7
- import { rng } from '../random.js';
7
+ import { rect, poly } from '@logomarks/core/geometry';
8
+ import { BOX, GAP } from '../draw.js';
8
9
 
9
10
  /** @type {import('../index.js').Control[]} */
10
11
  export const controls = [
11
- { key: 'grid', label: 'Grid', type: 'range', min: 2, max: 3, step: 1, value: 2 },
12
- { key: 'layout', label: 'Layout no.', type: 'range', min: 1, max: 999, step: 1, value: 3 },
13
- { key: 'halves', label: 'Half squares', type: 'range', min: 0.2, max: 0.8, step: 0.01, value: 0.5 },
14
- { key: 'symmetry', label: 'Symmetry', type: 'choice', options: ['mirror', 'diagonal', 'turn'], value: 'mirror' },
15
- { key: 'parted', label: 'Parted', type: 'toggle', value: false },
12
+ { key: 'grid', label: 'Grid', type: 'choice', options: ['2x2', '3x2', '2x3', '3x3'], value: '2x2' },
13
+ { key: 'rule', label: 'Rule', type: 'choice', options: ['rows', 'same', 'checker', 'zigzag', 'diagonal', 'steps'], value: 'rows' },
14
+ { key: 'facing', label: 'Facing', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
15
+ { key: 'spacing', label: 'Gap', type: 'range', min: 0.8, max: 1.8, step: 0.1, value: 1 },
16
16
  ];
17
17
 
18
- /** A cell: 'full', or a half square keeping corner 0–3 (top left, top right, bottom right, bottom left). */
19
- function cell(kind, x, y, s) {
20
- const c = [[x, y], [x + s, y], [x + s, y + s], [x, y + s]];
21
- if (kind === 'full') return rect(x, y, s, s);
22
- return poly([c[kind], c[(kind + 1) % 4], c[(kind + 3) % 4]]);
18
+ /** A cell inset by h on every side: 'full', or a half square keeping corner k (0 top left, then clockwise). */
19
+ function cell(k, x, y, s, h) {
20
+ if (k === 'full') return rect(x + h, y + h, s - 2 * h, s - 2 * h);
21
+ // the half's right angle at corner k, its legs shortened so the long side is also h in from the diagonal
22
+ const L = s - h * (2 + Math.SQRT2), sx = k === 0 || k === 3 ? 1 : -1, sy = k === 0 || k === 1 ? 1 : -1;
23
+ const cx = (sx > 0 ? x : x + s) + sx * h, cy = (sy > 0 ? y : y + s) + sy * h;
24
+ return poly([[cx, cy], [cx + sx * L, cy], [cx, cy + sy * L]]);
25
+ }
26
+
27
+ /** What stands in cell (r, c) under a rule: a corner 0–3, 'full', or null for an empty cell. */
28
+ function at(rule, r, c, k, rows, cols) {
29
+ if (rule === 'same') return k;
30
+ if (rule === 'checker') return (r + c) % 2 ? k : 'full';
31
+ // diagonal: a half on each cell of the diagonal, whole squares off it
32
+ if (rule === 'diagonal') return r === c ? k : 'full';
33
+ if (rule === 'zigzag') return c % 2 ? [1, 0, 3, 2][k] : k;
34
+ // steps: whole squares on and under the diagonal's stair, a half on each tread, nothing above
35
+ if (rule === 'steps') { const d = c - r * (cols / rows); return d < -0.01 ? 'full' : d < 0.99 ? 3 : null; }
36
+ return r % 2 ? (k + 2) % 4 : k; // rows: each row the last one turned about
23
37
  }
24
38
 
25
39
  /** The mark for resolved params. */
26
40
  export function build(p) {
27
- const n = p.grid, rand = rng(`halfsq:${n}:${p.layout}:${p.symmetry}`), s = BOX.size / n, g = p.parted ? GAP / 2 : 0;
28
- const grid = Array.from({ length: n }, () => Array(n).fill(null));
29
- const pick = () => (rand() < p.halves ? Math.floor(rand() * 4) : rand() < 0.92 ? 'full' : null);
30
- // the image of a cell and of a half's kept corner under the symmetry
31
- const image = {
32
- mirror: (r, c, k) => [r, n - 1 - c, typeof k === 'number' ? [1, 0, 3, 2][k] : k],
33
- diagonal: (r, c, k) => [c, r, typeof k === 'number' ? [0, 3, 2, 1][k] : k],
34
- turn: (r, c, k) => [n - 1 - r, n - 1 - c, typeof k === 'number' ? (k + 2) % 4 : k],
35
- }[p.symmetry];
36
- for (let r = 0; r < n; r++) for (let c = 0; c < n; c++) {
37
- if (grid[r][c] !== null) continue;
38
- const [r2, c2] = image(r, c, 0);
39
- let k = pick();
40
- // a cell that is its own image can't hold a half the symmetry would turn: whole or the matching half
41
- if (r2 === r && c2 === c && typeof k === 'number' && image(r, c, k)[2] !== k) k = 'full';
42
- grid[r][c] = k ?? 'none';
43
- const [r3, c3, k3] = image(r, c, k);
44
- grid[r3][c3] = k3 ?? 'none';
45
- }
41
+ const [cols, rows] = (/^[23]x[23]$/.test(p.grid) ? p.grid : '2x2').split('x').map(Number), k0 = Number(p.facing) / 90 || 0;
42
+ const s = BOX.size / Math.max(cols, rows), x0 = BOX.cx - (cols * s) / 2, y0 = BOX.cy - (rows * s) / 2, h = (GAP * (p.spacing || 1)) / 2;
46
43
  const parts = [];
47
- for (let r = 0; r < n; r++) for (let c = 0; c < n; c++) {
48
- const k = grid[r][c];
49
- if (k === 'none' || k === null) continue;
50
- parts.push(cell(k, BOX.x0 + c * s + g, BOX.y0 + r * s + g, s - 2 * g));
44
+ for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) {
45
+ const k = at(p.rule, r, c, k0, rows, cols);
46
+ if (k !== null) parts.push(cell(k, x0 + c * s, y0 + r * s, s, h));
51
47
  }
52
- return parts.length ? tidy(U(...parts)) : [];
48
+ return parts;
53
49
  }
@@ -17,7 +17,6 @@ import * as chevrons from './chevrons.js';
17
17
  import * as waves from './waves.js';
18
18
  import * as cut from './cut.js';
19
19
  import * as split from './split.js';
20
- import * as venn from './venn.js';
21
20
  import * as spiral from './spiral.js';
22
21
  import * as bloom from './bloom.js';
23
22
  import * as links from './links.js';
@@ -40,7 +39,13 @@ import * as wavecut from './wavecut.js';
40
39
  import * as capsules from './capsules.js';
41
40
  import * as flare from './flare.js';
42
41
  import * as seam from './seam.js';
43
- import * as pixelarc from './pixelarc.js';
42
+ import * as merge from './merge.js';
43
+ import * as overlap from './overlap.js';
44
+ import * as counter from './counter.js';
45
+ import * as pair from './pair.js';
46
+ import * as corners from './corners.js';
47
+ import * as offset from './offset.js';
48
+ import * as quarters from './quarters.js';
44
49
  import { FINISH, finish } from '../finish.js';
45
50
  import { TUNING } from '../tuning.js';
46
51
 
@@ -68,7 +73,6 @@ export const RECIPES = {
68
73
  waves: R('waves', 'Waves', 'Wavy bands, in step or turning.', waves),
69
74
  cut: R('cut', 'Cut', 'One solid with one cut: a bite, notch, slot or step.', cut),
70
75
  split: R('split', 'Split', 'A shape cut into slid parts by straight lines.', split),
71
- venn: R('venn', 'Venn', 'Overlapping circles or squares, xor, over or knocked out.', venn),
72
76
  spiral: R('spiral', 'Spiral', 'One round band coiled, with a dot or a tail.', spiral),
73
77
  bloom: R('bloom', 'Bloom', 'Petals round an open or dotted centre.', bloom),
74
78
  links: R('links', 'Links', 'Two or three loops woven like a chain.', links),
@@ -78,18 +82,24 @@ export const RECIPES = {
78
82
  iso: R('iso', 'Iso', 'Isometric cubes stacked from a height map.', iso),
79
83
  letter: R('letter', 'Letter', 'One capital or numeral in blocks, tiles, pixels, stencil, slabs or route.', letter),
80
84
  arcstep: R('arcstep', 'Arc Step', 'One heavy band that steps and turns through quarter arcs.', arcstep),
81
- halfsq: R('halfsq', 'Halves', 'Squares and half squares merged into one angular solid.', halfsq),
85
+ halfsq: R('halfsq', 'Halves', 'Half squares and squares set by one rule, a gap between each.', halfsq),
82
86
  invert: R('invert', 'Inverted', 'Rings with ink and ground swapped across one region.', invert),
83
87
  leaves: R('leaves', 'Leaf Tiles', 'One soft tile in each corner, turned from cell to cell.', leaves),
84
- lobes: R('lobes', 'Soft', 'One soft lobed solid, whole, pierced or cut.', lobes),
88
+ lobes: R('lobes', 'Soft', 'A soft block parted into pebbles of unlike size.', lobes),
85
89
  loops: R('loops', 'Loops', 'Rings merged into one heavy flower outline.', loops),
86
- trine: R('trine', 'Trine', 'A solid cut in three by slits that pass the centre.', trine),
90
+ trine: R('trine', 'Trine', 'A solid with three slits that pass the centre and stop short.', trine),
87
91
  strips: R('strips', 'Strips', 'Straight strips of tape laid over one another.', strips),
88
92
  bite: R('bite', 'Bite Link', 'A soft block with round bites taken from its sides.', bite),
89
93
  blades: R('blades', 'Blades', 'Curved blades side by side, each taller than the last.', blades),
90
94
  wavecut: R('wavecut', 'Squiggle', 'A solid cut or worn by one wavy line.', wavecut),
91
95
  capsules: R('capsules', 'Capsule', 'Slanted capsules stacked, their lengths set by one rule.', capsules),
92
96
  flare: R('flare', 'Flare', 'Rays that widen as they run out, from a corner, a foot or a centre.', flare),
93
- pixelarc: R('pixelarc', 'Pixel', 'One bold curve drawn in square pixels.', pixelarc),
97
+ merge: R('merge', 'Merge', 'Two unlike shapes fused along one edge into a single solid.', merge),
98
+ overlap: R('overlap', 'Overlap', 'Two unlike shapes crossing, one over the other or the overlap knocked out.', overlap),
99
+ counter: R('counter', 'Counter', 'A solid whose hole is a different shape.', counter),
100
+ pair: R('pair', 'Split pair', 'A block split in two, each half a different shape.', pair),
101
+ corners: R('corners', 'Corners', 'One block, each corner treated a different way.', corners),
102
+ offset: R('offset', 'Offset', 'A shape and its copy slid aside, kept apart by the gap.', offset),
103
+ quarters: R('quarters', 'Quarters', 'Four big cells, each a different shape, turned by one rule.', quarters),
94
104
  seam: R('seam', 'Seam', 'A block parted in two by one seam with a joint in it.', seam),
95
105
  };
@@ -1,28 +1,48 @@
1
1
  /**
2
- * Soft Pieces: one soft solid with three to eight lobes, whole, pierced by a round hole, or by a small echo of itself. No
3
- * corner anywhere: the calm end of the set.
2
+ * Soft Pieces: one soft block (a disc, a soft square or a pebble) parted into two to four pebbles of unlike size by
3
+ * curved gaps, every corner rounded: stones resting together, the calm end of the set. No hole in the middle and no ring
4
+ * of teeth: a lobed solid with a round hole is a cog, the settings icon.
4
5
  */
5
- import { D, poly, circle, closedCurve } from '@logomarks/core/geometry';
6
- import { BOX } from '../draw.js';
6
+ import { D, I, U, poly, circle, squircle, closedCurve, grow, rot } from '@logomarks/core/geometry';
7
+ import { BOX, GAP, tidy } from '../draw.js';
7
8
 
8
9
  /** @type {import('../index.js').Control[]} */
9
10
  export const controls = [
10
- { key: 'lobes', label: 'Lobes', type: 'range', min: 3, max: 8, step: 1, value: 5 },
11
- { key: 'depth', label: 'Depth', type: 'range', min: 0.06, max: 0.3, step: 0.01, value: 0.16 },
12
- { key: 'inside', label: 'Inside', type: 'choice', options: ['solid', 'hole', 'echo'], value: 'hole' },
13
- { key: 'hole', label: 'Hole size', type: 'range', min: 0.18, max: 0.5, step: 0.01, value: 0.3 },
14
- { key: 'spin', label: 'Spin', type: 'range', min: 0, max: 60, step: 1, value: 0 },
11
+ { key: 'body', label: 'Body', type: 'choice', options: ['pebble', 'disc', 'square'], value: 'pebble' },
12
+ { key: 'pieces', label: 'Pieces', type: 'range', min: 2, max: 4, step: 1, value: 3 },
13
+ { key: 'cuts', label: 'Cuts', type: 'choice', options: ['slices', 'tee'], value: 'tee' },
14
+ { key: 'bend', label: 'Bend', type: 'range', min: 0.1, max: 1, step: 0.01, value: 0.6 },
15
+ { key: 'balance', label: 'Balance', type: 'range', min: -0.2, max: 0.2, step: 0.01, value: 0.08 },
16
+ { key: 'angle', label: 'Angle', type: 'range', min: 0, max: 345, step: 15, value: 30 },
17
+ { key: 'soften', label: 'Soften', type: 'range', min: 0.2, max: 1, step: 0.05, value: 0.7 },
18
+ { key: 'spacing', label: 'Gap', type: 'range', min: 0.9, max: 1.8, step: 0.1, value: 1.1 },
15
19
  ];
16
20
 
17
- /** The lobed outline at radius R: r = R (1 + depth cos(n t)) / (1 + depth). */
18
- const blob = (n, depth, R, spin) => poly(closedCurve((t) => { const r = (R * (1 + depth * Math.cos(n * t))) / (1 + depth), a = t - Math.PI / 2 + (spin * Math.PI) / 180; return [BOX.cx + r * Math.cos(a), BOX.cy + r * Math.sin(a)]; }, 360));
21
+ /** Where the cuts fall across the body, as shares of its width: unlike pieces by design. */
22
+ const AT = { 2: [0.42], 3: [0.3, 0.64], 4: [0.24, 0.5, 0.74] };
19
23
 
20
24
  /** The mark for resolved params. */
21
25
  export function build(p) {
22
- const R = BOX.size / 2, s = blob(p.lobes, p.depth, R, p.spin);
23
- if (p.inside === 'hole') return D(s, circle(BOX.cx, BOX.cy, R * p.hole * (1 - p.depth), 96));
24
- // four lobes echoed inside is the four-point sparkle: a round hole instead
25
- if (p.inside === 'echo' && p.lobes === 4) return D(s, circle(BOX.cx, BOX.cy, R * p.hole * (1 - p.depth), 96));
26
- if (p.inside === 'echo') return D(s, blob(p.lobes, p.depth, R * Math.min(p.hole + 0.12, 0.55), p.spin));
27
- return s;
26
+ const { cx, cy, size } = BOX, R = size / 2, g = GAP * p.spacing, n = Math.round(p.pieces);
27
+ const body = p.body === 'disc' ? circle(cx, cy, R, 56) : p.body === 'square' ? squircle(cx, cy, R, 4.2, 56)
28
+ : poly(closedCurve((t) => { const r = (R * (1 + 0.07 * Math.cos(2 * t + 0.6) + 0.045 * Math.cos(3 * t + 2))) / 1.1; return [cx + r * Math.cos(t), cy + r * Math.sin(t)]; }, 56));
29
+ // a cut is a gap along a big circle whose centre lies off to the left: the more bend, the nearer and the rounder
30
+ const far = R * (0.9 + 2.6 * (1 - p.bend));
31
+ const arc = (share, dirDeg, c0 = [cx, cy]) => { const a = (dirDeg * Math.PI) / 180, o = [c0[0] - Math.cos(a) * far, c0[1] - Math.sin(a) * far], rho = far + (2 * share - 1) * R * 0.92; return { o, rho }; };
32
+ const gapOf = ({ o, rho }) => D(circle(o[0], o[1], rho + g / 2, 64), circle(o[0], o[1], rho - g / 2, 64));
33
+ let s;
34
+ if (p.cuts === 'tee' && n >= 3) {
35
+ // one cut across, then the larger side cut again the other way (and, for four, the smaller side too)
36
+ const first = arc(0.4 + p.balance * 0.5, 0), inner = circle(first.o[0], first.o[1], first.rho - g / 2, 64), outer = circle(first.o[0], first.o[1], first.rho + g / 2, 64);
37
+ const small = I(body, inner), big = D(body, outer);
38
+ const second = gapOf(arc(0.56 - p.balance, 90)), third = gapOf(arc(0.4 + p.balance, 270));
39
+ s = U(n >= 4 ? D(small, third) : small, D(big, second));
40
+ } else {
41
+ const at = (AT[n] || AT[3]).map((t, i) => t + p.balance * (i % 2 ? -0.5 : 0.5));
42
+ s = D(body, U(...at.map((t) => gapOf(arc(t, 0)))));
43
+ }
44
+ // every corner rounded: each piece shrunk and grown back by the same radius
45
+ const r = Math.min(46, 10 + 40 * p.soften);
46
+ s = grow(grow(s, -r), r);
47
+ return tidy(rot(s, p.angle || 0, cx, cy), { share: 0.04, width: 22 });
28
48
  }