@logomarks/generate 0.2.0 → 0.3.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 +46 -0
- package/README.md +29 -3
- package/package.json +1 -1
- package/src/generate.js +1 -1
- package/src/index.d.ts +17 -0
- package/src/index.js +1 -0
- package/src/presets.js +8 -1
- package/src/primitives.js +100 -0
- package/src/recipes/corners.js +57 -0
- package/src/recipes/counter.js +40 -0
- package/src/recipes/halfsq.js +35 -39
- package/src/recipes/index.js +17 -7
- package/src/recipes/lobes.js +37 -17
- package/src/recipes/merge.js +38 -0
- package/src/recipes/offset.js +37 -0
- package/src/recipes/overlap.js +37 -0
- package/src/recipes/pair.js +45 -0
- package/src/recipes/quarters.js +66 -0
- package/src/recipes/stack.js +27 -6
- package/src/recipes/strips.js +32 -12
- package/src/recipes/trine.js +24 -23
- package/src/tuning.js +23 -12
- package/src/recipes/pixelarc.js +0 -51
- package/src/recipes/venn.js +0 -54
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merge: two unlike shapes fused along a shared edge into ONE solid. One sits over the other, flat side to flat side;
|
|
3
|
+
* the lower one is narrower and set to one side, so the join steps (a centred join reads as an object: a mushroom, a
|
|
4
|
+
* lamp, a house). Which two, where they meet, how wide the second is and which side it keeps are the controls.
|
|
5
|
+
*/
|
|
6
|
+
import { rot } from '@logomarks/core/geometry';
|
|
7
|
+
import { BOX, tidy } from '../draw.js';
|
|
8
|
+
import { prim, unlike, join } from '../primitives.js';
|
|
9
|
+
|
|
10
|
+
// no triangle or diamond (fused to a block off centre, a point is an arrow), no disc or hexagon (they fuse into lumps
|
|
11
|
+
// with nicks where the outlines cross)
|
|
12
|
+
export const POOL = ['square', 'half', 'quarter', 'wedge', 'leaf', 'rsquare'];
|
|
13
|
+
/** Shapes with a flat lower edge the full width of their box: the others lap further into the join. */
|
|
14
|
+
const FLAT = ['square', 'half', 'quarter', 'wedge'];
|
|
15
|
+
|
|
16
|
+
/** @type {import('../index.js').Control[]} */
|
|
17
|
+
export const controls = [
|
|
18
|
+
{ key: 'a', label: 'First shape', type: 'choice', options: POOL, value: 'half' },
|
|
19
|
+
{ key: 'b', label: 'Second shape', type: 'choice', options: POOL, value: 'wedge' },
|
|
20
|
+
{ key: 'at', label: 'Join', type: 'range', min: 0.36, max: 0.64, step: 0.01, value: 0.5 },
|
|
21
|
+
{ key: 'width', label: 'Second width', type: 'range', min: 0.4, max: 1, step: 0.01, value: 0.62 },
|
|
22
|
+
{ key: 'side', label: 'Side', type: 'choice', options: ['start', 'end'], value: 'start' },
|
|
23
|
+
{ key: 'flip', label: 'Flip second', type: 'choice', options: ['no', 'yes'], value: 'no' },
|
|
24
|
+
{ key: 'spin', label: 'Spin', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
/** The two shapes as drawn (the second steered off a banned pair). */
|
|
28
|
+
export const shapesOf = (p) => [p.a, unlike('merge', p.a, p.b, POOL)];
|
|
29
|
+
|
|
30
|
+
/** The mark for resolved params. */
|
|
31
|
+
export function build(p) {
|
|
32
|
+
const { x0, y0, size, cx, cy } = BOX, [a, b] = shapesOf(p), ya = size * p.at;
|
|
33
|
+
const lapA = FLAT.includes(a) ? 1 : ya * 0.34, lapB = FLAT.includes(b) ? 1 : (size - ya) * 0.34;
|
|
34
|
+
const bw = size * p.width, bx = p.side === 'end' ? x0 + size - bw : x0;
|
|
35
|
+
const A = prim(a, [x0, y0, size, ya + lapA]);
|
|
36
|
+
const B = prim(b, [bx, y0 + ya - lapB, bw, size - ya + lapB], 2, p.flip === 'yes');
|
|
37
|
+
return tidy(rot(join(A, B), Number(p.spin), cx, cy));
|
|
38
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offset: a shape and a copy of itself slid along one direction, the two kept apart by the house gap: the copy behind
|
|
3
|
+
* as a hard shadow, the overlap knocked out, or the overlap kept as its own piece. One or two copies.
|
|
4
|
+
*/
|
|
5
|
+
import { U, D, I, move, grown, grow } from '@logomarks/core/geometry';
|
|
6
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
7
|
+
import { prim } from '../primitives.js';
|
|
8
|
+
|
|
9
|
+
// no disc (two discs are a Venn pair, which `venn` draws), no arch (two arches are a known logo), no square (a copy icon)
|
|
10
|
+
export const POOL = ['triangle', 'half', 'quarter', 'leaf', 'diamond', 'hexagon', 'wedge', 'pill'];
|
|
11
|
+
const DIRS = { e: [1, 0], se: [1, 1], s: [0, 1], sw: [-1, 1], ne: [1, -1] };
|
|
12
|
+
|
|
13
|
+
/** @type {import('../index.js').Control[]} */
|
|
14
|
+
export const controls = [
|
|
15
|
+
{ key: 'shape', label: 'Shape', type: 'choice', options: POOL, value: 'half' },
|
|
16
|
+
{ key: 'way', label: 'Copy', type: 'choice', options: ['shadow', 'knock', 'keep'], value: 'shadow' },
|
|
17
|
+
{ key: 'dir', label: 'Direction', type: 'choice', options: Object.keys(DIRS), value: 'se' },
|
|
18
|
+
{ key: 'shift', label: 'Shift', type: 'range', min: 0.16, max: 0.4, step: 0.01, value: 0.28 },
|
|
19
|
+
{ key: 'copies', label: 'Copies', type: 'range', min: 1, max: 2, step: 1, value: 1 },
|
|
20
|
+
{ key: 'facing', label: 'Turn', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
|
|
21
|
+
{ key: 'spacing', label: 'Gap', type: 'range', min: 1, max: 1.6, step: 0.1, value: 1 },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
/** The mark for resolved params. */
|
|
25
|
+
export function build(p) {
|
|
26
|
+
const { x0, y0, size } = BOX, g = GAP * p.spacing, [dx, dy] = DIRS[p.dir] || DIRS.se, n = Math.round(p.copies);
|
|
27
|
+
const d = size * p.shift, s = size - d * n * 0.6, way = p.way;
|
|
28
|
+
const A = prim(p.shape, [x0, y0, s, s], Number(p.facing) / 90);
|
|
29
|
+
let acc = A, front = A;
|
|
30
|
+
for (let k = 1; k <= n; k++) {
|
|
31
|
+
const C = move(A, dx * d * k, dy * d * k);
|
|
32
|
+
if (way === 'shadow') acc = U(acc, D(C, grown(front, g)));
|
|
33
|
+
else { const both = I(front, C); const out = D(U(acc, C), grown(both, g / 2)); acc = way === 'keep' && both.length ? U(out, grow(both, -g / 2)) : out; }
|
|
34
|
+
front = way === 'shadow' ? U(front, C) : C;
|
|
35
|
+
}
|
|
36
|
+
return tidy(acc);
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Overlap: two unlike shapes crossing, with the house gap deciding how: one laid over the other and cut free by the
|
|
3
|
+
* gap, or the overlap itself knocked out (and, as a third way, kept as its own piece between them). The shapes sit on
|
|
4
|
+
* a diagonal, side by side or one above the other.
|
|
5
|
+
*/
|
|
6
|
+
import { U, D, I, grown, grow } from '@logomarks/core/geometry';
|
|
7
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
8
|
+
import { prim, unlike } from '../primitives.js';
|
|
9
|
+
|
|
10
|
+
// no ring or arch: a ring under another shape is an eye or a key, an arch under a disc a person
|
|
11
|
+
export const POOL = ['disc', 'square', 'triangle', 'half', 'quarter', 'leaf', 'diamond', 'hexagon', 'rsquare', 'pill', 'wedge'];
|
|
12
|
+
|
|
13
|
+
/** @type {import('../index.js').Control[]} */
|
|
14
|
+
export const controls = [
|
|
15
|
+
{ key: 'a', label: 'First shape', type: 'choice', options: POOL, value: 'disc' },
|
|
16
|
+
{ key: 'b', label: 'Second shape', type: 'choice', options: POOL, value: 'square' },
|
|
17
|
+
{ key: 'way', label: 'Overlap', type: 'choice', options: ['over', 'knock', 'keep'], value: 'over' },
|
|
18
|
+
{ key: 'layout', label: 'Arrangement', type: 'choice', options: ['diagonal', 'counter', 'row', 'column'], value: 'diagonal' },
|
|
19
|
+
{ key: 'size', label: 'Shape size', type: 'range', min: 0.56, max: 0.78, step: 0.01, value: 0.66 },
|
|
20
|
+
{ key: 'turnA', label: 'Turn first', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
|
|
21
|
+
{ key: 'turnB', label: 'Turn second', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
|
|
22
|
+
{ key: 'spacing', label: 'Gap', type: 'range', min: 1, max: 1.6, step: 0.1, value: 1 },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export const shapesOf = (p) => [p.a, unlike('overlap', p.a, p.b, POOL)];
|
|
26
|
+
|
|
27
|
+
/** The mark for resolved params. */
|
|
28
|
+
export function build(p) {
|
|
29
|
+
const { x0, y0, x1, y1, size, cx, cy } = BOX, [a, b] = shapesOf(p), s = size * p.size, g = GAP * p.spacing;
|
|
30
|
+
const boxes = p.layout === 'row' ? [[x0, cy - s / 2], [x1 - s, cy - s / 2]] : p.layout === 'column' ? [[cx - s / 2, y0], [cx - s / 2, y1 - s]] : p.layout === 'counter' ? [[x1 - s, y0], [x0, y1 - s]] : [[x0, y0], [x1 - s, y1 - s]];
|
|
31
|
+
const A = prim(a, [...boxes[0], s, s], Number(p.turnA) / 90), B = prim(b, [...boxes[1], s, s], Number(p.turnB) / 90);
|
|
32
|
+
if (p.way === 'over') return tidy(U(D(A, grown(B, g)), B));
|
|
33
|
+
const both = I(A, B);
|
|
34
|
+
if (!both.length) return tidy(U(A, B));
|
|
35
|
+
const out = D(U(A, B), grown(both, g / 2));
|
|
36
|
+
return tidy(p.way === 'keep' ? U(out, grow(both, -g / 2)) : out);
|
|
37
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Split pair: a block split down the middle, each half a DIFFERENT shape, the two facing each other across the house
|
|
3
|
+
* gap with their flat sides to the split. One half can slide along the split.
|
|
4
|
+
*/
|
|
5
|
+
import { U, rot, move } from '@logomarks/core/geometry';
|
|
6
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
7
|
+
import { prim, unlike } from '../primitives.js';
|
|
8
|
+
|
|
9
|
+
export const POOL = ['half', 'quarter', 'wedge', 'square', 'triangle', 'rsquare', 'leaf', 'hexagon'];
|
|
10
|
+
/** The turn that puts each shape's flat side to the right (a mirror puts it to the left). */
|
|
11
|
+
const FACE = { half: 1, triangle: 1, quarter: 0, wedge: 3, arch: 1, square: 0, rsquare: 0, leaf: 0, hexagon: 0 };
|
|
12
|
+
|
|
13
|
+
/** @type {import('../index.js').Control[]} */
|
|
14
|
+
export const controls = [
|
|
15
|
+
{ key: 'a', label: 'First half', type: 'choice', options: POOL, value: 'half' },
|
|
16
|
+
{ key: 'b', label: 'Second half', type: 'choice', options: POOL, value: 'quarter' },
|
|
17
|
+
{ key: 'at', label: 'Split', type: 'range', min: 0.36, max: 0.64, step: 0.01, value: 0.5 },
|
|
18
|
+
{ key: 'flipA', label: 'Flip first', type: 'choice', options: ['no', 'yes'], value: 'no' },
|
|
19
|
+
{ key: 'flipB', label: 'Flip second', type: 'choice', options: ['no', 'yes'], value: 'no' },
|
|
20
|
+
{ key: 'slide', label: 'Slide', type: 'range', min: 0, max: 0.3, step: 0.01, value: 0 },
|
|
21
|
+
{ key: 'spin', label: 'Spin', type: 'choice', options: ['0', '45', '90', '135', '180', '270'], value: '0' },
|
|
22
|
+
{ key: 'spacing', label: 'Gap', type: 'range', min: 1, max: 2, step: 0.1, value: 1 },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export const shapesOf = (p) => [p.a, unlike('pair', p.a, p.b, POOL)];
|
|
26
|
+
|
|
27
|
+
/** A half-shape in `box`, flat side to the right, flipped top to bottom with `flip`. */
|
|
28
|
+
function facing(type, box, flip) {
|
|
29
|
+
let s = prim(type, box, FACE[type] ?? 0);
|
|
30
|
+
if (flip) s = mapY(s, box[1] + box[3] / 2);
|
|
31
|
+
return s;
|
|
32
|
+
}
|
|
33
|
+
const mapY = (s, cy) => (typeof s[0][0][0] === 'number' ? [s] : s).map((pg) => pg.map((r) => r.map(([x, y]) => [x, 2 * cy - y])));
|
|
34
|
+
|
|
35
|
+
/** The mark for resolved params. */
|
|
36
|
+
export function build(p) {
|
|
37
|
+
const { x0, y0, size, cx, cy } = BOX, [a, b] = shapesOf(p), g = GAP * p.spacing, wa = (size - g) * p.at, wb = size - g - wa;
|
|
38
|
+
const A = facing(a, [x0, y0, wa, size], p.flipA === 'yes');
|
|
39
|
+
// the second half is the first's mirror image in the split: drawn facing right, then flipped left to right
|
|
40
|
+
const Bbox = [x0 + wa + g, y0, wb, size], bcx = Bbox[0] + wb / 2;
|
|
41
|
+
let B = facing(b, Bbox, p.flipB === 'yes');
|
|
42
|
+
B = (typeof B[0][0][0] === 'number' ? [B] : B).map((pg) => pg.map((r) => r.map(([x, y]) => [2 * bcx - x, y])));
|
|
43
|
+
const d = size * p.slide;
|
|
44
|
+
return tidy(rot(U(move(A, 0, -d / 2), move(B, 0, d / 2)), Number(p.spin), cx, cy));
|
|
45
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quarters: a two by two grid of big cells, each a primitive, the four turned by ONE rule (all the same way, a quarter
|
|
3
|
+
* turn on from cell to cell, mirrored across the middle, or all facing in or out). Two to four different shapes fill
|
|
4
|
+
* it by a pattern. No more than two cells fill their inner corner, so the gap between them is never a plus.
|
|
5
|
+
*/
|
|
6
|
+
import { U, I, rect } from '@logomarks/core/geometry';
|
|
7
|
+
import { BOX, GAP, tidy } from '../draw.js';
|
|
8
|
+
import { prim, alike } from '../primitives.js';
|
|
9
|
+
|
|
10
|
+
export const POOL = ['quarter', 'wedge', 'half', 'leaf', 'triangle', 'disc', 'square', 'diamond', 'rsquare'];
|
|
11
|
+
/** Which of the four chosen shapes each cell takes (top left, top right, bottom right, bottom left). */
|
|
12
|
+
const PATTERNS = { four: [0, 1, 2, 3], diagonal: [0, 1, 0, 1], rows: [0, 0, 1, 1], three: [0, 1, 2, 1] };
|
|
13
|
+
|
|
14
|
+
/** @type {import('../index.js').Control[]} */
|
|
15
|
+
export const controls = [
|
|
16
|
+
{ key: 'a', label: 'Shape 1', type: 'choice', options: POOL, value: 'quarter' },
|
|
17
|
+
{ key: 'b', label: 'Shape 2', type: 'choice', options: POOL, value: 'wedge' },
|
|
18
|
+
{ key: 'c', label: 'Shape 3', type: 'choice', options: POOL, value: 'disc' },
|
|
19
|
+
{ key: 'd', label: 'Shape 4', type: 'choice', options: POOL, value: 'leaf' },
|
|
20
|
+
{ key: 'pattern', label: 'Pattern', type: 'choice', options: Object.keys(PATTERNS), value: 'four' },
|
|
21
|
+
{ key: 'rule', label: 'Turn rule', type: 'choice', options: ['same', 'rotate', 'mirror', 'in', 'out'], value: 'rotate' },
|
|
22
|
+
{ key: 'start', label: 'First turn', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
|
|
23
|
+
{ key: 'spacing', label: 'Gap', type: 'range', min: 1, max: 1.8, step: 0.1, value: 1 },
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
/** The four shapes as drawn: each steered off any before it that it reads like. */
|
|
27
|
+
export function shapesOf(p) {
|
|
28
|
+
const out = [];
|
|
29
|
+
for (const s of [p.a, p.b, p.c, p.d]) {
|
|
30
|
+
let c = s;
|
|
31
|
+
for (let k = 0; k < POOL.length && out.some((o) => alike(o, c)); k++) c = POOL[(POOL.indexOf(c) + 1) % POOL.length];
|
|
32
|
+
out.push(c);
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The mark for resolved params. */
|
|
38
|
+
export function build(p) {
|
|
39
|
+
const { x0, y0, size } = BOX, g = GAP * p.spacing, c = (size - g) / 2, shapes = shapesOf(p), t0 = Number(p.start) / 90;
|
|
40
|
+
const at = [[x0, y0], [x0 + c + g, y0], [x0 + c + g, y0 + c + g], [x0, y0 + c + g]];
|
|
41
|
+
// the turn that brings a shape's bottom-left corner to the grid's middle, for each cell
|
|
42
|
+
const inward = [1, 2, 3, 0];
|
|
43
|
+
const pick = PATTERNS[p.pattern] || PATTERNS.four;
|
|
44
|
+
let filled = 0;
|
|
45
|
+
const cells = at.map(([x, y], i) => {
|
|
46
|
+
// two discs never share a row (a pair of eyes): in the rows pattern a disc gives way to a leaf
|
|
47
|
+
const type = p.pattern === 'rows' && shapes[pick[i]] === 'disc' ? 'leaf' : shapes[pick[i]];
|
|
48
|
+
let turn = p.rule === 'rotate' ? t0 + i : p.rule === 'in' ? inward[i] + t0 * 0 : p.rule === 'out' ? inward[i] + 2 : p.rule === 'mirror' ? t0 : t0;
|
|
49
|
+
const mirror = p.rule === 'mirror' && (i === 1 || i === 2), flip = p.rule === 'mirror' && i >= 2;
|
|
50
|
+
const drawn = (tn) => prim(type, [x, y, c, c], tn + (flip ? (tn % 2 ? 0 : 0) : 0), mirror);
|
|
51
|
+
// the cell's inner corner: a small probe there says whether the shape fills it
|
|
52
|
+
const px = i === 0 || i === 3 ? x + c - 14 : x, py = i < 2 ? y + c - 14 : y, probe = rect(px, py, 14, 14);
|
|
53
|
+
const fills = (s) => I(s, probe).reduce((t, pg) => t + Math.abs(area(pg[0])), 0) > 14 * 14 * 0.6;
|
|
54
|
+
let s = drawn(turn);
|
|
55
|
+
if (flip) s = flipY(s, y + c / 2);
|
|
56
|
+
if (fills(s)) {
|
|
57
|
+
if (filled >= 2) { for (let k = 1; k < 4 && fills(s); k++) { s = drawn(turn + k); if (flip) s = flipY(s, y + c / 2); } if (fills(s)) s = prim('disc', [x, y, c, c]); }
|
|
58
|
+
if (fills(s)) filled++;
|
|
59
|
+
}
|
|
60
|
+
return s;
|
|
61
|
+
});
|
|
62
|
+
return tidy(U(...cells));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const area = (r) => { let t = 0; for (let i = 0; i < r.length; i++) { const [x1, y1] = r[i], [x2, y2] = r[(i + 1) % r.length]; t += x1 * y2 - x2 * y1; } return t / 2; };
|
|
66
|
+
const flipY = (s, cy) => (typeof s[0][0][0] === 'number' ? [s] : s).map((pg) => pg.map((r) => r.map(([x, y]) => [x, 2 * cy - y])));
|
package/src/recipes/stack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Stack:
|
|
2
|
+
* Stack: a totem. Two to four primitive shapes laid out as a stack, a row, a grid, overlapping, nested or staggered, combined by
|
|
3
3
|
* ONE rule: kept apart by the house gap, laid over the one before with a gap round them, cut out of it, merged, or
|
|
4
4
|
* exclusive-or. Two shapes (A and B) and an order spread them over the slots; each can be turned. After marks that
|
|
5
5
|
* stack and tweak simple shapes together.
|
|
@@ -8,6 +8,7 @@ import { U, D, X, rot } from '@logomarks/core/geometry';
|
|
|
8
8
|
import { over } from '@logomarks/core/geometry';
|
|
9
9
|
import { BOX, GAP, clear } from '../draw.js';
|
|
10
10
|
import { primitive, PRIMITIVES } from '../shapes.js';
|
|
11
|
+
import { BANNED } from '../primitives.js';
|
|
11
12
|
|
|
12
13
|
const TURNS = ['0', '90', '180', '270'];
|
|
13
14
|
|
|
@@ -15,11 +16,13 @@ const TURNS = ['0', '90', '180', '270'];
|
|
|
15
16
|
export const controls = [
|
|
16
17
|
{ key: 'layout', label: 'Layout', type: 'choice', options: ['stack', 'row', 'grid', 'overlap', 'nest', 'stagger'], value: 'stack' },
|
|
17
18
|
{ key: 'count', label: 'Shapes', type: 'range', min: 2, max: 4, step: 1, value: 3 },
|
|
18
|
-
{ key: 'shapeA', label: 'Shape A', type: 'choice', options: PRIMITIVES, value: '
|
|
19
|
+
{ key: 'shapeA', label: 'Shape A', type: 'choice', options: PRIMITIVES, value: 'quarter' },
|
|
19
20
|
{ key: 'turnA', label: 'Turn A', type: 'choice', options: TURNS, value: '0' },
|
|
20
|
-
{ key: 'shapeB', label: 'Shape B', type: 'choice', options: PRIMITIVES, value: '
|
|
21
|
+
{ key: 'shapeB', label: 'Shape B', type: 'choice', options: PRIMITIVES, value: 'parallelogram' },
|
|
21
22
|
{ key: 'turnB', label: 'Turn B', type: 'choice', options: TURNS, value: '180' },
|
|
22
|
-
{ key: '
|
|
23
|
+
{ key: 'shapeC', label: 'Shape C', type: 'choice', options: PRIMITIVES, value: 'half' },
|
|
24
|
+
{ key: 'turnC', label: 'Turn C', type: 'choice', options: TURNS, value: '0' },
|
|
25
|
+
{ key: 'order', label: 'Order', type: 'choice', options: ['AB', 'AAB', 'ABB', 'ABA', 'A', 'ABC'], value: 'AB' },
|
|
23
26
|
{ key: 'step', label: 'Turn each', type: 'choice', options: ['none', 'quarter', 'half'], value: 'none' },
|
|
24
27
|
{ key: 'combine', label: 'Combine', type: 'choice', options: ['gap', 'over', 'cut', 'merge', 'xor'], value: 'gap' },
|
|
25
28
|
{ key: 'size', label: 'Shape size', type: 'range', min: 0.5, max: 1, step: 0.01, value: 1 },
|
|
@@ -50,14 +53,32 @@ function which(order, i) {
|
|
|
50
53
|
return order === 'A' ? 'A' : order[i % order.length] || 'A';
|
|
51
54
|
}
|
|
52
55
|
|
|
56
|
+
/** Why two shapes never sit next to each other in a stack or a row ('' when they may): a disc over a block is a person. */
|
|
57
|
+
const clash = (a, b) => (BANNED.stack.find(([p, q]) => (p === a && q === b) || (p === b && q === a)) || [])[2] || '';
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The shape in each slot, in order: A, B and C by the order, then steered: in the ABC order no two the same, and in a
|
|
61
|
+
* stack, a row or a stagger no shape beside one it reads as an object with (the next shape of the list takes its place).
|
|
62
|
+
*/
|
|
63
|
+
export function shapesOf(p) {
|
|
64
|
+
const n = Math.round(p.count), named = { A: p.shapeA, B: p.shapeB, C: p.shapeC || p.shapeA };
|
|
65
|
+
const out = Array.from({ length: n }, (_, i) => named[which(p.order, i)]);
|
|
66
|
+
if (!['stack', 'row', 'stagger', 'grid'].includes(p.layout)) return out;
|
|
67
|
+
for (let i = 1; i < n; i++) {
|
|
68
|
+
const bad = (c) => clash(out[i - 1], c) || (p.order === 'ABC' && out.slice(0, i).includes(c));
|
|
69
|
+
for (let k = 0; k < PRIMITIVES.length && bad(out[i]); k++) out[i] = PRIMITIVES[(PRIMITIVES.indexOf(out[i]) + 1) % PRIMITIVES.length];
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
|
|
53
74
|
/** The mark for resolved params. */
|
|
54
75
|
export function build(p) {
|
|
55
|
-
const boxes = slots(p.layout, p.count, p.overlap);
|
|
76
|
+
const boxes = slots(p.layout, p.count, p.overlap), shapes = shapesOf(p);
|
|
56
77
|
const parts = boxes.map(([x, y, w, h], i) => {
|
|
57
78
|
const k = which(p.order, i), shrink = p.layout === 'nest' ? 1 : p.size;
|
|
58
79
|
const bw = w * shrink, bh = h * shrink, bx = x + (w - bw) / 2, by = y + (h - bh) / 2;
|
|
59
80
|
const extra = p.step === 'quarter' ? i : p.step === 'half' ? 2 * i : 0;
|
|
60
|
-
return primitive(
|
|
81
|
+
return primitive(shapes[i], bx, by, bw, bh, Number(k === 'A' ? p.turnA : k === 'B' ? p.turnB : p.turnC || 0) / 90 + extra);
|
|
61
82
|
});
|
|
62
83
|
let acc = parts[0];
|
|
63
84
|
for (const s of parts.slice(1)) {
|
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
|
@@ -12,7 +12,9 @@ export const TUNING = {
|
|
|
12
12
|
bars: { count: R(2, 4), weight: R(0.58, 0.8), cutSize: R(0.1, 0.2), cutAt: R(0.35, 0.65), lengths: { rare: 0.3 }, ends: { rare: 0.25 }, slant: rare(0.15, -20, 20), level: { rare: 0.1 }, cutAngle: rare(0.25, -35, 35), spine: { rare: 0.2 }, widths: { rare: 0.08, random: ['growing', 'thin-thick'] } },
|
|
13
13
|
bands: { count: R(2, 3), weight: R(0.6, 0.8), ends: { rare: 0.3 }, slant: rare(0.15, -18, 18) },
|
|
14
14
|
twin: { thickness: R(0.3, 0.42), slant: rare(0.3, -22, 22) },
|
|
15
|
-
|
|
15
|
+
// a totem: three unlike shapes on one axis, the gap between (nests and overlaps threw outlines, eyes and busts: by hand only)
|
|
16
|
+
stack: { layout: of('stack', 'stack', 'row', 'stagger'), count: R(2, 3), order: of('ABC', 'ABC', 'ABA', 'AB'), step: { rare: 0.15 }, combine: of('gap'), size: rare(0.2, 0.8, 1), overlap: R(0.2, 0.45),
|
|
17
|
+
shapeA: of('square', 'half', 'quarter', 'triangle', 'parallelogram', 'pill', 'chevron', 'diamond', 'leaf', 'circle'), shapeB: of('square', 'half', 'quarter', 'triangle', 'parallelogram', 'pill', 'chevron', 'diamond', 'leaf', 'circle'), shapeC: of('square', 'half', 'quarter', 'triangle', 'parallelogram', 'pill', 'chevron', 'diamond', 'leaf', 'circle') },
|
|
16
18
|
shear: { rows: R(1, 2), cols: R(2, 3), lean: of('same', 'rows', 'chevron'), angle: R(18, 32), drop: { rare: 0.25 }, spacing: R(1, 1.5), taper: rare(0.12, 0.1, 0.3), lengths: { rare: 0.3 }, slide: rare(0.2, 0.15, 0.4) },
|
|
17
19
|
turns: { count: of('3', '4', '5', '6'), size: R(0.32, 0.46), stretch: rare(0.3, 0.8, 1.4), radius: R(0.06, 0.26), tilt: rare(0.35, -30, 30) },
|
|
18
20
|
burst: { rays: R(5, 10), ray: of('bar', 'wedge', 'pill', 'drop'), width: R(0.1, 0.18), inner: R(0.06, 0.28), alternate: rare(0.2, 0.2, 0.45), twist: rare(0.2, -30, 30), move: { rare: 0.35 } },
|
|
@@ -25,7 +27,6 @@ export const TUNING = {
|
|
|
25
27
|
waves: { count: R(2, 4), weight: R(0.55, 0.8), amplitude: R(0.05, 0.13), waves: R(0.75, 1.5), phase: rare(0.15, 30, 180), clip: { rare: 0.35 } },
|
|
26
28
|
cut: { second: { rare: 0.2 } },
|
|
27
29
|
split: { cuts: R(1, 2), twist: rare(0.15, 2, 6), spacing: R(1, 2) },
|
|
28
|
-
venn: { count: R(2, 3), shape: of('circle', 'circle', 'rounded'), layout: of('row', 'triangle'), combine: of('xor', 'knockout'), overlap: R(0.28, 0.5) },
|
|
29
30
|
spiral: { turns: R(1.25, 2.5), tail: rare(0.3, 0.2, 0.5), squash: rare(0.2, 0.75, 0.9) },
|
|
30
31
|
bloom: { petals: R(4, 8), width: R(0.4, 0.8), twist: rare(0.25, -35, 35) },
|
|
31
32
|
links: { weight: R(0.1, 0.16) },
|
|
@@ -35,20 +36,27 @@ export const TUNING = {
|
|
|
35
36
|
iso: { grid: R(2, 3), height: R(1, 2), density: R(0.5, 1) },
|
|
36
37
|
letter: { build: of('stencil', 'route', 'blocks'), weight: R(0.17, 0.26), slant: rare(0.12, -12, 12), spacing: R(1, 1.6) },
|
|
37
38
|
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:
|
|
39
|
+
halfsq: { grid: of('2x2'), rule: of('rows', 'same', 'checker', 'zigzag', 'diagonal'), spacing: R(1, 1.3) },
|
|
39
40
|
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
41
|
leaves: { softness: rare(0.3, 0.6, 1), spacing: rare(0.3, 0.8, 1.6), centre: { rare: 0.2 } },
|
|
41
|
-
lobes: {
|
|
42
|
+
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
43
|
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('
|
|
44
|
+
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) },
|
|
45
|
+
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
46
|
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
47
|
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
48
|
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
49
|
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
50
|
flare: { rays: R(3, 5), inner: R(0.16, 0.3), spacing: R(1.2, 2), body: of('square', 'square', 'round') },
|
|
50
51
|
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
|
-
|
|
52
|
+
// the composition recipes: the shapes are drawn evenly from their pools (a banned pair is steered in the build)
|
|
53
|
+
merge: { at: R(0.4, 0.6), width: R(0.45, 0.78) },
|
|
54
|
+
overlap: { way: of('over', 'over', 'knock', 'keep'), layout: of('diagonal', 'counter', 'row'), size: R(0.6, 0.74), spacing: R(1, 1.3) },
|
|
55
|
+
counter: { size: R(0.34, 0.5), place: of('centre', 'corner', 'side', 'low', 'high') },
|
|
56
|
+
pair: { at: R(0.4, 0.6), slide: rare(0.3, 0.12, 0.28), spin: of('0', '0', '90', '45', '135'), spacing: R(1, 1.5) },
|
|
57
|
+
corners: { reach: R(0.3, 0.5), second: rare(0.4, 0.5, 0.8), shape: of('square', 'square', 'square', 'wide', 'tall') },
|
|
58
|
+
offset: { way: of('shadow', 'shadow', 'knock', 'keep'), shift: R(0.2, 0.36), copies: R(1, 1), spacing: R(1, 1.3) },
|
|
59
|
+
quarters: { pattern: of('four', 'four', 'diagonal', 'three', 'rows'), spacing: R(1, 1.4) },
|
|
52
60
|
};
|
|
53
61
|
|
|
54
62
|
/** The two to four controls of each recipe that decide the mark: a page shows these first, the rest under "More". */
|
|
@@ -57,11 +65,14 @@ export const MAIN = {
|
|
|
57
65
|
shear: ['rows', 'cols', 'lean', 'angle'], turns: ['unit', 'count', 'size', 'join'], burst: ['rays', 'ray', 'width', 'inner'], tiles: ['grid', 'layout', 'set', 'symmetry'],
|
|
58
66
|
route: ['layout', 'steps', 'weight', 'node'], arcs: ['count', 'sweep', 'weight', 'legs'], rings: ['count', 'weight', 'gaps', 'shape'], stripes: ['shape', 'stripes', 'angle', 'move'],
|
|
59
67
|
chevrons: ['count', 'angle', 'weight', 'point'], waves: ['count', 'weight', 'amplitude', 'clip'], cut: ['body', 'cut', 'side', 'size'], split: ['shape', 'cuts', 'angle', 'slide'],
|
|
60
|
-
|
|
68
|
+
spiral: ['turns', 'weight', 'start'], bloom: ['petals', 'petal', 'width', 'centre'], links: ['count', 'loop', 'layout', 'weight'],
|
|
61
69
|
horizon: ['sun', 'size', 'lines', 'style'], steps: ['count', 'shape', 'tread'], hex: ['layout', 'density', 'symmetry'],
|
|
62
70
|
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'],
|
|
71
|
+
arcstep: ['layout', 'steps', 'weight', 'corners'], halfsq: ['grid', 'rule', 'facing'], invert: ['count', 'weight', 'region', 'angle'], leaves: ['tile', 'order', 'facing'],
|
|
72
|
+
lobes: ['body', 'pieces', 'cuts', 'bend'], loops: ['petals', 'weight', 'spread', 'centre'], trine: ['body', 'offset', 'depth'],
|
|
73
|
+
strips: ['layout', 'weight', 'angle'], bite: ['place', 'size', 'depth', 'body'], blades: ['count', 'grow', 'width', 'belly'],
|
|
74
|
+
wavecut: ['body', 'move', 'waves', 'swell'], capsules: ['count', 'lengths', 'lean'], flare: ['origin', 'rays', 'body'], seam: ['joint', 'body', 'size', 'reach'],
|
|
75
|
+
merge: ['a', 'b', 'width', 'side'], overlap: ['a', 'b', 'way', 'layout'], counter: ['body', 'hole', 'size', 'place'], pair: ['a', 'b', 'at', 'spin'],
|
|
76
|
+
corners: ['nw', 'ne', 'se', 'sw'],
|
|
77
|
+
offset: ['shape', 'way', 'dir', 'shift'], quarters: ['a', 'b', 'pattern', 'rule'],
|
|
67
78
|
};
|
package/src/recipes/pixelarc.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pixel Curve: one bold curve drawn in square pixels on a coarse grid, so its edge climbs in steps: a quarter band, an
|
|
3
|
-
* arch, a hook or an S. Two or three pixels thick, one or two bands; never crumbs, and never a ring round a block.
|
|
4
|
-
*/
|
|
5
|
-
import { U, rect } from '@logomarks/core/geometry';
|
|
6
|
-
import { BOX } from '../draw.js';
|
|
7
|
-
|
|
8
|
-
/** @type {import('../index.js').Control[]} */
|
|
9
|
-
export const controls = [
|
|
10
|
-
{ key: 'curve', label: 'Curve', type: 'choice', options: ['quarter', 'arch', 'hook', 'ess'], value: 'quarter' },
|
|
11
|
-
{ key: 'grid', label: 'Pixels', type: 'range', min: 6, max: 12, step: 1, value: 8 },
|
|
12
|
-
{ key: 'weight', label: 'Weight', type: 'range', min: 0.2, max: 0.42, step: 0.01, value: 0.3 },
|
|
13
|
-
{ key: 'bands', label: 'Bands', type: 'range', min: 1, max: 2, step: 1, value: 1 },
|
|
14
|
-
{ key: 'facing', label: 'Facing', type: 'choice', options: ['0', '90', '180', '270'], value: '0' },
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
/** Whether the point (u, v) of the unit square (v down) is ink. */
|
|
18
|
-
function ink(p, u, v) {
|
|
19
|
-
const t = p.weight, bands = p.bands, inBand = (r, R) => {
|
|
20
|
-
// one band t wide ending at R, or two with a pixel-wide gap between, sharing that width
|
|
21
|
-
if (bands === 1) return r <= R && r > R - t;
|
|
22
|
-
const w = t * 0.62, gap = Math.max(1 / p.grid, t * 0.3);
|
|
23
|
-
return (r <= R && r > R - w) || (r <= R - w - gap && r > R - 2 * w - gap);
|
|
24
|
-
};
|
|
25
|
-
const core = () => false;
|
|
26
|
-
if (p.curve === 'quarter') { const r = Math.hypot(u, 1 - v); return inBand(r, 1) || core(r, 1); }
|
|
27
|
-
if (p.curve === 'arch') { const r = Math.hypot(u - 0.5, Math.max(0, 0.5 - v) ), x = Math.abs(u - 0.5); return v <= 0.5 ? inBand(r, 0.5) || core(r, 0.5) : inBand(x, 0.5) || core(x, 0.5); }
|
|
28
|
-
// a hook: an arch upside down whose right leg stops halfway
|
|
29
|
-
if (p.curve === 'hook') { const r = Math.hypot(u - 0.5, Math.max(0, v - 0.5)), x = Math.abs(u - 0.5); return v >= 0.5 ? inBand(r, 0.5) : u < 0.5 ? inBand(x, 0.5) : v > 0.3 && inBand(x, 0.5); }
|
|
30
|
-
// an S: two half rings, the upper open to the right's left, the lower mirrored
|
|
31
|
-
const top = v < 0.5, r = Math.hypot(u - 0.5, v - (top ? 0.27 : 0.73)), R = 0.27;
|
|
32
|
-
const open = top ? u > 0.5 && v > 0.27 : u < 0.5 && v < 0.73;
|
|
33
|
-
return !open && r <= R && r > R - Math.min(t * 0.6, 0.17);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** The mark for resolved params. */
|
|
37
|
-
export function build(p) {
|
|
38
|
-
const n = p.grid, s = BOX.size / n, parts = [], q = Number(p.facing) / 90;
|
|
39
|
-
for (let r = 0; r < n; r++) {
|
|
40
|
-
let start = -1;
|
|
41
|
-
for (let c = 0; c <= n; c++) {
|
|
42
|
-
// the cell (r, c) seen from the facing: the grid turned by quarter turns
|
|
43
|
-
let u = (c + 0.5) / n, v = (r + 0.5) / n;
|
|
44
|
-
for (let k = 0; k < q; k++) [u, v] = [v, 1 - u];
|
|
45
|
-
const on = c < n && ink(p, u, v);
|
|
46
|
-
if (on && start < 0) start = c;
|
|
47
|
-
if (!on && start >= 0) { parts.push(rect(BOX.x0 + start * s, BOX.y0 + r * s - 0.01, (c - start) * s, s + 0.02)); start = -1; }
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return parts.length ? U(...parts) : [];
|
|
51
|
-
}
|