/* patent drawings, one per post. each returns { spot, line } svg fragments in a 400×400 box.
'spot' prints in the second ink, 'line' in the first. labels are part numbers, like a filing. */
const D = (() => {
const r = n => Math.round(n * 10) / 10;
const L = (x1, y1, x2, y2, c = '') => ``;
const P = (d, c = '') => ``;
const E = (cx, cy, rx, ry, c = '', rot = 0) => ``;
const R = (x, y, w, h, c = '', rx = 0) => ``;
const C = (cx, cy, rr, c = '') => ``;
// a part number with a wiggly leader line
const tag = (x, y, tx, ty, t) => {
const mx = (x + tx) / 2 + (ty - y) * .18, my = (y + ty) / 2 - (tx - x) * .18;
return `${t}`;
};
// seeded random so drawings are stable
let seed = 7; const rnd = () => (seed = (seed * 16807) % 2147483647) / 2147483647;
return {
// Building UI in GPUI — an open laptop
laptop() {
let keys = '';
for (let row = 0; row < 5; row++) {
const y = 228 + row * 11, inset = row * 3;
const n = 13 - (row === 4 ? 4 : 0);
const x0 = 96 + inset, w = (208 - inset * 2) / n;
for (let k = 0; k < n; k++) keys += R(x0 + k * w + 1, y, w - 3, 8, 'k', 1.5);
}
return {
spot: R(113, 73, 174, 114, '', 4) + R(165, 286, 70, 18, '', 3),
line: R(98, 58, 204, 144, '', 10) + R(113, 73, 174, 114, '', 4) +
P('M80 212 L320 212 L348 312 L52 312 Z') + P('M52 312 L52 320 L348 320 L348 312') + keys +
R(165, 286, 70, 18, '', 3) + L(98, 202, 80, 212) + L(302, 202, 320, 212) +
P('M130 90 C170 130 140 160 200 140 S250 100 270 170', 'scrib') + P('M125 160 C160 110 230 180 280 95', 'scrib') +
C(200, 66, 2) + tag(260, 120, 345, 70, '12') + tag(220, 245, 360, 230, '14') + tag(200, 300, 120, 360, '16') + tag(325, 300, 370, 350, '18'),
};
},
// Spool — flanges, core, wound thread
spool() {
let wraps = '';
for (let y = 128; y <= 292; y += 7) wraps += P(`M${120} ${y} A80 18 0 0 0 280 ${y}`, 'thin');
return {
spot: P('M120 118 A80 18 0 0 0 280 118 L280 300 A80 18 0 0 1 120 300 Z'),
line: E(200, 92, 112, 28) + E(200, 106, 112, 28, 'hid') + L(88, 92, 88, 106) + L(312, 92, 312, 106) + E(200, 92, 16, 5) +
L(120, 118, 120, 300) + L(280, 118, 280, 300) + wraps +
E(200, 316, 112, 28, 'hid') + P('M88 316 A112 28 0 0 0 312 316') + P('M88 330 A112 28 0 0 0 312 330') + L(88, 316, 88, 330) + L(312, 316, 312, 330) +
P('M280 210 C320 230 330 260 360 250 S380 300 350 330', '') +
tag(170, 92, 60, 40, '20') + tag(250, 200, 360, 160, '22') + tag(312, 323, 360, 375, '24') + tag(355, 330, 300, 380, '26'),
};
},
// Ferrotype — a gear (rust) projected onto a tintype plate (typescript)
plate() {
let teeth = '';
for (let i = 0; i < 12; i++) {
const a = i / 12 * Math.PI * 2, a2 = a + .14;
teeth += P(`M${r(100 + Math.cos(a - .12) * 48)} ${r(150 + Math.sin(a - .12) * 48)} L${r(100 + Math.cos(a - .1) * 60)} ${r(150 + Math.sin(a - .1) * 60)} L${r(100 + Math.cos(a2) * 60)} ${r(150 + Math.sin(a2) * 60)} L${r(100 + Math.cos(a2 + .03) * 48)} ${r(150 + Math.sin(a2 + .03) * 48)}`);
}
return {
spot: E(268, 232, 52, 66, '', -8),
line: C(100, 150, 48) + C(100, 150, 16) + teeth +
P('M190 140 L350 112 Q362 110 364 122 L378 310 Q379 322 367 324 L206 352 Q194 354 192 342 L178 154 Q177 142 190 140 Z') +
P('M364 122 L372 128 L386 316 L378 310') + E(268, 232, 52, 66, '', -8) + E(268, 232, 60, 74, 'hid', -8) +
`T` +
P('M150 150 C170 150 180 170 210 180', 'hid arrow') + P('M150 170 C175 190 190 220 222 222', 'hid arrow') +
tag(100, 120, 40, 60, '30') + tag(340, 140, 380, 70, '32') + tag(268, 290, 230, 385, '34') + tag(190, 175, 165, 250, '36'),
};
},
// CSS Grid Lanes — masonry columns packing to the shortest
lanes() {
const cols = [[60, 90, 50], [110, 40, 70, 40], [45, 120, 60], [80, 60, 90]];
let line = '', spot = '';
cols.forEach((c, i) => {
let y = 70; const x = 60 + i * 74;
c.forEach((h, j) => {
line += R(x, y, 64, h - 6, '', 3);
if ((i + j) % 3 === 0) spot += R(x, y, 64, h - 6, '', 3);
y += h;
});
line += L(x + 32, y + 4, x + 32, y + 26, 'hid');
});
line += L(60, 52, 350, 52) + L(60, 46, 60, 58) + L(350, 46, 350, 58) + L(124, 46, 124, 58);
line += P('M134 306 L134 330 M60 330 L350 330', 'hid');
return { spot, line: line + tag(200, 120, 380, 110, '40') + tag(134, 52, 150, 22, '42') + tag(270, 300, 370, 370, '44') + tag(90, 210, 20, 260, '46') };
},
// The Black Magic of Canvas and Text Editing — a bezier, its handles, and a cursor
bezier() {
return {
spot: P('M60 300 C110 120 230 120 260 220 S330 330 360 160 L360 330 L60 330 Z'),
line: P('M60 300 C110 120 230 120 260 220 S330 330 360 160') +
L(60, 300, 110, 120, 'hid') + L(230, 120, 260, 220, 'hid') + L(260, 220, 290, 320, 'hid') + L(330, 330, 360, 160, 'hid') +
R(54, 294, 12, 12) + R(254, 214, 12, 12) + R(354, 154, 12, 12) + C(110, 120, 6) + C(230, 120, 6) + C(290, 320, 6) + C(330, 330, 6) +
`Aa` + L(70, 96, 210, 96, 'thin') + L(70, 62, 210, 62, 'hid') + L(70, 40, 210, 40, 'hid') +
L(226, 40, 226, 104) + L(218, 40, 234, 40) + L(218, 104, 234, 104) +
tag(110, 120, 40, 170, '50') + tag(260, 220, 330, 260, '52') + tag(226, 70, 300, 60, '54') + tag(160, 200, 140, 260, '56'),
};
},
// fig-gen — a tall frame of sine-placed dashes
sine() {
let dashes = '';
for (let i = 0; i < 64; i++) {
const y = 52 + i * 4.6;
const x = 200 + Math.sin(i * .31) * 46 * Math.cos(i * .07) + Math.tan(i * .05) * 3;
const w = 4 + (Math.sin(i * 1.7) * .5 + .5) * 18;
dashes += L(x - w / 2, y, x + w / 2, y, 'thin');
}
let curve = 'M60 200';
for (let x = 60; x <= 340; x += 6) curve += ` L${x} ${r(200 - Math.sin((x - 60) / 280 * Math.PI * 3) * 40)}`;
return {
spot: R(140, 40, 120, 320),
line: R(140, 40, 120, 320) + dashes + P(curve, 'hid') + L(40, 200, 360, 200, 'thin') + L(40, 196, 40, 204) +
tag(140, 80, 70, 60, '60') + tag(220, 260, 330, 300, '62') + tag(300, 160, 360, 110, '64') + `sin(i)`,
};
},
// Writing with ADHD — the eclipse, its orbits all crossing
eclipse() {
seed = 11;
let orbits = '';
for (let i = 0; i < 16; i++) {
const rx = 40 + rnd() * 150, ry = 6 + rnd() * 40;
orbits += E(200 + (rnd() - .5) * 60, 200 + (rnd() - .5) * 60, rx, ry, 'thin', rnd() * 180);
}
for (let i = 0; i < 9; i++) {
const a = rnd() * Math.PI, l = 60 + rnd() * 120;
orbits += L(200 - Math.cos(a) * l, 200 - Math.sin(a) * l, 200 + Math.cos(a) * l * .8, 200 + Math.sin(a) * l * .8, 'thin');
}
return {
spot: ``,
line: C(200, 200, 112, 'solid') + orbits + tag(300, 140, 370, 60, '70') + tag(110, 260, 40, 340, '72'),
};
},
// Design Workshop — a voxel stack
voxels() {
const s = 34, h = s * .58;
const cube = (cx, cy, fill) => {
const top = `M${cx} ${cy - h} L${cx + s} ${cy} L${cx} ${cy + h} L${cx - s} ${cy} Z`;
const lf = `M${cx - s} ${cy} L${cx} ${cy + h} L${cx} ${cy + h + s * 1.1} L${cx - s} ${cy + s * 1.1} Z`;
const rf = `M${cx + s} ${cy} L${cx} ${cy + h} L${cx} ${cy + h + s * 1.1} L${cx + s} ${cy + s * 1.1} Z`;
return { line: P(top) + P(lf) + P(rf), spot: fill ? P(top) : '' };
};
const spots = [[0, 0, 0], [1, 0, 0], [0, 1, 0], [2, 0, 0], [1, 1, 0], [0, 2, 0], [1, 0, 1], [0, 1, 1], [0, 0, 1], [0, 0, 2], [2, 1, 0], [1, 2, 0]];
spots.sort((a, b) => (a[0] + a[1]) - (b[0] + b[1]) || a[2] - b[2]);
let line = '', spot = '';
spots.forEach(([x, y, z], i) => {
const cx = 200 + (x - y) * s, cy = 150 + (x + y) * h - z * s * 1.1;
const c = cube(cx, cy, i % 3 === 0); line += `${c.line}`; spot += c.spot;
});
return { spot, line: line + tag(200, 100, 300, 50, '80') + tag(270, 250, 360, 300, '82') + tag(110, 250, 40, 330, '84') };
},
};
})();
const FIGS = {
'css-grid-lanes': { draw: 'lanes', panel: 'yellow', spot: 'blue' },
'spool': { draw: 'spool', panel: 'pinklt', spot: 'orange' },
'ferrotype': { draw: 'plate', panel: 'orange', spot: 'pink' },
'building-ui-in-gpui': { draw: 'laptop', panel: 'paper', spot: 'pink' },
'the-black-magic-of-canvas-and-text-editing': { draw: 'bezier', panel: 'green', spot: 'orange' },
'fig-gen-making-generative-art-in-figma': { draw: 'sine', panel: 'blue', spot: 'yellow' },
'writing-with-adhd': { draw: 'eclipse', panel: 'black', spot: 'pink' },
'design-workshop': { draw: 'voxels', panel: 'pink', spot: 'blue' },
};
function figure(slug, cls = '') {
const f = FIGS[slug] || { draw: 'voxels', panel: 'paper', spot: 'pink' };
const d = D[f.draw]();
return ``;
}
window.figure = figure; window.FIGS = FIGS;