@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,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,39 @@
1
+ /**
2
+ * Flare: heavy rays that widen as they run out, parted by gap-wide lines, spreading from a corner of a block or from
3
+ * the foot of one (all round a centre is Burst's). The rays stop short of where they meet, so no ray ends in a needle.
4
+ */
5
+ import { U, D, I, rect, circle, bar, regular, polar } 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: 'origin', label: 'From', type: 'choice', options: ['corner', 'foot'], value: 'corner' },
11
+ { key: 'rays', label: 'Rays', type: 'range', min: 3, max: 5, step: 1, value: 4 },
12
+ { key: 'body', label: 'Body', type: 'choice', options: ['square', 'round'], value: 'square' },
13
+ { key: 'inner', label: 'Open centre', type: 'range', min: 0.12, max: 0.4, step: 0.01, value: 0.24 },
14
+ { key: 'spacing', label: 'Gap', type: 'range', min: 1, max: 2.4, step: 0.1, value: 1.4 },
15
+ { key: 'spin', label: 'Spin', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
16
+ ];
17
+
18
+ import { rot } from '@logomarks/core/geometry';
19
+
20
+ /** The mark for resolved params. */
21
+ export function build(p) {
22
+ const { cx, cy, x0, y0, y1, size } = BOX, g = GAP * p.spacing, R = size / 2;
23
+ // where the rays spring from, the angles they span, and how many (a corner or a foot holds fewer)
24
+ const O = p.origin === 'corner' ? [x0, y1] : p.origin === 'foot' ? [cx, y1] : [cx, cy];
25
+ const [a0, a1] = p.origin === 'corner' ? [270, 360] : p.origin === 'foot' ? [198, 342] : [0, 360];
26
+ const n = p.origin === 'centre' ? Math.max(5, p.rays) : Math.min(p.rays, p.origin === 'corner' ? 5 : 5);
27
+ let body = p.body === 'round' ? (p.origin === 'corner' ? circle(x0, y1, size, 160) : p.origin === 'foot' ? circle(cx, y1, size * 0.92, 160) : circle(cx, cy, R, 128)) : p.body === 'hexagon' && p.origin === 'centre' ? regular(cx, cy, R * 1.06, 6, 0) : rect(x0, y0, size, size);
28
+ if (p.origin !== 'centre') body = I(body, rect(x0, y0, size, size));
29
+ // the parting lines: between rays, and along both edges of a foot's fan
30
+ const cuts = [], step = (a1 - a0) / n, far = size * 1.6;
31
+ const first = p.origin === 'centre' ? 0 : p.origin === 'corner' ? 1 : 0, lastK = p.origin === 'centre' ? n - 1 : p.origin === 'corner' ? n - 1 : n;
32
+ for (let k = first; k <= lastK; k++) cuts.push(bar(O, polar(far, a0 + k * step + (p.origin === 'centre' ? step / 2 - 90 : 0), ...O), g));
33
+ let s = D(body, U(...cuts));
34
+ if (p.origin === 'foot') s = I(s, U(...Array.from({ length: n }, (_, k) => [O, polar(far, a0 + k * step, ...O), polar(far, a0 + (k + 1) * step, ...O)]).map((t) => [t])));
35
+ // the rays stop at an open centre wide enough that each is at least a gap across where it starts
36
+ const open = Math.max(p.inner * size * (p.origin === 'centre' ? 0.5 : 1), (g * 1.9) / (2 * Math.sin(((step / 2) * Math.PI) / 180)));
37
+ s = D(s, circle(O[0], O[1], open, 96));
38
+ return tidy(rot(s, Number(p.spin), cx, cy));
39
+ }
@@ -0,0 +1,53 @@
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.
4
+ */
5
+ import { U, rect, poly } from '@logomarks/core/geometry';
6
+ import { BOX, GAP, tidy } from '../draw.js';
7
+ import { rng } from '../random.js';
8
+
9
+ /** @type {import('../index.js').Control[]} */
10
+ 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 },
16
+ ];
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]]);
23
+ }
24
+
25
+ /** The mark for resolved params. */
26
+ 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
+ }
46
+ 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));
51
+ }
52
+ return parts.length ? tidy(U(...parts)) : [];
53
+ }
@@ -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
+ }
@@ -0,0 +1,95 @@
1
+ /**
2
+ * The recipes, by id, in the order a picker lists them. Every recipe also takes the shared finish controls (FINISH).
3
+ */
4
+ import * as bars from './bars.js';
5
+ import * as bands from './bands.js';
6
+ import * as twin from './twin.js';
7
+ import * as stack from './stack.js';
8
+ import * as shear from './shear.js';
9
+ import * as turns from './turns.js';
10
+ import * as burst from './burst.js';
11
+ import * as tiles from './tiles.js';
12
+ import * as route from './route.js';
13
+ import * as arcs from './arcs.js';
14
+ import * as rings from './rings.js';
15
+ import * as stripes from './stripes.js';
16
+ import * as chevrons from './chevrons.js';
17
+ import * as waves from './waves.js';
18
+ import * as cut from './cut.js';
19
+ import * as split from './split.js';
20
+ import * as venn from './venn.js';
21
+ import * as spiral from './spiral.js';
22
+ import * as bloom from './bloom.js';
23
+ import * as links from './links.js';
24
+ import * as horizon from './horizon.js';
25
+ import * as steps from './steps.js';
26
+ import * as hex from './hex.js';
27
+ import * as iso from './iso.js';
28
+ import * as letter from './letter.js';
29
+ import * as arcstep from './arcstep.js';
30
+ import * as halfsq from './halfsq.js';
31
+ import * as invert from './invert.js';
32
+ import * as leaves from './leaves.js';
33
+ import * as lobes from './lobes.js';
34
+ import * as loops from './loops.js';
35
+ import * as trine from './trine.js';
36
+ import * as strips from './strips.js';
37
+ import * as bite from './bite.js';
38
+ import * as blades from './blades.js';
39
+ import * as wavecut from './wavecut.js';
40
+ import * as capsules from './capsules.js';
41
+ import * as flare from './flare.js';
42
+ import * as seam from './seam.js';
43
+ import * as pixelarc from './pixelarc.js';
44
+ import { FINISH, finish } from '../finish.js';
45
+ import { TUNING } from '../tuning.js';
46
+
47
+ /** A recipe's controls with its tuning laid over them (the default, and what a shuffle draws: `random`, `rare`). */
48
+ const tuned = (id, controls) => controls.map((c) => (TUNING[id]?.[c.key] ? { ...c, ...TUNING[id][c.key] } : c));
49
+
50
+ /** A recipe with its tuning, and the finish controls appended and applied. */
51
+ const R = (id, name, line, m) => ({ id, name, line, controls: [...tuned(id, m.controls), ...FINISH], build: (p) => finish(m.build(p), p), guard: m.guard || {} });
52
+
53
+ /** Every recipe: its id, name, one line and controls, and its `build(params)`. */
54
+ export const RECIPES = {
55
+ bars: R('bars', 'Bars', 'Upright bars with one cut, step or slant.', bars),
56
+ bands: R('bands', 'Bands', 'Stacked bands that climb through one bend.', bands),
57
+ twin: R('twin', 'Twin', 'One piece and its twin, turned halfway round.', twin),
58
+ stack: R('stack', 'Stack', 'Two to four simple shapes stacked, overlapped or nested.', stack),
59
+ shear: R('shear', 'Shear', 'A grid of slanted tiles, some left out.', shear),
60
+ turns: R('turns', 'Turns', 'One shape turned round a centre three to eight times.', turns),
61
+ burst: R('burst', 'Burst', 'Rays round a centre, with one move.', burst),
62
+ tiles: R('tiles', 'Tiles', 'A grid of squares, quarter rounds and discs.', tiles),
63
+ route: R('route', 'Route', 'Heavy bands at 0, 45 and 90° that fork and turn.', route),
64
+ arcs: R('arcs', 'Arcs', 'Nested quarter or half rings from a corner.', arcs),
65
+ rings: R('rings', 'Rings', 'Concentric rings broken by turning gaps.', rings),
66
+ stripes: R('stripes', 'Stripes', 'A shape drawn in stripes, with one move.', stripes),
67
+ chevrons: R('chevrons', 'Chevrons', 'Chevrons stacked along their point.', chevrons),
68
+ waves: R('waves', 'Waves', 'Wavy bands, in step or turning.', waves),
69
+ cut: R('cut', 'Cut', 'One solid with one cut: a bite, notch, slot or step.', cut),
70
+ 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
+ spiral: R('spiral', 'Spiral', 'One round band coiled, with a dot or a tail.', spiral),
73
+ bloom: R('bloom', 'Bloom', 'Petals round an open or dotted centre.', bloom),
74
+ links: R('links', 'Links', 'Two or three loops woven like a chain.', links),
75
+ horizon: R('horizon', 'Horizon', 'A striped sun over horizon lines.', horizon),
76
+ steps: R('steps', 'Steps', 'A staircase or ziggurat of blocks.', steps),
77
+ hex: R('hex', 'Hex', 'A honeycomb cluster of hexagon cells.', hex),
78
+ iso: R('iso', 'Iso', 'Isometric cubes stacked from a height map.', iso),
79
+ letter: R('letter', 'Letter', 'One capital or numeral in blocks, tiles, pixels, stencil, slabs or route.', letter),
80
+ 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),
82
+ invert: R('invert', 'Inverted', 'Rings with ink and ground swapped across one region.', invert),
83
+ 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),
85
+ 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),
87
+ strips: R('strips', 'Strips', 'Straight strips of tape laid over one another.', strips),
88
+ bite: R('bite', 'Bite Link', 'A soft block with round bites taken from its sides.', bite),
89
+ blades: R('blades', 'Blades', 'Curved blades side by side, each taller than the last.', blades),
90
+ wavecut: R('wavecut', 'Squiggle', 'A solid cut or worn by one wavy line.', wavecut),
91
+ capsules: R('capsules', 'Capsule', 'Slanted capsules stacked, their lengths set by one rule.', capsules),
92
+ 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),
94
+ seam: R('seam', 'Seam', 'A block parted in two by one seam with a joint in it.', seam),
95
+ };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Inverted Rings: concentric rings, with ink and ground swapped inside one region: a half, a band through the middle, a
3
+ * quarter or a disc set off centre. One move; the rings do the rest.
4
+ */
5
+ import { U, D, I, X, rect, circle, rot, regular, rr } 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: 'count', label: 'Rings', type: 'range', min: 1, max: 4, step: 1, value: 2 },
11
+ { key: 'weight', label: 'Weight', type: 'range', min: 0.4, max: 0.7, step: 0.01, value: 0.55 },
12
+ { key: 'region', label: 'Swapped', type: 'choice', options: ['half', 'band', 'quarter', 'disc'], value: 'half' },
13
+ { key: 'angle', label: 'Angle', type: 'choice', options: ['0', '45', '90', '135'], value: '0' },
14
+ { key: 'size', label: 'Region size', type: 'range', min: 0.25, max: 0.6, step: 0.01, value: 0.4 },
15
+ { key: 'shape', label: 'Shape', type: 'choice', options: ['circle', 'rounded', 'hexagon'], value: 'circle' },
16
+ ];
17
+
18
+ /** The outline at radius r. */
19
+ function outline(shape, r) {
20
+ const { cx, cy } = BOX;
21
+ if (shape === 'rounded') return rr(cx - r, cy - r, 2 * r, 2 * r, r * 0.42);
22
+ if (shape === 'hexagon') return regular(cx, cy, r * 1.08, 6, 0);
23
+ return circle(cx, cy, r, 128);
24
+ }
25
+
26
+ /** The mark for resolved params. */
27
+ export function build(p) {
28
+ const { cx, cy, size } = BOX, R = size / 2, n = p.count;
29
+ // n rings round an open centre: 2n + 1 steps of ink and ground, the ink `weight` of each pair
30
+ const pair = R / (n + 0.5), t = Math.max(GAP * 1.4, pair * p.weight), parts = [];
31
+ for (let k = 0; k < n; k++) { const ro = R - k * pair; parts.push(D(outline(p.shape, ro), outline(p.shape, ro - t))); }
32
+ const rings = U(...parts), whole = outline(p.shape, R);
33
+ let region;
34
+ if (p.region === 'half') region = rect(cx, cy - size, size, 2 * size);
35
+ else if (p.region === 'band') region = rect(cx - (p.size * size) / 2, cy - size, p.size * size, 2 * size);
36
+ else if (p.region === 'quarter') region = rect(cx, cy - size, size, size);
37
+ else region = circle(cx + R * 0.45, cy, p.size * size * 0.62, 96);
38
+ region = I(rot(region, Number(p.angle), cx, cy), whole);
39
+ return tidy(X(rings, region), { share: 0.004, width: 9 });
40
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Iso: isometric cubes stacked on a small height map (two to four cells a side, heights up to three) chosen by a
3
+ * numbered layout and made symmetric if asked, every face parted from its neighbours by the house gap. After iso
4
+ * cube and stacked-block marks.
5
+ */
6
+ import { cubes } from '@logomarks/core/geometry';
7
+ import { BOX, tidy } from '../draw.js';
8
+ import { rng } from '../random.js';
9
+
10
+ /** @type {import('../index.js').Control[]} */
11
+ export const controls = [
12
+ { key: 'grid', label: 'Grid', type: 'range', min: 2, max: 4, step: 1, value: 3 },
13
+ { key: 'layout', label: 'Layout no.', type: 'range', min: 1, max: 999, step: 1, value: 9 },
14
+ { key: 'height', label: 'Tallest', type: 'range', min: 1, max: 3, step: 1, value: 2 },
15
+ { key: 'density', label: 'Density', type: 'range', min: 0.3, max: 1, step: 0.01, value: 0.7 },
16
+ { key: 'symmetry', label: 'Symmetry', type: 'choice', options: ['mirror', 'none', 'stairs'], value: 'mirror' },
17
+ ];
18
+
19
+ /** The mark for resolved params. */
20
+ export function build(p) {
21
+ const n = p.grid, rand = rng(`iso:${p.layout}:${n}`), H = [];
22
+ for (let i = 0; i < n; i++) { H.push([]); for (let j = 0; j < n; j++) H[i].push(rand() < p.density ? 1 + Math.floor(rand() * p.height) : 0); }
23
+ if (p.symmetry === 'mirror') for (let i = 0; i < n; i++) for (let j = 0; j < n; j++) if (j > i) H[i][j] = H[j][i];
24
+ if (p.symmetry === 'stairs') for (let i = 0; i < n; i++) for (let j = 0; j < n; j++) H[i][j] = Math.max(0, Math.min(p.height, Math.round(((n - 1 - i + n - 1 - j) / (2 * (n - 1))) * p.height + 0.4)));
25
+ const list = [];
26
+ for (let i = 0; i < n; i++) for (let j = 0; j < n; j++) for (let z = 0; z < H[i][j]; z++) list.push([i - (n - 1) / 2, j - (n - 1) / 2, z]);
27
+ if (!list.length) return [];
28
+ // the cube edge: the stack fills the box (its iso width is about 2 × 0.866 × n cubes)
29
+ const u = BOX.size / (Math.sqrt(3) * n + 0.4);
30
+ // faces hidden down to slivers behind a nearer cube are dropped
31
+ return tidy(cubes(list, u, 0, -((p.height - 1) * u) / 2.4), { share: 0.002, width: 12 });
32
+ }
33
+
34
+ /** Many cubes, three faces each. */
35
+ export const guard = { maxPieces: 120, minPieceShare: 0.002, minMeanWidth: 10, minInkShare: 0.1, maxThinShare: 0.12 }; // faces meet at 60°
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Leaf Tiles: one soft tile (a leaf, a quarter round, an arch or a disc) set in each cell of a small grid and turned from
3
+ * cell to cell, the house gap between them: four leaves that read as a clover, a pinwheel or a knot.
4
+ */
5
+ import { U, rr, circle, rot } from '@logomarks/core/geometry';
6
+ import { BOX, GAP } from '../draw.js';
7
+
8
+ /** @type {import('../index.js').Control[]} */
9
+ export const controls = [
10
+ { key: 'tile', label: 'Tile', type: 'choice', options: ['leaf', 'quarter', 'arch', 'drop'], value: 'leaf' },
11
+ { key: 'order', label: 'Turned', type: 'choice', options: ['pinwheel', 'outward', 'inward', 'rows', 'same'], value: 'outward' },
12
+ { key: 'facing', label: 'Facing', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
13
+ { key: 'softness', label: 'Roundness', type: 'range', min: 0.5, max: 1, step: 0.01, value: 1 },
14
+ { key: 'spacing', label: 'Gap', type: 'range', min: 0.6, max: 2, step: 0.1, value: 1 },
15
+ { key: 'centre', label: 'Centre', type: 'choice', options: ['none', 'disc'], value: 'none' },
16
+ ];
17
+
18
+ /** A tile in the cell (x, y, s), unturned: its square corner(s) at the top left. */
19
+ function tile(kind, x, y, s, k) {
20
+ const r = (s * k) / (kind === 'arch' ? 2 : 1), q = Math.min(r, s / 2);
21
+ // corners: top left, top right, bottom right, bottom left
22
+ if (kind === 'leaf') return rr(x, y, s, s, [0, Math.min(r, s), 0, Math.min(r, s)].map((v) => Math.min(v, s * 0.999)));
23
+ if (kind === 'quarter') return rr(x, y, s, s, [0, 0, Math.min(r, s * 0.999), 0]);
24
+ if (kind === 'arch') return rr(x, y, s, s, [0, 0, q, q]);
25
+ return rr(x, y, s, s, [0, q, q, q]);
26
+ }
27
+
28
+ /** The mark for resolved params. */
29
+ export function build(p) {
30
+ const g = GAP * p.spacing, s = (BOX.size - g) / 2, parts = [];
31
+ // each cell's turn: the square corner to the middle (outward leaves), away from it, round in a pinwheel, by rows
32
+ const base = { outward: [180, 270, 0, 90], inward: [0, 90, 180, 270], pinwheel: [0, 90, 180, 270].map((a) => a + 90), rows: [0, 0, 180, 180], same: [0, 0, 0, 0] }[p.order];
33
+ const cells = [[0, 0], [1, 0], [1, 1], [0, 1]];
34
+ cells.forEach(([c, r], i) => {
35
+ const x = BOX.x0 + c * (s + g), y = BOX.y0 + r * (s + g);
36
+ parts.push(rot(tile(p.tile, x, y, s, p.softness), base[i] + Number(p.facing), x + s / 2, y + s / 2));
37
+ });
38
+ let out = U(...parts);
39
+ if (p.centre === 'disc') { const d = circle(BOX.cx, BOX.cy, s * 0.3, 96); out = U(mapClear(out, d, g), d); }
40
+ return out;
41
+ }
42
+
43
+ import { D, grown } from '@logomarks/core/geometry';
44
+ /** `a` kept the gap away from `b`. */
45
+ const mapClear = (a, b, g) => D(a, grown(b, g));