@logomarks/generate 0.3.1 → 0.4.0
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 +57 -0
- package/README.md +34 -0
- package/package.json +1 -1
- package/src/finish.js +19 -9
- package/src/generate.js +1 -1
- package/src/guard.js +3 -1
- package/src/index.d.ts +4 -3
- package/src/presets.js +11 -1
- package/src/primitives.js +2 -1
- package/src/recipes/arcs.js +6 -1
- package/src/recipes/burst.js +33 -5
- package/src/recipes/chevrons.js +25 -7
- package/src/recipes/counter.js +4 -3
- 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 +43 -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 +61 -0
- package/src/recipes/rings.js +49 -6
- 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 +24 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,62 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0 (2026-11-27)
|
|
4
|
+
|
|
5
|
+
The owner's reference styles, from the coverage audit of his 23 references (`drop68-brief.md` in the site repo): 55
|
|
6
|
+
recipes, eleven rows of five in a picker.
|
|
7
|
+
- Ten new recipes: `mosaic` (a capital on a coarse grid of tiles, R1), `weave` (curves woven over and under in a ring,
|
|
8
|
+
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`
|
|
9
|
+
(one band folding back with round turns and a slot, R23), `field` (bars broken by one stepped line, R7), `zigzag` (a
|
|
10
|
+
striped shape broken by a zigzag, R8) and `halfstripe` (half solid, half stepped bars, R18). `nodes`, `weave` and
|
|
11
|
+
`xband` are drawn as distance fields and traced (`@logomarks/core/sdf`): a smooth union gives the concave fillets, and
|
|
12
|
+
it is about twenty times faster than offsetting.
|
|
13
|
+
- Modes: `burst` `ray: 'flare'` and `move: 'slash'` (R6; `slashAngle`, eight rays or more, even: odd, a ray runs along
|
|
14
|
+
the slash; six with a rod is the star of life); `chevrons` `body: 'hexagon'` (R13) and `soft` (R21; `count` now from
|
|
15
|
+
1); `route` `body: 'cube'` (R12); `letter` builds `wedge` (R11, R20), `cut` (R5), `rails` (R15), `hexfold` (R9) and
|
|
16
|
+
`quarter` (R22, the Mosaic grid in quarter discs); the finish `containerMode: 'frame'` and `accentShape: 'square'` (R4).
|
|
17
|
+
- `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
|
|
18
|
+
nodes joined in arches round a centre disc) read as a face, a figure with arms or a phone handset. `mirror` is few
|
|
19
|
+
heavy pieces (two bowed bands meeting in the middle, one thick band above and below bowed in, cut to a hexagon on its
|
|
20
|
+
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
|
|
21
|
+
each other, with pill caps that made a face; a second, with tombstone ends in a disc, came too close to the R19
|
|
22
|
+
reference (17 of 31 draws scored 0.73–0.76 by the house outline measure). Now the default and 200 shuffles score at
|
|
23
|
+
most 0.631 against every reference (the band curve's range starts at 0.7: tighter, it neared R19; any setting by hand
|
|
24
|
+
stays under 0.641), and a test holds the shuffles under 0.65 (`tests/fixtures/r19.json`, R19's signature).
|
|
25
|
+
- Bans by construction, tested on 200 shuffles: no triangle seat in a notch, no diamond in a half stripe, nodes four or
|
|
26
|
+
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
|
|
27
|
+
hand only, a slash never level, upright or along a ray, a mirror cap shorter than one and a half times its width left
|
|
28
|
+
out (a dot).
|
|
29
|
+
- Fixed: a container whose mark was knocked out or clipped to almost nothing (a hole of a crumb in a disc or hexagon)
|
|
30
|
+
passed the guard; one piece whose holes are under 4% of it is now 'too plain'. And `shuffled(…, { locked: ['char'],
|
|
31
|
+
finish: true })` holds the letter (tested; the audit's draw had passed `base` without `locked`).
|
|
32
|
+
- Nine presets (45).
|
|
33
|
+
- `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),
|
|
34
|
+
and so is a leaf in a half disc (an eye; the 0.3.2 note allowed it there).
|
|
35
|
+
- `chevrons` soft keeps its opening to 60–100°, its band under a quarter of the box and its tip pointed (wide or heavy,
|
|
36
|
+
it rounded into a blob or a heart; notched, into two loose bars).
|
|
37
|
+
|
|
38
|
+
## 0.3.2 (2026-11-27)
|
|
39
|
+
|
|
40
|
+
Icon reads ruled out by construction, after the owner's sweep of the mix (a ring with a slash, a feed icon):
|
|
41
|
+
- `rings`: two gaps sit 150° apart, never opposite (a straight channel through the middle is the no-entry or empty-set
|
|
42
|
+
sign); the solid disc inside an open centre takes one gap (two cut it into sectors meeting in a spike); the first gap
|
|
43
|
+
starts at 40° from the top (`START`), and one gap turns at least 24° ring to ring (`minTurn`): a ring broken at twelve
|
|
44
|
+
o'clock round an aligned slot is the power symbol. An open centre is a real hole (its radius 2.6 gaps): filled to the
|
|
45
|
+
middle, the innermost band was a solid disc, and a heavy ring round a slotted disc reads as a power button, a volume
|
|
46
|
+
knob or a dial; the larger hole also keeps the innermost ring's gap from opening it into a keyhole. A dot in a rounded
|
|
47
|
+
frame draws as an open middle (an @). Shuffles now take three to five rings (two is the dial), at most two gaps (three
|
|
48
|
+
on few rings is a car badge), a turn of 20° to 60°, every body (circle, rounded, square, chamfer, hexagon), and never
|
|
49
|
+
move the centre off (the rings crowd into a crescent): 48 shuffles give about twenty layouts, none over an eighth.
|
|
50
|
+
In a round body the innermost ring is never broken once (a C inside a ring is the copyright sign ©, mirrored the
|
|
51
|
+
copyleft sign): it takes two gaps, 150° apart, or, too small for two, closes into a plain ring. Every rings draw moves.
|
|
52
|
+
- `arcs`: a quarter fan takes no disc or square core (a dot in the corner is the RSS icon), and half rings round a disc
|
|
53
|
+
always stand on legs (bare, they are the Wi-Fi icon). Settings that asked for either draw the allowed form.
|
|
54
|
+
- `burst`: eight rays long and short draw as ten (`raysOf`): four long rays on the axes are a plus.
|
|
55
|
+
- `counter`: an almond (leaf) hole only in a half or a quarter (in a square, a soft square or a hexagon it is an eye);
|
|
56
|
+
the default hole is a quarter disc; the Leaf window preset is a quarter disc with a leaf hole.
|
|
57
|
+
- `chevrons`: shuffles and the mix never pick the arrowhead or the stem move (an arrow, a download icon); by hand only.
|
|
58
|
+
- A test checks each ban on the build and on 300 shuffles.
|
|
59
|
+
|
|
3
60
|
## 0.3.1 (2026-11-27)
|
|
4
61
|
|
|
5
62
|
- **Stack keeps its shapes in proportion.** A stack, a row or a stagger no longer stretches each shape to fill its slot
|
package/README.md
CHANGED
|
@@ -52,6 +52,12 @@ MIT © ArrayPress Limited. What you generate is yours to use.
|
|
|
52
52
|
|
|
53
53
|
Seven recipes (and `stack`, a totem) build a mark from DIFFERENT basic shapes, drawn by `src/primitives.js`:
|
|
54
54
|
|
|
55
|
+
`stack` keeps each shape in proportion (since 0.3.1): no shape is drawn flatter than 2.2 to 1 (`FLAT` in
|
|
56
|
+
`src/recipes/stack.js`), and the three are sized along the axis by one rule, its `sizes` control: `equal`, `step` (1 to
|
|
57
|
+
2), `big` (one big, two small) or `fill` (the old stretch to fill, by hand only). `width` sets how wide the column is.
|
|
58
|
+
`overlap` shows a crossing with the full house gap or lays one shape over the other; a crossing that would leave a
|
|
59
|
+
sliver is never knocked out.
|
|
60
|
+
|
|
55
61
|
- `PRIMS`: disc, square, rsquare, triangle, wedge, half, quarter, arch, leaf, pill, diamond, hexagon, ring, bar.
|
|
56
62
|
`prim(type, [x, y, w, h], turn, mirror)` draws one in a box, turned by quarter turns.
|
|
57
63
|
- `alike(a, b)`: two shapes that read the same (a disc and a ring, a square and a rounded square) are never paired.
|
|
@@ -71,3 +77,31 @@ Seven recipes (and `stack`, a totem) build a mark from DIFFERENT basic shapes, d
|
|
|
71
77
|
| `corners` | one block, each corner square, rounded, cut, scooped or notched (never a cross, a star or an arrow) |
|
|
72
78
|
| `offset` | a shape and its copy slid aside: a hard shadow, the overlap knocked out or kept |
|
|
73
79
|
| `quarters` | four big cells, each a different shape, turned by one rule; never a plus-shaped gap |
|
|
80
|
+
|
|
81
|
+
## The reference styles (0.4.0)
|
|
82
|
+
|
|
83
|
+
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
|
|
84
|
+
in the build (and tested on 200 shuffles):
|
|
85
|
+
|
|
86
|
+
- `mosaic`: a capital on a coarse grid (three wide, five tall), each cell a square, a half-square triangle or a quarter
|
|
87
|
+
disc; `tiles` mixed (a square stem, round bowls), round, angled or alternate. M, N and W are by hand only.
|
|
88
|
+
- `weave`: two curves woven over and under in a ring (or three, bare); never one swell (an eye in a ring).
|
|
89
|
+
- `notch`: a block with a chevron notch and a diamond seated in it; the seat is never a triangle (a play button).
|
|
90
|
+
- `nodes`: four or five round nodes at even turns round a ring (a round or rounded-square hole), each joined to it by a
|
|
91
|
+
soft neck, every join a concave fillet (a smooth union of distance fields); never a centre disc (a face, a figure),
|
|
92
|
+
never three nodes (a fidget spinner, near the biohazard sign) or six (a cog).
|
|
93
|
+
- `xband`: an X of two bent bands meeting a gap apart; never two straight bars crossing (a close icon).
|
|
94
|
+
- `mirror`: a bold emblem symmetric both ways, cut to a hexagon on its point or a rounded square: two heavy bowed bands
|
|
95
|
+
meeting in the middle, one thick band above and below bowed in; one band each side and always thick (thin stacked
|
|
96
|
+
arcs are a Wi-Fi icon), never bowed out (a lens with two slits, an eye), no caps or dots. Its default and 200 shuffles score under 0.65 against the R19
|
|
97
|
+
reference by the house outline measure (a test, `tests/fixtures/r19.json`).
|
|
98
|
+
- `ribbon`: one thick band folding back with round turns and a slot.
|
|
99
|
+
- `field`: upright bars broken by one stepped line, the lower parts jogged.
|
|
100
|
+
- `zigzag`: a striped shape broken by a zigzag, one side slid.
|
|
101
|
+
- `halfstripe`: a shape half solid, half bars stepping down; never a diamond (a speaker, a play button).
|
|
102
|
+
|
|
103
|
+
Modes: `burst` takes `ray: 'flare'` and `move: 'slash'` (an even count of eight or more, the slash half way between rays
|
|
104
|
+
and off the axes); `chevrons` takes `body: 'hexagon'` and `soft` (round corners and a slot along one arm; `count` may
|
|
105
|
+
be 1, a soft A); `route` takes `body: 'cube'` (an iso cube, its three faces engraved with short tracks ending in a
|
|
106
|
+
node); `letter` takes five more builds, `wedge`, `cut`, `rails`, `hexfold` and `quarter`; the finish takes
|
|
107
|
+
`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.0",
|
|
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
|
@@ -249,7 +249,7 @@ export function similar(id, params, { count = 12, seed = 1, amount = 0.15, locke
|
|
|
249
249
|
* How often each recipe comes up in `mix()`, relative to 1: the ones whose shuffles most often give a mark worth
|
|
250
250
|
* keeping lead; the textured ones (iso, hex, tiles) come up less.
|
|
251
251
|
*/
|
|
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 };
|
|
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 , 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
253
|
|
|
254
254
|
/**
|
|
255
255
|
* `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;
|
package/src/presets.js
CHANGED
|
@@ -36,9 +36,19 @@ export const PRESETS = [
|
|
|
36
36
|
{ id: 'blade-sweep', name: 'Blade sweep', recipe: 'blades', params: { count: 3, grow: 0.5, width: 1.6 }, note: 'Three blades, each taller than the last.' },
|
|
37
37
|
{ id: 'dome-wedge', name: 'Dome and wedge', recipe: 'merge', params: { a: 'half', b: 'wedge', width: 0.62 }, note: 'A dome fused to a wedge set to one side: one solid.' },
|
|
38
38
|
{ id: 'four-corners', name: 'Four corners', recipe: 'corners', params: { nw: 'round', ne: 'square', se: 'scoop', sw: 'cut', reach: 0.4 }, note: 'One block, each corner treated a different way.' },
|
|
39
|
-
{ id: 'leaf-window', name: 'Leaf window', recipe: 'counter', params: { body: '
|
|
39
|
+
{ id: 'leaf-window', name: 'Leaf window', recipe: 'counter', params: { body: 'quarter', hole: 'leaf', size: 0.44 }, note: 'A quarter disc with a leaf-shaped hole.' },
|
|
40
40
|
{ id: 'facing-halves', name: 'Facing halves', recipe: 'pair', params: { a: 'half', b: 'quarter' }, note: 'A half disc and a quarter disc, flat sides to the split.' },
|
|
41
41
|
{ id: 'disc-on-square', name: 'Disc over square', recipe: 'overlap', params: { a: 'disc', b: 'square', way: 'over' }, note: 'A square laid over a disc, cut free by the gap.' },
|
|
42
42
|
{ id: 'dome-shadow', name: 'Dome shadow', recipe: 'offset', params: { shape: 'half', way: 'shadow', dir: 'se', shift: 0.28 }, note: 'A dome and its copy slid behind it.' },
|
|
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: 'n', weight: 0.27 }, note: 'One band folding back with round turns and a slot.' },
|
|
50
|
+
{ id: 'woven-ring', name: 'Woven ring', recipe: 'weave', params: { strands: 2, swells: 2, height: 0.5, ring: 'ring' }, note: 'Two curves woven over and under in a ring.' },
|
|
51
|
+
{ id: 'zigzag-disc', name: 'Zigzag disc', recipe: 'zigzag', params: { shape: 'circle', stripes: 5, teeth: 2 }, note: 'A striped disc broken by a zigzag, one side slid.' },
|
|
52
|
+
{ 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
53
|
{ 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
54
|
];
|
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/arcs.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* nested arches, stepped arcs and corner bands. The default is arches on legs: a quarter of rings round a disc in a
|
|
5
5
|
* corner is the RSS or Wi-Fi icon. `corner` squares or chamfers the bands into nested L-bands (the corporate-modernist
|
|
6
6
|
* corner marks), `slant` shears the group, and a `quarter` core fills the innermost corner in the bands' own corner style
|
|
7
|
-
* (only on legs: a bare quarter round a corner core is the RSS icon again).
|
|
7
|
+
* (only on legs: a bare quarter round a corner core is the RSS icon again). A quarter fan never takes a disc or square
|
|
8
|
+
* core (RSS), and half rings round a disc always stand on legs (bare, they are the Wi-Fi icon).
|
|
8
9
|
*/
|
|
9
10
|
import { U, D, I, rect, circle, poly, arcBand, sector, mapPts } from '@logomarks/core/geometry';
|
|
10
11
|
import { BOX, GAP, tidy, shear } from '../draw.js';
|
|
@@ -62,6 +63,10 @@ export function build(params) {
|
|
|
62
63
|
// a quarter core is for square or chamfered corners only, and on legs: round rings round a corner core are the RSS icon
|
|
63
64
|
if (p.core === 'quarter' && p.corner === 'round') p.core = 'none';
|
|
64
65
|
if (p.core === 'quarter' && p.legs < 0.2) p.legs = 0.25;
|
|
66
|
+
// a dot in the corner of a quarter fan is the RSS (feed) icon whatever its legs, and a small half disc under half rings
|
|
67
|
+
// with no legs is the Wi-Fi icon: a quarter fan takes no disc or square core, and a half one with a disc stands on legs
|
|
68
|
+
if (p.sweep === 'quarter' && (p.core === 'disc' || p.core === 'square')) p.core = 'none';
|
|
69
|
+
if (p.sweep === 'half' && p.core === 'disc' && p.legs < 0.2) p.legs = 0.25;
|
|
65
70
|
const half = p.sweep === 'half', { x0, y1, cx, size } = BOX;
|
|
66
71
|
let s;
|
|
67
72
|
if (p.move === 'pair') {
|
package/src/recipes/burst.js
CHANGED
|
@@ -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,12 +24,38 @@ 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
|
}
|
|
29
32
|
|
|
30
33
|
/** The mark for resolved params. */
|
|
31
|
-
|
|
34
|
+
/**
|
|
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
|
|
36
|
+
* long and short takes ten rays there, five long.
|
|
37
|
+
*/
|
|
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
|
+
}
|
|
56
|
+
|
|
57
|
+
export function build(params) {
|
|
58
|
+
const p = { ...params, rays: raysOf(params) };
|
|
32
59
|
const R = BOX.size / 2, w = p.width * BOX.size, r0 = Math.max(p.inner * R, p.move === 'dot' ? R * 0.28 : 0);
|
|
33
60
|
const parts = [];
|
|
34
61
|
for (let k = 0; k < p.rays; k++) {
|
|
@@ -39,6 +66,7 @@ export function build(p) {
|
|
|
39
66
|
}
|
|
40
67
|
let s = U(...parts);
|
|
41
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));
|
|
42
70
|
if (p.move === 'dot') s = U(s, circle(BOX.cx, BOX.cy, R * 0.28 - GAP, 64));
|
|
43
71
|
return s;
|
|
44
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);
|
package/src/recipes/counter.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Counter: one solid whose hole is a DIFFERENT shape (a square with a
|
|
2
|
+
* Counter: one solid whose hole is a DIFFERENT shape (a square with a quarter-disc hole, a half disc with a leaf-shaped one), the
|
|
3
3
|
* hole set in the middle or off towards a corner or a side. Never a round hole in a round body (a target), a triangle
|
|
4
|
-
* in a disc or a tile (a play button), or a disc in a leaf (an eye)
|
|
4
|
+
* in a disc or a tile (a play button), or a disc in a leaf (an eye); and an almond hole only in a half or a quarter (in a square, a soft square or a hexagon
|
|
5
|
+
* it is an eye).
|
|
5
6
|
*/
|
|
6
7
|
import { D, rot } from '@logomarks/core/geometry';
|
|
7
8
|
import { BOX, tidy } from '../draw.js';
|
|
@@ -21,7 +22,7 @@ const MOVE = { centre: [0, 0], corner: [1, 1], side: [1, 0], low: [0, 1], high:
|
|
|
21
22
|
/** @type {import('../index.js').Control[]} */
|
|
22
23
|
export const controls = [
|
|
23
24
|
{ key: 'body', label: 'Body', type: 'choice', options: BODIES, value: 'square' },
|
|
24
|
-
{ key: 'hole', label: 'Hole', type: 'choice', options: HOLES, value: '
|
|
25
|
+
{ key: 'hole', label: 'Hole', type: 'choice', options: HOLES, value: 'quarter' },
|
|
25
26
|
{ key: 'size', label: 'Hole size', type: 'range', min: 0.24, max: 0.5, step: 0.01, value: 0.44 },
|
|
26
27
|
{ key: 'place', label: 'Hole position', type: 'choice', options: ['centre', 'corner', 'side', 'low', 'high'], value: 'centre' },
|
|
27
28
|
{ key: 'holeTurn', label: 'Turn hole', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
|
|
@@ -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
|
};
|