@logomarks/generate 0.1.0 → 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 +32 -1
- package/README.md +8 -3
- package/package.json +1 -1
- package/src/controls.js +11 -4
- package/src/generate.js +107 -27
- package/src/index.d.ts +20 -5
- package/src/index.js +2 -1
- package/src/presets.js +31 -20
- package/src/recipes/arcstep.js +45 -0
- package/src/recipes/bite.js +65 -0
- package/src/recipes/blades.js +38 -0
- package/src/recipes/capsules.js +36 -0
- package/src/recipes/flare.js +39 -0
- package/src/recipes/halfsq.js +53 -0
- package/src/recipes/index.js +36 -20
- package/src/recipes/invert.js +40 -0
- package/src/recipes/leaves.js +45 -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/seam.js +30 -0
- package/src/recipes/strips.js +39 -0
- package/src/recipes/trine.js +37 -0
- package/src/recipes/wavecut.js +36 -0
- package/src/tuning.js +67 -0
- package/src/recipes/blobs.js +0 -74
- package/src/recipes/dashes.js +0 -61
- package/src/recipes/dots.js +0 -47
- package/src/recipes/fan.js +0 -73
- package/src/recipes/fold.js +0 -66
- package/src/recipes/line.js +0 -142
- package/src/recipes/orbit.js +0 -50
- package/src/recipes/pixel.js +0 -38
- package/src/recipes/tri.js +0 -126
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flare: heavy rays that widen as they run out, parted by gap-wide lines, spreading from a corner of a block or from
|
|
3
|
+
* the foot of one (all round a centre is Burst's). The rays stop short of where they meet, so no ray ends in a needle.
|
|
4
|
+
*/
|
|
5
|
+
import { U, D, I, rect, circle, bar, regular, polar } from '@logomarks/core/geometry';
|
|
6
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
7
|
+
|
|
8
|
+
/** @type {import('../index.js').Control[]} */
|
|
9
|
+
export const controls = [
|
|
10
|
+
{ key: 'origin', label: 'From', type: 'choice', options: ['corner', 'foot'], value: 'corner' },
|
|
11
|
+
{ key: 'rays', label: 'Rays', type: 'range', min: 3, max: 5, step: 1, value: 4 },
|
|
12
|
+
{ key: 'body', label: 'Body', type: 'choice', options: ['square', 'round'], value: 'square' },
|
|
13
|
+
{ key: 'inner', label: 'Open centre', type: 'range', min: 0.12, max: 0.4, step: 0.01, value: 0.24 },
|
|
14
|
+
{ key: 'spacing', label: 'Gap', type: 'range', min: 1, max: 2.4, step: 0.1, value: 1.4 },
|
|
15
|
+
{ key: 'spin', label: 'Spin', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
import { rot } from '@logomarks/core/geometry';
|
|
19
|
+
|
|
20
|
+
/** The mark for resolved params. */
|
|
21
|
+
export function build(p) {
|
|
22
|
+
const { cx, cy, x0, y0, y1, size } = BOX, g = GAP * p.spacing, R = size / 2;
|
|
23
|
+
// where the rays spring from, the angles they span, and how many (a corner or a foot holds fewer)
|
|
24
|
+
const O = p.origin === 'corner' ? [x0, y1] : p.origin === 'foot' ? [cx, y1] : [cx, cy];
|
|
25
|
+
const [a0, a1] = p.origin === 'corner' ? [270, 360] : p.origin === 'foot' ? [198, 342] : [0, 360];
|
|
26
|
+
const n = p.origin === 'centre' ? Math.max(5, p.rays) : Math.min(p.rays, p.origin === 'corner' ? 5 : 5);
|
|
27
|
+
let body = p.body === 'round' ? (p.origin === 'corner' ? circle(x0, y1, size, 160) : p.origin === 'foot' ? circle(cx, y1, size * 0.92, 160) : circle(cx, cy, R, 128)) : p.body === 'hexagon' && p.origin === 'centre' ? regular(cx, cy, R * 1.06, 6, 0) : rect(x0, y0, size, size);
|
|
28
|
+
if (p.origin !== 'centre') body = I(body, rect(x0, y0, size, size));
|
|
29
|
+
// the parting lines: between rays, and along both edges of a foot's fan
|
|
30
|
+
const cuts = [], step = (a1 - a0) / n, far = size * 1.6;
|
|
31
|
+
const first = p.origin === 'centre' ? 0 : p.origin === 'corner' ? 1 : 0, lastK = p.origin === 'centre' ? n - 1 : p.origin === 'corner' ? n - 1 : n;
|
|
32
|
+
for (let k = first; k <= lastK; k++) cuts.push(bar(O, polar(far, a0 + k * step + (p.origin === 'centre' ? step / 2 - 90 : 0), ...O), g));
|
|
33
|
+
let s = D(body, U(...cuts));
|
|
34
|
+
if (p.origin === 'foot') s = I(s, U(...Array.from({ length: n }, (_, k) => [O, polar(far, a0 + k * step, ...O), polar(far, a0 + (k + 1) * step, ...O)]).map((t) => [t])));
|
|
35
|
+
// the rays stop at an open centre wide enough that each is at least a gap across where it starts
|
|
36
|
+
const open = Math.max(p.inner * size * (p.origin === 'centre' ? 0.5 : 1), (g * 1.9) / (2 * Math.sin(((step / 2) * Math.PI) / 180)));
|
|
37
|
+
s = D(s, circle(O[0], O[1], open, 96));
|
|
38
|
+
return tidy(rot(s, Number(p.spin), cx, cy));
|
|
39
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Half Square: a small grid of whole squares and half squares (a square cut corner to corner), merged into one heavy
|
|
3
|
+
* angular solid, mirrored so it reads as built. Layouts are numbered: each number is one arrangement.
|
|
4
|
+
*/
|
|
5
|
+
import { U, rect, poly } from '@logomarks/core/geometry';
|
|
6
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
7
|
+
import { rng } from '../random.js';
|
|
8
|
+
|
|
9
|
+
/** @type {import('../index.js').Control[]} */
|
|
10
|
+
export const controls = [
|
|
11
|
+
{ key: 'grid', label: 'Grid', type: 'range', min: 2, max: 3, step: 1, value: 2 },
|
|
12
|
+
{ key: 'layout', label: 'Layout no.', type: 'range', min: 1, max: 999, step: 1, value: 3 },
|
|
13
|
+
{ key: 'halves', label: 'Half squares', type: 'range', min: 0.2, max: 0.8, step: 0.01, value: 0.5 },
|
|
14
|
+
{ key: 'symmetry', label: 'Symmetry', type: 'choice', options: ['mirror', 'diagonal', 'turn'], value: 'mirror' },
|
|
15
|
+
{ key: 'parted', label: 'Parted', type: 'toggle', value: false },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
/** A cell: 'full', or a half square keeping corner 0–3 (top left, top right, bottom right, bottom left). */
|
|
19
|
+
function cell(kind, x, y, s) {
|
|
20
|
+
const c = [[x, y], [x + s, y], [x + s, y + s], [x, y + s]];
|
|
21
|
+
if (kind === 'full') return rect(x, y, s, s);
|
|
22
|
+
return poly([c[kind], c[(kind + 1) % 4], c[(kind + 3) % 4]]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The mark for resolved params. */
|
|
26
|
+
export function build(p) {
|
|
27
|
+
const n = p.grid, rand = rng(`halfsq:${n}:${p.layout}:${p.symmetry}`), s = BOX.size / n, g = p.parted ? GAP / 2 : 0;
|
|
28
|
+
const grid = Array.from({ length: n }, () => Array(n).fill(null));
|
|
29
|
+
const pick = () => (rand() < p.halves ? Math.floor(rand() * 4) : rand() < 0.92 ? 'full' : null);
|
|
30
|
+
// the image of a cell and of a half's kept corner under the symmetry
|
|
31
|
+
const image = {
|
|
32
|
+
mirror: (r, c, k) => [r, n - 1 - c, typeof k === 'number' ? [1, 0, 3, 2][k] : k],
|
|
33
|
+
diagonal: (r, c, k) => [c, r, typeof k === 'number' ? [0, 3, 2, 1][k] : k],
|
|
34
|
+
turn: (r, c, k) => [n - 1 - r, n - 1 - c, typeof k === 'number' ? (k + 2) % 4 : k],
|
|
35
|
+
}[p.symmetry];
|
|
36
|
+
for (let r = 0; r < n; r++) for (let c = 0; c < n; c++) {
|
|
37
|
+
if (grid[r][c] !== null) continue;
|
|
38
|
+
const [r2, c2] = image(r, c, 0);
|
|
39
|
+
let k = pick();
|
|
40
|
+
// a cell that is its own image can't hold a half the symmetry would turn: whole or the matching half
|
|
41
|
+
if (r2 === r && c2 === c && typeof k === 'number' && image(r, c, k)[2] !== k) k = 'full';
|
|
42
|
+
grid[r][c] = k ?? 'none';
|
|
43
|
+
const [r3, c3, k3] = image(r, c, k);
|
|
44
|
+
grid[r3][c3] = k3 ?? 'none';
|
|
45
|
+
}
|
|
46
|
+
const parts = [];
|
|
47
|
+
for (let r = 0; r < n; r++) for (let c = 0; c < n; c++) {
|
|
48
|
+
const k = grid[r][c];
|
|
49
|
+
if (k === 'none' || k === null) continue;
|
|
50
|
+
parts.push(cell(k, BOX.x0 + c * s + g, BOX.y0 + r * s + g, s - 2 * g));
|
|
51
|
+
}
|
|
52
|
+
return parts.length ? tidy(U(...parts)) : [];
|
|
53
|
+
}
|
package/src/recipes/index.js
CHANGED
|
@@ -13,32 +13,42 @@ import * as route from './route.js';
|
|
|
13
13
|
import * as arcs from './arcs.js';
|
|
14
14
|
import * as rings from './rings.js';
|
|
15
15
|
import * as stripes from './stripes.js';
|
|
16
|
-
import * as dots from './dots.js';
|
|
17
|
-
import * as pixel from './pixel.js';
|
|
18
16
|
import * as chevrons from './chevrons.js';
|
|
19
17
|
import * as waves from './waves.js';
|
|
20
18
|
import * as cut from './cut.js';
|
|
21
19
|
import * as split from './split.js';
|
|
22
20
|
import * as venn from './venn.js';
|
|
23
|
-
import * as blobs from './blobs.js';
|
|
24
|
-
import * as dashes from './dashes.js';
|
|
25
|
-
import * as fan from './fan.js';
|
|
26
|
-
import * as fold from './fold.js';
|
|
27
21
|
import * as spiral from './spiral.js';
|
|
28
|
-
import * as orbit from './orbit.js';
|
|
29
22
|
import * as bloom from './bloom.js';
|
|
30
23
|
import * as links from './links.js';
|
|
31
24
|
import * as horizon from './horizon.js';
|
|
32
25
|
import * as steps from './steps.js';
|
|
33
26
|
import * as hex from './hex.js';
|
|
34
|
-
import * as tri from './tri.js';
|
|
35
27
|
import * as iso from './iso.js';
|
|
36
|
-
import * as line from './line.js';
|
|
37
28
|
import * as letter from './letter.js';
|
|
29
|
+
import * as arcstep from './arcstep.js';
|
|
30
|
+
import * as halfsq from './halfsq.js';
|
|
31
|
+
import * as invert from './invert.js';
|
|
32
|
+
import * as leaves from './leaves.js';
|
|
33
|
+
import * as lobes from './lobes.js';
|
|
34
|
+
import * as loops from './loops.js';
|
|
35
|
+
import * as trine from './trine.js';
|
|
36
|
+
import * as strips from './strips.js';
|
|
37
|
+
import * as bite from './bite.js';
|
|
38
|
+
import * as blades from './blades.js';
|
|
39
|
+
import * as wavecut from './wavecut.js';
|
|
40
|
+
import * as capsules from './capsules.js';
|
|
41
|
+
import * as flare from './flare.js';
|
|
42
|
+
import * as seam from './seam.js';
|
|
43
|
+
import * as pixelarc from './pixelarc.js';
|
|
38
44
|
import { FINISH, finish } from '../finish.js';
|
|
45
|
+
import { TUNING } from '../tuning.js';
|
|
39
46
|
|
|
40
|
-
/** A recipe with
|
|
41
|
-
const
|
|
47
|
+
/** A recipe's controls with its tuning laid over them (the default, and what a shuffle draws: `random`, `rare`). */
|
|
48
|
+
const tuned = (id, controls) => controls.map((c) => (TUNING[id]?.[c.key] ? { ...c, ...TUNING[id][c.key] } : c));
|
|
49
|
+
|
|
50
|
+
/** A recipe with its tuning, and the finish controls appended and applied. */
|
|
51
|
+
const R = (id, name, line, m) => ({ id, name, line, controls: [...tuned(id, m.controls), ...FINISH], build: (p) => finish(m.build(p), p), guard: m.guard || {} });
|
|
42
52
|
|
|
43
53
|
/** Every recipe: its id, name, one line and controls, and its `build(params)`. */
|
|
44
54
|
export const RECIPES = {
|
|
@@ -54,26 +64,32 @@ export const RECIPES = {
|
|
|
54
64
|
arcs: R('arcs', 'Arcs', 'Nested quarter or half rings from a corner.', arcs),
|
|
55
65
|
rings: R('rings', 'Rings', 'Concentric rings broken by turning gaps.', rings),
|
|
56
66
|
stripes: R('stripes', 'Stripes', 'A shape drawn in stripes, with one move.', stripes),
|
|
57
|
-
dots: R('dots', 'Dots', 'A halftone grid: dot sizes make the shape.', dots),
|
|
58
|
-
pixel: R('pixel', 'Pixel', 'A mirrored pixel figure from a layout number.', pixel),
|
|
59
67
|
chevrons: R('chevrons', 'Chevrons', 'Chevrons stacked along their point.', chevrons),
|
|
60
68
|
waves: R('waves', 'Waves', 'Wavy bands, in step or turning.', waves),
|
|
61
69
|
cut: R('cut', 'Cut', 'One solid with one cut: a bite, notch, slot or step.', cut),
|
|
62
70
|
split: R('split', 'Split', 'A shape cut into slid parts by straight lines.', split),
|
|
63
71
|
venn: R('venn', 'Venn', 'Overlapping circles or squares, xor, over or knocked out.', venn),
|
|
64
|
-
blobs: R('blobs', 'Blobs', 'Discs fused by soft necks.', blobs),
|
|
65
|
-
dashes: R('dashes', 'Dashes', 'Rows of dashes with a rhythm.', dashes),
|
|
66
|
-
fan: R('fan', 'Fan', 'Blades fanned out from a pivot.', fan),
|
|
67
|
-
fold: R('fold', 'Fold', 'One heavy band folded back and forth.', fold),
|
|
68
72
|
spiral: R('spiral', 'Spiral', 'One round band coiled, with a dot or a tail.', spiral),
|
|
69
|
-
orbit: R('orbit', 'Orbit', 'A planet with tilted rings passing in front and behind.', orbit),
|
|
70
73
|
bloom: R('bloom', 'Bloom', 'Petals round an open or dotted centre.', bloom),
|
|
71
74
|
links: R('links', 'Links', 'Two or three loops woven like a chain.', links),
|
|
72
75
|
horizon: R('horizon', 'Horizon', 'A striped sun over horizon lines.', horizon),
|
|
73
76
|
steps: R('steps', 'Steps', 'A staircase or ziggurat of blocks.', steps),
|
|
74
77
|
hex: R('hex', 'Hex', 'A honeycomb cluster of hexagon cells.', hex),
|
|
75
|
-
tri: R('tri', 'Tri', 'A grid of triangles in a triangle or hexagon.', tri),
|
|
76
78
|
iso: R('iso', 'Iso', 'Isometric cubes stacked from a height map.', iso),
|
|
77
|
-
line: R('line', 'Line', 'One heavy stroke through a few points, with a loop or a fold.', line),
|
|
78
79
|
letter: R('letter', 'Letter', 'One capital or numeral in blocks, tiles, pixels, stencil, slabs or route.', letter),
|
|
80
|
+
arcstep: R('arcstep', 'Arc Step', 'One heavy band that steps and turns through quarter arcs.', arcstep),
|
|
81
|
+
halfsq: R('halfsq', 'Halves', 'Squares and half squares merged into one angular solid.', halfsq),
|
|
82
|
+
invert: R('invert', 'Inverted', 'Rings with ink and ground swapped across one region.', invert),
|
|
83
|
+
leaves: R('leaves', 'Leaf Tiles', 'One soft tile in each corner, turned from cell to cell.', leaves),
|
|
84
|
+
lobes: R('lobes', 'Soft', 'One soft lobed solid, whole, pierced or cut.', lobes),
|
|
85
|
+
loops: R('loops', 'Loops', 'Rings merged into one heavy flower outline.', loops),
|
|
86
|
+
trine: R('trine', 'Trine', 'A solid cut in three by slits that pass the centre.', trine),
|
|
87
|
+
strips: R('strips', 'Strips', 'Straight strips of tape laid over one another.', strips),
|
|
88
|
+
bite: R('bite', 'Bite Link', 'A soft block with round bites taken from its sides.', bite),
|
|
89
|
+
blades: R('blades', 'Blades', 'Curved blades side by side, each taller than the last.', blades),
|
|
90
|
+
wavecut: R('wavecut', 'Squiggle', 'A solid cut or worn by one wavy line.', wavecut),
|
|
91
|
+
capsules: R('capsules', 'Capsule', 'Slanted capsules stacked, their lengths set by one rule.', capsules),
|
|
92
|
+
flare: R('flare', 'Flare', 'Rays that widen as they run out, from a corner, a foot or a centre.', flare),
|
|
93
|
+
pixelarc: R('pixelarc', 'Pixel', 'One bold curve drawn in square pixels.', pixelarc),
|
|
94
|
+
seam: R('seam', 'Seam', 'A block parted in two by one seam with a joint in it.', seam),
|
|
79
95
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inverted Rings: concentric rings, with ink and ground swapped inside one region: a half, a band through the middle, a
|
|
3
|
+
* quarter or a disc set off centre. One move; the rings do the rest.
|
|
4
|
+
*/
|
|
5
|
+
import { U, D, I, X, rect, circle, rot, regular, rr } from '@logomarks/core/geometry';
|
|
6
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
7
|
+
|
|
8
|
+
/** @type {import('../index.js').Control[]} */
|
|
9
|
+
export const controls = [
|
|
10
|
+
{ key: 'count', label: 'Rings', type: 'range', min: 1, max: 4, step: 1, value: 2 },
|
|
11
|
+
{ key: 'weight', label: 'Weight', type: 'range', min: 0.4, max: 0.7, step: 0.01, value: 0.55 },
|
|
12
|
+
{ key: 'region', label: 'Swapped', type: 'choice', options: ['half', 'band', 'quarter', 'disc'], value: 'half' },
|
|
13
|
+
{ key: 'angle', label: 'Angle', type: 'choice', options: ['0', '45', '90', '135'], value: '0' },
|
|
14
|
+
{ key: 'size', label: 'Region size', type: 'range', min: 0.25, max: 0.6, step: 0.01, value: 0.4 },
|
|
15
|
+
{ key: 'shape', label: 'Shape', type: 'choice', options: ['circle', 'rounded', 'hexagon'], value: 'circle' },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
/** The outline at radius r. */
|
|
19
|
+
function outline(shape, r) {
|
|
20
|
+
const { cx, cy } = BOX;
|
|
21
|
+
if (shape === 'rounded') return rr(cx - r, cy - r, 2 * r, 2 * r, r * 0.42);
|
|
22
|
+
if (shape === 'hexagon') return regular(cx, cy, r * 1.08, 6, 0);
|
|
23
|
+
return circle(cx, cy, r, 128);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The mark for resolved params. */
|
|
27
|
+
export function build(p) {
|
|
28
|
+
const { cx, cy, size } = BOX, R = size / 2, n = p.count;
|
|
29
|
+
// n rings round an open centre: 2n + 1 steps of ink and ground, the ink `weight` of each pair
|
|
30
|
+
const pair = R / (n + 0.5), t = Math.max(GAP * 1.4, pair * p.weight), parts = [];
|
|
31
|
+
for (let k = 0; k < n; k++) { const ro = R - k * pair; parts.push(D(outline(p.shape, ro), outline(p.shape, ro - t))); }
|
|
32
|
+
const rings = U(...parts), whole = outline(p.shape, R);
|
|
33
|
+
let region;
|
|
34
|
+
if (p.region === 'half') region = rect(cx, cy - size, size, 2 * size);
|
|
35
|
+
else if (p.region === 'band') region = rect(cx - (p.size * size) / 2, cy - size, p.size * size, 2 * size);
|
|
36
|
+
else if (p.region === 'quarter') region = rect(cx, cy - size, size, size);
|
|
37
|
+
else region = circle(cx + R * 0.45, cy, p.size * size * 0.62, 96);
|
|
38
|
+
region = I(rot(region, Number(p.angle), cx, cy), whole);
|
|
39
|
+
return tidy(X(rings, region), { share: 0.004, width: 9 });
|
|
40
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Leaf Tiles: one soft tile (a leaf, a quarter round, an arch or a disc) set in each cell of a small grid and turned from
|
|
3
|
+
* cell to cell, the house gap between them: four leaves that read as a clover, a pinwheel or a knot.
|
|
4
|
+
*/
|
|
5
|
+
import { U, rr, circle, rot } from '@logomarks/core/geometry';
|
|
6
|
+
import { BOX, GAP } from '../draw.js';
|
|
7
|
+
|
|
8
|
+
/** @type {import('../index.js').Control[]} */
|
|
9
|
+
export const controls = [
|
|
10
|
+
{ key: 'tile', label: 'Tile', type: 'choice', options: ['leaf', 'quarter', 'arch', 'drop'], value: 'leaf' },
|
|
11
|
+
{ key: 'order', label: 'Turned', type: 'choice', options: ['pinwheel', 'outward', 'inward', 'rows', 'same'], value: 'outward' },
|
|
12
|
+
{ key: 'facing', label: 'Facing', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
|
|
13
|
+
{ key: 'softness', label: 'Roundness', type: 'range', min: 0.5, max: 1, step: 0.01, value: 1 },
|
|
14
|
+
{ key: 'spacing', label: 'Gap', type: 'range', min: 0.6, max: 2, step: 0.1, value: 1 },
|
|
15
|
+
{ key: 'centre', label: 'Centre', type: 'choice', options: ['none', 'disc'], value: 'none' },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
/** A tile in the cell (x, y, s), unturned: its square corner(s) at the top left. */
|
|
19
|
+
function tile(kind, x, y, s, k) {
|
|
20
|
+
const r = (s * k) / (kind === 'arch' ? 2 : 1), q = Math.min(r, s / 2);
|
|
21
|
+
// corners: top left, top right, bottom right, bottom left
|
|
22
|
+
if (kind === 'leaf') return rr(x, y, s, s, [0, Math.min(r, s), 0, Math.min(r, s)].map((v) => Math.min(v, s * 0.999)));
|
|
23
|
+
if (kind === 'quarter') return rr(x, y, s, s, [0, 0, Math.min(r, s * 0.999), 0]);
|
|
24
|
+
if (kind === 'arch') return rr(x, y, s, s, [0, 0, q, q]);
|
|
25
|
+
return rr(x, y, s, s, [0, q, q, q]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The mark for resolved params. */
|
|
29
|
+
export function build(p) {
|
|
30
|
+
const g = GAP * p.spacing, s = (BOX.size - g) / 2, parts = [];
|
|
31
|
+
// each cell's turn: the square corner to the middle (outward leaves), away from it, round in a pinwheel, by rows
|
|
32
|
+
const base = { outward: [180, 270, 0, 90], inward: [0, 90, 180, 270], pinwheel: [0, 90, 180, 270].map((a) => a + 90), rows: [0, 0, 180, 180], same: [0, 0, 0, 0] }[p.order];
|
|
33
|
+
const cells = [[0, 0], [1, 0], [1, 1], [0, 1]];
|
|
34
|
+
cells.forEach(([c, r], i) => {
|
|
35
|
+
const x = BOX.x0 + c * (s + g), y = BOX.y0 + r * (s + g);
|
|
36
|
+
parts.push(rot(tile(p.tile, x, y, s, p.softness), base[i] + Number(p.facing), x + s / 2, y + s / 2));
|
|
37
|
+
});
|
|
38
|
+
let out = U(...parts);
|
|
39
|
+
if (p.centre === 'disc') { const d = circle(BOX.cx, BOX.cy, s * 0.3, 96); out = U(mapClear(out, d, g), d); }
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
import { D, grown } from '@logomarks/core/geometry';
|
|
44
|
+
/** `a` kept the gap away from `b`. */
|
|
45
|
+
const mapClear = (a, b, g) => D(a, grown(b, g));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Soft Pieces: one soft solid with three to eight lobes, whole, pierced by a round hole, or by a small echo of itself. No
|
|
3
|
+
* corner anywhere: the calm end of the set.
|
|
4
|
+
*/
|
|
5
|
+
import { D, poly, circle, closedCurve } from '@logomarks/core/geometry';
|
|
6
|
+
import { BOX } from '../draw.js';
|
|
7
|
+
|
|
8
|
+
/** @type {import('../index.js').Control[]} */
|
|
9
|
+
export const controls = [
|
|
10
|
+
{ key: 'lobes', label: 'Lobes', type: 'range', min: 3, max: 8, step: 1, value: 5 },
|
|
11
|
+
{ key: 'depth', label: 'Depth', type: 'range', min: 0.06, max: 0.3, step: 0.01, value: 0.16 },
|
|
12
|
+
{ key: 'inside', label: 'Inside', type: 'choice', options: ['solid', 'hole', 'echo'], value: 'hole' },
|
|
13
|
+
{ key: 'hole', label: 'Hole size', type: 'range', min: 0.18, max: 0.5, step: 0.01, value: 0.3 },
|
|
14
|
+
{ key: 'spin', label: 'Spin', type: 'range', min: 0, max: 60, step: 1, value: 0 },
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
/** The lobed outline at radius R: r = R (1 + depth cos(n t)) / (1 + depth). */
|
|
18
|
+
const blob = (n, depth, R, spin) => poly(closedCurve((t) => { const r = (R * (1 + depth * Math.cos(n * t))) / (1 + depth), a = t - Math.PI / 2 + (spin * Math.PI) / 180; return [BOX.cx + r * Math.cos(a), BOX.cy + r * Math.sin(a)]; }, 360));
|
|
19
|
+
|
|
20
|
+
/** The mark for resolved params. */
|
|
21
|
+
export function build(p) {
|
|
22
|
+
const R = BOX.size / 2, s = blob(p.lobes, p.depth, R, p.spin);
|
|
23
|
+
if (p.inside === 'hole') return D(s, circle(BOX.cx, BOX.cy, R * p.hole * (1 - p.depth), 96));
|
|
24
|
+
// four lobes echoed inside is the four-point sparkle: a round hole instead
|
|
25
|
+
if (p.inside === 'echo' && p.lobes === 4) return D(s, circle(BOX.cx, BOX.cy, R * p.hole * (1 - p.depth), 96));
|
|
26
|
+
if (p.inside === 'echo') return D(s, blob(p.lobes, p.depth, R * Math.min(p.hole + 0.12, 0.55), p.spin));
|
|
27
|
+
return s;
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Petal Loop: rings set round a centre and merged, so only the outline of the flower is left: a heavy loop that dips
|
|
3
|
+
* between each petal, round an open middle or a dot.
|
|
4
|
+
*/
|
|
5
|
+
import { U, D, circle, ellipse } from '@logomarks/core/geometry';
|
|
6
|
+
import { BOX, GAP } from '../draw.js';
|
|
7
|
+
|
|
8
|
+
/** @type {import('../index.js').Control[]} */
|
|
9
|
+
export const controls = [
|
|
10
|
+
{ key: 'petals', label: 'Petals', type: 'range', min: 3, max: 8, step: 1, value: 4 },
|
|
11
|
+
{ key: 'weight', label: 'Weight', type: 'range', min: 0.3, max: 0.7, step: 0.01, value: 0.5 },
|
|
12
|
+
{ key: 'spread', label: 'Spread', type: 'range', min: 0.75, max: 1.3, step: 0.01, value: 1 },
|
|
13
|
+
{ key: 'stretch', label: 'Petal length', type: 'range', min: 1, max: 1.5, step: 0.01, value: 1 },
|
|
14
|
+
{ key: 'centre', label: 'Centre', type: 'choice', options: ['open', 'dot'], value: 'open' },
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
/** The mark for resolved params. */
|
|
18
|
+
export function build(p) {
|
|
19
|
+
const { cx, cy, size } = BOX, n = p.petals, R = size / 2;
|
|
20
|
+
// petal radius r at distance d from the centre: neighbours overlap by `spread`, and d + r·stretch = R
|
|
21
|
+
const sin = Math.sin(Math.PI / n), r = R / (p.stretch + p.spread / sin), d = (r * p.spread) / sin;
|
|
22
|
+
const t = Math.max(GAP * 1.3, r * p.weight);
|
|
23
|
+
const at = (rad) => Array.from({ length: n }, (_, k) => { const a = (360 / n) * k - 90, ar = (a * Math.PI) / 180; return ellipse(cx + d * Math.cos(ar), cy + d * Math.sin(ar), rad * p.stretch, rad, a, 96); });
|
|
24
|
+
const outer = U(...at(r)), inner = U(...at(r - t));
|
|
25
|
+
let s = D(outer, inner);
|
|
26
|
+
if (p.centre === 'dot') { const dot = Math.max(GAP, d - (r - t) - GAP * 1.2); if (dot >= GAP) s = U(s, circle(cx, cy, Math.min(dot, d * 0.5), 64)); }
|
|
27
|
+
return s;
|
|
28
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pixel Curve: one bold curve drawn in square pixels on a coarse grid, so its edge climbs in steps: a quarter band, an
|
|
3
|
+
* arch, a hook or an S. Two or three pixels thick, one or two bands; never crumbs, and never a ring round a block.
|
|
4
|
+
*/
|
|
5
|
+
import { U, rect } from '@logomarks/core/geometry';
|
|
6
|
+
import { BOX } from '../draw.js';
|
|
7
|
+
|
|
8
|
+
/** @type {import('../index.js').Control[]} */
|
|
9
|
+
export const controls = [
|
|
10
|
+
{ key: 'curve', label: 'Curve', type: 'choice', options: ['quarter', 'arch', 'hook', 'ess'], value: 'quarter' },
|
|
11
|
+
{ key: 'grid', label: 'Pixels', type: 'range', min: 6, max: 12, step: 1, value: 8 },
|
|
12
|
+
{ key: 'weight', label: 'Weight', type: 'range', min: 0.2, max: 0.42, step: 0.01, value: 0.3 },
|
|
13
|
+
{ key: 'bands', label: 'Bands', type: 'range', min: 1, max: 2, step: 1, value: 1 },
|
|
14
|
+
{ key: 'facing', label: 'Facing', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
/** Whether the point (u, v) of the unit square (v down) is ink. */
|
|
18
|
+
function ink(p, u, v) {
|
|
19
|
+
const t = p.weight, bands = p.bands, inBand = (r, R) => {
|
|
20
|
+
// one band t wide ending at R, or two with a pixel-wide gap between, sharing that width
|
|
21
|
+
if (bands === 1) return r <= R && r > R - t;
|
|
22
|
+
const w = t * 0.62, gap = Math.max(1 / p.grid, t * 0.3);
|
|
23
|
+
return (r <= R && r > R - w) || (r <= R - w - gap && r > R - 2 * w - gap);
|
|
24
|
+
};
|
|
25
|
+
const core = () => false;
|
|
26
|
+
if (p.curve === 'quarter') { const r = Math.hypot(u, 1 - v); return inBand(r, 1) || core(r, 1); }
|
|
27
|
+
if (p.curve === 'arch') { const r = Math.hypot(u - 0.5, Math.max(0, 0.5 - v) ), x = Math.abs(u - 0.5); return v <= 0.5 ? inBand(r, 0.5) || core(r, 0.5) : inBand(x, 0.5) || core(x, 0.5); }
|
|
28
|
+
// a hook: an arch upside down whose right leg stops halfway
|
|
29
|
+
if (p.curve === 'hook') { const r = Math.hypot(u - 0.5, Math.max(0, v - 0.5)), x = Math.abs(u - 0.5); return v >= 0.5 ? inBand(r, 0.5) : u < 0.5 ? inBand(x, 0.5) : v > 0.3 && inBand(x, 0.5); }
|
|
30
|
+
// an S: two half rings, the upper open to the right's left, the lower mirrored
|
|
31
|
+
const top = v < 0.5, r = Math.hypot(u - 0.5, v - (top ? 0.27 : 0.73)), R = 0.27;
|
|
32
|
+
const open = top ? u > 0.5 && v > 0.27 : u < 0.5 && v < 0.73;
|
|
33
|
+
return !open && r <= R && r > R - Math.min(t * 0.6, 0.17);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The mark for resolved params. */
|
|
37
|
+
export function build(p) {
|
|
38
|
+
const n = p.grid, s = BOX.size / n, parts = [], q = Number(p.facing) / 90;
|
|
39
|
+
for (let r = 0; r < n; r++) {
|
|
40
|
+
let start = -1;
|
|
41
|
+
for (let c = 0; c <= n; c++) {
|
|
42
|
+
// the cell (r, c) seen from the facing: the grid turned by quarter turns
|
|
43
|
+
let u = (c + 0.5) / n, v = (r + 0.5) / n;
|
|
44
|
+
for (let k = 0; k < q; k++) [u, v] = [v, 1 - u];
|
|
45
|
+
const on = c < n && ink(p, u, v);
|
|
46
|
+
if (on && start < 0) start = c;
|
|
47
|
+
if (!on && start >= 0) { parts.push(rect(BOX.x0 + start * s, BOX.y0 + r * s - 0.01, (c - start) * s, s + 0.02)); start = -1; }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return parts.length ? U(...parts) : [];
|
|
51
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seam: one block parted in two by a single gap-wide seam that jogs on its way across: a step, a square tenon, a
|
|
3
|
+
* dovetail, or a corner taken out as its own piece. The two halves read as fitted together.
|
|
4
|
+
*/
|
|
5
|
+
import { D, rect, circle, rr, regular, stroke, rot } from '@logomarks/core/geometry';
|
|
6
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
7
|
+
|
|
8
|
+
/** @type {import('../index.js').Control[]} */
|
|
9
|
+
export const controls = [
|
|
10
|
+
{ key: 'joint', label: 'Joint', type: 'choice', options: ['step', 'tenon', 'dovetail', 'corner'], value: 'tenon' },
|
|
11
|
+
{ key: 'body', label: 'Body', type: 'choice', options: ['square', 'rounded', 'disc', 'hexagon'], value: 'square' },
|
|
12
|
+
{ key: 'at', label: 'Seam position', type: 'range', min: 0.3, max: 0.7, step: 0.01, value: 0.5 },
|
|
13
|
+
{ key: 'size', label: 'Joint size', type: 'range', min: 0.15, max: 0.4, step: 0.01, value: 0.28 },
|
|
14
|
+
{ key: 'reach', label: 'Joint depth', type: 'range', min: 0.12, max: 0.3, step: 0.01, value: 0.2 },
|
|
15
|
+
{ key: 'spin', label: 'Spin', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
|
|
16
|
+
{ key: 'spacing', label: 'Gap', type: 'range', min: 1, max: 2, step: 0.1, value: 1.1 },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
/** The mark for resolved params: the seam drawn top to bottom, then the whole turned. */
|
|
20
|
+
export function build(p) {
|
|
21
|
+
const { cx, cy, x0, y0, x1, y1, size } = BOX, g = GAP * p.spacing, R = size / 2;
|
|
22
|
+
const body = p.body === 'rounded' ? rr(x0, y0, size, size, size * 0.2) : p.body === 'disc' ? circle(cx, cy, R, 128) : p.body === 'hexagon' ? regular(cx, cy, R * 1.06, 6, 0) : rect(x0, y0, size, size);
|
|
23
|
+
const x = x0 + size * p.at, h = (size * p.size) / 2, d = size * p.reach, T = y0 - 40, B = y1 + 40;
|
|
24
|
+
let line;
|
|
25
|
+
if (p.joint === 'step') line = [[x - d / 2, T], [x - d / 2, cy], [x + d / 2, cy], [x + d / 2, B]];
|
|
26
|
+
else if (p.joint === 'tenon') line = [[x, T], [x, cy - h], [x + d, cy - h], [x + d, cy + h], [x, cy + h], [x, B]];
|
|
27
|
+
else if (p.joint === 'dovetail') line = [[x, T], [x, cy - h * 0.6], [x + d, cy - h * 1.15], [x + d, cy + h * 1.15], [x, cy + h * 0.6], [x, B]];
|
|
28
|
+
else line = [[x, T], [x, y0 + size * (0.35 + p.size * 0.6)], [x1 + 40, y0 + size * (0.35 + p.size * 0.6)]];
|
|
29
|
+
return tidy(rot(D(body, stroke(line, g, { chunk: 1 })), Number(p.spin), cx, cy));
|
|
30
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strips: two to four straight strips of tape laid at angles, each passing over the last with the house gap and
|
|
3
|
+
* running a little past the joint: a woven triangle, a pair of chevrons, a woven diamond, a Z. Square-cut
|
|
4
|
+
* ends; never level-and-upright strips crossed, which is a plus or a hash sign.
|
|
5
|
+
*/
|
|
6
|
+
import { U, I, bar, over, rot, circle } 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: 'layout', label: 'Layout', type: 'choice', options: ['triangle', 'chevrons', 'diamond', 'zed'], value: 'triangle' },
|
|
12
|
+
{ key: 'weight', label: 'Weight', type: 'range', min: 0.14, max: 0.26, step: 0.01, value: 0.2 },
|
|
13
|
+
{ key: 'overhang', label: 'Overhang', type: 'range', min: 0, max: 0.16, step: 0.01, value: 0.08 },
|
|
14
|
+
{ key: 'spin', label: 'Spin', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
|
|
15
|
+
{ key: 'spacing', label: 'Gap', type: 'range', min: 0.8, max: 1.6, step: 0.1, value: 1 },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
/** The strips of a layout as [from, to] pairs in the unit square, in laying order; `loop` when they close a ring. */
|
|
19
|
+
function plan(layout) {
|
|
20
|
+
if (layout === 'triangle') { const a = [0.5, 0.06], b = [0.95, 0.86], c = [0.05, 0.86]; return { segs: [[a, b], [b, c], [c, a]], loop: true }; }
|
|
21
|
+
if (layout === 'diamond') { const a = [0.5, 0.08], b = [0.92, 0.5], c = [0.5, 0.92], d = [0.08, 0.5]; return { segs: [[a, b], [b, c], [c, d], [d, a]], loop: true }; }
|
|
22
|
+
if (layout === 'chevrons') return { segs: [[[0.08, 0.9], [0.46, 0.5]], [[0.08, 0.1], [0.46, 0.5]], [[0.54, 0.9], [0.92, 0.5]], [[0.54, 0.1], [0.92, 0.5]]], ends: [0, 1] };
|
|
23
|
+
return { segs: [[[0.06, 0.16], [0.94, 0.16]], [[0.06, 0.84], [0.94, 0.84]], [[0.88, 0.16], [0.12, 0.84]]], ends: [1, 1], last: true };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The mark for resolved params. */
|
|
27
|
+
export function build(p) {
|
|
28
|
+
const { x0, y0, size, cx, cy } = BOX, w = p.weight * size, g = GAP * p.spacing, e = p.overhang * size;
|
|
29
|
+
const { segs, loop, ends = [1, 1], last } = plan(p.layout);
|
|
30
|
+
const pt = ([x, y]) => [x0 + x * size, y0 + y * size];
|
|
31
|
+
// a strip from a to b, run on past each end by the overhang where `ends` says (like tape past a joint)
|
|
32
|
+
const strip = ([a, b], [ea, eb]) => { const A = pt(a), B = pt(b), L = Math.hypot(B[0] - A[0], B[1] - A[1]), ux = (B[0] - A[0]) / L, uy = (B[1] - A[1]) / L; return bar([A[0] - ux * e * ea, A[1] - uy * e * ea], [B[0] + ux * e * eb, B[1] + uy * e * eb], w); };
|
|
33
|
+
const all = segs.map((sg, i) => strip(sg, last && i < segs.length - 1 ? [0, 0] : ends));
|
|
34
|
+
let s = all[0];
|
|
35
|
+
for (const b of all.slice(1)) s = over(s, b, g);
|
|
36
|
+
// a closed ring is woven: the first strip passes back over the last at the corner they share
|
|
37
|
+
if (loop) { const A = pt(segs[0][0]); s = over(s, I(all[0], circle(A[0], A[1], w * 1.5 + e, 48)), g); }
|
|
38
|
+
return tidy(rot(s, Number(p.spin), cx, cy));
|
|
39
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trine: one solid cut into three by lines that run past the centre, never through it, so the three parts turn round
|
|
3
|
+
* a small triangle like a shutter. Three lines through the centre are a known badge; these miss it by design.
|
|
4
|
+
*/
|
|
5
|
+
import { D, I, U, circle, regular, poly } from '@logomarks/core/geometry';
|
|
6
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
7
|
+
|
|
8
|
+
/** @type {import('../index.js').Control[]} */
|
|
9
|
+
export const controls = [
|
|
10
|
+
{ key: 'body', label: 'Body', type: 'choice', options: ['disc', 'hexagon', 'triangle', 'ring', 'hexring'], value: 'disc' },
|
|
11
|
+
{ key: 'offset', label: 'Past the centre', type: 'range', min: 0.12, max: 0.42, step: 0.01, value: 0.22 },
|
|
12
|
+
{ key: 'middle', label: 'Middle', type: 'choice', options: ['open', 'triangle'], value: 'open' },
|
|
13
|
+
{ key: 'spacing', label: 'Gap', type: 'range', min: 1, max: 2.2, step: 0.1, value: 1.2 },
|
|
14
|
+
{ key: 'spin', label: 'Spin', type: 'range', min: 0, max: 120, step: 1, value: 0 },
|
|
15
|
+
{ key: 'hand', label: 'Hand', type: 'choice', options: ['right', 'left'], value: 'right' },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
/** The half plane n·(x − c) ≥ d (or ≤ d with `below`), n at `deg`, as a big polygon. */
|
|
19
|
+
function half(deg, d, below) {
|
|
20
|
+
const { cx, cy } = BOX, a = (deg * Math.PI) / 180, n = [Math.cos(a), Math.sin(a)], t = [-n[1], n[0]], F = 2000, s = below ? -1 : 1;
|
|
21
|
+
const o = [cx + n[0] * d, cy + n[1] * d];
|
|
22
|
+
return poly([[o[0] - t[0] * F, o[1] - t[1] * F], [o[0] + t[0] * F, o[1] + t[1] * F], [o[0] + t[0] * F + n[0] * F * s, o[1] + t[1] * F + n[1] * F * s], [o[0] - t[0] * F + n[0] * F * s, o[1] - t[1] * F + n[1] * F * s]]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The mark for resolved params. */
|
|
26
|
+
export function build(p) {
|
|
27
|
+
const { cx, cy, size } = BOX, R = size / 2, g = GAP * p.spacing;
|
|
28
|
+
let s = p.body === 'hexagon' || p.body === 'hexring' ? regular(cx, cy, R, 6, -90) : p.body === 'triangle' ? regular(cx, cy + R * 0.14, R * 1.16, 3, -90) : circle(cx, cy, R, 128);
|
|
29
|
+
if (p.body === 'ring') s = D(s, circle(cx, cy, R * 0.46, 96));
|
|
30
|
+
if (p.body === 'hexring') s = D(s, regular(cx, cy, R * 0.46, 6, -90));
|
|
31
|
+
// three lines, each passing the centre at distance o; part i lies beyond line i and short of the next one round,
|
|
32
|
+
// each side set back half a gap. What all three leave in the middle is a small triangle: kept or left open.
|
|
33
|
+
const o = p.offset * R, k = p.hand === 'left' ? -1 : 1, base = (p.body === 'triangle' ? 30 : 0) + p.spin, parts = [];
|
|
34
|
+
for (let i = 0; i < 3; i++) parts.push(I(s, half(base + 120 * i, o + g / 2), half(base + 120 * (i + k), o - g / 2, true)));
|
|
35
|
+
if (p.middle === 'triangle' && o - g / 2 > GAP * 1.6) parts.push(I(s, half(base, o - g / 2, true), half(base + 120, o - g / 2, true), half(base + 240, o - g / 2, true)));
|
|
36
|
+
return tidy(U(...parts));
|
|
37
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Squiggle: one solid cut in two by a wavy line, or with one edge worn into a wave and a loose squiggle running beside
|
|
3
|
+
* it. At least a wave and a half: a single S through a disc is a known symbol.
|
|
4
|
+
*/
|
|
5
|
+
import { U, D, I, rect, circle, rr, regular, poly, rot, stroke } from '@logomarks/core/geometry';
|
|
6
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
7
|
+
|
|
8
|
+
/** @type {import('../index.js').Control[]} */
|
|
9
|
+
export const controls = [
|
|
10
|
+
{ key: 'body', label: 'Body', type: 'choice', options: ['disc', 'rounded', 'square', 'hexagon'], value: 'disc' },
|
|
11
|
+
{ key: 'move', label: 'Move', type: 'choice', options: ['split', 'edge'], value: 'split' },
|
|
12
|
+
{ key: 'waves', label: 'Waves', type: 'range', min: 1.5, max: 3.5, step: 0.5, value: 2 },
|
|
13
|
+
{ key: 'swell', label: 'Wave height', type: 'range', min: 0.05, max: 0.13, step: 0.005, value: 0.09 },
|
|
14
|
+
{ key: 'at', label: 'Position', type: 'range', min: 0.3, max: 0.7, step: 0.01, value: 0.5 },
|
|
15
|
+
{ key: 'angle', label: 'Angle', type: 'choice', options: ['0', '45', '90', '135'], value: '0' },
|
|
16
|
+
{ key: 'spacing', label: 'Gap', type: 'range', min: 1, max: 2.2, step: 0.1, value: 1.3 },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
/** A level wave line across the canvas at height y. */
|
|
20
|
+
const wave = (y, waves, amp) => Array.from({ length: 241 }, (_, i) => { const t = i / 240, x = BOX.x0 - 60 + t * (BOX.size + 120); return [x, y + amp * Math.sin(((x - BOX.x0) / BOX.size) * waves * 2 * Math.PI)]; });
|
|
21
|
+
|
|
22
|
+
/** The mark for resolved params. */
|
|
23
|
+
export function build(p) {
|
|
24
|
+
const { cx, cy, x0, y0, size } = BOX, R = size / 2, g = GAP * p.spacing, amp = p.swell * size;
|
|
25
|
+
const body = p.body === 'rounded' ? rr(x0, y0, size, size, size * 0.2) : p.body === 'square' ? rect(x0, y0, size, size) : p.body === 'hexagon' ? regular(cx, cy, R * 1.06, 6, 0) : circle(cx, cy, R, 128);
|
|
26
|
+
const y = y0 + size * p.at, line = wave(y, p.waves, amp);
|
|
27
|
+
let s;
|
|
28
|
+
if (p.move === 'split') s = D(body, stroke(line, g, { chunk: 8 }));
|
|
29
|
+
else {
|
|
30
|
+
// everything below the wave goes; a squiggle of the band's own weight runs beside the worn edge
|
|
31
|
+
const w = Math.max(GAP * 1.5, size * 0.085), below = poly([...line, [BOX.x1 + 60, BOX.y1 + 90], [x0 - 60, BOX.y1 + 90]]);
|
|
32
|
+
const kept = D(body, below), free = I(stroke(wave(y + g + w / 2 + 2, p.waves, amp), w, { chunk: 8 }), rect(x0, y0 - 9, size, 2 * size));
|
|
33
|
+
s = U(D(kept, stroke(line, 2, { chunk: 8 })), I(free, rect(cx - R * 0.86, y0, R * 1.72, 2 * size)));
|
|
34
|
+
}
|
|
35
|
+
return tidy(rot(s, Number(p.angle), cx, cy));
|
|
36
|
+
}
|
package/src/tuning.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tuning: for each recipe, what a shuffle draws. The sliders keep their whole range for a hand; a shuffle stays in the
|
|
3
|
+
* part of it that gives a mark worth keeping (heavy weight, few big parts, the house gap) and makes ONE move: the
|
|
4
|
+
* second moves (a slant, a taper, a twist, a second cut) are `rare`, the chance a shuffle touches them at all. From
|
|
5
|
+
* contact sheets of every recipe's shuffles, judged against the live set. `value` here replaces a control's default.
|
|
6
|
+
*/
|
|
7
|
+
const R = (lo, hi) => ({ random: [lo, hi] });
|
|
8
|
+
const rare = (p, lo, hi) => (lo === undefined ? { rare: p } : { rare: p, random: [lo, hi] });
|
|
9
|
+
const of = (...o) => ({ random: o });
|
|
10
|
+
|
|
11
|
+
export const TUNING = {
|
|
12
|
+
bars: { count: R(2, 4), weight: R(0.58, 0.8), cutSize: R(0.1, 0.2), cutAt: R(0.35, 0.65), lengths: { rare: 0.3 }, ends: { rare: 0.25 }, slant: rare(0.15, -20, 20), level: { rare: 0.1 }, cutAngle: rare(0.25, -35, 35), spine: { rare: 0.2 }, widths: { rare: 0.08, random: ['growing', 'thin-thick'] } },
|
|
13
|
+
bands: { count: R(2, 3), weight: R(0.6, 0.8), ends: { rare: 0.3 }, slant: rare(0.15, -18, 18) },
|
|
14
|
+
twin: { thickness: R(0.3, 0.42), slant: rare(0.3, -22, 22) },
|
|
15
|
+
stack: { layout: of('stack', 'row', 'overlap', 'nest'), count: R(2, 3), order: of('AB', 'ABA', 'A'), step: { rare: 0.2 }, combine: of('gap', 'over', 'cut'), size: rare(0.3, 0.75, 1), overlap: R(0.2, 0.45) },
|
|
16
|
+
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) },
|
|
17
|
+
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) },
|
|
18
|
+
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 } },
|
|
19
|
+
tiles: { grid: R(2, 3), density: R(0.72, 1), symmetry: of('mirror', 'both', 'turn') },
|
|
20
|
+
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 } },
|
|
21
|
+
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) },
|
|
22
|
+
rings: { count: R(2, 3), weight: R(0.55, 0.8), gaps: R(1, 2), gapSize: R(1.4, 3), centre: of('open', 'open', 'dot'), shape: of('circle', 'circle', 'rounded', 'hexagon'), offset: rare(0.15, 0.2, 0.5), breakKind: { rare: 0.15 } },
|
|
23
|
+
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 } },
|
|
24
|
+
chevrons: { count: R(2, 4), weight: R(0.5, 0.75), angle: R(75, 120), grow: rare(0.3, 0.15, 0.45), move: { rare: 0.35 } },
|
|
25
|
+
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 } },
|
|
26
|
+
cut: { second: { rare: 0.2 } },
|
|
27
|
+
split: { cuts: R(1, 2), twist: rare(0.15, 2, 6), spacing: R(1, 2) },
|
|
28
|
+
venn: { count: R(2, 3), shape: of('circle', 'circle', 'rounded'), layout: of('row', 'triangle'), combine: of('xor', 'knockout'), overlap: R(0.28, 0.5) },
|
|
29
|
+
spiral: { turns: R(1.25, 2.5), tail: rare(0.3, 0.2, 0.5), squash: rare(0.2, 0.75, 0.9) },
|
|
30
|
+
bloom: { petals: R(4, 8), width: R(0.4, 0.8), twist: rare(0.25, -35, 35) },
|
|
31
|
+
links: { weight: R(0.1, 0.16) },
|
|
32
|
+
horizon: { lines: R(2, 4), stripes: R(2, 4), size: R(0.6, 0.9) },
|
|
33
|
+
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) },
|
|
34
|
+
hex: { rings: R(1, 1), density: R(0.5, 0.9), cell: { rare: 0.15 }, gap: R(1, 1.5) },
|
|
35
|
+
iso: { grid: R(2, 3), height: R(1, 2), density: R(0.5, 1) },
|
|
36
|
+
letter: { build: of('stencil', 'route', 'blocks'), weight: R(0.17, 0.26), slant: rare(0.12, -12, 12), spacing: R(1, 1.6) },
|
|
37
|
+
arcstep: { steps: R(1, 3), weight: R(0.66, 0.86), rise: rare(0.3, 0.7, 1.3), ends: { rare: 0.3 } },
|
|
38
|
+
halfsq: { grid: R(2, 2), halves: R(0.4, 0.75), parted: { rare: 0 } },
|
|
39
|
+
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) },
|
|
40
|
+
leaves: { softness: rare(0.3, 0.6, 1), spacing: rare(0.3, 0.8, 1.6), centre: { rare: 0.2 } },
|
|
41
|
+
lobes: { lobes: R(5, 8), depth: R(0.1, 0.22), inside: of('hole', 'hole', 'echo', 'solid'), hole: R(0.24, 0.42), spin: rare(0.3, 0, 40) },
|
|
42
|
+
loops: { petals: R(3, 6), weight: R(0.42, 0.56), spread: R(0.9, 1), stretch: rare(0.15, 1, 1.2), centre: of('open', 'open', 'dot') },
|
|
43
|
+
trine: { offset: R(0.14, 0.25), middle: of('open'), spacing: R(1, 1.6), spin: rare(0.4, 0, 120) },
|
|
44
|
+
strips: { layout: of('triangle', 'chevrons', 'diamond'), weight: R(0.17, 0.24), overhang: R(0.04, 0.12), spacing: R(0.9, 1.3) },
|
|
45
|
+
bite: { size: R(0.15, 0.22), depth: R(0.65, 1), slide: R(0.12, 0.2), softness: R(0.16, 0.28) },
|
|
46
|
+
blades: { count: R(2, 3), grow: R(0.25, 0.65), width: R(1.5, 2.4), belly: R(0.6, 1), edge: { rare: 0.2 }, lean: rare(0.3, -14, 14) },
|
|
47
|
+
wavecut: { move: of('split'), waves: R(1.5, 2.5), swell: R(0.07, 0.12), at: R(0.42, 0.58), spacing: R(1.1, 1.7) },
|
|
48
|
+
capsules: { count: R(2, 3), lengths: of('stagger', 'grow', 'middle'), lean: R(16, 30), short: R(0.5, 0.75), softness: R(0.6, 1), cut: { rare: 0.15 }, spacing: R(1, 1.4) },
|
|
49
|
+
flare: { rays: R(3, 5), inner: R(0.16, 0.3), spacing: R(1.2, 2), body: of('square', 'square', 'round') },
|
|
50
|
+
seam: { body: of('square', 'square', 'rounded', 'disc', 'hexagon'), at: R(0.4, 0.6), size: R(0.2, 0.36), reach: R(0.14, 0.26), spacing: R(1, 1.5) },
|
|
51
|
+
pixelarc: { curve: of('quarter', 'arch', 'hook'), grid: R(6, 9), weight: R(0.3, 0.42), bands: R(1, 1) },
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** The two to four controls of each recipe that decide the mark: a page shows these first, the rest under "More". */
|
|
55
|
+
export const MAIN = {
|
|
56
|
+
bars: ['count', 'weight', 'cut', 'ends'], bands: ['count', 'weight', 'join', 'extra'], twin: ['piece', 'thickness', 'corner', 'ends'], stack: ['layout', 'shapeA', 'shapeB', 'combine'],
|
|
57
|
+
shear: ['rows', 'cols', 'lean', 'angle'], turns: ['unit', 'count', 'size', 'join'], burst: ['rays', 'ray', 'width', 'inner'], tiles: ['grid', 'layout', 'set', 'symmetry'],
|
|
58
|
+
route: ['layout', 'steps', 'weight', 'node'], arcs: ['count', 'sweep', 'weight', 'legs'], rings: ['count', 'weight', 'gaps', 'shape'], stripes: ['shape', 'stripes', 'angle', 'move'],
|
|
59
|
+
chevrons: ['count', 'angle', 'weight', 'point'], waves: ['count', 'weight', 'amplitude', 'clip'], cut: ['body', 'cut', 'side', 'size'], split: ['shape', 'cuts', 'angle', 'slide'],
|
|
60
|
+
venn: ['count', 'shape', 'layout', 'combine'], spiral: ['turns', 'weight', 'start'], bloom: ['petals', 'petal', 'width', 'centre'], links: ['count', 'loop', 'layout', 'weight'],
|
|
61
|
+
horizon: ['sun', 'size', 'lines', 'style'], steps: ['count', 'shape', 'tread'], hex: ['layout', 'density', 'symmetry'],
|
|
62
|
+
iso: ['grid', 'layout', 'height'], letter: ['char', 'build', 'weight'],
|
|
63
|
+
arcstep: ['layout', 'steps', 'weight', 'corners'], halfsq: ['layout', 'halves', 'symmetry'], invert: ['count', 'weight', 'region', 'angle'], leaves: ['tile', 'order', 'facing'],
|
|
64
|
+
lobes: ['lobes', 'depth', 'inside'], loops: ['petals', 'weight', 'spread', 'centre'], trine: ['body', 'offset', 'middle'],
|
|
65
|
+
strips: ['layout', 'weight', 'overhang'], bite: ['place', 'size', 'depth', 'body'], blades: ['count', 'grow', 'width', 'belly'],
|
|
66
|
+
wavecut: ['body', 'move', 'waves', 'swell'], capsules: ['count', 'lengths', 'lean'], flare: ['origin', 'rays', 'body'], seam: ['joint', 'body', 'size', 'reach'], pixelarc: ['curve', 'grid', 'weight', 'bands'],
|
|
67
|
+
};
|