@logomarks/generate 0.1.0 → 0.2.1
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 +54 -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 +49 -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 +48 -0
- package/src/recipes/loops.js +28 -0
- package/src/recipes/pixelarc.js +59 -0
- package/src/recipes/seam.js +30 -0
- package/src/recipes/strips.js +59 -0
- package/src/recipes/trine.js +38 -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,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,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,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Half Square: a small grid of half squares (a square cut corner to corner) and whole squares, each a house gap from
|
|
3
|
+
* the next, set by ONE rule: every half the same way, rows turned about, halves and squares in a checker, or a zigzag.
|
|
4
|
+
* A quilt block, read as built. Merged into one solid the same cells fall into arrows, crowns, houses and envelopes
|
|
5
|
+
* (every one-solid arrangement on 2 × 2 and 3 × 2 was drawn and looked at), so the cells stay parted.
|
|
6
|
+
*/
|
|
7
|
+
import { rect, poly } from '@logomarks/core/geometry';
|
|
8
|
+
import { BOX, GAP } from '../draw.js';
|
|
9
|
+
|
|
10
|
+
/** @type {import('../index.js').Control[]} */
|
|
11
|
+
export const controls = [
|
|
12
|
+
{ key: 'grid', label: 'Grid', type: 'choice', options: ['2x2', '3x2', '2x3', '3x3'], value: '2x2' },
|
|
13
|
+
{ key: 'rule', label: 'Rule', type: 'choice', options: ['rows', 'same', 'checker', 'zigzag', 'diagonal', 'steps'], value: 'rows' },
|
|
14
|
+
{ key: 'facing', label: 'Facing', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
|
|
15
|
+
{ key: 'spacing', label: 'Gap', type: 'range', min: 0.8, max: 1.8, step: 0.1, value: 1 },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
/** A cell inset by h on every side: 'full', or a half square keeping corner k (0 top left, then clockwise). */
|
|
19
|
+
function cell(k, x, y, s, h) {
|
|
20
|
+
if (k === 'full') return rect(x + h, y + h, s - 2 * h, s - 2 * h);
|
|
21
|
+
// the half's right angle at corner k, its legs shortened so the long side is also h in from the diagonal
|
|
22
|
+
const L = s - h * (2 + Math.SQRT2), sx = k === 0 || k === 3 ? 1 : -1, sy = k === 0 || k === 1 ? 1 : -1;
|
|
23
|
+
const cx = (sx > 0 ? x : x + s) + sx * h, cy = (sy > 0 ? y : y + s) + sy * h;
|
|
24
|
+
return poly([[cx, cy], [cx + sx * L, cy], [cx, cy + sy * L]]);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** What stands in cell (r, c) under a rule: a corner 0–3, 'full', or null for an empty cell. */
|
|
28
|
+
function at(rule, r, c, k, rows, cols) {
|
|
29
|
+
if (rule === 'same') return k;
|
|
30
|
+
if (rule === 'checker') return (r + c) % 2 ? k : 'full';
|
|
31
|
+
// diagonal: a half on each cell of the diagonal, whole squares off it
|
|
32
|
+
if (rule === 'diagonal') return r === c ? k : 'full';
|
|
33
|
+
if (rule === 'zigzag') return c % 2 ? [1, 0, 3, 2][k] : k;
|
|
34
|
+
// steps: whole squares on and under the diagonal's stair, a half on each tread, nothing above
|
|
35
|
+
if (rule === 'steps') { const d = c - r * (cols / rows); return d < -0.01 ? 'full' : d < 0.99 ? 3 : null; }
|
|
36
|
+
return r % 2 ? (k + 2) % 4 : k; // rows: each row the last one turned about
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The mark for resolved params. */
|
|
40
|
+
export function build(p) {
|
|
41
|
+
const [cols, rows] = (/^[23]x[23]$/.test(p.grid) ? p.grid : '2x2').split('x').map(Number), k0 = Number(p.facing) / 90 || 0;
|
|
42
|
+
const s = BOX.size / Math.max(cols, rows), x0 = BOX.cx - (cols * s) / 2, y0 = BOX.cy - (rows * s) / 2, h = (GAP * (p.spacing || 1)) / 2;
|
|
43
|
+
const parts = [];
|
|
44
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) {
|
|
45
|
+
const k = at(p.rule, r, c, k0, rows, cols);
|
|
46
|
+
if (k !== null) parts.push(cell(k, x0 + c * s, y0 + r * s, s, h));
|
|
47
|
+
}
|
|
48
|
+
return parts;
|
|
49
|
+
}
|
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', 'Half squares and squares set by one rule, a gap between each.', 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', 'A soft block parted into pebbles of unlike size.', lobes),
|
|
85
|
+
loops: R('loops', 'Loops', 'Rings merged into one heavy flower outline.', loops),
|
|
86
|
+
trine: R('trine', 'Trine', 'A solid with three slits that pass the centre and stop short.', 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 figure 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,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Soft Pieces: one soft block (a disc, a soft square or a pebble) parted into two to four pebbles of unlike size by
|
|
3
|
+
* curved gaps, every corner rounded: stones resting together, the calm end of the set. No hole in the middle and no ring
|
|
4
|
+
* of teeth: a lobed solid with a round hole is a cog, the settings icon.
|
|
5
|
+
*/
|
|
6
|
+
import { D, I, U, poly, circle, squircle, closedCurve, grow, rot } 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: 'body', label: 'Body', type: 'choice', options: ['pebble', 'disc', 'square'], value: 'pebble' },
|
|
12
|
+
{ key: 'pieces', label: 'Pieces', type: 'range', min: 2, max: 4, step: 1, value: 3 },
|
|
13
|
+
{ key: 'cuts', label: 'Cuts', type: 'choice', options: ['slices', 'tee'], value: 'tee' },
|
|
14
|
+
{ key: 'bend', label: 'Bend', type: 'range', min: 0.1, max: 1, step: 0.01, value: 0.6 },
|
|
15
|
+
{ key: 'balance', label: 'Balance', type: 'range', min: -0.2, max: 0.2, step: 0.01, value: 0.08 },
|
|
16
|
+
{ key: 'angle', label: 'Angle', type: 'range', min: 0, max: 345, step: 15, value: 30 },
|
|
17
|
+
{ key: 'soften', label: 'Soften', type: 'range', min: 0.2, max: 1, step: 0.05, value: 0.7 },
|
|
18
|
+
{ key: 'spacing', label: 'Gap', type: 'range', min: 0.9, max: 1.8, step: 0.1, value: 1.1 },
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
/** Where the cuts fall across the body, as shares of its width: unlike pieces by design. */
|
|
22
|
+
const AT = { 2: [0.42], 3: [0.3, 0.64], 4: [0.24, 0.5, 0.74] };
|
|
23
|
+
|
|
24
|
+
/** The mark for resolved params. */
|
|
25
|
+
export function build(p) {
|
|
26
|
+
const { cx, cy, size } = BOX, R = size / 2, g = GAP * p.spacing, n = Math.round(p.pieces);
|
|
27
|
+
const body = p.body === 'disc' ? circle(cx, cy, R, 56) : p.body === 'square' ? squircle(cx, cy, R, 4.2, 56)
|
|
28
|
+
: poly(closedCurve((t) => { const r = (R * (1 + 0.07 * Math.cos(2 * t + 0.6) + 0.045 * Math.cos(3 * t + 2))) / 1.1; return [cx + r * Math.cos(t), cy + r * Math.sin(t)]; }, 56));
|
|
29
|
+
// a cut is a gap along a big circle whose centre lies off to the left: the more bend, the nearer and the rounder
|
|
30
|
+
const far = R * (0.9 + 2.6 * (1 - p.bend));
|
|
31
|
+
const arc = (share, dirDeg, c0 = [cx, cy]) => { const a = (dirDeg * Math.PI) / 180, o = [c0[0] - Math.cos(a) * far, c0[1] - Math.sin(a) * far], rho = far + (2 * share - 1) * R * 0.92; return { o, rho }; };
|
|
32
|
+
const gapOf = ({ o, rho }) => D(circle(o[0], o[1], rho + g / 2, 64), circle(o[0], o[1], rho - g / 2, 64));
|
|
33
|
+
let s;
|
|
34
|
+
if (p.cuts === 'tee' && n >= 3) {
|
|
35
|
+
// one cut across, then the larger side cut again the other way (and, for four, the smaller side too)
|
|
36
|
+
const first = arc(0.4 + p.balance * 0.5, 0), inner = circle(first.o[0], first.o[1], first.rho - g / 2, 64), outer = circle(first.o[0], first.o[1], first.rho + g / 2, 64);
|
|
37
|
+
const small = I(body, inner), big = D(body, outer);
|
|
38
|
+
const second = gapOf(arc(0.56 - p.balance, 90)), third = gapOf(arc(0.4 + p.balance, 270));
|
|
39
|
+
s = U(n >= 4 ? D(small, third) : small, D(big, second));
|
|
40
|
+
} else {
|
|
41
|
+
const at = (AT[n] || AT[3]).map((t, i) => t + p.balance * (i % 2 ? -0.5 : 0.5));
|
|
42
|
+
s = D(body, U(...at.map((t) => gapOf(arc(t, 0)))));
|
|
43
|
+
}
|
|
44
|
+
// every corner rounded: each piece shrunk and grown back by the same radius
|
|
45
|
+
const r = Math.min(46, 10 + 40 * p.soften);
|
|
46
|
+
s = grow(grow(s, -r), r);
|
|
47
|
+
return tidy(rot(s, p.angle || 0, cx, cy), { share: 0.04, width: 22 });
|
|
48
|
+
}
|
|
@@ -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,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pixel Curve: one bold figure drawn in square pixels on a coarse grid, so its edges climb in steps: two arcs back to
|
|
3
|
+
* back, a wave, an S, an open ring, a spiral turn, an arch or a hook. Heavy and in one or two pieces; never crumbs,
|
|
4
|
+
* never a ring round a block (a target), never two holes side by side.
|
|
5
|
+
*/
|
|
6
|
+
import { U, rect } from '@logomarks/core/geometry';
|
|
7
|
+
import { BOX } from '../draw.js';
|
|
8
|
+
|
|
9
|
+
/** @type {import('../index.js').Control[]} */
|
|
10
|
+
export const controls = [
|
|
11
|
+
{ key: 'grid', label: 'Pixels', type: 'range', min: 5, max: 12, step: 1, value: 7 },
|
|
12
|
+
{ key: 'curve', label: 'Curve', type: 'choice', options: ['twin', 'wave', 'ess', 'cee', 'spiral', 'arch', 'hook', 'quarter'], value: 'twin' },
|
|
13
|
+
{ key: 'weight', label: 'Weight', type: 'range', min: 0.2, max: 0.42, step: 0.01, value: 0.3 },
|
|
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, band = (r, R, w = t) => r <= R && r > R - w;
|
|
20
|
+
if (p.curve === 'quarter') return band(Math.hypot(u, 1 - v), 1);
|
|
21
|
+
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 ? band(r, 0.5) : band(x, 0.5); }
|
|
22
|
+
// a hook: an arch upside down whose right leg stops short
|
|
23
|
+
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 ? band(r, 0.5) : u < 0.5 ? band(x, 0.5) : v > 0.3 && band(x, 0.5); }
|
|
24
|
+
// twin: a quarter band round the top left corner and its twin round the bottom right, a clear lane between them
|
|
25
|
+
if (p.curve === 'twin') { const w = Math.min(t, 0.3), R = 0.58; return band(Math.hypot(u, v), R, w) || band(Math.hypot(1 - u, 1 - v), R, w); }
|
|
26
|
+
// wave: one band riding a full sine across the square
|
|
27
|
+
if (p.curve === 'wave') { const w = Math.min(t * 1.25, 0.44), y = 0.5 - 0.5 * (1 - w) * Math.sin(u * Math.PI * 2); return Math.abs(v - y) <= w / 2; }
|
|
28
|
+
// cee: a ring open to the right by at least one whole row of pixels (two on an even grid: one would close it and
|
|
29
|
+
// leave a plus-shaped hole)
|
|
30
|
+
if (p.curve === 'cee') { const x = u - 0.5, y = v - 0.5, r = Math.hypot(x, y), w = Math.min(t * 0.8, 0.3); return band(r, 0.5, w) && !(x > 0 && Math.abs(y) < Math.max((p.grid % 2 ? 0.51 : 1.01) / p.grid, w * 0.45)); }
|
|
31
|
+
// spiral: one and a quarter turns of a band winding out from the middle
|
|
32
|
+
if (p.curve === 'spiral') {
|
|
33
|
+
const x = u - 0.5, y = v - 0.5, r = Math.hypot(x, y), a = (Math.atan2(y, x) + Math.PI * 2) % (Math.PI * 2), w = Math.min(t * 0.55, 0.17), pitch = 0.5 - w / 2 - 0.06;
|
|
34
|
+
for (let k = 0; k < 2; k++) { const th = a + k * Math.PI * 2; if (th > Math.PI * 2.6) continue; const rc = 0.06 + w / 2 + (pitch * th) / (Math.PI * 2.6); if (Math.abs(r - rc) <= w / 2) return true; }
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
// an S: two half rings, each open on its inner quarter
|
|
38
|
+
const top = v < 0.5, r = Math.hypot(u - 0.5, v - (top ? 0.27 : 0.73)), R = 0.27;
|
|
39
|
+
const open = top ? u > 0.5 && v > 0.27 : u < 0.5 && v < 0.73;
|
|
40
|
+
return !open && r <= R && r > R - Math.min(t * 0.6, 0.17);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The mark for resolved params. */
|
|
44
|
+
export function build(p) {
|
|
45
|
+
// an open ring faces left or right only: opening up it is the power sign
|
|
46
|
+
const n = p.grid, s = BOX.size / n, parts = [], q = p.curve === 'cee' ? (Number(p.facing) / 90) % 2 * 2 : Number(p.facing) / 90;
|
|
47
|
+
for (let r = 0; r < n; r++) {
|
|
48
|
+
let start = -1;
|
|
49
|
+
for (let c = 0; c <= n; c++) {
|
|
50
|
+
// the cell (r, c) seen from the facing: the grid turned by quarter turns
|
|
51
|
+
let u = (c + 0.5) / n, v = (r + 0.5) / n;
|
|
52
|
+
for (let k = 0; k < q; k++) [u, v] = [v, 1 - u];
|
|
53
|
+
const on = c < n && ink(p, u, v);
|
|
54
|
+
if (on && start < 0) start = c;
|
|
55
|
+
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; }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return parts.length ? U(...parts) : [];
|
|
59
|
+
}
|
|
@@ -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,59 @@
|
|
|
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 square at a turn, a Z, a pair of chevrons, one strip leaning on another, a
|
|
4
|
+
* fold, a bridge over two rails. Square-cut ends. Never level-and-upright strips crossed (a plus or a hash sign), never
|
|
5
|
+
* two strips crossed alone (an X), never three in a woven triangle (a known mark, and the recycling sign).
|
|
6
|
+
*/
|
|
7
|
+
import { U, I, bar, over, rot, circle, mapPts } from '@logomarks/core/geometry';
|
|
8
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
9
|
+
|
|
10
|
+
/** @type {import('../index.js').Control[]} */
|
|
11
|
+
export const controls = [
|
|
12
|
+
{ key: 'layout', label: 'Layout', type: 'choice', options: ['square', 'zed', 'lean', 'vee', 'fold', 'chevrons', 'bridge'], value: 'square' },
|
|
13
|
+
{ key: 'weight', label: 'Weight', type: 'range', min: 0.14, max: 0.26, step: 0.01, value: 0.2 },
|
|
14
|
+
{ key: 'angle', label: 'Angle', type: 'range', min: 12, max: 45, step: 1, value: 30 },
|
|
15
|
+
{ key: 'overhang', label: 'Overhang', type: 'range', min: 0, max: 0.16, step: 0.01, value: 0.08 },
|
|
16
|
+
{ key: 'spin', label: 'Spin', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
|
|
17
|
+
{ key: 'flip', label: 'Flip', type: 'toggle', value: false },
|
|
18
|
+
{ key: 'spacing', label: 'Gap', type: 'range', min: 0.8, max: 1.6, step: 0.1, value: 1 },
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
/** The strips of a layout as [from, to] pairs in the unit square, in laying order; `loop` when they close a ring. */
|
|
22
|
+
function plan(layout, turn) {
|
|
23
|
+
// the old woven diamond is the square at 45°; the old woven triangle is gone (a known mark): it draws the default
|
|
24
|
+
if (layout === 'diamond') { layout = 'square'; turn = 45; }
|
|
25
|
+
if (layout === 'triangle') layout = 'square';
|
|
26
|
+
if (layout === 'square') {
|
|
27
|
+
// a square of four strips turned off the level (never level: that is a hash sign once the ends run on)
|
|
28
|
+
const a = (Math.min(45, Math.max(12, turn)) * Math.PI) / 180, r = 0.4, pts = [0, 1, 2, 3].map((i) => [0.5 + r * Math.SQRT2 * Math.cos(a + Math.PI / 4 + (i * Math.PI) / 2) * 0.72, 0.5 + r * Math.SQRT2 * Math.sin(a + Math.PI / 4 + (i * Math.PI) / 2) * 0.72]);
|
|
29
|
+
return { segs: pts.map((q, i) => [q, pts[(i + 1) % 4]]), loop: true };
|
|
30
|
+
}
|
|
31
|
+
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] };
|
|
32
|
+
// lean: a short strip set against a long one, a third of the way down it
|
|
33
|
+
if (layout === 'lean') return { segs: [[[0.92, 0.92], [0.5, 0.4]], [[0.1, 0.94], [0.66, 0.06]]], ends: [0, 0], each: [[0, 1], [0, 0]] };
|
|
34
|
+
// vee: two strips hinged at the foot, one laid over the other and both running past the joint
|
|
35
|
+
if (layout === 'vee') return { segs: [[[0.12, 0.1], [0.56, 0.9]], [[0.92, 0.14], [0.4, 0.86]]], each: [[0, 1], [0, 1]] };
|
|
36
|
+
// fold: one tape turned back on itself, the upper length over the lower
|
|
37
|
+
if (layout === 'fold') return { segs: [[[0.22, 0.92], [0.86, 0.3]], [[0.08, 0.16], [0.86, 0.16]]], each: [[0, 1], [0, 1]] };
|
|
38
|
+
// bridge: two rails at a lean, one short strip laid across both
|
|
39
|
+
if (layout === 'bridge') return { segs: [[[0.06, 0.92], [0.4, 0.08]], [[0.6, 0.92], [0.94, 0.08]], [[0.1, 0.62], [0.9, 0.38]]], each: [[0, 0], [0, 0], [1, 1]] };
|
|
40
|
+
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]]], each: [[0, 0], [0, 0], [1, 1]] };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The mark for resolved params. */
|
|
44
|
+
export function build(p) {
|
|
45
|
+
const { x0, y0, size, cx, cy } = BOX, w = p.weight * size, g = GAP * p.spacing, e = p.overhang * size;
|
|
46
|
+
const { segs, loop, ends = [1, 1], each } = plan(p.layout, p.angle ?? 30);
|
|
47
|
+
// two strips alone are light at a weight that suits four: they take a third more
|
|
48
|
+
const wide = segs.length === 2 ? 1.4 : 1;
|
|
49
|
+
const pt = ([x, y]) => [x0 + x * size, y0 + y * size];
|
|
50
|
+
// a strip from a to b, run on past each end by the overhang where its ends say (like tape past a joint)
|
|
51
|
+
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 * wide); };
|
|
52
|
+
const all = segs.map((sg, i) => strip(sg, each ? each[i] : ends));
|
|
53
|
+
let s = all[0];
|
|
54
|
+
for (const b of all.slice(1)) s = over(s, b, g);
|
|
55
|
+
// a closed ring is woven: the first strip passes back over the last at the corner they share
|
|
56
|
+
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); }
|
|
57
|
+
if (p.flip) s = mapPts(s, ([x, y]) => [2 * cx - x, y]);
|
|
58
|
+
return tidy(rot(s, Number(p.spin), cx, cy));
|
|
59
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trine: one solid with three slits that run in past the centre, never to it and never to each other, so the body
|
|
3
|
+
* stays whole and turns like a rotor. The slits are of unlike depth by default. Three cuts that meet leave a triangle in
|
|
4
|
+
* the middle, which is a play button or a camera shutter, and three through the centre are a known badge: these stop
|
|
5
|
+
* short by design.
|
|
6
|
+
*/
|
|
7
|
+
import { D, circle, regular, squircle, bar } from '@logomarks/core/geometry';
|
|
8
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
9
|
+
|
|
10
|
+
/** @type {import('../index.js').Control[]} */
|
|
11
|
+
export const controls = [
|
|
12
|
+
{ key: 'body', label: 'Body', type: 'choice', options: ['disc', 'hexagon', 'square', 'triangle'], value: 'disc' },
|
|
13
|
+
{ key: 'offset', label: 'Past the centre', type: 'range', min: 0.16, max: 0.5, step: 0.01, value: 0.3 },
|
|
14
|
+
{ key: 'depth', label: 'Depth', type: 'range', min: 0.45, max: 0.9, step: 0.01, value: 0.8 },
|
|
15
|
+
{ key: 'even', label: 'Even slits', type: 'toggle', value: false },
|
|
16
|
+
{ key: 'spacing', label: 'Slit', type: 'range', min: 1, max: 2.6, step: 0.1, value: 1.6 },
|
|
17
|
+
{ key: 'spin', label: 'Spin', type: 'range', min: 0, max: 120, step: 1, value: 0 },
|
|
18
|
+
{ key: 'hand', label: 'Hand', type: 'choice', options: ['right', 'left'], value: 'right' },
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
/** The mark for resolved params. */
|
|
22
|
+
export function build(p) {
|
|
23
|
+
const { cx, cy, size } = BOX, R = size / 2, g = GAP * p.spacing;
|
|
24
|
+
const body = p.body === 'hexagon' ? regular(cx, cy, R, 6, -90) : p.body === 'triangle' ? regular(cx, cy + R * 0.14, R * 1.16, 3, -90) : p.body === 'square' ? squircle(cx, cy, R, 5) : circle(cx, cy, R, 128);
|
|
25
|
+
// slit i lies along a line that passes the centre at distance o; it comes in from outside the body and stops short
|
|
26
|
+
// of where the next slit's line crosses it, by a share of that run (its depth) and never nearer than a gap and a half
|
|
27
|
+
const o = p.offset * R, k = p.hand === 'left' ? -1 : 1, base = (p.body === 'triangle' ? 30 : 0) + p.spin, meet = o * Math.sqrt(3);
|
|
28
|
+
const depths = p.even ? [1, 1, 1] : [1, 0.74, 0.5];
|
|
29
|
+
const slits = [];
|
|
30
|
+
for (let i = 0; i < 3; i++) {
|
|
31
|
+
const a = ((base + 120 * i) * Math.PI) / 180, n = [Math.cos(a), Math.sin(a)], t = [-n[1] * k, n[0] * k];
|
|
32
|
+
const foot = [cx + n[0] * o, cy + n[1] * o], reach = Math.sqrt(Math.max(0, R * R - o * o));
|
|
33
|
+
// from the edge (at −reach along the line) to the end: a share of the way to the crossing, less the bridge
|
|
34
|
+
const end = -reach + (reach + meet - g * 1.6) * (p.depth ?? 0.8) * depths[i];
|
|
35
|
+
slits.push(bar([foot[0] - t[0] * R * 3, foot[1] - t[1] * R * 3], [foot[0] + t[0] * end, foot[1] + t[1] * end], g));
|
|
36
|
+
}
|
|
37
|
+
return tidy(D(body, ...slits));
|
|
38
|
+
}
|
|
@@ -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
|
+
}
|