@logomarks/generate 0.4.1 → 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 +34 -0
- package/README.md +6 -2
- package/package.json +1 -1
- package/src/generate.js +8 -3
- package/src/index.d.ts +2 -0
- package/src/index.js +1 -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/ribbon.js +41 -6
- 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 +11 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
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
|
+
|
|
3
37
|
## 0.4.1 (2026-11-27)
|
|
4
38
|
|
|
5
39
|
- **Safe turns.** `TURNS` gives each of the 55 recipes the turns and mirror a shuffle may apply, and about one shuffle in
|
package/README.md
CHANGED
|
@@ -18,6 +18,8 @@ outline), and `mix()` weights the strongest recipes (`MIX_WEIGHT`). `MAIN` names
|
|
|
18
18
|
`TURNS` gives each recipe the turns and mirror that keep its marks what they are: about one shuffle in three turns or
|
|
19
19
|
mirrors a mark by it (`TURN_SHARE`), never outside it, and a locked Turn or Mirror stays. Letters, the sun, chevrons
|
|
20
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).
|
|
21
23
|
|
|
22
24
|
## Install
|
|
23
25
|
|
|
@@ -99,10 +101,12 @@ in the build (and tested on 200 shuffles):
|
|
|
99
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
|
|
100
102
|
its point, a rounded square, an octagon or (four ways) a disc. Two ways never takes a centre piece (between bands
|
|
101
103
|
above and below it is a face), loose arcs (lips) or a round body (the reference itself). Every setting scores under
|
|
102
|
-
0.65 against the R19 reference by the house outline measure (tests, `tests/fixtures/r19.json`).
|
|
104
|
+
0.65 against the R19 reference by the house outline measure (tests, `tests/fixtures/r19.json`). Shuffles are mostly
|
|
105
|
+
four-way.
|
|
103
106
|
- `ribbon`: one thick band folding back on itself: one, two or three steps or one wave swing, the turns round or creased
|
|
104
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,
|
|
105
|
-
a hook and a
|
|
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.
|
|
106
110
|
- `field`: upright bars broken by one stepped line, the lower parts jogged.
|
|
107
111
|
- `zigzag`: a striped shape broken by a zigzag, one side slid.
|
|
108
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,7 +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 } from './tuning.js';
|
|
10
|
+
import { TURNS, TURN_SHARE, HOLD } from './tuning.js';
|
|
11
11
|
import { fill, thinShareBits } from './raster.js';
|
|
12
12
|
|
|
13
13
|
robust();
|
|
@@ -91,10 +91,15 @@ export function qualityOf(shape) {
|
|
|
91
91
|
* passes. What a Shuffle button and a random grid should call, rather than taking the first draw that passes.
|
|
92
92
|
*/
|
|
93
93
|
export function shuffled(id, seed, { tries = 4, base = {}, locked = [], finish = false } = {}) {
|
|
94
|
-
let best = null;
|
|
94
|
+
let best = null, held = null;
|
|
95
|
+
const hold = (HOLD[id] || []).filter((k) => !locked.includes(k));
|
|
95
96
|
for (let i = 0, s = seedOf(seed); i < tries; i++, s = (s + 1) >>> 0) {
|
|
96
97
|
try {
|
|
97
|
-
|
|
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);
|
|
98
103
|
if (g.problems.length || !g.svg) continue;
|
|
99
104
|
const quality = qualityOf(shape).score;
|
|
100
105
|
if (!best || quality > best.quality) best = { ...g, seed: s, quality };
|
package/src/index.d.ts
CHANGED
|
@@ -78,6 +78,8 @@ export const MAIN: Record<string, string[]>;
|
|
|
78
78
|
export const TURNS: Record<string, { turns: ('0' | '90' | '180' | '270')[]; mirror: boolean }>;
|
|
79
79
|
/** The share of shuffles that turn or mirror a mark. */
|
|
80
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[]>;
|
|
81
83
|
/** Every control's default. */
|
|
82
84
|
export function defaults(controls: Control[]): Params;
|
|
83
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, TURNS, TURN_SHARE } 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/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/ribbon.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Ribbon: one thick band that folds back on itself, its turns round, slots (round-ended gaps) along its runs, its ends
|
|
3
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
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.
|
|
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
|
|
6
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
|
|
7
8
|
* hand only; a shuffle never draws them.
|
|
8
9
|
*/
|
|
@@ -27,11 +28,15 @@ const FIGURES = {
|
|
|
27
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 },
|
|
28
29
|
// three steps, a flight
|
|
29
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 },
|
|
30
33
|
};
|
|
31
34
|
/**
|
|
32
35
|
* The figures a shuffle draws: never one whose main read is a letter. Drawn and dropped (2026-11-27, from sheets): a
|
|
33
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
|
|
34
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.
|
|
35
40
|
*/
|
|
36
41
|
export const SHUFFLE_FIGURES = ['step', 'stairs', 'flight', 'wave'];
|
|
37
42
|
|
|
@@ -47,6 +52,7 @@ export const controls = [
|
|
|
47
52
|
{ key: 'ends', label: 'Ends', type: 'choice', options: ['box', 'round', 'angled'], value: 'box' },
|
|
48
53
|
{ key: 'turns', label: 'Turns', type: 'choice', options: ['round', 'crease'], value: 'round' },
|
|
49
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' },
|
|
50
56
|
];
|
|
51
57
|
|
|
52
58
|
/** A polyline with each inner corner rounded: a circular-ish quadratic `r` back along both legs. */
|
|
@@ -66,11 +72,35 @@ const len = (a, b) => Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
|
66
72
|
/** A point `d` along from `a` towards `b`. */
|
|
67
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]; };
|
|
68
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
|
+
|
|
69
94
|
/** The mark for resolved params. */
|
|
70
95
|
export function build(p) {
|
|
71
96
|
const fig = FIGURES[p.path] || FIGURES.step;
|
|
72
|
-
|
|
73
|
-
|
|
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;
|
|
74
104
|
const x0 = BOX.cx - W / 2, y0 = BOX.y0 + T / 2;
|
|
75
105
|
const at = (v) => (typeof v === 'function' ? v(p.reach) : v);
|
|
76
106
|
const unit = fig.pts;
|
|
@@ -81,8 +111,13 @@ export function build(p) {
|
|
|
81
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];
|
|
82
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); }
|
|
83
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); }
|
|
84
|
-
|
|
85
|
-
|
|
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) {
|
|
86
121
|
// each corner a crease: the mitre line from the inner corner to the outer one, opened by the gap
|
|
87
122
|
for (let k = 1; k < pts.length - 1; k++) {
|
|
88
123
|
const a = pts[k - 1], v = pts[k], b = pts[k + 1];
|
|
@@ -113,7 +148,7 @@ export function build(p) {
|
|
|
113
148
|
runs.push([straight, a, b]);
|
|
114
149
|
}
|
|
115
150
|
runs.sort((x, y) => y[0] - x[0]);
|
|
116
|
-
const want = p.slots === 'none' ? 0 : p.slots === 'two' ? 2 : 1;
|
|
151
|
+
const want = p.slots === 'none' || two ? 0 : p.slots === 'two' ? 2 : 1;
|
|
117
152
|
for (const [straight, a, b] of runs.slice(0, want)) {
|
|
118
153
|
const h = (straight * p.slot) / 2;
|
|
119
154
|
if (h < GAP * 0.6) continue;
|
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', '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'), ground: of('ink', '
|
|
74
|
-
ribbon: { path: of('step', 'stairs', 'flight', 'wave'), 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) },
|
|
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) },
|
|
@@ -130,5 +130,11 @@ export const TURNS = {
|
|
|
130
130
|
letter: NONE, mosaic: NONE, horizon: NONE, chevrons: NONE, notch: NONE, iso: NONE, arcs: NONE,
|
|
131
131
|
rings: NONE, burst: NONE, bloom: NONE, loops: NONE, nodes: NONE, turns: NONE,
|
|
132
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'] };
|
|
133
139
|
/** How often a shuffle turns or mirrors a mark (of the turns its recipe allows). */
|
|
134
140
|
export const TURN_SHARE = 1 / 3;
|