@logomarks/generate 0.0.0-stage → 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.
Files changed (57) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/LICENSE +21 -0
  3. package/README.md +46 -2
  4. package/package.json +29 -4
  5. package/src/controls.js +41 -0
  6. package/src/draw.js +60 -0
  7. package/src/finish.js +172 -0
  8. package/src/generate.js +274 -0
  9. package/src/guard.js +66 -0
  10. package/src/index.d.ts +111 -0
  11. package/src/index.js +10 -0
  12. package/src/presets.js +37 -0
  13. package/src/random.js +23 -0
  14. package/src/raster.js +52 -0
  15. package/src/recipes/arcs.js +83 -0
  16. package/src/recipes/arcstep.js +45 -0
  17. package/src/recipes/bands.js +90 -0
  18. package/src/recipes/bars.js +106 -0
  19. package/src/recipes/bite.js +65 -0
  20. package/src/recipes/blades.js +38 -0
  21. package/src/recipes/bloom.js +53 -0
  22. package/src/recipes/burst.js +44 -0
  23. package/src/recipes/capsules.js +36 -0
  24. package/src/recipes/chevrons.js +45 -0
  25. package/src/recipes/cut.js +80 -0
  26. package/src/recipes/flare.js +39 -0
  27. package/src/recipes/halfsq.js +53 -0
  28. package/src/recipes/hex.js +58 -0
  29. package/src/recipes/horizon.js +51 -0
  30. package/src/recipes/index.js +95 -0
  31. package/src/recipes/invert.js +40 -0
  32. package/src/recipes/iso.js +35 -0
  33. package/src/recipes/leaves.js +45 -0
  34. package/src/recipes/letter.js +204 -0
  35. package/src/recipes/links.js +63 -0
  36. package/src/recipes/lobes.js +28 -0
  37. package/src/recipes/loops.js +28 -0
  38. package/src/recipes/pixelarc.js +51 -0
  39. package/src/recipes/rings.js +82 -0
  40. package/src/recipes/route.js +107 -0
  41. package/src/recipes/seam.js +30 -0
  42. package/src/recipes/shear.js +61 -0
  43. package/src/recipes/spiral.js +42 -0
  44. package/src/recipes/split.js +54 -0
  45. package/src/recipes/stack.js +71 -0
  46. package/src/recipes/steps.js +35 -0
  47. package/src/recipes/stripes.js +66 -0
  48. package/src/recipes/strips.js +39 -0
  49. package/src/recipes/tiles.js +60 -0
  50. package/src/recipes/trine.js +37 -0
  51. package/src/recipes/turns.js +41 -0
  52. package/src/recipes/twin.js +64 -0
  53. package/src/recipes/venn.js +54 -0
  54. package/src/recipes/wavecut.js +36 -0
  55. package/src/recipes/waves.js +40 -0
  56. package/src/shapes.js +54 -0
  57. package/src/tuning.js +67 -0
