@logomarks/generate 0.3.2 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/README.md +35 -0
- package/package.json +1 -1
- package/src/finish.js +19 -9
- package/src/generate.js +14 -1
- package/src/guard.js +3 -1
- package/src/index.d.ts +8 -3
- package/src/index.js +1 -1
- package/src/presets.js +12 -0
- package/src/primitives.js +2 -1
- package/src/recipes/burst.js +26 -5
- package/src/recipes/chevrons.js +25 -7
- package/src/recipes/field.js +46 -0
- package/src/recipes/halfstripe.js +43 -0
- package/src/recipes/index.js +20 -0
- package/src/recipes/letter.js +49 -3
- package/src/recipes/mirror.js +108 -0
- package/src/recipes/mosaic.js +106 -0
- package/src/recipes/nodes.js +41 -0
- package/src/recipes/notch.js +47 -0
- package/src/recipes/ribbon.js +128 -0
- package/src/recipes/route.js +47 -3
- package/src/recipes/weave.js +58 -0
- package/src/recipes/xband.js +55 -0
- package/src/recipes/zigzag.js +42 -0
- package/src/tuning.js +55 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,67 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.1 (2026-11-27)
|
|
4
|
+
|
|
5
|
+
- **Safe turns.** `TURNS` gives each of the 55 recipes the turns and mirror a shuffle may apply, and about one shuffle in
|
|
6
|
+
three (`TURN_SHARE`) now turns or mirrors its mark by them, through the existing Turn and Mirror finish controls (so
|
|
7
|
+
nothing new shows, and saved settings keep working). Every mark is refitted, so the grid holds; the lists keep out the
|
|
8
|
+
turns that change what a mark reads as. No turns: letter, mosaic, horizon, chevrons and notch (arrows, a play button),
|
|
9
|
+
iso (its light), arcs (upside down, a magnet), and rings, burst, bloom, loops, nodes, turns (the same every quarter
|
|
10
|
+
turn). Mirror only: stack, bars and shear (on their side, a menu icon), leaves, trine. Steps a half turn only (on their
|
|
11
|
+
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
|
|
12
|
+
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
|
|
13
|
+
`finish: true` a drawn turn outside the list falls back to none. Of 48 shuffles of each of the 42 recipes that gained
|
|
14
|
+
turns, the marks that look different as drawn went from 691 to 802. (The house similarity measure folds turns and
|
|
15
|
+
mirrors together, so distinct-per-130 by it doesn't move.)
|
|
16
|
+
- **Ribbon, widened** (it gave only N and Z): figures `step`, `stairs` (two steps), `flight` (three) and `wave` (one
|
|
17
|
+
swing); turns round or creased (folded flat, a mitre opened by the gap; `turns`); slots none, one or two (`slots`);
|
|
18
|
+
ends cut by the box, round or angled (`ends`); a slant (`slant`); the middle run's place (`reach`). Shuffles draw only
|
|
19
|
+
`SHUFFLE_FIGURES`; n, z, hook and hairpin stay by hand. Drawn and dropped from sheets: a loop over itself (a P), a
|
|
20
|
+
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
|
|
21
|
+
pleat of level runs (2, 3), two wave swings (an M), a hairpin stepping out (ru). Distinct per 130 shuffles: 4 → 17.
|
|
22
|
+
- **Mirror, widened** (it was one emblem): `symmetry` two or four ways (bands from all four sides, each kept to its
|
|
23
|
+
quarter, a gap along the diagonals), `bands` one to three a side, `centre` the meeting bands, a diamond, a square or
|
|
24
|
+
none, `ground` ink or cut out of a solid body with a rim, bodies octagon and (four ways) disc added. Two ways a centre
|
|
25
|
+
piece draws the meeting bands instead (between bands above and below it is a face), with nothing between the slots are
|
|
26
|
+
always cut out of a hexagon or octagon (loose arcs are lips; in a rounded square, a screen), and no round body (the
|
|
27
|
+
reference). Settings saved under 0.4.0 draw the same bytes. Every hand setting scores under 0.65 against R19 (a test
|
|
28
|
+
over the whole choice grid); the default and 200 shuffles top out at 0.631. Distinct per 130 shuffles: 2 → 17.
|
|
29
|
+
|
|
30
|
+
## 0.4.0 (2026-11-27)
|
|
31
|
+
|
|
32
|
+
The owner's reference styles, from the coverage audit of his 23 references (`drop68-brief.md` in the site repo): 55
|
|
33
|
+
recipes, eleven rows of five in a picker.
|
|
34
|
+
- Ten new recipes: `mosaic` (a capital on a coarse grid of tiles, R1), `weave` (curves woven over and under in a ring,
|
|
35
|
+
R2), `notch` (a block with a chevron notch and a seated diamond, R3), `nodes` (soft nodes round a ring, R10), `xband` (an X of two bent bands, R17), `mirror` (a heavy two-way emblem, R19), `ribbon`
|
|
36
|
+
(one band folding back with round turns and a slot, R23), `field` (bars broken by one stepped line, R7), `zigzag` (a
|
|
37
|
+
striped shape broken by a zigzag, R8) and `halfstripe` (half solid, half stepped bars, R18). `nodes`, `weave` and
|
|
38
|
+
`xband` are drawn as distance fields and traced (`@logomarks/core/sdf`): a smooth union gives the concave fillets, and
|
|
39
|
+
it is about twenty times faster than offsetting.
|
|
40
|
+
- Modes: `burst` `ray: 'flare'` and `move: 'slash'` (R6; `slashAngle`, eight rays or more, even: odd, a ray runs along
|
|
41
|
+
the slash; six with a rod is the star of life); `chevrons` `body: 'hexagon'` (R13) and `soft` (R21; `count` now from
|
|
42
|
+
1); `route` `body: 'cube'` (R12); `letter` builds `wedge` (R11, R20), `cut` (R5), `rails` (R15), `hexfold` (R9) and
|
|
43
|
+
`quarter` (R22, the Mosaic grid in quarter discs); the finish `containerMode: 'frame'` and `accentShape: 'square'` (R4).
|
|
44
|
+
- `nodes` is four or five nodes round a ring, each joined to it by a soft neck, never a centre disc: a first build (four
|
|
45
|
+
nodes joined in arches round a centre disc) read as a face, a figure with arms or a phone handset. `mirror` is few
|
|
46
|
+
heavy pieces (two bowed bands meeting in the middle, one thick band above and below bowed in, cut to a hexagon on its
|
|
47
|
+
point or a rounded square, no caps; bowed out it closed into an eye, and in a disc it was the reference again): a first build stacked thin concentric arcs, two Wi-Fi icons facing
|
|
48
|
+
each other, with pill caps that made a face; a second, with tombstone ends in a disc, came too close to the R19
|
|
49
|
+
reference (17 of 31 draws scored 0.73–0.76 by the house outline measure). Now the default and 200 shuffles score at
|
|
50
|
+
most 0.631 against every reference (the band curve's range starts at 0.7: tighter, it neared R19; any setting by hand
|
|
51
|
+
stays under 0.641), and a test holds the shuffles under 0.65 (`tests/fixtures/r19.json`, R19's signature).
|
|
52
|
+
- Bans by construction, tested on 200 shuffles: no triangle seat in a notch, no diamond in a half stripe, nodes four or
|
|
53
|
+
five round a ring and one piece (a node left apart is a loading spinner), one-swell weaves never, M, N and W mosaics by
|
|
54
|
+
hand only, a slash never level, upright or along a ray, a mirror cap shorter than one and a half times its width left
|
|
55
|
+
out (a dot).
|
|
56
|
+
- Fixed: a container whose mark was knocked out or clipped to almost nothing (a hole of a crumb in a disc or hexagon)
|
|
57
|
+
passed the guard; one piece whose holes are under 4% of it is now 'too plain'. And `shuffled(…, { locked: ['char'],
|
|
58
|
+
finish: true })` holds the letter (tested; the audit's draw had passed `base` without `locked`).
|
|
59
|
+
- Nine presets (45).
|
|
60
|
+
- `counter`: a triangle or a wedge hole in any body is steered away (in a half disc, seen in a mix, it was a play button),
|
|
61
|
+
and so is a leaf in a half disc (an eye; the 0.3.2 note allowed it there).
|
|
62
|
+
- `chevrons` soft keeps its opening to 60–100°, its band under a quarter of the box and its tip pointed (wide or heavy,
|
|
63
|
+
it rounded into a blob or a heart; notched, into two loose bars).
|
|
64
|
+
|
|
3
65
|
## 0.3.2 (2026-11-27)
|
|
4
66
|
|
|
5
67
|
Icon reads ruled out by construction, after the owner's sweep of the mix (a ring with a slash, a feed icon):
|
package/README.md
CHANGED
|
@@ -15,6 +15,9 @@ 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.
|
|
18
21
|
|
|
19
22
|
## Install
|
|
20
23
|
|
|
@@ -77,3 +80,35 @@ sliver is never knocked out.
|
|
|
77
80
|
| `corners` | one block, each corner square, rounded, cut, scooped or notched (never a cross, a star or an arrow) |
|
|
78
81
|
| `offset` | a shape and its copy slid aside: a hard shadow, the overlap knocked out or kept |
|
|
79
82
|
| `quarters` | four big cells, each a different shape, turned by one rule; never a plus-shaped gap |
|
|
83
|
+
|
|
84
|
+
## The reference styles (0.4.0)
|
|
85
|
+
|
|
86
|
+
Ten recipes and a set of modes, each after a style in the owner's 2026-11-27 references, with its bad reads ruled out
|
|
87
|
+
in the build (and tested on 200 shuffles):
|
|
88
|
+
|
|
89
|
+
- `mosaic`: a capital on a coarse grid (three wide, five tall), each cell a square, a half-square triangle or a quarter
|
|
90
|
+
disc; `tiles` mixed (a square stem, round bowls), round, angled or alternate. M, N and W are by hand only.
|
|
91
|
+
- `weave`: two curves woven over and under in a ring (or three, bare); never one swell (an eye in a ring).
|
|
92
|
+
- `notch`: a block with a chevron notch and a diamond seated in it; the seat is never a triangle (a play button).
|
|
93
|
+
- `nodes`: four or five round nodes at even turns round a ring (a round or rounded-square hole), each joined to it by a
|
|
94
|
+
soft neck, every join a concave fillet (a smooth union of distance fields); never a centre disc (a face, a figure),
|
|
95
|
+
never three nodes (a fidget spinner, near the biohazard sign) or six (a cog).
|
|
96
|
+
- `xband`: an X of two bent bands meeting a gap apart; never two straight bars crossing (a close icon).
|
|
97
|
+
- `mirror`: a family of bold symmetric emblems in few heavy pieces, cut by a body: two ways (one thick band each side
|
|
98
|
+
bowed in, two meeting in the middle) or four ways (bands from all four sides round a diamond, a square or nothing),
|
|
99
|
+
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
|
+
its point, a rounded square, an octagon or (four ways) a disc. Two ways never takes a centre piece (between bands
|
|
101
|
+
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`).
|
|
103
|
+
- `ribbon`: one thick band folding back on itself: one, two or three steps or one wave swing, the turns round or creased
|
|
104
|
+
(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 hairpin draw by hand; a shuffle never draws a figure that reads as a letter (`SHUFFLE_FIGURES`).
|
|
106
|
+
- `field`: upright bars broken by one stepped line, the lower parts jogged.
|
|
107
|
+
- `zigzag`: a striped shape broken by a zigzag, one side slid.
|
|
108
|
+
- `halfstripe`: a shape half solid, half bars stepping down; never a diamond (a speaker, a play button).
|
|
109
|
+
|
|
110
|
+
Modes: `burst` takes `ray: 'flare'` and `move: 'slash'` (an even count of eight or more, the slash half way between rays
|
|
111
|
+
and off the axes); `chevrons` takes `body: 'hexagon'` and `soft` (round corners and a slot along one arm; `count` may
|
|
112
|
+
be 1, a soft A); `route` takes `body: 'cube'` (an iso cube, its three faces engraved with short tracks ending in a
|
|
113
|
+
node); `letter` takes five more builds, `wedge`, `cut`, `rails`, `hexfold` and `quarter`; the finish takes
|
|
114
|
+
`containerMode: 'frame'` (the container as a heavy ring, the mark whole inside) and `accentShape: 'square'`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logomarks/generate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Abstract logomarks from rules and controls, no AI: 34 recipes (bars, bands, twin, stack, shear, turns, burst, tiles, route, arcs, rings, stripes, dots, pixel, chevrons, waves, cut, split, venn, blobs, dashes, fan, fold, spiral, orbit, bloom, links, horizon, steps, hex, tri, iso, line, letter) that each list their controls and draw a mark from them and a seed, fitted to the Logomarks standard (512 canvas, 448 fit, the house gap), a shared finish (rounding, outline, an accent dot, a container), two-colour pieces, seeded variations and presets. Runs in the browser and in Node.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
package/src/finish.js
CHANGED
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
* right end, top or outer corner (measured from the piece's own box). `accent` adds one accent dot, a house gap off the
|
|
7
7
|
* mark's right end or corner, or inside its biggest counter (never a round one: a ring with a dot is an eye).
|
|
8
8
|
* `container` puts the finished mark in a circle, square, rounded square or hexagon: clipped to it (`clip`: the mark
|
|
9
|
-
* zoomed by 1 / `containerSize` and cut at the shape's edge)
|
|
10
|
-
* house gap's worth of hole, sitting at `containerSize` of the shape)
|
|
9
|
+
* zoomed by 1 / `containerSize` and cut at the shape's edge), knocked out of it (`badge`: the shape solid, the mark a
|
|
10
|
+
* house gap's worth of hole, sitting at `containerSize` of the shape) or framed by it (`frame`: the shape as a heavy
|
|
11
|
+
* ring, the mark whole inside). `accentShape` makes the accent a disc or a square (a square full stop).
|
|
11
12
|
*/
|
|
12
13
|
import { U, D, I, rect, rot, mapPts, grow, signedArea, perimeter, circle, rr, regular } from '@logomarks/core/geometry';
|
|
13
14
|
import { BOX, GAP, tidy } from './draw.js';
|
|
@@ -22,8 +23,9 @@ export const FINISH = [
|
|
|
22
23
|
{ key: 'accent', label: 'Accent dot', type: 'choice', options: ['none', 'end', 'corner', 'inside'], value: 'none', group: 'finish' },
|
|
23
24
|
{ key: 'accentSize', label: 'Dot size', type: 'range', min: 0.8, max: 1.4, step: 0.05, value: 1, group: 'finish' },
|
|
24
25
|
{ key: 'container', label: 'Container', type: 'choice', options: ['none', 'circle', 'square', 'rounded', 'hexagon'], value: 'none', group: 'finish' },
|
|
25
|
-
{ key: 'containerMode', label: 'Container mode', type: 'choice', options: ['badge', 'clip'], value: 'badge', group: 'finish' },
|
|
26
|
+
{ key: 'containerMode', label: 'Container mode', type: 'choice', options: ['badge', 'clip', 'frame'], value: 'badge', group: 'finish' },
|
|
26
27
|
{ key: 'containerSize', label: 'Mark size inside', type: 'range', min: 0.5, max: 0.9, step: 0.01, value: 0.78, group: 'finish' },
|
|
28
|
+
{ key: 'accentShape', label: 'Dot shape', type: 'choice', options: ['disc', 'square'], value: 'disc', group: 'finish' },
|
|
27
29
|
];
|
|
28
30
|
|
|
29
31
|
/** The mark with the finish applied, in this order: round, outline, accent, mirror, turn, container. */
|
|
@@ -31,7 +33,7 @@ export function finish(shape, p) {
|
|
|
31
33
|
let s = shape;
|
|
32
34
|
if (p.round > 0) s = rounded(s, p.round, p.roundWhich || 'all');
|
|
33
35
|
if (p.outline > 0) s = D(s, grow(s, -p.outline));
|
|
34
|
-
if (p.accent && p.accent !== 'none') s = accent(s, p.accent, p.accentSize || 1);
|
|
36
|
+
if (p.accent && p.accent !== 'none') s = accent(s, p.accent, p.accentSize || 1, p.accentShape || 'disc');
|
|
35
37
|
if (p.mirror) s = mapPts(s, ([x, y]) => [2 * BOX.cx - x, y]);
|
|
36
38
|
if (p.turn && p.turn !== '0') s = rot(s, Number(p.turn), BOX.cx, BOX.cy);
|
|
37
39
|
if (p.container && p.container !== 'none') s = contain(s, p.container, p.containerMode || 'badge', p.containerSize ?? 0.78);
|
|
@@ -63,6 +65,13 @@ function contain(shape, kind, mode, size) {
|
|
|
63
65
|
if (!shape || !shape.length) return shape;
|
|
64
66
|
const box = containerShape(kind);
|
|
65
67
|
if (mode === 'clip') return tidy(I(scaledTo(shape, (BOX.size * 0.9) / size), box));
|
|
68
|
+
// frame: the container drawn as a heavy ring (its band about the house gap and a half), the mark whole inside it, a gap
|
|
69
|
+
// clear of the ring all round
|
|
70
|
+
if (mode === 'frame') {
|
|
71
|
+
const band = GAP * 1.7, ring = D(box, grow(box, -band));
|
|
72
|
+
const mark = scaledTo(shape, BOX.size * size * INSCRIBE[kind] * 0.86);
|
|
73
|
+
return tidy(U(ring, D(mark, grow(ring, GAP * 1.1))));
|
|
74
|
+
}
|
|
66
75
|
// badge: the mark sits at `size` of the shape, its pieces knocked out; a mark spilling past the shape's edge would cut
|
|
67
76
|
// it open, so it is kept inside by a house gap. Scaled down, the mark's own gaps would become hairline bridges between
|
|
68
77
|
// the holes, so each hole is shrunk by half of what the scale took off the gap (the bridges get it back). A mark too
|
|
@@ -141,7 +150,8 @@ const areaOf = (poly) => Math.abs(signedArea(poly[0])) - poly.slice(1).reduce((t
|
|
|
141
150
|
* off the right of the mark at the height of its lowest rightmost ink ('end'), off its bottom-right corner ('corner'),
|
|
142
151
|
* or in its biggest counter ('inside', never a round counter, and only where it fits with a gap all round).
|
|
143
152
|
*/
|
|
144
|
-
function accent(shape, where, size) {
|
|
153
|
+
function accent(shape, where, size, kind = 'disc') {
|
|
154
|
+
const dot = (x, y, r) => (kind === 'square' ? rect(x - r * 0.9, y - r * 0.9, r * 1.8, r * 1.8) : circle(x, y, r, 64));
|
|
145
155
|
const polys = !shape.length ? [] : typeof shape[0][0][0] === 'number' ? [shape] : shape;
|
|
146
156
|
if (!polys.length) return shape;
|
|
147
157
|
const big = polys.reduce((a, b) => (areaOf(b) > areaOf(a) ? b : a));
|
|
@@ -157,14 +167,14 @@ function accent(shape, where, size) {
|
|
|
157
167
|
const [hx0, hy0, hx1, hy1] = boxOf([[best.hole]]), cx = (hx0 + hx1) / 2, cy = (hy0 + hy1) / 2;
|
|
158
168
|
const fit = Math.min(hx1 - hx0, hy1 - hy0) / 2 - GAP;
|
|
159
169
|
if (fit < GAP * 0.5) return shape;
|
|
160
|
-
const
|
|
161
|
-
return I(
|
|
170
|
+
const d = dot(cx, cy, Math.min(r, fit));
|
|
171
|
+
return I(d, shape).length ? shape : U(shape, D(d, grow(shape, GAP)));
|
|
162
172
|
}
|
|
163
|
-
if (where === 'corner') return U(shape,
|
|
173
|
+
if (where === 'corner') return U(shape, dot(x1 + GAP + r * 0.7, y1 + GAP * 0.2 - r * 0.3, r));
|
|
164
174
|
// end: beside the lowest point of the rightmost ink
|
|
165
175
|
let ex = -Infinity, ey = y0;
|
|
166
176
|
for (const poly of polys) for (const [x, y] of poly[0]) if (x > ex - 0.5) { if (x > ex + 0.5 || y > ey) ey = y; ex = Math.max(ex, x); }
|
|
167
|
-
return U(shape,
|
|
177
|
+
return U(shape, dot(x1 + GAP + r, Math.min(y1 - r, Math.max(y0 + r, ey - r)), r));
|
|
168
178
|
}
|
|
169
179
|
|
|
170
180
|
/** A polygon's top and left edges, for reading order. */
|
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 } from './tuning.js';
|
|
10
11
|
import { fill, thinShareBits } from './raster.js';
|
|
11
12
|
|
|
12
13
|
robust();
|
|
@@ -193,6 +194,18 @@ export function randomParams(id, seed, { base = {}, locked = [], finish = false
|
|
|
193
194
|
const v = randomValue(c, rand); // drawn even when kept, so a seed draws the same construction whatever is locked
|
|
194
195
|
out[c.key] = keep ? base[c.key] : c.group === 'finish' && !finish ? c.value : v;
|
|
195
196
|
}
|
|
197
|
+
// about one shuffle in three turns or mirrors the mark, by the recipe's safe turns (never outside them); a locked Turn
|
|
198
|
+
// or Mirror stays. With `finish`, the turn and mirror drawn above are kept to the safe ones too
|
|
199
|
+
const safe = TURNS[id] || { turns: ['0'], mirror: false }, rt = rng(`${seedOf(seed)}:turn`);
|
|
200
|
+
const roll = rt(), pickTurn = safe.turns[Math.floor(rt() * safe.turns.length)], pickMirror = safe.mirror && rt() < 0.5;
|
|
201
|
+
if (!locked.includes('turn')) {
|
|
202
|
+
if (finish) { if (!safe.turns.includes(String(out.turn))) out.turn = '0'; }
|
|
203
|
+
else if (roll < TURN_SHARE) out.turn = pickTurn;
|
|
204
|
+
}
|
|
205
|
+
if (!locked.includes('mirror')) {
|
|
206
|
+
if (finish) { if (out.mirror && !safe.mirror) out.mirror = false; }
|
|
207
|
+
else if (roll < TURN_SHARE) out.mirror = pickMirror;
|
|
208
|
+
}
|
|
196
209
|
return resolve(r.controls, out);
|
|
197
210
|
}
|
|
198
211
|
|
|
@@ -249,7 +262,7 @@ export function similar(id, params, { count = 12, seed = 1, amount = 0.15, locke
|
|
|
249
262
|
* How often each recipe comes up in `mix()`, relative to 1: the ones whose shuffles most often give a mark worth
|
|
250
263
|
* keeping lead; the textured ones (iso, hex, tiles) come up less.
|
|
251
264
|
*/
|
|
252
|
-
export const MIX_WEIGHT = { twin: 1.6, cut: 1.6, split: 1.4, chevrons: 1.3, spiral: 1.2, links: 1.2, arcs: 1.2, bands: 1.2, stripes: 1.2, rings: 0.8, turns: 1.1, bloom: 1, burst: 1, bars: 1, waves: 0.9, stack: 0.8, steps: 0.8, letter: 0.8, shear: 0.6, route: 0.5, horizon: 0.5, tiles: 0.6, hex: 0.5, iso: 0.5, arcstep: 1.4, leaves: 1.3, seam: 1.3, trine: 1.1, blades: 1.1, invert: 1, wavecut: 1, capsules: 1, bite: 0.9, loops: 0.8, strips: 0.7, flare: 0.8, lobes: 0.9, halfsq: 0.8, pixelarc: 0.4 , merge: 1.3, overlap: 1.3, counter: 1.2, pair: 1.3, corners: 1.2, offset: 1.1, quarters: 1.1 };
|
|
265
|
+
export const MIX_WEIGHT = { twin: 1.6, cut: 1.6, split: 1.4, chevrons: 1.3, spiral: 1.2, links: 1.2, arcs: 1.2, bands: 1.2, stripes: 1.2, rings: 0.8, turns: 1.1, bloom: 1, burst: 1, bars: 1, waves: 0.9, stack: 0.8, steps: 0.8, letter: 0.8, shear: 0.6, route: 0.5, horizon: 0.5, tiles: 0.6, hex: 0.5, iso: 0.5, arcstep: 1.4, leaves: 1.3, seam: 1.3, trine: 1.1, blades: 1.1, invert: 1, wavecut: 1, capsules: 1, bite: 0.9, loops: 0.8, strips: 0.7, flare: 0.8, lobes: 0.9, halfsq: 0.8, pixelarc: 0.4 , merge: 1.3, overlap: 1.3, counter: 1.2, pair: 1.3, corners: 1.2, offset: 1.1, quarters: 1.1 , mosaic: 0.8, weave: 0.8, notch: 1, nodes: 0.9, xband: 0.9, mirror: 0.8, ribbon: 1, field: 0.7, zigzag: 0.9, halfstripe: 0.9 };
|
|
253
266
|
|
|
254
267
|
/**
|
|
255
268
|
* `count` marks from ANY recipe: each slot picks a recipe by its seed (from `ids`, every recipe by default, weighted by
|
package/src/guard.js
CHANGED
|
@@ -36,7 +36,9 @@ export function problems(shape, limits = {}) {
|
|
|
36
36
|
const holes = polys.flatMap((poly) => poly.slice(1).map((h) => [h]));
|
|
37
37
|
const holeArea = holes.reduce((t, h) => t + Math.abs(signedArea(h[0])), 0);
|
|
38
38
|
if (!out.length && holeArea > 0.03 * total && thinShareBits(fill(holes, GUARD.raster), GUARD.raster, 1) > L.maxThinHoles) out.push('hairline holes');
|
|
39
|
-
|
|
39
|
+
// one solid convex piece is too plain, and so is one whose holes are crumbs (under 4% of it): a container whose mark
|
|
40
|
+
// was knocked out or clipped to almost nothing reads as a blank disc or hexagon
|
|
41
|
+
if (polys.length === 1 && (polys[0].length === 1 || holeArea < 0.04 * total) && (total + holeArea) / hullArea(polys[0][0]) > L.plainSolidity) out.push('too plain');
|
|
40
42
|
const [x0, y0, x1, y1] = box(polys);
|
|
41
43
|
if (total / Math.max(1, (x1 - x0) * (y1 - y0)) < L.minInkShare) out.push('too sparse');
|
|
42
44
|
return out;
|
package/src/index.d.ts
CHANGED
|
@@ -44,9 +44,10 @@ export interface Generated {
|
|
|
44
44
|
seed?: number;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
/** Every recipe, by id: bars, bands, twin, stack, shear, turns, burst, tiles, route, arcs, rings, stripes, chevrons,
|
|
48
|
-
* cut, split,
|
|
49
|
-
* capsules, flare,
|
|
47
|
+
/** Every recipe, by id (55): bars, bands, twin, stack, shear, turns, burst, tiles, route, arcs, rings, stripes, chevrons,
|
|
48
|
+
* waves, cut, split, spiral, bloom, links, horizon, steps, hex, iso, letter, arcstep, halfsq, invert, leaves, lobes, loops,
|
|
49
|
+
* trine, strips, bite, blades, wavecut, capsules, flare, merge, overlap, counter, pair, corners, offset, quarters, seam,
|
|
50
|
+
* mosaic, weave, notch, nodes, xband, mirror, ribbon, field, zigzag and halfstripe. */
|
|
50
51
|
export const RECIPES: Record<string, Recipe>;
|
|
51
52
|
/** A recipe by id; throws for an unknown one. */
|
|
52
53
|
export function recipe(id: string): Recipe;
|
|
@@ -73,6 +74,10 @@ export const MIX_WEIGHT: Record<string, number>;
|
|
|
73
74
|
export const TUNING: Record<string, Record<string, { random?: [number, number] | string[]; rare?: number; value?: number | string | boolean }>>;
|
|
74
75
|
/** Per recipe: the keys of the controls a page shows first. */
|
|
75
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;
|
|
76
81
|
/** Every control's default. */
|
|
77
82
|
export function defaults(controls: Control[]): Params;
|
|
78
83
|
/** 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 } 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
|
@@ -40,5 +40,17 @@ export const PRESETS = [
|
|
|
40
40
|
{ id: 'facing-halves', name: 'Facing halves', recipe: 'pair', params: { a: 'half', b: 'quarter' }, note: 'A half disc and a quarter disc, flat sides to the split.' },
|
|
41
41
|
{ id: 'disc-on-square', name: 'Disc over square', recipe: 'overlap', params: { a: 'disc', b: 'square', way: 'over' }, note: 'A square laid over a disc, cut free by the gap.' },
|
|
42
42
|
{ id: 'dome-shadow', name: 'Dome shadow', recipe: 'offset', params: { shape: 'half', way: 'shadow', dir: 'se', shift: 0.28 }, note: 'A dome and its copy slid behind it.' },
|
|
43
|
+
// the reference styles (0.4.0)
|
|
44
|
+
{ id: 'tile-b', name: 'Tile B', recipe: 'mosaic', params: { char: 'B', tiles: 'mixed' }, note: 'A B on a coarse grid: a square stem, its bowls in quarter discs.' },
|
|
45
|
+
{ id: 'notched-block', name: 'Notched block', recipe: 'notch', params: { body: 'chamfer', depth: 0.34, seat: 'diamond', split: true }, note: 'A chamfered block with a chevron notch and a diamond seated in it.' },
|
|
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
|
+
{ 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
|
+
{ 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: '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.' },
|
|
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.' },
|
|
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.' },
|
|
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.' },
|
|
43
55
|
{ id: 'four-shapes', name: 'Four shapes', recipe: 'quarters', params: { a: 'quarter', b: 'wedge', c: 'disc', d: 'leaf', rule: 'rotate' }, note: 'Four unlike shapes, each a quarter turn on from the last.' },
|
|
44
56
|
];
|
package/src/primitives.js
CHANGED
|
@@ -58,7 +58,8 @@ export const alike = (a, b) => a === b || ALIKE.some(([p, q]) => (p === a && q =
|
|
|
58
58
|
export const BANNED = {
|
|
59
59
|
merge: [['disc', 'square', 'a person'], ['disc', 'rsquare', 'a person'], ['disc', 'pill', 'a person'], ['disc', 'half', 'a person'], ['disc', 'bar', 'a person'], ['disc', 'triangle', 'a pin'], ['disc', 'wedge', 'a pin'], ['disc', 'diamond', 'a pin'], ['triangle', 'square', 'a house'], ['triangle', 'rsquare', 'a house'], ['triangle', 'pill', 'an arrow'], ['triangle', 'bar', 'an arrow'], ['triangle', 'half', 'a cone'], ['diamond', 'half', 'a cone'], ['leaf', 'disc', 'a flame'], ['hexagon', 'triangle', 'a pencil'], ['square', 'half', 'a tombstone'], ['rsquare', 'half', 'a tombstone'], ['pill', 'half', 'a mushroom']],
|
|
60
60
|
overlap: [['disc', 'triangle', 'a play button'], ['ring', 'bar', 'a no-entry sign'], ['ring', 'pill', 'a no-entry sign'], ['disc', 'bar', 'a no-entry sign'], ['ring', 'triangle', 'a play button'], ['ring', 'square', 'a magnifier'], ['ring', 'rsquare', 'a magnifier'], ['ring', 'diamond', 'a key'], ['disc', 'half', 'a person'], ['triangle', 'square', 'a house'], ['triangle', 'rsquare', 'a house']],
|
|
61
|
-
|
|
61
|
+
// a triangle hole in any body is a play button (in a half disc or a leaf too, seen in the mix)
|
|
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']],
|
|
62
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']],
|
|
63
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
65
|
offset: [],
|
package/src/recipes/burst.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Burst: five to sixteen rays round an open or solid centre, each a bar, a wedge, a pill, a pair of dashes or a
|
|
3
|
-
* long and short in turn if asked, with ONE move: a ring cut through them, a ray left out,
|
|
2
|
+
* Burst: five to sixteen rays round an open or solid centre, each a bar, a wedge, a pill, a pair of dashes, a drop or a flare,
|
|
3
|
+
* long and short in turn if asked, with ONE move: a ring cut through them, a ray left out, a centre dot, or a slash
|
|
4
|
+
* gap through the centre (the flared asterisk cut by a slash). Never four
|
|
4
5
|
* rays (the four-point sparkle is banned).
|
|
5
6
|
*/
|
|
6
7
|
import { U, D, poly, circle, rot, pill, annulus } from '@logomarks/core/geometry';
|
|
@@ -9,12 +10,12 @@ import { BOX, GAP } from '../draw.js';
|
|
|
9
10
|
/** @type {import('../index.js').Control[]} */
|
|
10
11
|
export const controls = [
|
|
11
12
|
{ key: 'rays', label: 'Rays', type: 'range', min: 5, max: 16, step: 1, value: 8 },
|
|
12
|
-
{ key: 'ray', label: 'Ray', type: 'choice', options: ['bar', 'wedge', 'pill', 'dashes', 'drop'], value: 'bar' },
|
|
13
|
+
{ key: 'ray', label: 'Ray', type: 'choice', options: ['bar', 'wedge', 'pill', 'dashes', 'drop', 'flare'], value: 'bar' },
|
|
13
14
|
{ key: 'width', label: 'Ray width', type: 'range', min: 0.07, max: 0.2, step: 0.005, value: 0.1 },
|
|
14
15
|
{ key: 'inner', label: 'Open centre', type: 'range', min: 0, max: 0.35, step: 0.01, value: 0.14 },
|
|
15
16
|
{ key: 'alternate', label: 'Long and short', type: 'range', min: 0, max: 0.5, step: 0.01, value: 0 },
|
|
16
17
|
{ key: 'twist', label: 'Twist', type: 'range', min: -40, max: 40, step: 1, value: 0 },
|
|
17
|
-
{ key: 'move', label: 'Move', type: 'choice', options: ['none', 'ring', 'gap', 'dot'], value: 'none' },
|
|
18
|
+
{ key: 'move', label: 'Move', type: 'choice', options: ['none', 'ring', 'gap', 'dot', 'slash'], value: 'none' },
|
|
18
19
|
];
|
|
19
20
|
|
|
20
21
|
/** One ray pointing up from radius r0 to r1, `w` wide at its outer end. */
|
|
@@ -23,6 +24,8 @@ function ray(kind, r0, r1, w) {
|
|
|
23
24
|
if (kind === 'wedge') return poly([[cx - w / 2, y0], [cx + w / 2, y0], [cx + w * 0.22, y1], [cx - w * 0.22, y1]]);
|
|
24
25
|
if (kind === 'pill') return pill([cx, y0 + w / 2], [cx, y1 - w / 2], w);
|
|
25
26
|
if (kind === 'drop') return U(circle(cx, y0 + w / 2, w / 2, 48), poly([[cx - w / 2, y0 + w / 2], [cx + w / 2, y0 + w / 2], [cx, y1]]));
|
|
27
|
+
// flare: a ray widening from its root to a round end (the flared asterisk)
|
|
28
|
+
if (kind === 'flare') return U(poly([[cx - w * 0.3, y1], [cx + w * 0.3, y1], [cx + w * 0.62, y0 + w * 0.62], [cx - w * 0.62, y0 + w * 0.62]]), circle(cx, y0 + w * 0.62, w * 0.62, 48));
|
|
26
29
|
if (kind === 'dashes') { const m = y0 + (y1 - y0) * 0.55; return U(pill([cx, y0 + w / 2], [cx, m - GAP / 2 - w / 2], w), pill([cx, m + GAP / 2 + w / 2], [cx, y1 - w / 2], w)); }
|
|
27
30
|
return poly([[cx - w / 2, y0], [cx + w / 2, y0], [cx + w / 2, y1], [cx - w / 2, y1]]);
|
|
28
31
|
}
|
|
@@ -32,7 +35,24 @@ function ray(kind, r0, r1, w) {
|
|
|
32
35
|
* Eight rays long and short leave four long ones on the axes: a plus (a cross, or a compass rose) with stubs between. So
|
|
33
36
|
* long and short takes ten rays there, five long.
|
|
34
37
|
*/
|
|
35
|
-
export const raysOf = (p) =>
|
|
38
|
+
export const raysOf = (p) => {
|
|
39
|
+
// an odd count puts a ray along the slash's far half; six is the star of life; eight long and short is a plus
|
|
40
|
+
if (p.move === 'slash') { const n = Math.max(8, p.rays + (p.rays % 2)); return n === 8 && p.alternate > 0 ? 10 : n; }
|
|
41
|
+
return p.alternate > 0 && p.rays === 8 ? 10 : p.rays;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The slash: one straight gap through the centre, half way between two rays on both sides (so an even count of eight
|
|
46
|
+
* or more: odd, a ray runs along its far half; six with a rod is the star of life), turned off the axes (level or
|
|
47
|
+
* upright, a no-entry sign).
|
|
48
|
+
*/
|
|
49
|
+
export function slashAngle(n) {
|
|
50
|
+
// ray k points at -90 + 360k / n (screen degrees, 0 to the right): the slash runs half way between two rays
|
|
51
|
+
let a = -90 + 180 / n;
|
|
52
|
+
const offAxis = (v) => { const m = ((v % 90) + 90) % 90; return Math.min(m, 90 - m) >= 12; };
|
|
53
|
+
for (let k = 0; k < n && !offAxis(a); k++) a += 360 / n;
|
|
54
|
+
return a;
|
|
55
|
+
}
|
|
36
56
|
|
|
37
57
|
export function build(params) {
|
|
38
58
|
const p = { ...params, rays: raysOf(params) };
|
|
@@ -46,6 +66,7 @@ export function build(params) {
|
|
|
46
66
|
}
|
|
47
67
|
let s = U(...parts);
|
|
48
68
|
if (p.move === 'ring') s = D(s, annulus(BOX.cx, BOX.cy, R * 0.62, GAP * 1.1));
|
|
69
|
+
if (p.move === 'slash') s = D(s, rot(poly([[BOX.cx - R * 1.2, BOX.cy - GAP * 0.7], [BOX.cx + R * 1.2, BOX.cy - GAP * 0.7], [BOX.cx + R * 1.2, BOX.cy + GAP * 0.7], [BOX.cx - R * 1.2, BOX.cy + GAP * 0.7]]), slashAngle(p.rays), BOX.cx, BOX.cy));
|
|
49
70
|
if (p.move === 'dot') s = U(s, circle(BOX.cx, BOX.cy, R * 0.28 - GAP, 64));
|
|
50
71
|
return s;
|
|
51
72
|
}
|
package/src/recipes/chevrons.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Chevrons: two to five chevrons stacked along their point, the house gap between them, pointed, flat-tipped or soft,
|
|
3
|
-
* stepping in size if asked,
|
|
3
|
+
* stepping in size if asked, cut to a hexagon or softened (round corners and a slot along one arm: a soft A), and ONE
|
|
4
|
+
* move: the last one solid (an arrowhead), one left out, or a stem under them (a
|
|
4
5
|
* tree). After Chevron Stack and stacked-arrow marks.
|
|
5
6
|
*/
|
|
6
|
-
import { U, poly, rect, rot, mapPts } from '@logomarks/core/geometry';
|
|
7
|
-
import { BOX, GAP } from '../draw.js';
|
|
7
|
+
import { U, D, I, poly, rect, rot, mapPts, grow, pill, regular } from '@logomarks/core/geometry';
|
|
8
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
8
9
|
|
|
9
10
|
/** @type {import('../index.js').Control[]} */
|
|
10
11
|
export const controls = [
|
|
11
|
-
{ key: 'count', label: 'Chevrons', type: 'range', min:
|
|
12
|
+
{ key: 'count', label: 'Chevrons', type: 'range', min: 1, max: 5, step: 1, value: 3 },
|
|
12
13
|
{ key: 'angle', label: 'Opening', type: 'range', min: 60, max: 140, step: 1, value: 90 },
|
|
13
14
|
{ key: 'weight', label: 'Weight', type: 'range', min: 0.35, max: 0.8, step: 0.01, value: 0.6 },
|
|
14
15
|
{ key: 'tip', label: 'Tip', type: 'choice', options: ['pointed', 'flat', 'notched'], value: 'pointed' },
|
|
15
16
|
{ key: 'grow', label: 'Step in size', type: 'range', min: 0, max: 0.5, step: 0.01, value: 0 },
|
|
16
17
|
{ key: 'move', label: 'Move', type: 'choice', options: ['none', 'arrowhead', 'skip', 'stem'], value: 'none' },
|
|
17
18
|
{ key: 'point', label: 'Point', type: 'choice', options: ['up', 'right', 'down', 'left'], value: 'up' },
|
|
19
|
+
{ key: 'body', label: 'Body', type: 'choice', options: ['none', 'hexagon'], value: 'none' },
|
|
20
|
+
{ key: 'soft', label: 'Soft', type: 'toggle', value: false },
|
|
18
21
|
];
|
|
19
22
|
|
|
20
23
|
/** One chevron pointing up, its tip at (cx, y), arms `half` wide each, `t` thick (measured upright). */
|
|
@@ -29,16 +32,31 @@ function chevron(cx, y, half, t, k, tip, solid) {
|
|
|
29
32
|
|
|
30
33
|
/** The mark for resolved params. */
|
|
31
34
|
export function build(p) {
|
|
32
|
-
|
|
35
|
+
// a soft chevron opened wide, or a heavy one, rounds into a blob or a heart: soft keeps the opening to 60–100°
|
|
36
|
+
const angle = p.soft ? Math.min(100, Math.max(60, p.angle)) : p.angle;
|
|
37
|
+
const n = p.count, k = Math.tan(((angle / 2) * Math.PI) / 180); // half-width over drop
|
|
33
38
|
const half = BOX.size / 2, drop = half / k;
|
|
34
|
-
|
|
39
|
+
// a soft chevron is a band, never a slab (one heavy soft chevron fills into a blob)
|
|
40
|
+
const total = BOX.size - drop * 0.4, pitch = total / n, t = Math.min(p.soft ? BOX.size * 0.24 : Infinity, Math.max(GAP * 1.2, pitch * p.weight)), parts = [];
|
|
35
41
|
for (let i = 0; i < n; i++) {
|
|
36
42
|
if (p.move === 'skip' && i === 1) continue;
|
|
37
43
|
const scale = 1 - p.grow * (1 - i / Math.max(1, n - 1));
|
|
38
|
-
|
|
44
|
+
// soft: the tip always pointed (a notched or flat tip rounds into two loose bars)
|
|
45
|
+
parts.push(chevron(BOX.cx, BOX.y0 + i * pitch, half * scale, t, k, p.soft ? 'pointed' : p.tip, p.move === 'arrowhead' && i === 0));
|
|
39
46
|
}
|
|
40
47
|
if (p.move === 'stem') parts.push(rect(BOX.cx - t / 2, BOX.y0 + n * pitch + t * 0.2, t, BOX.size * 0.3));
|
|
41
48
|
let s = U(...parts);
|
|
49
|
+
// soft: every corner rounded, and a slot (a round-ended gap) along the inner side of the first chevron's left arm
|
|
50
|
+
if (p.soft) {
|
|
51
|
+
const r = t * Math.sin(((angle / 2) * Math.PI) / 180) * 0.4; // under half the band measured square to its arms
|
|
52
|
+
s = grow(grow(s, -r), r);
|
|
53
|
+
// the slot runs along the middle of the first chevron's left arm, from a quarter to three quarters of its length
|
|
54
|
+
const h0 = half * (1 - p.grow), L = [[BOX.cx, BOX.y0 + t / 2], [BOX.cx - h0, BOX.y0 + h0 / k + t / 2]];
|
|
55
|
+
const at = (f) => [L[0][0] + (L[1][0] - L[0][0]) * f, L[0][1] + (L[1][1] - L[0][1]) * f];
|
|
56
|
+
if (t * Math.sin(((angle / 2) * Math.PI) / 180) > GAP * 3) s = D(s, pill(at(0.3), at(0.78), GAP));
|
|
57
|
+
}
|
|
58
|
+
// hexagon: the stack cut to a hexagon standing on a point (the chevrons' outer edges run along its sides)
|
|
59
|
+
if (p.body === 'hexagon') s = tidy(I(mapPts(s, ([x, y]) => [x, y + BOX.size * 0.08]), regular(BOX.cx, BOX.cy, BOX.size / 2, 6, -90)));
|
|
42
60
|
const turn = { up: 0, right: 90, down: 180, left: 270 }[p.point];
|
|
43
61
|
if (turn) s = rot(s, turn, BOX.cx, BOX.cy);
|
|
44
62
|
return mapPts(s, (q) => q);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bar field: six to ten upright bars across the box, each broken once with the gap, the breaks stepping across
|
|
3
|
+
* the field by one profile (a stair, a skyline, a ramp, a V), the lower parts jogged sideways, so a shape is cut out of
|
|
4
|
+
* the field. Widths even or varied. After the barcode skylines of the owner's references.
|
|
5
|
+
*/
|
|
6
|
+
import { U, rect } from '@logomarks/core/geometry';
|
|
7
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
8
|
+
|
|
9
|
+
/** @type {import('../index.js').Control[]} */
|
|
10
|
+
export const controls = [
|
|
11
|
+
{ key: 'bars', label: 'Bars', type: 'range', min: 6, max: 10, step: 1, value: 8 },
|
|
12
|
+
{ key: 'weight', label: 'Weight', type: 'range', min: 0.5, max: 0.75, step: 0.01, value: 0.64 },
|
|
13
|
+
{ key: 'profile', label: 'Break line', type: 'choice', options: ['stair', 'skyline', 'ramp', 'vee', 'arch'], value: 'skyline' },
|
|
14
|
+
{ key: 'depth', label: 'Break depth', type: 'range', min: 0.2, max: 0.6, step: 0.01, value: 0.4 },
|
|
15
|
+
{ key: 'slide', label: 'Jog', type: 'range', min: 0, max: 0.5, step: 0.01, value: 0.3 },
|
|
16
|
+
{ key: 'widths', label: 'Widths', type: 'choice', options: ['even', 'varied'], value: 'varied' },
|
|
17
|
+
{ key: 'drop', label: 'Gap', type: 'range', min: 0, max: 2, step: 0.1, value: 1 },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
/** Where bar k of n breaks, 0 (top) to 1 (bottom), by the profile. */
|
|
21
|
+
function breakAt(profile, k, n, depth) {
|
|
22
|
+
const u = n > 1 ? k / (n - 1) : 0.5, top = 0.5 - depth / 2;
|
|
23
|
+
if (profile === 'stair') return top + Math.floor(u * 4) / 3 * depth;
|
|
24
|
+
if (profile === 'ramp') return top + u * depth;
|
|
25
|
+
if (profile === 'vee') return top + Math.abs(u - 0.5) * 2 * depth;
|
|
26
|
+
if (profile === 'arch') return top + (1 - Math.sin(u * Math.PI)) * depth;
|
|
27
|
+
// skyline: blocks of two or three bars at stepped heights, in a fixed rhythm
|
|
28
|
+
const H = [0.55, 0.15, 0.85, 0.35, 1, 0.25, 0.7];
|
|
29
|
+
return top + H[Math.floor(k / 2) % H.length] * depth;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The mark for resolved params. */
|
|
33
|
+
export function build(p) {
|
|
34
|
+
const n = p.bars, pitch = BOX.size / n, parts = [];
|
|
35
|
+
const W = (k) => (p.widths === 'varied' ? pitch * p.weight * [1, 0.85, 1.2, 0.9, 1.1][k % 5] : pitch * p.weight);
|
|
36
|
+
for (let k = 0; k < n; k++) {
|
|
37
|
+
const w = Math.min(W(k), pitch - GAP * 0.8), x = BOX.x0 + k * pitch + (pitch - w) / 2;
|
|
38
|
+
const y = BOX.y0 + breakAt(p.profile, k, n, p.depth) * BOX.size, g = GAP * p.drop;
|
|
39
|
+
parts.push(rect(x, BOX.y0, w, y - g / 2 - BOX.y0));
|
|
40
|
+
parts.push(rect(x + p.slide * pitch, y + g / 2, w, BOX.y1 - y - g / 2));
|
|
41
|
+
}
|
|
42
|
+
return tidy(U(...parts), { share: 0.002, width: 12 });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A field is many pieces by design, each a thin bar. */
|
|
46
|
+
export const guard = { maxPieces: 30, maxThinShare: 0.07, minInkShare: 0.12 };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Half stripe: a shape half solid, the other half upright bars that step down in height away from it, each a gap from
|
|
3
|
+
* the next, their ends cut by the shape's own edge. Never a diamond (its solid half is a triangle: with the bars, a
|
|
4
|
+
* speaker or a play button). After the half-solid, half-barred hexagon of the owner's references.
|
|
5
|
+
*/
|
|
6
|
+
import { U, I, rect, poly, mapPts } from '@logomarks/core/geometry';
|
|
7
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
8
|
+
import { primitive } from '../shapes.js';
|
|
9
|
+
|
|
10
|
+
/** @type {import('../index.js').Control[]} */
|
|
11
|
+
export const controls = [
|
|
12
|
+
{ key: 'shape', label: 'Shape', type: 'choice', options: ['hexagon', 'circle', 'square', 'half', 'shield'], value: 'hexagon' },
|
|
13
|
+
{ key: 'bars', label: 'Bars', type: 'range', min: 2, max: 5, step: 1, value: 4 },
|
|
14
|
+
{ key: 'solid', label: 'Solid part', type: 'range', min: 0.4, max: 0.62, step: 0.01, value: 0.5 },
|
|
15
|
+
{ key: 'step', label: 'Step down', type: 'range', min: 0, max: 0.18, step: 0.01, value: 0.1 },
|
|
16
|
+
{ key: 'weight', label: 'Bar weight', type: 'range', min: 0.45, max: 0.75, step: 0.01, value: 0.6 },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
/** The silhouette, filling the box. */
|
|
20
|
+
function silhouette(shape) {
|
|
21
|
+
const { x0, y0, size, cx, cy } = BOX;
|
|
22
|
+
if (shape === 'hexagon') return poly(Array.from({ length: 6 }, (_, k) => { const a = (Math.PI / 3) * k - Math.PI / 2; return [cx + (size / 2) * Math.cos(a), cy + (size / 2) * Math.sin(a)]; }));
|
|
23
|
+
if (shape === 'shield') return poly([[x0, y0], [x0 + size, y0], [x0 + size, cy], [cx, y0 + size], [x0, cy]]);
|
|
24
|
+
return primitive(shape, x0, y0, size, size);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The mark for resolved params. */
|
|
28
|
+
export function build(p) {
|
|
29
|
+
const body = silhouette(p.shape), split = BOX.x1 - p.solid * BOX.size;
|
|
30
|
+
const parts = [I(body, rect(split, BOX.y0 - 10, BOX.size, BOX.size + 20))];
|
|
31
|
+
const span = split - GAP - BOX.x0, pitch = span / p.bars, w = Math.max(GAP, pitch * p.weight);
|
|
32
|
+
for (let k = 0; k < p.bars; k++) {
|
|
33
|
+
const x = split - GAP - (k + 1) * pitch + (pitch - w);
|
|
34
|
+
// each bar is the body squeezed toward the middle line by its step, so the bars step down away from the solid part
|
|
35
|
+
const squeeze = 1 - p.step * (k + 1);
|
|
36
|
+
const scaled = mapPts(body, ([px, py]) => [px, BOX.cy + (py - BOX.cy) * squeeze]);
|
|
37
|
+
parts.push(I(scaled, rect(x, BOX.y0 - 10, w, BOX.size + 20)));
|
|
38
|
+
}
|
|
39
|
+
return tidy(U(...parts));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** A solid and its bars. */
|
|
43
|
+
export const guard = {};
|
package/src/recipes/index.js
CHANGED
|
@@ -46,6 +46,16 @@ import * as pair from './pair.js';
|
|
|
46
46
|
import * as corners from './corners.js';
|
|
47
47
|
import * as offset from './offset.js';
|
|
48
48
|
import * as quarters from './quarters.js';
|
|
49
|
+
import * as mosaic from './mosaic.js';
|
|
50
|
+
import * as weave from './weave.js';
|
|
51
|
+
import * as notch from './notch.js';
|
|
52
|
+
import * as nodes from './nodes.js';
|
|
53
|
+
import * as xband from './xband.js';
|
|
54
|
+
import * as mirror from './mirror.js';
|
|
55
|
+
import * as ribbon from './ribbon.js';
|
|
56
|
+
import * as field from './field.js';
|
|
57
|
+
import * as zigzag from './zigzag.js';
|
|
58
|
+
import * as halfstripe from './halfstripe.js';
|
|
49
59
|
import { FINISH, finish } from '../finish.js';
|
|
50
60
|
import { TUNING } from '../tuning.js';
|
|
51
61
|
|
|
@@ -102,4 +112,14 @@ export const RECIPES = {
|
|
|
102
112
|
offset: R('offset', 'Offset', 'A shape and its copy slid aside, kept apart by the gap.', offset),
|
|
103
113
|
quarters: R('quarters', 'Quarters', 'Four big cells, each a different shape, turned by one rule.', quarters),
|
|
104
114
|
seam: R('seam', 'Seam', 'A block parted in two by one seam with a joint in it.', seam),
|
|
115
|
+
mosaic: R('mosaic', 'Mosaic', 'A capital on a coarse grid, each cell a square, a triangle or a quarter disc.', mosaic),
|
|
116
|
+
weave: R('weave', 'Weave', 'Curves crossing over and under by turns, in a ring.', weave),
|
|
117
|
+
notch: R('notch', 'Notch', 'A block with a chevron notch and a diamond seated in it.', notch),
|
|
118
|
+
nodes: R('nodes', 'Nodes', 'Four round nodes joined in pairs by soft bands round a centre.', nodes),
|
|
119
|
+
xband: R('xband', 'Bent X', 'An X of two bent bands meeting a gap apart at the waist.', xband),
|
|
120
|
+
mirror: R('mirror', 'Mirror', 'An emblem symmetric both ways: arches round a bow.', mirror),
|
|
121
|
+
ribbon: R('ribbon', 'Ribbon', 'One thick band folding back with round turns and a slot.', ribbon),
|
|
122
|
+
field: R('field', 'Bar Field', 'A field of upright bars broken by one stepped line.', field),
|
|
123
|
+
zigzag: R('zigzag', 'Zigzag', 'A striped shape broken by a zigzag, one side slid.', zigzag),
|
|
124
|
+
halfstripe: R('halfstripe', 'Half Stripe', 'A shape half solid, half bars stepping down.', halfstripe),
|
|
105
125
|
};
|