@logomarks/generate 0.2.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 +22 -0
- package/package.json +1 -1
- package/src/generate.js +1 -1
- package/src/presets.js +1 -1
- package/src/recipes/halfsq.js +35 -39
- package/src/recipes/index.js +4 -4
- package/src/recipes/lobes.js +37 -17
- package/src/recipes/pixelarc.js +26 -18
- package/src/recipes/strips.js +32 -12
- package/src/recipes/trine.js +24 -23
- package/src/tuning.js +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.1 (2026-11-26)
|
|
4
|
+
|
|
5
|
+
Five recipes reworked from sheets of their shuffles (ids and count unchanged, 40; settings saved from 0.2.0 still draw):
|
|
6
|
+
|
|
7
|
+
- `halfsq`: the cells stay a house gap apart and follow ONE rule (`rule`: rows turned about, all the same, a checker
|
|
8
|
+
with whole squares, a zigzag, a diagonal; `facing`; `grid` as '2x2', '3x2', '2x3', '3x3'). Merged into one solid they
|
|
9
|
+
fell into arrows, crowns, houses and envelopes: every one-solid arrangement on 2 × 2 and 3 × 2 was drawn and looked at.
|
|
10
|
+
A shuffle stays on 2 × 2 (a triangle's tips are thin on a finer grid).
|
|
11
|
+
- `lobes` (Soft): a soft block (pebble, disc or soft square) parted into two to four pebbles of unlike size by curved
|
|
12
|
+
gaps, every corner rounded (`body`, `pieces`, `cuts`, `bend`, `balance`, `angle`, `soften`). The lobed solid with a
|
|
13
|
+
round hole was a cog, the settings icon. A shuffle draws two or three pieces by the tee cut (parallel slices read as
|
|
14
|
+
sound waves, four pieces as a cross of gaps).
|
|
15
|
+
- `strips`: the woven triangle is gone (a known mark, and the recycling sign); the woven square turns between 12° and
|
|
16
|
+
45° (`angle`), and one strip leans on another (`lean`), two hinge at the foot (`vee`) or one folds back (`fold`);
|
|
17
|
+
`flip`. The bridge over two rails (a not-equal sign) and the chevrons (the chevrons recipe's) are by hand only.
|
|
18
|
+
- `trine`: three slits that pass the centre and stop short of each other, of unlike depth by default (`depth`, `even`),
|
|
19
|
+
so the body stays whole and there is no triangle in the middle (a play button, a camera shutter); a soft square body.
|
|
20
|
+
The preset Shutter is now Rotor.
|
|
21
|
+
- `pixelarc`: new figures, `twin` (two stepped arcs back to back, the default), `wave`, `cee` (an open ring, facing
|
|
22
|
+
left or right only: opening up it is the power sign) and `spiral`; one band only. A shuffle draws twin, wave, hook or arch; the
|
|
23
|
+
open ring (on a coarse grid its hole is a plus), the S and the spiral are by hand.
|
|
24
|
+
|
|
3
25
|
## 0.2.0 (2026-11-26)
|
|
4
26
|
|
|
5
27
|
Everything below came after 0.1.0 went to npm the same day: the quality pass (nine recipes removed, tuned shuffles,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logomarks/generate",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Abstract logomarks from rules and controls, no AI: 34 recipes (bars, bands, twin, stack, shear, turns, burst, tiles, route, arcs, rings, stripes, dots, pixel, chevrons, waves, cut, split, venn, blobs, dashes, fan, fold, spiral, orbit, bloom, links, horizon, steps, hex, tri, iso, line, letter) that each list their controls and draw a mark from them and a seed, fitted to the Logomarks standard (512 canvas, 448 fit, the house gap), a shared finish (rounding, outline, an accent dot, a container), two-colour pieces, seeded variations and presets. Runs in the browser and in Node.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
package/src/generate.js
CHANGED
|
@@ -249,7 +249,7 @@ export function similar(id, params, { count = 12, seed = 1, amount = 0.15, locke
|
|
|
249
249
|
* How often each recipe comes up in `mix()`, relative to 1: the ones whose shuffles most often give a mark worth
|
|
250
250
|
* keeping lead; the textured ones (iso, hex, tiles) come up less.
|
|
251
251
|
*/
|
|
252
|
-
export const MIX_WEIGHT = { twin: 1.6, cut: 1.6, split: 1.4, chevrons: 1.3, spiral: 1.2, links: 1.2, arcs: 1.2, bands: 1.2, stripes: 1.2, rings: 0.8, turns: 1.1, bloom: 1, burst: 1, bars: 1, waves: 0.9, stack: 0.8, steps: 0.8, letter: 0.8, shear: 0.6, venn: 0.5, route: 0.5, horizon: 0.5, tiles: 0.6, hex: 0.5, iso: 0.5, arcstep: 1.4, leaves: 1.3, seam: 1.3, trine: 1.
|
|
252
|
+
export const MIX_WEIGHT = { twin: 1.6, cut: 1.6, split: 1.4, chevrons: 1.3, spiral: 1.2, links: 1.2, arcs: 1.2, bands: 1.2, stripes: 1.2, rings: 0.8, turns: 1.1, bloom: 1, burst: 1, bars: 1, waves: 0.9, stack: 0.8, steps: 0.8, letter: 0.8, shear: 0.6, venn: 0.5, route: 0.5, horizon: 0.5, tiles: 0.6, hex: 0.5, iso: 0.5, arcstep: 1.4, leaves: 1.3, seam: 1.3, trine: 1.1, blades: 1.1, invert: 1, wavecut: 1, capsules: 1, bite: 0.9, loops: 0.8, strips: 0.7, flare: 0.8, lobes: 0.9, halfsq: 0.8, pixelarc: 0.4 };
|
|
253
253
|
|
|
254
254
|
/**
|
|
255
255
|
* `count` marks from ANY recipe: each slot picks a recipe by its seed (from `ids`, every recipe by default, weighted by
|
package/src/presets.js
CHANGED
|
@@ -32,6 +32,6 @@ export const PRESETS = [
|
|
|
32
32
|
{ id: 'arc-step', name: 'Arc step', recipe: 'arcstep', params: { layout: 'stair', steps: 1, weight: 0.8, corners: 'round' }, note: 'One heavy band through two quarter arcs.' },
|
|
33
33
|
{ id: 'leaf-tiles', name: 'Leaf tiles', recipe: 'leaves', params: { tile: 'leaf', order: 'outward' }, note: 'Four leaves, their points to the middle.' },
|
|
34
34
|
{ id: 'tenon-block', name: 'Tenon block', recipe: 'seam', params: { joint: 'tenon', body: 'square' }, note: 'A block in two halves, joined by a tenon.' },
|
|
35
|
-
{ id: 'shutter', name: '
|
|
35
|
+
{ id: 'shutter', name: 'Rotor', recipe: 'trine', params: { body: 'disc', offset: 0.3, depth: 0.8 }, note: 'A disc with three slits of unlike depth that pass the centre and stop short.' },
|
|
36
36
|
{ id: 'blade-sweep', name: 'Blade sweep', recipe: 'blades', params: { count: 3, grow: 0.5, width: 1.6 }, note: 'Three blades, each taller than the last.' },
|
|
37
37
|
];
|
package/src/recipes/halfsq.js
CHANGED
|
@@ -1,53 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Half Square: a small grid of
|
|
3
|
-
*
|
|
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.
|
|
4
6
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import { BOX, GAP
|
|
7
|
-
import { rng } from '../random.js';
|
|
7
|
+
import { rect, poly } from '@logomarks/core/geometry';
|
|
8
|
+
import { BOX, GAP } from '../draw.js';
|
|
8
9
|
|
|
9
10
|
/** @type {import('../index.js').Control[]} */
|
|
10
11
|
export const controls = [
|
|
11
|
-
{ key: 'grid', label: 'Grid', type: '
|
|
12
|
-
{ key: '
|
|
13
|
-
{ key: '
|
|
14
|
-
{ key: '
|
|
15
|
-
{ key: 'parted', label: 'Parted', type: 'toggle', value: false },
|
|
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
16
|
];
|
|
17
17
|
|
|
18
|
-
/** A cell: 'full', or a half square keeping corner 0
|
|
19
|
-
function cell(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
23
37
|
}
|
|
24
38
|
|
|
25
39
|
/** The mark for resolved params. */
|
|
26
40
|
export function build(p) {
|
|
27
|
-
const
|
|
28
|
-
const
|
|
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
|
-
}
|
|
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;
|
|
46
43
|
const parts = [];
|
|
47
|
-
for (let r = 0; r <
|
|
48
|
-
const k =
|
|
49
|
-
if (k
|
|
50
|
-
parts.push(cell(k, BOX.x0 + c * s + g, BOX.y0 + r * s + g, s - 2 * g));
|
|
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));
|
|
51
47
|
}
|
|
52
|
-
return parts
|
|
48
|
+
return parts;
|
|
53
49
|
}
|
package/src/recipes/index.js
CHANGED
|
@@ -78,18 +78,18 @@ export const RECIPES = {
|
|
|
78
78
|
iso: R('iso', 'Iso', 'Isometric cubes stacked from a height map.', iso),
|
|
79
79
|
letter: R('letter', 'Letter', 'One capital or numeral in blocks, tiles, pixels, stencil, slabs or route.', letter),
|
|
80
80
|
arcstep: R('arcstep', 'Arc Step', 'One heavy band that steps and turns through quarter arcs.', arcstep),
|
|
81
|
-
halfsq: R('halfsq', 'Halves', '
|
|
81
|
+
halfsq: R('halfsq', 'Halves', 'Half squares and squares set by one rule, a gap between each.', halfsq),
|
|
82
82
|
invert: R('invert', 'Inverted', 'Rings with ink and ground swapped across one region.', invert),
|
|
83
83
|
leaves: R('leaves', 'Leaf Tiles', 'One soft tile in each corner, turned from cell to cell.', leaves),
|
|
84
|
-
lobes: R('lobes', 'Soft', '
|
|
84
|
+
lobes: R('lobes', 'Soft', 'A soft block parted into pebbles of unlike size.', lobes),
|
|
85
85
|
loops: R('loops', 'Loops', 'Rings merged into one heavy flower outline.', loops),
|
|
86
|
-
trine: R('trine', 'Trine', 'A solid
|
|
86
|
+
trine: R('trine', 'Trine', 'A solid with three slits that pass the centre and stop short.', trine),
|
|
87
87
|
strips: R('strips', 'Strips', 'Straight strips of tape laid over one another.', strips),
|
|
88
88
|
bite: R('bite', 'Bite Link', 'A soft block with round bites taken from its sides.', bite),
|
|
89
89
|
blades: R('blades', 'Blades', 'Curved blades side by side, each taller than the last.', blades),
|
|
90
90
|
wavecut: R('wavecut', 'Squiggle', 'A solid cut or worn by one wavy line.', wavecut),
|
|
91
91
|
capsules: R('capsules', 'Capsule', 'Slanted capsules stacked, their lengths set by one rule.', capsules),
|
|
92
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
|
|
93
|
+
pixelarc: R('pixelarc', 'Pixel', 'One bold figure drawn in square pixels.', pixelarc),
|
|
94
94
|
seam: R('seam', 'Seam', 'A block parted in two by one seam with a joint in it.', seam),
|
|
95
95
|
};
|
package/src/recipes/lobes.js
CHANGED
|
@@ -1,28 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Soft Pieces: one soft
|
|
3
|
-
* corner
|
|
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.
|
|
4
5
|
*/
|
|
5
|
-
import { D, poly, circle, closedCurve } from '@logomarks/core/geometry';
|
|
6
|
-
import { BOX } from '../draw.js';
|
|
6
|
+
import { D, I, U, poly, circle, squircle, closedCurve, grow, rot } from '@logomarks/core/geometry';
|
|
7
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
7
8
|
|
|
8
9
|
/** @type {import('../index.js').Control[]} */
|
|
9
10
|
export const controls = [
|
|
10
|
-
{ key: '
|
|
11
|
-
{ key: '
|
|
12
|
-
{ key: '
|
|
13
|
-
{ key: '
|
|
14
|
-
{ key: '
|
|
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 },
|
|
15
19
|
];
|
|
16
20
|
|
|
17
|
-
/**
|
|
18
|
-
const
|
|
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] };
|
|
19
23
|
|
|
20
24
|
/** The mark for resolved params. */
|
|
21
25
|
export function build(p) {
|
|
22
|
-
const R =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return
|
|
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 });
|
|
28
48
|
}
|
package/src/recipes/pixelarc.js
CHANGED
|
@@ -1,33 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Pixel Curve: one bold
|
|
3
|
-
*
|
|
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.
|
|
4
5
|
*/
|
|
5
6
|
import { U, rect } from '@logomarks/core/geometry';
|
|
6
7
|
import { BOX } from '../draw.js';
|
|
7
8
|
|
|
8
9
|
/** @type {import('../index.js').Control[]} */
|
|
9
10
|
export const controls = [
|
|
10
|
-
{ key: '
|
|
11
|
-
{ key: '
|
|
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' },
|
|
12
13
|
{ 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
14
|
{ key: 'facing', label: 'Facing', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
|
|
15
15
|
];
|
|
16
16
|
|
|
17
17
|
/** Whether the point (u, v) of the unit square (v down) is ink. */
|
|
18
18
|
function ink(p, u, v) {
|
|
19
|
-
const t = p.weight,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
if (p.curve === '
|
|
28
|
-
// a
|
|
29
|
-
|
|
30
|
-
|
|
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
|
|
31
38
|
const top = v < 0.5, r = Math.hypot(u - 0.5, v - (top ? 0.27 : 0.73)), R = 0.27;
|
|
32
39
|
const open = top ? u > 0.5 && v > 0.27 : u < 0.5 && v < 0.73;
|
|
33
40
|
return !open && r <= R && r > R - Math.min(t * 0.6, 0.17);
|
|
@@ -35,7 +42,8 @@ function ink(p, u, v) {
|
|
|
35
42
|
|
|
36
43
|
/** The mark for resolved params. */
|
|
37
44
|
export function build(p) {
|
|
38
|
-
|
|
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;
|
|
39
47
|
for (let r = 0; r < n; r++) {
|
|
40
48
|
let start = -1;
|
|
41
49
|
for (let c = 0; c <= n; c++) {
|
package/src/recipes/strips.js
CHANGED
|
@@ -1,39 +1,59 @@
|
|
|
1
1
|
/**
|
|
2
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
|
|
4
|
-
* ends
|
|
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).
|
|
5
6
|
*/
|
|
6
|
-
import { U, I, bar, over, rot, circle } from '@logomarks/core/geometry';
|
|
7
|
+
import { U, I, bar, over, rot, circle, mapPts } from '@logomarks/core/geometry';
|
|
7
8
|
import { BOX, GAP, tidy } from '../draw.js';
|
|
8
9
|
|
|
9
10
|
/** @type {import('../index.js').Control[]} */
|
|
10
11
|
export const controls = [
|
|
11
|
-
{ key: 'layout', label: 'Layout', type: 'choice', options: ['
|
|
12
|
+
{ key: 'layout', label: 'Layout', type: 'choice', options: ['square', 'zed', 'lean', 'vee', 'fold', 'chevrons', 'bridge'], value: 'square' },
|
|
12
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 },
|
|
13
15
|
{ key: 'overhang', label: 'Overhang', type: 'range', min: 0, max: 0.16, step: 0.01, value: 0.08 },
|
|
14
16
|
{ key: 'spin', label: 'Spin', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
|
|
17
|
+
{ key: 'flip', label: 'Flip', type: 'toggle', value: false },
|
|
15
18
|
{ key: 'spacing', label: 'Gap', type: 'range', min: 0.8, max: 1.6, step: 0.1, value: 1 },
|
|
16
19
|
];
|
|
17
20
|
|
|
18
21
|
/** 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
|
-
|
|
21
|
-
if (layout === 'diamond') {
|
|
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
|
+
}
|
|
22
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] };
|
|
23
|
-
|
|
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]] };
|
|
24
41
|
}
|
|
25
42
|
|
|
26
43
|
/** The mark for resolved params. */
|
|
27
44
|
export function build(p) {
|
|
28
45
|
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],
|
|
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;
|
|
30
49
|
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
|
|
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,
|
|
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));
|
|
34
53
|
let s = all[0];
|
|
35
54
|
for (const b of all.slice(1)) s = over(s, b, g);
|
|
36
55
|
// a closed ring is woven: the first strip passes back over the last at the corner they share
|
|
37
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]);
|
|
38
58
|
return tidy(rot(s, Number(p.spin), cx, cy));
|
|
39
59
|
}
|
package/src/recipes/trine.js
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Trine: one solid
|
|
3
|
-
*
|
|
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.
|
|
4
6
|
*/
|
|
5
|
-
import { D,
|
|
7
|
+
import { D, circle, regular, squircle, bar } from '@logomarks/core/geometry';
|
|
6
8
|
import { BOX, GAP, tidy } from '../draw.js';
|
|
7
9
|
|
|
8
10
|
/** @type {import('../index.js').Control[]} */
|
|
9
11
|
export const controls = [
|
|
10
|
-
{ key: 'body', label: 'Body', type: 'choice', options: ['disc', 'hexagon', '
|
|
11
|
-
{ key: 'offset', label: 'Past the centre', type: 'range', min: 0.
|
|
12
|
-
{ key: '
|
|
13
|
-
{ key: '
|
|
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 },
|
|
14
17
|
{ key: 'spin', label: 'Spin', type: 'range', min: 0, max: 120, step: 1, value: 0 },
|
|
15
18
|
{ key: 'hand', label: 'Hand', type: 'choice', options: ['right', 'left'], value: 'right' },
|
|
16
19
|
];
|
|
17
20
|
|
|
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
21
|
/** The mark for resolved params. */
|
|
26
22
|
export function build(p) {
|
|
27
23
|
const { cx, cy, size } = BOX, R = size / 2, g = GAP * p.spacing;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
for (let i = 0; i < 3; i++)
|
|
35
|
-
|
|
36
|
-
|
|
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));
|
|
37
38
|
}
|
package/src/tuning.js
CHANGED
|
@@ -35,20 +35,20 @@ export const TUNING = {
|
|
|
35
35
|
iso: { grid: R(2, 3), height: R(1, 2), density: R(0.5, 1) },
|
|
36
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
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:
|
|
38
|
+
halfsq: { grid: of('2x2'), rule: of('rows', 'same', 'checker', 'zigzag', 'diagonal'), spacing: R(1, 1.3) },
|
|
39
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
40
|
leaves: { softness: rare(0.3, 0.6, 1), spacing: rare(0.3, 0.8, 1.6), centre: { rare: 0.2 } },
|
|
41
|
-
lobes: {
|
|
41
|
+
lobes: { body: of('pebble', 'disc', 'square'), pieces: R(2, 3), cuts: of('tee'), bend: R(0.35, 0.95), balance: R(-0.1, 0.14), angle: R(0, 345), soften: R(0.5, 0.9), spacing: R(1, 1.4) },
|
|
42
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.
|
|
44
|
-
strips: { layout: of('
|
|
43
|
+
trine: { body: of('disc', 'disc', 'hexagon', 'square'), offset: R(0.24, 0.42), depth: R(0.66, 0.88), even: { rare: 0.25 }, spacing: R(1.3, 2), spin: rare(0.5, 0, 120) },
|
|
44
|
+
strips: { layout: of('square', 'square', 'zed', 'lean', 'vee'), weight: R(0.17, 0.24), angle: R(14, 45), overhang: R(0.04, 0.12), spacing: R(0.9, 1.3), flip: { rare: 0.5 } },
|
|
45
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
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
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
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
49
|
flare: { rays: R(3, 5), inner: R(0.16, 0.3), spacing: R(1.2, 2), body: of('square', 'square', 'round') },
|
|
50
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('
|
|
51
|
+
pixelarc: { curve: of('twin', 'twin', 'wave', 'wave', 'hook', 'arch'), grid: R(7, 10), weight: R(0.24, 0.42) },
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
/** The two to four controls of each recipe that decide the mark: a page shows these first, the rest under "More". */
|
|
@@ -60,8 +60,8 @@ export const MAIN = {
|
|
|
60
60
|
venn: ['count', 'shape', 'layout', 'combine'], spiral: ['turns', 'weight', 'start'], bloom: ['petals', 'petal', 'width', 'centre'], links: ['count', 'loop', 'layout', 'weight'],
|
|
61
61
|
horizon: ['sun', 'size', 'lines', 'style'], steps: ['count', 'shape', 'tread'], hex: ['layout', 'density', 'symmetry'],
|
|
62
62
|
iso: ['grid', 'layout', 'height'], letter: ['char', 'build', 'weight'],
|
|
63
|
-
arcstep: ['layout', 'steps', 'weight', 'corners'], halfsq: ['
|
|
64
|
-
lobes: ['
|
|
65
|
-
strips: ['layout', 'weight', '
|
|
66
|
-
wavecut: ['body', 'move', 'waves', 'swell'], capsules: ['count', 'lengths', 'lean'], flare: ['origin', 'rays', 'body'], seam: ['joint', 'body', 'size', 'reach'], pixelarc: ['curve', 'grid', 'weight', '
|
|
63
|
+
arcstep: ['layout', 'steps', 'weight', 'corners'], halfsq: ['grid', 'rule', 'facing'], invert: ['count', 'weight', 'region', 'angle'], leaves: ['tile', 'order', 'facing'],
|
|
64
|
+
lobes: ['body', 'pieces', 'cuts', 'bend'], loops: ['petals', 'weight', 'spread', 'centre'], trine: ['body', 'offset', 'depth'],
|
|
65
|
+
strips: ['layout', 'weight', 'angle'], 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', 'facing'],
|
|
67
67
|
};
|