@logomarks/generate 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/package.json +1 -1
- package/src/recipes/overlap.js +28 -6
- package/src/recipes/stack.js +69 -7
- package/src/tuning.js +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.1 (2026-11-27)
|
|
4
|
+
|
|
5
|
+
- **Stack keeps its shapes in proportion.** A stack, a row or a stagger no longer stretches each shape to fill its slot
|
|
6
|
+
(three layers 448 by 135): `totem()` gives each shape as much of the column's width as its own proportions allow (a
|
|
7
|
+
disc stays round, a half disc about two to one, a slab stops at `FLAT`, 2.2 to one), sizes them along the axis by one
|
|
8
|
+
rule (`sizes`: equal, a 1 to 2 step, or one big; the roundest shapes take the biggest shares, so none is a crumb), and
|
|
9
|
+
lays a shape with a long side across the axis whatever its turn says. New controls `sizes` and `width`; `sizes: 'fill'`
|
|
10
|
+
is the old stretch, by hand. A banned neighbour is swapped for a plain solid only (an arch or a disc brought in by the
|
|
11
|
+
steering made mushrooms and busts), a dome and a pill never end a stack of three (a burger), and shuffles leave out the
|
|
12
|
+
disc (over or under anything, a person or an exclamation mark) and the chevron (thin when small). Settings saved before
|
|
13
|
+
still draw, now in proportion.
|
|
14
|
+
- **Overlap's gaps are the house gap at full width.** Kept, the overlap stands whole with a full gap to each side (the
|
|
15
|
+
under shapes are cut back), where it used to be shrunk inside a line traced round the crossing; knocked out or kept,
|
|
16
|
+
a crossing that would eat a part to a sliver or leave a crumb (`sound()`: every piece at least 34 wide on average and a
|
|
17
|
+
tenth of the ink) is laid over instead. Shuffles set the gap a little over the house's (1.15 to 1.5 times), and the
|
|
18
|
+
recipe's guard takes less thin ink (`maxThinShare` 0.025).
|
|
19
|
+
|
|
3
20
|
## 0.3.0 (2026-11-27)
|
|
4
21
|
|
|
5
22
|
Recipes that combine UNLIKE shapes (the owner: "there isn't enough variation… most shapes are combined different shapes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logomarks/generate",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Abstract logomarks from rules and controls, no AI: 34 recipes (bars, bands, twin, stack, shear, turns, burst, tiles, route, arcs, rings, stripes, dots, pixel, chevrons, waves, cut, split, venn, blobs, dashes, fan, fold, spiral, orbit, bloom, links, horizon, steps, hex, tri, iso, line, letter) that each list their controls and draw a mark from them and a seed, fitted to the Logomarks standard (512 canvas, 448 fit, the house gap), a shared finish (rounding, outline, an accent dot, a container), two-colour pieces, seeded variations and presets. Runs in the browser and in Node.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
package/src/recipes/overlap.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* gap, or the overlap itself knocked out (and, as a third way, kept as its own piece between them). The shapes sit on
|
|
4
4
|
* a diagonal, side by side or one above the other.
|
|
5
5
|
*/
|
|
6
|
-
import { U, D, I, grown
|
|
6
|
+
import { U, D, I, grown } from '@logomarks/core/geometry';
|
|
7
7
|
import { BOX, GAP, tidy } from '../draw.js';
|
|
8
|
+
import { pieces } from '../guard.js';
|
|
8
9
|
import { prim, unlike } from '../primitives.js';
|
|
9
10
|
|
|
10
11
|
// no ring or arch: a ring under another shape is an eye or a key, an arch under a disc a person
|
|
@@ -24,14 +25,35 @@ export const controls = [
|
|
|
24
25
|
|
|
25
26
|
export const shapesOf = (p) => [p.a, unlike('overlap', p.a, p.b, POOL)];
|
|
26
27
|
|
|
27
|
-
/** The
|
|
28
|
+
/** The narrowest a piece may be on average, and the least share of the ink it may hold, for a crossing to be shown that way. */
|
|
29
|
+
const SOUND = { width: 34, share: 0.1 };
|
|
30
|
+
/** Whether a drawing is `n` pieces, each wide and big enough to read: nothing eaten to a sliver, no crumb left. */
|
|
31
|
+
function sound(shape, n) {
|
|
32
|
+
const ps = pieces(shape), total = ps.reduce((t, q) => t + q.area, 0);
|
|
33
|
+
return ps.length === n && ps.every((q) => q.width >= SOUND.width && q.area >= SOUND.share * total);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The mark for resolved params. Every gap is the house gap at its full width: laid over, the under shape is cut back by
|
|
38
|
+
* it; knocked out, the overlap leaves a hole a gap wider than itself; kept, the overlap stands whole with a full gap to
|
|
39
|
+
* each side (never a hairline traced round the crossing). Where knocking out or keeping would eat a part to a sliver or
|
|
40
|
+
* leave a crumb, the crossing is laid over instead.
|
|
41
|
+
*/
|
|
28
42
|
export function build(p) {
|
|
29
|
-
const { x0, y0, x1, y1, size, cx, cy } = BOX, [a, b] = shapesOf(p), s = size * p.size, g = GAP * p.spacing;
|
|
43
|
+
const { x0, y0, x1, y1, size, cx, cy } = BOX, [a, b] = shapesOf(p), s = size * p.size, g = GAP * Math.max(1, p.spacing);
|
|
30
44
|
const boxes = p.layout === 'row' ? [[x0, cy - s / 2], [x1 - s, cy - s / 2]] : p.layout === 'column' ? [[cx - s / 2, y0], [cx - s / 2, y1 - s]] : p.layout === 'counter' ? [[x1 - s, y0], [x0, y1 - s]] : [[x0, y0], [x1 - s, y1 - s]];
|
|
31
45
|
const A = prim(a, [...boxes[0], s, s], Number(p.turnA) / 90), B = prim(b, [...boxes[1], s, s], Number(p.turnB) / 90);
|
|
32
|
-
|
|
46
|
+
const laid = () => tidy(U(D(A, grown(B, g)), B));
|
|
47
|
+
if (p.way === 'over') return laid();
|
|
33
48
|
const both = I(A, B);
|
|
34
|
-
if (!both.length) return
|
|
49
|
+
if (!both.length) return laid();
|
|
50
|
+
if (p.way === 'keep') {
|
|
51
|
+
const rest = D(U(A, B), grown(both, g)), out = U(rest, both);
|
|
52
|
+
return sound(both, 1) && sound(rest, 2) && sound(out, 3) ? out : laid();
|
|
53
|
+
}
|
|
35
54
|
const out = D(U(A, B), grown(both, g / 2));
|
|
36
|
-
return
|
|
55
|
+
return sound(out, 2) ? out : laid();
|
|
37
56
|
}
|
|
57
|
+
|
|
58
|
+
/** Tighter than the house's: a crossing drawn with thin parts is the fault this recipe is checked for. */
|
|
59
|
+
export const guard = { maxThinShare: 0.025 };
|
package/src/recipes/stack.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Stack: a totem. Two to four primitive shapes
|
|
2
|
+
* Stack: a totem. Two to four primitive shapes on one axis (a stack, a row or a stagger), each kept to its own
|
|
3
|
+
* proportions (`totem()`: never squashed into a layer) and sized by one rule, or in a grid, overlapping or nested, combined by
|
|
3
4
|
* ONE rule: kept apart by the house gap, laid over the one before with a gap round them, cut out of it, merged, or
|
|
4
5
|
* exclusive-or. Two shapes (A and B) and an order spread them over the slots; each can be turned. After marks that
|
|
5
6
|
* stack and tweak simple shapes together.
|
|
@@ -11,6 +12,10 @@ import { primitive, PRIMITIVES } from '../shapes.js';
|
|
|
11
12
|
import { BANNED } from '../primitives.js';
|
|
12
13
|
|
|
13
14
|
const TURNS = ['0', '90', '180', '270'];
|
|
15
|
+
/** The first and last of three that read as an object whatever is between them: a burger. */
|
|
16
|
+
const ENDS = [['half', 'pill'], ['half', 'square'], ['half', 'half']];
|
|
17
|
+
/** The shapes a banned neighbour is swapped for, in turn. */
|
|
18
|
+
const STEER = ['square', 'half', 'quarter', 'triangle', 'parallelogram', 'pill', 'diamond', 'leaf'];
|
|
14
19
|
|
|
15
20
|
/** @type {import('../index.js').Control[]} */
|
|
16
21
|
export const controls = [
|
|
@@ -27,8 +32,51 @@ export const controls = [
|
|
|
27
32
|
{ key: 'combine', label: 'Combine', type: 'choice', options: ['gap', 'over', 'cut', 'merge', 'xor'], value: 'gap' },
|
|
28
33
|
{ key: 'size', label: 'Shape size', type: 'range', min: 0.5, max: 1, step: 0.01, value: 1 },
|
|
29
34
|
{ key: 'overlap', label: 'Overlap', type: 'range', min: 0, max: 0.6, step: 0.01, value: 0.3 },
|
|
35
|
+
{ key: 'sizes', label: 'Sizes', type: 'choice', options: ['equal', 'step', 'big', 'fill'], value: 'equal' },
|
|
36
|
+
{ key: 'width', label: 'Width', type: 'range', min: 0.55, max: 1, step: 0.01, value: 0.7 },
|
|
30
37
|
];
|
|
31
38
|
|
|
39
|
+
/**
|
|
40
|
+
* How wide each shape may be for its height, unturned (least, most): a disc is always round, a half disc about two to
|
|
41
|
+
* one, a slab up to the limit. Nothing is flatter than FLAT to one: past that a shape is a layer, not a shape.
|
|
42
|
+
*/
|
|
43
|
+
export const FLAT = 2.2;
|
|
44
|
+
const ASPECT = { square: [1, 2], circle: [1, 1], half: [1.7, FLAT], quarter: [1, 1.8], triangle: [1, 1.8], parallelogram: [1.5, FLAT], pill: [1.8, FLAT], ring: [1, 1], arch: [0.9, 1.4], chevron: [1.2, 2], diamond: [1, 1.8], leaf: [1, 1.7] };
|
|
45
|
+
/** Shapes that read the same lying or standing: a turn doesn't change how wide they may be. The rest have a long side. */
|
|
46
|
+
const FREE = ['square', 'diamond', 'leaf', 'quarter', 'circle', 'ring'];
|
|
47
|
+
/** The sizes along the axis, as shares: equal, stepping up 1 to 2 from the first, or one big and the rest small. */
|
|
48
|
+
const shares = (sizes, n) => (sizes === 'step' ? Array.from({ length: n }, (_, i) => 1 + i / Math.max(1, n - 1)) : sizes === 'big' ? Array.from({ length: n }, (_, i) => (i === n - 1 ? 2 : 1)) : Array(n).fill(1));
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A totem's boxes: the shapes along one axis by `sizes`, the house gap between, each as wide across the axis as `width`
|
|
52
|
+
* of the box allows AND its own shape allows (so none is squashed: a disc stays a disc, a slab stops at FLAT to one),
|
|
53
|
+
* centred on the axis (a stagger sets them left and right in turn). `turns` are each shape's quarter turns; a shape
|
|
54
|
+
* that would stand on end across the axis is laid along it instead (the returned turns say how each was laid).
|
|
55
|
+
*/
|
|
56
|
+
export function totem(layout, shapes, turns, sizes, width) {
|
|
57
|
+
const n = shapes.length, row = layout === 'row', { x0, y0, size, cx, cy } = BOX, room = size - (n - 1) * GAP;
|
|
58
|
+
// the roundest shapes take the biggest shares: a disc or a leaf given a small share is a crumb beside a slab
|
|
59
|
+
const sorted = shares(sizes, n).sort((a, b) => a - b), rank = shapes.map((sp, i) => [-(ASPECT[sp] || [1, 1])[1], i]).sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
|
60
|
+
const sh = Array(n); rank.forEach(([, i], k) => { sh[i] = sizes === 'equal' ? 1 : sorted[k]; });
|
|
61
|
+
const total = sh.reduce((a, b) => a + b, 0), across = size * width;
|
|
62
|
+
// a shape with a long side lies across the axis (level in a stack, upright in a row), whatever its own turn says
|
|
63
|
+
const laid = turns.map((t, i) => (FREE.includes(shapes[i]) || (((t % 2) + 2) % 2 === 1) === row ? t : t + 1));
|
|
64
|
+
const aspectOf = (shape) => { const [lo, hi] = ASPECT[shape] || [1, 1]; return row ? [1 / hi, 1 / lo] : [lo, hi]; };
|
|
65
|
+
let at = row ? x0 : y0;
|
|
66
|
+
const boxes = shapes.map((shape, i) => {
|
|
67
|
+
const along = (room * sh[i]) / total, [lo, hi] = aspectOf(shape);
|
|
68
|
+
// the span across the axis: as much of `across` as the shape's own proportions allow
|
|
69
|
+
const span = row ? Math.min(Math.max(across, along / hi), along / lo) : Math.min(Math.max(across, along * lo), along * hi);
|
|
70
|
+
const start = at; at += along + GAP;
|
|
71
|
+
return row ? [start, cy - span / 2, along, span] : [cx - span / 2, start, span, along];
|
|
72
|
+
});
|
|
73
|
+
if (layout === 'stagger') {
|
|
74
|
+
const widest = Math.max(...boxes.map((b) => b[2]));
|
|
75
|
+
boxes.forEach((b, i) => { b[0] = i % 2 ? cx + widest / 2 - b[2] : cx - widest / 2; });
|
|
76
|
+
}
|
|
77
|
+
return { boxes, turns: laid };
|
|
78
|
+
}
|
|
79
|
+
|
|
32
80
|
/** The slots (boxes) of a layout for `n` shapes, in drawing order. */
|
|
33
81
|
function slots(layout, n, overlap) {
|
|
34
82
|
const { x0, y0, size } = BOX, g = GAP;
|
|
@@ -65,20 +113,34 @@ export function shapesOf(p) {
|
|
|
65
113
|
const out = Array.from({ length: n }, (_, i) => named[which(p.order, i)]);
|
|
66
114
|
if (!['stack', 'row', 'stagger', 'grid'].includes(p.layout)) return out;
|
|
67
115
|
for (let i = 1; i < n; i++) {
|
|
68
|
-
|
|
69
|
-
|
|
116
|
+
// beside its neighbour, and for the last of three against the first: a dome over a pill is a burger whatever lies between
|
|
117
|
+
const bad = (c) => clash(out[i - 1], c) || (i === 2 && ENDS.some(([u, v]) => (u === out[0] && v === c) || (v === out[0] && u === c))) || (p.order === 'ABC' && out.slice(0, i).includes(c));
|
|
118
|
+
// steered through the plain solids only: an arch, a ring, a disc or a chevron brought in here made mushrooms and busts
|
|
119
|
+
for (let k = 0; k < STEER.length && bad(out[i]); k++) out[i] = STEER[(STEER.indexOf(out[i]) + 1) % STEER.length];
|
|
70
120
|
}
|
|
71
121
|
return out;
|
|
72
122
|
}
|
|
73
123
|
|
|
124
|
+
/** Each slot's turn, in quarter turns: its shape's own turn plus the turn-each step. */
|
|
125
|
+
const turnsOf = (p, n) => Array.from({ length: n }, (_, i) => {
|
|
126
|
+
const k = which(p.order, i), extra = p.step === 'quarter' ? i : p.step === 'half' ? 2 * i : 0;
|
|
127
|
+
return Number(k === 'A' ? p.turnA : k === 'B' ? p.turnB : p.turnC || 0) / 90 + extra;
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
/** The boxes and turns the shapes are drawn in: a totem's own for a stack, a row or a stagger, else the layout's slots. */
|
|
131
|
+
export function placed(p) {
|
|
132
|
+
const shapes = shapesOf(p), n = shapes.length, turns = turnsOf(p, n);
|
|
133
|
+
if (['stack', 'row', 'stagger'].includes(p.layout) && p.sizes !== 'fill') return { shapes, ...totem(p.layout, shapes, turns, p.sizes, p.width) };
|
|
134
|
+
return { shapes, boxes: slots(p.layout, p.count, p.overlap), turns };
|
|
135
|
+
}
|
|
136
|
+
|
|
74
137
|
/** The mark for resolved params. */
|
|
75
138
|
export function build(p) {
|
|
76
|
-
const
|
|
139
|
+
const { shapes, boxes, turns } = placed(p);
|
|
77
140
|
const parts = boxes.map(([x, y, w, h], i) => {
|
|
78
|
-
const
|
|
141
|
+
const shrink = p.layout === 'nest' ? 1 : p.size;
|
|
79
142
|
const bw = w * shrink, bh = h * shrink, bx = x + (w - bw) / 2, by = y + (h - bh) / 2;
|
|
80
|
-
|
|
81
|
-
return primitive(shapes[i], bx, by, bw, bh, Number(k === 'A' ? p.turnA : k === 'B' ? p.turnB : p.turnC || 0) / 90 + extra);
|
|
143
|
+
return primitive(shapes[i], bx, by, bw, bh, turns[i]);
|
|
82
144
|
});
|
|
83
145
|
let acc = parts[0];
|
|
84
146
|
for (const s of parts.slice(1)) {
|
package/src/tuning.js
CHANGED
|
@@ -12,9 +12,10 @@ export const TUNING = {
|
|
|
12
12
|
bars: { count: R(2, 4), weight: R(0.58, 0.8), cutSize: R(0.1, 0.2), cutAt: R(0.35, 0.65), lengths: { rare: 0.3 }, ends: { rare: 0.25 }, slant: rare(0.15, -20, 20), level: { rare: 0.1 }, cutAngle: rare(0.25, -35, 35), spine: { rare: 0.2 }, widths: { rare: 0.08, random: ['growing', 'thin-thick'] } },
|
|
13
13
|
bands: { count: R(2, 3), weight: R(0.6, 0.8), ends: { rare: 0.3 }, slant: rare(0.15, -18, 18) },
|
|
14
14
|
twin: { thickness: R(0.3, 0.42), slant: rare(0.3, -22, 22) },
|
|
15
|
-
// a totem: three unlike shapes on one axis, the gap between (nests and overlaps threw outlines, eyes and busts: by hand only
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
// a totem: three unlike shapes on one axis, the gap between (nests and overlaps threw outlines, eyes and busts: by hand only;
|
|
16
|
+
// so are a disc, which over or under anything is a person or an exclamation mark, and a chevron, thin when small)
|
|
17
|
+
stack: { layout: of('stack', 'stack', 'stack', 'stagger'), sizes: of('equal', 'equal', 'step', 'big'), width: R(0.62, 0.86), count: R(2, 3), order: of('ABC', 'ABC', 'ABA', 'AB'), step: { rare: 0.15 }, combine: of('gap'), size: rare(0.2, 0.8, 1), overlap: R(0.2, 0.45),
|
|
18
|
+
shapeA: of('square', 'half', 'quarter', 'triangle', 'parallelogram', 'pill', 'diamond', 'leaf'), shapeB: of('square', 'half', 'quarter', 'triangle', 'parallelogram', 'pill', 'diamond', 'leaf'), shapeC: of('square', 'half', 'quarter', 'triangle', 'parallelogram', 'pill', 'diamond', 'leaf') },
|
|
18
19
|
shear: { rows: R(1, 2), cols: R(2, 3), lean: of('same', 'rows', 'chevron'), angle: R(18, 32), drop: { rare: 0.25 }, spacing: R(1, 1.5), taper: rare(0.12, 0.1, 0.3), lengths: { rare: 0.3 }, slide: rare(0.2, 0.15, 0.4) },
|
|
19
20
|
turns: { count: of('3', '4', '5', '6'), size: R(0.32, 0.46), stretch: rare(0.3, 0.8, 1.4), radius: R(0.06, 0.26), tilt: rare(0.35, -30, 30) },
|
|
20
21
|
burst: { rays: R(5, 10), ray: of('bar', 'wedge', 'pill', 'drop'), width: R(0.1, 0.18), inner: R(0.06, 0.28), alternate: rare(0.2, 0.2, 0.45), twist: rare(0.2, -30, 30), move: { rare: 0.35 } },
|
|
@@ -51,7 +52,8 @@ export const TUNING = {
|
|
|
51
52
|
seam: { body: of('square', 'square', 'rounded', 'disc', 'hexagon'), at: R(0.4, 0.6), size: R(0.2, 0.36), reach: R(0.14, 0.26), spacing: R(1, 1.5) },
|
|
52
53
|
// the composition recipes: the shapes are drawn evenly from their pools (a banned pair is steered in the build)
|
|
53
54
|
merge: { at: R(0.4, 0.6), width: R(0.45, 0.78) },
|
|
54
|
-
|
|
55
|
+
// the gap a little over the house's: at exactly 22 a line traced round a crossing reads as a hairline beside two big solids
|
|
56
|
+
overlap: { way: of('over', 'over', 'knock', 'keep'), layout: of('diagonal', 'counter', 'row'), size: R(0.6, 0.74), spacing: R(1.15, 1.5) },
|
|
55
57
|
counter: { size: R(0.34, 0.5), place: of('centre', 'corner', 'side', 'low', 'high') },
|
|
56
58
|
pair: { at: R(0.4, 0.6), slide: rare(0.3, 0.12, 0.28), spin: of('0', '0', '90', '45', '135'), spacing: R(1, 1.5) },
|
|
57
59
|
corners: { reach: R(0.3, 0.5), second: rare(0.4, 0.5, 0.8), shape: of('square', 'square', 'square', 'wide', 'tall') },
|