@logomarks/generate 0.3.2 → 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 +35 -0
- package/README.md +28 -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 +10 -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 +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/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 +20 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
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
|
+
|
|
3
38
|
## 0.3.2 (2026-11-27)
|
|
4
39
|
|
|
5
40
|
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
|
@@ -77,3 +77,31 @@ sliver is never knocked out.
|
|
|
77
77
|
| `corners` | one block, each corner square, rounded, cut, scooped or notched (never a cross, a star or an arrow) |
|
|
78
78
|
| `offset` | a shape and its copy slid aside: a hard shadow, the overlap knocked out or kept |
|
|
79
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
|
@@ -40,5 +40,15 @@ 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: '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/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
|
};
|
package/src/recipes/letter.js
CHANGED
|
@@ -4,9 +4,13 @@
|
|
|
4
4
|
* by the gap). Three from core's letter skeletons (one geometric sans as centrelines): stencil (each stroke solid, split
|
|
5
5
|
* at its sharp corners and cleared from the ones before by the gap, a closed bowl slit at its top), slabs (the stencil
|
|
6
6
|
* parts sheared and parted wider, like Shear) and route (the skeleton walked in runs at 0°, 45° and 90°, mitred, like
|
|
7
|
-
* Route).
|
|
7
|
+
* Route). And five more: wedge (strokes cut level at the cap and base lines: slanted-slab letters), cut (the route
|
|
8
|
+
* letter heavy, its outer corners rounded: the upright, diagonal band and quarter round of a cut block letter), rails
|
|
9
|
+
* (two nested strokes), hexfold (heavy, cut by a hexagon) and quarter (the Mosaic grid in quarter discs). After
|
|
10
|
+
* lettermarks built as blocks, slabs and bands: a K of slanted slabs, an H of three bars.
|
|
8
11
|
*/
|
|
9
|
-
import { U, D, I, rect, rr, mapPts, stroke, SKEL, skelSolid, skStroke, skLine, robust } from '@logomarks/core/geometry';
|
|
12
|
+
import { U, D, I, rect, rr, mapPts, stroke, grow, regular, SKEL, skelSolid, skStroke, skLine, robust } from '@logomarks/core/geometry';
|
|
13
|
+
import { build as mosaic, CHARS as MOSAIC } from './mosaic.js';
|
|
10
14
|
import { BOX, GAP, clear, tidy } from '../draw.js';
|
|
11
15
|
|
|
12
16
|
robust();
|
|
@@ -57,7 +61,7 @@ const NUMERAL = { 0: 'Zero', 1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five
|
|
|
57
61
|
/** @type {import('../index.js').Control[]} */
|
|
58
62
|
export const controls = [
|
|
59
63
|
{ key: 'char', label: 'Letter', type: 'choice', options: CHARS, value: 'K' },
|
|
60
|
-
{ key: 'build', label: 'Build', type: 'choice', options: ['slabs', 'stencil', 'route', 'tiles', 'blocks', 'pixel'], value: 'slabs' },
|
|
64
|
+
{ key: 'build', label: 'Build', type: 'choice', options: ['slabs', 'stencil', 'route', 'tiles', 'blocks', 'pixel', 'wedge', 'cut', 'rails', 'hexfold', 'quarter'], value: 'slabs' },
|
|
61
65
|
{ key: 'weight', label: 'Weight', type: 'range', min: 0.12, max: 0.26, step: 0.005, value: 0.2 },
|
|
62
66
|
{ key: 'slant', label: 'Slant', type: 'range', min: -20, max: 20, step: 1, value: 0 },
|
|
63
67
|
{ key: 'spacing', label: 'Gaps', type: 'range', min: 1, max: 2.5, step: 0.1, value: 1.2 },
|
|
@@ -188,11 +192,53 @@ function routeLetter(ch, H, T) {
|
|
|
188
192
|
return I(U(...parts), rect(-600, -T / 2, 1800, H + T));
|
|
189
193
|
}
|
|
190
194
|
|
|
195
|
+
/**
|
|
196
|
+
* Wedge: the stencil letter with every stroke that ends on the cap or base line run on past it and cut level there, so
|
|
197
|
+
* an upright ends square and a diagonal becomes a parallelogram with a flat top and foot (the slanted-slab M).
|
|
198
|
+
*/
|
|
199
|
+
function wedgeLetter(ch, H, T, gap) {
|
|
200
|
+
const run = (a, b) => { const l = Math.hypot(b[0] - a[0], b[1] - a[1]) || 1; return [b[0] + ((b[0] - a[0]) / l) * T, b[1] + ((b[1] - a[1]) / l) * T]; };
|
|
201
|
+
const edge = (q) => q[1] < 1 || q[1] > H - 1;
|
|
202
|
+
const strokes = splitAtCorners(skeleton(ch, H)).map((st) => {
|
|
203
|
+
if (st.closed || st.p.length < 2) return st;
|
|
204
|
+
const pts = st.p.slice();
|
|
205
|
+
if (edge(pts[0])) pts[0] = run(pts[1], pts[0]);
|
|
206
|
+
if (edge(pts.at(-1))) pts[pts.length - 1] = run(pts.at(-2), pts.at(-1));
|
|
207
|
+
return skStroke(pts, st.e);
|
|
208
|
+
}).sort((a, b) => lengthOf(b) - lengthOf(a));
|
|
209
|
+
const parts = [];
|
|
210
|
+
for (const st of strokes) { const solid = skelSolid(null, H, T, [st]); parts.push(parts.length ? clear(solid, U(...parts), gap) : solid); }
|
|
211
|
+
return I(U(...parts), rect(-600, 0, 1800, H));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Rails: the letter drawn heavy, then as two nested strokes: its outer rim and an inner core, the gap between (the
|
|
216
|
+
* offset-line F).
|
|
217
|
+
*/
|
|
218
|
+
function railsLetter(ch, H, T) {
|
|
219
|
+
const heavy = skelSolid(null, H, T * 1.55, skeleton(ch, H)), W = T * 1.55, a = (W - 2 * GAP) / 3;
|
|
220
|
+
return U(D(heavy, grow(heavy, -a)), grow(heavy, -a - GAP));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Hexfold: the stencil letter drawn heavy and cut by a hexagon standing on a point round it (its corners chamfered). */
|
|
224
|
+
function hexfoldLetter(ch, H, T, gap) {
|
|
225
|
+
const s = stencilLetter(ch, H, T * 1.3, gap);
|
|
226
|
+
let x0 = Infinity, x1 = -Infinity;
|
|
227
|
+
for (const poly of s) for (const [x] of poly[0]) { x0 = Math.min(x0, x); x1 = Math.max(x1, x); }
|
|
228
|
+
const cx = (x0 + x1) / 2, r = Math.max(H * 0.58, (x1 - x0) * 0.6);
|
|
229
|
+
return I(s, regular(cx, H / 2, r, 6, -90));
|
|
230
|
+
}
|
|
231
|
+
|
|
191
232
|
/** The mark for resolved params. */
|
|
192
233
|
export function build(p) {
|
|
193
234
|
const ch = String(p.char), H = 400, T = p.weight * BOX.size;
|
|
194
235
|
let s;
|
|
236
|
+
if (p.build === 'quarter') return MOSAIC.includes(ch) ? mosaic({ char: ch, tiles: 'round', parted: false, corners: 'outer' }) : tidy(bitmapLetter(ch, 'tiles', p), { share: 0.004, width: 10 });
|
|
195
237
|
if (p.build === 'tiles' || p.build === 'blocks' || p.build === 'pixel') s = bitmapLetter(ch, p.build, p);
|
|
238
|
+
else if (p.build === 'wedge') s = wedgeLetter(ch, H, T * 1.25, GAP * p.spacing);
|
|
239
|
+
else if (p.build === 'cut') { const r = routeLetter(ch, H, T * 1.15), k = T * 0.45; s = grow(grow(r, -k), k); }
|
|
240
|
+
else if (p.build === 'rails') s = railsLetter(ch, H, T);
|
|
241
|
+
else if (p.build === 'hexfold') s = hexfoldLetter(ch, H, T, GAP * p.spacing);
|
|
196
242
|
else if (p.build === 'route') s = routeLetter(ch, H, T * 0.9);
|
|
197
243
|
else s = stencilLetter(ch, H, T, GAP * p.spacing * (p.build === 'slabs' ? 1.5 : 1));
|
|
198
244
|
const slant = p.slant + (p.build === 'slabs' ? 12 : 0);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mirror: a bold emblem symmetric both ways, in few heavy pieces cut by a body (a hexagon on its point or a rounded
|
|
3
|
+
* square): across the middle two thick bowed bands that meet at the centre and part towards the sides in a V; above and
|
|
4
|
+
* below, one thick band bowed in towards the middle, a gap between.
|
|
5
|
+
* After the arch emblems of the owner's references, made a family of its own rather than one of them: no end caps, the
|
|
6
|
+
* body and the bands vary. One band each side and always thick (thin arcs stacked are a Wi-Fi icon), no dots (a face).
|
|
7
|
+
*/
|
|
8
|
+
import { U, I, arcBand, mapPts, rr, regular } from '@logomarks/core/geometry';
|
|
9
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
10
|
+
|
|
11
|
+
/** @type {import('../index.js').Control[]} */
|
|
12
|
+
export const controls = [
|
|
13
|
+
{ key: 'body', label: 'Body', type: 'choice', options: ['hexagon', 'square'], value: 'hexagon' },
|
|
14
|
+
{ key: 'weight', label: 'Weight', type: 'range', min: 0.22, max: 0.34, step: 0.005, value: 0.28 },
|
|
15
|
+
{ key: 'bow', label: 'Middle curve', type: 'range', min: 1, max: 1.8, step: 0.05, value: 1.3 },
|
|
16
|
+
{ key: 'bowl', label: 'Band curve', type: 'range', min: 0.7, max: 1.1, step: 0.01, value: 0.78 },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
/** The body, filling the box. */
|
|
20
|
+
function body(kind) {
|
|
21
|
+
const { cx, cy, x0, y0, size } = BOX;
|
|
22
|
+
// a hexagon standing on a point (on its side, points left and right, the silhouette is the reference's own) or a
|
|
23
|
+
// rounded square; never a disc (with these bands, the reference itself)
|
|
24
|
+
if (kind === 'hexagon') return regular(cx, cy, size / 2, 6, -90);
|
|
25
|
+
return rr(x0, y0, size, size, size * 0.2);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The mark for resolved params. */
|
|
29
|
+
export function build(p) {
|
|
30
|
+
const R = BOX.size / 2, T = p.weight * R, { cx, cy } = BOX;
|
|
31
|
+
// the middle: a band sagging from above and its mirror rising from below, meeting at the centre (never a straight bar:
|
|
32
|
+
// with a band either side, a divide sign; inside a lens, a theta or an eye)
|
|
33
|
+
const Rc = R * p.bow, middle = arcBand(cx, cy - Rc, Rc, T, 5, 175);
|
|
34
|
+
// the band above, a gap over the middle's top edge, bowed in (a bowl, its low point over the centre). Never bowed out:
|
|
35
|
+
// with the middle it closes into a lens with two slits, an eye
|
|
36
|
+
const edge = cy - T / 2 - GAP * 1.5, r2 = R * p.bowl * 1.4;
|
|
37
|
+
const band = arcBand(cx, edge - T / 2 - r2, r2, T, 5, 175);
|
|
38
|
+
const above = U(middle, band), below = mapPts(above, ([x, y]) => [x, 2 * cy - y]);
|
|
39
|
+
return tidy(I(U(above, below), body(p.body)));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Four to six heavy pieces. */
|
|
43
|
+
export const guard = {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mosaic: a capital on a coarse grid of cells (three wide, five tall, four wide for M and W), each filled cell one tile:
|
|
3
|
+
* a square, a half-square triangle or a quarter disc. Where a cell's two outer sides are open the tile turns its corner,
|
|
4
|
+
* round or angled; a diagonal stroke (the legs of K, M, N, V, W, X, Y, Z) is drawn by triangle cells. `tiles` sets the
|
|
5
|
+
* rule: all round, all angled, mixed (the stem square, the bowls of a B or a D round) or alternate (round and angled
|
|
6
|
+
* by the cell's parity). `parted` sets the cells apart by the gap instead of edge to edge. After Biskon's B and the tile-built
|
|
7
|
+
* capitals of Letters · Half Square.
|
|
8
|
+
*/
|
|
9
|
+
import { U, rect, poly, circle, I, mapPts } from '@logomarks/core/geometry';
|
|
10
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The grids: '#' a square, '.' empty, a triangle named by the corner its right angle fills ('1' top left, '2' top
|
|
14
|
+
* right, '3' bottom right, '4' bottom left: a diagonal stroke runs along its long side), and a joint ('a' to 'd', the
|
|
15
|
+
* same corners): the tile that joins two squares meeting only at a corner, a triangle or a quarter disc by the tile rule.
|
|
16
|
+
*/
|
|
17
|
+
const GRID = {
|
|
18
|
+
A: ['###', '#.#', '###', '#.#', '#.#'],
|
|
19
|
+
B: ['##d', '#.#', '###', '#.#', '##a'],
|
|
20
|
+
C: ['###', '#..', '#..', '#..', '###'],
|
|
21
|
+
D: ['##d', '#.#', '#.#', '#.#', '##a'],
|
|
22
|
+
E: ['###', '#..', '##.', '#..', '###'],
|
|
23
|
+
F: ['###', '#..', '##.', '#..', '#..'],
|
|
24
|
+
G: ['###', '#..', '#.#', '#.#', '###'],
|
|
25
|
+
H: ['#.#', '#.#', '###', '#.#', '#.#'],
|
|
26
|
+
J: ['..#', '..#', '..#', '#.#', '###'],
|
|
27
|
+
K: ['#.#', '#3#', '##.', '#2#', '#.#'],
|
|
28
|
+
L: ['#..', '#..', '#..', '#..', '###'],
|
|
29
|
+
M: ['#43#', '#..#', '#..#', '#..#', '#..#'],
|
|
30
|
+
N: ['#..#', '##.#', '#2##', '#..#', '#..#'],
|
|
31
|
+
P: ['##d', '#.#', '##a', '#..', '#..'],
|
|
32
|
+
R: ['##d', '#.#', '##a', '#b#', '#.#'],
|
|
33
|
+
S: ['###', '#..', '###', '..#', '###'],
|
|
34
|
+
T: ['###', '.#.', '.#.', '.#.', '.#.'],
|
|
35
|
+
U: ['#.#', '#.#', '#.#', '#.#', '###'],
|
|
36
|
+
V: ['#.#', '#.#', '#.#', '2.1', '.#.'],
|
|
37
|
+
W: ['#..#', '#..#', '#..#', '#..#', '#12#'],
|
|
38
|
+
X: ['#.#', '2.1', '.#.', '3.4', '#.#'],
|
|
39
|
+
Y: ['#.#', '#.#', '2#1', '.#.', '.#.'],
|
|
40
|
+
Z: ['###', '.3#', '.#.', '#1.', '###'],
|
|
41
|
+
};
|
|
42
|
+
export const CHARS = Object.keys(GRID);
|
|
43
|
+
|
|
44
|
+
/** @type {import('../index.js').Control[]} */
|
|
45
|
+
export const controls = [
|
|
46
|
+
{ key: 'char', label: 'Letter', type: 'choice', options: CHARS, value: 'B' },
|
|
47
|
+
{ key: 'tiles', label: 'Corners', type: 'choice', options: ['mixed', 'round', 'angled', 'alternate'], value: 'mixed' },
|
|
48
|
+
{ key: 'parted', label: 'Cells apart', type: 'toggle', value: false },
|
|
49
|
+
{ key: 'corners', label: 'Turned corners', type: 'choice', options: ['outer', 'all', 'ends'], value: 'outer' },
|
|
50
|
+
{ key: 'width', label: 'Cell width', type: 'range', min: 0.8, max: 1.3, step: 0.01, value: 1 },
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
/** A quarter disc filling a cell, its round corner at `corner` (0 top left, 1 top right, 2 bottom right, 3 bottom left). */
|
|
54
|
+
function quarter(x, y, s, corner) {
|
|
55
|
+
const c = [[x + s, y + s], [x, y + s], [x, y], [x + s, y]][corner];
|
|
56
|
+
return I(circle(c[0], c[1], s, 96), rect(x, y, s, s));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** A half-square triangle filling the corner `corner` of a cell (the same numbering as `quarter`). */
|
|
60
|
+
function triangle(x, y, s, corner) {
|
|
61
|
+
const P = [[x, y], [x + s, y], [x + s, y + s], [x, y + s]];
|
|
62
|
+
return poly([P[corner], P[(corner + 1) % 4], P[(corner + 3) % 4]]);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The mark for resolved params. */
|
|
66
|
+
export function build(p) {
|
|
67
|
+
const rows = GRID[p.char] || GRID.B, cols = rows[0].length, n = rows.length;
|
|
68
|
+
const g = p.parted ? GAP : 0, sh = (BOX.size - (n - 1) * g) / n, sw = sh * (p.width ?? 1), s = sh, w = cols * sw + (cols - 1) * g;
|
|
69
|
+
const at = (c, r) => rows[r]?.[c] ?? '.', full = (c, r) => at(c, r) === '#';
|
|
70
|
+
const filled = (c, r) => at(c, r) !== '.';
|
|
71
|
+
const parts = [];
|
|
72
|
+
for (let r = 0; r < n; r++) for (let c = 0; c < cols; c++) {
|
|
73
|
+
const ch = at(c, r), x = BOX.cx - (cols * s + (cols - 1) * g) / 2 + c * (s + g), y = BOX.y0 + r * (s + g);
|
|
74
|
+
if (ch === '.') continue;
|
|
75
|
+
if ('1234'.includes(ch)) { parts.push(triangle(x, y, s, Number(ch) - 1)); continue; }
|
|
76
|
+
if ('abcd'.includes(ch)) {
|
|
77
|
+
const k = 'abcd'.indexOf(ch), round = p.tiles === 'round' || (p.tiles === 'mixed' && c > 0) || (p.tiles === 'alternate' && (c + r) % 2 === 0);
|
|
78
|
+
parts.push(round ? quarter(x, y, s, (k + 2) % 4) : triangle(x, y, s, k));
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
// which corner turns: the one whose two sides are open (outer); with `all`, also a corner with one open side at a
|
|
82
|
+
// stroke's end; `ends`, only the cell at the end of a stroke (open on three sides)
|
|
83
|
+
const open = [[-1, 0], [0, -1], [1, 0], [0, 1]].map(([dc, dr]) => !filled(c + dc, r + dr));
|
|
84
|
+
const corners = [[open[0] && open[1]], [open[1] && open[2]], [open[2] && open[3]], [open[3] && open[0]]].map(([v]) => v);
|
|
85
|
+
const ends = open.filter(Boolean).length >= 3;
|
|
86
|
+
let corner = -1;
|
|
87
|
+
if (p.corners !== 'ends' || ends) corner = corners.findIndex(Boolean);
|
|
88
|
+
if (corner < 0 || (!full(c, r))) { parts.push(rect(x - (g ? 0 : 0.02), y - (g ? 0 : 0.02), s + (g ? 0 : 0.04), s + (g ? 0 : 0.04))); continue; }
|
|
89
|
+
// mixed: the stem (the left column) keeps its square corners, the rest round (Biskon's B)
|
|
90
|
+
if (p.tiles === 'mixed' && c === 0) { parts.push(rect(x - (g ? 0 : 0.02), y - (g ? 0 : 0.02), s + (g ? 0 : 0.04), s + (g ? 0 : 0.04))); continue; }
|
|
91
|
+
const round = p.tiles === 'round' || p.tiles === 'mixed' || (p.tiles === 'alternate' && (c + r) % 2 === 0);
|
|
92
|
+
const keep = (corner + 2) % 4; // the tile keeps the corner opposite the one that turns
|
|
93
|
+
parts.push(round ? quarter(x, y, s, corner) : triangle(x, y, s, keep));
|
|
94
|
+
// a second open corner on the same cell (a cell open on three sides) turns too: the cell becomes a half
|
|
95
|
+
if (p.corners === 'all') {
|
|
96
|
+
const second = corners.findIndex((v, k) => v && k !== corner);
|
|
97
|
+
if (second >= 0) parts[parts.length - 1] = I(parts.at(-1), round ? quarter(x, y, s, second) : triangle(x, y, s, (second + 2) % 4));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// cells drawn square, then the whole letter stretched across by the cell width
|
|
101
|
+
const k = sw / sh, out = U(...parts);
|
|
102
|
+
return tidy(k === 1 ? out : mapPts(out, ([x, y]) => [BOX.cx + (x - BOX.cx) * k, y]), { share: 0.004, width: 10 });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** A mosaic letter is up to fifteen cells; parted, each its own piece. */
|
|
106
|
+
export const guard = { maxPieces: 22, minInkShare: 0.2 };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nodes: four or five round nodes at even turns round a ring (a round or rounded-square hole through the middle), each
|
|
3
|
+
* joined to the ring by a soft neck, every join a concave fillet, so the whole reads as one soft solid with a hole.
|
|
4
|
+
* After Orbience's soft X and the live Soft · Nodes. Never a centre disc (with the nodes round it, a face or a figure),
|
|
5
|
+
* never three nodes (a fidget spinner, near the biohazard sign) or six (a cog), and no orbits (an atom).
|
|
6
|
+
*/
|
|
7
|
+
import { sdCircle, sdBox, shell, smin, shapeOf } from '@logomarks/core/sdf';
|
|
8
|
+
import { BOX, tidy } from '../draw.js';
|
|
9
|
+
|
|
10
|
+
/** @type {import('../index.js').Control[]} */
|
|
11
|
+
export const controls = [
|
|
12
|
+
{ key: 'nodes', label: 'Nodes', type: 'range', min: 4, max: 5, step: 1, value: 4 },
|
|
13
|
+
{ key: 'size', label: 'Node size', type: 'range', min: 0.13, max: 0.24, step: 0.01, value: 0.19 },
|
|
14
|
+
{ key: 'ring', label: 'Ring width', type: 'range', min: 0.1, max: 0.24, step: 0.01, value: 0.16 },
|
|
15
|
+
{ key: 'hole', label: 'Hole', type: 'range', min: 0.2, max: 0.42, step: 0.01, value: 0.3 },
|
|
16
|
+
{ key: 'neck', label: 'Neck', type: 'range', min: 0.3, max: 1, step: 0.05, value: 0.6 },
|
|
17
|
+
{ key: 'shape', label: 'Hole shape', type: 'choice', options: ['round', 'square'], value: 'round' },
|
|
18
|
+
{ key: 'sizes', label: 'Node sizes', type: 'choice', options: ['even', 'big-small'], value: 'even' },
|
|
19
|
+
{ key: 'spin', label: 'Spin', type: 'range', min: 0, max: 90, step: 1, value: 45 },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
/** The mark for resolved params. */
|
|
23
|
+
export function build(p) {
|
|
24
|
+
const n = p.nodes, R = BOX.size / 2, { cx, cy } = BOX;
|
|
25
|
+
const hole = p.hole * R, w = p.ring * R, mid = hole + w / 2;
|
|
26
|
+
const fields = [p.shape === 'square' ? shell(sdBox(cx, cy, 2 * mid, 2 * mid, mid * 0.28), w) : shell(sdCircle(cx, cy, mid), w)];
|
|
27
|
+
for (let k = 0; k < n; k++) {
|
|
28
|
+
// big and small take turns (four only: with five the odd one is out)
|
|
29
|
+
const rn = p.size * R * (p.sizes === 'big-small' && n === 4 ? (k % 2 ? 0.78 : 1.15) : 1);
|
|
30
|
+
// each node sits just off the ring's outer edge and the smooth union draws the neck across (wide enough that it
|
|
31
|
+
// always joins: a node left apart is a dot round a ring, a loading spinner); the fit scales the whole to the box
|
|
32
|
+
const a = ((p.spin - 90 + (360 * k) / n) * Math.PI) / 180, d = mid + w / 2 + rn * 1.05;
|
|
33
|
+
fields.push(sdCircle(cx + d * Math.cos(a), cy + d * Math.sin(a), rn));
|
|
34
|
+
}
|
|
35
|
+
// a smooth union: the neck between each node and the ring a concave fillet, its width by `neck`
|
|
36
|
+
const k = p.size * R * (0.35 + p.neck * 0.55);
|
|
37
|
+
return tidy(shapeOf(smin(k, ...fields), { h: 2, x0: BOX.x0 - 8, y0: BOX.y0 - 8, x1: BOX.x1 + 8, y1: BOX.y1 + 8 }));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** One soft solid with one hole. */
|
|
41
|
+
export const guard = {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notch: a block (square, chamfered or rounded) with a chevron notch cut into one side and a diamond seated in the
|
|
3
|
+
* notch, the gap all round it, poking out past the side; the block parted from the notch's point to the
|
|
4
|
+
* far side by the gap if asked. After Dinpak's D. The notch is always on a side (on the top it is an envelope), the seat
|
|
5
|
+
* is never a triangle (a play button), and nothing runs behind the point (an arrow).
|
|
6
|
+
*/
|
|
7
|
+
import { U, D, rect, poly, rr, grow } from '@logomarks/core/geometry';
|
|
8
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
9
|
+
|
|
10
|
+
/** @type {import('../index.js').Control[]} */
|
|
11
|
+
export const controls = [
|
|
12
|
+
{ key: 'body', label: 'Block', type: 'choice', options: ['chamfer', 'square', 'rounded'], value: 'chamfer' },
|
|
13
|
+
{ key: 'depth', label: 'Notch depth', type: 'range', min: 0.22, max: 0.5, step: 0.01, value: 0.34 },
|
|
14
|
+
{ key: 'mouth', label: 'Notch mouth', type: 'range', min: 0.45, max: 0.85, step: 0.01, value: 0.62 },
|
|
15
|
+
{ key: 'seat', label: 'Seat', type: 'choice', options: ['diamond', 'none'], value: 'diamond' },
|
|
16
|
+
{ key: 'split', label: 'Parted', type: 'toggle', value: true },
|
|
17
|
+
{ key: 'width', label: 'Width', type: 'range', min: 0.7, max: 1, step: 0.01, value: 0.86 },
|
|
18
|
+
{ key: 'height', label: 'Height', type: 'range', min: 0.5, max: 1, step: 0.01, value: 0.72 },
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
/** The mark for resolved params. */
|
|
22
|
+
export function build(p) {
|
|
23
|
+
const H = BOX.size * p.height, W = BOX.size * p.width, x0 = BOX.cx - W / 2 + (p.seat === 'diamond' ? W * 0.08 : 0), y0 = BOX.cy - H / 2;
|
|
24
|
+
const x1 = x0 + W, cy = BOX.cy, c = H * 0.22;
|
|
25
|
+
let body;
|
|
26
|
+
if (p.body === 'chamfer') body = poly([[x0, y0], [x1 - c, y0], [x1, y0 + c], [x1, y0 + H - c], [x1 - c, y0 + H], [x0, y0 + H]]);
|
|
27
|
+
else if (p.body === 'rounded') body = rr(x0, y0, W, H, [0, c, c, 0]);
|
|
28
|
+
else body = rect(x0, y0, W, H);
|
|
29
|
+
// the notch: a V from the left side, its mouth `mouth` of the height, its point `depth` of the width in
|
|
30
|
+
const m = (H * p.mouth) / 2, d = W * p.depth;
|
|
31
|
+
const notch = poly([[x0 - 2, cy - m - 2], [x0 + d, cy], [x0 - 2, cy + m + 2]]);
|
|
32
|
+
let s = D(body, notch);
|
|
33
|
+
if (p.split) s = D(s, rect(x0 + d - 1, cy - GAP / 2, W, GAP));
|
|
34
|
+
if (p.seat !== 'none') {
|
|
35
|
+
// the seat: the notch shrunk by the gap, mirrored out past the side into a diamond (or left as the notch's own shape, sunk)
|
|
36
|
+
const k = (d - GAP * 1.5) / d;
|
|
37
|
+
if (k > 0.3) {
|
|
38
|
+
const dx = d * k, dy = m * k, ax = x0 + d - GAP * 1.5 / Math.sin(Math.atan2(m, d));
|
|
39
|
+
const seat = poly([[ax, cy], [ax - dx, cy - dy], [ax - 2 * dx, cy], [ax - dx, cy + dy]]);
|
|
40
|
+
s = U(s, D(seat, grow(s, GAP)));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return tidy(s);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** A block, its parts and its seat. */
|
|
47
|
+
export const guard = {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ribbon: one thick band that folds back on itself, its turns round, a slot (a round-ended gap) along its longest run,
|
|
3
|
+
* one end square and the other cut by the box. After the folded S of the owner's references. Unlike a plain letter (the
|
|
4
|
+
* dropped Fold, mitred, read as blocky L, U, S): the round turns, the slot and the weight are always there.
|
|
5
|
+
*/
|
|
6
|
+
import { D, I, rect, stroke, pill, grow } from '@logomarks/core/geometry';
|
|
7
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
8
|
+
|
|
9
|
+
/** The paths, in a unit box (0–1 across and down). */
|
|
10
|
+
const PATHS = {
|
|
11
|
+
n: [[0, 1], [0, 0], [1, 1], [1, 0]],
|
|
12
|
+
z: [[0, 0], [1, 0], [0, 1], [1, 1]],
|
|
13
|
+
hook: [[1, 0], [0.3, 0], [1, 0.85], [0.1, 0.85]],
|
|
14
|
+
hairpin: [[0, 1], [0, 0], [1, 1], [1, 0.45]],
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** @type {import('../index.js').Control[]} */
|
|
18
|
+
export const controls = [
|
|
19
|
+
{ key: 'path', label: 'Fold', type: 'choice', options: Object.keys(PATHS), value: 'n' },
|
|
20
|
+
{ key: 'weight', label: 'Weight', type: 'range', min: 0.2, max: 0.34, step: 0.005, value: 0.27 },
|
|
21
|
+
{ key: 'bend', label: 'Turn radius', type: 'range', min: 0.6, max: 1.4, step: 0.05, value: 1 },
|
|
22
|
+
{ key: 'slot', label: 'Slot length', type: 'range', min: 0.35, max: 0.75, step: 0.01, value: 0.55 },
|
|
23
|
+
{ key: 'width', label: 'Width', type: 'range', min: 0.7, max: 1, step: 0.01, value: 0.86 },
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
/** A polyline with each inner corner rounded: a circular-ish quadratic `r` back along both legs. */
|
|
27
|
+
function fillet(pts, r) {
|
|
28
|
+
const out = [pts[0]];
|
|
29
|
+
for (let k = 1; k < pts.length - 1; k++) {
|
|
30
|
+
const [a, v, b] = [pts[k - 1], pts[k], pts[k + 1]];
|
|
31
|
+
const la = Math.hypot(a[0] - v[0], a[1] - v[1]), lb = Math.hypot(b[0] - v[0], b[1] - v[1]), d = Math.min(r, la * 0.48, lb * 0.48);
|
|
32
|
+
const p1 = [v[0] + ((a[0] - v[0]) * d) / la, v[1] + ((a[1] - v[1]) * d) / la], p2 = [v[0] + ((b[0] - v[0]) * d) / lb, v[1] + ((b[1] - v[1]) * d) / lb];
|
|
33
|
+
for (let i = 0; i <= 16; i++) { const t = i / 16, u = 1 - t; out.push([u * u * p1[0] + 2 * u * t * v[0] + t * t * p2[0], u * u * p1[1] + 2 * u * t * v[1] + t * t * p2[1]]); }
|
|
34
|
+
}
|
|
35
|
+
out.push(pts.at(-1));
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The mark for resolved params. */
|
|
40
|
+
export function build(p) {
|
|
41
|
+
const T = p.weight * BOX.size, W = BOX.size * p.width - T, H = BOX.size - T;
|
|
42
|
+
const x0 = BOX.cx - W / 2, y0 = BOX.y0 + T / 2;
|
|
43
|
+
const pts = PATHS[p.path].map(([u, v]) => [x0 + u * W, y0 + v * H]);
|
|
44
|
+
// the ends run a little past the box so the box's edge squares them off
|
|
45
|
+
const ext = (a, b) => { const l = Math.hypot(b[0] - a[0], b[1] - a[1]); return [b[0] + ((b[0] - a[0]) / l) * T, b[1] + ((b[1] - a[1]) / l) * T]; };
|
|
46
|
+
pts[0] = ext(pts[1], pts[0]);
|
|
47
|
+
pts[pts.length - 1] = ext(pts.at(-2), pts.at(-1));
|
|
48
|
+
let s = stroke(fillet(pts, T * p.bend), T, {});
|
|
49
|
+
// the slot: a round-ended gap along the middle of the longest run
|
|
50
|
+
let best = 1, bl = 0;
|
|
51
|
+
for (let k = 1; k < pts.length - 2; k++) { const l = Math.hypot(pts[k + 1][0] - pts[k][0], pts[k + 1][1] - pts[k][1]); if (l > bl) { bl = l; best = k; } }
|
|
52
|
+
if (pts.length === 4) best = 1; // the middle run of a three-run fold
|
|
53
|
+
const [a, b] = [pts[best], pts[best + 1]], m = [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2], h = p.slot / 2;
|
|
54
|
+
const sa = [m[0] + (a[0] - m[0]) * h * 2 * 0.5, m[1] + (a[1] - m[1]) * h * 2 * 0.5], sb = [m[0] + (b[0] - m[0]) * h * 2 * 0.5, m[1] + (b[1] - m[1]) * h * 2 * 0.5];
|
|
55
|
+
s = D(s, pill(sa, sb, GAP));
|
|
56
|
+
return tidy(I(s, rect(BOX.x0, BOX.y0, BOX.size, BOX.size)));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** One band with a slot: its turns are its only curves. */
|
|
60
|
+
export const guard = {};
|
|
61
|
+
void grow;
|
package/src/recipes/route.js
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
* Route: heavy bands that run only level, upright or at 45°, turning on a lattice and forking, joined by nodes (a
|
|
3
3
|
* square, a diamond or a disc) where they turn, laid out by a numbered layout. After the owner's favourite, Tech · Route.
|
|
4
4
|
* `frame` joins the bands to a square frame (full, open on one side, or two corner Ls: the square-glyph meanders), which
|
|
5
|
-
* turns the diagonals off; `turns` round fillets every turn.
|
|
5
|
+
* turns the diagonals off; `turns` round fillets every turn. `body: 'cube'` draws an iso cube instead, its three faces
|
|
6
|
+
* a gap apart, each engraved with one or two short round-ended tracks ending in a node (circuit tracks on a cube). A framed layout that looks the same a quarter turn round
|
|
6
7
|
* (four hooks round a centre) is passed over for the next layout.
|
|
7
8
|
*/
|
|
8
|
-
import { U, rect, poly, circle, stroke, rot } from '@logomarks/core/geometry';
|
|
9
|
-
import { BOX } from '../draw.js';
|
|
9
|
+
import { U, D, rect, poly, circle, stroke, rot } from '@logomarks/core/geometry';
|
|
10
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
10
11
|
import { rng } from '../random.js';
|
|
11
12
|
import { fill } from '../raster.js';
|
|
12
13
|
|
|
@@ -21,6 +22,7 @@ export const controls = [
|
|
|
21
22
|
{ key: 'diagonals', label: 'Diagonals', type: 'toggle', value: true },
|
|
22
23
|
{ key: 'frame', label: 'Frame', type: 'choice', options: ['none', 'full', 'open', 'corners'], value: 'none' },
|
|
23
24
|
{ key: 'turns', label: 'Turns', type: 'choice', options: ['mitre', 'round'], value: 'mitre' },
|
|
25
|
+
{ key: 'body', label: 'Body', type: 'choice', options: ['square', 'cube'], value: 'square' },
|
|
24
26
|
];
|
|
25
27
|
|
|
26
28
|
/** A polyline with every inner corner filleted: each turn becomes a quadratic curve `r` back along both legs. */
|
|
@@ -71,6 +73,7 @@ function node(kind, [x, y], w) {
|
|
|
71
73
|
|
|
72
74
|
/** The mark for resolved params. */
|
|
73
75
|
export function build(p) {
|
|
76
|
+
if (p.body === 'cube') return cube(p, p.layout);
|
|
74
77
|
const framed = p.frame && p.frame !== 'none';
|
|
75
78
|
for (let tries = 0; tries < 6; tries++) {
|
|
76
79
|
const s = draw(p, p.layout + tries * 1000, framed);
|
|
@@ -103,5 +106,46 @@ function draw(p, layout, framed) {
|
|
|
103
106
|
return U(...parts);
|
|
104
107
|
}
|
|
105
108
|
|
|
109
|
+
/** The short track shapes a cube face takes, in its own unit square (an L, a Z, a U, a hook, a straight run). */
|
|
110
|
+
const FACE_TRACKS = [
|
|
111
|
+
[[0.22, 0.2], [0.22, 0.78], [0.78, 0.78]],
|
|
112
|
+
[[0.2, 0.25], [0.5, 0.25], [0.5, 0.75], [0.8, 0.75]],
|
|
113
|
+
[[0.25, 0.2], [0.25, 0.75], [0.75, 0.75], [0.75, 0.35]],
|
|
114
|
+
[[0.2, 0.5], [0.62, 0.5], [0.62, 0.2]],
|
|
115
|
+
[[0.2, 0.3], [0.8, 0.3]],
|
|
116
|
+
[[0.3, 0.8], [0.3, 0.45], [0.75, 0.45]],
|
|
117
|
+
];
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Circuit tracks on an iso cube: the cube's three faces (parallelograms of a hexagon standing on a point), the gap
|
|
121
|
+
* between them, and on each face one or two short tracks (drawn in the face's own square and mapped onto it, so they
|
|
122
|
+
* lie in the face's plane), round-ended, with a node at their end.
|
|
123
|
+
*/
|
|
124
|
+
function cube(p, layout) {
|
|
125
|
+
const rand = rng(`route-cube:${layout}`), R = BOX.size / 2, { cx, cy } = BOX;
|
|
126
|
+
const V = (deg) => [cx + R * Math.cos((deg * Math.PI) / 180), cy + R * Math.sin((deg * Math.PI) / 180)], C = [cx, cy];
|
|
127
|
+
const sub = (a, b) => [a[0] - b[0], a[1] - b[1]];
|
|
128
|
+
const faces = [[V(210), sub(V(270), V(210)), sub(C, V(210))], [V(210), sub(C, V(210)), sub(V(150), V(210))], [C, sub(V(330), C), sub(V(90), C)]];
|
|
129
|
+
const parts = [], m = GAP / R / 2.2, w = Math.min(0.16, p.weight * 1.1);
|
|
130
|
+
for (const [O, a, b] of faces) {
|
|
131
|
+
const map = ([u, v]) => [O[0] + u * a[0] + v * b[0], O[1] + u * a[1] + v * b[1]];
|
|
132
|
+
const face = poly([[m, m], [1 - m, m], [1 - m, 1 - m], [m, 1 - m]].map(map));
|
|
133
|
+
const n = p.tracks > 1 && rand() < 0.5 ? 2 : 1;
|
|
134
|
+
let ink = [];
|
|
135
|
+
for (let k = 0; k < n; k++) {
|
|
136
|
+
let t = FACE_TRACKS[Math.floor(rand() * FACE_TRACKS.length)];
|
|
137
|
+
if (rand() < 0.5) t = t.map(([u, v]) => [1 - u, v]);
|
|
138
|
+
t = t.map(([u, v]) => [0.12 + u * 0.76, 0.12 + v * 0.76]); // kept off the face's edges, or the strip left there is a sliver
|
|
139
|
+
if (n === 2) t = t.map(([u, v]) => [u, k ? 0.5 + v * 0.45 : v * 0.45]);
|
|
140
|
+
const line = stroke(t, w, { roundCaps: true }), nodes = p.node !== 'none' ? [circle(t.at(-1)[0], t.at(-1)[1], w * 1.05, 32)] : [];
|
|
141
|
+
ink.push(U(line, ...nodes));
|
|
142
|
+
}
|
|
143
|
+
// the face is solid, the tracks cut out of it (a gap round each): circuit tracks engraved on the cube
|
|
144
|
+
const tracks = U(...ink.map((q) => q.map((poly2) => poly2.map((ring) => ring.map(map)))));
|
|
145
|
+
parts.push(D(face, tracks));
|
|
146
|
+
}
|
|
147
|
+
return tidy(U(...parts));
|
|
148
|
+
}
|
|
149
|
+
|
|
106
150
|
/** Routes are drawn over one another: a route crossing itself is allowed many pieces. */
|
|
107
151
|
export const guard = { maxPieces: 30 };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Weave: two or three curves (waves of one to three swells) crossing each other, over and under by turns, the under
|
|
3
|
+
* strand broken by the gap at every crossing, inside a ring that holds their ends; or bare, with three strands. After the
|
|
4
|
+
* woven lenses in a ring of the owner's references. Never one swell (two curves crossing twice round one lens, in a ring:
|
|
5
|
+
* an eye), never a dot, and never three strands turned in threes (a trefoil).
|
|
6
|
+
*/
|
|
7
|
+
import { sdPath, sdCircle, sdRing, shapeOf } from '@logomarks/core/sdf';
|
|
8
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
9
|
+
|
|
10
|
+
/** @type {import('../index.js').Control[]} */
|
|
11
|
+
export const controls = [
|
|
12
|
+
{ key: 'strands', label: 'Strands', type: 'range', min: 2, max: 3, step: 1, value: 2 },
|
|
13
|
+
{ key: 'swells', label: 'Swells', type: 'range', min: 2, max: 3, step: 1, value: 2 },
|
|
14
|
+
{ key: 'height', label: 'Height', type: 'range', min: 0.3, max: 0.7, step: 0.01, value: 0.5 },
|
|
15
|
+
{ key: 'weight', label: 'Weight', type: 'range', min: 0.06, max: 0.1, step: 0.005, value: 0.075 },
|
|
16
|
+
{ key: 'ring', label: 'Ring', type: 'choice', options: ['ring', 'none'], value: 'ring' },
|
|
17
|
+
{ key: 'tilt', label: 'Tilt', type: 'range', min: -30, max: 30, step: 1, value: 0 },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
/** The mark for resolved params. */
|
|
21
|
+
export function build(p) {
|
|
22
|
+
const R = BOX.size / 2, T = p.weight * BOX.size, n = p.ring === 'none' ? 3 : p.strands;
|
|
23
|
+
const inner = p.ring === 'ring' ? R - T : R, A = inner * p.height, steps = 64;
|
|
24
|
+
const tilt = (p.tilt * Math.PI) / 180, ct = Math.cos(tilt), st = Math.sin(tilt);
|
|
25
|
+
const curve = (phase) => Array.from({ length: steps + 1 }, (_, i) => {
|
|
26
|
+
const u = -1.15 + (2.3 * i) / steps, x = u * inner, y = A * Math.sin((u * p.swells * Math.PI) / 2 + phase) * Math.cos((u * Math.PI) / 2.3);
|
|
27
|
+
return [BOX.cx + x * ct - y * st, BOX.cy + x * st + y * ct];
|
|
28
|
+
});
|
|
29
|
+
const phases = Array.from({ length: n }, (_, k) => (2 * Math.PI * k) / n + (n === 2 ? 0 : 0.4));
|
|
30
|
+
const lines = phases.map(curve), fields = lines.map((pts) => sdPath(pts, T));
|
|
31
|
+
// the crossings, in order across: at each, one strand goes over and the other is broken by the gap, by turns
|
|
32
|
+
const crossings = [];
|
|
33
|
+
for (let a = 0; a < n; a++) for (let b = a + 1; b < n; b++) {
|
|
34
|
+
const P = lines[a], Q = lines[b];
|
|
35
|
+
for (let i = 1; i < P.length; i++) {
|
|
36
|
+
const d0 = P[i - 1][1] - Q[i - 1][1], d1 = P[i][1] - Q[i][1];
|
|
37
|
+
if (Math.sign(d0) !== Math.sign(d1)) crossings.push({ a, b, at: P[i] });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
crossings.sort((u, v) => u.at[0] - v.at[0]);
|
|
41
|
+
const zone = T * 2.4;
|
|
42
|
+
const woven = (x, y) => {
|
|
43
|
+
const d = fields.map((f) => f(x, y));
|
|
44
|
+
for (const [k, c] of crossings.entries()) {
|
|
45
|
+
if (Math.hypot(x - c.at[0], y - c.at[1]) > zone) continue;
|
|
46
|
+
const [over, under] = k % 2 ? [c.a, c.b] : [c.b, c.a];
|
|
47
|
+
d[under] = Math.max(d[under], GAP - d[over]);
|
|
48
|
+
}
|
|
49
|
+
return Math.min(...d);
|
|
50
|
+
};
|
|
51
|
+
const ring = p.ring === 'ring';
|
|
52
|
+
const clip = sdCircle(BOX.cx, BOX.cy, ring ? inner + T * 0.2 : R), band = sdRing(BOX.cx, BOX.cy, R - T / 2, T);
|
|
53
|
+
const f = (x, y) => { const w = Math.max(woven(x, y), clip(x, y)); return ring ? Math.min(w, band(x, y)) : w; };
|
|
54
|
+
return tidy(shapeOf(f, { h: 2.5, x0: BOX.x0 - 6, y0: BOX.y0 - 6, x1: BOX.x1 + 6, y1: BOX.y1 + 6 }));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Strands are lines: they run near the thin limit by design. */
|
|
58
|
+
export const guard = { maxThinShare: 0.06, minInkShare: 0.1 };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bent X: an X drawn as two bent bands, a V from the top and a V from the bottom, their bends meeting at the waist a gap
|
|
3
|
+
* apart, each bend round or flat, each V doubled by a second band outside it if asked. After the X of two bent
|
|
4
|
+
* bands in the owner's references. Never two straight bars crossing (a close icon, a multiplication sign): the bend and
|
|
5
|
+
* the gap at the waist are always there.
|
|
6
|
+
*/
|
|
7
|
+
import { sdPath, sdBox, shapeOf } from '@logomarks/core/sdf';
|
|
8
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
9
|
+
|
|
10
|
+
/** @type {import('../index.js').Control[]} */
|
|
11
|
+
export const controls = [
|
|
12
|
+
{ key: 'angle', label: 'Arm angle', type: 'range', min: 35, max: 60, step: 1, value: 48 },
|
|
13
|
+
{ key: 'weight', label: 'Weight', type: 'range', min: 0.1, max: 0.2, step: 0.005, value: 0.14 },
|
|
14
|
+
{ key: 'bend', label: 'Bend', type: 'choice', options: ['round', 'flat'], value: 'flat' },
|
|
15
|
+
{ key: 'double', label: 'Doubled', type: 'toggle', value: false },
|
|
16
|
+
{ key: 'waist', label: 'Waist', type: 'range', min: 1, max: 3, step: 0.1, value: 1.4 },
|
|
17
|
+
{ key: 'flat', label: 'Flat bend width', type: 'range', min: 0.08, max: 0.3, step: 0.01, value: 0.16 },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
/** A polyline with each inner corner rounded: a quadratic curve `r` back along both legs (never past half a leg). */
|
|
21
|
+
function fillet(pts, r) {
|
|
22
|
+
const out = [pts[0]];
|
|
23
|
+
for (let k = 1; k < pts.length - 1; k++) {
|
|
24
|
+
const [a, v, b] = [pts[k - 1], pts[k], pts[k + 1]];
|
|
25
|
+
const la = Math.hypot(a[0] - v[0], a[1] - v[1]), lb = Math.hypot(b[0] - v[0], b[1] - v[1]), d = Math.min(r, la * 0.49, lb * 0.49);
|
|
26
|
+
const p1 = [v[0] + ((a[0] - v[0]) * d) / la, v[1] + ((a[1] - v[1]) * d) / la], p2 = [v[0] + ((b[0] - v[0]) * d) / lb, v[1] + ((b[1] - v[1]) * d) / lb];
|
|
27
|
+
for (let i = 0; i <= 10; i++) { const t = i / 10, u = 1 - t; out.push([u * u * p1[0] + 2 * u * t * v[0] + t * t * p2[0], u * u * p1[1] + 2 * u * t * v[1] + t * t * p2[1]]); }
|
|
28
|
+
}
|
|
29
|
+
out.push(pts.at(-1));
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** One V opening upward with its bend at (cx, y), arms rising at `deg` from level to past the box: its centreline, the bend rounded or cut flat. */
|
|
34
|
+
function vee(y, deg, T, bend, flat) {
|
|
35
|
+
const k = Math.tan((deg * Math.PI) / 180), reach = BOX.size * 0.7;
|
|
36
|
+
const half = bend === 'flat' ? flat * BOX.size : 0;
|
|
37
|
+
const pts = half ? [[BOX.cx - half - reach, y - reach * k], [BOX.cx - half, y], [BOX.cx + half, y], [BOX.cx + half + reach, y - reach * k]] : [[BOX.cx - reach, y - reach * k], [BOX.cx, y], [BOX.cx + reach, y - reach * k]];
|
|
38
|
+
return fillet(pts, bend === 'round' ? T * 1.6 : T * 0.6);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The mark for resolved params. */
|
|
42
|
+
export function build(p) {
|
|
43
|
+
const T = p.weight * BOX.size, waist = GAP * p.waist;
|
|
44
|
+
// the upper V's bend sits half the waist above the middle; the second V outside it, a gap further up
|
|
45
|
+
const y1 = BOX.cy - waist / 2 - T / 2, paths = [vee(y1, p.angle, T, p.bend, p.flat)];
|
|
46
|
+
if (p.double) paths.push(vee(y1 - (T + GAP) / Math.cos((p.angle * Math.PI) / 180), p.angle, T, p.bend, p.flat));
|
|
47
|
+
const mirrored = paths.map((q) => q.map(([x, y]) => [x, 2 * BOX.cy - y]));
|
|
48
|
+
const fs = [...paths, ...mirrored].map((q) => sdPath(q, T));
|
|
49
|
+
const box = sdBox(BOX.cx, BOX.cy, BOX.size, BOX.size);
|
|
50
|
+
return tidy(shapeOf((x, y) => Math.max(Math.min(...fs.map((f) => f(x, y))), box(x, y)), { h: 2, x0: BOX.x0 - 4, y0: BOX.y0 - 4, x1: BOX.x1 + 4, y1: BOX.y1 + 4 }));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Two to four bands cut by the box's edge. */
|
|
54
|
+
export const guard = { maxThinShare: 0.05 };
|
|
55
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zigzag: a shape drawn in level stripes, broken top to bottom by a zigzag the gap wide, the stripes on one side slid
|
|
3
|
+
* half a step up so the break shows. After the striped disc with a chevron break in the owner's references.
|
|
4
|
+
*/
|
|
5
|
+
import { U, D, I, rect, poly, stroke } from '@logomarks/core/geometry';
|
|
6
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
7
|
+
import { primitive } from '../shapes.js';
|
|
8
|
+
|
|
9
|
+
/** @type {import('../index.js').Control[]} */
|
|
10
|
+
export const controls = [
|
|
11
|
+
{ key: 'shape', label: 'Shape', type: 'choice', options: ['circle', 'square', 'hexagon', 'half'], value: 'circle' },
|
|
12
|
+
{ key: 'stripes', label: 'Stripes', type: 'range', min: 4, max: 8, step: 1, value: 5 },
|
|
13
|
+
{ key: 'weight', label: 'Weight', type: 'range', min: 0.5, max: 0.75, step: 0.01, value: 0.62 },
|
|
14
|
+
{ key: 'teeth', label: 'Zigs', type: 'range', min: 1, max: 3, step: 1, value: 2 },
|
|
15
|
+
{ key: 'swing', label: 'Swing', type: 'range', min: 0.1, max: 0.3, step: 0.01, value: 0.18 },
|
|
16
|
+
{ key: 'at', label: 'Where', type: 'range', min: 0.35, max: 0.65, step: 0.01, value: 0.45 },
|
|
17
|
+
{ key: 'slide', label: 'Slide', type: 'range', min: 0.3, max: 0.7, step: 0.01, value: 0.5 },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
/** The silhouette, filling the box. */
|
|
21
|
+
function silhouette(shape) {
|
|
22
|
+
const { x0, y0, size, cx, cy } = BOX;
|
|
23
|
+
if (shape === 'hexagon') return poly(Array.from({ length: 6 }, (_, k) => { const a = (Math.PI / 3) * k; return [cx + (size / 2) * Math.cos(a), cy + (size / 2) * Math.sin(a)]; }));
|
|
24
|
+
return primitive(shape, x0, y0, size, size);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The mark for resolved params. */
|
|
28
|
+
export function build(p) {
|
|
29
|
+
const n = p.stripes, pitch = BOX.size / n, gap = Math.max(GAP, pitch * (1 - p.weight)), w = pitch - gap;
|
|
30
|
+
const stripes = (shift) => U(...Array.from({ length: n + 2 }, (_, k) => rect(BOX.x0 - 40, BOX.y0 + (k - 1) * pitch + gap / 2 + shift, BOX.size + 80, w)));
|
|
31
|
+
// the zigzag: `teeth` full swings from top to bottom about x = at
|
|
32
|
+
const xs = BOX.x0 + p.at * BOX.size, A = p.swing * BOX.size, steps = p.teeth * 2;
|
|
33
|
+
const zig = Array.from({ length: steps + 1 }, (_, i) => [xs + (i % 2 ? A : -A) / 2, BOX.y0 - 10 + ((BOX.size + 20) * i) / steps]);
|
|
34
|
+
const left = poly([[BOX.x0 - 60, BOX.y0 - 10], ...zig, [BOX.x0 - 60, BOX.y1 + 10]]);
|
|
35
|
+
const body = silhouette(p.shape);
|
|
36
|
+
const a = I(stripes(0), left), b = D(stripes(pitch * p.slide), left);
|
|
37
|
+
const s = D(I(U(a, b), body), stroke(zig, GAP, {}));
|
|
38
|
+
return tidy(s);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Stripes are many pieces by design. */
|
|
42
|
+
export const guard = { maxPieces: 26 };
|
package/src/tuning.js
CHANGED
|
@@ -18,16 +18,16 @@ export const TUNING = {
|
|
|
18
18
|
shapeA: of('square', 'half', 'quarter', 'triangle', 'parallelogram', 'pill', 'diamond', 'leaf'), shapeB: of('square', 'half', 'quarter', 'triangle', 'parallelogram', 'pill', 'diamond', 'leaf'), shapeC: of('square', 'half', 'quarter', 'triangle', 'parallelogram', 'pill', 'diamond', 'leaf') },
|
|
19
19
|
shear: { rows: R(1, 2), cols: R(2, 3), lean: of('same', 'rows', 'chevron'), angle: R(18, 32), drop: { rare: 0.25 }, spacing: R(1, 1.5), taper: rare(0.12, 0.1, 0.3), lengths: { rare: 0.3 }, slide: rare(0.2, 0.15, 0.4) },
|
|
20
20
|
turns: { count: of('3', '4', '5', '6'), size: R(0.32, 0.46), stretch: rare(0.3, 0.8, 1.4), radius: R(0.06, 0.26), tilt: rare(0.35, -30, 30) },
|
|
21
|
-
burst: { rays: R(5, 10), ray: of('bar', 'wedge', 'pill', 'drop'), width: R(0.1, 0.18), inner: R(0.06, 0.28), alternate: rare(0.2, 0.2, 0.45), twist: rare(0.2, -30, 30), move: { rare: 0.35 } },
|
|
21
|
+
burst: { rays: R(5, 10), ray: of('bar', 'wedge', 'pill', 'drop', 'flare'), width: R(0.1, 0.18), inner: R(0.06, 0.28), alternate: rare(0.2, 0.2, 0.45), twist: rare(0.2, -30, 30), move: { rare: 0.35 } },
|
|
22
22
|
tiles: { grid: R(2, 3), density: R(0.72, 1), symmetry: of('mirror', 'both', 'turn') },
|
|
23
|
-
route: { tracks: R(1, 1), steps: R(2, 3), weight: R(0.14, 0.2), node: of('none', 'diamond', 'square'), ends: of('square', 'node'), frame: { rare: 0.12 }, turns: { rare: 0.3 } },
|
|
23
|
+
route: { body: { rare: 0.15 }, tracks: R(1, 1), steps: R(2, 3), weight: R(0.14, 0.2), node: of('none', 'diamond', 'square'), ends: of('square', 'node'), frame: { rare: 0.12 }, turns: { rare: 0.3 } },
|
|
24
24
|
arcs: { count: R(2, 3), weight: R(0.55, 0.8), core: { rare: 0.3 }, legs: R(0, 0.45), move: { rare: 0.3 }, corner: { rare: 0.35 }, slant: rare(0.1, -15, 15) },
|
|
25
25
|
// rings: three to five rings (two, one heavy round a slotted middle, is a dial or a knob; three gaps on few rings, a car
|
|
26
26
|
// badge), every body, gaps that turn
|
|
27
27
|
rings: { count: R(3, 5), weight: R(0.5, 0.72), gaps: R(1, 2), gapSize: R(1.3, 2.6), spin: R(20, 60), centre: of('open', 'open', 'dot'), shape: of('circle', 'circle', 'rounded', 'square', 'chamfer', 'hexagon'), offset: { rare: 0 }, breakKind: { rare: 0.2 } }, // off centre by hand only: shuffled, rings crowd into a crescent
|
|
28
28
|
stripes: { stripes: R(4, 7), weight: R(0.5, 0.75), angle: R(-60, 60), move: of('none', 'shift', 'wave', 'taper', 'slot'), cover: rare(0.25, 0.5, 0.85), ends: { rare: 0.3 } },
|
|
29
29
|
// the arrowhead (the lead chevron solid) and the stem make an arrow or a download icon: by hand only
|
|
30
|
-
chevrons: { count: R(2, 4), weight: R(0.5, 0.75), angle: R(75, 120), grow: rare(0.3, 0.15, 0.45), move: of('none', 'none', 'none', 'skip') },
|
|
30
|
+
chevrons: { count: R(2, 4), body: { rare: 0.2 }, soft: { rare: 0.15 }, weight: R(0.5, 0.75), angle: R(75, 120), grow: rare(0.3, 0.15, 0.45), move: of('none', 'none', 'none', 'skip') },
|
|
31
31
|
waves: { count: R(2, 4), weight: R(0.55, 0.8), amplitude: R(0.05, 0.13), waves: R(0.75, 1.5), phase: rare(0.15, 30, 180), clip: { rare: 0.35 } },
|
|
32
32
|
cut: { second: { rare: 0.2 } },
|
|
33
33
|
split: { cuts: R(1, 2), twist: rare(0.15, 2, 6), spacing: R(1, 2) },
|
|
@@ -38,7 +38,7 @@ export const TUNING = {
|
|
|
38
38
|
steps: { count: R(3, 5), tread: R(0.45, 1), gap: rare(0.25, 1.2, 2), roundTreads: rare(0.25, 0.2, 0.5) },
|
|
39
39
|
hex: { rings: R(1, 1), density: R(0.5, 0.9), cell: { rare: 0.15 }, gap: R(1, 1.5) },
|
|
40
40
|
iso: { grid: R(2, 3), height: R(1, 2), density: R(0.5, 1) },
|
|
41
|
-
letter: { build: of('stencil', 'route', 'blocks'), weight: R(0.17, 0.26), slant: rare(0.12, -12, 12), spacing: R(1, 1.6) },
|
|
41
|
+
letter: { build: of('stencil', 'route', 'blocks', 'rails', 'hexfold', 'wedge'), weight: R(0.17, 0.26), slant: rare(0.12, -12, 12), spacing: R(1, 1.6) },
|
|
42
42
|
arcstep: { steps: R(1, 3), weight: R(0.66, 0.86), rise: rare(0.3, 0.7, 1.3), ends: { rare: 0.3 } },
|
|
43
43
|
halfsq: { grid: of('2x2'), rule: of('rows', 'same', 'checker', 'zigzag', 'diagonal'), spacing: R(1, 1.3) },
|
|
44
44
|
invert: { count: R(1, 3), weight: R(0.5, 0.66), region: of('half', 'half', 'quarter', 'disc'), shape: of('circle', 'circle', 'circle', 'rounded', 'hexagon'), size: R(0.34, 0.5) },
|
|
@@ -62,6 +62,19 @@ export const TUNING = {
|
|
|
62
62
|
corners: { reach: R(0.3, 0.5), second: rare(0.4, 0.5, 0.8), shape: of('square', 'square', 'square', 'wide', 'tall') },
|
|
63
63
|
offset: { way: of('shadow', 'shadow', 'knock', 'keep'), shift: R(0.2, 0.36), copies: R(1, 1), spacing: R(1, 1.3) },
|
|
64
64
|
quarters: { pattern: of('four', 'four', 'diagonal', 'three', 'rows'), spacing: R(1, 1.4) },
|
|
65
|
+
// the reference styles (2026-11-27): each shuffled about its reference's construction
|
|
66
|
+
// M, N and W draw their diagonals in single triangles: by hand only
|
|
67
|
+
mosaic: { char: of(...'ABCDEFGHJKLPRSTUVXYZ'), tiles: of('mixed', 'mixed', 'round', 'angled'), parted: { rare: 0.15 }, corners: of('outer'), width: R(0.9, 1.25) },
|
|
68
|
+
// three swells crowd the crossings at 32 px: by hand only
|
|
69
|
+
weave: { strands: of(2), swells: R(2, 2), height: R(0.34, 0.66), weight: R(0.07, 0.09), ring: of('ring', 'ring', 'ring', 'none'), tilt: rare(0.5, -25, 25) },
|
|
70
|
+
notch: { depth: R(0.28, 0.42), mouth: R(0.52, 0.74), seat: of('diamond', 'diamond', 'diamond', 'none'), width: R(0.72, 0.98), height: R(0.52, 0.95) },
|
|
71
|
+
nodes: { nodes: R(4, 5), size: R(0.15, 0.22), ring: R(0.12, 0.2), hole: R(0.22, 0.36), neck: R(0.45, 0.85), shape: of('round', 'round', 'square'), sizes: { rare: 0.25 }, spin: R(0, 45) },
|
|
72
|
+
xband: { angle: R(42, 56), weight: R(0.12, 0.17), bend: of('flat', 'flat', 'round'), double: { rare: 0.3 }, waist: R(1.1, 1.8), flat: R(0.1, 0.2) },
|
|
73
|
+
mirror: { body: of('hexagon', 'square'), weight: R(0.24, 0.32), bow: R(1.1, 1.6), bowl: R(0.74, 1) },
|
|
74
|
+
ribbon: { weight: R(0.23, 0.31), bend: R(0.8, 1.2), slot: R(0.45, 0.65), width: R(0.78, 0.92) },
|
|
75
|
+
field: { bars: R(6, 9), weight: R(0.58, 0.72), depth: R(0.3, 0.55), slide: R(0.15, 0.35), drop: R(0.4, 1.4) },
|
|
76
|
+
zigzag: { stripes: R(4, 6), weight: R(0.55, 0.7), teeth: R(1, 2), swing: R(0.14, 0.24), at: R(0.4, 0.6), slide: R(0.4, 0.6) },
|
|
77
|
+
halfstripe: { bars: R(3, 5), solid: R(0.44, 0.58), step: R(0.05, 0.14), weight: R(0.5, 0.7) },
|
|
65
78
|
};
|
|
66
79
|
|
|
67
80
|
/** The two to four controls of each recipe that decide the mark: a page shows these first, the rest under "More". */
|
|
@@ -80,4 +93,7 @@ export const MAIN = {
|
|
|
80
93
|
merge: ['a', 'b', 'width', 'side'], overlap: ['a', 'b', 'way', 'layout'], counter: ['body', 'hole', 'size', 'place'], pair: ['a', 'b', 'at', 'spin'],
|
|
81
94
|
corners: ['nw', 'ne', 'se', 'sw'],
|
|
82
95
|
offset: ['shape', 'way', 'dir', 'shift'], quarters: ['a', 'b', 'pattern', 'rule'],
|
|
96
|
+
mosaic: ['char', 'tiles', 'parted'], weave: ['strands', 'swells', 'height', 'ring'], notch: ['body', 'depth', 'seat', 'split'], nodes: ['nodes', 'size', 'hole', 'neck'],
|
|
97
|
+
xband: ['angle', 'weight', 'bend', 'double'], mirror: ['body', 'weight', 'bow', 'bowl'], ribbon: ['path', 'weight', 'slot'], field: ['bars', 'profile', 'slide', 'widths'],
|
|
98
|
+
zigzag: ['shape', 'stripes', 'teeth', 'slide'], halfstripe: ['shape', 'bars', 'step'],
|
|
83
99
|
};
|