@logomarks/generate 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +21 -0
  3. package/README.md +41 -2
  4. package/package.json +29 -4
  5. package/src/controls.js +34 -0
  6. package/src/draw.js +60 -0
  7. package/src/finish.js +172 -0
  8. package/src/generate.js +194 -0
  9. package/src/guard.js +66 -0
  10. package/src/index.d.ts +96 -0
  11. package/src/index.js +9 -0
  12. package/src/presets.js +26 -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/bands.js +90 -0
  17. package/src/recipes/bars.js +106 -0
  18. package/src/recipes/blobs.js +74 -0
  19. package/src/recipes/bloom.js +53 -0
  20. package/src/recipes/burst.js +44 -0
  21. package/src/recipes/chevrons.js +45 -0
  22. package/src/recipes/cut.js +80 -0
  23. package/src/recipes/dashes.js +61 -0
  24. package/src/recipes/dots.js +47 -0
  25. package/src/recipes/fan.js +73 -0
  26. package/src/recipes/fold.js +66 -0
  27. package/src/recipes/hex.js +58 -0
  28. package/src/recipes/horizon.js +51 -0
  29. package/src/recipes/index.js +79 -0
  30. package/src/recipes/iso.js +35 -0
  31. package/src/recipes/letter.js +204 -0
  32. package/src/recipes/line.js +142 -0
  33. package/src/recipes/links.js +63 -0
  34. package/src/recipes/orbit.js +50 -0
  35. package/src/recipes/pixel.js +38 -0
  36. package/src/recipes/rings.js +82 -0
  37. package/src/recipes/route.js +107 -0
  38. package/src/recipes/shear.js +61 -0
  39. package/src/recipes/spiral.js +42 -0
  40. package/src/recipes/split.js +54 -0
  41. package/src/recipes/stack.js +71 -0
  42. package/src/recipes/steps.js +35 -0
  43. package/src/recipes/stripes.js +66 -0
  44. package/src/recipes/tiles.js +60 -0
  45. package/src/recipes/tri.js +126 -0
  46. package/src/recipes/turns.js +41 -0
  47. package/src/recipes/twin.js +64 -0
  48. package/src/recipes/venn.js +54 -0
  49. package/src/recipes/waves.js +40 -0
  50. package/src/shapes.js +54 -0
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Bloom: five to twelve petals (a leaf, a drop, an ellipse or a round end) set round an open or dotted centre, each
3
+ * turned with it, parted from the next by the house gap or tucked under it, twisted if asked. Sharp petals come at least
4
+ * five at a time: four sharp leaves are the banned four-point sparkle.
5
+ */
6
+ import { U, I, poly, circle, ellipse, pill, rot } from '@logomarks/core/geometry';
7
+ import { BOX, GAP, clear } from '../draw.js';
8
+
9
+ /** @type {import('../index.js').Control[]} */
10
+ export const controls = [
11
+ { key: 'petals', label: 'Petals', type: 'range', min: 4, max: 12, step: 1, value: 6 },
12
+ { key: 'petal', label: 'Petal', type: 'choice', options: ['leaf', 'drop', 'ellipse', 'round'], value: 'leaf' },
13
+ { key: 'width', label: 'Petal width', type: 'range', min: 0.25, max: 0.8, step: 0.01, value: 0.5 },
14
+ { key: 'inner', label: 'Open centre', type: 'range', min: 0, max: 0.35, step: 0.01, value: 0.1 },
15
+ { key: 'centre', label: 'Centre', type: 'choice', options: ['none', 'dot'], value: 'none' },
16
+ { key: 'twist', label: 'Twist', type: 'range', min: -45, max: 45, step: 1, value: 0 },
17
+ { key: 'join', label: 'Join', type: 'choice', options: ['gap', 'tuck'], value: 'gap' },
18
+ ];
19
+
20
+ /** A lens from (cx, y0) to (cx, y1), `w` wide at its middle. */
21
+ function lens(cx, y0, y1, w) {
22
+ const c = (y1 - y0) / 2, s = w / 2, R = (c * c + s * s) / (2 * s), my = (y0 + y1) / 2;
23
+ return I(circle(cx - (R - s), my, R, 56), circle(cx + (R - s), my, R, 56));
24
+ }
25
+
26
+ /** One petal pointing up from radius r0 to r1 above the centre, `w` wide. */
27
+ function petal(kind, r0, r1, w) {
28
+ const { cx, cy } = BOX, y0 = cy - r1, y1 = cy - r0, L = y1 - y0;
29
+ if (kind === 'drop') return U(circle(cx, y0 + w / 2, w / 2, 64), poly([[cx - w / 2, y0 + w / 2], [cx + w / 2, y0 + w / 2], [cx, y1]]));
30
+ if (kind === 'ellipse') return ellipse(cx, y0 + L / 2, w / 2, L / 2, 0, 56);
31
+ if (kind === 'round') return pill([cx, y0 + w / 2], [cx, y1 - w / 2], w);
32
+ return lens(cx, y0, y1, w);
33
+ }
34
+
35
+ /** The mark for resolved params. */
36
+ export function build(p) {
37
+ const sharp = p.petal === 'leaf' || p.petal === 'drop';
38
+ const n = sharp ? Math.max(5, p.petals) : p.petals;
39
+ const R = BOX.size / 2, r0 = Math.max(p.inner * R, p.centre === 'dot' ? R * 0.26 : 0);
40
+ // the petal's width: its share of the circle at its middle, so neighbours never quite touch before the gap
41
+ const mid = (r0 + R) / 2, w = Math.min(R - r0, Math.max(GAP * 1.4, ((2 * Math.PI * mid) / n) * p.width));
42
+ const one = rot(petal(p.petal, r0, R, w), p.twist, BOX.cx, BOX.cy - r0);
43
+ const ps = Array.from({ length: n }, (_, k) => rot(one, (360 * k) / n, BOX.cx, BOX.cy));
44
+ let s;
45
+ if (p.join === 'tuck') s = U(...ps.map((q, k) => clear(q, ps[(k + 1) % n], GAP)));
46
+ // each petal cleared from the one before it (and the last from the first too): petals only ever touch neighbours
47
+ else s = U(...ps.map((q, k) => (k === 0 ? q : clear(q, k === n - 1 ? U(ps[k - 1], ps[0]) : ps[k - 1], GAP))));
48
+ if (p.centre === 'dot') s = U(s, circle(BOX.cx, BOX.cy, Math.max(GAP, r0 - GAP), 64));
49
+ return s;
50
+ }
51
+
52
+ /** Twelve petals and a dot are thirteen pieces; pointed petals lose their tips to the thin-parts test. */
53
+ export const guard = { maxPieces: 30, maxThinShare: 0.07 }; // a leaf or a drop comes to a point by design
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Burst: five to sixteen rays round an open or solid centre, each a bar, a wedge, a pill, a pair of dashes or a drop,
3
+ * long and short in turn if asked, with ONE move: a ring cut through them, a ray left out, or a centre dot. Never four
4
+ * rays (the four-point sparkle is banned).
5
+ */
6
+ import { U, D, poly, circle, rot, pill, annulus } from '@logomarks/core/geometry';
7
+ import { BOX, GAP } from '../draw.js';
8
+
9
+ /** @type {import('../index.js').Control[]} */
10
+ export const controls = [
11
+ { key: 'rays', label: 'Rays', type: 'range', min: 5, max: 16, step: 1, value: 8 },
12
+ { key: 'ray', label: 'Ray', type: 'choice', options: ['bar', 'wedge', 'pill', 'dashes', 'drop'], value: 'bar' },
13
+ { key: 'width', label: 'Ray width', type: 'range', min: 0.07, max: 0.2, step: 0.005, value: 0.1 },
14
+ { key: 'inner', label: 'Open centre', type: 'range', min: 0, max: 0.35, step: 0.01, value: 0.14 },
15
+ { key: 'alternate', label: 'Long and short', type: 'range', min: 0, max: 0.5, step: 0.01, value: 0 },
16
+ { key: 'twist', label: 'Twist', type: 'range', min: -40, max: 40, step: 1, value: 0 },
17
+ { key: 'move', label: 'Move', type: 'choice', options: ['none', 'ring', 'gap', 'dot'], value: 'none' },
18
+ ];
19
+
20
+ /** One ray pointing up from radius r0 to r1, `w` wide at its outer end. */
21
+ function ray(kind, r0, r1, w) {
22
+ const { cx, cy } = BOX, y0 = cy - r1, y1 = cy - r0;
23
+ if (kind === 'wedge') return poly([[cx - w / 2, y0], [cx + w / 2, y0], [cx + w * 0.22, y1], [cx - w * 0.22, y1]]);
24
+ if (kind === 'pill') return pill([cx, y0 + w / 2], [cx, y1 - w / 2], w);
25
+ if (kind === 'drop') return U(circle(cx, y0 + w / 2, w / 2, 48), poly([[cx - w / 2, y0 + w / 2], [cx + w / 2, y0 + w / 2], [cx, y1]]));
26
+ if (kind === 'dashes') { const m = y0 + (y1 - y0) * 0.55; return U(pill([cx, y0 + w / 2], [cx, m - GAP / 2 - w / 2], w), pill([cx, m + GAP / 2 + w / 2], [cx, y1 - w / 2], w)); }
27
+ return poly([[cx - w / 2, y0], [cx + w / 2, y0], [cx + w / 2, y1], [cx - w / 2, y1]]);
28
+ }
29
+
30
+ /** The mark for resolved params. */
31
+ export function build(p) {
32
+ const R = BOX.size / 2, w = p.width * BOX.size, r0 = Math.max(p.inner * R, p.move === 'dot' ? R * 0.28 : 0);
33
+ const parts = [];
34
+ for (let k = 0; k < p.rays; k++) {
35
+ if (p.move === 'gap' && k === 0) continue;
36
+ const r1 = k % 2 && p.alternate ? R * (1 - p.alternate) : R;
37
+ const one = ray(p.ray, Math.min(r0, r1 * 0.6), r1, w);
38
+ parts.push(rot(rot(one, p.twist, BOX.cx, BOX.cy - (r0 + r1) / 2), (360 * k) / p.rays, BOX.cx, BOX.cy));
39
+ }
40
+ let s = U(...parts);
41
+ if (p.move === 'ring') s = D(s, annulus(BOX.cx, BOX.cy, R * 0.62, GAP * 1.1));
42
+ if (p.move === 'dot') s = U(s, circle(BOX.cx, BOX.cy, R * 0.28 - GAP, 64));
43
+ return s;
44
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Chevrons: two to five chevrons stacked along their point, the house gap between them, pointed, flat-tipped or soft,
3
+ * stepping in size if asked, and ONE move: the last one solid (an arrowhead), one left out, or a stem under them (a
4
+ * tree). After Chevron Stack and stacked-arrow marks.
5
+ */
6
+ import { U, poly, rect, rot, mapPts } 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: 'Chevrons', type: 'range', min: 2, max: 5, step: 1, value: 3 },
12
+ { key: 'angle', label: 'Opening', type: 'range', min: 60, max: 140, step: 1, value: 90 },
13
+ { key: 'weight', label: 'Weight', type: 'range', min: 0.35, max: 0.8, step: 0.01, value: 0.6 },
14
+ { key: 'tip', label: 'Tip', type: 'choice', options: ['pointed', 'flat', 'notched'], value: 'pointed' },
15
+ { key: 'grow', label: 'Step in size', type: 'range', min: 0, max: 0.5, step: 0.01, value: 0 },
16
+ { key: 'move', label: 'Move', type: 'choice', options: ['none', 'arrowhead', 'skip', 'stem'], value: 'none' },
17
+ { key: 'point', label: 'Point', type: 'choice', options: ['up', 'right', 'down', 'left'], value: 'up' },
18
+ ];
19
+
20
+ /** One chevron pointing up, its tip at (cx, y), arms `half` wide each, `t` thick (measured upright). */
21
+ function chevron(cx, y, half, t, k, tip, solid) {
22
+ const drop = half / k; // how far the arms fall over their width
23
+ if (solid) return poly([[cx, y], [cx + half, y + drop], [cx + half, y + drop + t * 0.2], [cx - half, y + drop + t * 0.2], [cx - half, y + drop]]);
24
+ const outer = [[cx - half, y + drop], [cx, y], [cx + half, y + drop]], inner = [[cx + half, y + drop + t], [cx, y + t], [cx - half, y + drop + t]];
25
+ if (tip === 'flat') { const f = t * 0.6; return poly([[cx - half, y + drop], [cx - f, y + f / k], [cx + f, y + f / k], [cx + half, y + drop], [cx + half, y + drop + t], [cx, y + t], [cx - half, y + drop + t]]); }
26
+ if (tip === 'notched') return U(poly([...outer.slice(0, 2), [cx - GAP / 2, y + GAP / (2 * k)], [cx - GAP / 2, y + t + GAP / (2 * k)], inner[2]]), poly([[cx + GAP / 2, y + GAP / (2 * k)], outer[1], outer[2], inner[0], [cx + GAP / 2, y + t + GAP / (2 * k)]]));
27
+ return poly([...outer, ...inner]);
28
+ }
29
+
30
+ /** The mark for resolved params. */
31
+ export function build(p) {
32
+ const n = p.count, k = Math.tan(((p.angle / 2) * Math.PI) / 180); // half-width over drop
33
+ const half = BOX.size / 2, drop = half / k;
34
+ const total = BOX.size - drop * 0.4, pitch = total / n, t = Math.max(GAP * 1.2, pitch * p.weight), parts = [];
35
+ for (let i = 0; i < n; i++) {
36
+ if (p.move === 'skip' && i === 1) continue;
37
+ const scale = 1 - p.grow * (1 - i / Math.max(1, n - 1));
38
+ parts.push(chevron(BOX.cx, BOX.y0 + i * pitch, half * scale, t, k, p.tip, p.move === 'arrowhead' && i === 0));
39
+ }
40
+ if (p.move === 'stem') parts.push(rect(BOX.cx - t / 2, BOX.y0 + n * pitch + t * 0.2, t, BOX.size * 0.3));
41
+ let s = U(...parts);
42
+ const turn = { up: 0, right: 90, down: 180, left: 270 }[p.point];
43
+ if (turn) s = rot(s, turn, BOX.cx, BOX.cy);
44
+ return mapPts(s, (q) => q);
45
+ }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Cut: ONE heavy solid (a square, a rounded square, a circle, a hexagon or a tall pill) with ONE cut taken out of it: a
3
+ * quarter-disc bite at a corner, a round bite from an edge, a notch, a slot running in, a step off a corner, or a 45°
4
+ * wedge. Where the
5
+ * cut sits along its edge and how big it is are controls. A circle never takes a centred cut from the top (the power
6
+ * icon): it moves off centre. `angle` 45 runs a slot, notch or wedge in from the corner along the diagonal (never a
7
+ * slot through a circle's centre: the "no" sign), `second` adds a half-size cut on the opposite or the next side (kept off
8
+ * the first one's line: two crossing slots are a plus), and an `arc` cut is a quarter-ring band about a corner.
9
+ */
10
+ import { U, D, I, rect, poly, circle, rr, rot, arcBand } 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: 'body', label: 'Body', type: 'choice', options: ['square', 'rounded', 'circle', 'hexagon', 'pill'], value: 'rounded' },
16
+ { key: 'cut', label: 'Cut', type: 'choice', options: ['corner', 'bite', 'notch', 'slot', 'step', 'wedge', 'arc'], value: 'corner' },
17
+ { key: 'side', label: 'Side', type: 'choice', options: ['top', 'right', 'bottom', 'left'], value: 'right' },
18
+ { key: 'at', label: 'Position', type: 'range', min: 0.2, max: 0.8, step: 0.01, value: 0.5 },
19
+ { key: 'size', label: 'Cut size', type: 'range', min: 0.15, max: 0.55, step: 0.01, value: 0.42 },
20
+ { key: 'width', label: 'Cut width', type: 'range', min: 1, max: 4, step: 0.1, value: 2 },
21
+ { key: 'angle', label: 'Cut angle', type: 'choice', options: ['0', '45'], value: '0' },
22
+ { key: 'second', label: 'Second cut', type: 'choice', options: ['none', 'opposite', 'adjacent'], value: 'none' },
23
+ ];
24
+
25
+ /** A cut run in from the top-right corner along the diagonal toward the centre: a slot, a notch or a wedge. */
26
+ function diagonalCut(p, depth, w) {
27
+ const { x1, y0, cx, cy } = BOX, ux = (cx - x1) / Math.hypot(cx - x1, cy - y0), uy = (cy - y0) / Math.hypot(cx - x1, cy - y0);
28
+ // a slot through a circle's centre is the "no" sign: stop well short of it
29
+ // a round body's edge sits in from the box corner; start the cut there, and stop well short of a circle's centre
30
+ const inset = { circle: 0.21, hexagon: 0.2, pill: 0.25, rounded: 0.07, square: 0 }[p.body] * BOX.size * Math.SQRT2;
31
+ const toCentre = Math.hypot(cx - x1, cy - y0);
32
+ const L = Math.min(depth * 1.6 * Math.SQRT2 + inset, p.body === 'circle' ? toCentre - BOX.size * 0.14 : Infinity) + 30;
33
+ const nx = -uy, ny = ux, sx = x1 - ux * 30, sy = y0 - uy * 30;
34
+ const half = p.cut === 'notch' ? Math.max(w, depth * 0.8) / 2 : p.cut === 'wedge' ? depth * 0.7 : w / 2;
35
+ if (p.cut === 'wedge') return poly([[sx + nx * half, sy + ny * half], [sx + ux * L, sy + uy * L], [sx - nx * half, sy - ny * half]]);
36
+ return poly([[sx + nx * half, sy + ny * half], [sx + nx * half + ux * L, sy + ny * half + uy * L], [sx - nx * half + ux * L, sy - ny * half + uy * L], [sx - nx * half, sy - ny * half]]);
37
+ }
38
+
39
+ /** The body, filling the box (the pill: tall, two thirds as wide). */
40
+ function body(kind) {
41
+ const { x0, y0, size, cx, cy } = BOX;
42
+ if (kind === 'circle') return circle(cx, cy, size / 2, 128);
43
+ if (kind === 'rounded') return rr(x0, y0, size, size, size * 0.22);
44
+ if (kind === 'hexagon') return poly(Array.from({ length: 6 }, (_, k) => { const a = (Math.PI / 3) * k - Math.PI / 2; return [cx + (size / 2) * Math.cos(a), cy + (size / 2) * Math.sin(a)]; }));
45
+ if (kind === 'pill') { const w = size * 0.62; return rr(cx - w / 2, y0, w, size, w / 2); }
46
+ return rect(x0, y0, size, size);
47
+ }
48
+
49
+ /** The cut on the top edge (the whole shape is turned to put it on another side). */
50
+ function cutShape(p) {
51
+ const { x0, y0, size } = BOX, depth = p.size * size, w = Math.max(GAP * 1.5, GAP * p.width), x = x0 + p.at * size;
52
+ // how far the body's own top-right corner sits in from the box's: a cut at the corner must reach past it
53
+ const inset = { circle: 0.21, hexagon: 0.2, pill: 0.25, rounded: 0.07, square: 0 }[p.body] * size;
54
+ if (p.angle === '45' && (p.cut === 'slot' || p.cut === 'notch' || p.cut === 'wedge')) return diagonalCut(p, depth, w);
55
+ if (p.cut === 'arc') { const r = (0.45 + p.size * 0.65) * size; return arcBand(x0 + size, y0, r, GAP * p.width, 90, 180); }
56
+ if (p.cut === 'slot') return rect(x - w / 2, y0 - 20, w, depth * 1.5 + 20);
57
+ if (p.cut === 'corner') return circle(x0 + size, y0, depth * 1.15 + inset * 1.41, 96);
58
+ if (p.cut === 'bite') return circle(x, y0 + (p.body === 'circle' || p.body === 'hexagon' ? size * 0.06 : 0), depth * 0.8, 96);
59
+ if (p.cut === 'step') return rect(x0 + size - depth - inset, y0 - 20, depth + inset + 20, depth + inset + 20);
60
+ if (p.cut === 'wedge') return poly([[x - depth, y0 - 1], [x + depth, y0 - 1], [x, y0 + depth]]);
61
+ return rect(x - Math.max(w, depth * 0.8) / 2, y0 - 20, Math.max(w, depth * 0.8), depth + 20); // notch
62
+ }
63
+
64
+ /** The mark for resolved params. */
65
+ export function build(params) {
66
+ const p = { ...params };
67
+ // a centred notch or slot from the top of a circle is the power icon: slide it off centre
68
+ if (p.body === 'circle' && (p.cut === 'slot' || p.cut === 'notch') && Math.abs(p.at - 0.5) < 0.2) p.at = p.at < 0.5 ? 0.28 : 0.72;
69
+ const turn = { top: 0, right: 90, bottom: 180, left: 270 }[p.side];
70
+ let cut = turn ? rot(cutShape(p), turn, BOX.cx, BOX.cy) : cutShape(p);
71
+ if (p.second && p.second !== 'none') {
72
+ // half the size, on the opposite or the next side; off the first one's line when they would meet
73
+ const q = { ...p, size: p.size * 0.5 };
74
+ if (p.second === 'opposite' && Math.abs(q.at - 0.5) < 0.15) q.at = q.at < 0.5 ? q.at + 0.2 : q.at - 0.2;
75
+ let c2 = rot(cutShape(q), turn + (p.second === 'opposite' ? 180 : 90), BOX.cx, BOX.cy);
76
+ if (I(c2, cut).length) c2 = rot(cutShape(q), turn + 180, BOX.cx, BOX.cy); // two crossing cuts are a plus
77
+ if (!I(c2, cut).length) cut = U(cut, c2);
78
+ }
79
+ return tidy(D(body(p.body), cut));
80
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Dashes: two to five rows of dashes, the house gap between rows and between dashes, each row broken by ONE rhythm
3
+ * (long then short, short then long, even halves, a dash and a dot, one then two), the rows set flush left, centred,
4
+ * flush right or staggered, their lengths equal, falling or rising, the ends square or round. The breaks drift from row to
5
+ * row by default: short pieces lined up down one side read as a bulleted list (a UI icon). After Hematonix-style
6
+ * dash marks and speed lines.
7
+ */
8
+ import { U, rect, rr } from '@logomarks/core/geometry';
9
+ import { BOX, GAP } from '../draw.js';
10
+
11
+ /** @type {import('../index.js').Control[]} */
12
+ export const controls = [
13
+ { key: 'rows', label: 'Rows', type: 'range', min: 2, max: 5, step: 1, value: 3 },
14
+ { key: 'rhythm', label: 'Rhythm', type: 'choice', options: ['long-short', 'short-long', 'halves', 'dash-dot', 'one-two', 'alternate'], value: 'long-short' },
15
+ { key: 'align', label: 'Align', type: 'choice', options: ['left', 'centre', 'right', 'stagger'], value: 'left' },
16
+ { key: 'lengths', label: 'Lengths', type: 'choice', options: ['equal', 'falling', 'rising', 'middle'], value: 'equal' },
17
+ { key: 'weight', label: 'Weight', type: 'range', min: 0.22, max: 0.6, step: 0.01, value: 0.34 },
18
+ { key: 'split', label: 'Break at', type: 'range', min: 0.2, max: 0.5, step: 0.01, value: 0.3 },
19
+ { key: 'drift', label: 'Drift', type: 'range', min: -0.15, max: 0.15, step: 0.01, value: 0.1 },
20
+ { key: 'spacing', label: 'Dash gap', type: 'range', min: 1, max: 3, step: 0.1, value: 1.6 },
21
+ { key: 'ends', label: 'Ends', type: 'choice', options: ['square', 'round'], value: 'square' },
22
+ ];
23
+
24
+ /** A row's dashes as [from, to] shares of its length, for a rhythm, row k. */
25
+ function pieces(rhythm, k, split, gapShare) {
26
+ const g = gapShare, a = split;
27
+ if (rhythm === 'long-short') return [[0, 1 - a - g / 2], [1 - a + g / 2, 1]];
28
+ if (rhythm === 'halves') return [[0, 0.5 - g / 2], [0.5 + g / 2, 1]];
29
+ if (rhythm === 'dash-dot') return [[0, 1 - a * 0.6 - g], [1 - a * 0.6, 1]];
30
+ if (rhythm === 'one-two') return k % 2 ? [[0, 0.5 - g / 2], [0.5 + g / 2, 1]] : [[0, 1]];
31
+ if (rhythm === 'alternate') return k % 2 ? [[0, 1 - a - g / 2], [1 - a + g / 2, 1]] : [[0, a - g / 2], [a + g / 2, 1]];
32
+ return [[0, a - g / 2], [a + g / 2, 1]]; // short-long
33
+ }
34
+
35
+ /** How long row k of n is, as a share of the box, for a lengths setting. */
36
+ function lengthOf(lengths, k, n) {
37
+ const t = n === 1 ? 0 : k / (n - 1);
38
+ if (lengths === 'falling') return 1 - 0.4 * t;
39
+ if (lengths === 'rising') return 0.6 + 0.4 * t;
40
+ if (lengths === 'middle') return 1 - 0.4 * Math.abs(2 * t - 1);
41
+ return 1;
42
+ }
43
+
44
+ /** The mark for resolved params. */
45
+ export function build(p) {
46
+ const n = p.rows, pitch = (BOX.size + GAP) / n, h = Math.max(GAP * 1.2, Math.min(pitch - GAP, pitch * p.weight * 1.6, BOX.size * 0.2)), parts = [];
47
+ const used = n * h + (n - 1) * Math.max(GAP, pitch - h), top = BOX.cy - used / 2, step = h + Math.max(GAP, pitch - h);
48
+ for (let k = 0; k < n; k++) {
49
+ const L = BOX.size * lengthOf(p.lengths, k, n), y = top + k * step;
50
+ let x0 = p.align === 'right' ? BOX.x1 - L : p.align === 'centre' ? BOX.cx - L / 2 : BOX.x0;
51
+ if (p.align === 'stagger') x0 = k % 2 ? BOX.x1 - L * 0.88 : BOX.x0, x0 = Math.max(BOX.x0, x0);
52
+ const len = p.align === 'stagger' ? L * 0.88 : L, gapShare = (GAP * p.spacing) / len;
53
+ const split = Math.min(0.75, Math.max(0.12, p.split + p.drift * (k - (n - 1) / 2)));
54
+ for (const [a, b] of pieces(p.rhythm, k, split, gapShare)) {
55
+ const xa = x0 + a * len, w = (b - a) * len;
56
+ if (w < 2) continue;
57
+ parts.push(p.ends === 'round' ? rr(xa, y, w, h, Math.min(h, w) / 2) : rect(xa, y, w, h));
58
+ }
59
+ }
60
+ return U(...parts);
61
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Dots: a grid of dots (discs, squares or diamonds) whose size follows ONE rule: a gradient across, a radial swell from
3
+ * the centre, a ring, or a wave, the smallest left out, so a shape appears from the sizes alone. After halftone discs,
4
+ * dot gradients and dissolves.
5
+ */
6
+ import { U, circle, rect, poly } from '@logomarks/core/geometry';
7
+ import { BOX } from '../draw.js';
8
+
9
+ /** @type {import('../index.js').Control[]} */
10
+ export const controls = [
11
+ { key: 'grid', label: 'Grid', type: 'range', min: 4, max: 9, step: 1, value: 7 },
12
+ { key: 'dot', label: 'Dot', type: 'choice', options: ['circle', 'square', 'diamond'], value: 'circle' },
13
+ { key: 'rule', label: 'Rule', type: 'choice', options: ['gradient', 'radial', 'ring', 'wave', 'corner'], value: 'radial' },
14
+ { key: 'angle', label: 'Direction', type: 'range', min: 0, max: 315, step: 45, value: 0 },
15
+ { key: 'size', label: 'Biggest', type: 'range', min: 0.6, max: 1, step: 0.01, value: 0.92 },
16
+ { key: 'cutoff', label: 'Leave out under', type: 'range', min: 0.1, max: 0.5, step: 0.01, value: 0.28 },
17
+ { key: 'invert', label: 'Invert', type: 'toggle', value: false },
18
+ ];
19
+
20
+ /** How big the dot at u, v (−1 to 1 across the grid) is, 0–1, for a rule. */
21
+ function weight(rule, u, v, angle) {
22
+ const a = (angle * Math.PI) / 180, along = (u * Math.cos(a) + v * Math.sin(a) + 1.414) / 2.828, r = Math.hypot(u, v) / 1.414;
23
+ if (rule === 'gradient') return along;
24
+ if (rule === 'ring') return 1 - Math.min(1, Math.abs(r - 0.6) * 2.6);
25
+ if (rule === 'wave') return 0.5 + 0.5 * Math.sin((u * Math.cos(a) + v * Math.sin(a)) * Math.PI * 1.5);
26
+ if (rule === 'corner') return 1 - Math.hypot(u - Math.cos(a) * 1, v - Math.sin(a) * 1) / 2.6;
27
+ return 1 - r; // radial
28
+ }
29
+
30
+ /** The mark for resolved params. */
31
+ export function build(p) {
32
+ const n = p.grid, cell = BOX.size / n, parts = [];
33
+ for (let j = 0; j < n; j++) for (let i = 0; i < n; i++) {
34
+ const u = n === 1 ? 0 : (2 * i) / (n - 1) - 1, v = n === 1 ? 0 : (2 * j) / (n - 1) - 1;
35
+ let w = Math.max(0, Math.min(1, weight(p.rule, u, v, p.angle)));
36
+ if (p.invert) w = 1 - w;
37
+ if (w < p.cutoff) continue;
38
+ const s = cell * p.size * Math.sqrt(w);
39
+ if (s < 26) continue; // under about 1.8 px at 32 px: noise
40
+ const cx = BOX.x0 + (i + 0.5) * cell, cy = BOX.y0 + (j + 0.5) * cell;
41
+ parts.push(p.dot === 'square' ? rect(cx - s / 2, cy - s / 2, s, s) : p.dot === 'diamond' ? poly([[cx, cy - s * 0.6], [cx + s * 0.6, cy], [cx, cy + s * 0.6], [cx - s * 0.6, cy]]) : circle(cx, cy, s / 2, 40));
42
+ }
43
+ return parts.length ? U(...parts) : [];
44
+ }
45
+
46
+ /** Dots are many pieces by design; small ones are the point, so specks are judged by size alone. */
47
+ export const guard = { maxPieces: 81, minPieceShare: 0.002, minMeanWidth: 10, maxThinShare: 0.15 };
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Fan: three to nine blades (bars, wedges, pills or leaves) fanned out from a pivot at a corner, the middle of the foot
3
+ * or the centre, over a spread angle, the house gap between them at the narrow end so they open out, their lengths even,
4
+ * arched or long and short. Never rising: blades that grow across read as a signal-strength icon. After fanned-blade and sunrise marks.
5
+ * The default is a quarter fan of pills from a corner: wedges spread in a half circle from the foot read as a
6
+ * rising sun (too near the flag).
7
+ */
8
+ import { U, D, I, poly, circle, pill, rot, sector } from '@logomarks/core/geometry';
9
+ import { BOX, GAP, tidy } from '../draw.js';
10
+
11
+ /** @type {import('../index.js').Control[]} */
12
+ export const controls = [
13
+ { key: 'blades', label: 'Blades', type: 'range', min: 3, max: 9, step: 1, value: 4 },
14
+ { key: 'blade', label: 'Blade', type: 'choice', options: ['wedge', 'bar', 'pill', 'leaf'], value: 'pill' },
15
+ { key: 'pivot', label: 'Pivot', type: 'choice', options: ['corner', 'foot', 'centre'], value: 'corner' },
16
+ { key: 'spread', label: 'Spread', type: 'range', min: 60, max: 240, step: 5, value: 90 },
17
+ { key: 'inner', label: 'Open centre', type: 'range', min: 0, max: 0.45, step: 0.01, value: 0.18 },
18
+ { key: 'lengths', label: 'Lengths', type: 'choice', options: ['even', 'arch', 'alternate'], value: 'even' },
19
+ { key: 'spacing', label: 'Gap', type: 'range', min: 1, max: 2.5, step: 0.1, value: 1.2 },
20
+ ];
21
+
22
+ /** The pivot point, the reach of the longest blade, and the middle angle (degrees, 0 = right, −90 = up). */
23
+ function frame(pivot, spread) {
24
+ const { x0, y1, cx, cy, size } = BOX;
25
+ if (pivot === 'corner') return { px: x0, py: y1, R: size, mid: -45, spread: Math.min(spread, 90) };
26
+ if (pivot === 'centre') return { px: cx, py: cy + (spread <= 180 ? size * 0.22 : 0), R: spread <= 180 ? size * 0.72 : size / 2, mid: -90, spread };
27
+ return { px: cx, py: y1, R: size * (spread > 180 ? 0.5 : 0.92), mid: -90, spread: Math.min(spread, 180) };
28
+ }
29
+
30
+ /** How long blade k of n is, a share of the reach. */
31
+ function lengthOf(lengths, k, n) {
32
+ const t = n === 1 ? 0 : k / (n - 1);
33
+ if (lengths === 'arch') return 1 - 0.4 * Math.abs(2 * t - 1);
34
+ if (lengths === 'alternate') return k % 2 ? 0.72 : 1;
35
+ return 1;
36
+ }
37
+
38
+ /** One blade along angle 0 (pointing right) from r0 to r1, `w` its angular width in degrees at its outer end. */
39
+ function blade(kind, px, py, r0, r1, a0, a1) {
40
+ const mid = (a0 + a1) / 2, half = (((a1 - a0) / 2) * Math.PI) / 180, wOut = 2 * r1 * Math.sin(half);
41
+ const along = (r) => { const t = (mid * Math.PI) / 180; return [px + r * Math.cos(t), py + r * Math.sin(t)]; };
42
+ if (kind === 'bar') { const w = Math.max(GAP * 1.4, 2 * ((r0 + r1) / 2) * Math.sin(half) * 0.9); const [ax, ay] = along(r0), [bx, by] = along(r1); return rot(poly([[ax, ay - w / 2], [ax + (r1 - r0), ay - w / 2], [ax + (r1 - r0), ay + w / 2], [ax, ay + w / 2]]), mid, ax, ay); }
43
+ if (kind === 'pill') { const w = Math.max(GAP * 1.4, 2 * ((r0 + r1) / 2) * Math.sin(half) * 0.9); return pill(along(r0 + w / 2), along(r1 - w / 2), w); }
44
+ if (kind === 'leaf') {
45
+ const [ax, ay] = along(r0), [bx, by] = along(r1), L = Math.hypot(bx - ax, by - ay), w = Math.min(wOut * 0.9, L * 0.45);
46
+ if (w < GAP || L < GAP * 2) return D(sector(px, py, r1, a0, a1, 48), circle(px, py, r0, 96)); // too short for a leaf
47
+ const R = (L * L / 4 + w * w / 4) / w; // the arc through both tips and the leaf's widest point
48
+ const mx = (ax + bx) / 2, my = (ay + by) / 2, nx = -(by - ay) / L, ny = (bx - ax) / L, off = R - w / 2;
49
+ return I(circle(mx + nx * off, my + ny * off, R, 160), circle(mx - nx * off, my - ny * off, R, 160));
50
+ }
51
+ return D(sector(px, py, r1, a0, a1, 48), circle(px, py, r0, 96)); // wedge
52
+ }
53
+
54
+ /** The mark for resolved params. */
55
+ export function build(p) {
56
+ const f = frame(p.pivot, p.spread), g = GAP * p.spacing, spreadRad = (f.spread * Math.PI) / 180;
57
+ const n = Math.max(3, Math.min(p.blades, Math.floor(f.spread / 22))); // about one blade per 22° at most: crowded blades go to needles
58
+ // the blades start far enough out that their gaps take at most 40% of the arc there and every blade's inner end is at
59
+ // least 1.2 gaps wide (a wedge tapering to a needle is a thin part at 32 px)
60
+ const r0 = Math.min(f.R * 0.62, Math.max(p.inner * f.R, GAP * 2, ((n - 1) * g) / (0.4 * spreadRad), (1.2 * GAP * n) / (0.6 * spreadRad)));
61
+ const gapDeg = (g / r0) * (180 / Math.PI);
62
+ const each = (f.spread - (n - 1) * gapDeg) / n;
63
+ if (each <= 1) return [];
64
+ const parts = [];
65
+ for (let k = 0; k < n; k++) {
66
+ const a0 = f.mid - f.spread / 2 + k * (each + gapDeg), a1 = a0 + each;
67
+ parts.push(blade(p.blade, f.px, f.py, r0, f.R * lengthOf(p.lengths, k, n), a0, a1));
68
+ }
69
+ return tidy(U(...parts));
70
+ }
71
+
72
+ /** Wedges and leaves end in points by design: a little more of the ink may be thin. */
73
+ export const guard = { maxThinShare: 0.07 };
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Fold: ONE heavy band zigzagging two to five times. As a crease (sharp mitred turns), round (rounded turns), notched
3
+ * (each run its own piece, the house gap at every turn, as if the band were cut at its folds) or a ribbon (the band run
4
+ * across and back, row under row, a 45° fold line slit through it at every turn). Level
5
+ * or upright. After folded-ribbon and zigzag-band marks.
6
+ */
7
+ import { U, D, rect, stroke, grown, rot } from '@logomarks/core/geometry';
8
+ import { BOX, GAP, tidy } from '../draw.js';
9
+
10
+ /** @type {import('../index.js').Control[]} */
11
+ export const controls = [
12
+ { key: 'folds', label: 'Folds', type: 'range', min: 2, max: 5, step: 1, value: 3 },
13
+ { key: 'style', label: 'Style', type: 'choice', options: ['ribbon', 'crease', 'round', 'notch'], value: 'ribbon' },
14
+ { key: 'weight', label: 'Weight', type: 'range', min: 0.1, max: 0.26, step: 0.005, value: 0.17 },
15
+ { key: 'depth', label: 'Depth', type: 'range', min: 0.3, max: 1, step: 0.01, value: 0.7 },
16
+ { key: 'upright', label: 'Upright', type: 'toggle', value: false },
17
+ ];
18
+
19
+ /** A zigzag's turning points: `folds` + 1 runs across the box, rising and falling by `depth` of the box. */
20
+ function zigzag(folds, depth, w) {
21
+ const n = folds + 1, { x0, size, cy } = BOX, a = ((size - w) * depth) / 2;
22
+ return Array.from({ length: n + 1 }, (_, k) => [x0 + w / 2 + ((size - w) * k) / n, cy + (k % 2 ? -a : a)]);
23
+ }
24
+
25
+ /**
26
+ * A ribbon folded flat: the band runs across the box and back, row under row, and at every turn a fold line, a slit the
27
+ * gap wide on the 45° from the turn's inner corner to its outer one, so it reads as one strip creased.
28
+ */
29
+ function ribbon(folds, w) {
30
+ const rows = folds + 1, { x0, x1, y0, size } = BOX, gap = Math.max(GAP, (size - rows * w) / Math.max(1, rows - 1));
31
+ const pitch = w + gap, xa = x0 + w / 2, xb = x1 - w / 2, pts = [], slits = [];
32
+ for (let k = 0; k < rows; k++) {
33
+ const y = y0 + w / 2 + k * pitch, right = k % 2 === 0;
34
+ pts.push(right ? [xa, y] : [xb, y], right ? [xb, y] : [xa, y]);
35
+ }
36
+ const band = stroke(pts, w);
37
+ // the fold lines: at each corner of the run, from its inner corner to its outer one
38
+ for (let i = 1; i < pts.length - 1; i++) {
39
+ const [x, y] = pts[i], [px, py] = pts[i - 1], [nx, ny] = pts[i + 1];
40
+ const din = [Math.sign(px - x) + Math.sign(nx - x), Math.sign(py - y) + Math.sign(ny - y)]; // towards the inner corner
41
+ const len = w * 1.6, ang = (Math.atan2(din[1], din[0]) * 180) / Math.PI;
42
+ slits.push(rot(rect(x - len / 2, y - (GAP * 0.9) / 2, len, GAP * 0.9), ang, x, y));
43
+ }
44
+ return D(band, U(...slits));
45
+ }
46
+
47
+ /** The mark for resolved params. */
48
+ export function build(p) {
49
+ const w = p.weight * BOX.size;
50
+ let s;
51
+ if (p.style === 'ribbon') s = ribbon(p.folds, w);
52
+ else {
53
+ const pts = zigzag(p.folds, p.depth, w);
54
+ if (p.style === 'notch') {
55
+ // each run its own bar, the later ones cleared from the earlier by the gap at the turns
56
+ let acc = null;
57
+ for (let k = 0; k < pts.length - 1; k++) {
58
+ const bar = stroke([pts[k], pts[k + 1]], w);
59
+ acc = acc ? U(acc, D(bar, grown(acc, GAP))) : bar;
60
+ }
61
+ s = acc;
62
+ } else s = stroke(pts, w, { roundCaps: p.style === 'round' });
63
+ if (p.style === 'round') s = U(s, ...pts.slice(1, -1).map(([x, y]) => rect(x - 0.5, y - 0.5, 1, 1)));
64
+ }
65
+ return tidy(p.upright ? rot(s, 90, BOX.cx, BOX.cy) : s);
66
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Hex: a honeycomb of hexagon cells, a small cluster chosen by a numbered layout and made symmetric if asked (a mirror
3
+ * or a half turn, never a six-fold star), the cells parted by the house gap, some drawn as dots. No hexagonal rings:
4
+ * a hexagon with a hole is a nut. After hex
5
+ * cluster and honeycomb marks.
6
+ */
7
+ import { U, poly, circle } from '@logomarks/core/geometry';
8
+ import { BOX, GAP } from '../draw.js';
9
+ import { rng } from '../random.js';
10
+
11
+ /** @type {import('../index.js').Control[]} */
12
+ export const controls = [
13
+ { key: 'rings', label: 'Size', type: 'range', min: 1, max: 2, step: 1, value: 1 },
14
+ { key: 'layout', label: 'Layout no.', type: 'range', min: 1, max: 999, step: 1, value: 5 },
15
+ { key: 'density', label: 'Density', type: 'range', min: 0.35, max: 0.9, step: 0.01, value: 0.6 },
16
+ { key: 'symmetry', label: 'Symmetry', type: 'choice', options: ['mirror', 'turn', 'none'], value: 'mirror' },
17
+ { key: 'cell', label: 'Cells', type: 'choice', options: ['solid', 'mixed'], value: 'solid' },
18
+ { key: 'point', label: 'Point', type: 'choice', options: ['up', 'side'], value: 'up' },
19
+ { key: 'gap', label: 'Gap', type: 'range', min: 1, max: 2, step: 0.1, value: 1 },
20
+ ];
21
+
22
+ /** The axial coordinates of a hexagonal patch of radius `r` (1: seven cells, 2: nineteen). */
23
+ function patch(r) {
24
+ const out = [];
25
+ for (let q = -r; q <= r; q++) for (let s = Math.max(-r, -q - r); s <= Math.min(r, -q + r); s++) out.push([q, s]);
26
+ return out;
27
+ }
28
+
29
+ /** A hexagon round (x, y), radius R to its corners, pointing up or to the side. */
30
+ const hexagon = (x, y, R, up) => poly(Array.from({ length: 6 }, (_, k) => { const a = ((60 * k + (up ? -90 : 0)) * Math.PI) / 180; return [x + R * Math.cos(a), y + R * Math.sin(a)]; }));
31
+
32
+ /** The mark for resolved params. */
33
+ export function build(p) {
34
+ const r = p.rings, cells = patch(r), rand = rng(`hex:${p.layout}:${r}`), up = p.point === 'up';
35
+ const key = (q, s) => `${q},${s}`, on = new Map();
36
+ // the layout: each cell on or off, then made symmetric; the centre cell decides itself
37
+ for (const [q, s] of cells) on.set(key(q, s), rand() < p.density ? (p.cell === 'solid' ? 'solid' : rand() < 0.7 ? 'solid' : 'dot') : null);
38
+ for (const [q, s] of cells) {
39
+ if (p.symmetry === 'mirror') { const m = key(-q - s, s); if (cells.some(([a, b]) => key(a, b) === m) && (q > -q - s)) on.set(key(q, s), on.get(m)); }
40
+ if (p.symmetry === 'turn') { const m = key(-q, -s); if (q > 0 || (q === 0 && s > 0)) on.set(key(q, s), on.get(m)); }
41
+ }
42
+ // the cell size: the patch spans 2r + 1 cells across, fitted to the box
43
+ const pitch = BOX.size / (2 * r + 1), R = pitch / Math.sqrt(3), g = GAP * p.gap, Rc = R - g / Math.sqrt(3);
44
+ const parts = [];
45
+ for (const [q, s] of cells) {
46
+ const kind = on.get(key(q, s));
47
+ if (!kind) continue;
48
+ let x = BOX.cx + pitch * (q + s / 2), y = BOX.cy + pitch * (Math.sqrt(3) / 2) * s;
49
+ if (!up) [x, y] = [BOX.cx + (y - BOX.cy), BOX.cy + (x - BOX.cx)];
50
+ const h = hexagon(x, y, Rc, up);
51
+ if (kind === 'dot') parts.push(circle(x, y, Rc * 0.55, 48));
52
+ else parts.push(h);
53
+ }
54
+ return parts.length ? U(...parts) : [];
55
+ }
56
+
57
+ /** Nineteen cells are many pieces. */
58
+ export const guard = { maxPieces: 30, maxThinShare: 0.06 };
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Horizon: a sun (a half disc on the horizon, or a whole one) over two to six horizon lines that thin and close up
3
+ * toward the foot, the sun cut by stripes across its lower part (a striped sun), plain, or drawn as a ring. No rays: a
4
+ * rayed sun over lines is the sunrise weather icon. After striped suns and sunset marks.
5
+ */
6
+ import { U, D, rect, circle, sector, pill } from '@logomarks/core/geometry';
7
+ import { BOX, GAP, tidy } from '../draw.js';
8
+
9
+ /** @type {import('../index.js').Control[]} */
10
+ export const controls = [
11
+ { key: 'sun', label: 'Sun', type: 'choice', options: ['half', 'full'], value: 'half' },
12
+ { key: 'size', label: 'Sun size', type: 'range', min: 0.5, max: 0.9, step: 0.01, value: 0.72 },
13
+ { key: 'lines', label: 'Lines', type: 'range', min: 2, max: 6, step: 1, value: 3 },
14
+ { key: 'style', label: 'Sun style', type: 'choice', options: ['striped', 'plain', 'ring'], value: 'striped' },
15
+ { key: 'stripes', label: 'Sun stripes', type: 'range', min: 2, max: 5, step: 1, value: 3 },
16
+ { key: 'span', label: 'Line length', type: 'choice', options: ['full', 'narrowing', 'widening'], value: 'narrowing' },
17
+ { key: 'ends', label: 'Ends', type: 'choice', options: ['square', 'round'], value: 'round' },
18
+ ];
19
+
20
+ /** The mark for resolved params. */
21
+ export function build(p) {
22
+ const { cx, size } = BOX, R = (p.size * size) / 2, parts = [];
23
+ const n = p.lines, lineBlock = size * 0.32, t0 = Math.max(GAP * 1.3, lineBlock / (n * 1.6));
24
+ // the horizon sits so the sun and the lines fill the box together
25
+ const sunH = p.sun === 'half' ? R : 2 * R, top = BOX.y0 + Math.max(0, (size - sunH - lineBlock - GAP) / 2);
26
+ const hy = top + sunH;
27
+ let sun = p.sun === 'half' ? sector(cx, hy, R, 180, 360, 128) : circle(cx, hy - R, R, 128);
28
+ if (p.style === 'striped') {
29
+ // gaps across the lower part, each strip under it at least twice the gap; as many as fit
30
+ const span = sunH * (p.sun === 'half' ? 0.75 : 0.6), k = Math.max(1, Math.min(p.stripes, Math.floor(span / (GAP * 2.6))));
31
+ const pitch = span / k;
32
+ for (let i = 0; i < k; i++) {
33
+ const g = GAP * (1.25 - (i / k) * 0.3), y = hy - i * pitch - pitch * 0.5;
34
+ sun = D(sun, rect(cx - R - 5, y - g / 2, 2 * R + 10, g));
35
+ }
36
+ }
37
+ if (p.style === 'ring') {
38
+ const t = Math.max(GAP * 1.4, R * 0.28);
39
+ sun = p.sun === 'half' ? D(sun, sector(cx, hy + 1, R - t, 180, 360, 128)) : D(sun, circle(cx, hy - R, R - t, 128));
40
+ }
41
+ parts.push(sun);
42
+ let y = hy + GAP;
43
+ for (let i = 0; i < n; i++) {
44
+ const t = Math.max(GAP * 1.05, t0 * (1 - (i / n) * 0.45));
45
+ const frac = p.span === 'narrowing' ? 1 - (i / n) * 0.55 : p.span === 'widening' ? 0.45 + (i / n) * 0.55 : 1;
46
+ const half = (size / 2) * frac, a = [cx - half + t / 2, y + t / 2], b = [cx + half - t / 2, y + t / 2];
47
+ parts.push(p.ends === 'round' ? pill(a, b, t) : rect(cx - half, y, 2 * half, t));
48
+ y += t + GAP * (1 - (i / n) * 0.35);
49
+ }
50
+ return tidy(U(...parts));
51
+ }