@@ -0,0 +1,204 @@
1
+ /**
2
+ * Letter: one capital A–Z or numeral 0–9 in one of six constructions. Three from a 5 × 7 bitmap: blocks (the cells
3
+ * merged, square), tiles (the cells as squares and quarter discs, the outer corners rounded) and pixel (the cells parted
4
+ * by the gap). Three from core's letter skeletons (one geometric sans as centrelines): stencil (each stroke solid, split
5
+ * at its sharp corners and cleared from the ones before by the gap, a closed bowl slit at its top), slabs (the stencil
6
+ * parts sheared and parted wider, like Shear) and route (the skeleton walked in runs at 0°, 45° and 90°, mitred, like
7
+ * Route). After lettermarks built as blocks, slabs and bands: a K of slanted slabs, an H of three bars.
8
+ */
9
+ import { U, D, I, rect, rr, mapPts, stroke, SKEL, skelSolid, skStroke, skLine, robust } from '@logomarks/core/geometry';
10
+ import { BOX, GAP, clear, tidy } from '../draw.js';
11
+
12
+ robust();
13
+
14
+ /** The 5 × 7 bitmaps, rows top to bottom. */
15
+ const BITMAP = {
16
+ A: ['.###.', '#...#', '#...#', '#####', '#...#', '#...#', '#...#'],
17
+ B: ['####.', '#...#', '#...#', '####.', '#...#', '#...#', '####.'],
18
+ C: ['.####', '#....', '#....', '#....', '#....', '#....', '.####'],
19
+ D: ['####.', '#...#', '#...#', '#...#', '#...#', '#...#', '####.'],
20
+ E: ['#####', '#....', '#....', '####.', '#....', '#....', '#####'],
21
+ F: ['#####', '#....', '#....', '####.', '#....', '#....', '#....'],
22
+ G: ['.####', '#....', '#....', '#.###', '#...#', '#...#', '.####'],
23
+ H: ['#...#', '#...#', '#...#', '#####', '#...#', '#...#', '#...#'],
24
+ I: ['#####', '..#..', '..#..', '..#..', '..#..', '..#..', '#####'],
25
+ J: ['....#', '....#', '....#', '....#', '#...#', '#...#', '.###.'],
26
+ K: ['#...#', '#..#.', '#.#..', '##...', '#.#..', '#..#.', '#...#'],
27
+ L: ['#....', '#....', '#....', '#....', '#....', '#....', '#####'],
28
+ M: ['#...#', '##.##', '#.#.#', '#.#.#', '#...#', '#...#', '#...#'],
29
+ N: ['#...#', '##..#', '#.#.#', '#..##', '#...#', '#...#', '#...#'],
30
+ O: ['.###.', '#...#', '#...#', '#...#', '#...#', '#...#', '.###.'],
31
+ P: ['####.', '#...#', '#...#', '####.', '#....', '#....', '#....'],
32
+ Q: ['.###.', '#...#', '#...#', '#...#', '#.#.#', '#..#.', '.##.#'],
33
+ R: ['####.', '#...#', '#...#', '####.', '#.#..', '#..#.', '#...#'],
34
+ S: ['.####', '#....', '#....', '.###.', '....#', '....#', '####.'],
35
+ T: ['#####', '..#..', '..#..', '..#..', '..#..', '..#..', '..#..'],
36
+ U: ['#...#', '#...#', '#...#', '#...#', '#...#', '#...#', '.###.'],
37
+ V: ['#...#', '#...#', '#...#', '#...#', '#...#', '.#.#.', '..#..'],
38
+ W: ['#...#', '#...#', '#...#', '#.#.#', '#.#.#', '##.##', '#...#'],
39
+ X: ['#...#', '#...#', '.#.#.', '..#..', '.#.#.', '#...#', '#...#'],
40
+ Y: ['#...#', '#...#', '.#.#.', '..#..', '..#..', '..#..', '..#..'],
41
+ Z: ['#####', '....#', '...#.', '..#..', '.#...', '#....', '#####'],
42
+ 0: ['.###.', '#...#', '#..##', '#.#.#', '##..#', '#...#', '.###.'],
43
+ 1: ['..#..', '.##..', '..#..', '..#..', '..#..', '..#..', '.###.'],
44
+ 2: ['.###.', '#...#', '....#', '..##.', '.#...', '#....', '#####'],
45
+ 3: ['####.', '....#', '....#', '.###.', '....#', '....#', '####.'],
46
+ 4: ['...#.', '..##.', '.#.#.', '#..#.', '#####', '...#.', '...#.'],
47
+ 5: ['#####', '#....', '####.', '....#', '....#', '#...#', '.###.'],
48
+ 6: ['.###.', '#....', '#....', '####.', '#...#', '#...#', '.###.'],
49
+ 7: ['#####', '....#', '...#.', '..#..', '.#...', '.#...', '.#...'],
50
+ 8: ['.###.', '#...#', '#...#', '.###.', '#...#', '#...#', '.###.'],
51
+ 9: ['.###.', '#...#', '#...#', '.####', '....#', '....#', '.###.'],
52
+ };
53
+
54
+ const CHARS = [...'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'];
55
+ const NUMERAL = { 0: 'Zero', 1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', 6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine' };
56
+
57
+ /** @type {import('../index.js').Control[]} */
58
+ export const controls = [
59
+ { key: 'char', label: 'Letter', type: 'choice', options: CHARS, value: 'K' },
60
+ { key: 'build', label: 'Build', type: 'choice', options: ['slabs', 'stencil', 'route', 'tiles', 'blocks', 'pixel'], value: 'slabs' },
61
+ { key: 'weight', label: 'Weight', type: 'range', min: 0.12, max: 0.26, step: 0.005, value: 0.2 },
62
+ { key: 'slant', label: 'Slant', type: 'range', min: -20, max: 20, step: 1, value: 0 },
63
+ { key: 'spacing', label: 'Gaps', type: 'range', min: 1, max: 2.5, step: 0.1, value: 1.2 },
64
+ { key: 'soft', label: 'Round corners (tiles)', type: 'range', min: 0, max: 1, step: 0.05, value: 1 },
65
+ ];
66
+
67
+ /* ---------- the bitmap builds ---------- */
68
+
69
+ /** The bitmap's cells, as [col, row] for every filled one. */
70
+ function cells(ch) {
71
+ const rows = BITMAP[ch], out = [];
72
+ rows.forEach((row, r) => [...row].forEach((c, k) => { if (c === '#') out.push([k, r]); }));
73
+ return out;
74
+ }
75
+
76
+ /** A bitmap letter: blocks merged, tiles rounded at their outer corners, or pixels parted by the gap. */
77
+ function bitmapLetter(ch, build, p) {
78
+ const on = new Set(cells(ch).map(([c, r]) => `${c},${r}`)), has = (c, r) => on.has(`${c},${r}`);
79
+ const g = build === 'pixel' ? GAP * p.spacing : 0, cell = (BOX.size - 6 * g) / 7;
80
+ const parts = [];
81
+ for (const [c, r] of cells(ch)) {
82
+ const x = BOX.cx - (5 * cell + 4 * g) / 2 + c * (cell + g), y = BOX.y0 + r * (cell + g);
83
+ if (build === 'tiles') {
84
+ // a corner rounds where nothing touches it: both side neighbours and the diagonal one are empty
85
+ const free = (dc, dr) => !has(c + dc, r) && !has(c, r + dr) && !has(c + dc, r + dr);
86
+ const k = cell * p.soft;
87
+ parts.push(rr(x, y, cell, cell, [free(-1, -1) ? k : 0, free(1, -1) ? k : 0, free(1, 1) ? k : 0, free(-1, 1) ? k : 0]));
88
+ } else parts.push(rect(x - (g ? 0 : 0.01), y - (g ? 0 : 0.01), cell + (g ? 0 : 0.02), cell + (g ? 0 : 0.02)));
89
+ }
90
+ return U(...parts);
91
+ }
92
+
93
+ /* ---------- the skeleton builds ---------- */
94
+
95
+ /** The letter's skeleton at cap height H: core's, with an I (bars top and foot) core doesn't have. */
96
+ function skeleton(ch, H) {
97
+ if (ch === 'I') { const w = H * 0.72; return [skStroke(skLine([0, 0], [w, 0])), skStroke(skLine([w / 2, 0], [w / 2, H]), ['j', 'j']), skStroke(skLine([0, H], [w, H]))]; }
98
+ return SKEL[NUMERAL[ch] || ch](H);
99
+ }
100
+
101
+ /** The turn at point b, in degrees. */
102
+ function turnAt(a, b, c) {
103
+ const u = [b[0] - a[0], b[1] - a[1]], v = [c[0] - b[0], c[1] - b[1]], lu = Math.hypot(...u), lv = Math.hypot(...v);
104
+ if (!lu || !lv) return 0;
105
+ return (Math.acos(Math.max(-1, Math.min(1, (u[0] * v[0] + u[1] * v[1]) / (lu * lv)))) * 180) / Math.PI;
106
+ }
107
+
108
+ /** Strokes split at their sharp corners (a turn over 50°), so a stencil gap can open there. */
109
+ function splitAtCorners(strokes) {
110
+ const out = [];
111
+ for (const s of strokes) {
112
+ const p = s.p, cuts = [];
113
+ for (let i = 1; i < p.length - 1; i++) if (turnAt(p[i - 1], p[i], p[i + 1]) > 50) cuts.push(i);
114
+ if (!cuts.length) { out.push(s); continue; }
115
+ let from = 0;
116
+ for (const [k, i] of [...cuts, p.length - 1].entries()) {
117
+ const e = [from === 0 ? s.e[0] : 'f', i === p.length - 1 ? s.e[1] : 'f'];
118
+ if (i - from >= 1) out.push(skStroke(p.slice(from, i + 1), e));
119
+ from = i;
120
+ void k;
121
+ }
122
+ if (s.closed) out.push(skStroke([p.at(-1), p[0]], ['f', 'f']));
123
+ }
124
+ return out;
125
+ }
126
+
127
+ /** The length of a stroke's centreline. */
128
+ const lengthOf = (s) => s.p.reduce((t, q, i) => (i ? t + Math.hypot(q[0] - s.p[i - 1][0], q[1] - s.p[i - 1][1]) : 0), 0);
129
+
130
+ /** A stencil letter: each stroke solid, the longest first, every later one cleared from those before by the gap. */
131
+ function stencilLetter(ch, H, T, gap) {
132
+ const strokes = splitAtCorners(skeleton(ch, H)).sort((a, b) => lengthOf(b) - lengthOf(a));
133
+ const parts = [];
134
+ for (const s of strokes) {
135
+ let solid = skelSolid(null, H, T, [s]);
136
+ // a closed bowl with no corners (an O, a 0, the loops of an 8) is slit at its top, or it would hold no gap at all
137
+ if (s.closed) { const top = Math.min(...s.p.map(([, y]) => y)), xs = s.p.filter(([, y]) => y < top + 2).map(([x]) => x), cx = xs.reduce((a, b) => a + b, 0) / xs.length; solid = D(solid, rect(cx - gap / 2, top - T, gap, T * 2)); }
138
+ parts.push(parts.length ? clear(solid, U(...parts), gap) : solid);
139
+ }
140
+ return U(...parts);
141
+ }
142
+
143
+ /**
144
+ * A route letter: the skeleton walked in runs at 0°, 45° and 90°, stroked with mitred joins and clipped at the cap and
145
+ * base lines. A long straight stroke at another angle becomes a dog-leg (its straight part, then its 45° part), as Route
146
+ * draws; a curve (a run of short segments) is resampled and each step snapped to the nearest of the eight directions.
147
+ */
148
+ function routeLetter(ch, H, T) {
149
+ const step = H / 7, long = H / 5, parts = [];
150
+ const snap = (cur, q) => { const dx = q[0] - cur[0], dy = q[1] - cur[1], a = Math.round(Math.atan2(dy, dx) / (Math.PI / 4)) * (Math.PI / 4), len = dx * Math.cos(a) + dy * Math.sin(a); return len > 1 ? [cur[0] + Math.cos(a) * len, cur[1] + Math.sin(a) * len] : null; };
151
+ for (const s of skeleton(ch, H)) {
152
+ const p = s.closed ? [...s.p, s.p[0]] : s.p;
153
+ // merge collinear points into segments
154
+ const segs = [[p[0], p[1]]];
155
+ for (let i = 2; i < p.length; i++) { const last = segs.at(-1); if (turnAt(last[0], last[1], p[i]) < 3) last[1] = p[i]; else segs.push([last[1], p[i]]); }
156
+ const walk = [p[0]];
157
+ let curve = [];
158
+ const flush = () => {
159
+ // a curve: resample every `step` along it, then walk it in snapped runs
160
+ if (!curve.length) return;
161
+ const pts = [walk.at(-1), ...curve];
162
+ let carry = 0;
163
+ for (let i = 1; i < pts.length; i++) {
164
+ const [ax, ay] = pts[i - 1], [bx, by] = pts[i], L = Math.hypot(bx - ax, by - ay);
165
+ let t = step - carry;
166
+ while (t <= L) { const q = snap(walk.at(-1), [ax + ((bx - ax) * t) / L, ay + ((by - ay) * t) / L]); if (q) walk.push(q); t += step; }
167
+ carry = L - (t - step);
168
+ }
169
+ const q = snap(walk.at(-1), pts.at(-1)); if (q) walk.push(q);
170
+ curve = [];
171
+ };
172
+ for (const [a, b] of segs) {
173
+ const L = Math.hypot(b[0] - a[0], b[1] - a[1]);
174
+ if (L < long) { curve.push(b); continue; }
175
+ flush();
176
+ const cur = walk.at(-1), dx = b[0] - cur[0], dy = b[1] - cur[1], ang = (Math.atan2(dy, dx) * 180) / Math.PI;
177
+ const off = Math.abs(((ang % 45) + 45) % 45);
178
+ if (off < 8 || off > 37) { const q = snap(cur, b); if (q) walk.push(q); continue; }
179
+ // a dog-leg: the straight part along the stroke's main axis, then the 45° part into its end
180
+ const ax = Math.abs(dx), ay = Math.abs(dy), d = Math.min(ax, ay);
181
+ const mid = ax > ay ? [cur[0] + Math.sign(dx) * (ax - d), cur[1]] : [cur[0], cur[1] + Math.sign(dy) * (ay - d)];
182
+ walk.push(mid, [mid[0] + Math.sign(dx) * d, mid[1] + Math.sign(dy) * d]);
183
+ }
184
+ flush();
185
+ const pts = walk.filter((q, i) => i === 0 || i === walk.length - 1 || turnAt(walk[i - 1], q, walk[i + 1]) > 1);
186
+ if (pts.length >= 2) parts.push(stroke(pts, T, {}));
187
+ }
188
+ return I(U(...parts), rect(-600, -T / 2, 1800, H + T));
189
+ }
190
+
191
+ /** The mark for resolved params. */
192
+ export function build(p) {
193
+ const ch = String(p.char), H = 400, T = p.weight * BOX.size;
194
+ let s;
195
+ if (p.build === 'tiles' || p.build === 'blocks' || p.build === 'pixel') s = bitmapLetter(ch, p.build, p);
196
+ else if (p.build === 'route') s = routeLetter(ch, H, T * 0.9);
197
+ else s = stencilLetter(ch, H, T, GAP * p.spacing * (p.build === 'slabs' ? 1.5 : 1));
198
+ const slant = p.slant + (p.build === 'slabs' ? 12 : 0);
199
+ if (slant) { const k = Math.tan((slant * Math.PI) / 180), my = p.build === 'tiles' || p.build === 'blocks' || p.build === 'pixel' ? BOX.cy : H / 2; s = mapPts(s, ([x, y]) => [x - k * (y - my), y]); }
200
+ return tidy(s, { share: 0.004, width: 10 });
201
+ }
202
+
203
+ /** A pixel letter is many pieces and sparse (an L, a T); a slab's tips are sharp. */
204
+ export const guard = { maxPieces: 40, maxThinShare: 0.08, minInkShare: 0.08 };
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Links: two or three loops (rings, rounded squares or pills) linked like a chain, each crossing woven: over on one
3
+ * side, under on the other, cut free by the house gap; in a row, on a diagonal, or three round a triangle. Never more
4
+ * than three, and never the five-ring layout.
5
+ */
6
+ import { U, D, I, rect, rr, circle, rot, grown } from '@logomarks/core/geometry';
7
+ import { BOX, GAP } from '../draw.js';
8
+
9
+ /** @type {import('../index.js').Control[]} */
10
+ export const controls = [
11
+ { key: 'count', label: 'Loops', type: 'range', min: 2, max: 3, step: 1, value: 2 },
12
+ { key: 'loop', label: 'Loop', type: 'choice', options: ['ring', 'rounded', 'pill'], value: 'rounded' },
13
+ { key: 'layout', label: 'Arrangement', type: 'choice', options: ['row', 'diagonal', 'triangle'], value: 'diagonal' },
14
+ { key: 'weight', label: 'Weight', type: 'range', min: 0.07, max: 0.16, step: 0.005, value: 0.11 },
15
+ { key: 'overlap', label: 'Overlap', type: 'range', min: 0.15, max: 0.45, step: 0.01, value: 0.3 },
16
+ { key: 'corner', label: 'Corner', type: 'range', min: 0.1, max: 0.5, step: 0.01, value: 0.32 },
17
+ ];
18
+
19
+ /** A loop of outer size w × h centred at (x, y), `t` thick. */
20
+ function loop(kind, x, y, w, h, t, corner) {
21
+ if (kind === 'ring') { const r = Math.min(w, h) / 2; return D(circle(x, y, r, 72), circle(x, y, r - t, 72)); }
22
+ const rad = kind === 'pill' ? Math.min(w, h) / 2 : Math.min(w, h) * corner;
23
+ const inner = Math.max(0, rad - t);
24
+ return D(rr(x - w / 2, y - h / 2, w, h, rad), rr(x - w / 2 + t, y - h / 2 + t, w - 2 * t, h - 2 * t, inner));
25
+ }
26
+
27
+ /** The half plane to one side of the line from a to b (the left, seen walking from a to b). */
28
+ function side(a, b) {
29
+ const ang = (Math.atan2(b[1] - a[1], b[0] - a[0]) * 180) / Math.PI, mx = (a[0] + b[0]) / 2, my = (a[1] + b[1]) / 2;
30
+ return rot(rect(mx - 800, my - 800, 1600, 800), ang, mx, my);
31
+ }
32
+
33
+ /** The mark for resolved params. */
34
+ export function build(p) {
35
+ const n = p.count, t = p.weight * BOX.size, { cx, cy, size } = BOX;
36
+ const tri = p.layout === 'triangle' && n === 3;
37
+ // the loop size: n loops overlapping by `overlap` of a loop fill the box along the arrangement
38
+ const along = p.layout === 'diagonal' ? size * 1.0 : size;
39
+ const s = tri ? size / (2 - p.overlap) : along / (n - (n - 1) * p.overlap);
40
+ const pill = p.loop === 'pill';
41
+ const w = pill ? s : s, h = pill ? s * 0.56 : s;
42
+ let centres;
43
+ if (tri) centres = [[cx, cy - (size - s) / 2], [cx - (size - s) / 2, cy + (size - s) / 2], [cx + (size - s) / 2, cy + (size - s) / 2]];
44
+ else if (p.layout === 'diagonal') { const step = (size - s) / (n - 1); centres = Array.from({ length: n }, (_, k) => [BOX.x0 + s / 2 + k * step, BOX.y0 + s / 2 + k * step]); }
45
+ else { const step = (size - w) / (n - 1); centres = Array.from({ length: n }, (_, k) => [BOX.x0 + w / 2 + k * step, cy]); }
46
+ const loops = centres.map(([x, y]) => loop(p.loop, x, y, w, h, t, p.corner));
47
+ let acc = loops[0];
48
+ for (let k = 1; k < n; k++) {
49
+ const a = centres[k - 1], b = centres[k], half = side(a, b), L = loops[k];
50
+ // woven: the new loop over on one side of the line between the centres, under on the other
51
+ const flip = k % 2 === 0;
52
+ // over and under: only the loop before touches the new one, so only those two are grown for the gap
53
+ const upper = U(D(acc, grown(L, GAP)), L), lower = U(D(L, grown(loops[k - 1], GAP)), acc);
54
+ acc = U(I(flip ? lower : upper, half), D(flip ? upper : lower, half));
55
+ }
56
+ if (tri) {
57
+ // the third crossing, between the last loop and the first
58
+ const a = centres[2], b = centres[0], half = side(a, b);
59
+ const upper = U(D(acc, grown(loops[0], GAP)), loops[0]), lower = U(D(loops[0], grown(loops[2], GAP)), D(acc, loops[0]));
60
+ acc = U(I(upper, half), D(lower, half));
61
+ }
62
+ return acc;
63
+ }
@@ -0,0 +1,28 @@
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.
4
+ */
5
+ import { D, poly, circle, closedCurve } from '@logomarks/core/geometry';
6
+ import { BOX } from '../draw.js';
7
+
8
+ /** @type {import('../index.js').Control[]} */
9
+ 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 },
15
+ ];
16
+
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));
19
+
20
+ /** The mark for resolved params. */
21
+ 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;
28
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Petal Loop: rings set round a centre and merged, so only the outline of the flower is left: a heavy loop that dips
3
+ * between each petal, round an open middle or a dot.
4
+ */
5
+ import { U, D, circle, ellipse } from '@logomarks/core/geometry';
6
+ import { BOX, GAP } from '../draw.js';
7
+
8
+ /** @type {import('../index.js').Control[]} */
9
+ export const controls = [
10
+ { key: 'petals', label: 'Petals', type: 'range', min: 3, max: 8, step: 1, value: 4 },
11
+ { key: 'weight', label: 'Weight', type: 'range', min: 0.3, max: 0.7, step: 0.01, value: 0.5 },
12
+ { key: 'spread', label: 'Spread', type: 'range', min: 0.75, max: 1.3, step: 0.01, value: 1 },
13
+ { key: 'stretch', label: 'Petal length', type: 'range', min: 1, max: 1.5, step: 0.01, value: 1 },
14
+ { key: 'centre', label: 'Centre', type: 'choice', options: ['open', 'dot'], value: 'open' },
15
+ ];
16
+
17
+ /** The mark for resolved params. */
18
+ export function build(p) {
19
+ const { cx, cy, size } = BOX, n = p.petals, R = size / 2;
20
+ // petal radius r at distance d from the centre: neighbours overlap by `spread`, and d + r·stretch = R
21
+ const sin = Math.sin(Math.PI / n), r = R / (p.stretch + p.spread / sin), d = (r * p.spread) / sin;
22
+ const t = Math.max(GAP * 1.3, r * p.weight);
23
+ const at = (rad) => Array.from({ length: n }, (_, k) => { const a = (360 / n) * k - 90, ar = (a * Math.PI) / 180; return ellipse(cx + d * Math.cos(ar), cy + d * Math.sin(ar), rad * p.stretch, rad, a, 96); });
24
+ const outer = U(...at(r)), inner = U(...at(r - t));
25
+ let s = D(outer, inner);
26
+ if (p.centre === 'dot') { const dot = Math.max(GAP, d - (r - t) - GAP * 1.2); if (dot >= GAP) s = U(s, circle(cx, cy, Math.min(dot, d * 0.5), 64)); }
27
+ return s;
28
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Pixel Curve: one bold curve drawn in square pixels on a coarse grid, so its edge climbs in steps: a quarter band, an
3
+ * arch, a hook or an S. Two or three pixels thick, one or two bands; never crumbs, and never a ring round a block.
4
+ */
5
+ import { U, rect } from '@logomarks/core/geometry';
6
+ import { BOX } from '../draw.js';
7
+
8
+ /** @type {import('../index.js').Control[]} */
9
+ export const controls = [
10
+ { key: 'curve', label: 'Curve', type: 'choice', options: ['quarter', 'arch', 'hook', 'ess'], value: 'quarter' },
11
+ { key: 'grid', label: 'Pixels', type: 'range', min: 6, max: 12, step: 1, value: 8 },
12
+ { key: 'weight', label: 'Weight', type: 'range', min: 0.2, max: 0.42, step: 0.01, value: 0.3 },
13
+ { key: 'bands', label: 'Bands', type: 'range', min: 1, max: 2, step: 1, value: 1 },
14
+ { key: 'facing', label: 'Facing', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
15
+ ];
16
+
17
+ /** Whether the point (u, v) of the unit square (v down) is ink. */
18
+ function ink(p, u, v) {
19
+ const t = p.weight, bands = p.bands, inBand = (r, R) => {
20
+ // one band t wide ending at R, or two with a pixel-wide gap between, sharing that width
21
+ if (bands === 1) return r <= R && r > R - t;
22
+ const w = t * 0.62, gap = Math.max(1 / p.grid, t * 0.3);
23
+ return (r <= R && r > R - w) || (r <= R - w - gap && r > R - 2 * w - gap);
24
+ };
25
+ const core = () => false;
26
+ if (p.curve === 'quarter') { const r = Math.hypot(u, 1 - v); return inBand(r, 1) || core(r, 1); }
27
+ if (p.curve === 'arch') { const r = Math.hypot(u - 0.5, Math.max(0, 0.5 - v) ), x = Math.abs(u - 0.5); return v <= 0.5 ? inBand(r, 0.5) || core(r, 0.5) : inBand(x, 0.5) || core(x, 0.5); }
28
+ // a hook: an arch upside down whose right leg stops halfway
29
+ if (p.curve === 'hook') { const r = Math.hypot(u - 0.5, Math.max(0, v - 0.5)), x = Math.abs(u - 0.5); return v >= 0.5 ? inBand(r, 0.5) : u < 0.5 ? inBand(x, 0.5) : v > 0.3 && inBand(x, 0.5); }
30
+ // an S: two half rings, the upper open to the right's left, the lower mirrored
31
+ const top = v < 0.5, r = Math.hypot(u - 0.5, v - (top ? 0.27 : 0.73)), R = 0.27;
32
+ const open = top ? u > 0.5 && v > 0.27 : u < 0.5 && v < 0.73;
33
+ return !open && r <= R && r > R - Math.min(t * 0.6, 0.17);
34
+ }
35
+
36
+ /** The mark for resolved params. */
37
+ export function build(p) {
38
+ const n = p.grid, s = BOX.size / n, parts = [], q = Number(p.facing) / 90;
39
+ for (let r = 0; r < n; r++) {
40
+ let start = -1;
41
+ for (let c = 0; c <= n; c++) {
42
+ // the cell (r, c) seen from the facing: the grid turned by quarter turns
43
+ let u = (c + 0.5) / n, v = (r + 0.5) / n;
44
+ for (let k = 0; k < q; k++) [u, v] = [v, 1 - u];
45
+ const on = c < n && ink(p, u, v);
46
+ if (on && start < 0) start = c;
47
+ if (!on && start >= 0) { parts.push(rect(BOX.x0 + start * s, BOX.y0 + r * s - 0.01, (c - start) * s, s + 0.02)); start = -1; }
48
+ }
49
+ }
50
+ return parts.length ? U(...parts) : [];
51
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Rings: two to five concentric rings, each broken by one to four gaps, the gaps turning a little from ring to ring (a
3
+ * spiral or a fan; with two or more gaps they always turn, never line up into a sign or a crosshair), round a centre dot
4
+ * or an open eye, the centre pushed off to one side if asked. After inverted
5
+ * rings, halos and orbit marks. `shape` makes the rings frames (rounded, square, chamfered or hexagonal: broken polygon
6
+ * frames), and `breakKind` step makes each gap a stepped break (on rings at least 3 gaps thick; thinner ones split into
7
+ * hairlines, so they keep the straight cut). Square frames take three gaps at most (four is a
8
+ * crosshair or a focus frame).
9
+ */
10
+ import { U, D, circle, annulus, rot, rect, rr, poly } from '@logomarks/core/geometry';
11
+ import { BOX, GAP, tidy } from '../draw.js';
12
+
13
+ /** @type {import('../index.js').Control[]} */
14
+ export const controls = [
15
+ { key: 'count', label: 'Rings', type: 'range', min: 2, max: 5, step: 1, value: 3 },
16
+ { key: 'weight', label: 'Weight', type: 'range', min: 0.4, max: 0.85, step: 0.01, value: 0.62 },
17
+ { key: 'gaps', label: 'Gaps per ring', type: 'range', min: 0, max: 4, step: 1, value: 1 },
18
+ { key: 'gapSize', label: 'Gap size', type: 'range', min: 1, max: 4, step: 0.1, value: 1.6 },
19
+ { key: 'spin', label: 'Turn per ring', type: 'range', min: -90, max: 90, step: 1, value: 30 },
20
+ { key: 'centre', label: 'Centre', type: 'choice', options: ['dot', 'open', 'solid'], value: 'dot' },
21
+ { key: 'offset', label: 'Off centre', type: 'range', min: 0, max: 0.6, step: 0.01, value: 0 },
22
+ { key: 'shape', label: 'Shape', type: 'choice', options: ['circle', 'rounded', 'square', 'chamfer', 'hexagon'], value: 'circle' },
23
+ { key: 'breakKind', label: 'Break', type: 'choice', options: ['cut', 'step'], value: 'cut' },
24
+ ];
25
+
26
+ /** A solid outline of a shape, radius r round (cx, cy). */
27
+ function outline(shape, cx, cy, r) {
28
+ if (shape === 'rounded') return rr(cx - r, cy - r, 2 * r, 2 * r, r * 0.32);
29
+ if (shape === 'square') return rect(cx - r, cy - r, 2 * r, 2 * r);
30
+ if (shape === 'chamfer') { const k = r * 0.32; return poly([[cx - r + k, cy - r], [cx + r - k, cy - r], [cx + r, cy - r + k], [cx + r, cy + r - k], [cx + r - k, cy + r], [cx - r + k, cy + r], [cx - r, cy + r - k], [cx - r, cy - r + k]]); }
31
+ return poly(Array.from({ length: 6 }, (_, i) => { const a = (Math.PI / 3) * i - Math.PI / 2; return [cx + r * Math.cos(a), cy + r * Math.sin(a)]; }));
32
+ }
33
+
34
+ /** One ring of a shape: the outline at rOuter less its inner outline, drawn directly so the band is even. */
35
+ function ringOf(shape, cx, cy, rOuter, t) {
36
+ if (shape === 'circle') return annulus(cx, cy, rOuter - t / 2, t);
37
+ const ri = rOuter - t;
38
+ if (ri <= 2) return outline(shape, cx, cy, rOuter);
39
+ let inner;
40
+ if (shape === 'square') inner = rect(cx - ri, cy - ri, 2 * ri, 2 * ri);
41
+ else if (shape === 'rounded') inner = rr(cx - ri, cy - ri, 2 * ri, 2 * ri, Math.max(0.01, rOuter * 0.32 - t));
42
+ else if (shape === 'chamfer') { const k = Math.max(0, rOuter * 0.32 - t * 0.414); inner = poly([[cx - ri + k, cy - ri], [cx + ri - k, cy - ri], [cx + ri, cy - ri + k], [cx + ri, cy + ri - k], [cx + ri - k, cy + ri], [cx - ri + k, cy + ri], [cx - ri, cy + ri - k], [cx - ri, cy - ri + k]]); }
43
+ else inner = outline('hexagon', cx, cy, rOuter - t / Math.cos(Math.PI / 6));
44
+ return D(outline(shape, cx, cy, rOuter), inner);
45
+ }
46
+
47
+ /** A gap cut through a ring, pointing up from (cx, cy) then turned a degrees: straight, or stepped halfway out. */
48
+ function gapCut(kind, cx, cy, R, w, a, t, rMid) {
49
+ if (kind === 'step') {
50
+ const outer = rect(cx - w * 0.75, cy - R - 10, w * 0.75, R + 10 - rMid);
51
+ const inner = rect(cx, cy - rMid, w * 0.75, rMid);
52
+ return rot(U(outer, inner, rect(cx - w * 0.75, cy - rMid - Math.min(GAP, t) / 2, w * 1.5, Math.min(GAP, t))), a, cx, cy);
53
+ }
54
+ return rot(rect(cx - w / 2, cy - R - 10, w, R + 10), a, cx, cy);
55
+ }
56
+
57
+ /** The mark for resolved params. */
58
+ export function build(params) {
59
+ const p = { ...params };
60
+ if ((p.shape === 'square' || p.shape === 'rounded' || p.shape === 'chamfer') && p.gaps > 3) p.gaps = 3;
61
+ const R = BOX.size / 2, n = p.count + (p.centre === 'open' ? 0 : 1);
62
+ const gap = Math.max(GAP, ((1 - p.weight) * R) / n), t = (R - (n - 1) * gap) / n, parts = [];
63
+ for (let k = 0; k < p.count; k++) {
64
+ const rOuter = R - k * (t + gap), rMid = rOuter - t / 2;
65
+ // an off-centre stack: the rings share their top edge's tangent, slid toward it by the offset
66
+ const cy = BOX.cy - p.offset * (R - rOuter);
67
+ let ring = p.shape && p.shape !== 'circle' ? ringOf(p.shape, BOX.cx, cy, rOuter, t) : annulus(BOX.cx, cy, rMid, t);
68
+ // gaps lined up through every ring read as a sign (three: a peace sign or a car badge; four: a crosshair), so with
69
+ // two or more gaps a ring always turns at least 14° from the one outside it
70
+ const step = p.gaps >= 2 && Math.abs(p.spin) < 14 ? (p.spin < 0 ? -14 : 14) : p.spin;
71
+ for (let g = 0; g < p.gaps; g++) {
72
+ const a = step * k + (360 * g) / p.gaps;
73
+ ring = D(ring, p.breakKind === 'step' && t >= GAP * 3 ? gapCut('step', BOX.cx, cy, R, GAP * p.gapSize, a, t, rMid) : rot(rect(BOX.cx - (GAP * p.gapSize) / 2, cy - R - 10, GAP * p.gapSize, R + 10), a, BOX.cx, cy));
74
+ }
75
+ parts.push(ring);
76
+ }
77
+ const inner = R - p.count * (t + gap);
78
+ const poly2 = (r) => (p.shape && p.shape !== 'circle' ? outline(p.shape, BOX.cx, BOX.cy - p.offset * (R - inner), r) : circle(BOX.cx, BOX.cy - p.offset * (R - inner), r, 64));
79
+ if (p.centre === 'dot' && inner > t * 0.6) parts.push(poly2(Math.min(inner, t)));
80
+ if (p.centre === 'solid' && inner > 4) parts.push(poly2(inner));
81
+ return tidy(U(...parts));
82
+ }
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Route: heavy bands that run only level, upright or at 45°, turning on a lattice and forking, joined by nodes (a
3
+ * square, a diamond or a disc) where they turn, laid out by a numbered layout. After the owner's favourite, Tech · Route.
4
+ * `frame` joins the bands to a square frame (full, open on one side, or two corner Ls: the square-glyph meanders), which
5
+ * turns the diagonals off; `turns` round fillets every turn. A framed layout that looks the same a quarter turn round
6
+ * (four hooks round a centre) is passed over for the next layout.
7
+ */
8
+ import { U, rect, poly, circle, stroke, rot } from '@logomarks/core/geometry';
9
+ import { BOX } from '../draw.js';
10
+ import { rng } from '../random.js';
11
+ import { fill } from '../raster.js';
12
+
13
+ /** @type {import('../index.js').Control[]} */
14
+ export const controls = [
15
+ { key: 'tracks', label: 'Tracks', type: 'range', min: 1, max: 3, step: 1, value: 2 },
16
+ { key: 'steps', label: 'Turns', type: 'range', min: 1, max: 4, step: 1, value: 2 },
17
+ { key: 'layout', label: 'Layout no.', type: 'range', min: 1, max: 999, step: 1, value: 12 },
18
+ { key: 'weight', label: 'Weight', type: 'range', min: 0.08, max: 0.2, step: 0.005, value: 0.13 },
19
+ { key: 'node', label: 'Nodes', type: 'choice', options: ['none', 'square', 'diamond', 'disc'], value: 'diamond' },
20
+ { key: 'ends', label: 'Ends', type: 'choice', options: ['square', 'node', 'round'], value: 'node' },
21
+ { key: 'diagonals', label: 'Diagonals', type: 'toggle', value: true },
22
+ { key: 'frame', label: 'Frame', type: 'choice', options: ['none', 'full', 'open', 'corners'], value: 'none' },
23
+ { key: 'turns', label: 'Turns', type: 'choice', options: ['mitre', 'round'], value: 'mitre' },
24
+ ];
25
+
26
+ /** A polyline with every inner corner filleted: each turn becomes a quadratic curve `r` back along both legs. */
27
+ function fillet(pts, r) {
28
+ const out = [pts[0]];
29
+ for (let k = 1; k < pts.length - 1; k++) {
30
+ const [a, v, b] = [pts[k - 1], pts[k], pts[k + 1]];
31
+ const la = Math.hypot(a[0] - v[0], a[1] - v[1]), lb = Math.hypot(b[0] - v[0], b[1] - v[1]), d = Math.min(r, la / 2, lb / 2);
32
+ const p1 = [v[0] + ((a[0] - v[0]) * d) / la, v[1] + ((a[1] - v[1]) * d) / la], p2 = [v[0] + ((b[0] - v[0]) * d) / lb, v[1] + ((b[1] - v[1]) * d) / lb];
33
+ for (let i = 0; i <= 10; i++) { const t = i / 10, u = 1 - t; out.push([u * u * p1[0] + 2 * u * t * v[0] + t * t * p2[0], u * u * p1[1] + 2 * u * t * v[1] + t * t * p2[1]]); }
34
+ }
35
+ out.push(pts.at(-1));
36
+ return out;
37
+ }
38
+
39
+ /** The frame's strokes, as polylines on the lattice's outer points. */
40
+ function framePaths(kind) {
41
+ const c = [at(0, 0), at(4, 0), at(4, 4), at(0, 4)];
42
+ if (kind === 'full') return [[...c, c[0]]];
43
+ if (kind === 'open') return [[c[3], c[2], c[1], c[0]]];
44
+ return [[at(0, 2), c[0], at(2, 0)], [at(4, 2), c[2], at(2, 4)]];
45
+ }
46
+
47
+ /** A lattice of 5 × 5 points across the box. */
48
+ const at = (i, j) => [BOX.x0 + (i * BOX.size) / 4, BOX.y0 + (j * BOX.size) / 4];
49
+ const DIRS = [[1, 0], [0, 1], [-1, 0], [0, -1], [1, 1], [-1, 1], [1, -1], [-1, -1]];
50
+
51
+ /** One track's lattice points: from a start on the left edge, `steps` runs, each turning, staying in the lattice. */
52
+ function track(rand, steps, diagonals, row) {
53
+ let i = 0, j = row, pts = [[i, j]], dir = [1, 0];
54
+ for (let s = 0; s <= steps; s++) {
55
+ const len = 1 + Math.floor(rand() * 2);
56
+ for (let k = 0; k < len; k++) { const ni = i + dir[0], nj = j + dir[1]; if (ni < 0 || nj < 0 || ni > 4 || nj > 4) break; i = ni; j = nj; }
57
+ pts.push([i, j]);
58
+ const options = DIRS.slice(0, diagonals ? 8 : 4).filter(([a, b]) => !(a === -dir[0] && b === -dir[1]) && !(a === dir[0] && b === dir[1]) && a >= 0);
59
+ dir = options[Math.floor(rand() * options.length)];
60
+ }
61
+ return pts.filter((p, k, a) => k === 0 || p[0] !== a[k - 1][0] || p[1] !== a[k - 1][1]);
62
+ }
63
+
64
+ /** A node at a lattice point. */
65
+ function node(kind, [x, y], w) {
66
+ const r = w * 0.95;
67
+ if (kind === 'square') return rect(x - r, y - r, 2 * r, 2 * r);
68
+ if (kind === 'disc') return circle(x, y, r * 1.1, 48);
69
+ return poly([[x, y - r * 1.35], [x + r * 1.35, y], [x, y + r * 1.35], [x - r * 1.35, y]]);
70
+ }
71
+
72
+ /** The mark for resolved params. */
73
+ export function build(p) {
74
+ const framed = p.frame && p.frame !== 'none';
75
+ for (let tries = 0; tries < 6; tries++) {
76
+ const s = draw(p, p.layout + tries * 1000, framed);
77
+ if (!framed || !quarterSame(s)) return s;
78
+ }
79
+ return draw(p, p.layout, framed);
80
+ }
81
+
82
+ /** Whether a mark looks the same a quarter turn round (bitmaps 90% the same): four hooks round a centre. */
83
+ function quarterSame(s) {
84
+ const a = fill(s, 64), b = fill(rot(s, 90, BOX.cx, BOX.cy), 64);
85
+ let both = 0, either = 0;
86
+ for (let i = 0; i < a.length; i++) { both += a[i] & b[i]; either += a[i] | b[i]; }
87
+ return either > 0 && both / either > 0.9;
88
+ }
89
+
90
+ /** The route for a layout number. */
91
+ function draw(p, layout, framed) {
92
+ const rand = rng(`route:${layout}`), w = p.weight * BOX.size, parts = [];
93
+ const rows = [[2], [1, 3], [0, 2, 4]][p.tracks - 1];
94
+ const line = (pts) => stroke(p.turns === 'round' ? fillet(pts, w * 0.9) : pts, w, { roundCaps: p.ends === 'round' });
95
+ if (framed) for (const f of framePaths(p.frame)) parts.push(line(f));
96
+ for (const row of rows) {
97
+ const pts = track(rand, p.steps, framed ? false : p.diagonals, row).map(([i, j]) => at(i, j));
98
+ if (pts.length < 2) continue;
99
+ parts.push(line(pts));
100
+ if (p.node !== 'none') for (const q of pts.slice(1, -1)) parts.push(node(p.node, q, w));
101
+ if (p.ends === 'node' && p.node !== 'none') parts.push(node(p.node, pts[0], w), node(p.node, pts.at(-1), w));
102
+ }
103
+ return U(...parts);
104
+ }
105
+
106
+ /** Routes are drawn over one another: a route crossing itself is allowed many pieces. */
107
+ export const guard = { maxPieces: 30 };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Seam: one block parted in two by a single gap-wide seam that jogs on its way across: a step, a square tenon, a
3
+ * dovetail, or a corner taken out as its own piece. The two halves read as fitted together.
4
+ */
5
+ import { D, rect, circle, rr, regular, stroke, rot } from '@logomarks/core/geometry';
6
+ import { BOX, GAP, tidy } from '../draw.js';
7
+
8
+ /** @type {import('../index.js').Control[]} */
9
+ export const controls = [
10
+ { key: 'joint', label: 'Joint', type: 'choice', options: ['step', 'tenon', 'dovetail', 'corner'], value: 'tenon' },
11
+ { key: 'body', label: 'Body', type: 'choice', options: ['square', 'rounded', 'disc', 'hexagon'], value: 'square' },
12
+ { key: 'at', label: 'Seam position', type: 'range', min: 0.3, max: 0.7, step: 0.01, value: 0.5 },
13
+ { key: 'size', label: 'Joint size', type: 'range', min: 0.15, max: 0.4, step: 0.01, value: 0.28 },
14
+ { key: 'reach', label: 'Joint depth', type: 'range', min: 0.12, max: 0.3, step: 0.01, value: 0.2 },
15
+ { key: 'spin', label: 'Spin', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
16
+ { key: 'spacing', label: 'Gap', type: 'range', min: 1, max: 2, step: 0.1, value: 1.1 },
17
+ ];
18
+
19
+ /** The mark for resolved params: the seam drawn top to bottom, then the whole turned. */
20
+ export function build(p) {
21
+ const { cx, cy, x0, y0, x1, y1, size } = BOX, g = GAP * p.spacing, R = size / 2;
22
+ const body = p.body === 'rounded' ? rr(x0, y0, size, size, size * 0.2) : p.body === 'disc' ? circle(cx, cy, R, 128) : p.body === 'hexagon' ? regular(cx, cy, R * 1.06, 6, 0) : rect(x0, y0, size, size);
23
+ const x = x0 + size * p.at, h = (size * p.size) / 2, d = size * p.reach, T = y0 - 40, B = y1 + 40;
24
+ let line;
25
+ if (p.joint === 'step') line = [[x - d / 2, T], [x - d / 2, cy], [x + d / 2, cy], [x + d / 2, B]];
26
+ else if (p.joint === 'tenon') line = [[x, T], [x, cy - h], [x + d, cy - h], [x + d, cy + h], [x, cy + h], [x, B]];
27
+ else if (p.joint === 'dovetail') line = [[x, T], [x, cy - h * 0.6], [x + d, cy - h * 1.15], [x + d, cy + h * 1.15], [x, cy + h * 0.6], [x, B]];
28
+ else line = [[x, T], [x, y0 + size * (0.35 + p.size * 0.6)], [x1 + 40, y0 + size * (0.35 + p.size * 0.6)]];
29
+ return tidy(rot(D(body, stroke(line, g, { chunk: 1 })), Number(p.spin), cx, cy));
30
+ }