@logomarks/generate 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/README.md +34 -0
- package/package.json +1 -1
- package/src/finish.js +19 -9
- package/src/generate.js +1 -1
- package/src/guard.js +3 -1
- package/src/index.d.ts +4 -3
- package/src/presets.js +11 -1
- package/src/primitives.js +2 -1
- package/src/recipes/arcs.js +6 -1
- package/src/recipes/burst.js +33 -5
- package/src/recipes/chevrons.js +25 -7
- package/src/recipes/counter.js +4 -3
- package/src/recipes/field.js +46 -0
- package/src/recipes/halfstripe.js +43 -0
- package/src/recipes/index.js +20 -0
- package/src/recipes/letter.js +49 -3
- package/src/recipes/mirror.js +43 -0
- package/src/recipes/mosaic.js +106 -0
- package/src/recipes/nodes.js +41 -0
- package/src/recipes/notch.js +47 -0
- package/src/recipes/ribbon.js +61 -0
- package/src/recipes/rings.js +49 -6
- package/src/recipes/route.js +47 -3
- package/src/recipes/weave.js +58 -0
- package/src/recipes/xband.js +55 -0
- package/src/recipes/zigzag.js +42 -0
- package/src/tuning.js +24 -5
|
@@ -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,13 +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
|
-
rings:
|
|
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
|
+
// badge), every body, gaps that turn
|
|
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
|
|
26
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 } },
|
|
27
|
-
|
|
29
|
+
// the arrowhead (the lead chevron solid) and the stem make an arrow or a download icon: by hand only
|
|
30
|
+
chevrons: { count: R(2, 4), body: { rare: 0.2 }, soft: { rare: 0.15 }, weight: R(0.5, 0.75), angle: R(75, 120), grow: rare(0.3, 0.15, 0.45), move: of('none', 'none', 'none', 'skip') },
|
|
28
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 } },
|
|
29
32
|
cut: { second: { rare: 0.2 } },
|
|
30
33
|
split: { cuts: R(1, 2), twist: rare(0.15, 2, 6), spacing: R(1, 2) },
|
|
@@ -35,7 +38,7 @@ export const TUNING = {
|
|
|
35
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) },
|
|
36
39
|
hex: { rings: R(1, 1), density: R(0.5, 0.9), cell: { rare: 0.15 }, gap: R(1, 1.5) },
|
|
37
40
|
iso: { grid: R(2, 3), height: R(1, 2), density: R(0.5, 1) },
|
|
38
|
-
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) },
|
|
39
42
|
arcstep: { steps: R(1, 3), weight: R(0.66, 0.86), rise: rare(0.3, 0.7, 1.3), ends: { rare: 0.3 } },
|
|
40
43
|
halfsq: { grid: of('2x2'), rule: of('rows', 'same', 'checker', 'zigzag', 'diagonal'), spacing: R(1, 1.3) },
|
|
41
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) },
|
|
@@ -59,6 +62,19 @@ export const TUNING = {
|
|
|
59
62
|
corners: { reach: R(0.3, 0.5), second: rare(0.4, 0.5, 0.8), shape: of('square', 'square', 'square', 'wide', 'tall') },
|
|
60
63
|
offset: { way: of('shadow', 'shadow', 'knock', 'keep'), shift: R(0.2, 0.36), copies: R(1, 1), spacing: R(1, 1.3) },
|
|
61
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) },
|
|
62
78
|
};
|
|
63
79
|
|
|
64
80
|
/** The two to four controls of each recipe that decide the mark: a page shows these first, the rest under "More". */
|
|
@@ -77,4 +93,7 @@ export const MAIN = {
|
|
|
77
93
|
merge: ['a', 'b', 'width', 'side'], overlap: ['a', 'b', 'way', 'layout'], counter: ['body', 'hole', 'size', 'place'], pair: ['a', 'b', 'at', 'spin'],
|
|
78
94
|
corners: ['nw', 'ne', 'se', 'sw'],
|
|
79
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'],
|
|
80
99
|
};
|