@logomarks/generate 0.4.2 → 0.6.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 +55 -0
- package/README.md +74 -4
- package/package.json +1 -1
- package/src/finish.js +18 -10
- package/src/generate.js +98 -1
- package/src/index.d.ts +33 -2
- package/src/index.js +2 -1
- package/src/presets.js +14 -0
- package/src/raster.js +1 -1
- package/src/recipes/bubble.js +90 -0
- package/src/recipes/check.js +77 -0
- package/src/recipes/clash.js +13 -0
- package/src/recipes/cloud.js +98 -0
- package/src/recipes/crossover.js +14 -0
- package/src/recipes/duo.js +395 -0
- package/src/recipes/index.js +20 -0
- package/src/recipes/layers.js +66 -0
- package/src/recipes/letter.js +2 -2
- package/src/recipes/peak.js +91 -0
- package/src/recipes/splitchar.js +14 -0
- package/src/recipes/tucked.js +17 -0
- package/src/tuning.js +31 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
|
|
5
|
+
## 0.6.0 (2026-11-28)
|
|
6
|
+
|
|
7
|
+
Contrast monograms, after the owner's idea of initials treated unlike on purpose (one boxed, one open; each in a ring;
|
|
8
|
+
a sans beside a serif; a letter turned and locked into the other). Five recipes (65 in all), a page maker, and bans.
|
|
9
|
+
|
|
10
|
+
- **`duo`** (Duo): two (or three) initials in unlike treatments: `boxed` (a letter knocked out of a box beside an open
|
|
11
|
+
one), `rings` (each in a circle, apart or overlapping; round letters take rounded squares, two O's in rings being a
|
|
12
|
+
pair of eyes), `cells` (one container split by the gap, a cell filled with its letter knocked out, the next open) and
|
|
13
|
+
`turned` (one or both letters turned a quarter or half turn or mirrored, drawn extended, and nested by a raster search
|
|
14
|
+
so their strokes lock together a gap apart, after the owner's turned F and P). Each side has a build (`sans`, `serif`,
|
|
15
|
+
`blackletter` from core, or the Letter recipe's stencil, route, cut, wedge, blocks, rails, tiles) and a treatment
|
|
16
|
+
(`solid`, `knockout`, `outline`); a knocked-out letter is always a heavy build. The container control is `box` (the
|
|
17
|
+
finish already has a `container`).
|
|
18
|
+
- **`crossover`** (Crossover): A solid running into B's block, ink outside it and cut out inside; the block's edge
|
|
19
|
+
moves until 68% of A's ink is outside, so no stroke is lost to the gap.
|
|
20
|
+
- **`tucked`** (Tucked): a big letter with one or two small ones boxed at its corner.
|
|
21
|
+
- **`clash`** (Type Clash): the letters side by side in unlike builds, apart or interlocked (eased back until the later
|
|
22
|
+
letter keeps 90% of its ink; a T or an I never interlocks).
|
|
23
|
+
- **`splitchar`** (Split Letter): one character cut upright, level or diagonally, the second half cut out of its box or
|
|
24
|
+
drawn in another build (an H never in a disc, a P never in a square). A letter of slanted strokes (A, V, W, Y, K, X,
|
|
25
|
+
M, N, 4) is never split upright: the half body and the slanted stroke running out of it read as a pistol.
|
|
26
|
+
- **`monograms(initials, { count, seed })`**: a page of them from typed initials (upper-cased, A–Z and 0–9 kept, at most
|
|
27
|
+
three): every way of contrasting tried a few times (`monogramPlans()`), failed draws and near-twins dropped, ranked by
|
|
28
|
+
`qualityOf`, no way allowed to crowd the page, the order alternating them. `initialsOf()` cleans the input.
|
|
29
|
+
Three initials keep only marks scoring 0.6 or more (the pair layouts squeezed to three look cramped), so their page
|
|
30
|
+
is shorter and mostly Tucked, which is tried more often for them.
|
|
31
|
+
- **Bans:** `BLOCKED`/`blocked()`: other companies' monogram logos (LV, CC, GG, DG, YSL, VW, HP, GE, MK, CK, HM, DC, NY,
|
|
32
|
+
LA, IBM, BMW, KFC) and hate codes (SS, HH, KKK, 88) draw nothing. `BECOMES`/`safeTurn()`: a turn that makes a letter
|
|
33
|
+
another letter (M↔W, N↔Z, 6↔9, L↔7; A, V, Y on their side are arrowheads, a J upside down a padlock's shackle)
|
|
34
|
+
moves on to one that doesn't. A turned pair keeps no detached crumb (under 6% of the ink), and one left with a small
|
|
35
|
+
piece (under 30% of the mark across) isn't drawn: a small square in an M's crotch over a J's bowl is a face. A J on its side is a C or a U, so it stays upright. Two T's, two L's or an X never turn and nest.
|
|
36
|
+
- **Reads after a turn:** each turned letter is read as what it now looks like (`LOOKS`, `readsOf()`: a P or a D on its
|
|
37
|
+
side a U, a C a U, an N a Z, an M upside down a W, an E on its side an M or a W…, and still itself: nested, an F on
|
|
38
|
+
its side with a P's stem makes an F again), and a pair that reads, in either
|
|
39
|
+
order, as blocked initials or a rude read isn't drawn (`readsBlocked()`): F (upright or turned) with a P on its side is FU. `RUDE` (FU,
|
|
40
|
+
FK, FCK, FUK, FFS, WTF, STFU, GTFO, KYS, FML, BS, SOB, ASS, slurs, XXX, 1488…) is blocked as typed initials too, like
|
|
41
|
+
`BLOCKED`. The owner's F/P reference stays: the P upside down (its half turn is allowed) with its bowl against the F's
|
|
42
|
+
bars, the preset 'Turned pair'.
|
|
43
|
+
- Tuning, main controls, no turns, mix weights and five presets (60 in all) for the new recipes. `letter.js` exports its
|
|
44
|
+
`skeleton()` and `CHARS`; `raster.js` its `morph()`.
|
|
45
|
+
|
|
46
|
+
## 0.5.0 (2026-11-28)
|
|
47
|
+
|
|
48
|
+
- **Five recipes after the commonest tech-brand marks** (the owner's audit of 623 tech-brand icons): `cloud`, `layers`,
|
|
49
|
+
`bubble`, `check` and `peak` (the letter A as a peak), 60 in all. Each makes one construction move, never the plain
|
|
50
|
+
icon, with its bad reads ruled out in the build: no rain, bolt or sun in a cloud; no level bars in layers; no eyes,
|
|
51
|
+
three dots, lines of text or a magnifier in a bubble; no checkbox or verified disc for a tick; no caret, arrow stem or
|
|
52
|
+
rounded apex for an A. The defaults and 200 shuffles of each stay under 0.72 against the brands' own icons by the house
|
|
53
|
+
outline measure (cloud 0.717, layers 0.699, bubble 0.711, check 0.622, peak 0.632); stacks of rhombus plates, a disc
|
|
54
|
+
pair of bubbles, a rounded or wide A and a slab-cut tick were steered off because they crowded a brand.
|
|
55
|
+
- **A speech-bubble container**: `container: 'bubble'` in the finish, as a badge, a clip or a frame.
|
|
56
|
+
- `TUNING`, `MAIN`, `TURNS` (a cloud, a bubble, an A and layers mirror only; a tick never turns), `HOLD` (each new
|
|
57
|
+
recipe's move, and the bubble's body) and `MIX_WEIGHT` for the five; eight presets (55).
|
|
58
|
+
|
|
4
59
|
## 0.4.2 (2026-11-27)
|
|
5
60
|
|
|
6
61
|
- **Mirror:** four-way emblems are now most of a shuffle (34 of 47, from 16): `shuffled()` holds a recipe's `HOLD` keys
|
package/README.md
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
# @logomarks/generate
|
|
2
2
|
|
|
3
|
-
Abstract logomarks from rules and controls, no AI. Each recipe is one construction (
|
|
3
|
+
Abstract logomarks from rules and controls, no AI. Each recipe is one construction (65 of them: bars, bands, twin,
|
|
4
4
|
stack, shear, turns, burst, tiles, route, arcs, rings, stripes, chevrons, waves, cut, split, spiral, bloom, links,
|
|
5
5
|
horizon, steps, hex, iso and letter; fourteen after live house families: arcstep, halfsq, invert, leaves, lobes, loops,
|
|
6
6
|
trine, strips, bite, blades, wavecut, capsules, flare, seam; and seven that combine unlike shapes: merge, overlap,
|
|
7
|
-
counter, pair, corners, offset, quarters
|
|
7
|
+
counter, pair, corners, offset, quarters; ten after the owner's reference logos: mosaic, weave, notch, nodes, xband,
|
|
8
|
+
mirror, ribbon, field, zigzag, halfstripe; five after the commonest tech-brand marks: cloud, layers, bubble, check,
|
|
9
|
+
peak; and five contrast monograms from initials: duo, crossover, tucked, clash, splitchar) that lists its controls
|
|
8
10
|
and draws a mark from them, fitted to the Logomarks standard: a 512 canvas, the longest side 448, centred,
|
|
9
11
|
`currentColor`, the house gap. Every recipe also takes the finish controls (turn, mirror, round corners, outline, an
|
|
10
|
-
accent dot, a container: badge or
|
|
12
|
+
accent dot, a container: a circle, square, rounded square, hexagon or speech bubble, as a badge, a clip or a frame). Each mark comes with its `pieces`, and `svgOf()` draws them in two colours. A
|
|
11
13
|
quality guard skips draws with specks, slivers, thin necks, hairline holes, a bare primitive or too little ink. Runs in
|
|
12
14
|
the browser and in Node.
|
|
13
15
|
|
|
@@ -39,7 +41,7 @@ const badge = generate('letter', { char: 'K', build: 'slabs', container: 'circle
|
|
|
39
41
|
const twoTone = svgOf(mark.pieces, { colors: ['#0b0b0b', '#c8ff00'], pattern: 'rows' });
|
|
40
42
|
```
|
|
41
43
|
|
|
42
|
-
`PRESETS` lists
|
|
44
|
+
`PRESETS` lists 55 one-click starting points. `RECIPES[id].controls` describes every control (range, choice or toggle) so a UI can build its sliders from it.
|
|
43
45
|
|
|
44
46
|
## Playground
|
|
45
47
|
|
|
@@ -116,3 +118,71 @@ and off the axes); `chevrons` takes `body: 'hexagon'` and `soft` (round corners
|
|
|
116
118
|
be 1, a soft A); `route` takes `body: 'cube'` (an iso cube, its three faces engraved with short tracks ending in a
|
|
117
119
|
node); `letter` takes five more builds, `wedge`, `cut`, `rails`, `hexfold` and `quarter`; the finish takes
|
|
118
120
|
`containerMode: 'frame'` (the container as a heavy ring, the mark whole inside) and `accentShape: 'square'`.
|
|
121
|
+
|
|
122
|
+
## The tech-brand styles (0.5.0)
|
|
123
|
+
|
|
124
|
+
Five recipes after the archetypes the owner's audit of 623 tech-brand icons found thin or missing in the set
|
|
125
|
+
(`tools/logomarks/review/handoffs/tech-brands-audit.md` in the site repo). Every one makes a construction move; none
|
|
126
|
+
draws the plain icon, and none copies a brand: the default and 200 shuffles of each score under 0.72 against the brands'
|
|
127
|
+
own icons for that archetype by the house outline measure (cloud 0.717, layers 0.699, bubble 0.711, check 0.622,
|
|
128
|
+
peak 0.632).
|
|
129
|
+
|
|
130
|
+
- `cloud`: two to five round puffs on a flat or round base, with one move: lifted off a strip of its base by a gap
|
|
131
|
+
(`bands`), split by one slanted gap, a slot run in from one end, a heavy outline broken once, or stacked over a smaller
|
|
132
|
+
cloud. Never rain, a bolt or a sun (nothing under or behind it; no piece a whole disc). A plain cloud is by hand only.
|
|
133
|
+
- `layers`: two to four plates (rhombus, rounded, chevron or a slab with a thickness) stacked with the gap between,
|
|
134
|
+
apart, stepped aside or tapered. Never level bars (a menu icon). Plain flat plates stacked straight are the UI layers
|
|
135
|
+
icon and one company's mark, and slabs stacked straight or tapered outline two others': they taper or step aside.
|
|
136
|
+
- `bubble`: a speech bubble (a disc, a rounded or a soft block) with one move: the tail parted by the gap, a pair (the
|
|
137
|
+
back one cleared by the gap), bands, a bar run in from one side, or a quarter bitten from the far corner. Never two
|
|
138
|
+
holes (eyes) or three dots, never lines of text (a block takes one cut), never a disc pair (one brand's mark) or a
|
|
139
|
+
disc with a parted wedge (a magnifier).
|
|
140
|
+
- `check`: a heavy tick with one move: the legs parted at the heel, doubled or tripled, or cut out of a half disc (a
|
|
141
|
+
bowl) with the long leg running out over the rim. Never a hole (a checkbox, the verified disc); the slab cut-out (a
|
|
142
|
+
box with the tick running out of it) is by hand only; never turned or mirrored.
|
|
143
|
+
- `peak`: the letter A as a peak, two heavy legs and no crossbar, narrow, the apex pointed or flat, with one move: the
|
|
144
|
+
right leg parted, a slot up a leg, the feet cut off, a small triangle seated in the counter, or a second peak nested
|
|
145
|
+
under. Never wider than tall (a caret), nothing up the middle (an arrow), never rounded at the apex (one brand's A).
|
|
146
|
+
|
|
147
|
+
The finish's `container` takes `'bubble'`: the mark knocked out of, clipped to or framed by a speech bubble, set a
|
|
148
|
+
little above the middle to sit in the bubble's body.
|
|
149
|
+
|
|
150
|
+
## Contrast monograms (0.6.0)
|
|
151
|
+
|
|
152
|
+
Initials treated unlike on purpose, after the owner's contrast monograms: one boxed and one open, each in a ring (one
|
|
153
|
+
solid, one outlined), a sans beside a serif, a letter turned and locked into the other. Each side of a pair has a build
|
|
154
|
+
(`sans`, `serif` and `blackletter` from core's letters, or the Letter recipe's stencil, route, cut, wedge, blocks,
|
|
155
|
+
rails, tiles) and, in Duo, a treatment (`solid`, `knockout`, `outline`; a knocked-out letter is always a heavy build).
|
|
156
|
+
|
|
157
|
+
- `duo`: two (or three, `charC`) initials laid out `boxed` (side by side, each with its treatment), `rings` (each in a
|
|
158
|
+
circle, apart or overlapping, the later ring cleared behind the earlier; a round letter takes a rounded square, two
|
|
159
|
+
O's in rings being a pair of eyes), `cells` (one container split by the gap, a cell filled with its letter cut out, the
|
|
160
|
+
next open) or `turned` (one or both letters turned a quarter or half turn or mirrored, drawn extended at a light
|
|
161
|
+
weight, and nested by a raster search so their strokes lock a gap apart: after the owner's F and P, the P upside down
|
|
162
|
+
with its bowl against the F's bars). The container control is `box`: the finish already has `container`.
|
|
163
|
+
- `crossover`: A solid, running into B's block, ink outside it and cut out inside; the block's edge moves until 68% of
|
|
164
|
+
A's ink is outside (an M whose last stem falls in the gap is an I).
|
|
165
|
+
- `tucked`: a big letter with one or two small ones knocked out of small boxes at its lower or upper corner.
|
|
166
|
+
- `clash`: the letters side by side in unlike builds at one cap height, apart or interlocked (the later letter laid
|
|
167
|
+
over by up to 22% of its width, eased back until it keeps 90% of its ink; a T or an I never interlocks).
|
|
168
|
+
- `splitchar`: one character cut upright, level or on the diagonal, the second half cut out of its half of a box or
|
|
169
|
+
drawn in another build. An H never in a disc (a helipad), a P never in a square (a car park); a letter of slanted
|
|
170
|
+
strokes (A, V, W, Y, K, X, M, N, 4) is never split upright (a pistol's grip and barrel).
|
|
171
|
+
|
|
172
|
+
`monograms(initials, { count = 24, seed = 1 })` makes a page of them from typed initials: upper-cased, A–Z and 0–9 kept,
|
|
173
|
+
at most three (`initialsOf()`). One letter gets the split letter cut each way; two get boxed, rings, cells, turned,
|
|
174
|
+
crossover, tucked and clash; three get boxed, rings and cells with a third, tucked with two small boxes, and clash.
|
|
175
|
+
Each way of contrasting is tried a few times with seeded settings (`monogramPlans()`), failed draws and near-twins (a
|
|
176
|
+
coarse outline over 90% alike) dropped, ranked by `qualityOf()`, no way allowed more than its share, and the page
|
|
177
|
+
alternates them, best first. Each result is a mark with its `group` and `quality`. Three initials keep only marks
|
|
178
|
+
scoring 0.6 or more, so their page is shorter and mostly Tucked. A turned pair keeps no detached crumb (a face).
|
|
179
|
+
|
|
180
|
+
Bans, by construction: `BLOCKED` / `blocked()` initials (other companies' monogram logos: LV, CC, GG, DG, YSL, VW, HP,
|
|
181
|
+
GE, MK, CK, HM, DC, NY, LA, IBM, BMW, KFC; hate codes: SS, HH, KKK, 88) draw nothing in any of the five, and `monograms()`
|
|
182
|
+
returns none. A turn that makes a letter another letter (`BECOMES`: an M upside down is a W, an N on its side a Z,
|
|
183
|
+
6 and 9, L and 7; an A, V or Y on its side an arrowhead; a J upside down a padlock's shackle) moves on
|
|
184
|
+
(the P upside down stays: it is the owner's F/P reference)
|
|
185
|
+
to one that doesn't (`safeTurn()`); two T's, two L's or an X never turn and nest (a cross, a swastika-like hook). No
|
|
186
|
+
faces: two round letters never sit in rings, and no recipe draws paired holes on purpose. None of the five turns or
|
|
187
|
+
mirrors in a shuffle (`TURNS`). A turned pair is also read as it now looks (`LOOKS`, `readsOf()`: a P on its side is a
|
|
188
|
+
U) and is not drawn when that read is blocked or rude (`RUDE`: FU, FK, WTF, slurs…; also blocked as typed initials).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logomarks/generate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
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/finish.js
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* inner corners instead (a closing, kept under half the house gap so separate pieces never fuse), or each piece's own
|
|
6
6
|
* right end, top or outer corner (measured from the piece's own box). `accent` adds one accent dot, a house gap off the
|
|
7
7
|
* mark's right end or corner, or inside its biggest counter (never a round one: a ring with a dot is an eye).
|
|
8
|
-
* `container` puts the finished mark in a circle, square, rounded square or
|
|
8
|
+
* `container` puts the finished mark in a circle, square, rounded square, hexagon or speech bubble: clipped to it (`clip`: the mark
|
|
9
9
|
* zoomed by 1 / `containerSize` and cut at the shape's edge), knocked out of it (`badge`: the shape solid, the mark a
|
|
10
10
|
* house gap's worth of hole, sitting at `containerSize` of the shape) or framed by it (`frame`: the shape as a heavy
|
|
11
11
|
* ring, the mark whole inside). `accentShape` makes the accent a disc or a square (a square full stop).
|
|
12
12
|
*/
|
|
13
|
-
import { U, D, I, rect, rot, mapPts, grow, signedArea, perimeter, circle, rr, regular } from '@logomarks/core/geometry';
|
|
13
|
+
import { U, D, I, rect, rot, mapPts, grow, signedArea, perimeter, circle, rr, regular, poly } from '@logomarks/core/geometry';
|
|
14
14
|
import { BOX, GAP, tidy } from './draw.js';
|
|
15
15
|
|
|
16
16
|
/** @type {import('./index.js').Control[]} */
|
|
@@ -22,7 +22,7 @@ export const FINISH = [
|
|
|
22
22
|
{ key: 'outline', label: 'Outline', type: 'range', min: 0, max: 60, step: 1, value: 0, group: 'finish' },
|
|
23
23
|
{ key: 'accent', label: 'Accent dot', type: 'choice', options: ['none', 'end', 'corner', 'inside'], value: 'none', group: 'finish' },
|
|
24
24
|
{ key: 'accentSize', label: 'Dot size', type: 'range', min: 0.8, max: 1.4, step: 0.05, value: 1, group: 'finish' },
|
|
25
|
-
{ key: 'container', label: 'Container', type: 'choice', options: ['none', 'circle', 'square', 'rounded', 'hexagon'], value: 'none', group: 'finish' },
|
|
25
|
+
{ key: 'container', label: 'Container', type: 'choice', options: ['none', 'circle', 'square', 'rounded', 'hexagon', 'bubble'], value: 'none', group: 'finish' },
|
|
26
26
|
{ key: 'containerMode', label: 'Container mode', type: 'choice', options: ['badge', 'clip', 'frame'], value: 'badge', group: 'finish' },
|
|
27
27
|
{ key: 'containerSize', label: 'Mark size inside', type: 'range', min: 0.5, max: 0.9, step: 0.01, value: 0.78, group: 'finish' },
|
|
28
28
|
{ key: 'accentShape', label: 'Dot shape', type: 'choice', options: ['disc', 'square'], value: 'disc', group: 'finish' },
|
|
@@ -46,30 +46,38 @@ function containerShape(kind) {
|
|
|
46
46
|
if (kind === 'circle') return circle(cx, cy, size / 2, 160);
|
|
47
47
|
if (kind === 'rounded') return rr(x0, y0, size, size, size * 0.22);
|
|
48
48
|
if (kind === 'hexagon') return regular(cx, cy, size / 2, 6, -90);
|
|
49
|
+
if (kind === 'bubble') {
|
|
50
|
+
// a speech bubble: a rounded block with its lower-left corner sharp and run down into a tail
|
|
51
|
+
const h = size * 0.84, r = size * 0.22, t = size * 0.17;
|
|
52
|
+
return U(rr(x0, y0, size, h, [r, r, r, 0]), poly([[x0, y0 + h - t], [x0, y0 + size], [x0 + t * 1.5, y0 + h - 1]]));
|
|
53
|
+
}
|
|
49
54
|
return rect(x0, y0, size, size);
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
/** How much of a container's width a mark's box can take and still sit inside it with room round its corners. */
|
|
53
|
-
const INSCRIBE = { circle: 0.74, square: 1, rounded: 0.94, hexagon: 0.8 };
|
|
58
|
+
const INSCRIBE = { circle: 0.74, square: 1, rounded: 0.94, hexagon: 0.8, bubble: 0.8 };
|
|
59
|
+
/** Where a container's mark sits: its centre's drop from the box's (a bubble's body is above its tail). */
|
|
60
|
+
const LIFT = { bubble: -0.08 };
|
|
54
61
|
|
|
55
|
-
/** The mark scaled about the box's centre so its longest side is `side`, centred. */
|
|
56
|
-
function scaledTo(shape, side) {
|
|
62
|
+
/** The mark scaled about the box's centre so its longest side is `side`, centred (`dy` lower, in boxes). */
|
|
63
|
+
function scaledTo(shape, side, dy = 0) {
|
|
57
64
|
const polys = typeof shape[0][0][0] === 'number' ? [shape] : shape;
|
|
58
65
|
const [x0, y0, x1, y1] = boxOf(polys), k = side / Math.max(x1 - x0, y1 - y0, 1e-9);
|
|
59
66
|
const mx = (x0 + x1) / 2, my = (y0 + y1) / 2;
|
|
60
|
-
return mapPts(polys, ([x, y]) => [BOX.cx + (x - mx) * k, BOX.cy + (y - my) * k]);
|
|
67
|
+
return mapPts(polys, ([x, y]) => [BOX.cx + (x - mx) * k, BOX.cy + dy * BOX.size + (y - my) * k]);
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
/** The mark in a container: clipped to it, or knocked out of it as a badge. */
|
|
64
71
|
function contain(shape, kind, mode, size) {
|
|
65
72
|
if (!shape || !shape.length) return shape;
|
|
66
73
|
const box = containerShape(kind);
|
|
67
|
-
|
|
74
|
+
const dy = LIFT[kind] || 0;
|
|
75
|
+
if (mode === 'clip') return tidy(I(scaledTo(shape, (BOX.size * 0.9) / size, dy), box));
|
|
68
76
|
// frame: the container drawn as a heavy ring (its band about the house gap and a half), the mark whole inside it, a gap
|
|
69
77
|
// clear of the ring all round
|
|
70
78
|
if (mode === 'frame') {
|
|
71
79
|
const band = GAP * 1.7, ring = D(box, grow(box, -band));
|
|
72
|
-
const mark = scaledTo(shape, BOX.size * size * INSCRIBE[kind] * 0.86);
|
|
80
|
+
const mark = scaledTo(shape, BOX.size * size * INSCRIBE[kind] * 0.86, dy);
|
|
73
81
|
return tidy(U(ring, D(mark, grow(ring, GAP * 1.1))));
|
|
74
82
|
}
|
|
75
83
|
// badge: the mark sits at `size` of the shape, its pieces knocked out; a mark spilling past the shape's edge would cut
|
|
@@ -77,7 +85,7 @@ function contain(shape, kind, mode, size) {
|
|
|
77
85
|
// the holes, so each hole is shrunk by half of what the scale took off the gap (the bridges get it back). A mark too
|
|
78
86
|
// thin for this leaves hairline holes, which the guard turns away.
|
|
79
87
|
const k = (size * INSCRIBE[kind]);
|
|
80
|
-
const mark = I(scaledTo(shape, BOX.size * k), grow(box, -GAP));
|
|
88
|
+
const mark = I(scaledTo(shape, BOX.size * k, dy), grow(box, -GAP));
|
|
81
89
|
const back = (GAP * Math.max(0, 1 - k)) / 2;
|
|
82
90
|
return tidy(D(box, back > 0.5 ? grow(mark, -back) : mark));
|
|
83
91
|
}
|
package/src/generate.js
CHANGED
|
@@ -9,6 +9,7 @@ import { rng, seedOf } from './random.js';
|
|
|
9
9
|
import { problems } from './guard.js';
|
|
10
10
|
import { TURNS, TURN_SHARE, HOLD } from './tuning.js';
|
|
11
11
|
import { fill, thinShareBits } from './raster.js';
|
|
12
|
+
import { blocked, readsBlocked, safeTurn } from './recipes/duo.js';
|
|
12
13
|
|
|
13
14
|
robust();
|
|
14
15
|
|
|
@@ -267,7 +268,7 @@ export function similar(id, params, { count = 12, seed = 1, amount = 0.15, locke
|
|
|
267
268
|
* How often each recipe comes up in `mix()`, relative to 1: the ones whose shuffles most often give a mark worth
|
|
268
269
|
* keeping lead; the textured ones (iso, hex, tiles) come up less.
|
|
269
270
|
*/
|
|
270
|
-
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, 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 , merge: 1.3, overlap: 1.3, counter: 1.2, pair: 1.3, corners: 1.2, offset: 1.1, quarters: 1.1 , mosaic: 0.8, weave: 0.8, notch: 1, nodes: 0.9, xband: 0.9, mirror: 0.8, ribbon: 1, field: 0.7, zigzag: 0.9, halfstripe: 0.9 };
|
|
271
|
+
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, 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 , merge: 1.3, overlap: 1.3, counter: 1.2, pair: 1.3, corners: 1.2, offset: 1.1, quarters: 1.1 , mosaic: 0.8, weave: 0.8, notch: 1, nodes: 0.9, xband: 0.9, mirror: 0.8, ribbon: 1, field: 0.7, zigzag: 0.9, halfstripe: 0.9, cloud: 0.9, layers: 0.9, bubble: 0.8, check: 0.7, peak: 0.8, duo: 0.9, crossover: 0.7, tucked: 0.7, clash: 0.7, splitchar: 0.6 };
|
|
271
272
|
|
|
272
273
|
/**
|
|
273
274
|
* `count` marks from ANY recipe: each slot picks a recipe by its seed (from `ids`, every recipe by default, weighted by
|
|
@@ -290,3 +291,99 @@ export function mix({ count = 48, seed = 1, ids = Object.keys(RECIPES), tries =
|
|
|
290
291
|
}
|
|
291
292
|
return out;
|
|
292
293
|
}
|
|
294
|
+
|
|
295
|
+
/** Initials as monograms take them: upper case, letters and numerals only, at most three. */
|
|
296
|
+
export const initialsOf = (text) => [...String(text ?? '').toUpperCase()].filter((c) => /[A-Z0-9]/.test(c)).slice(0, 3);
|
|
297
|
+
|
|
298
|
+
/** A shape's coarse outline signature: its fitted ink on a small bitmap, for telling near-twins apart. */
|
|
299
|
+
function signatureOf(shape) {
|
|
300
|
+
const polys = !shape || !shape.length ? [] : typeof shape[0][0][0] === 'number' ? [shape] : shape;
|
|
301
|
+
if (!polys.length) return null;
|
|
302
|
+
let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
|
|
303
|
+
for (const poly of polys) for (const [x, y] of poly[0]) { x0 = Math.min(x0, x); y0 = Math.min(y0, y); x1 = Math.max(x1, x); y1 = Math.max(y1, y); }
|
|
304
|
+
const k = 448 / Math.max(x1 - x0, y1 - y0, 1e-9), mx = (x0 + x1) / 2, my = (y0 + y1) / 2;
|
|
305
|
+
return fill(polys.map((poly) => mapPts(poly, ([x, y]) => [256 + (x - mx) * k, 256 + (y - my) * k])), 28);
|
|
306
|
+
}
|
|
307
|
+
/** How alike two signatures are (shared ink over all ink). */
|
|
308
|
+
function alikeness(a, b) {
|
|
309
|
+
let both = 0, any = 0;
|
|
310
|
+
for (let i = 0; i < a.length; i++) { both += a[i] & b[i]; any += a[i] | b[i]; }
|
|
311
|
+
return any ? both / any : 1;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* The plans `monograms()` draws from, in groups (one group a way of contrasting the letters), each plan a recipe and its
|
|
316
|
+
* params, varied by the seed. One letter: the split letter, cut each way, its second half cut out or in another build.
|
|
317
|
+
* Two: boxed, rings (apart and overlapping), cells, turned, crossover, tucked and clash. Three: boxed, rings and cells
|
|
318
|
+
* with a third cell, tucked with two small boxes, and clash.
|
|
319
|
+
*/
|
|
320
|
+
export function monogramPlans(initials, { seed = 1, each = 4 } = {}) {
|
|
321
|
+
const chars = initialsOf(initials);
|
|
322
|
+
if (!chars.length || blocked(chars)) return [];
|
|
323
|
+
const rand = rng(`monograms:${chars.join('')}:${seed}`), pick = (a) => a[Math.floor(rand() * a.length)];
|
|
324
|
+
const [a, b, c] = chars, heavy = ['sans', 'cut', 'wedge', 'blocks', 'route'], contrast = ['serif', 'serif', 'blackletter', 'sans', 'stencil'];
|
|
325
|
+
const boxes = ['rounded', 'square', 'circle'], groups = [];
|
|
326
|
+
const group = (name, recipe, make, n = each) => groups.push({ name, plans: [...Array(n)].map(() => ({ recipe, params: make(), group: name })) });
|
|
327
|
+
const w = () => 0.18 + rand() * 0.05, pair = { charA: a, charB: b, charC: c || '-' };
|
|
328
|
+
if (chars.length === 1) {
|
|
329
|
+
for (const axis of ['upright', 'level', 'diagonal']) {
|
|
330
|
+
group(`split-${axis}`, 'splitchar', () => ({ charA: a, axis, treatB: 'knockout', buildA: pick(['sans', 'cut', 'wedge']), box: pick(boxes), weight: w() }));
|
|
331
|
+
group(`split-${axis}-type`, 'splitchar', () => ({ charA: a, axis, treatB: 'build', buildA: pick(['sans', 'cut', 'wedge']), buildB: pick(['serif', 'serif', 'stencil']), weight: w() }));
|
|
332
|
+
}
|
|
333
|
+
} else {
|
|
334
|
+
group('boxed', 'duo', () => ({ ...pair, layout: 'boxed', treatA: pick(['knockout', 'knockout', 'outline']), treatB: pick(['solid', 'solid', 'outline']), buildA: pick(heavy), buildB: pick(contrast), box: pick(boxes), weight: w() }));
|
|
335
|
+
group('rings', 'duo', () => ({ ...pair, layout: 'rings', treatA: 'knockout', treatB: pick(['outline', 'solid']), join: pick(['apart', 'overlap']), buildA: pick(heavy), buildB: pick(contrast), weight: w() }));
|
|
336
|
+
group('cells', 'duo', () => ({ ...pair, layout: 'cells', buildA: pick(heavy), buildB: pick(contrast), box: pick(['rounded', 'square']), weight: w() }));
|
|
337
|
+
group('tucked', 'tucked', () => ({ ...pair, buildA: pick(['sans', 'serif', 'serif', 'cut']), buildB: pick(['sans', 'sans', 'cut']), treatB: 'knockout', box: pick(boxes), corner: 'JSGCOUQ'.includes(a) ? 'top' : pick(['bottom', 'bottom', 'top']), size: 0.4 + rand() * 0.1, weight: w() }), chars.length === 3 ? each * 3 : each);
|
|
338
|
+
group('clash', 'clash', () => ({ ...pair, buildA: pick(['sans', 'cut', 'wedge']), buildB: pick(['serif', 'serif', 'blackletter']), join: pick(['apart', 'interlock']), weight: w() }));
|
|
339
|
+
if (chars.length === 2) {
|
|
340
|
+
group('turned', 'duo', () => {
|
|
341
|
+
// turns whose pair reads as blocked or rude (F with a P on its side is FU) are drawn again, a few times
|
|
342
|
+
let turnA = '0', turnB = '180';
|
|
343
|
+
for (let k = 0; k < 8; k++) {
|
|
344
|
+
turnA = pick(['0', '0', '270', '90']); turnB = pick(['180', '180', '90', '270', 'mirror']);
|
|
345
|
+
if (!readsBlocked(a, safeTurn(a, turnA), b, safeTurn(b, turnB))) break;
|
|
346
|
+
}
|
|
347
|
+
return { ...pair, layout: 'turned', buildA: pick(['sans', 'sans', 'cut', 'serif']), turnA, turnB, stretch: 1.2 + rand() * 0.3, weight: w() };
|
|
348
|
+
});
|
|
349
|
+
// a letter whose last stroke is a stem or an arm (H, M, T…) loses it to the block's edge: no crossover for it
|
|
350
|
+
if (!'HIMNTWXY'.includes(a)) group('crossover', 'crossover', () => ({ ...pair, buildA: pick(['sans', 'cut', 'wedge']), buildB: pick(['sans', 'cut', 'wedge']), box: pick(['rounded', 'square']), overlap: 0.16 + rand() * 0.1, weight: w() }));
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
// the groups in a seeded order, each plan's settings drawn above
|
|
354
|
+
for (let i = groups.length - 1; i > 0; i--) { const j = Math.floor(rand() * (i + 1)); [groups[i], groups[j]] = [groups[j], groups[i]]; }
|
|
355
|
+
return groups;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* A page of contrast monograms for typed initials (one to three letters and numerals; anything else is ignored, and a
|
|
360
|
+
* blocked run of initials gives none): every way of contrasting the letters tried a few times (`monogramPlans()`),
|
|
361
|
+
* failed draws and near-twins dropped, ranked by `qualityOf`, and no way of contrasting allowed to crowd the page. Each
|
|
362
|
+
* result is a mark (`generate()`'s) with its `group` and `quality`, in an order that alternates the groups, best first.
|
|
363
|
+
*/
|
|
364
|
+
export function monograms(initials, { count = 24, seed = 1, each } = {}) {
|
|
365
|
+
const groups = monogramPlans(initials, { seed, each: each ?? Math.max(3, Math.ceil((count * 1.6) / 7)) });
|
|
366
|
+
if (!groups.length) return [];
|
|
367
|
+
const found = [], sigs = [];
|
|
368
|
+
for (const gr of groups) for (const plan of gr.plans) {
|
|
369
|
+
try {
|
|
370
|
+
const { shape, g } = draw(plan.recipe, plan.params);
|
|
371
|
+
if (g.problems.length || !g.svg) continue;
|
|
372
|
+
const sig = signatureOf(shape);
|
|
373
|
+
if (sigs.some((s) => alikeness(s, sig) > 0.9)) continue;
|
|
374
|
+
sigs.push(sig);
|
|
375
|
+
found.push({ ...g, group: plan.group, quality: qualityOf(shape).score });
|
|
376
|
+
} catch { /* the next plan */ }
|
|
377
|
+
}
|
|
378
|
+
// three initials crowd the pair layouts (rings, cells, boxed): below 0.6 they look cramped, so a three-letter page
|
|
379
|
+
// shows fewer, better ones (tucked, one big and two small, scores well)
|
|
380
|
+
if (initialsOf(initials).length === 3) for (let i = found.length - 1; i >= 0; i--) if (found[i].quality < 0.6) found.splice(i, 1);
|
|
381
|
+
const live = new Set(found.map((m) => m.group)).size || 1, cap = Math.max(2, Math.ceil(count / live) + 1), byGroup = new Map();
|
|
382
|
+
for (const m of found.sort((x, y) => y.quality - x.quality)) {
|
|
383
|
+
const list = byGroup.get(m.group) || [];
|
|
384
|
+
if (list.length < cap) { list.push(m); byGroup.set(m.group, list); }
|
|
385
|
+
}
|
|
386
|
+
const lanes = [...byGroup.values()], out = [];
|
|
387
|
+
while (out.length < count && lanes.some((l) => l.length)) for (const l of lanes) if (l.length && out.length < count) out.push(l.shift());
|
|
388
|
+
return out;
|
|
389
|
+
}
|
package/src/index.d.ts
CHANGED
|
@@ -44,10 +44,10 @@ export interface Generated {
|
|
|
44
44
|
seed?: number;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
/** Every recipe, by id (
|
|
47
|
+
/** Every recipe, by id (60): bars, bands, twin, stack, shear, turns, burst, tiles, route, arcs, rings, stripes, chevrons,
|
|
48
48
|
* waves, cut, split, spiral, bloom, links, horizon, steps, hex, iso, letter, arcstep, halfsq, invert, leaves, lobes, loops,
|
|
49
49
|
* trine, strips, bite, blades, wavecut, capsules, flare, merge, overlap, counter, pair, corners, offset, quarters, seam,
|
|
50
|
-
* mosaic, weave, notch, nodes, xband, mirror, ribbon, field, zigzag and
|
|
50
|
+
* mosaic, weave, notch, nodes, xband, mirror, ribbon, field, zigzag, halfstripe, cloud, layers, bubble, check and peak. */
|
|
51
51
|
export const RECIPES: Record<string, Recipe>;
|
|
52
52
|
/** A recipe by id; throws for an unknown one. */
|
|
53
53
|
export function recipe(id: string): Recipe;
|
|
@@ -133,3 +133,34 @@ export function unlikePair(rand: () => number, pool?: string[], recipe?: string)
|
|
|
133
133
|
export function unlikeTriple(rand: () => number, pool?: string[], recipe?: string): [string, string, string];
|
|
134
134
|
/** Per recipe, the pairings it never draws: [a, b, the read avoided]. */
|
|
135
135
|
export const BANNED: Record<string, [string, string, string][]>;
|
|
136
|
+
|
|
137
|
+
/** A contrast monogram on a `monograms()` page: the mark, which way it contrasts the letters (`group`), and its quality. */
|
|
138
|
+
export type Monogram = Generated & { group: string; quality: number };
|
|
139
|
+
/**
|
|
140
|
+
* A page of contrast monograms for typed initials (one to three letters and numerals; anything else ignored; blocked
|
|
141
|
+
* initials give none): every way of contrasting tried a few times, failed draws and near-twins dropped, ranked by
|
|
142
|
+
* `qualityOf`, no way allowed to crowd the page, the order alternating them. Seeded.
|
|
143
|
+
*/
|
|
144
|
+
export function monograms(initials: string, o?: { count?: number; seed?: number | string; each?: number }): Monogram[];
|
|
145
|
+
/** The plans `monograms()` draws from, grouped by way of contrasting the letters. */
|
|
146
|
+
export function monogramPlans(initials: string, o?: { seed?: number | string; each?: number }): { name: string; plans: { recipe: string; params: Params; group: string }[] }[];
|
|
147
|
+
/** Initials as monograms take them: upper case, A–Z and 0–9 only, at most three. */
|
|
148
|
+
export function initialsOf(text: string): string[];
|
|
149
|
+
/** Initials never drawn: other companies' monogram logos and hate codes. */
|
|
150
|
+
export const BLOCKED: string[];
|
|
151
|
+
/** Whether a run of characters is one of the blocked initials. */
|
|
152
|
+
export function blocked(chars: string | string[]): boolean;
|
|
153
|
+
/** The letter builds a monogram side can take. */
|
|
154
|
+
export const BUILDS: string[];
|
|
155
|
+
/** Turns that make a letter another letter (an M upside down is a W). */
|
|
156
|
+
export const BECOMES: Record<string, Record<string, string>>;
|
|
157
|
+
/** The turn a letter takes for an asked one: the asked turn, or the next that keeps it itself. */
|
|
158
|
+
export function safeTurn(ch: string, turn: string): string;
|
|
159
|
+
/** Rude or offensive reads, typed or made by a turn (profanity initials, slurs); blocked like `BLOCKED`. */
|
|
160
|
+
export const RUDE: string[];
|
|
161
|
+
/** What a letter looks like once turned, where that passes for another letter. */
|
|
162
|
+
export const LOOKS: Record<string, Record<string, string>>;
|
|
163
|
+
/** The letters a character may be read as, turned `turn` ('?' for none). */
|
|
164
|
+
export function readsOf(ch: string, turn: string): string;
|
|
165
|
+
/** Whether two turned letters read, in either order, as blocked initials or a rude read. */
|
|
166
|
+
export function readsBlocked(a: string, ta: string, b: string, tb: string): boolean;
|
package/src/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* @logomarks/generate: abstract logomarks from rules and controls, no AI.
|
|
3
3
|
*/
|
|
4
4
|
export { RECIPES } from './recipes/index.js';
|
|
5
|
-
export { recipe, generate, randomParams, variations, nearby, similar, mix, shuffled, qualityOf, MIX_WEIGHT, piecesOf, svgOf, PATTERNS } from './generate.js';
|
|
5
|
+
export { recipe, generate, randomParams, variations, nearby, similar, mix, shuffled, qualityOf, MIX_WEIGHT, piecesOf, svgOf, PATTERNS, monograms, monogramPlans, initialsOf } from './generate.js';
|
|
6
|
+
export { BLOCKED, RUDE, blocked, BUILDS, BECOMES, safeTurn, LOOKS, readsOf, readsBlocked } from './recipes/duo.js';
|
|
6
7
|
export { defaults, resolve, clampTo, randomValue } from './controls.js';
|
|
7
8
|
export { rng, seedOf } from './random.js';
|
|
8
9
|
export { GUARD, problems } from './guard.js';
|
package/src/presets.js
CHANGED
|
@@ -53,4 +53,18 @@ export const PRESETS = [
|
|
|
53
53
|
{ id: 'zigzag-disc', name: 'Zigzag disc', recipe: 'zigzag', params: { shape: 'circle', stripes: 5, teeth: 2 }, note: 'A striped disc broken by a zigzag, one side slid.' },
|
|
54
54
|
{ id: 'half-bars', name: 'Half bars', recipe: 'halfstripe', params: { shape: 'hexagon', bars: 4, step: 0.1 }, note: 'A hexagon half solid, half bars stepping down.' },
|
|
55
55
|
{ id: 'four-shapes', name: 'Four shapes', recipe: 'quarters', params: { a: 'quarter', b: 'wedge', c: 'disc', d: 'leaf', rule: 'rotate' }, note: 'Four unlike shapes, each a quarter turn on from the last.' },
|
|
56
|
+
// the tech-brand styles (0.5.0)
|
|
57
|
+
{ id: 'banded-cloud', name: 'Banded cloud', recipe: 'cloud', params: { puffs: 3, rise: 'left', move: 'bands' }, note: 'A cloud lifted off a strip of its base by one gap.' },
|
|
58
|
+
{ id: 'slotted-cloud', name: 'Slotted cloud', recipe: 'cloud', params: { puffs: 3, rise: 'right', move: 'slot', base: 'round' }, note: 'A cloud with a slot run in from one end.' },
|
|
59
|
+
{ id: 'slab-layers', name: 'Slab layers', recipe: 'layers', params: { plate: 'slab', count: 3, lay: 'stack' }, note: 'Three plates with a thickness, stacked a gap apart.' },
|
|
60
|
+
{ id: 'offset-layers', name: 'Offset layers', recipe: 'layers', params: { plate: 'rounded', count: 3, lay: 'offset' }, note: 'Three soft plates, each a step to one side.' },
|
|
61
|
+
{ id: 'bubble-pair', name: 'Bubble pair', recipe: 'bubble', params: { move: 'pair', body: 'rounded' }, note: 'Two speech bubbles, the back one cleared by the gap.' },
|
|
62
|
+
{ id: 'striped-bubble', name: 'Striped bubble', recipe: 'bubble', params: { move: 'bands', body: 'disc', bands: 3 }, note: 'A round speech bubble cut into three bands.' },
|
|
63
|
+
{ id: 'parted-tick', name: 'Parted tick', recipe: 'check', params: { move: 'heel', weight: 0.21 }, note: 'A heavy tick, its two legs parted at the heel.' },
|
|
64
|
+
{ id: 'seated-a', name: 'Seated A', recipe: 'peak', params: { move: 'seat', apex: 'flat', weight: 0.22 }, note: 'An A as a peak, a small triangle seated for its crossbar.' },
|
|
65
|
+
{ id: 'boxed-pair', name: 'Boxed pair', recipe: 'duo', params: { charA: 'J', charB: 'M', layout: 'boxed', treatA: 'knockout', treatB: 'solid', buildA: 'sans', buildB: 'serif', box: 'rounded' }, note: 'One initial cut from a box, the other a serif beside it.' },
|
|
66
|
+
{ id: 'two-rings', name: 'Two rings', recipe: 'duo', params: { charA: 'A', charB: 'S', layout: 'rings', treatA: 'knockout', treatB: 'outline', buildA: 'cut', buildB: 'serif', join: 'overlap' }, note: 'Each initial in a ring, one solid, one outlined.' },
|
|
67
|
+
{ id: 'turned-pair', name: 'Turned pair', recipe: 'duo', params: { charA: 'F', charB: 'P', layout: 'turned', buildA: 'sans', turnA: '0', turnB: '180', stretch: 1.45 }, note: 'Two letters turned and locked together.' },
|
|
68
|
+
{ id: 'type-clash', name: 'Type clash', recipe: 'clash', params: { charA: 'J', charB: 'M', buildA: 'sans', buildB: 'blackletter', join: 'interlock' }, note: 'A heavy sans beside a blackletter.' },
|
|
69
|
+
{ id: 'split-letter', name: 'Split letter', recipe: 'splitchar', params: { charA: 'D', axis: 'upright', treatB: 'build', buildA: 'sans', buildB: 'serif' }, note: 'Half a sans D, half a serif one.' },
|
|
56
70
|
];
|
package/src/raster.js
CHANGED
|
@@ -29,7 +29,7 @@ function disc(r) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/** One pass of erosion (`all` true: kept where the whole disc is set) or dilation (set where any of it is). */
|
|
32
|
-
function morph(bits, N, r, all) {
|
|
32
|
+
export function morph(bits, N, r, all) {
|
|
33
33
|
const out = new Uint8Array(N * N), d = disc(r);
|
|
34
34
|
for (let y = 0; y < N; y++) for (let x = 0; x < N; x++) {
|
|
35
35
|
let v = all ? 1 : 0;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bubble: a speech bubble as a construction, after the chat marks of the owner's tech-brand audit (2026-11-27): a disc,
|
|
3
|
+
* rounded square or squircle-cornered block with a tail at one lower corner, and ONE move: the tail parted from the body
|
|
4
|
+
* by the gap, two bubbles overlapping with the back one cleared by the gap, the bubble cut into bands, a glyph cut in (a
|
|
5
|
+
* slot, a bar run in from the side, a quarter). Folded from one heavy band it read as a Q: left out. Never eyes or a face (no two
|
|
6
|
+
* holes in a bubble), never three dots (the typing indicator), never a heart, never lines of text (a message icon):
|
|
7
|
+
* a bubble takes at most one cut-out.
|
|
8
|
+
*/
|
|
9
|
+
import { U, D, I, rect, rr, circle, poly, grow, sector } from '@logomarks/core/geometry';
|
|
10
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
11
|
+
|
|
12
|
+
/** @type {import('../index.js').Control[]} */
|
|
13
|
+
export const controls = [
|
|
14
|
+
{ key: 'body', label: 'Body', type: 'choice', options: ['disc', 'rounded', 'soft'], value: 'rounded' },
|
|
15
|
+
{ key: 'move', label: 'Move', type: 'choice', options: ['tail', 'pair', 'bands', 'glyph', 'none'], value: 'pair' },
|
|
16
|
+
{ key: 'glyph', label: 'Cut-out', type: 'choice', options: ['bar', 'quarter', 'slot'], value: 'bar' },
|
|
17
|
+
{ key: 'tail', label: 'Tail', type: 'choice', options: ['left', 'right'], value: 'left' },
|
|
18
|
+
{ key: 'tailSize', label: 'Tail size', type: 'range', min: 0.16, max: 0.3, step: 0.01, value: 0.22 },
|
|
19
|
+
{ key: 'bands', label: 'Bands', type: 'range', min: 2, max: 3, step: 1, value: 2 },
|
|
20
|
+
{ key: 'weight', label: 'Band weight', type: 'range', min: 0.13, max: 0.2, step: 0.005, value: 0.16 },
|
|
21
|
+
{ key: 'back', label: 'Back bubble', type: 'range', min: 0.55, max: 0.8, step: 0.01, value: 0.66 },
|
|
22
|
+
{ key: 'spacing', label: 'Gap', type: 'range', min: 1, max: 1.7, step: 0.05, value: 1.2 },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A bubble's body `s` square at (x, y) and its tail: a corner of the body pulled down past the foot at the `side`. The
|
|
27
|
+
* disc's tail is a wedge under it; the rounded and soft blocks keep that corner sharp and run it down.
|
|
28
|
+
*/
|
|
29
|
+
function bubble(x, y, s, p, side = p.tail) {
|
|
30
|
+
const t = s * p.tailSize, left = side === 'left';
|
|
31
|
+
const r = p.body === 'disc' ? s / 2 : p.body === 'soft' ? s * 0.36 : s * 0.2;
|
|
32
|
+
const body = p.body === 'disc' ? circle(x + s / 2, y + s / 2, s / 2, 160) : rr(x, y, s, s, left ? [r, r, r, 0] : [r, r, 0, r]);
|
|
33
|
+
const cx = left ? x : x + s, foot = y + s;
|
|
34
|
+
// the tail: from the corner (or, on a disc, from under its side) down and out
|
|
35
|
+
const tail = p.body === 'disc'
|
|
36
|
+
? poly(left ? [[x + s * 0.12, y + s * 0.62], [x - t * 0.2, foot + t * 0.55], [x + s * 0.5, y + s * 0.94]] : [[x + s * 0.88, y + s * 0.62], [x + s + t * 0.2, foot + t * 0.55], [x + s * 0.5, y + s * 0.94]])
|
|
37
|
+
: poly(left ? [[cx, foot - t], [cx, foot + t * 0.95], [cx + t * 1.5, foot]] : [[cx, foot - t], [cx, foot + t * 0.95], [cx - t * 1.5, foot]]);
|
|
38
|
+
return { body, tail, all: U(body, tail) };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The mark for resolved params. */
|
|
42
|
+
export function build(p) {
|
|
43
|
+
const g = GAP * p.spacing, S = BOX.size * 0.84, x = BOX.cx - S / 2, y = BOX.cy - S / 2 - S * p.tailSize * 0.35;
|
|
44
|
+
const b = bubble(x, y, S, p);
|
|
45
|
+
// two round bubbles side by side are one tech brand's mark: a disc pair is drawn as rounded blocks
|
|
46
|
+
if (p.move === 'pair' && p.body === 'disc') return build({ ...p, body: 'soft' });
|
|
47
|
+
if (p.move === 'pair') {
|
|
48
|
+
// a smaller bubble behind, up and to the far side, its tail the other way; the front one whole, the back one
|
|
49
|
+
// cleared of it by the gap
|
|
50
|
+
const s2 = S * p.back, left = p.tail === 'left';
|
|
51
|
+
const fx = left ? BOX.x0 : BOX.x1 - S * 0.86, front = bubble(fx, BOX.y1 - S * 0.86 * (1 + p.tailSize * 0.6), S * 0.86, p);
|
|
52
|
+
const bx = left ? BOX.x1 - s2 : BOX.x0, back = bubble(bx, BOX.y0, s2, p, left ? 'right' : 'left');
|
|
53
|
+
return tidy(U(front.all, D(back.all, grow(front.all, g))));
|
|
54
|
+
}
|
|
55
|
+
if (p.move === 'tail') {
|
|
56
|
+
// the tail parted from the body: a right triangle a gap under the block's sharp corner (a disc with a parted
|
|
57
|
+
// wedge is a magnifier: the disc takes its tail whole and is cut into three bands instead)
|
|
58
|
+
if (p.body === 'disc') return build({ ...p, move: 'bands', bands: 3 });
|
|
59
|
+
const t = S * p.tailSize * 1.5, left = p.tail === 'left', cx = left ? x : x + S, ty = y + S + g;
|
|
60
|
+
const tail = poly(left ? [[cx, ty], [cx, ty + t], [cx + t * 1.25, ty]] : [[cx, ty], [cx, ty + t], [cx - t * 1.25, ty]]);
|
|
61
|
+
return tidy(U(b.body, tail));
|
|
62
|
+
}
|
|
63
|
+
// a disc with a bar run into it reads as an e: a disc's cut-out is its bands
|
|
64
|
+
if (p.move === 'bands' || (p.move === 'glyph' && p.body === 'disc')) {
|
|
65
|
+
// level gaps across the bubble, the tail riding with the lowest band
|
|
66
|
+
// a block cut into three is the lines of a message: a block takes one cut, a disc up to two
|
|
67
|
+
// (a disc cut once stays too solid a disc: a disc takes two cuts)
|
|
68
|
+
const n = p.body === 'disc' ? Math.max(3, p.bands) : 2, h = S / n, cuts = [];
|
|
69
|
+
for (let k = 1; k < n; k++) cuts.push(rect(x - S, y + k * h - g / 2, S * 3, g));
|
|
70
|
+
return tidy(D(b.all, U(...cuts)));
|
|
71
|
+
}
|
|
72
|
+
if (p.move === 'glyph') {
|
|
73
|
+
// one cut-out: a round-ended slot across the middle, a bar run in from the tail's far side, or a quarter disc
|
|
74
|
+
const cx = x + S / 2, cy = y + S / 2, w = S * p.weight;
|
|
75
|
+
if (p.glyph === 'bar') {
|
|
76
|
+
const fromRight = p.tail === 'left';
|
|
77
|
+
return tidy(D(b.all, rr(fromRight ? cx - S * 0.12 : x - S, cy - w / 2, S * 0.62 + S, w, w / 2)));
|
|
78
|
+
}
|
|
79
|
+
if (p.glyph === 'quarter') {
|
|
80
|
+
// a quarter bitten from the top corner away from the tail (a quarter hole in the middle read as a D or a P)
|
|
81
|
+
const q = S * 0.54, left = p.tail === 'left', qx = left ? x + S : x;
|
|
82
|
+
return tidy(D(b.all, circle(qx, y, q, 120)));
|
|
83
|
+
}
|
|
84
|
+
return tidy(D(b.all, rr(cx - S * 0.28, cy - w / 2, S * 0.56, w, w / 2)));
|
|
85
|
+
}
|
|
86
|
+
return tidy(b.all);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** One or two bubbles and their cut. */
|
|
90
|
+
export const guard = {};
|