@logomarks/generate 0.3.0 → 0.3.2
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 +39 -0
- package/README.md +6 -0
- package/package.json +1 -1
- package/src/presets.js +1 -1
- package/src/primitives.js +1 -1
- package/src/recipes/arcs.js +6 -1
- package/src/recipes/burst.js +8 -1
- package/src/recipes/counter.js +4 -3
- package/src/recipes/overlap.js +28 -6
- package/src/recipes/rings.js +49 -6
- package/src/recipes/stack.js +69 -7
- package/src/tuning.js +11 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.2 (2026-11-27)
|
|
4
|
+
|
|
5
|
+
Icon reads ruled out by construction, after the owner's sweep of the mix (a ring with a slash, a feed icon):
|
|
6
|
+
- `rings`: two gaps sit 150° apart, never opposite (a straight channel through the middle is the no-entry or empty-set
|
|
7
|
+
sign); the solid disc inside an open centre takes one gap (two cut it into sectors meeting in a spike); the first gap
|
|
8
|
+
starts at 40° from the top (`START`), and one gap turns at least 24° ring to ring (`minTurn`): a ring broken at twelve
|
|
9
|
+
o'clock round an aligned slot is the power symbol. An open centre is a real hole (its radius 2.6 gaps): filled to the
|
|
10
|
+
middle, the innermost band was a solid disc, and a heavy ring round a slotted disc reads as a power button, a volume
|
|
11
|
+
knob or a dial; the larger hole also keeps the innermost ring's gap from opening it into a keyhole. A dot in a rounded
|
|
12
|
+
frame draws as an open middle (an @). Shuffles now take three to five rings (two is the dial), at most two gaps (three
|
|
13
|
+
on few rings is a car badge), a turn of 20° to 60°, every body (circle, rounded, square, chamfer, hexagon), and never
|
|
14
|
+
move the centre off (the rings crowd into a crescent): 48 shuffles give about twenty layouts, none over an eighth.
|
|
15
|
+
In a round body the innermost ring is never broken once (a C inside a ring is the copyright sign ©, mirrored the
|
|
16
|
+
copyleft sign): it takes two gaps, 150° apart, or, too small for two, closes into a plain ring. Every rings draw moves.
|
|
17
|
+
- `arcs`: a quarter fan takes no disc or square core (a dot in the corner is the RSS icon), and half rings round a disc
|
|
18
|
+
always stand on legs (bare, they are the Wi-Fi icon). Settings that asked for either draw the allowed form.
|
|
19
|
+
- `burst`: eight rays long and short draw as ten (`raysOf`): four long rays on the axes are a plus.
|
|
20
|
+
- `counter`: an almond (leaf) hole only in a half or a quarter (in a square, a soft square or a hexagon it is an eye);
|
|
21
|
+
the default hole is a quarter disc; the Leaf window preset is a quarter disc with a leaf hole.
|
|
22
|
+
- `chevrons`: shuffles and the mix never pick the arrowhead or the stem move (an arrow, a download icon); by hand only.
|
|
23
|
+
- A test checks each ban on the build and on 300 shuffles.
|
|
24
|
+
|
|
25
|
+
## 0.3.1 (2026-11-27)
|
|
26
|
+
|
|
27
|
+
- **Stack keeps its shapes in proportion.** A stack, a row or a stagger no longer stretches each shape to fill its slot
|
|
28
|
+
(three layers 448 by 135): `totem()` gives each shape as much of the column's width as its own proportions allow (a
|
|
29
|
+
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
|
|
30
|
+
rule (`sizes`: equal, a 1 to 2 step, or one big; the roundest shapes take the biggest shares, so none is a crumb), and
|
|
31
|
+
lays a shape with a long side across the axis whatever its turn says. New controls `sizes` and `width`; `sizes: 'fill'`
|
|
32
|
+
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
|
|
33
|
+
steering made mushrooms and busts), a dome and a pill never end a stack of three (a burger), and shuffles leave out the
|
|
34
|
+
disc (over or under anything, a person or an exclamation mark) and the chevron (thin when small). Settings saved before
|
|
35
|
+
still draw, now in proportion.
|
|
36
|
+
- **Overlap's gaps are the house gap at full width.** Kept, the overlap stands whole with a full gap to each side (the
|
|
37
|
+
under shapes are cut back), where it used to be shrunk inside a line traced round the crossing; knocked out or kept,
|
|
38
|
+
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
|
|
39
|
+
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
|
|
40
|
+
recipe's guard takes less thin ink (`maxThinShare` 0.025).
|
|
41
|
+
|
|
3
42
|
## 0.3.0 (2026-11-27)
|
|
4
43
|
|
|
5
44
|
Recipes that combine UNLIKE shapes (the owner: "there isn't enough variation… most shapes are combined different shapes
|
package/README.md
CHANGED
|
@@ -52,6 +52,12 @@ MIT © ArrayPress Limited. What you generate is yours to use.
|
|
|
52
52
|
|
|
53
53
|
Seven recipes (and `stack`, a totem) build a mark from DIFFERENT basic shapes, drawn by `src/primitives.js`:
|
|
54
54
|
|
|
55
|
+
`stack` keeps each shape in proportion (since 0.3.1): no shape is drawn flatter than 2.2 to 1 (`FLAT` in
|
|
56
|
+
`src/recipes/stack.js`), and the three are sized along the axis by one rule, its `sizes` control: `equal`, `step` (1 to
|
|
57
|
+
2), `big` (one big, two small) or `fill` (the old stretch to fill, by hand only). `width` sets how wide the column is.
|
|
58
|
+
`overlap` shows a crossing with the full house gap or lays one shape over the other; a crossing that would leave a
|
|
59
|
+
sliver is never knocked out.
|
|
60
|
+
|
|
55
61
|
- `PRIMS`: disc, square, rsquare, triangle, wedge, half, quarter, arch, leaf, pill, diamond, hexagon, ring, bar.
|
|
56
62
|
`prim(type, [x, y, w, h], turn, mirror)` draws one in a box, turned by quarter turns.
|
|
57
63
|
- `alike(a, b)`: two shapes that read the same (a disc and a ring, a square and a rounded square) are never paired.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logomarks/generate",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
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/presets.js
CHANGED
|
@@ -36,7 +36,7 @@ export const PRESETS = [
|
|
|
36
36
|
{ id: 'blade-sweep', name: 'Blade sweep', recipe: 'blades', params: { count: 3, grow: 0.5, width: 1.6 }, note: 'Three blades, each taller than the last.' },
|
|
37
37
|
{ id: 'dome-wedge', name: 'Dome and wedge', recipe: 'merge', params: { a: 'half', b: 'wedge', width: 0.62 }, note: 'A dome fused to a wedge set to one side: one solid.' },
|
|
38
38
|
{ id: 'four-corners', name: 'Four corners', recipe: 'corners', params: { nw: 'round', ne: 'square', se: 'scoop', sw: 'cut', reach: 0.4 }, note: 'One block, each corner treated a different way.' },
|
|
39
|
-
{ id: 'leaf-window', name: 'Leaf window', recipe: 'counter', params: { body: '
|
|
39
|
+
{ id: 'leaf-window', name: 'Leaf window', recipe: 'counter', params: { body: 'quarter', hole: 'leaf', size: 0.44 }, note: 'A quarter disc with a leaf-shaped hole.' },
|
|
40
40
|
{ id: 'facing-halves', name: 'Facing halves', recipe: 'pair', params: { a: 'half', b: 'quarter' }, note: 'A half disc and a quarter disc, flat sides to the split.' },
|
|
41
41
|
{ id: 'disc-on-square', name: 'Disc over square', recipe: 'overlap', params: { a: 'disc', b: 'square', way: 'over' }, note: 'A square laid over a disc, cut free by the gap.' },
|
|
42
42
|
{ id: 'dome-shadow', name: 'Dome shadow', recipe: 'offset', params: { shape: 'half', way: 'shadow', dir: 'se', shift: 0.28 }, note: 'A dome and its copy slid behind it.' },
|
package/src/primitives.js
CHANGED
|
@@ -58,7 +58,7 @@ export const alike = (a, b) => a === b || ALIKE.some(([p, q]) => (p === a && q =
|
|
|
58
58
|
export const BANNED = {
|
|
59
59
|
merge: [['disc', 'square', 'a person'], ['disc', 'rsquare', 'a person'], ['disc', 'pill', 'a person'], ['disc', 'half', 'a person'], ['disc', 'bar', 'a person'], ['disc', 'triangle', 'a pin'], ['disc', 'wedge', 'a pin'], ['disc', 'diamond', 'a pin'], ['triangle', 'square', 'a house'], ['triangle', 'rsquare', 'a house'], ['triangle', 'pill', 'an arrow'], ['triangle', 'bar', 'an arrow'], ['triangle', 'half', 'a cone'], ['diamond', 'half', 'a cone'], ['leaf', 'disc', 'a flame'], ['hexagon', 'triangle', 'a pencil'], ['square', 'half', 'a tombstone'], ['rsquare', 'half', 'a tombstone'], ['pill', 'half', 'a mushroom']],
|
|
60
60
|
overlap: [['disc', 'triangle', 'a play button'], ['ring', 'bar', 'a no-entry sign'], ['ring', 'pill', 'a no-entry sign'], ['disc', 'bar', 'a no-entry sign'], ['ring', 'triangle', 'a play button'], ['ring', 'square', 'a magnifier'], ['ring', 'rsquare', 'a magnifier'], ['ring', 'diamond', 'a key'], ['disc', 'half', 'a person'], ['triangle', 'square', 'a house'], ['triangle', 'rsquare', 'a house']],
|
|
61
|
-
counter: [['disc', 'triangle', 'a play button'], ['rsquare', 'triangle', 'a play button'], ['square', 'triangle', 'a play button'], ['hexagon', 'triangle', 'a play button'], ['disc', 'wedge', 'a play button'], ['rsquare', 'wedge', 'a play button'], ['hexagon', 'disc', 'a nut'], ['triangle', 'disc', 'an eye in a triangle'], ['leaf', 'disc', 'an eye'], ['disc', 'leaf', 'an eye'], ['disc', 'square', 'a stop button'], ['disc', 'rsquare', 'a stop button'], ['rsquare', 'disc', 'a camera'], ['square', 'disc', 'a camera'], ['half', 'disc', 'an eye'], ['diamond', 'disc', 'an eye'], ['disc', 'pill', 'a no-entry sign'], ['disc', 'bar', 'a no-entry sign'], ['rsquare', 'pill', 'a battery'], ['hexagon', 'pill', 'a screw head'], ['disc', 'half', 'a face'], ['rsquare', 'half', 'a face'], ['square', 'half', 'a door'], ['square', 'arch', 'a door'], ['rsquare', 'arch', 'a door']],
|
|
61
|
+
counter: [['disc', 'triangle', 'a play button'], ['rsquare', 'triangle', 'a play button'], ['square', 'triangle', 'a play button'], ['hexagon', 'triangle', 'a play button'], ['disc', 'wedge', 'a play button'], ['rsquare', 'wedge', 'a play button'], ['hexagon', 'disc', 'a nut'], ['triangle', 'disc', 'an eye in a triangle'], ['leaf', 'disc', 'an eye'], ['disc', 'leaf', 'an eye'], ['disc', 'square', 'a stop button'], ['disc', 'rsquare', 'a stop button'], ['rsquare', 'disc', 'a camera'], ['square', 'disc', 'a camera'], ['half', 'disc', 'an eye'], ['diamond', 'disc', 'an eye'], ['disc', 'pill', 'a no-entry sign'], ['disc', 'bar', 'a no-entry sign'], ['rsquare', 'pill', 'a battery'], ['hexagon', 'pill', 'a screw head'], ['disc', 'half', 'a face'], ['rsquare', 'half', 'a face'], ['square', 'half', 'a door'], ['square', 'arch', 'a door'], ['rsquare', 'arch', 'a door'], ['square', 'leaf', 'an eye'], ['rsquare', 'leaf', 'an eye'], ['hexagon', 'leaf', 'an eye']],
|
|
62
62
|
pair: [['triangle', 'square', 'an arrow'], ['triangle', 'rsquare', 'an arrow'], ['triangle', 'pill', 'an arrow'], ['wedge', 'square', 'an arrow'], ['triangle', 'bar', 'an arrow'], ['half', 'triangle', 'a play button']],
|
|
63
63
|
stack: [['half', 'square', 'a burger'], ['half', 'pill', 'a burger'], ['circle', 'square', 'a person'], ['circle', 'pill', 'a person'], ['circle', 'half', 'a person'], ['circle', 'arch', 'a person'], ['circle', 'triangle', 'a pin'], ['circle', 'chevron', 'a person'], ['circle', 'ring', 'an eye'], ['ring', 'half', 'an eye'], ['ring', 'pill', 'an eye'], ['ring', 'square', 'a person'], ['ring', 'triangle', 'a pin'], ['triangle', 'square', 'a house'], ['triangle', 'pill', 'an arrow'], ['chevron', 'square', 'a house'], ['triangle', 'half', 'a cone'], ['diamond', 'half', 'a cone']],
|
|
64
64
|
offset: [],
|
package/src/recipes/arcs.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* nested arches, stepped arcs and corner bands. The default is arches on legs: a quarter of rings round a disc in a
|
|
5
5
|
* corner is the RSS or Wi-Fi icon. `corner` squares or chamfers the bands into nested L-bands (the corporate-modernist
|
|
6
6
|
* corner marks), `slant` shears the group, and a `quarter` core fills the innermost corner in the bands' own corner style
|
|
7
|
-
* (only on legs: a bare quarter round a corner core is the RSS icon again).
|
|
7
|
+
* (only on legs: a bare quarter round a corner core is the RSS icon again). A quarter fan never takes a disc or square
|
|
8
|
+
* core (RSS), and half rings round a disc always stand on legs (bare, they are the Wi-Fi icon).
|
|
8
9
|
*/
|
|
9
10
|
import { U, D, I, rect, circle, poly, arcBand, sector, mapPts } from '@logomarks/core/geometry';
|
|
10
11
|
import { BOX, GAP, tidy, shear } from '../draw.js';
|
|
@@ -62,6 +63,10 @@ export function build(params) {
|
|
|
62
63
|
// a quarter core is for square or chamfered corners only, and on legs: round rings round a corner core are the RSS icon
|
|
63
64
|
if (p.core === 'quarter' && p.corner === 'round') p.core = 'none';
|
|
64
65
|
if (p.core === 'quarter' && p.legs < 0.2) p.legs = 0.25;
|
|
66
|
+
// a dot in the corner of a quarter fan is the RSS (feed) icon whatever its legs, and a small half disc under half rings
|
|
67
|
+
// with no legs is the Wi-Fi icon: a quarter fan takes no disc or square core, and a half one with a disc stands on legs
|
|
68
|
+
if (p.sweep === 'quarter' && (p.core === 'disc' || p.core === 'square')) p.core = 'none';
|
|
69
|
+
if (p.sweep === 'half' && p.core === 'disc' && p.legs < 0.2) p.legs = 0.25;
|
|
65
70
|
const half = p.sweep === 'half', { x0, y1, cx, size } = BOX;
|
|
66
71
|
let s;
|
|
67
72
|
if (p.move === 'pair') {
|
package/src/recipes/burst.js
CHANGED
|
@@ -28,7 +28,14 @@ function ray(kind, r0, r1, w) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/** The mark for resolved params. */
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Eight rays long and short leave four long ones on the axes: a plus (a cross, or a compass rose) with stubs between. So
|
|
33
|
+
* long and short takes ten rays there, five long.
|
|
34
|
+
*/
|
|
35
|
+
export const raysOf = (p) => (p.alternate > 0 && p.rays === 8 ? 10 : p.rays);
|
|
36
|
+
|
|
37
|
+
export function build(params) {
|
|
38
|
+
const p = { ...params, rays: raysOf(params) };
|
|
32
39
|
const R = BOX.size / 2, w = p.width * BOX.size, r0 = Math.max(p.inner * R, p.move === 'dot' ? R * 0.28 : 0);
|
|
33
40
|
const parts = [];
|
|
34
41
|
for (let k = 0; k < p.rays; k++) {
|
package/src/recipes/counter.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Counter: one solid whose hole is a DIFFERENT shape (a square with a
|
|
2
|
+
* Counter: one solid whose hole is a DIFFERENT shape (a square with a quarter-disc hole, a half disc with a leaf-shaped one), the
|
|
3
3
|
* hole set in the middle or off towards a corner or a side. Never a round hole in a round body (a target), a triangle
|
|
4
|
-
* in a disc or a tile (a play button), or a disc in a leaf (an eye)
|
|
4
|
+
* in a disc or a tile (a play button), or a disc in a leaf (an eye); and an almond hole only in a half or a quarter (in a square, a soft square or a hexagon
|
|
5
|
+
* it is an eye).
|
|
5
6
|
*/
|
|
6
7
|
import { D, rot } from '@logomarks/core/geometry';
|
|
7
8
|
import { BOX, tidy } from '../draw.js';
|
|
@@ -21,7 +22,7 @@ const MOVE = { centre: [0, 0], corner: [1, 1], side: [1, 0], low: [0, 1], high:
|
|
|
21
22
|
/** @type {import('../index.js').Control[]} */
|
|
22
23
|
export const controls = [
|
|
23
24
|
{ key: 'body', label: 'Body', type: 'choice', options: BODIES, value: 'square' },
|
|
24
|
-
{ key: 'hole', label: 'Hole', type: 'choice', options: HOLES, value: '
|
|
25
|
+
{ key: 'hole', label: 'Hole', type: 'choice', options: HOLES, value: 'quarter' },
|
|
25
26
|
{ key: 'size', label: 'Hole size', type: 'range', min: 0.24, max: 0.5, step: 0.01, value: 0.44 },
|
|
26
27
|
{ key: 'place', label: 'Hole position', type: 'choice', options: ['centre', 'corner', 'side', 'low', 'high'], value: 'centre' },
|
|
27
28
|
{ key: 'holeTurn', label: 'Turn hole', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
|
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/rings.js
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* rings, halos and orbit marks. `shape` makes the rings frames (rounded, square, chamfered or hexagonal: broken polygon
|
|
6
6
|
* frames), and `breakKind` step makes each gap a stepped break (on rings at least 3 gaps thick; thinner ones split into
|
|
7
7
|
* hairlines, so they keep the straight cut). Square frames take three gaps at most (four is a
|
|
8
|
-
* crosshair or a focus frame).
|
|
8
|
+
* crosshair or a focus frame). Two gaps sit 150° apart, never opposite (a slashed ring is the no-entry sign), and one
|
|
9
|
+
* gap turns at least 24° ring to ring (aligned, it is the power symbol). In a round body the innermost ring is never broken
|
|
10
|
+
* once (a C in a ring is the copyright sign): it takes two gaps.
|
|
9
11
|
*/
|
|
10
12
|
import { U, D, circle, annulus, rot, rect, rr, poly } from '@logomarks/core/geometry';
|
|
11
13
|
import { BOX, GAP, tidy } from '../draw.js';
|
|
@@ -54,12 +56,44 @@ function gapCut(kind, cx, cy, R, w, a, t, rMid) {
|
|
|
54
56
|
return rot(rect(cx - w / 2, cy - R - 10, w, R + 10), a, cx, cy);
|
|
55
57
|
}
|
|
56
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Where gap g of n sits on a ring, in degrees from the top. Two gaps are never opposite: two opposite gaps cut one straight
|
|
61
|
+
* channel through the middle, and round an open centre that is the empty-set or no-entry sign (a slashed ring). They sit
|
|
62
|
+
* 150° apart instead; three and four stay even (they always turn ring to ring, so they never line up into a channel).
|
|
63
|
+
*/
|
|
64
|
+
export const gapAt = (n, g) => START + (n === 2 ? g * 150 : (360 * g) / n);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Where the first gap starts, clockwise from the top. A ring broken at twelve o'clock round a slotted middle is the power
|
|
68
|
+
* symbol, so the outer ring's first gap sits up and to the right instead.
|
|
69
|
+
*/
|
|
70
|
+
export const START = 40;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* How far each ring's gaps turn from the ring outside it. Gaps lined up through every ring read as a sign: one gap is
|
|
74
|
+
* the power symbol (a ring broken at the top round a bar), two or more a peace sign, a car badge or a crosshair. So with
|
|
75
|
+
* one gap the turn is at least 24°, with more at least 14°.
|
|
76
|
+
*/
|
|
77
|
+
export function minTurn(p) {
|
|
78
|
+
const least = p.gaps === 1 ? 24 : p.gaps >= 2 ? 14 : 0;
|
|
79
|
+
return Math.abs(p.spin) < least ? (p.spin < 0 ? -least : least) : p.spin;
|
|
80
|
+
}
|
|
81
|
+
|
|
57
82
|
/** The mark for resolved params. */
|
|
58
83
|
export function build(params) {
|
|
59
84
|
const p = { ...params };
|
|
85
|
+
// a dot inside a rounded square frame broken once is an @: there the middle stays open
|
|
86
|
+
if (p.centre === 'dot' && p.shape === 'rounded') p.centre = 'open';
|
|
60
87
|
if ((p.shape === 'square' || p.shape === 'rounded' || p.shape === 'chamfer') && p.gaps > 3) p.gaps = 3;
|
|
61
|
-
|
|
62
|
-
|
|
88
|
+
// an open centre is a real hole, a gap wide at least: filled to the middle, the innermost band was a solid disc, and a disc
|
|
89
|
+
// with one slot inside a ring is a power button, a volume knob or a dial
|
|
90
|
+
const R = BOX.size / 2, open = p.centre === 'open', n = p.count + (open ? 0 : 1);
|
|
91
|
+
const gap = Math.max(GAP, ((1 - p.weight) * R) / (n + (open ? 1 : 0)));
|
|
92
|
+
// the open hole's radius is this plus a gap: smaller, the innermost ring's gap opens it into a keyhole (a lock) or an @;
|
|
93
|
+
// kept whole instead, the rings close round it into a target
|
|
94
|
+
// (with many rings it shrinks so each ring keeps a gap's width at least)
|
|
95
|
+
const hole = open ? Math.max(0, Math.min(gap * 1.6, R - n * gap - n * GAP)) : 0;
|
|
96
|
+
const t = (R - hole - (n - (open ? 0 : 1)) * gap) / n, parts = [];
|
|
63
97
|
for (let k = 0; k < p.count; k++) {
|
|
64
98
|
const rOuter = R - k * (t + gap), rMid = rOuter - t / 2;
|
|
65
99
|
// an off-centre stack: the rings share their top edge's tangent, slid toward it by the offset
|
|
@@ -67,9 +101,18 @@ export function build(params) {
|
|
|
67
101
|
let ring = p.shape && p.shape !== 'circle' ? ringOf(p.shape, BOX.cx, cy, rOuter, t) : annulus(BOX.cx, cy, rMid, t);
|
|
68
102
|
// gaps lined up through every ring read as a sign (three: a peace sign or a car badge; four: a crosshair), so with
|
|
69
103
|
// two or more gaps a ring always turns at least 14° from the one outside it
|
|
70
|
-
const step =
|
|
71
|
-
|
|
72
|
-
|
|
104
|
+
const step = minTurn(p);
|
|
105
|
+
// round an open centre the innermost band is a solid disc: two gaps cut it into two sectors meeting in a point (or, opposite,
|
|
106
|
+
// into the halves of a slashed circle), so a disc takes one gap, a slot to its middle
|
|
107
|
+
const solid = rOuter - t < GAP; // (a dot centre's own disc is never cut; this only guards a very heavy setting)
|
|
108
|
+
// in a round body the innermost ring broken once is a C in a ring, the copyright sign (or, mirrored, copyleft): it takes
|
|
109
|
+
// two gaps instead, 150° apart (never opposite, so never a slash)
|
|
110
|
+
const round = !p.shape || p.shape === 'circle';
|
|
111
|
+
// (too small for two pieces that both read, the short one a crumb, it closes into a plain ring)
|
|
112
|
+
const two = rMid * ((150 * Math.PI) / 180) - GAP * p.gapSize >= GAP * 4;
|
|
113
|
+
const cuts = solid ? Math.min(1, p.gaps) : round && k === p.count - 1 && p.gaps === 1 ? (two ? 2 : 0) : p.gaps;
|
|
114
|
+
for (let g = 0; g < cuts; g++) {
|
|
115
|
+
const a = step * k + gapAt(cuts, g);
|
|
73
116
|
ring = D(ring, p.breakKind === 'step' && t >= GAP * 3 ? gapCut('step', BOX.cx, cy, R, GAP * p.gapSize, a, t, rMid) : rot(rect(BOX.cx - (GAP * p.gapSize) / 2, cy - R - 10, GAP * p.gapSize, R + 10), a, BOX.cx, cy));
|
|
74
117
|
}
|
|
75
118
|
parts.push(ring);
|
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,18 +12,22 @@ 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 } },
|
|
21
22
|
tiles: { grid: R(2, 3), density: R(0.72, 1), symmetry: of('mirror', 'both', 'turn') },
|
|
22
23
|
route: { tracks: R(1, 1), steps: R(2, 3), weight: R(0.14, 0.2), node: of('none', 'diamond', 'square'), ends: of('square', 'node'), frame: { rare: 0.12 }, turns: { rare: 0.3 } },
|
|
23
24
|
arcs: { count: R(2, 3), weight: R(0.55, 0.8), core: { rare: 0.3 }, legs: R(0, 0.45), move: { rare: 0.3 }, corner: { rare: 0.35 }, slant: rare(0.1, -15, 15) },
|
|
24
|
-
rings:
|
|
25
|
+
// rings: three to five rings (two, one heavy round a slotted middle, is a dial or a knob; three gaps on few rings, a car
|
|
26
|
+
// badge), every body, gaps that turn
|
|
27
|
+
rings: { count: R(3, 5), weight: R(0.5, 0.72), gaps: R(1, 2), gapSize: R(1.3, 2.6), spin: R(20, 60), centre: of('open', 'open', 'dot'), shape: of('circle', 'circle', 'rounded', 'square', 'chamfer', 'hexagon'), offset: { rare: 0 }, breakKind: { rare: 0.2 } }, // off centre by hand only: shuffled, rings crowd into a crescent
|
|
25
28
|
stripes: { stripes: R(4, 7), weight: R(0.5, 0.75), angle: R(-60, 60), move: of('none', 'shift', 'wave', 'taper', 'slot'), cover: rare(0.25, 0.5, 0.85), ends: { rare: 0.3 } },
|
|
26
|
-
|
|
29
|
+
// the arrowhead (the lead chevron solid) and the stem make an arrow or a download icon: by hand only
|
|
30
|
+
chevrons: { count: R(2, 4), weight: R(0.5, 0.75), angle: R(75, 120), grow: rare(0.3, 0.15, 0.45), move: of('none', 'none', 'none', 'skip') },
|
|
27
31
|
waves: { count: R(2, 4), weight: R(0.55, 0.8), amplitude: R(0.05, 0.13), waves: R(0.75, 1.5), phase: rare(0.15, 30, 180), clip: { rare: 0.35 } },
|
|
28
32
|
cut: { second: { rare: 0.2 } },
|
|
29
33
|
split: { cuts: R(1, 2), twist: rare(0.15, 2, 6), spacing: R(1, 2) },
|
|
@@ -51,7 +55,8 @@ export const TUNING = {
|
|
|
51
55
|
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
56
|
// the composition recipes: the shapes are drawn evenly from their pools (a banned pair is steered in the build)
|
|
53
57
|
merge: { at: R(0.4, 0.6), width: R(0.45, 0.78) },
|
|
54
|
-
|
|
58
|
+
// 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
|
|
59
|
+
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
60
|
counter: { size: R(0.34, 0.5), place: of('centre', 'corner', 'side', 'low', 'high') },
|
|
56
61
|
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
62
|
corners: { reach: R(0.3, 0.5), second: rare(0.4, 0.5, 0.8), shape: of('square', 'square', 'square', 'wide', 'tall') },
|