@logomarks/generate 0.4.0 → 0.4.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 +61 -0
- package/README.md +16 -5
- package/package.json +1 -1
- package/src/generate.js +20 -2
- package/src/index.d.ts +6 -0
- package/src/index.js +1 -1
- package/src/presets.js +3 -1
- package/src/primitives.js +2 -2
- package/src/recipes/bars.js +2 -0
- package/src/recipes/chevrons.js +11 -1
- package/src/recipes/counter.js +12 -2
- package/src/recipes/cut.js +5 -0
- package/src/recipes/halfsq.js +4 -1
- package/src/recipes/invert.js +6 -1
- package/src/recipes/leaves.js +38 -3
- package/src/recipes/mirror.js +86 -21
- package/src/recipes/ribbon.js +132 -30
- package/src/recipes/rings.js +6 -3
- package/src/recipes/seam.js +5 -2
- package/src/recipes/shear.js +4 -1
- package/src/recipes/split.js +4 -1
- package/src/recipes/tiles.js +8 -1
- package/src/recipes/trine.js +7 -2
- package/src/recipes/turns.js +7 -0
- package/src/tuning.js +47 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,66 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
## 0.4.2 (2026-11-27)
|
|
5
|
+
|
|
6
|
+
- **Mirror:** four-way emblems are now most of a shuffle (34 of 47, from 16): `shuffled()` holds a recipe's `HOLD` keys
|
|
7
|
+
(new export; Mirror's `symmetry`, Ribbon's `path`) from the first try across the rest, so the best-of picks within one
|
|
8
|
+
form instead of always picking the two-way emblem, which scores higher. Shuffles also leave the centre empty and cut
|
|
9
|
+
the bands out of the body more often. 22 distinct in 130 (from 15); every draw still under 0.65 against R19 (default
|
|
10
|
+
and 200 shuffles: 0.627).
|
|
11
|
+
- **Ribbon:** every figure can be drawn as two bands side by side (`lanes: 'two'`), their turns concentric, the gap
|
|
12
|
+
between them the line; round ends split into two rounded corners (never one hairpin end: a paperclip). Shuffles draw
|
|
13
|
+
two bands about half the time. 25 distinct in 130 (from 18). A twisted strap (`path: 'twist'`) is by hand only. Tried
|
|
14
|
+
and dropped: a loop round a square or a hexagon with its ends crossing over and under (an ð, a key ring).
|
|
15
|
+
- **Seam:** a corner joint in a disc is a pie chart at any turn; it draws in a rounded square instead.
|
|
16
|
+
- **Banned reads found in the mix:** Turns never draws six pointed units (triangles, kites, diamonds, chevrons, blades,
|
|
17
|
+
parallelograms, quarters) round a centre: they resolve into a hexagram, the Star of David; six becomes five, and pointed
|
|
18
|
+
units are never fused (a solid star). Cut never takes a wedge, a corner or a notch out of a circle (Pac-Man); it cuts
|
|
19
|
+
a slim slot, off centre. Chevrons: one hard chevron
|
|
20
|
+
alone is an arrow head, so it draws as two, a skip never leaves one, a lone soft chevron (R21) points up or down, and
|
|
21
|
+
shuffles point only up or down (sideways stacks are fast-forward).
|
|
22
|
+
- **A sweep of every recipe** (24 shuffles of each of the 55 and four mixes of 96, viewed): ruled out by construction —
|
|
23
|
+
Rings: the innermost ring never broken once in any body (©); in a round body it is left out, the centre open (broken,
|
|
24
|
+
two arcs chasing round a centre are the refresh icon; whole inside broken rings, a target). Leaves: any tiling whose gap reads as a plus (a cross) or whose points ring a
|
|
25
|
+
four-pointed star (the AI sparkle) is measured on the drawing (`plusRead`) and turned another way. Turns: four pills,
|
|
26
|
+
squares, circles, arches or halves meet on the axes in a plus, so four becomes five. Counter: a half or a quarter disc
|
|
27
|
+
(a lens) takes a square, quarter or half hole off its middle (an eye). Cut: a circle takes only a slot or an arc,
|
|
28
|
+
square to its side (Pac-Man, a pie, a knob). Invert: a circle swaps a band only, and shuffles draw no circle (no entry,
|
|
29
|
+
©, Pac-Man, a pie). Split: a disc is cut at least twice, the cuts kept inside (a slashed circle). Trine: in a disc the
|
|
30
|
+
slits stay near the centre and nearly even. Chevrons: no plain stack of fewer than three without a body (show more).
|
|
31
|
+
Bars: three bars arched are a plus; they rise. Halves: two by two never in facing rows (fast forward). Shear: two rows
|
|
32
|
+
never lean against each other (<< >>). Tiles: no three-by-three layout that is a plus or a face. Stack: a diamond or a
|
|
33
|
+
triangle on a square (a house), a diamond on a triangle (an arrow), a triangle on a half (a pin), a half over a leaf (a
|
|
34
|
+
person). Merge: a quarter with a half, a wedge or a leaf (a pie chart), a half with a leaf (Pac-Man); a half keeps a square, a
|
|
35
|
+
rounded square or a wedge.
|
|
36
|
+
|
|
37
|
+
## 0.4.1 (2026-11-27)
|
|
38
|
+
|
|
39
|
+
- **Safe turns.** `TURNS` gives each of the 55 recipes the turns and mirror a shuffle may apply, and about one shuffle in
|
|
40
|
+
three (`TURN_SHARE`) now turns or mirrors its mark by them, through the existing Turn and Mirror finish controls (so
|
|
41
|
+
nothing new shows, and saved settings keep working). Every mark is refitted, so the grid holds; the lists keep out the
|
|
42
|
+
turns that change what a mark reads as. No turns: letter, mosaic, horizon, chevrons and notch (arrows, a play button),
|
|
43
|
+
iso (its light), arcs (upside down, a magnet), and rings, burst, bloom, loops, nodes, turns (the same every quarter
|
|
44
|
+
turn). Mirror only: stack, bars and shear (on their side, a menu icon), leaves, trine. Steps a half turn only (on their
|
|
45
|
+
side, signal bars) and ribbon a half turn only (its wave on its side is an S), flare no half turn (from a foot, turned
|
|
46
|
+
over, a rising sun). Two presets added (Creased ribbon, Four-way emblem; 47), Slotted ribbon now a step. A locked Turn or Mirror stays; with
|
|
47
|
+
`finish: true` a drawn turn outside the list falls back to none. Of 48 shuffles of each of the 42 recipes that gained
|
|
48
|
+
turns, the marks that look different as drawn went from 691 to 802. (The house similarity measure folds turns and
|
|
49
|
+
mirrors together, so distinct-per-130 by it doesn't move.)
|
|
50
|
+
- **Ribbon, widened** (it gave only N and Z): figures `step`, `stairs` (two steps), `flight` (three) and `wave` (one
|
|
51
|
+
swing); turns round or creased (folded flat, a mitre opened by the gap; `turns`); slots none, one or two (`slots`);
|
|
52
|
+
ends cut by the box, round or angled (`ends`); a slant (`slant`); the middle run's place (`reach`). Shuffles draw only
|
|
53
|
+
`SHUFFLE_FIGURES`; n, z, hook and hairpin stay by hand. Drawn and dropped from sheets: a loop over itself (a P), a
|
|
54
|
+
square spiral (an a), a frame round a square (a Q) or a triangle (a muddle), a serpent of upright runs (n, N, M), a
|
|
55
|
+
pleat of level runs (2, 3), two wave swings (an M), a hairpin stepping out (ru). Distinct per 130 shuffles: 4 → 17.
|
|
56
|
+
- **Mirror, widened** (it was one emblem): `symmetry` two or four ways (bands from all four sides, each kept to its
|
|
57
|
+
quarter, a gap along the diagonals), `bands` one to three a side, `centre` the meeting bands, a diamond, a square or
|
|
58
|
+
none, `ground` ink or cut out of a solid body with a rim, bodies octagon and (four ways) disc added. Two ways a centre
|
|
59
|
+
piece draws the meeting bands instead (between bands above and below it is a face), with nothing between the slots are
|
|
60
|
+
always cut out of a hexagon or octagon (loose arcs are lips; in a rounded square, a screen), and no round body (the
|
|
61
|
+
reference). Settings saved under 0.4.0 draw the same bytes. Every hand setting scores under 0.65 against R19 (a test
|
|
62
|
+
over the whole choice grid); the default and 200 shuffles top out at 0.631. Distinct per 130 shuffles: 2 → 17.
|
|
63
|
+
|
|
3
64
|
## 0.4.0 (2026-11-27)
|
|
4
65
|
|
|
5
66
|
The owner's reference styles, from the coverage audit of his 23 references (`drop68-brief.md` in the site repo): 55
|
package/README.md
CHANGED
|
@@ -15,6 +15,11 @@ A shuffle is curated, not uniform: each recipe's `TUNING` keeps random draws to
|
|
|
15
15
|
keeping and makes one move at a time (`random`, `rare` on a control; a hand still has every slider's whole range);
|
|
16
16
|
`shuffled()` keeps the best of a few draws by `qualityOf()` (ink, pieces, thin parts, thin gaps, balance, a calm
|
|
17
17
|
outline), and `mix()` weights the strongest recipes (`MIX_WEIGHT`). `MAIN` names the controls a page shows first.
|
|
18
|
+
`TURNS` gives each recipe the turns and mirror that keep its marks what they are: about one shuffle in three turns or
|
|
19
|
+
mirrors a mark by it (`TURN_SHARE`), never outside it, and a locked Turn or Mirror stays. Letters, the sun, chevrons
|
|
20
|
+
(arrows), arcs (a magnet), bars and shear (a menu icon) and the styles already the same every quarter turn never turn.
|
|
21
|
+
`HOLD` names keys a shuffle draws once and holds across its tries, so its best-of picks within one form (Mirror's
|
|
22
|
+
symmetry: otherwise the higher-scoring two-way emblem always won; Ribbon's fold).
|
|
18
23
|
|
|
19
24
|
## Install
|
|
20
25
|
|
|
@@ -91,11 +96,17 @@ in the build (and tested on 200 shuffles):
|
|
|
91
96
|
soft neck, every join a concave fillet (a smooth union of distance fields); never a centre disc (a face, a figure),
|
|
92
97
|
never three nodes (a fidget spinner, near the biohazard sign) or six (a cog).
|
|
93
98
|
- `xband`: an X of two bent bands meeting a gap apart; never two straight bars crossing (a close icon).
|
|
94
|
-
- `mirror`: a bold
|
|
95
|
-
meeting in the middle
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
- `mirror`: a family of bold symmetric emblems in few heavy pieces, cut by a body: two ways (one thick band each side
|
|
100
|
+
bowed in, two meeting in the middle) or four ways (bands from all four sides round a diamond, a square or nothing),
|
|
101
|
+
one to three bands each side four ways, the bands as ink or cut out of a solid body with a rim; the body a hexagon on
|
|
102
|
+
its point, a rounded square, an octagon or (four ways) a disc. Two ways never takes a centre piece (between bands
|
|
103
|
+
above and below it is a face), loose arcs (lips) or a round body (the reference itself). Every setting scores under
|
|
104
|
+
0.65 against the R19 reference by the house outline measure (tests, `tests/fixtures/r19.json`). Shuffles are mostly
|
|
105
|
+
four-way.
|
|
106
|
+
- `ribbon`: one thick band folding back on itself: one, two or three steps or one wave swing, the turns round or creased
|
|
107
|
+
(folded flat: a mitre opened by the gap), none, one or two slots, ends cut by the box, rounded or angled, slanted. N, Z,
|
|
108
|
+
a hook, a hairpin and a twisted strap draw by hand; a shuffle never draws a figure that reads as a letter
|
|
109
|
+
(`SHUFFLE_FIGURES`). Any figure can be two bands side by side (`lanes: 'two'`), their turns concentric.
|
|
99
110
|
- `field`: upright bars broken by one stepped line, the lower parts jogged.
|
|
100
111
|
- `zigzag`: a striped shape broken by a zigzag, one side slid.
|
|
101
112
|
- `halfstripe`: a shape half solid, half bars stepping down; never a diamond (a speaker, a play button).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logomarks/generate",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.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/generate.js
CHANGED
|
@@ -7,6 +7,7 @@ import { RECIPES } from './recipes/index.js';
|
|
|
7
7
|
import { resolve, randomValue } from './controls.js';
|
|
8
8
|
import { rng, seedOf } from './random.js';
|
|
9
9
|
import { problems } from './guard.js';
|
|
10
|
+
import { TURNS, TURN_SHARE, HOLD } from './tuning.js';
|
|
10
11
|
import { fill, thinShareBits } from './raster.js';
|
|
11
12
|
|
|
12
13
|
robust();
|
|
@@ -90,10 +91,15 @@ export function qualityOf(shape) {
|
|
|
90
91
|
* passes. What a Shuffle button and a random grid should call, rather than taking the first draw that passes.
|
|
91
92
|
*/
|
|
92
93
|
export function shuffled(id, seed, { tries = 4, base = {}, locked = [], finish = false } = {}) {
|
|
93
|
-
let best = null;
|
|
94
|
+
let best = null, held = null;
|
|
95
|
+
const hold = (HOLD[id] || []).filter((k) => !locked.includes(k));
|
|
94
96
|
for (let i = 0, s = seedOf(seed); i < tries; i++, s = (s + 1) >>> 0) {
|
|
95
97
|
try {
|
|
96
|
-
|
|
98
|
+
// the recipe's held keys come from the first draw and stay for the rest, so the best of the tries is chosen
|
|
99
|
+
// within one form (Mirror's two- and four-way forms score differently, and the two-way would always win)
|
|
100
|
+
const params = randomParams(id, s, held ? { base: { ...base, ...held }, locked: [...locked, ...hold], finish } : { base, locked, finish });
|
|
101
|
+
if (!held && hold.length) held = Object.fromEntries(hold.map((k) => [k, params[k]]));
|
|
102
|
+
const { shape, g } = draw(id, params);
|
|
97
103
|
if (g.problems.length || !g.svg) continue;
|
|
98
104
|
const quality = qualityOf(shape).score;
|
|
99
105
|
if (!best || quality > best.quality) best = { ...g, seed: s, quality };
|
|
@@ -193,6 +199,18 @@ export function randomParams(id, seed, { base = {}, locked = [], finish = false
|
|
|
193
199
|
const v = randomValue(c, rand); // drawn even when kept, so a seed draws the same construction whatever is locked
|
|
194
200
|
out[c.key] = keep ? base[c.key] : c.group === 'finish' && !finish ? c.value : v;
|
|
195
201
|
}
|
|
202
|
+
// about one shuffle in three turns or mirrors the mark, by the recipe's safe turns (never outside them); a locked Turn
|
|
203
|
+
// or Mirror stays. With `finish`, the turn and mirror drawn above are kept to the safe ones too
|
|
204
|
+
const safe = TURNS[id] || { turns: ['0'], mirror: false }, rt = rng(`${seedOf(seed)}:turn`);
|
|
205
|
+
const roll = rt(), pickTurn = safe.turns[Math.floor(rt() * safe.turns.length)], pickMirror = safe.mirror && rt() < 0.5;
|
|
206
|
+
if (!locked.includes('turn')) {
|
|
207
|
+
if (finish) { if (!safe.turns.includes(String(out.turn))) out.turn = '0'; }
|
|
208
|
+
else if (roll < TURN_SHARE) out.turn = pickTurn;
|
|
209
|
+
}
|
|
210
|
+
if (!locked.includes('mirror')) {
|
|
211
|
+
if (finish) { if (out.mirror && !safe.mirror) out.mirror = false; }
|
|
212
|
+
else if (roll < TURN_SHARE) out.mirror = pickMirror;
|
|
213
|
+
}
|
|
196
214
|
return resolve(r.controls, out);
|
|
197
215
|
}
|
|
198
216
|
|
package/src/index.d.ts
CHANGED
|
@@ -74,6 +74,12 @@ export const MIX_WEIGHT: Record<string, number>;
|
|
|
74
74
|
export const TUNING: Record<string, Record<string, { random?: [number, number] | string[]; rare?: number; value?: number | string | boolean }>>;
|
|
75
75
|
/** Per recipe: the keys of the controls a page shows first. */
|
|
76
76
|
export const MAIN: Record<string, string[]>;
|
|
77
|
+
/** Each recipe's safe turns: the Turn values and whether Mirror is allowed in a shuffle. */
|
|
78
|
+
export const TURNS: Record<string, { turns: ('0' | '90' | '180' | '270')[]; mirror: boolean }>;
|
|
79
|
+
/** The share of shuffles that turn or mirror a mark. */
|
|
80
|
+
export const TURN_SHARE: number;
|
|
81
|
+
/** Keys a shuffle draws once and holds across its tries, so its best-of is chosen within one form (Mirror's symmetry, Ribbon's fold). */
|
|
82
|
+
export const HOLD: Record<string, string[]>;
|
|
77
83
|
/** Every control's default. */
|
|
78
84
|
export function defaults(controls: Control[]): Params;
|
|
79
85
|
/** Every control's value from params, clamped, defaults for missing ones. */
|
package/src/index.js
CHANGED
|
@@ -6,6 +6,6 @@ export { recipe, generate, randomParams, variations, nearby, similar, mix, shuff
|
|
|
6
6
|
export { defaults, resolve, clampTo, randomValue } from './controls.js';
|
|
7
7
|
export { rng, seedOf } from './random.js';
|
|
8
8
|
export { GUARD, problems } from './guard.js';
|
|
9
|
-
export { TUNING, MAIN } from './tuning.js';
|
|
9
|
+
export { TUNING, MAIN, TURNS, TURN_SHARE, HOLD } from './tuning.js';
|
|
10
10
|
export { PRESETS } from './presets.js';
|
|
11
11
|
export { PRIMS, prim, alike, banned, unlike, unlikePair, unlikeTriple, BANNED } from './primitives.js';
|
package/src/presets.js
CHANGED
|
@@ -46,7 +46,9 @@ export const PRESETS = [
|
|
|
46
46
|
{ id: 'soft-nodes', name: 'Soft nodes', recipe: 'nodes', params: { nodes: 4, size: 0.19, hole: 0.3, neck: 0.6 }, note: 'Four soft nodes on the diagonals, joined by necks to a ring round a hole.' },
|
|
47
47
|
{ id: 'bent-x', name: 'Bent X', recipe: 'xband', params: { angle: 48, bend: 'flat', double: false }, note: 'An X of two bent bands meeting a gap apart.' },
|
|
48
48
|
{ id: 'arch-emblem', name: 'Arch emblem', recipe: 'mirror', params: { body: 'hexagon', weight: 0.28 }, note: 'Two heavy bowed bands meeting in the middle, a thick bowl above and below, cut to a hexagon.' },
|
|
49
|
-
{ id: 'slotted-ribbon', name: 'Slotted ribbon', recipe: 'ribbon', params: { path: '
|
|
49
|
+
{ id: 'slotted-ribbon', name: 'Slotted ribbon', recipe: 'ribbon', params: { path: 'step', weight: 0.27 }, note: 'One band stepping across with round turns and a slot.' },
|
|
50
|
+
{ id: 'creased-ribbon', name: 'Creased ribbon', recipe: 'ribbon', params: { path: 'stairs', turns: 'crease', weight: 0.27 }, note: 'One band folded flat twice, each crease a gap along the mitre.' },
|
|
51
|
+
{ id: 'four-way-emblem', name: 'Four-way emblem', recipe: 'mirror', params: { symmetry: 'four', centre: 'diamond', bands: 2, body: 'octagon' }, note: 'Bands pressing in from all four sides round a diamond, cut to an octagon.' },
|
|
50
52
|
{ id: 'woven-ring', name: 'Woven ring', recipe: 'weave', params: { strands: 2, swells: 2, height: 0.5, ring: 'ring' }, note: 'Two curves woven over and under in a ring.' },
|
|
51
53
|
{ id: 'zigzag-disc', name: 'Zigzag disc', recipe: 'zigzag', params: { shape: 'circle', stripes: 5, teeth: 2 }, note: 'A striped disc broken by a zigzag, one side slid.' },
|
|
52
54
|
{ id: 'half-bars', name: 'Half bars', recipe: 'halfstripe', params: { shape: 'hexagon', bars: 4, step: 0.1 }, note: 'A hexagon half solid, half bars stepping down.' },
|
package/src/primitives.js
CHANGED
|
@@ -56,12 +56,12 @@ export const alike = (a, b) => a === b || ALIKE.some(([p, q]) => (p === a && q =
|
|
|
56
56
|
* The pairings each recipe never draws, with the read each avoids. A pair is banned either way round.
|
|
57
57
|
*/
|
|
58
58
|
export const BANNED = {
|
|
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']],
|
|
59
|
+
merge: [['half', 'leaf', 'Pac-Man'], ['quarter', 'leaf', 'a pie chart'], ['quarter', 'wedge', 'a pie chart'], ['quarter', 'half', 'a pie chart'], ['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
61
|
// a triangle hole in any body is a play button (in a half disc or a leaf too, seen in the mix)
|
|
62
62
|
counter: [['half', 'leaf', 'an eye'], ['half', 'wedge', 'a play button'], ['quarter', 'wedge', 'a play button'], ['hexagon', 'wedge', 'a play button'], ['square', 'wedge', 'a play button'], ['half', 'triangle', 'a play button'], ['leaf', 'triangle', 'a play button'], ['pill', 'triangle', 'a play button'], ['quarter', 'triangle', 'a play button'], ['diamond', 'triangle', 'a play button'], ['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']],
|
|
63
63
|
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']],
|
|
64
|
-
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
|
+
stack: [['diamond', 'triangle', 'an arrow'], ['triangle', 'half', 'a pin'], ['diamond', 'square', 'a house'], ['diamond', 'rsquare', 'a house'], ['triangle', 'square', 'a house'], ['triangle', 'rsquare', 'a house'], ['half', 'leaf', 'a person'], ['arch', 'leaf', 'a person'], ['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']],
|
|
65
65
|
offset: [],
|
|
66
66
|
quarters: [],
|
|
67
67
|
};
|
package/src/recipes/bars.js
CHANGED
|
@@ -63,6 +63,8 @@ function cutOf(cut, i, n, at) {
|
|
|
63
63
|
export function build(params) {
|
|
64
64
|
const p = { ...params }, n = p.count;
|
|
65
65
|
if (p.spine === 'bottom' && n === 3 && p.lengths === 'arch') p.lengths = 'equal'; // a trident
|
|
66
|
+
// three bars, the middle one longest, are a plus (a cross): they rise instead
|
|
67
|
+
if (n === 3 && p.lengths === 'arch' && !p.level && p.spine === 'none') p.lengths = 'rising';
|
|
66
68
|
// rising bars on one foot are the signal-strength icon (slanted too), and on a bottom spine a bar chart: they hang
|
|
67
69
|
// from a top spine instead, a stepped comb, whatever their cut or slant
|
|
68
70
|
if (p.lengths === 'rising' && (p.spine === 'none' || p.spine === 'bottom') && !p.level) p.spine = 'top';
|
package/src/recipes/chevrons.js
CHANGED
|
@@ -31,7 +31,17 @@ function chevron(cx, y, half, t, k, tip, solid) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/** The mark for resolved params. */
|
|
34
|
-
export function build(
|
|
34
|
+
export function build(params) {
|
|
35
|
+
const p = { ...params };
|
|
36
|
+
// one hard chevron alone is an arrow head (>, ^): one only as the soft chevron with its slot (R21); sideways a soft one
|
|
37
|
+
// is an arrow too, so it points up or down
|
|
38
|
+
if (p.count === 1 && !p.soft) p.count = 2;
|
|
39
|
+
// skipping the second of two leaves one chevron alone: the same arrow head
|
|
40
|
+
if (p.move === 'skip' && p.count < 3) p.move = 'none';
|
|
41
|
+
// two plain chevrons alone (or three with the middle skipped) are a show-more icon: without a body, three show at least
|
|
42
|
+
// (the lone soft chevron with its slot, R21, is its own mark and stays one)
|
|
43
|
+
if (p.body !== 'hexagon' && !(p.soft && p.count === 1) && p.count - (p.move === 'skip' ? 1 : 0) < 3) { if (p.move === 'skip') p.move = 'none'; p.count = Math.max(3, p.count); }
|
|
44
|
+
if (p.count === 1 && p.soft && (p.point === 'left' || p.point === 'right')) p.point = p.point === 'left' ? 'up' : 'down';
|
|
35
45
|
// a soft chevron opened wide, or a heavy one, rounds into a blob or a heart: soft keeps the opening to 60–100°
|
|
36
46
|
const angle = p.soft ? Math.min(100, Math.max(60, p.angle)) : p.angle;
|
|
37
47
|
const n = p.count, k = Math.tan(((angle / 2) * Math.PI) / 180); // half-width over drop
|
package/src/recipes/counter.js
CHANGED
|
@@ -32,8 +32,18 @@ export const controls = [
|
|
|
32
32
|
export const shapesOf = (p) => [p.body, unlike('counter', p.body, p.hole, HOLES)];
|
|
33
33
|
|
|
34
34
|
/** The mark for resolved params. */
|
|
35
|
-
export function build(
|
|
36
|
-
const
|
|
35
|
+
export function build(params) {
|
|
36
|
+
const p = { ...params };
|
|
37
|
+
// a half or a quarter disc is a lens turned, and a hole in its middle, or any round, almond or diamond hole, is an eye:
|
|
38
|
+
// there the hole sits low or in the corner, a square or a half
|
|
39
|
+
if (p.body === 'half' || p.body === 'quarter') {
|
|
40
|
+
if (p.place === 'centre' || p.place === 'high') p.place = p.body === 'half' ? 'low' : 'corner';
|
|
41
|
+
if (['disc', 'leaf', 'diamond', 'pill', 'hexagon'].includes(p.hole)) p.hole = 'square';
|
|
42
|
+
}
|
|
43
|
+
// (steered within the shapes that are no eye there: a half disc and a square are banned together, so it takes a quarter)
|
|
44
|
+
const lens = p.body === 'half' || p.body === 'quarter';
|
|
45
|
+
const body = p.body, hole = lens ? unlike('counter', p.body, p.hole, ['square', 'quarter', 'half']) : shapesOf(p)[1];
|
|
46
|
+
const { x0, y0, size, cx, cy } = BOX, [mx, my, reach, most] = ROOM[body] || ROOM.square;
|
|
37
47
|
const s = size * Math.min(p.size, most), [dx, dy] = MOVE[p.place] || MOVE.centre;
|
|
38
48
|
const hx = x0 + size * (mx + dx * reach) - s / 2, hy = y0 + size * (my + dy * reach) - s / 2;
|
|
39
49
|
const cut = D(prim(body, [x0, y0, size, size]), prim(hole, [hx, hy, s, s], Number(p.holeTurn) / 90));
|
package/src/recipes/cut.js
CHANGED
|
@@ -64,6 +64,11 @@ function cutShape(p) {
|
|
|
64
64
|
/** The mark for resolved params. */
|
|
65
65
|
export function build(params) {
|
|
66
66
|
const p = { ...params };
|
|
67
|
+
// a wedge, a corner, a notch, a step or a bite taken out of a circle is a mouth (Pac-Man) or a pie chart at any turn: in a
|
|
68
|
+
// circle it is a slim slot instead (or an arc)
|
|
69
|
+
if (p.body === 'circle' && p.cut !== 'slot' && p.cut !== 'arc') { p.cut = 'slot'; if (Math.abs(p.at - 0.5) < 0.2) p.at = p.at < 0.5 ? 0.28 : 0.72; }
|
|
70
|
+
// a slot in a circle on the slant is a knob or a dial's hand: in a circle every cut runs square to its side
|
|
71
|
+
if (p.body === 'circle') p.angle = '0';
|
|
67
72
|
// a centred notch or slot from the top of a circle is the power icon: slide it off centre
|
|
68
73
|
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
74
|
const turn = { top: 0, right: 90, bottom: 180, left: 270 }[p.side];
|
package/src/recipes/halfsq.js
CHANGED
|
@@ -37,7 +37,10 @@ function at(rule, r, c, k, rows, cols) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/** The mark for resolved params. */
|
|
40
|
-
export function build(
|
|
40
|
+
export function build(params) {
|
|
41
|
+
const p = { ...params };
|
|
42
|
+
// two by two, rows of triangles facing one way are fast-forward (or play twice): the zigzag rule there is a checker
|
|
43
|
+
if ((!p.grid || p.grid === '2x2') && (p.rule === 'zigzag' || p.rule === 'rows')) p.rule = 'checker';
|
|
41
44
|
const [cols, rows] = (/^[23]x[23]$/.test(p.grid) ? p.grid : '2x2').split('x').map(Number), k0 = Number(p.facing) / 90 || 0;
|
|
42
45
|
const s = BOX.size / Math.max(cols, rows), x0 = BOX.cx - (cols * s) / 2, y0 = BOX.cy - (rows * s) / 2, h = (GAP * (p.spacing || 1)) / 2;
|
|
43
46
|
const parts = [];
|
package/src/recipes/invert.js
CHANGED
|
@@ -24,7 +24,12 @@ function outline(shape, r) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/** The mark for resolved params. */
|
|
27
|
-
export function build(
|
|
27
|
+
export function build(params) {
|
|
28
|
+
const p = { ...params };
|
|
29
|
+
// rings swapped across a half of a circle leave one straight seam through them: on the slant a no-entry sign, upright a
|
|
30
|
+
// slashed zero
|
|
31
|
+
// and a quarter swapped is a pie chart or Pac-Man, a disc swapped a C in rings (©): in a circle the swap is a band
|
|
32
|
+
if (p.shape === 'circle') p.region = 'band';
|
|
28
33
|
const { cx, cy, size } = BOX, R = size / 2, n = p.count;
|
|
29
34
|
// n rings round an open centre: 2n + 1 steps of ink and ground, the ink `weight` of each pair
|
|
30
35
|
const pair = R / (n + 0.5), t = Math.max(GAP * 1.4, pair * p.weight), parts = [];
|
package/src/recipes/leaves.js
CHANGED
|
@@ -26,7 +26,29 @@ function tile(kind, x, y, s, k) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/** The mark for resolved params. */
|
|
29
|
-
|
|
29
|
+
/** Even-odd: whether (x, y) is in the ink. */
|
|
30
|
+
const inRing = (r, x, y) => { let c = false; for (let i = 0, j = r.length - 1; i < r.length; j = i++) { const [xi, yi] = r[i], [xj, yj] = r[j]; if ((yi > y) !== (yj > y) && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) c = !c; } return c; };
|
|
31
|
+
const inked = (shape, x, y) => shape.some((poly) => inRing(poly[0], x, y) && !poly.slice(1).some((h) => inRing(h, x, y)));
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Whether four tiles read as one solid parted by a plus (a cross) or round a four-pointed star (the AI sparkle): the
|
|
35
|
+
* share of each gap line with ink close on both sides (a plus: most of both lines), or ink along the lines' outer ends
|
|
36
|
+
* with the middle hollow (the tiles' points round a star).
|
|
37
|
+
*/
|
|
38
|
+
export function plusRead(shape, g) {
|
|
39
|
+
const { cx, cy, x0, size } = BOX, d = g / 2 + 4, N = 60;
|
|
40
|
+
let v = 0, h = 0;
|
|
41
|
+
for (let i = 0; i < N; i++) { const t = x0 + (size * (i + 0.5)) / N; if (inked(shape, cx - d, t) && inked(shape, cx + d, t)) v++; if (inked(shape, t, cy - d) && inked(shape, t, cy + d)) h++; }
|
|
42
|
+
if (Math.min(v, h) / N >= 0.55) return 'a plus';
|
|
43
|
+
let o = 0, n = 0;
|
|
44
|
+
for (let i = 0; i < 40; i++) {
|
|
45
|
+
const t = x0 + 8 + i * 2.5;
|
|
46
|
+
for (const [ax, ay, bx, by] of [[cx - d, t, cx + d, t], [cx - d, 512 - t, cx + d, 512 - t], [t, cy - d, t, cy + d], [512 - t, cy - d, 512 - t, cy + d]]) { n++; if (inked(shape, ax, ay) && inked(shape, bx, by)) o++; }
|
|
47
|
+
}
|
|
48
|
+
return o / n >= 0.3 && !inked(shape, cx + size * 0.13, cy + size * 0.13) ? 'a sparkle' : '';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function draw(p) {
|
|
30
52
|
const g = GAP * p.spacing, s = (BOX.size - g) / 2, parts = [];
|
|
31
53
|
// each cell's turn: the square corner to the middle (outward leaves), away from it, round in a pinwheel, by rows
|
|
32
54
|
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];
|
|
@@ -35,8 +57,21 @@ export function build(p) {
|
|
|
35
57
|
const x = BOX.x0 + c * (s + g), y = BOX.y0 + r * (s + g);
|
|
36
58
|
parts.push(rot(tile(p.tile, x, y, s, p.softness), base[i] + Number(p.facing), x + s / 2, y + s / 2));
|
|
37
59
|
});
|
|
38
|
-
|
|
39
|
-
|
|
60
|
+
return { out: U(...parts), g, s };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function build(params) {
|
|
64
|
+
const p = { ...params };
|
|
65
|
+
// four tiles that close into one solid parted by a plus (a disc or a rounded square in four: a cross), or whose points
|
|
66
|
+
// ring a four-pointed star (the AI sparkle), are measured on the drawing and turned another way: the next order that
|
|
67
|
+
// reads as neither (0.4.2; in 0.4.1 only inward leaves and outward quarters were caught, by name)
|
|
68
|
+
let d = draw(p);
|
|
69
|
+
for (const order of ['pinwheel', 'rows', 'same', 'outward', 'inward']) {
|
|
70
|
+
if (!plusRead(d.out, d.g)) break;
|
|
71
|
+
if (order !== p.order) d = draw({ ...p, order });
|
|
72
|
+
}
|
|
73
|
+
let out = d.out;
|
|
74
|
+
if (p.centre === 'disc') { const c = circle(BOX.cx, BOX.cy, d.s * 0.3, 96); out = U(mapClear(out, c, d.g), c); }
|
|
40
75
|
return out;
|
|
41
76
|
}
|
|
42
77
|
|
package/src/recipes/mirror.js
CHANGED
|
@@ -1,43 +1,108 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mirror: a bold
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* Mirror: a family of bold symmetric emblems in few heavy pieces, cut by a body. Symmetric two ways (bands pressing in
|
|
3
|
+
* from above and below) or four ways (from all four sides); one to three bands each side at stepping radii, bowed in;
|
|
4
|
+
* across the middle two bowed bands meeting at the centre, or (four ways) a centre piece (a diamond or a square);
|
|
5
|
+
* the bands as ink, or cut out of a solid body; the body a hexagon on its point, a rounded square, an octagon, or (four
|
|
6
|
+
* ways only) a disc. Cut, the bands are slots in a solid body with a rim.
|
|
7
|
+
* After the arch emblems of the owner's references and kept clear of the one it came from (R19, someone else's logo:
|
|
8
|
+
* under 0.65 by the house outline measure, a test holds it): no end caps, no two-way disc. Always thick bands (thin arcs
|
|
9
|
+
* stacked are a Wi-Fi icon), never a dot (a face), never a bar across the middle (a divide sign; in a lens, a theta or an
|
|
10
|
+
* eye), never bands bowed out round a lens (an eye).
|
|
7
11
|
*/
|
|
8
|
-
import { U, I, arcBand, mapPts, rr, regular } from '@logomarks/core/geometry';
|
|
12
|
+
import { U, D, I, arcBand, mapPts, rr, regular, rot, grow, poly } from '@logomarks/core/geometry';
|
|
9
13
|
import { BOX, GAP, tidy } from '../draw.js';
|
|
10
14
|
|
|
11
15
|
/** @type {import('../index.js').Control[]} */
|
|
12
16
|
export const controls = [
|
|
13
|
-
{ key: 'body', label: 'Body', type: 'choice', options: ['hexagon', 'square'], value: 'hexagon' },
|
|
17
|
+
{ key: 'body', label: 'Body', type: 'choice', options: ['hexagon', 'square', 'octagon', 'disc'], value: 'hexagon' },
|
|
14
18
|
{ key: 'weight', label: 'Weight', type: 'range', min: 0.22, max: 0.34, step: 0.005, value: 0.28 },
|
|
15
19
|
{ key: 'bow', label: 'Middle curve', type: 'range', min: 1, max: 1.8, step: 0.05, value: 1.3 },
|
|
16
20
|
{ key: 'bowl', label: 'Band curve', type: 'range', min: 0.7, max: 1.1, step: 0.01, value: 0.78 },
|
|
21
|
+
{ key: 'symmetry', label: 'Symmetry', type: 'choice', options: ['two', 'four'], value: 'two' },
|
|
22
|
+
{ key: 'bands', label: 'Bands each side', type: 'range', min: 1, max: 3, step: 1, value: 1 },
|
|
23
|
+
{ key: 'centre', label: 'Centre', type: 'choice', options: ['bands', 'diamond', 'square', 'none'], value: 'bands' },
|
|
24
|
+
{ key: 'ground', label: 'Ground', type: 'choice', options: ['ink', 'cut'], value: 'ink' },
|
|
17
25
|
];
|
|
18
26
|
|
|
19
27
|
/** The body, filling the box. */
|
|
20
|
-
function body(kind) {
|
|
28
|
+
function body(kind, four) {
|
|
21
29
|
const { cx, cy, x0, y0, size } = BOX;
|
|
22
|
-
// a hexagon standing on a point
|
|
23
|
-
//
|
|
30
|
+
// a hexagon standing on a point, a rounded square or an octagon; a disc only four ways (two ways, with these bands, the
|
|
31
|
+
// reference itself)
|
|
24
32
|
if (kind === 'hexagon') return regular(cx, cy, size / 2, 6, -90);
|
|
33
|
+
if (kind === 'octagon') return regular(cx, cy, size / 2 / Math.cos(Math.PI / 8), 8, 22.5);
|
|
34
|
+
if (kind === 'disc' && four) return regular(cx, cy, size / 2, 96, 0);
|
|
25
35
|
return rr(x0, y0, size, size, size * 0.2);
|
|
26
36
|
}
|
|
27
37
|
|
|
38
|
+
/**
|
|
39
|
+
* The centre piece, `r` the room it has (a half width): a diamond, or a rounded square on its side. Never a lens: between
|
|
40
|
+
* bands above and below it is an eye.
|
|
41
|
+
*/
|
|
42
|
+
function centrePiece(kind, r) {
|
|
43
|
+
const { cx, cy } = BOX;
|
|
44
|
+
if (kind === 'square') return rr(cx - r * 0.7, cy - r * 0.7, r * 1.4, r * 1.4, r * 0.22);
|
|
45
|
+
return regular(cx, cy, r, 4, 0);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The bands pressing in from above: `n` of them, the innermost `edge` above the centre, each bowed in. */
|
|
49
|
+
function bandsAbove(n, edge, T, bowl, R) {
|
|
50
|
+
const { cx } = BOX, out = [];
|
|
51
|
+
for (let i = 0; i < n; i++) {
|
|
52
|
+
const e = edge - i * (T + GAP), r2 = R * bowl * (1.4 + i * 0.35);
|
|
53
|
+
out.push(arcBand(cx, e - T / 2 - r2, r2, T, 5, 175));
|
|
54
|
+
}
|
|
55
|
+
return out.length > 1 ? U(...out) : out[0];
|
|
56
|
+
}
|
|
57
|
+
|
|
28
58
|
/** The mark for resolved params. */
|
|
29
59
|
export function build(p) {
|
|
30
|
-
const R = BOX.size / 2,
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
60
|
+
const R = BOX.size / 2, { cx, cy } = BOX, four = p.symmetry === 'four';
|
|
61
|
+
// two ways a centre piece between bands above and below is a face (brows, a nose, a mouth), so it takes the bands; the
|
|
62
|
+
// meeting bands take one a side (more stack into lips or a Wi-Fi fan); with nothing between, two or three slots cut in a
|
|
63
|
+
// solid hexagon or octagon (one is a bare smile and frown; in a rounded square they make a screen)
|
|
64
|
+
const centre = four ? p.centre : p.centre === 'none' ? 'none' : 'bands';
|
|
65
|
+
const n = !four && centre === 'bands' ? 1 : !four ? Math.max(2, Math.round(p.bands)) : Math.round(p.bands);
|
|
66
|
+
// more bands each side are thinner, so the gaps keep the house width and nothing crowds
|
|
67
|
+
const T = p.weight * R * (n === 1 ? 1 : n === 2 ? 0.78 : 0.62);
|
|
68
|
+
let middle = [], edge;
|
|
69
|
+
// two ways, slots with nothing between are always cut out of a body (bare arcs are lips)
|
|
70
|
+
const cut = four ? p.ground === 'cut' : centre === 'none' || p.ground === 'cut';
|
|
71
|
+
// two ways the reference's own round silhouette is out: no disc, and no octagon unless the bands are cut out of it
|
|
72
|
+
const kind = four ? p.body : cut ? (p.body === 'square' || p.body === 'disc' ? 'octagon' : p.body) : p.body === 'octagon' || p.body === 'disc' ? 'hexagon' : p.body;
|
|
73
|
+
const b = body(kind, four);
|
|
74
|
+
if (centre === 'bands' && !four) {
|
|
75
|
+
// a band sagging from above and its mirror rising from below, meeting at the centre
|
|
76
|
+
const Rc = R * p.bow;
|
|
77
|
+
middle = arcBand(cx, cy - Rc, Rc, T, 5, 175);
|
|
78
|
+
edge = cy - T / 2 - GAP * 1.5;
|
|
79
|
+
} else {
|
|
80
|
+
// a centre piece (or none): the bands start a gap clear of it
|
|
81
|
+
const room = R * (four ? 0.26 : 0.3) * (centre === 'none' ? 0.6 : 1);
|
|
82
|
+
edge = cy - room - GAP;
|
|
83
|
+
if (centre !== 'none' && centre !== 'bands') middle = centrePiece(centre, room);
|
|
84
|
+
}
|
|
85
|
+
let above = bandsAbove(n, edge, T, p.bowl, R);
|
|
86
|
+
if (!four && centre === 'bands' && n === 1 && p.ground === 'ink') {
|
|
87
|
+
// the 0.4.0 emblem, built in its own order so settings saved then draw the same bytes
|
|
88
|
+
const top = U(middle, above), bottom = mapPts(top, ([x, y]) => [x, 2 * cy - y]);
|
|
89
|
+
return tidy(I(U(top, bottom), b));
|
|
90
|
+
}
|
|
91
|
+
let sides;
|
|
92
|
+
if (four) {
|
|
93
|
+
// the same bands from all four sides, each kept to its quarter (a wedge from the centre), a gap along the diagonals
|
|
94
|
+
const wedge = grow(poly([[cx, cy], [cx - R * 3, cy - R * 3], [cx + R * 3, cy - R * 3]]), -GAP / 2);
|
|
95
|
+
above = I(above, wedge);
|
|
96
|
+
sides = U(above, rot(above, 90, cx, cy), rot(above, 180, cx, cy), rot(above, 270, cx, cy));
|
|
97
|
+
} else {
|
|
98
|
+
const below = mapPts(above, ([x, y]) => [x, 2 * cy - y]);
|
|
99
|
+
sides = U(above, below);
|
|
100
|
+
}
|
|
101
|
+
const art = middle.length ? U(sides, middle) : sides;
|
|
102
|
+
// cut: the bands (and the centre) taken out of a solid body, a rim of the body kept round them
|
|
103
|
+
if (cut) return tidy(D(b, I(art, grow(b, -GAP * 1.6))));
|
|
104
|
+
return tidy(I(art, b));
|
|
40
105
|
}
|
|
41
106
|
|
|
42
|
-
/** Four to
|
|
107
|
+
/** Four to fifteen heavy pieces. */
|
|
43
108
|
export const guard = {};
|
package/src/recipes/ribbon.js
CHANGED
|
@@ -1,26 +1,58 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Ribbon: one thick band that folds back on itself, its turns round,
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Ribbon: one thick band that folds back on itself, its turns round, slots (round-ended gaps) along its runs, its ends
|
|
3
|
+
* cut by the box, rounded or angled. After the folded S of the owner's references, widened into a family: one, two or
|
|
4
|
+
* three steps, a wave of one swing, the turns round or creased (paper folded flat: a mitre opened by the gap), one or
|
|
5
|
+
* two slots or none, the whole slanted, and (0.4.2) any figure as two bands side by side, their turns concentric, or (by
|
|
6
|
+
* hand) a twisted strap. Unlike a plain letter (the dropped Fold, mitred, read as
|
|
7
|
+
* blocky L, U, S): the round turns and the weight are always there, and the figures that read as a letter (N, Z) are by
|
|
8
|
+
* hand only; a shuffle never draws them.
|
|
5
9
|
*/
|
|
6
|
-
import { D, I, rect, stroke, pill,
|
|
7
|
-
import { BOX, GAP, tidy } from '../draw.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
import { D, I, rect, stroke, pill, regular } from '@logomarks/core/geometry';
|
|
11
|
+
import { BOX, GAP, tidy, shear } from '../draw.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The figures, in a unit box (0–1 across and down): the path's corners, the band's weight as a share of the plain one
|
|
15
|
+
* (a figure with more runs side by side needs a thinner band to keep the gaps), and `over`: the run that passes over
|
|
16
|
+
* another ([over, under] run indices), the under run cut by a gap either side of it.
|
|
17
|
+
*/
|
|
18
|
+
const FIGURES = {
|
|
19
|
+
n: { pts: [[0, 1], [0, 0], [1, 1], [1, 0]] },
|
|
20
|
+
z: { pts: [[0, 0], [1, 0], [0, 1], [1, 1]] },
|
|
21
|
+
hook: { pts: [[1, 0], [0.3, 0], [1, 0.85], [0.1, 0.85]] },
|
|
22
|
+
hairpin: { pts: [[0, 1], [0, 0], [1, 1], [1, 0.45]] },
|
|
23
|
+
// a stair of two folds, the runs level and upright, the middle run at `reach`
|
|
24
|
+
step: { pts: [[0, 1], [0, (r) => r], [1, (r) => r], [1, 0]], k: 1 },
|
|
25
|
+
// two steps: down and across twice
|
|
26
|
+
stairs: { pts: [[0, 1], [0, 0.55], [0.5, 0.55], [0.5, 0], [1, 0]], k: 0.8 },
|
|
27
|
+
// a wave: the band swinging across and back, its turns wide and round (`reach` sets how deep)
|
|
28
|
+
wave: { pts: [[0, 0.5], [0.25, (r) => 0.5 - r * 0.5], [0.75, (r) => 0.5 + r * 0.5], [1, 0.5]], k: 0.92, wave: true },
|
|
29
|
+
// three steps, a flight
|
|
30
|
+
flight: { pts: [[0, 1], [0, 0.68], [0.34, 0.68], [0.34, 0.34], [0.68, 0.34], [0.68, 0], [1, 0]], k: 0.62 },
|
|
31
|
+
// a level band with a half twist: two creases across the middle, the slot jumping from one edge to the other
|
|
32
|
+
twist: { twist: true, k: 1 },
|
|
15
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* The figures a shuffle draws: never one whose main read is a letter. Drawn and dropped (2026-11-27, from sheets): a
|
|
36
|
+
* loop over itself (a P), a square spiral (an a), a frame round a square (a Q), one round a triangle (a muddle), a
|
|
37
|
+
* serpent of upright runs (n, N, M), a pleat of level runs (the numerals 2 and 3), a wave of two swings (an M) and a hairpin that steps out (ru).
|
|
38
|
+
* In 0.4.2: a loop round a square or a hexagon with its ends crossing over and under (an ð, a key ring) and the twisted
|
|
39
|
+
* strap (three blocks; by hand only). What a shuffle gained instead: two bands, every figure drawn as a pair.
|
|
40
|
+
*/
|
|
41
|
+
export const SHUFFLE_FIGURES = ['step', 'stairs', 'flight', 'wave'];
|
|
16
42
|
|
|
17
43
|
/** @type {import('../index.js').Control[]} */
|
|
18
44
|
export const controls = [
|
|
19
|
-
{ key: 'path', label: 'Fold', type: 'choice', options: Object.keys(
|
|
45
|
+
{ key: 'path', label: 'Fold', type: 'choice', options: Object.keys(FIGURES), value: 'step' },
|
|
20
46
|
{ key: 'weight', label: 'Weight', type: 'range', min: 0.2, max: 0.34, step: 0.005, value: 0.27 },
|
|
21
47
|
{ key: 'bend', label: 'Turn radius', type: 'range', min: 0.6, max: 1.4, step: 0.05, value: 1 },
|
|
22
48
|
{ key: 'slot', label: 'Slot length', type: 'range', min: 0.35, max: 0.75, step: 0.01, value: 0.55 },
|
|
23
49
|
{ key: 'width', label: 'Width', type: 'range', min: 0.7, max: 1, step: 0.01, value: 0.86 },
|
|
50
|
+
{ key: 'reach', label: 'Reach', type: 'range', min: 0.3, max: 0.7, step: 0.01, value: 0.5 },
|
|
51
|
+
{ key: 'slots', label: 'Slots', type: 'choice', options: ['one', 'two', 'none'], value: 'one' },
|
|
52
|
+
{ key: 'ends', label: 'Ends', type: 'choice', options: ['box', 'round', 'angled'], value: 'box' },
|
|
53
|
+
{ key: 'turns', label: 'Turns', type: 'choice', options: ['round', 'crease'], value: 'round' },
|
|
54
|
+
{ key: 'slant', label: 'Slant', type: 'range', min: -25, max: 25, step: 1, value: 0 },
|
|
55
|
+
{ key: 'lanes', label: 'Bands', type: 'choice', options: ['one', 'two'], value: 'one' },
|
|
24
56
|
];
|
|
25
57
|
|
|
26
58
|
/** A polyline with each inner corner rounded: a circular-ish quadratic `r` back along both legs. */
|
|
@@ -36,26 +68,96 @@ function fillet(pts, r) {
|
|
|
36
68
|
return out;
|
|
37
69
|
}
|
|
38
70
|
|
|
71
|
+
const len = (a, b) => Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
72
|
+
/** A point `d` along from `a` towards `b`. */
|
|
73
|
+
const along = (a, b, d) => { const l = len(a, b) || 1; return [a[0] + ((b[0] - a[0]) * d) / l, a[1] + ((b[1] - a[1]) * d) / l]; };
|
|
74
|
+
|
|
75
|
+
/** A twisted strap: a level band, its middle a parallelogram between two creases, the slot above one side, below the other. */
|
|
76
|
+
function twist(p, T) {
|
|
77
|
+
const { cx, cy } = BOX, W = BOX.size * p.width, h = T, x0 = cx - W / 2, x1 = cx + W / 2;
|
|
78
|
+
// the twist: a short slanted stretch between two creases, the right run dropped by most of a band's height
|
|
79
|
+
const s = T * (0.55 + p.reach * 0.5), drop = h * 0.75, yl = cy - (h + drop) / 2, yr = yl + drop;
|
|
80
|
+
const a0 = cx - s / 2, a1 = cx + s / 2;
|
|
81
|
+
let out = [[[x0, yl], [a0, yl], [a1, yr], [x1, yr], [x1, yr + h], [a1, yr + h], [a0, yl + h], [x0, yl + h]]];
|
|
82
|
+
// the creases: a gap along each end of the slanted stretch, square across the band
|
|
83
|
+
out = D(out, pill([a0, yl - T], [a0, yl + h + T], GAP * 0.9));
|
|
84
|
+
out = D(out, pill([a1, yr - T], [a1, yr + h + T], GAP * 0.9));
|
|
85
|
+
if (p.slots !== 'none') {
|
|
86
|
+
// the slot near the top edge on the left, near the bottom edge on the right: the strap shows its other face
|
|
87
|
+
const lx0 = x0 + T * 0.5, lx1 = a0 - T * 0.5, rx0 = a1 + T * 0.5, rx1 = x1 - T * 0.5;
|
|
88
|
+
if (lx1 - lx0 > GAP * 2) out = D(out, pill([lx0, yl + h * 0.3], [lx1, yl + h * 0.3], GAP));
|
|
89
|
+
if (rx1 - rx0 > GAP * 2) out = D(out, pill([rx0, yr + h * 0.7], [rx1, yr + h * 0.7], GAP));
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
|
|
39
94
|
/** The mark for resolved params. */
|
|
40
95
|
export function build(p) {
|
|
41
|
-
const
|
|
96
|
+
const fig = FIGURES[p.path] || FIGURES.step;
|
|
97
|
+
if (fig.twist) {
|
|
98
|
+
const T = p.weight * BOX.size * 0.85; // a strap, longer than it is tall
|
|
99
|
+
return tidy(p.slant ? shear(twist(p, T), p.slant) : twist(p, T));
|
|
100
|
+
}
|
|
101
|
+
const kW = fig.k ?? 1, two = p.lanes === 'two';
|
|
102
|
+
// two bands side by side are each thinner, so the pair weighs about one band and a gap
|
|
103
|
+
const T = p.weight * BOX.size * kW * (two ? 0.6 : 1), W = BOX.size * p.width - T, H = BOX.size - T;
|
|
42
104
|
const x0 = BOX.cx - W / 2, y0 = BOX.y0 + T / 2;
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
105
|
+
const at = (v) => (typeof v === 'function' ? v(p.reach) : v);
|
|
106
|
+
const unit = fig.pts;
|
|
107
|
+
const pts = unit.map(([u, v]) => [x0 + at(u) * W, y0 + at(v) * H]);
|
|
108
|
+
// creased turns need runs long enough to hold a mitre and its gap; a flight's short runs keep round turns
|
|
109
|
+
const crease = p.turns === 'crease' && !fig.wave && pts.slice(2, -1).every((q, k) => len(pts[k + 1], q) > T * 1.5);
|
|
110
|
+
// the ends: run past the box and cut square by it, or stop short and round, or stop short and cut on the slant
|
|
111
|
+
const ext = (a, b, d) => [b[0] + ((b[0] - a[0]) / len(a, b)) * d, b[1] + ((b[1] - a[1]) / len(a, b)) * d];
|
|
112
|
+
if (p.ends === 'box') { pts[0] = ext(pts[1], pts[0], T); pts[pts.length - 1] = ext(pts.at(-2), pts.at(-1), T); }
|
|
113
|
+
else if (p.ends === 'angled') { pts[0] = ext(pts[1], pts[0], T * 0.5); pts[pts.length - 1] = ext(pts.at(-2), pts.at(-1), T * 0.5); }
|
|
114
|
+
const line = crease && !two ? pts : fillet(pts, T * p.bend * (fig.wave ? 3 : 1) * (two ? 2 : 1));
|
|
115
|
+
// two bands: the pair's outline with the gap's line taken out of it, so the turns stay concentric
|
|
116
|
+
// (the gap's line runs on through the ends, so round ends split into two rounded corners, never one hairpin: a paperclip)
|
|
117
|
+
const through = two ? [ext(line[1], line[0], T + GAP), ...line.slice(1, -1), ext(line.at(-2), line.at(-1), T + GAP)] : line;
|
|
118
|
+
let s = two ? D(stroke(line, T * 2 + GAP, { roundCaps: p.ends === 'round' }), stroke(through, GAP, { roundCaps: false })) : stroke(line, T, { roundCaps: p.ends === 'round' });
|
|
119
|
+
|
|
120
|
+
if (crease && !two) {
|
|
121
|
+
// each corner a crease: the mitre line from the inner corner to the outer one, opened by the gap
|
|
122
|
+
for (let k = 1; k < pts.length - 1; k++) {
|
|
123
|
+
const a = pts[k - 1], v = pts[k], b = pts[k + 1];
|
|
124
|
+
const ua = [(a[0] - v[0]) / len(a, v), (a[1] - v[1]) / len(a, v)], ub = [(b[0] - v[0]) / len(b, v), (b[1] - v[1]) / len(b, v)];
|
|
125
|
+
const bis = [ua[0] + ub[0], ua[1] + ub[1]], bl = Math.hypot(bis[0], bis[1]) || 1, d = (T / 2) * Math.SQRT2 * 1.2;
|
|
126
|
+
const inner = [v[0] + (bis[0] / bl) * d, v[1] + (bis[1] / bl) * d], outer = [v[0] - (bis[0] / bl) * d, v[1] - (bis[1] / bl) * d];
|
|
127
|
+
s = D(s, pill(inner, outer, GAP));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (p.ends === 'angled') {
|
|
131
|
+
// each end sliced at 45° across the band: everything past the line through the tip's middle at 45° goes
|
|
132
|
+
for (const [a, b] of [[pts[1], pts[0]], [pts.at(-2), pts.at(-1)]]) {
|
|
133
|
+
const u = [(b[0] - a[0]) / len(a, b), (b[1] - a[1]) / len(a, b)], n = [-u[1], u[0]], F = T * 2;
|
|
134
|
+
const c = [b[0] - u[0] * T * 0.25, b[1] - u[1] * T * 0.25], l = [u[0] - n[0], u[1] - n[1]], o = [u[0] + n[0], u[1] + n[1]];
|
|
135
|
+
// only near the tip: a fold that comes back close by must not lose a corner to it
|
|
136
|
+
const near = regular(b[0], b[1], T * 0.95, 32, 0);
|
|
137
|
+
s = D(s, I([[[c[0] + l[0] * F, c[1] + l[1] * F], [c[0] - l[0] * F, c[1] - l[1] * F], [c[0] - l[0] * F + o[0] * F, c[1] - l[1] * F + o[1] * F], [c[0] + l[0] * F + o[0] * F, c[1] + l[1] * F + o[1] * F]]], near));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// the slots: round-ended gaps along the longest runs (none, one, or two), each kept to the run's straight middle: an end
|
|
141
|
+
// run counts only up to the box (its extension is cut away), a turn's curve takes `bend` × the weight off each end
|
|
142
|
+
const inBox = ([x, y]) => [Math.min(BOX.x1, Math.max(BOX.x0, x)), Math.min(BOX.y1, Math.max(BOX.y0, y))];
|
|
143
|
+
const runs = [];
|
|
144
|
+
for (let k = 0; k < pts.length - 1; k++) {
|
|
145
|
+
const a = k === 0 ? inBox(pts[0]) : pts[k], b = k === pts.length - 2 ? inBox(pts[k + 1]) : pts[k + 1];
|
|
146
|
+
// a wave is all curve but for the swing's middle, where it crosses straight: there a short slot fits
|
|
147
|
+
const curve = (k === 0 ? 0 : 1) + (k === pts.length - 2 ? 0 : 1), straight = fig.wave ? (k === 1 ? len(a, b) * 0.3 : 0) : len(a, b) - curve * T * p.bend * 0.9 - T * 0.3;
|
|
148
|
+
runs.push([straight, a, b]);
|
|
149
|
+
}
|
|
150
|
+
runs.sort((x, y) => y[0] - x[0]);
|
|
151
|
+
const want = p.slots === 'none' || two ? 0 : p.slots === 'two' ? 2 : 1;
|
|
152
|
+
for (const [straight, a, b] of runs.slice(0, want)) {
|
|
153
|
+
const h = (straight * p.slot) / 2;
|
|
154
|
+
if (h < GAP * 0.6) continue;
|
|
155
|
+
const m = [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];
|
|
156
|
+
s = D(s, pill(along(m, a, h), along(m, b, h), GAP));
|
|
157
|
+
}
|
|
158
|
+
s = I(s, rect(BOX.x0, BOX.y0, BOX.size, BOX.size));
|
|
159
|
+
return tidy(p.slant ? shear(s, p.slant) : s);
|
|
57
160
|
}
|
|
58
161
|
|
|
59
|
-
/** One band
|
|
162
|
+
/** One band: its turns are its only curves. */
|
|
60
163
|
export const guard = {};
|
|
61
|
-
void grow;
|
package/src/recipes/rings.js
CHANGED
|
@@ -105,16 +105,19 @@ export function build(params) {
|
|
|
105
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
106
|
// into the halves of a slashed circle), so a disc takes one gap, a slot to its middle
|
|
107
107
|
const solid = rOuter - t < GAP; // (a dot centre's own disc is never cut; this only guards a very heavy setting)
|
|
108
|
-
//
|
|
109
|
-
//
|
|
108
|
+
// the innermost ring broken once is a C in a ring, the copyright sign (or, mirrored, copyleft), in any body (an octagon
|
|
109
|
+
// or a rounded square too, 0.4.2): it closes. (Two gaps there, the 0.3.2 answer, made two arcs chasing round a
|
|
110
|
+
// centre: the refresh icon, which in a round body any gaps in the innermost ring make, so there it is always whole.)
|
|
110
111
|
const round = !p.shape || p.shape === 'circle';
|
|
111
112
|
// (too small for two pieces that both read, the short one a crumb, it closes into a plain ring)
|
|
112
113
|
const two = rMid * ((150 * Math.PI) / 180) - GAP * p.gapSize >= GAP * 4;
|
|
113
|
-
const cuts = solid ? Math.min(1, p.gaps) :
|
|
114
|
+
const cuts = solid ? Math.min(1, p.gaps) : k === p.count - 1 && (p.gaps === 1 || round) ? 0 : p.gaps;
|
|
114
115
|
for (let g = 0; g < cuts; g++) {
|
|
115
116
|
const a = step * k + gapAt(cuts, g);
|
|
116
117
|
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));
|
|
117
118
|
}
|
|
119
|
+
// a whole innermost ring in a round body, inside broken ones, is a target: there it is left out (the centre opens)
|
|
120
|
+
if (round && cuts === 0 && k === p.count - 1 && p.count > 1 && p.gaps >= 1 && !solid) continue;
|
|
118
121
|
parts.push(ring);
|
|
119
122
|
}
|
|
120
123
|
const inner = R - p.count * (t + gap);
|
package/src/recipes/seam.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Seam: one block parted in two by a single gap-wide seam that jogs on its way across: a step, a square tenon, a
|
|
3
|
-
* dovetail, or a corner taken out as its own piece. The two halves read as fitted together.
|
|
3
|
+
* dovetail, or a corner taken out as its own piece. The two halves read as fitted together. Never a corner joint in a
|
|
4
|
+
* disc: a quarter taken out of a round is a pie chart (it draws in a rounded square instead).
|
|
4
5
|
*/
|
|
5
6
|
import { D, rect, circle, rr, regular, stroke, rot } from '@logomarks/core/geometry';
|
|
6
7
|
import { BOX, GAP, tidy } from '../draw.js';
|
|
@@ -19,7 +20,9 @@ export const controls = [
|
|
|
19
20
|
/** The mark for resolved params: the seam drawn top to bottom, then the whole turned. */
|
|
20
21
|
export function build(p) {
|
|
21
22
|
const { cx, cy, x0, y0, x1, y1, size } = BOX, g = GAP * p.spacing, R = size / 2;
|
|
22
|
-
|
|
23
|
+
// a corner joint in a disc is a pie chart (a quarter taken out of a round), at any turn: it takes the rounded square
|
|
24
|
+
const kind = p.joint === 'corner' && p.body === 'disc' ? 'rounded' : p.body;
|
|
25
|
+
const body = kind === 'rounded' ? rr(x0, y0, size, size, size * 0.2) : kind === 'disc' ? circle(cx, cy, R, 128) : kind === 'hexagon' ? regular(cx, cy, R * 1.06, 6, 0) : rect(x0, y0, size, size);
|
|
23
26
|
const x = x0 + size * p.at, h = (size * p.size) / 2, d = size * p.reach, T = y0 - 40, B = y1 + 40;
|
|
24
27
|
let line;
|
|
25
28
|
if (p.joint === 'step') line = [[x - d / 2, T], [x - d / 2, cy], [x + d / 2, cy], [x + d / 2, B]];
|
package/src/recipes/shear.js
CHANGED
|
@@ -38,7 +38,10 @@ function leanOf(lean, r, c, C) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/** The mark for resolved params. */
|
|
41
|
-
export function build(
|
|
41
|
+
export function build(params) {
|
|
42
|
+
const p = { ...params };
|
|
43
|
+
// two rows leaning opposite ways stack into sideways chevrons, << or >> (rewind, fast forward): they lean one way
|
|
44
|
+
if (p.rows === 2 && p.lean === 'rows') p.lean = 'same';
|
|
42
45
|
const R = p.rows, C = p.cols, g = GAP * p.spacing;
|
|
43
46
|
const cw = (BOX.size - (C - 1) * g) / C, ch = (BOX.size - (R - 1) * g) / R;
|
|
44
47
|
const d = Math.min(cw * 0.55, ch * Math.tan((p.angle * Math.PI) / 180)); // past about half the tile, its tips go needle-thin
|
package/src/recipes/split.js
CHANGED
|
@@ -27,7 +27,10 @@ function whole(kind) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/** The mark for resolved params. */
|
|
30
|
-
export function build(
|
|
30
|
+
export function build(params) {
|
|
31
|
+
const p = { ...params };
|
|
32
|
+
// a disc cut once (or a second cut spread off its edge) is a slashed circle: in a circle two or three cuts, kept inside
|
|
33
|
+
if (p.shape === 'circle') { p.cuts = Math.max(2, p.cuts); p.spread = Math.min(p.spread, p.cuts === 2 ? 0.55 : 0.75); }
|
|
31
34
|
const { cx, cy, size } = BOX, n = p.cuts, g = GAP * p.spacing, s = whole(p.shape), parts = [];
|
|
32
35
|
// the cuts run level in a frame turned `angle`: cut k at offset (k − (n−1)/2) × pitch across the middle
|
|
33
36
|
const pitch = (size * 0.84 * p.spread) / Math.max(1, n), cuts = Array.from({ length: n }, (_, k) => (k - (n - 1) / 2) * pitch);
|
package/src/recipes/tiles.js
CHANGED
|
@@ -28,7 +28,8 @@ function cellOf(p, r, c, rand) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/** The mark for resolved params. */
|
|
31
|
-
export function build(
|
|
31
|
+
export function build(params, tries = 0) {
|
|
32
|
+
const p = { ...params };
|
|
32
33
|
const n = p.grid, g = p.gap ? GAP : 0, c = (BOX.size - (n - 1) * g) / n, rand = rng(`tiles:${p.layout}:${n}:${p.set}`);
|
|
33
34
|
const cells = Array.from({ length: n }, () => Array(n).fill(null));
|
|
34
35
|
for (let r = 0; r < n; r++) for (let k = 0; k < n; k++) cells[r][k] = cellOf(p, r, k, rand);
|
|
@@ -39,6 +40,12 @@ export function build(p) {
|
|
|
39
40
|
}
|
|
40
41
|
for (let r = Math.ceil(n / 2); r < n && p.symmetry === 'both'; r++) for (let k = 0; k < n; k++) { const s = cells[n - 1 - r][k]; cells[r][k] = s && { ...s, flip: s.flip === 'x' ? 'xy' : 'y' }; }
|
|
41
42
|
for (let r = 0; r < n && p.symmetry === 'turn'; r++) for (let k = 0; k < n; k++) if (r * n + k >= Math.ceil((n * n) / 2)) { const s = cells[n - 1 - r][n - 1 - k]; cells[r][k] = s && { type: s.type, turns: s.turns + 2 }; }
|
|
43
|
+
// a layout whose filled cells make a plus (the middle row and column, the corners empty) is a cross; two filled cells
|
|
44
|
+
// over one in the middle below, the rest empty, is a face: the next layout instead (0.4.2)
|
|
45
|
+
const on = (r, k) => !!cells[r]?.[k];
|
|
46
|
+
const plus = n === 3 && on(1, 1) && on(0, 1) && on(1, 0) && on(1, 2) && on(2, 1) && !on(0, 0) && !on(0, 2) && !on(2, 0) && !on(2, 2);
|
|
47
|
+
const face = n === 3 && on(0, 0) && on(0, 2) && !on(0, 1) && (on(2, 1) || on(1, 1)) && !on(2, 0) && !on(2, 2) && !(on(1, 0) && on(1, 2));
|
|
48
|
+
if ((plus || face) && tries < 12) return build({ ...p, layout: (p.layout % 999) + 1 }, tries + 1);
|
|
42
49
|
const parts = [];
|
|
43
50
|
for (let r = 0; r < n; r++) for (let k = 0; k < n; k++) {
|
|
44
51
|
const cell = cells[r][k]; if (!cell) continue;
|
package/src/recipes/trine.js
CHANGED
|
@@ -19,13 +19,18 @@ export const controls = [
|
|
|
19
19
|
];
|
|
20
20
|
|
|
21
21
|
/** The mark for resolved params. */
|
|
22
|
-
export function build(
|
|
22
|
+
export function build(params) {
|
|
23
|
+
const p = { ...params };
|
|
24
|
+
// in a disc, slits far past the centre and short ones leave one long slit across a circle (a slashed sign): there the
|
|
25
|
+
// lines stay near the centre and the three slits nearly even
|
|
26
|
+
const disc = !p.body || p.body === 'disc';
|
|
27
|
+
if (disc) p.offset = Math.min(p.offset, 0.32);
|
|
23
28
|
const { cx, cy, size } = BOX, R = size / 2, g = GAP * p.spacing;
|
|
24
29
|
const body = p.body === 'hexagon' ? regular(cx, cy, R, 6, -90) : p.body === 'triangle' ? regular(cx, cy + R * 0.14, R * 1.16, 3, -90) : p.body === 'square' ? squircle(cx, cy, R, 5) : circle(cx, cy, R, 128);
|
|
25
30
|
// slit i lies along a line that passes the centre at distance o; it comes in from outside the body and stops short
|
|
26
31
|
// of where the next slit's line crosses it, by a share of that run (its depth) and never nearer than a gap and a half
|
|
27
32
|
const o = p.offset * R, k = p.hand === 'left' ? -1 : 1, base = (p.body === 'triangle' ? 30 : 0) + p.spin, meet = o * Math.sqrt(3);
|
|
28
|
-
const depths = p.even ? [1, 1, 1] : [1, 0.74, 0.5];
|
|
33
|
+
const depths = p.even ? [1, 1, 1] : disc ? [1, 0.88, 0.76] : [1, 0.74, 0.5];
|
|
29
34
|
const slits = [];
|
|
30
35
|
for (let i = 0; i < 3; i++) {
|
|
31
36
|
const a = ((base + 120 * i) * Math.PI) / 180, n = [Math.cos(a), Math.sin(a)], t = [-n[1] * k, n[0] * k];
|
package/src/recipes/turns.js
CHANGED
|
@@ -28,6 +28,13 @@ export const controls = [
|
|
|
28
28
|
export function build(params) {
|
|
29
29
|
const p = { ...params };
|
|
30
30
|
if (p.unit === 'blade' && p.count === '4') p.count = '5';
|
|
31
|
+
// four pills (or squares, or circles) turned round a centre meet on the axes in a plus (a cross): five instead
|
|
32
|
+
if (['pill', 'square', 'circle', 'arch', 'half'].includes(p.unit) && p.count === '4') p.count = '5';
|
|
33
|
+
// six pointed units round a centre resolve into a hexagram (two triangles: the Star of David, a religious sign the
|
|
34
|
+
// house bans): six triangles, kites, diamonds, chevrons, blades or wedge-ended units take five (or eight) instead
|
|
35
|
+
if (p.count === '6' && ['triangle', 'kite', 'diamond', 'chevron', 'blade', 'parallelogram', 'quarter'].includes(p.unit)) p.count = '5';
|
|
36
|
+
// pointed units fused round a centre are a solid star (five points too): pointed units keep a gap between them
|
|
37
|
+
if (p.join === 'merge' && ['triangle', 'kite', 'diamond', 'chevron'].includes(p.unit)) p.join = 'gap';
|
|
31
38
|
if (p.unit === 'kite' && p.count === '3' && p.face !== '180' && Math.abs(p.tilt) < 15) p.tilt = p.tilt < 0 ? -15 : 15;
|
|
32
39
|
const n = Number(p.count), s = p.size * BOX.size, w = s * Math.sqrt(p.stretch), h = s / Math.sqrt(p.stretch);
|
|
33
40
|
const cy = BOX.cy - p.radius * BOX.size - h / 2;
|
package/src/tuning.js
CHANGED
|
@@ -27,7 +27,7 @@ export const TUNING = {
|
|
|
27
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
|
|
28
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 } },
|
|
29
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), body: { rare: 0.2 }, soft: { rare: 0.15 }, weight: R(0.5, 0.75), angle: R(75, 120), grow: rare(0.3, 0.15, 0.45), move: of('none', 'none', 'none', 'skip') },
|
|
30
|
+
chevrons: { count: R(2, 4), point: of('up', 'down'), body: { rare: 0.2 }, soft: { rare: 0.15 }, weight: R(0.5, 0.75), angle: R(75, 120), grow: rare(0.3, 0.15, 0.45), move: of('none', 'none', 'none', 'skip') },
|
|
31
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 } },
|
|
32
32
|
cut: { second: { rare: 0.2 } },
|
|
33
33
|
split: { cuts: R(1, 2), twist: rare(0.15, 2, 6), spacing: R(1, 2) },
|
|
@@ -40,8 +40,8 @@ export const TUNING = {
|
|
|
40
40
|
iso: { grid: R(2, 3), height: R(1, 2), density: R(0.5, 1) },
|
|
41
41
|
letter: { build: of('stencil', 'route', 'blocks', 'rails', 'hexfold', 'wedge'), weight: R(0.17, 0.26), slant: rare(0.12, -12, 12), spacing: R(1, 1.6) },
|
|
42
42
|
arcstep: { steps: R(1, 3), weight: R(0.66, 0.86), rise: rare(0.3, 0.7, 1.3), ends: { rare: 0.3 } },
|
|
43
|
-
halfsq: { grid: of('2x2'), rule: of('
|
|
44
|
-
invert: { count: R(1, 3), weight: R(0.5, 0.66), region: of('half', '
|
|
43
|
+
halfsq: { grid: of('2x2'), rule: of('same', 'checker', 'diagonal'), spacing: R(1, 1.3) },
|
|
44
|
+
invert: { count: R(1, 3), weight: R(0.5, 0.66), region: of('half', 'band', 'band'), shape: of('rounded', 'hexagon'), size: R(0.34, 0.5) }, // a circle swapped reads as a sign (©, Pac-Man, a pie, no entry): by hand only, a band
|
|
45
45
|
leaves: { softness: rare(0.3, 0.6, 1), spacing: rare(0.3, 0.8, 1.6), centre: { rare: 0.2 } },
|
|
46
46
|
lobes: { body: of('pebble', 'disc', 'square'), pieces: R(2, 3), cuts: of('tee'), bend: R(0.35, 0.95), balance: R(-0.1, 0.14), angle: R(0, 345), soften: R(0.5, 0.9), spacing: R(1, 1.4) },
|
|
47
47
|
loops: { petals: R(3, 6), weight: R(0.42, 0.56), spread: R(0.9, 1), stretch: rare(0.15, 1, 1.2), centre: of('open', 'open', 'dot') },
|
|
@@ -70,8 +70,8 @@ export const TUNING = {
|
|
|
70
70
|
notch: { depth: R(0.28, 0.42), mouth: R(0.52, 0.74), seat: of('diamond', 'diamond', 'diamond', 'none'), width: R(0.72, 0.98), height: R(0.52, 0.95) },
|
|
71
71
|
nodes: { nodes: R(4, 5), size: R(0.15, 0.22), ring: R(0.12, 0.2), hole: R(0.22, 0.36), neck: R(0.45, 0.85), shape: of('round', 'round', 'square'), sizes: { rare: 0.25 }, spin: R(0, 45) },
|
|
72
72
|
xband: { angle: R(42, 56), weight: R(0.12, 0.17), bend: of('flat', 'flat', 'round'), double: { rare: 0.3 }, waist: R(1.1, 1.8), flat: R(0.1, 0.2) },
|
|
73
|
-
mirror: { body: of('hexagon', 'square'), weight: R(0.24, 0.32), bow: R(1.1, 1.6), bowl: R(0.74, 1) },
|
|
74
|
-
ribbon: { weight: R(0.23, 0.31), bend: R(0.8, 1.2), slot: R(0.45, 0.65), width: R(0.78, 0.92) },
|
|
73
|
+
mirror: { body: of('hexagon', 'square', 'octagon', 'disc'), weight: R(0.24, 0.32), bow: R(1.1, 1.6), bowl: R(0.74, 1), symmetry: of('two', 'four', 'four'), bands: R(1, 3), centre: of('bands', 'diamond', 'square', 'none', 'none'), ground: of('ink', 'cut') },
|
|
74
|
+
ribbon: { path: of('step', 'stairs', 'flight', 'wave'), lanes: of('one', 'two'), weight: R(0.23, 0.31), bend: R(0.8, 1.2), slot: R(0.45, 0.65), width: R(0.78, 0.92), reach: R(0.32, 0.68), slots: of('one', 'one', 'two', 'none'), ends: of('box', 'round'), turns: of('round', 'crease'), slant: rare(0.35, -22, 22) },
|
|
75
75
|
field: { bars: R(6, 9), weight: R(0.58, 0.72), depth: R(0.3, 0.55), slide: R(0.15, 0.35), drop: R(0.4, 1.4) },
|
|
76
76
|
zigzag: { stripes: R(4, 6), weight: R(0.55, 0.7), teeth: R(1, 2), swing: R(0.14, 0.24), at: R(0.4, 0.6), slide: R(0.4, 0.6) },
|
|
77
77
|
halfstripe: { bars: R(3, 5), solid: R(0.44, 0.58), step: R(0.05, 0.14), weight: R(0.5, 0.7) },
|
|
@@ -94,6 +94,47 @@ export const MAIN = {
|
|
|
94
94
|
corners: ['nw', 'ne', 'se', 'sw'],
|
|
95
95
|
offset: ['shape', 'way', 'dir', 'shift'], quarters: ['a', 'b', 'pattern', 'rule'],
|
|
96
96
|
mosaic: ['char', 'tiles', 'parted'], weave: ['strands', 'swells', 'height', 'ring'], notch: ['body', 'depth', 'seat', 'split'], nodes: ['nodes', 'size', 'hole', 'neck'],
|
|
97
|
-
xband: ['angle', 'weight', 'bend', 'double'], mirror: ['
|
|
97
|
+
xband: ['angle', 'weight', 'bend', 'double'], mirror: ['symmetry', 'bands', 'centre', 'body'], ribbon: ['path', 'turns', 'ends', 'slots'], field: ['bars', 'profile', 'slide', 'widths'],
|
|
98
98
|
zigzag: ['shape', 'stripes', 'teeth', 'slide'], halfstripe: ['shape', 'bars', 'step'],
|
|
99
99
|
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Safe turns: the turns and mirror a shuffle may give each recipe's mark, about one shuffle in three (the Turn and Mirror
|
|
103
|
+
* finish controls, so nothing new shows and saved settings keep working). Every mark is refitted after turning, so a turn
|
|
104
|
+
* never breaks the grid; what it can do is change what a mark reads as, so each list is only the turns that keep it what
|
|
105
|
+
* it was, judged from sheets of turned shuffles (2026-11-27). Left without turns:
|
|
106
|
+
* - letters and the sun stay upright: letter, mosaic, horizon;
|
|
107
|
+
* - turned they point, an arrow, a play button or a skip icon: chevrons, notch;
|
|
108
|
+
* - iso keeps its light from one side: iso;
|
|
109
|
+
* - turned they are another sign: bars or slanted bars on their side (a menu icon), arcs upside down (a magnet);
|
|
110
|
+
* - already the same every quarter turn, a turn adds nothing: rings, burst, bloom, loops, nodes, turns.
|
|
111
|
+
* Stack, Bars, Shear, Leaf Tiles and Trine take the mirror only (a stack turned is a figure the other way up; shear on
|
|
112
|
+
* its side is a menu icon; the others are symmetric under quarter turns). Steps and Ribbon take a half turn only (steps on their
|
|
113
|
+
* side are signal bars; a ribbon's wave on its side is an S), Flare no half turn (from a foot, turned over, a rising sun).
|
|
114
|
+
*/
|
|
115
|
+
const Q = { turns: ['0', '90', '180', '270'], mirror: true };
|
|
116
|
+
const HALF = { turns: ['0', '90'], mirror: false };
|
|
117
|
+
const HALF_M = { turns: ['0', '90'], mirror: true };
|
|
118
|
+
const MIRROR = { turns: ['0'], mirror: true };
|
|
119
|
+
const NONE = { turns: ['0'], mirror: false };
|
|
120
|
+
export const TURNS = {
|
|
121
|
+
twin: Q, cut: Q, split: Q, arcstep: Q, seam: Q, bands: Q, stripes: Q, spiral: Q, blades: Q,
|
|
122
|
+
halfsq: Q, quarters: Q, merge: Q, pair: Q, offset: Q, overlap: Q, counter: Q, corners: Q, capsules: Q,
|
|
123
|
+
// steps on their side are signal bars; flare from a foot turned over is a rising sun
|
|
124
|
+
steps: { turns: ['0', '180'], mirror: true }, flare: { turns: ['0', '90', '270'], mirror: true },
|
|
125
|
+
wavecut: Q, halfstripe: Q,
|
|
126
|
+
// a ribbon's wave on its side is an S
|
|
127
|
+
ribbon: { turns: ['0', '180'], mirror: true }, invert: Q, route: Q, bite: Q, lobes: Q, tiles: Q,
|
|
128
|
+
mirror: HALF, xband: HALF, zigzag: HALF_M, field: HALF_M, weave: HALF, hex: HALF, links: HALF_M, strips: HALF_M, waves: HALF_M,
|
|
129
|
+
stack: MIRROR, bars: MIRROR, leaves: MIRROR, trine: MIRROR, shear: MIRROR,
|
|
130
|
+
letter: NONE, mosaic: NONE, horizon: NONE, chevrons: NONE, notch: NONE, iso: NONE, arcs: NONE,
|
|
131
|
+
rings: NONE, burst: NONE, bloom: NONE, loops: NONE, nodes: NONE, turns: NONE,
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Keys a shuffle draws once and holds across its tries (`shuffled()` keeps the best of a few draws by quality; where a
|
|
135
|
+
* recipe's forms score unalike, the best-of would always pick one form). Mirror's symmetry: the two-way emblem outscores
|
|
136
|
+
* the four-way one, so without this two-way won nearly every shuffle.
|
|
137
|
+
*/
|
|
138
|
+
export const HOLD = { mirror: ['symmetry'], ribbon: ['path'] };
|
|
139
|
+
/** How often a shuffle turns or mirrors a mark (of the turns its recipe allows). */
|
|
140
|
+
export const TURN_SHARE = 1 / 3;
|