@logomarks/generate 0.0.0-stage → 0.2.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 +56 -0
- package/LICENSE +21 -0
- package/README.md +46 -2
- package/package.json +29 -4
- package/src/controls.js +41 -0
- package/src/draw.js +60 -0
- package/src/finish.js +172 -0
- package/src/generate.js +274 -0
- package/src/guard.js +66 -0
- package/src/index.d.ts +111 -0
- package/src/index.js +10 -0
- package/src/presets.js +37 -0
- package/src/random.js +23 -0
- package/src/raster.js +52 -0
- package/src/recipes/arcs.js +83 -0
- package/src/recipes/arcstep.js +45 -0
- package/src/recipes/bands.js +90 -0
- package/src/recipes/bars.js +106 -0
- package/src/recipes/bite.js +65 -0
- package/src/recipes/blades.js +38 -0
- package/src/recipes/bloom.js +53 -0
- package/src/recipes/burst.js +44 -0
- package/src/recipes/capsules.js +36 -0
- package/src/recipes/chevrons.js +45 -0
- package/src/recipes/cut.js +80 -0
- package/src/recipes/flare.js +39 -0
- package/src/recipes/halfsq.js +53 -0
- package/src/recipes/hex.js +58 -0
- package/src/recipes/horizon.js +51 -0
- package/src/recipes/index.js +95 -0
- package/src/recipes/invert.js +40 -0
- package/src/recipes/iso.js +35 -0
- package/src/recipes/leaves.js +45 -0
- package/src/recipes/letter.js +204 -0
- package/src/recipes/links.js +63 -0
- package/src/recipes/lobes.js +28 -0
- package/src/recipes/loops.js +28 -0
- package/src/recipes/pixelarc.js +51 -0
- package/src/recipes/rings.js +82 -0
- package/src/recipes/route.js +107 -0
- package/src/recipes/seam.js +30 -0
- package/src/recipes/shear.js +61 -0
- package/src/recipes/spiral.js +42 -0
- package/src/recipes/split.js +54 -0
- package/src/recipes/stack.js +71 -0
- package/src/recipes/steps.js +35 -0
- package/src/recipes/stripes.js +66 -0
- package/src/recipes/strips.js +39 -0
- package/src/recipes/tiles.js +60 -0
- package/src/recipes/trine.js +37 -0
- package/src/recipes/turns.js +41 -0
- package/src/recipes/twin.js +64 -0
- package/src/recipes/venn.js +54 -0
- package/src/recipes/wavecut.js +36 -0
- package/src/recipes/waves.js +40 -0
- package/src/shapes.js +54 -0
- package/src/tuning.js +67 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arcs: nested quarter or half rings from a corner or an edge, the house gap between them, round a core (a quarter disc,
|
|
3
|
+
* a square or nothing), with ONE move: an arrow cut along the diagonal, a slot, or the group mirrored into a pair. After
|
|
4
|
+
* nested arches, stepped arcs and corner bands. The default is arches on legs: a quarter of rings round a disc in a
|
|
5
|
+
* corner is the RSS or Wi-Fi icon. `corner` squares or chamfers the bands into nested L-bands (the corporate-modernist
|
|
6
|
+
* corner marks), `slant` shears the group, and a `quarter` core fills the innermost corner in the bands' own corner style
|
|
7
|
+
* (only on legs: a bare quarter round a corner core is the RSS icon again).
|
|
8
|
+
*/
|
|
9
|
+
import { U, D, I, rect, circle, poly, arcBand, sector, mapPts } from '@logomarks/core/geometry';
|
|
10
|
+
import { BOX, GAP, tidy, shear } from '../draw.js';
|
|
11
|
+
|
|
12
|
+
/** @type {import('../index.js').Control[]} */
|
|
13
|
+
export const controls = [
|
|
14
|
+
{ key: 'count', label: 'Rings', type: 'range', min: 1, max: 5, step: 1, value: 3 },
|
|
15
|
+
{ key: 'sweep', label: 'Sweep', type: 'choice', options: ['half', 'quarter'], value: 'half' },
|
|
16
|
+
{ key: 'weight', label: 'Weight', type: 'range', min: 0.4, max: 0.85, step: 0.01, value: 0.6 },
|
|
17
|
+
{ key: 'core', label: 'Core', type: 'choice', options: ['none', 'disc', 'square', 'quarter'], value: 'none' },
|
|
18
|
+
{ key: 'legs', label: 'Legs', type: 'range', min: 0, max: 0.6, step: 0.01, value: 0.3 },
|
|
19
|
+
{ key: 'move', label: 'Move', type: 'choice', options: ['none', 'arrow', 'slot', 'pair'], value: 'none' },
|
|
20
|
+
{ key: 'corner', label: 'Corner', type: 'choice', options: ['round', 'square', 'chamfer'], value: 'round' },
|
|
21
|
+
{ key: 'chamfer', label: 'Chamfer', type: 'range', min: 0.3, max: 0.6, step: 0.01, value: 0.4 },
|
|
22
|
+
{ key: 'slant', label: 'Slant', type: 'range', min: -25, max: 25, step: 1, value: 0 },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The outer outline of a band at radius `ro` in a corner style: a quarter (opening up-right from (cx, cy)) or a half
|
|
27
|
+
* (opening up), square or chamfered (`c` the chamfer as a share of ro).
|
|
28
|
+
*/
|
|
29
|
+
function frame(cx, cy, ro, half, style, c) {
|
|
30
|
+
const k = c * ro;
|
|
31
|
+
if (half) return style === 'square' ? rect(cx - ro, cy - ro, 2 * ro, ro) : poly([[cx - ro, cy], [cx - ro, cy - ro + k], [cx - ro + k, cy - ro], [cx + ro - k, cy - ro], [cx + ro, cy - ro + k], [cx + ro, cy]]);
|
|
32
|
+
return style === 'square' ? rect(cx, cy - ro, ro, ro) : poly([[cx, cy], [cx, cy - ro], [cx + ro - k, cy - ro], [cx + ro, cy - ro + k], [cx + ro, cy]]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** A band of width t at radius r in a corner style; round is the arc band. */
|
|
36
|
+
function band(cx, cy, r, t, half, p) {
|
|
37
|
+
if (p.corner === 'round') return arcBand(cx, cy, r, t, half ? 180 : 270, 360);
|
|
38
|
+
const ro = r + t / 2, ri = r - t / 2, c = p.chamfer;
|
|
39
|
+
// the inner outline's chamfer is shortened so the band keeps its width round the cut corner
|
|
40
|
+
const ci = ri > 0 ? Math.max(0, (c * ro - t * 0.414) / ri) : 0;
|
|
41
|
+
return ri > 0 ? D(frame(cx, cy, ro, half, p.corner, c), frame(cx, cy, ri, half, p.corner, ci)) : frame(cx, cy, ro, half, p.corner, c);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** One group: rings round a centre at (cx, cy), opening up-right (quarter) or up (half), radius R. */
|
|
45
|
+
function group(p, cx, cy, R, half) {
|
|
46
|
+
const n = p.count, gap = Math.max(GAP, ((1 - p.weight) * R) / (n + 1)), t = (R - n * gap) / (n + 1), parts = [];
|
|
47
|
+
const a0 = half ? 180 : 270, a1 = 360;
|
|
48
|
+
if (p.core === 'disc') parts.push(sector(cx, cy, t, a0, a1, 64));
|
|
49
|
+
if (p.core === 'square') parts.push(I(rect(cx - t, cy - t, half ? 2 * t : t, t), rect(cx - (half ? t : 0), cy - t, half ? 2 * t : t, t)));
|
|
50
|
+
if (p.core === 'quarter') parts.push(p.corner === 'round' ? sector(cx, cy, t, a0, a1, 64) : frame(cx, cy, t, half, p.corner, p.chamfer));
|
|
51
|
+
for (let k = 1; k <= n; k++) {
|
|
52
|
+
const r = t + k * (gap + t) - t / 2;
|
|
53
|
+
parts.push(p.corner === 'round' ? arcBand(cx, cy, r, t, a0, a1) : band(cx, cy, r, t, half, p));
|
|
54
|
+
if (p.legs > 0) { const l = p.legs * R; parts.push(rect(cx + r - t / 2, cy, t, l)); if (half) parts.push(rect(cx - r - t / 2, cy, t, l)); }
|
|
55
|
+
}
|
|
56
|
+
return U(...parts);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The mark for resolved params. */
|
|
60
|
+
export function build(params) {
|
|
61
|
+
const p = { ...params };
|
|
62
|
+
// a quarter core is for square or chamfered corners only, and on legs: round rings round a corner core are the RSS icon
|
|
63
|
+
if (p.core === 'quarter' && p.corner === 'round') p.core = 'none';
|
|
64
|
+
if (p.core === 'quarter' && p.legs < 0.2) p.legs = 0.25;
|
|
65
|
+
const half = p.sweep === 'half', { x0, y1, cx, size } = BOX;
|
|
66
|
+
let s;
|
|
67
|
+
if (p.move === 'pair') {
|
|
68
|
+
const R = half ? size / 4 : size / 2;
|
|
69
|
+
const one = half ? group(p, cx, BOX.y0 + R, R, true) : group(p, x0, BOX.y0 + R, R, false);
|
|
70
|
+
s = U(one, mapPts(one, ([x, y]) => [2 * BOX.cx - x, 2 * BOX.cy - y]));
|
|
71
|
+
} else {
|
|
72
|
+
s = half ? group(p, cx, y1 - (p.legs * size) / 2, size / 2, true) : group(p, x0, y1, size, false);
|
|
73
|
+
}
|
|
74
|
+
if (p.move === 'arrow') {
|
|
75
|
+
// a slot along the diagonal from the centre corner, ending in an arrowhead out at the far corner
|
|
76
|
+
const w = GAP * 1.6, ox = half ? cx : x0, oy = half ? y1 : y1, L = size * (half ? 0.55 : 1.25), a = half ? -90 : -45;
|
|
77
|
+
const dx = Math.cos((a * Math.PI) / 180), dy = Math.sin((a * Math.PI) / 180), nx = -dy, ny = dx;
|
|
78
|
+
const tip = [ox + dx * L, oy + dy * L];
|
|
79
|
+
s = D(s, poly([[ox + nx * w, oy + ny * w], [tip[0] + nx * w, tip[1] + ny * w], [tip[0] - nx * w, tip[1] - ny * w], [ox - nx * w, oy - ny * w]]));
|
|
80
|
+
}
|
|
81
|
+
if (p.move === 'slot') s = D(s, rect(half ? cx - GAP : x0 - 5, half ? BOX.y0 - 5 : y1 - size * 0.55 - GAP, half ? GAP * 2 : size + 10, half ? size + 10 : GAP * 2));
|
|
82
|
+
return tidy(p.slant ? shear(s, p.slant) : s);
|
|
83
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arc Step: one heavy band that runs level, turns up or down through a quarter arc and runs on, as a stair, a wave or
|
|
3
|
+
* a coil. The corners are round, square or one of each in turn (the step beside the arc is the family's signature).
|
|
4
|
+
*/
|
|
5
|
+
import { fillet, stroke, U, circle } from '@logomarks/core/geometry';
|
|
6
|
+
import { BOX } from '../draw.js';
|
|
7
|
+
|
|
8
|
+
/** @type {import('../index.js').Control[]} */
|
|
9
|
+
export const controls = [
|
|
10
|
+
{ key: 'layout', label: 'Path', type: 'choice', options: ['stair', 'wave', 'coil'], value: 'wave' },
|
|
11
|
+
{ key: 'steps', label: 'Steps', type: 'range', min: 1, max: 4, step: 1, value: 2 },
|
|
12
|
+
{ key: 'weight', label: 'Weight', type: 'range', min: 0.5, max: 0.9, step: 0.01, value: 0.72 },
|
|
13
|
+
{ key: 'corners', label: 'Corners', type: 'choice', options: ['round', 'alternate', 'square'], value: 'alternate' },
|
|
14
|
+
{ key: 'rise', label: 'Rise', type: 'range', min: 0.6, max: 1.6, step: 0.05, value: 1 },
|
|
15
|
+
{ key: 'ends', label: 'Ends', type: 'choice', options: ['square', 'round'], value: 'square' },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
/** The path's corners on a unit grid (x right, y down). */
|
|
19
|
+
function path(p) {
|
|
20
|
+
const n = p.steps, pts = [];
|
|
21
|
+
if (p.layout === 'stair') for (let k = 0; k <= n; k++) pts.push([k, n - k], [k + 1, n - k]);
|
|
22
|
+
else if (p.layout === 'wave') for (let k = 0; k <= n; k++) pts.push([k, k % 2 ? 0 : 1], [k + 1, k % 2 ? 0 : 1]);
|
|
23
|
+
else {
|
|
24
|
+
// a square coil: out along the top, down, back, and in, each run a cell shorter after two turns
|
|
25
|
+
let x = 0, y = 0, len = Math.min(n, 2) + 1, d = 0;
|
|
26
|
+
pts.push([0, 0]);
|
|
27
|
+
const dirs = [[1, 0], [0, 1], [-1, 0], [0, -1]];
|
|
28
|
+
for (let k = 0; k < Math.min(n, 2) + 2; k++) { x += dirs[d][0] * len; y += dirs[d][1] * len; pts.push([x, y]); d = (d + 1) % 4; if (k % 2) len -= 1; if (len <= 0) break; }
|
|
29
|
+
}
|
|
30
|
+
return pts;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The mark for resolved params. */
|
|
34
|
+
export function build(p) {
|
|
35
|
+
const raw = path(p), cols = Math.max(...raw.map((q) => q[0])) - Math.min(...raw.map((q) => q[0])) || 1;
|
|
36
|
+
const cell = BOX.size / (cols + 1), w = cell * p.weight, ry = p.layout === 'coil' ? 1 : p.rise;
|
|
37
|
+
const pts = raw.map(([x, y]) => [BOX.x0 + x * cell, BOX.y0 + y * cell * ry]);
|
|
38
|
+
// a round corner turns on the band's own outer edge, so its inner edge stays a true arc
|
|
39
|
+
const r = Math.min(cell, cell * ry) / 2;
|
|
40
|
+
const rs = pts.map((_, i) => (p.corners === 'square' ? 0 : p.corners === 'round' || i % 2 ? r : 0));
|
|
41
|
+
const line = fillet(pts, rs);
|
|
42
|
+
let s = stroke(line, w, { chunk: 8 });
|
|
43
|
+
if (p.ends === 'round') s = U(s, circle(...line[0], w / 2, 64), circle(...line.at(-1), w / 2, 64));
|
|
44
|
+
return s;
|
|
45
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bands: two to four level bands stacked down the square, each rising one row part way along through ONE kind of
|
|
3
|
+
* join (an S-curve, a slant or a step), every band cleared from the ones above it by the house gap. An optional short
|
|
4
|
+
* piece fills the free end of the bottom row (a tail) or the top row (a cap). After marks of stacked bars climbing
|
|
5
|
+
* through a smooth bend.
|
|
6
|
+
*/
|
|
7
|
+
import { U, poly, mapPts, circle } from '@logomarks/core/geometry';
|
|
8
|
+
import { BOX, GAP, clear, shear, level } from '../draw.js';
|
|
9
|
+
|
|
10
|
+
/** @type {import('../index.js').Control[]} */
|
|
11
|
+
export const controls = [
|
|
12
|
+
{ key: 'count', label: 'Bands', type: 'range', min: 2, max: 4, step: 1, value: 2 },
|
|
13
|
+
{ key: 'weight', label: 'Weight', type: 'range', min: 0.4, max: 0.85, step: 0.01, value: 0.66 },
|
|
14
|
+
{ key: 'join', label: 'Join', type: 'choice', options: ['curve', 'slant', 'step'], value: 'curve' },
|
|
15
|
+
{ key: 'joinAt', label: 'Join position', type: 'range', min: 0.2, max: 0.7, step: 0.01, value: 0.4 },
|
|
16
|
+
{ key: 'joinWidth', label: 'Join width', type: 'range', min: 0.08, max: 0.35, step: 0.01, value: 0.16 },
|
|
17
|
+
{ key: 'extra', label: 'Extra piece', type: 'choice', options: ['none', 'tail', 'cap', 'both'], value: 'tail' },
|
|
18
|
+
{ key: 'ends', label: 'Ends', type: 'choice', options: ['square', 'round', 'angled'], value: 'square' },
|
|
19
|
+
{ key: 'slant', label: 'Slant', type: 'range', min: -25, max: 25, step: 1, value: 0 },
|
|
20
|
+
{ key: 'flip', label: 'Mirror', type: 'toggle', value: false },
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
/** How far along a join the centre line has risen (0 → 1), for a join kind, at t from 0 to 1. */
|
|
24
|
+
function rise(join, t) {
|
|
25
|
+
if (join === 'slant') return t;
|
|
26
|
+
return t * t * (3 - 2 * t); // smoothstep: an S-curve
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** One band from the left edge to the right, its left part centred at yL and its right part at yR, `th` thick. */
|
|
30
|
+
function band(p, yL, yR, th, xj, jw) {
|
|
31
|
+
const { x0, x1 } = BOX;
|
|
32
|
+
if (p.join === 'step') {
|
|
33
|
+
// a Z of three straight parts: the left run, an upright the join wide, the right run
|
|
34
|
+
return U(level(x0, xj + jw, yL - th / 2, th, 'square'), level(xj, x1, yR - th / 2, th, 'square'), poly([[xj, yR - th / 2], [xj + jw, yR - th / 2], [xj + jw, yL + th / 2], [xj, yL + th / 2]]));
|
|
35
|
+
}
|
|
36
|
+
const steps = 48, top = [], bottom = [];
|
|
37
|
+
const yc = (x) => (x <= xj ? yL : x >= xj + jw ? yR : yL + (yR - yL) * rise(p.join, (x - xj) / jw));
|
|
38
|
+
const xs = [x0, ...Array.from({ length: steps + 1 }, (_, i) => xj + (jw * i) / steps), x1];
|
|
39
|
+
for (const x of xs) { top.push([x, yc(x) - th / 2]); bottom.push([x, yc(x) + th / 2]); }
|
|
40
|
+
return poly([...top, ...bottom.reverse()]);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Round or angle a band's two free ends by trimming it with its end caps. */
|
|
44
|
+
function ends(shape, p, yL, yR, th) {
|
|
45
|
+
if (p.ends === 'square') return shape;
|
|
46
|
+
const { x0, x1 } = BOX;
|
|
47
|
+
if (p.ends === 'round') {
|
|
48
|
+
const trim = poly([[x0 - 1, yL - th], [x0 + th / 2, yL - th], [x0 + th / 2, yL + th], [x0 - 1, yL + th]]);
|
|
49
|
+
const trimR = poly([[x1 - th / 2, yR - th], [x1 + 1, yR - th], [x1 + 1, yR + th], [x1 - th / 2, yR + th]]);
|
|
50
|
+
return U(clearExact(shape, U(trim, trimR)), circle(x0 + th / 2, yL, th / 2, 64), circle(x1 - th / 2, yR, th / 2, 64));
|
|
51
|
+
}
|
|
52
|
+
// angled: both ends cut at 45°, parallel
|
|
53
|
+
const cutL = poly([[x0 - 1, yL - th / 2 - 1], [x0 + th, yL - th / 2 - 1], [x0, yL + th / 2 + 1], [x0 - 1, yL + th / 2 + 1]]);
|
|
54
|
+
const cutR = poly([[x1, yR - th / 2 - 1], [x1 + 1, yR - th / 2 - 1], [x1 + 1, yR + th / 2 + 1], [x1 - th, yR + th / 2 + 1]]);
|
|
55
|
+
return clearExact(shape, U(cutL, cutR));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** A level piece centred at y from x0 to x1, only its `side` end shaped (round, or square for anything else). */
|
|
59
|
+
function endOnly(x0, x1, y, th, shape, side) {
|
|
60
|
+
if (shape !== 'round' || x1 - x0 < th * 1.5) return level(x0, x1, y - th / 2, th, 'square');
|
|
61
|
+
return side === 'right'
|
|
62
|
+
? U(level(x0, x1 - th / 2, y - th / 2, th, 'square'), circle(x1 - th / 2, y, th / 2, 64))
|
|
63
|
+
: U(level(x0 + th / 2, x1, y - th / 2, th, 'square'), circle(x0 + th / 2, y, th / 2, 64));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** `a` without `b` (no gap). */
|
|
67
|
+
function clearExact(a, b) { return clear(a, b, 0.0001); }
|
|
68
|
+
|
|
69
|
+
/** The mark for resolved params. */
|
|
70
|
+
export function build(params) {
|
|
71
|
+
// a step join is three straight runs: its ends stay square, or the caps land on the upright
|
|
72
|
+
const p = params.join === 'step' ? { ...params, ends: 'square' } : params;
|
|
73
|
+
const rows = p.count + 1;
|
|
74
|
+
const gap = Math.max(GAP, ((1 - p.weight) * BOX.size) / rows);
|
|
75
|
+
const th = (BOX.size - (rows - 1) * gap) / rows;
|
|
76
|
+
const yOf = (r) => BOX.y0 + r * (th + gap) + th / 2;
|
|
77
|
+
const xj = BOX.x0 + p.joinAt * BOX.size, jw = Math.max(p.join === 'step' ? th : th * 0.5, p.joinWidth * BOX.size);
|
|
78
|
+
const placed = [];
|
|
79
|
+
for (let k = 0; k < p.count; k++) {
|
|
80
|
+
let b = ends(band(p, yOf(k + 1), yOf(k), th, xj, jw), p, yOf(k + 1), yOf(k), th);
|
|
81
|
+
if (placed.length) b = clear(b, U(...placed));
|
|
82
|
+
placed.push(b);
|
|
83
|
+
}
|
|
84
|
+
// the extra pieces: square where they meet the bands (that end is carved), shaped like the bands at their free end
|
|
85
|
+
if (p.extra === 'tail' || p.extra === 'both') placed.push(clear(endOnly(xj, BOX.x1, yOf(rows - 1), th, p.ends, 'right'), U(...placed)));
|
|
86
|
+
if (p.extra === 'cap' || p.extra === 'both') placed.push(clear(endOnly(BOX.x0, xj + jw, yOf(0), th, p.ends, 'left'), U(...placed)));
|
|
87
|
+
let mark = shear(U(...placed), p.slant);
|
|
88
|
+
if (p.flip) mark = mapPts(mark, ([x, y]) => [2 * BOX.cx - x, y]);
|
|
89
|
+
return mark;
|
|
90
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bars: two to six upright bars across the square, the house gap or more between them, with ONE move: a cut through
|
|
3
|
+
* some of them (the middle one, every other one, a stair of cuts), lengths that rise or fall, round or angled ends, a
|
|
4
|
+
* slant. After marks like a three-bar H with its middle bar cut, or slanted slashes. `spine` joins the bars with one
|
|
5
|
+
* crossbar (comb and barcode letters), `widths` makes them uneven, `cutAngle` slants the cut and a `notch` cut bites a V
|
|
6
|
+
* into the outer bars' inner edges. Banned reads: three bars on a bottom spine with the middle longest is a trident;
|
|
7
|
+
* rising bars on a common foot with gaps are the signal-bars icon (slanted or cut too; on a bottom spine, a bar chart),
|
|
8
|
+
* so rising bars always hang from a top spine.
|
|
9
|
+
*/
|
|
10
|
+
import { U, D, rect, poly, rot } from '@logomarks/core/geometry';
|
|
11
|
+
import { BOX, GAP, upright, shear, quarterTurn, tidy } from '../draw.js';
|
|
12
|
+
import { rng } from '../random.js';
|
|
13
|
+
|
|
14
|
+
/** @type {import('../index.js').Control[]} */
|
|
15
|
+
export const controls = [
|
|
16
|
+
{ key: 'count', label: 'Bars', type: 'range', min: 2, max: 6, step: 1, value: 3 },
|
|
17
|
+
{ key: 'weight', label: 'Weight', type: 'range', min: 0.35, max: 0.85, step: 0.01, value: 0.6 },
|
|
18
|
+
{ key: 'cut', label: 'Cut', type: 'choice', options: ['none', 'middle', 'alternate', 'stair', 'outer', 'notch'], value: 'middle' },
|
|
19
|
+
{ key: 'cutSize', label: 'Cut size', type: 'range', min: 0.05, max: 0.3, step: 0.01, value: 0.12 },
|
|
20
|
+
{ key: 'cutAt', label: 'Cut height', type: 'range', min: 0.2, max: 0.8, step: 0.01, value: 0.5 },
|
|
21
|
+
{ key: 'lengths', label: 'Lengths', type: 'choice', options: ['equal', 'arch', 'valley', 'rising'], value: 'equal' },
|
|
22
|
+
{ key: 'ends', label: 'Ends', type: 'choice', options: ['square', 'round', 'angled'], value: 'square' },
|
|
23
|
+
{ key: 'slant', label: 'Slant', type: 'range', min: -35, max: 35, step: 1, value: 0 },
|
|
24
|
+
{ key: 'level', label: 'Lie flat', type: 'toggle', value: false },
|
|
25
|
+
{ key: 'cutAngle', label: 'Cut angle', type: 'range', min: -45, max: 45, step: 1, value: 0 },
|
|
26
|
+
{ key: 'spine', label: 'Spine', type: 'choice', options: ['none', 'top', 'bottom', 'middle', 'half'], value: 'none' },
|
|
27
|
+
{ key: 'spineWeight', label: 'Spine weight', type: 'range', min: 0.6, max: 1, step: 0.01, value: 0.8 },
|
|
28
|
+
{ key: 'widths', label: 'Widths', type: 'choice', options: ['equal', 'growing', 'thin-thick', 'random'], value: 'equal' },
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
/** Each bar's width: shares of the room left after the gaps, by a widths setting. */
|
|
32
|
+
function widthsOf(kind, n, room) {
|
|
33
|
+
const rand = rng(`bars:${n}`);
|
|
34
|
+
const k = Array.from({ length: n }, (_, i) => (kind === 'growing' ? 0.6 + (0.8 * i) / Math.max(1, n - 1) : kind === 'thin-thick' ? (i % 2 ? 1.4 : 0.6) : kind === 'random' ? 0.55 + rand() * 0.9 : 1));
|
|
35
|
+
const sum = k.reduce((a, b) => a + b, 0);
|
|
36
|
+
// never a bar under 34 wide (a hairline at 32 px): the thin ones take from the rest
|
|
37
|
+
const ws = k.map((v) => (room * v) / sum), floor = Math.min(34, room / n);
|
|
38
|
+
const short = ws.reduce((t, x) => t + Math.max(0, floor - x), 0), over = ws.reduce((t, x) => t + Math.max(0, x - floor), 0);
|
|
39
|
+
return ws.map((x) => (x < floor ? floor : x - (over ? ((x - floor) / over) * short : 0)));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** How tall bar `i` of `n` is, as a share of the box, for a lengths setting. */
|
|
43
|
+
function heightOf(lengths, i, n) {
|
|
44
|
+
const t = n === 1 ? 0 : i / (n - 1), mid = 1 - Math.abs(2 * t - 1);
|
|
45
|
+
if (lengths === 'arch') return 0.55 + 0.45 * mid;
|
|
46
|
+
if (lengths === 'valley') return 1 - 0.45 * mid;
|
|
47
|
+
if (lengths === 'rising') return 0.45 + 0.55 * t;
|
|
48
|
+
return 1;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Whether bar `i` of `n` is cut, and where along it (0 bottom … 1 top), for a cut setting. */
|
|
52
|
+
function cutOf(cut, i, n, at) {
|
|
53
|
+
const middle = n % 2 ? i === (n - 1) / 2 : i === n / 2 - 1 || i === n / 2;
|
|
54
|
+
if (cut === 'middle') return middle ? at : null;
|
|
55
|
+
if (cut === 'alternate') return i % 2 === 1 ? at : null;
|
|
56
|
+
if (cut === 'outer') return i === 0 || i === n - 1 ? at : null;
|
|
57
|
+
if (cut === 'stair') return 0.2 + (0.6 * i) / Math.max(1, n - 1);
|
|
58
|
+
if (cut === 'notch') return i === 0 || i === n - 1 ? at : null;
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** The mark for resolved params. */
|
|
63
|
+
export function build(params) {
|
|
64
|
+
const p = { ...params }, n = p.count;
|
|
65
|
+
if (p.spine === 'bottom' && n === 3 && p.lengths === 'arch') p.lengths = 'equal'; // a trident
|
|
66
|
+
// rising bars on one foot are the signal-strength icon (slanted too), and on a bottom spine a bar chart: they hang
|
|
67
|
+
// from a top spine instead, a stepped comb, whatever their cut or slant
|
|
68
|
+
if (p.lengths === 'rising' && (p.spine === 'none' || p.spine === 'bottom') && !p.level) p.spine = 'top';
|
|
69
|
+
const gap = Math.max(GAP, ((1 - p.weight) * BOX.size) / n);
|
|
70
|
+
const ws = widthsOf(p.widths || 'equal', n, BOX.size - (n - 1) * gap);
|
|
71
|
+
const cutH = Math.max(GAP, p.cutSize * BOX.size);
|
|
72
|
+
const parts = [];
|
|
73
|
+
let x = BOX.x0;
|
|
74
|
+
for (let i = 0; i < n; i++) {
|
|
75
|
+
const w = ws[i], h = heightOf(p.lengths, i, n) * BOX.size;
|
|
76
|
+
// bars meet a spine: hung from a top spine, standing on a bottom one
|
|
77
|
+
const top = p.spine === 'top' || p.spine === 'half';
|
|
78
|
+
const y0 = top ? BOX.y0 : p.lengths === 'rising' || p.spine === 'bottom' ? BOX.y1 - h : BOX.cy - h / 2, y1 = y0 + h;
|
|
79
|
+
const at = cutOf(p.cut, i, n, p.cutAt);
|
|
80
|
+
const bx = x;
|
|
81
|
+
x += w + gap;
|
|
82
|
+
if (at === null || (p.cut !== 'notch' && h < cutH + 2 * w)) { parts.push(upright(bx, y0, y1, w, p.ends)); continue; }
|
|
83
|
+
const yc = y1 - at * h;
|
|
84
|
+
if (p.cut === 'notch') {
|
|
85
|
+
// a V bitten from the bar's inner edge (the side facing the middle)
|
|
86
|
+
const depth = w * Math.min(0.45, 0.15 + p.cutSize), inner = i === 0 ? bx + w : bx, s = i === 0 ? -1 : 1;
|
|
87
|
+
parts.push(D(upright(bx, y0, y1, w, p.ends), poly([[inner + 1 * -s, yc - cutH], [inner + s * depth, yc], [inner + 1 * -s, yc + cutH]])));
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (p.cutAngle) {
|
|
91
|
+
// a slanted cut: a band the cut's height turned about the bar's middle at that height
|
|
92
|
+
const band = rot(rect(bx - w, yc - cutH / 2, 3 * w, cutH), p.cutAngle, bx + w / 2, yc);
|
|
93
|
+
parts.push(D(upright(bx, y0, y1, w, p.ends), band));
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const a = Math.max(y0 + w, yc - cutH / 2), b = Math.min(y1 - w, yc + cutH / 2);
|
|
97
|
+
parts.push(upright(bx, y0, a, w, p.ends), upright(bx, b, y1, w, p.ends));
|
|
98
|
+
}
|
|
99
|
+
if (p.spine !== 'none') {
|
|
100
|
+
const t = (ws.reduce((a, b) => a + b, 0) / n) * p.spineWeight, x1 = p.spine === 'half' ? BOX.x0 + (x - gap - BOX.x0) / 2 : x - gap;
|
|
101
|
+
const y = p.spine === 'bottom' ? BOX.y1 - t : p.spine === 'middle' ? BOX.cy - t / 2 : BOX.y0;
|
|
102
|
+
parts.push(rect(BOX.x0, y, x1 - BOX.x0, t));
|
|
103
|
+
}
|
|
104
|
+
const mark = shear(p.cutAngle || p.cut === 'notch' || p.widths !== 'equal' ? tidy(U(...parts)) : U(...parts), p.slant);
|
|
105
|
+
return p.level ? quarterTurn(mark) : mark;
|
|
106
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bite Link: one soft block with round bites taken out of its sides, placed by a rule: facing each other (a bone),
|
|
3
|
+
* set off on opposite sides (an S), all four sides (a soft four-leaf), or two on one side. Where a bite meets a side
|
|
4
|
+
* the point is rounded off, so the block stays soft all the way round.
|
|
5
|
+
*/
|
|
6
|
+
import { D, U, rr, circle, poly } from '@logomarks/core/geometry';
|
|
7
|
+
import { BOX, tidy } from '../draw.js';
|
|
8
|
+
|
|
9
|
+
/** @type {import('../index.js').Control[]} */
|
|
10
|
+
export const controls = [
|
|
11
|
+
{ key: 'place', label: 'Bites', type: 'choice', options: ['facing', 'offset', 'four', 'side'], value: 'offset' },
|
|
12
|
+
{ key: 'size', label: 'Bite size', type: 'range', min: 0.12, max: 0.24, step: 0.01, value: 0.18 },
|
|
13
|
+
{ key: 'depth', label: 'Bite depth', type: 'range', min: 0.5, max: 1, step: 0.01, value: 0.8 },
|
|
14
|
+
{ key: 'slide', label: 'Set off', type: 'range', min: 0.1, max: 0.2, step: 0.01, value: 0.16 },
|
|
15
|
+
{ key: 'body', label: 'Body', type: 'choice', options: ['square', 'tall', 'wide'], value: 'square' },
|
|
16
|
+
{ key: 'softness', label: 'Roundness', type: 'range', min: 0.12, max: 0.3, step: 0.01, value: 0.22 },
|
|
17
|
+
{ key: 'axis', label: 'Sides', type: 'choice', options: ['left-right', 'top-bottom'], value: 'left-right' },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A bite on a side: the side runs from E along the unit tangent T, the block lies on the N side of it. The bite's
|
|
22
|
+
* centre is `a` along the side and `d` outside it, radius r. Returns the bite and, for each of its two points, the
|
|
23
|
+
* offcut to take away so the point becomes an arc of radius f.
|
|
24
|
+
*/
|
|
25
|
+
function biteOn(E, T, N, a, d, r, f) {
|
|
26
|
+
const P = (u, v) => [E[0] + T[0] * u + N[0] * v, E[1] + T[1] * u + N[1] * v];
|
|
27
|
+
const bc = P(a, -d), half = Math.sqrt(Math.max(0, r * r - d * d)), run = Math.sqrt(Math.max(0, (r + f) ** 2 - (f + d) ** 2));
|
|
28
|
+
const trims = [-1, 1].map((sg) => {
|
|
29
|
+
const fc = P(a + sg * run, f), cusp = P(a + sg * half, 0), t1 = P(a + sg * run, 0);
|
|
30
|
+
const k = r / (r + f), t2 = [bc[0] + (fc[0] - bc[0]) * k, bc[1] + (fc[1] - bc[1]) * k];
|
|
31
|
+
return D(poly([cusp, t1, t2]), circle(fc[0], fc[1], f, 48));
|
|
32
|
+
});
|
|
33
|
+
return { cut: circle(bc[0], bc[1], r, 96), trims };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The mark for resolved params. */
|
|
37
|
+
export function build(p) {
|
|
38
|
+
const { cx, cy, size } = BOX, w = size * (p.body === 'tall' ? 0.74 : 1), h = size * (p.body === 'wide' ? 0.74 : 1);
|
|
39
|
+
const x0 = cx - w / 2, y0 = cy - h / 2;
|
|
40
|
+
const [s1, s2] = p.axis === 'top-bottom' ? ['top', 'bottom'] : ['left', 'right'];
|
|
41
|
+
const lenOf = (name) => (name === 'left' || name === 'right' ? h : w), len = lenOf(s1), short = Math.min(w, h);
|
|
42
|
+
// a bite and the arcs that round its two points take `run` of the side each way: the bite is kept small enough
|
|
43
|
+
// that they fit on the side's straight run (two of them, side by side, on a side that holds two)
|
|
44
|
+
const fit = (r) => { const d = r * (1 - p.depth), f = Math.min(r * 0.4, 24); return { r, d, f, run: Math.sqrt((r + f) ** 2 - (f + d) ** 2) }; };
|
|
45
|
+
let b = fit(p.size * size);
|
|
46
|
+
const room = p.place === 'side' ? len / 4 - 10 : p.place === 'four' ? short / 2 - 30 : len / 2 - 24;
|
|
47
|
+
if (b.run > room) b = fit((p.size * size * room) / b.run);
|
|
48
|
+
const { r, d, f, run } = b;
|
|
49
|
+
const off = p.place === 'offset' ? Math.min(p.slide * size, len / 2 - run - 14) : 0, q = Math.max(run + 8, len * 0.25);
|
|
50
|
+
// the block's corners take what the bites leave
|
|
51
|
+
const reach = p.place === 'side' ? q + run : p.place === 'offset' ? off + run : run;
|
|
52
|
+
const cr = Math.max(8, Math.min(short * p.softness, (p.place === 'four' ? short : len) / 2 - reach - 2));
|
|
53
|
+
const body = rr(x0, y0, w, h, cr);
|
|
54
|
+
// the four sides, each from its start corner along its tangent, the block on its normal's side
|
|
55
|
+
const side = { left: [[x0, y0], [0, 1], [1, 0]], right: [[x0 + w, y0 + h], [0, -1], [-1, 0]], top: [[x0 + w, y0], [-1, 0], [0, 1]], bottom: [[x0, y0 + h], [1, 0], [0, -1]] };
|
|
56
|
+
const on = (name, shift) => { const [E, T, N] = side[name]; return biteOn(E, T, N, lenOf(name) / 2 + shift, d, r, f); };
|
|
57
|
+
let bites;
|
|
58
|
+
if (p.place === 'facing') bites = [on(s1, 0), on(s2, 0)];
|
|
59
|
+
else if (p.place === 'offset') bites = [on(s1, -off), on(s2, -off)]; // each side's own run: the two end up set off opposite ways
|
|
60
|
+
else if (p.place === 'four') bites = ['left', 'right', 'top', 'bottom'].map((n) => on(n, 0));
|
|
61
|
+
else bites = [on(s1, -q), on(s1, q)];
|
|
62
|
+
let s = D(body, U(...bites.map((x) => x.cut)));
|
|
63
|
+
for (const x of bites) for (const t of x.trims) s = D(s, t);
|
|
64
|
+
return tidy(s); // the trims leave hairs on the side's own line
|
|
65
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Blade Sweep: two to four curved blades side by side, each taller than the last, each tucked behind the next with the
|
|
3
|
+
* house gap: a fin's curve on one side, a straight edge on the other.
|
|
4
|
+
*/
|
|
5
|
+
import { U, I, D, ellipse, rect, over, mapPts } from '@logomarks/core/geometry';
|
|
6
|
+
import { BOX, GAP, tidy, shear } from '../draw.js';
|
|
7
|
+
|
|
8
|
+
/** @type {import('../index.js').Control[]} */
|
|
9
|
+
export const controls = [
|
|
10
|
+
{ key: 'count', label: 'Blades', type: 'range', min: 2, max: 4, step: 1, value: 3 },
|
|
11
|
+
{ key: 'grow', label: 'Growth', type: 'range', min: 0, max: 0.7, step: 0.01, value: 0.5 },
|
|
12
|
+
{ key: 'width', label: 'Blade width', type: 'range', min: 1, max: 2.4, step: 0.05, value: 1.6 },
|
|
13
|
+
{ key: 'belly', label: 'Curve', type: 'range', min: 0.5, max: 1, step: 0.01, value: 0.8 },
|
|
14
|
+
{ key: 'edge', label: 'Back edge', type: 'choice', options: ['straight', 'hollow'], value: 'straight' },
|
|
15
|
+
{ key: 'lean', label: 'Lean', type: 'range', min: -20, max: 20, step: 1, value: 0 },
|
|
16
|
+
{ key: 'facing', label: 'Facing', type: 'choice', options: ['right', 'left'], value: 'right' },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
/** One blade: its foot from x to x + w on the base line y1, its tip at (x + w, y1 − h); the curve is a quarter of a superellipse. */
|
|
20
|
+
function blade(x, w, h, y1, belly, hollow) {
|
|
21
|
+
const n = 48, e = 2 / (0.6 + belly * 1.4), pts = [];
|
|
22
|
+
for (let k = 0; k <= n; k++) { const t = (k / n) * (Math.PI / 2); pts.push([x + w - w * Math.cos(t) ** e, y1 - h * Math.sin(t) ** e]); }
|
|
23
|
+
let s = [[...pts, [x + w, y1]]];
|
|
24
|
+
if (hollow) s = D(s, ellipse(x + w * 1.55, y1 - h * 0.1, w * 0.62, h * 0.82, 0, 96));
|
|
25
|
+
return s;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The mark for resolved params. */
|
|
29
|
+
export function build(p) {
|
|
30
|
+
const { x0, y1, size } = BOX, n = p.count, step = size / (n + p.width - 1), w = step * p.width;
|
|
31
|
+
let s = null;
|
|
32
|
+
for (let k = 0; k < n; k++) {
|
|
33
|
+
const h = size * (1 - p.grow * (1 - (k + 1) / n) * 1.1), b = blade(x0 + k * step, w, Math.max(size * 0.3, h), y1, p.belly, p.edge === 'hollow');
|
|
34
|
+
s = s ? over(s, b, GAP) : b;
|
|
35
|
+
}
|
|
36
|
+
if (p.facing === 'left') s = mapPts(s, ([x, y]) => [2 * BOX.cx - x, y]);
|
|
37
|
+
return tidy(p.lean ? shear(s, p.lean) : s);
|
|
38
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bloom: five to twelve petals (a leaf, a drop, an ellipse or a round end) set round an open or dotted centre, each
|
|
3
|
+
* turned with it, parted from the next by the house gap or tucked under it, twisted if asked. Sharp petals come at least
|
|
4
|
+
* five at a time: four sharp leaves are the banned four-point sparkle.
|
|
5
|
+
*/
|
|
6
|
+
import { U, I, poly, circle, ellipse, pill, rot } from '@logomarks/core/geometry';
|
|
7
|
+
import { BOX, GAP, clear } from '../draw.js';
|
|
8
|
+
|
|
9
|
+
/** @type {import('../index.js').Control[]} */
|
|
10
|
+
export const controls = [
|
|
11
|
+
{ key: 'petals', label: 'Petals', type: 'range', min: 4, max: 12, step: 1, value: 6 },
|
|
12
|
+
{ key: 'petal', label: 'Petal', type: 'choice', options: ['leaf', 'drop', 'ellipse', 'round'], value: 'leaf' },
|
|
13
|
+
{ key: 'width', label: 'Petal width', type: 'range', min: 0.25, max: 0.8, step: 0.01, value: 0.5 },
|
|
14
|
+
{ key: 'inner', label: 'Open centre', type: 'range', min: 0, max: 0.35, step: 0.01, value: 0.1 },
|
|
15
|
+
{ key: 'centre', label: 'Centre', type: 'choice', options: ['none', 'dot'], value: 'none' },
|
|
16
|
+
{ key: 'twist', label: 'Twist', type: 'range', min: -45, max: 45, step: 1, value: 0 },
|
|
17
|
+
{ key: 'join', label: 'Join', type: 'choice', options: ['gap', 'tuck'], value: 'gap' },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
/** A lens from (cx, y0) to (cx, y1), `w` wide at its middle. */
|
|
21
|
+
function lens(cx, y0, y1, w) {
|
|
22
|
+
const c = (y1 - y0) / 2, s = w / 2, R = (c * c + s * s) / (2 * s), my = (y0 + y1) / 2;
|
|
23
|
+
return I(circle(cx - (R - s), my, R, 56), circle(cx + (R - s), my, R, 56));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** One petal pointing up from radius r0 to r1 above the centre, `w` wide. */
|
|
27
|
+
function petal(kind, r0, r1, w) {
|
|
28
|
+
const { cx, cy } = BOX, y0 = cy - r1, y1 = cy - r0, L = y1 - y0;
|
|
29
|
+
if (kind === 'drop') return U(circle(cx, y0 + w / 2, w / 2, 64), poly([[cx - w / 2, y0 + w / 2], [cx + w / 2, y0 + w / 2], [cx, y1]]));
|
|
30
|
+
if (kind === 'ellipse') return ellipse(cx, y0 + L / 2, w / 2, L / 2, 0, 56);
|
|
31
|
+
if (kind === 'round') return pill([cx, y0 + w / 2], [cx, y1 - w / 2], w);
|
|
32
|
+
return lens(cx, y0, y1, w);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The mark for resolved params. */
|
|
36
|
+
export function build(p) {
|
|
37
|
+
const sharp = p.petal === 'leaf' || p.petal === 'drop';
|
|
38
|
+
const n = sharp ? Math.max(5, p.petals) : p.petals;
|
|
39
|
+
const R = BOX.size / 2, r0 = Math.max(p.inner * R, p.centre === 'dot' ? R * 0.26 : 0);
|
|
40
|
+
// the petal's width: its share of the circle at its middle, so neighbours never quite touch before the gap
|
|
41
|
+
const mid = (r0 + R) / 2, w = Math.min(R - r0, Math.max(GAP * 1.4, ((2 * Math.PI * mid) / n) * p.width));
|
|
42
|
+
const one = rot(petal(p.petal, r0, R, w), p.twist, BOX.cx, BOX.cy - r0);
|
|
43
|
+
const ps = Array.from({ length: n }, (_, k) => rot(one, (360 * k) / n, BOX.cx, BOX.cy));
|
|
44
|
+
let s;
|
|
45
|
+
if (p.join === 'tuck') s = U(...ps.map((q, k) => clear(q, ps[(k + 1) % n], GAP)));
|
|
46
|
+
// each petal cleared from the one before it (and the last from the first too): petals only ever touch neighbours
|
|
47
|
+
else s = U(...ps.map((q, k) => (k === 0 ? q : clear(q, k === n - 1 ? U(ps[k - 1], ps[0]) : ps[k - 1], GAP))));
|
|
48
|
+
if (p.centre === 'dot') s = U(s, circle(BOX.cx, BOX.cy, Math.max(GAP, r0 - GAP), 64));
|
|
49
|
+
return s;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Twelve petals and a dot are thirteen pieces; pointed petals lose their tips to the thin-parts test. */
|
|
53
|
+
export const guard = { maxPieces: 30, maxThinShare: 0.07 }; // a leaf or a drop comes to a point by design
|
|
@@ -0,0 +1,44 @@
|
|
|
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 drop,
|
|
3
|
+
* long and short in turn if asked, with ONE move: a ring cut through them, a ray left out, or a centre dot. Never four
|
|
4
|
+
* rays (the four-point sparkle is banned).
|
|
5
|
+
*/
|
|
6
|
+
import { U, D, poly, circle, rot, pill, annulus } from '@logomarks/core/geometry';
|
|
7
|
+
import { BOX, GAP } from '../draw.js';
|
|
8
|
+
|
|
9
|
+
/** @type {import('../index.js').Control[]} */
|
|
10
|
+
export const controls = [
|
|
11
|
+
{ 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: 'width', label: 'Ray width', type: 'range', min: 0.07, max: 0.2, step: 0.005, value: 0.1 },
|
|
14
|
+
{ key: 'inner', label: 'Open centre', type: 'range', min: 0, max: 0.35, step: 0.01, value: 0.14 },
|
|
15
|
+
{ key: 'alternate', label: 'Long and short', type: 'range', min: 0, max: 0.5, step: 0.01, value: 0 },
|
|
16
|
+
{ 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
|
+
];
|
|
19
|
+
|
|
20
|
+
/** One ray pointing up from radius r0 to r1, `w` wide at its outer end. */
|
|
21
|
+
function ray(kind, r0, r1, w) {
|
|
22
|
+
const { cx, cy } = BOX, y0 = cy - r1, y1 = cy - r0;
|
|
23
|
+
if (kind === 'wedge') return poly([[cx - w / 2, y0], [cx + w / 2, y0], [cx + w * 0.22, y1], [cx - w * 0.22, y1]]);
|
|
24
|
+
if (kind === 'pill') return pill([cx, y0 + w / 2], [cx, y1 - w / 2], w);
|
|
25
|
+
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]]));
|
|
26
|
+
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
|
+
return poly([[cx - w / 2, y0], [cx + w / 2, y0], [cx + w / 2, y1], [cx - w / 2, y1]]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The mark for resolved params. */
|
|
31
|
+
export function build(p) {
|
|
32
|
+
const R = BOX.size / 2, w = p.width * BOX.size, r0 = Math.max(p.inner * R, p.move === 'dot' ? R * 0.28 : 0);
|
|
33
|
+
const parts = [];
|
|
34
|
+
for (let k = 0; k < p.rays; k++) {
|
|
35
|
+
if (p.move === 'gap' && k === 0) continue;
|
|
36
|
+
const r1 = k % 2 && p.alternate ? R * (1 - p.alternate) : R;
|
|
37
|
+
const one = ray(p.ray, Math.min(r0, r1 * 0.6), r1, w);
|
|
38
|
+
parts.push(rot(rot(one, p.twist, BOX.cx, BOX.cy - (r0 + r1) / 2), (360 * k) / p.rays, BOX.cx, BOX.cy));
|
|
39
|
+
}
|
|
40
|
+
let s = U(...parts);
|
|
41
|
+
if (p.move === 'ring') s = D(s, annulus(BOX.cx, BOX.cy, R * 0.62, GAP * 1.1));
|
|
42
|
+
if (p.move === 'dot') s = U(s, circle(BOX.cx, BOX.cy, R * 0.28 - GAP, 64));
|
|
43
|
+
return s;
|
|
44
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capsule: two to four heavy slanted capsules stacked with the house gap, their lengths set by one rule (growing,
|
|
3
|
+
* staggered, long in the middle), sometimes one of them cut in two.
|
|
4
|
+
*/
|
|
5
|
+
import { U, D, rr, rect } from '@logomarks/core/geometry';
|
|
6
|
+
import { BOX, GAP, tidy, shear } from '../draw.js';
|
|
7
|
+
|
|
8
|
+
/** @type {import('../index.js').Control[]} */
|
|
9
|
+
export const controls = [
|
|
10
|
+
{ key: 'count', label: 'Capsules', type: 'range', min: 2, max: 4, step: 1, value: 3 },
|
|
11
|
+
{ key: 'lengths', label: 'Lengths', type: 'choice', options: ['stagger', 'grow', 'middle', 'even'], value: 'stagger' },
|
|
12
|
+
{ key: 'lean', label: 'Lean', type: 'range', min: 0, max: 35, step: 1, value: 22 },
|
|
13
|
+
{ key: 'short', label: 'Shortest', type: 'range', min: 0.4, max: 0.85, step: 0.01, value: 0.62 },
|
|
14
|
+
{ key: 'softness', label: 'Roundness', type: 'range', min: 0.3, max: 1, step: 0.01, value: 1 },
|
|
15
|
+
{ key: 'cut', label: 'Cut one', type: 'choice', options: ['none', 'first', 'last'], value: 'none' },
|
|
16
|
+
{ key: 'spacing', label: 'Gap', type: 'range', min: 1, max: 2, step: 0.1, value: 1 },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
/** The mark for resolved params. */
|
|
20
|
+
export function build(p) {
|
|
21
|
+
const { x0, y0, size } = BOX, n = p.count, g = GAP * p.spacing, h = (size * (n === 2 ? 0.8 : 1) - (n - 1) * g) / n, parts = [];
|
|
22
|
+
const top = y0 + (size - (n * h + (n - 1) * g)) / 2;
|
|
23
|
+
for (let k = 0; k < n; k++) {
|
|
24
|
+
const t = n === 1 ? 0 : k / (n - 1);
|
|
25
|
+
// each capsule's length as a share of the row, and where it sits in it (0 left, 1 right)
|
|
26
|
+
let len = 1, side = 0;
|
|
27
|
+
if (p.lengths === 'grow') len = p.short + (1 - p.short) * t;
|
|
28
|
+
if (p.lengths === 'stagger') { len = p.short + (1 - p.short) * 0.5; side = k % 2; }
|
|
29
|
+
if (p.lengths === 'middle') { len = p.short + (1 - p.short) * (1 - Math.abs(2 * t - 1)); side = 0.5; }
|
|
30
|
+
const w = Math.max(h * 1.25, size * len), x = x0 + (size - w) * side, y = top + k * (h + g);
|
|
31
|
+
let c = rr(x, y, w, h, (h / 2) * p.softness * 0.999);
|
|
32
|
+
if ((p.cut === 'first' && k === 0) || (p.cut === 'last' && k === n - 1)) { const at = x + w * (p.cut === 'first' ? 0.68 : 0.32); if (w > h * 2.6) c = D(c, rect(at - g / 2, y - 2, g, h + 4)); }
|
|
33
|
+
parts.push(c);
|
|
34
|
+
}
|
|
35
|
+
return tidy(shear(U(...parts), p.lean));
|
|
36
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
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, and ONE move: the last one solid (an arrowhead), one left out, or a stem under them (a
|
|
4
|
+
* tree). After Chevron Stack and stacked-arrow marks.
|
|
5
|
+
*/
|
|
6
|
+
import { U, poly, rect, rot, mapPts } from '@logomarks/core/geometry';
|
|
7
|
+
import { BOX, GAP } from '../draw.js';
|
|
8
|
+
|
|
9
|
+
/** @type {import('../index.js').Control[]} */
|
|
10
|
+
export const controls = [
|
|
11
|
+
{ key: 'count', label: 'Chevrons', type: 'range', min: 2, max: 5, step: 1, value: 3 },
|
|
12
|
+
{ key: 'angle', label: 'Opening', type: 'range', min: 60, max: 140, step: 1, value: 90 },
|
|
13
|
+
{ key: 'weight', label: 'Weight', type: 'range', min: 0.35, max: 0.8, step: 0.01, value: 0.6 },
|
|
14
|
+
{ key: 'tip', label: 'Tip', type: 'choice', options: ['pointed', 'flat', 'notched'], value: 'pointed' },
|
|
15
|
+
{ key: 'grow', label: 'Step in size', type: 'range', min: 0, max: 0.5, step: 0.01, value: 0 },
|
|
16
|
+
{ key: 'move', label: 'Move', type: 'choice', options: ['none', 'arrowhead', 'skip', 'stem'], value: 'none' },
|
|
17
|
+
{ key: 'point', label: 'Point', type: 'choice', options: ['up', 'right', 'down', 'left'], value: 'up' },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
/** One chevron pointing up, its tip at (cx, y), arms `half` wide each, `t` thick (measured upright). */
|
|
21
|
+
function chevron(cx, y, half, t, k, tip, solid) {
|
|
22
|
+
const drop = half / k; // how far the arms fall over their width
|
|
23
|
+
if (solid) return poly([[cx, y], [cx + half, y + drop], [cx + half, y + drop + t * 0.2], [cx - half, y + drop + t * 0.2], [cx - half, y + drop]]);
|
|
24
|
+
const outer = [[cx - half, y + drop], [cx, y], [cx + half, y + drop]], inner = [[cx + half, y + drop + t], [cx, y + t], [cx - half, y + drop + t]];
|
|
25
|
+
if (tip === 'flat') { const f = t * 0.6; return poly([[cx - half, y + drop], [cx - f, y + f / k], [cx + f, y + f / k], [cx + half, y + drop], [cx + half, y + drop + t], [cx, y + t], [cx - half, y + drop + t]]); }
|
|
26
|
+
if (tip === 'notched') return U(poly([...outer.slice(0, 2), [cx - GAP / 2, y + GAP / (2 * k)], [cx - GAP / 2, y + t + GAP / (2 * k)], inner[2]]), poly([[cx + GAP / 2, y + GAP / (2 * k)], outer[1], outer[2], inner[0], [cx + GAP / 2, y + t + GAP / (2 * k)]]));
|
|
27
|
+
return poly([...outer, ...inner]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The mark for resolved params. */
|
|
31
|
+
export function build(p) {
|
|
32
|
+
const n = p.count, k = Math.tan(((p.angle / 2) * Math.PI) / 180); // half-width over drop
|
|
33
|
+
const half = BOX.size / 2, drop = half / k;
|
|
34
|
+
const total = BOX.size - drop * 0.4, pitch = total / n, t = Math.max(GAP * 1.2, pitch * p.weight), parts = [];
|
|
35
|
+
for (let i = 0; i < n; i++) {
|
|
36
|
+
if (p.move === 'skip' && i === 1) continue;
|
|
37
|
+
const scale = 1 - p.grow * (1 - i / Math.max(1, n - 1));
|
|
38
|
+
parts.push(chevron(BOX.cx, BOX.y0 + i * pitch, half * scale, t, k, p.tip, p.move === 'arrowhead' && i === 0));
|
|
39
|
+
}
|
|
40
|
+
if (p.move === 'stem') parts.push(rect(BOX.cx - t / 2, BOX.y0 + n * pitch + t * 0.2, t, BOX.size * 0.3));
|
|
41
|
+
let s = U(...parts);
|
|
42
|
+
const turn = { up: 0, right: 90, down: 180, left: 270 }[p.point];
|
|
43
|
+
if (turn) s = rot(s, turn, BOX.cx, BOX.cy);
|
|
44
|
+
return mapPts(s, (q) => q);
|
|
45
|
+
}
|