@brunosouzas/design-system 0.6.0 → 0.7.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/NOTICE +13 -0
- package/README.md +75 -40
- package/dist/scripts/cover.d.ts +7 -4
- package/dist/scripts/cover.js +25 -8
- package/dist/src/fonts/embed.d.ts +7 -0
- package/dist/src/fonts/embed.js +219 -0
- package/dist/src/pieces/bank-objects.d.ts +1 -1
- package/dist/src/pieces/bank-objects.js +26 -18
- package/dist/src/pieces/cover.js +2 -1
- package/dist/src/pieces/diagram.js +3 -3
- package/dist/src/pieces/eip-icons.js +27 -27
- package/dist/src/pieces/emote.d.ts +13 -0
- package/dist/src/pieces/emote.js +88 -0
- package/dist/src/pieces/index.d.ts +1 -1
- package/dist/src/pieces/index.js +1 -1
- package/dist/src/pieces/ink.d.ts +26 -16
- package/dist/src/pieces/ink.js +15 -6
- package/dist/src/pieces/library.d.ts +9 -15
- package/dist/src/pieces/library.js +52 -53
- package/dist/src/pieces/link-icons.d.ts +2 -1
- package/dist/src/pieces/link-icons.js +10 -18
- package/dist/src/pieces/metro.d.ts +4 -2
- package/dist/src/pieces/metro.js +14 -13
- package/dist/src/pieces/node.d.ts +5 -3
- package/dist/src/pieces/node.js +6 -4
- package/dist/src/pieces/params.js +2 -2
- package/dist/tokens/generated/tokens.d.ts +71 -155
- package/dist/tokens/generated/tokens.js +72 -156
- package/fonts/OFL.txt +97 -0
- package/fonts/SourceCodePro-Bold.ttf +0 -0
- package/fonts/SourceCodePro-Regular.ttf +0 -0
- package/fonts/SourceSans3-Black.ttf +0 -0
- package/fonts/SourceSans3-Bold.ttf +0 -0
- package/fonts/SourceSans3-Regular.ttf +0 -0
- package/package.json +10 -1
- package/tokens/generated/tokens.css +62 -110
- package/tokens/generated/tokens.json +72 -156
- package/tokens/generated/tokens.ts +72 -156
- package/dist/src/pieces/cast.d.ts +0 -35
- package/dist/src/pieces/cast.js +0 -333
package/dist/src/pieces/cast.js
DELETED
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
// The cast (spec illustration-pieces, change cast-and-emotes, card 152):
|
|
2
|
-
// `mascot`, seven characters with a shared face, actions and named parts, and
|
|
3
|
-
// `emote`, eight reaction symbols with a fixed meaning (ADR 0005).
|
|
4
|
-
//
|
|
5
|
-
// Why here: covers, diagrams and scenes draw the same characters from one
|
|
6
|
-
// source; a scene animates them by recomputing parameters per frame and
|
|
7
|
-
// wrapping the piece in `pose`.
|
|
8
|
-
//
|
|
9
|
-
// The geometry is the approved spike's, ported unchanged
|
|
10
|
-
// (~/.hermes/spikes/design-system/cast-and-emotes/cast.mts). The frozen fixture
|
|
11
|
-
// test/fixtures/cast-0.5.0.json pins every call's output, so a refactor here
|
|
12
|
-
// must keep every hash.
|
|
13
|
-
import { tokens } from "../../tokens/generated/tokens.js";
|
|
14
|
-
import { drawn, el, g } from "./node.js";
|
|
15
|
-
import { surfaceParam } from "./ink.js";
|
|
16
|
-
import { colour, pos } from "./params.js";
|
|
17
|
-
import { definePiece } from "./piece.js";
|
|
18
|
-
const c = (path) => colour(path);
|
|
19
|
-
export const MASCOTS = ["dev", "agent", "architect", "devops", "data", "request", "message"];
|
|
20
|
-
export const MASCOT_FACES = ["normal", "blink", "happy", "wink", "surprised", "worried", "thinking", "focused"];
|
|
21
|
-
export const MASCOT_ACTIONS = ["none", "rest", "wave", "hold", "reach", "up", "shrug", "type"];
|
|
22
|
-
export const EMOTE_KINDS = ["idea", "doubt", "problem", "worked", "refused", "pressure", "liked", "waiting"];
|
|
23
|
-
const ink = () => c("color.ink");
|
|
24
|
-
const O = () => ({ stroke: ink(), "stroke-width": 4, "stroke-linejoin": "round" });
|
|
25
|
-
// Every hard shadow is made by `hard`, so the dark drawing finds it by identity, not by its look.
|
|
26
|
-
const SHADOWS = new WeakSet();
|
|
27
|
-
const hard = (n) => (SHADOWS.add(n), n);
|
|
28
|
-
const shade = (d, dx = 8) => hard(el("path", { d, fill: ink(), transform: `translate(${dx} ${dx})` }));
|
|
29
|
-
const solid = (d, fill, dx = 8) => [shade(d, dx), el("path", { d, fill, ...O() })];
|
|
30
|
-
const shine = (d, col) => el("path", { d, fill: "none", stroke: col, "stroke-width": 9, "stroke-linecap": "round" });
|
|
31
|
-
const rr = (x, y, w, h, r) => `M${x + r},${y} H${x + w - r} Q${x + w},${y} ${x + w},${y + r} V${y + h - r} Q${x + w},${y + h} ${x + w - r},${y + h} H${x + r} Q${x},${y + h} ${x},${y + h - r} V${y + r} Q${x},${y} ${x + r},${y} Z`;
|
|
32
|
-
// ---------------------------------------------------------------- dark surface (card 187)
|
|
33
|
-
// On the dark surface (ADR 0003 amendment) the light drawing is rewritten, so the
|
|
34
|
-
// light output stays the frozen 0.5.0 tree: each hard shadow (made by `hard`) takes the surface's
|
|
35
|
-
// shadow colour, the ground takes the surface's grid colour, and a light rim
|
|
36
|
-
// (the drawing in the rim colour, every stroke widened by 2 × 2 × rimWidth) sits
|
|
37
|
-
// behind the whole outline, arms and legs included. The face is unchanged.
|
|
38
|
-
const walk = (n, f) => {
|
|
39
|
-
const m = f(n);
|
|
40
|
-
if (!m)
|
|
41
|
-
return null;
|
|
42
|
-
const kids = m.children.map((k) => (typeof k === "string" ? k : walk(k, f))).filter((k) => k !== null);
|
|
43
|
-
return { ...m, children: kids };
|
|
44
|
-
};
|
|
45
|
-
const part = (n) => String(n.attrs["data-part"] ?? "");
|
|
46
|
-
const onDark = (n) => {
|
|
47
|
-
const d = tokens.surface.dark;
|
|
48
|
-
return walk(n, (x) => {
|
|
49
|
-
if (SHADOWS.has(x))
|
|
50
|
-
return { ...x, attrs: { ...x.attrs, fill: d.shadow } };
|
|
51
|
-
if (part(x) === "ground")
|
|
52
|
-
return { ...x, children: x.children.map((k) => (typeof k === "string" ? k : { ...k, attrs: { ...k.attrs, fill: d.grid } })) };
|
|
53
|
-
return x;
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
const rimOf = (n) => {
|
|
57
|
-
const d = tokens.surface.dark;
|
|
58
|
-
return walk(n, (x) => {
|
|
59
|
-
if (SHADOWS.has(x) || ["ground", "face"].includes(part(x)) || x.attrs.opacity !== undefined)
|
|
60
|
-
return null;
|
|
61
|
-
if (x.tag === "g")
|
|
62
|
-
return x;
|
|
63
|
-
const sw = x.attrs.stroke !== undefined && x.attrs.stroke !== "none" ? Number(x.attrs["stroke-width"] ?? 4) : 0;
|
|
64
|
-
const attrs = { ...x.attrs, stroke: d.rim, "stroke-width": sw + 4 * d.rimWidth, "stroke-linejoin": "round" };
|
|
65
|
-
if (x.attrs.fill !== undefined && x.attrs.fill !== "none")
|
|
66
|
-
attrs.fill = d.rim;
|
|
67
|
-
return { ...x, attrs };
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
/** The light drawing redrawn for the dark surface: ground, rim, then the drawing. */
|
|
71
|
-
const darken = (root) => {
|
|
72
|
-
// The rim is taken from the light tree, where shadows are still known by identity.
|
|
73
|
-
const isGround = (k) => typeof k === "object" && part(k) === "ground";
|
|
74
|
-
const rim = rimOf({ ...root, attrs: {}, children: root.children.filter((k) => !isGround(k)) });
|
|
75
|
-
const dark = onDark(root);
|
|
76
|
-
return { ...dark, children: [...dark.children.filter(isGround), ...(rim ? [g({ "data-part": "rim" }, ...rim.children)] : []), ...dark.children.filter((k) => !isGround(k))] };
|
|
77
|
-
};
|
|
78
|
-
// ---------------------------------------------------------------- face (macs.ts)
|
|
79
|
-
export const face = (cx, cy, f, col, mouthFill) => {
|
|
80
|
-
const k = 1, dx = 24 * k;
|
|
81
|
-
const eye = (x, right) => {
|
|
82
|
-
if (f === "blink")
|
|
83
|
-
return el("path", { d: `M${x - 9 * k},${cy} H${x + 9 * k}`, stroke: col, "stroke-width": 5 * k, "stroke-linecap": "round" });
|
|
84
|
-
if (f === "happy" || (f === "wink" && right))
|
|
85
|
-
return el("path", { d: `M${x - 10 * k},${cy + 3 * k} Q${x},${cy - 10 * k} ${x + 10 * k},${cy + 3 * k}`, fill: "none", stroke: col, "stroke-width": 5 * k, "stroke-linecap": "round" });
|
|
86
|
-
if (f === "focused")
|
|
87
|
-
return el("path", { d: right ? `M${x + 10 * k},${cy - 6 * k} L${x - 8 * k},${cy} L${x + 10 * k},${cy + 6 * k}` : `M${x - 10 * k},${cy - 6 * k} L${x + 8 * k},${cy} L${x - 10 * k},${cy + 6 * k}`, fill: "none", stroke: col, "stroke-width": 5 * k, "stroke-linecap": "round", "stroke-linejoin": "round" });
|
|
88
|
-
const s = f === "surprised" ? 1.35 : 1, o = f === "thinking" ? 5 * k : 0;
|
|
89
|
-
return g({}, el("ellipse", { cx: x + o, cy: cy - o, rx: 7 * k * s, ry: 10 * k * s, fill: col }), el("circle", { cx: x + o + 2.5 * k, cy: cy - o - 4 * k, r: 2.6 * k, fill: c("color.white") }));
|
|
90
|
-
};
|
|
91
|
-
const by = cy - 22 * k, brow = (x, a, b) => el("path", { d: `M${x - 9 * k},${by + a * k} L${x + 9 * k},${by + b * k}`, stroke: col, "stroke-width": 4.5 * k, "stroke-linecap": "round" });
|
|
92
|
-
const brows = f === "worried" ? [brow(cx - dx, 4, -3), brow(cx + dx, -3, 4)]
|
|
93
|
-
: f === "surprised" ? [brow(cx - dx, -6, -8), brow(cx + dx, -8, -6)]
|
|
94
|
-
: f === "thinking" ? [brow(cx + dx, 0, -7)] : [];
|
|
95
|
-
const my = cy + 26 * k, ln = (d, fill = "none") => el("path", { d, fill, stroke: col, "stroke-width": 5 * k, "stroke-linecap": "round", "stroke-linejoin": "round" });
|
|
96
|
-
const smile = ln(`M${cx - 12 * k},${my - 2 * k} Q${cx},${my + 11 * k} ${cx + 12 * k},${my - 2 * k}`);
|
|
97
|
-
const mouth = {
|
|
98
|
-
blink: smile,
|
|
99
|
-
normal: smile,
|
|
100
|
-
happy: ln(`M${cx - 15 * k},${my - 4 * k} Q${cx},${my + 16 * k} ${cx + 15 * k},${my - 4 * k} Z`, mouthFill),
|
|
101
|
-
wink: ln(`M${cx - 12 * k},${my - 2 * k} Q${cx + 2 * k},${my + 12 * k} ${cx + 14 * k},${my - 6 * k}`),
|
|
102
|
-
surprised: el("ellipse", { cx, cy: my + 4 * k, rx: 7 * k, ry: 9 * k, fill: mouthFill, stroke: col, "stroke-width": 4 * k }),
|
|
103
|
-
worried: ln(`M${cx - 12 * k},${my + 5 * k} Q${cx},${my - 6 * k} ${cx + 12 * k},${my + 5 * k}`),
|
|
104
|
-
thinking: ln(`M${cx - 7 * k},${my + 2 * k} L${cx + 10 * k},${my - 2 * k}`),
|
|
105
|
-
focused: ln(`M${cx - 8 * k},${my} L${cx + 8 * k},${my}`),
|
|
106
|
-
}[f];
|
|
107
|
-
return g({ "data-part": "face" }, g({ "data-part": "eyes" }, eye(cx - dx, false), eye(cx + dx, true)), brows.length ? g({ "data-part": "brows" }, ...brows) : null, g({ "data-part": "mouth" }, mouth));
|
|
108
|
-
};
|
|
109
|
-
// Arm targets as offsets from the shoulders (left, right). "computer" = macs.ts, "object" = mascots4.ts.
|
|
110
|
-
const COMPUTER = {
|
|
111
|
-
armWidth: 15, legWidth: 15, bend: 8,
|
|
112
|
-
offsets: { rest: [[-20, 40], [20, 40]], wave: [[-20, 40], [30, -86]], hold: [[30, 50], [-30, 50]], reach: [[-20, 40], [70, -4]], up: [[-30, -90], [30, -90]], shrug: [[-44, -26], [44, -26]], type: [[26, 58], [-26, 58]] },
|
|
113
|
-
};
|
|
114
|
-
const OBJECT = {
|
|
115
|
-
armWidth: 16, legWidth: 16, bend: 8,
|
|
116
|
-
offsets: { rest: [[-22, 34], [22, 34]], wave: [[-22, 34], [34, -92]], hold: [[0, 0], [0, 0]], reach: [[-22, 34], [70, -4]], up: [[-34, -96], [34, -96]], shrug: [[-46, -30], [46, -30]], type: [[26, 58], [-26, 58]] },
|
|
117
|
-
};
|
|
118
|
-
const arm = (from, to, side, w) => [
|
|
119
|
-
el("path", { d: `M${from[0]},${from[1]} Q${(from[0] + to[0]) / 2 + side * 14},${Math.max(from[1], to[1]) + 8} ${to[0]},${to[1]}`, fill: "none", stroke: ink(), "stroke-width": w, "stroke-linecap": "round" }),
|
|
120
|
-
el("ellipse", { cx: to[0], cy: to[1], rx: 15, ry: 12, fill: ink(), transform: `rotate(${side * 20} ${to[0]} ${to[1]})` }),
|
|
121
|
-
];
|
|
122
|
-
// ---------------------------------------------------------------- props (mascots4.ts)
|
|
123
|
-
const boardProp = (x, y) => [
|
|
124
|
-
shade(rr(x, y, 104, 78, 10), 6), el("path", { d: rr(x, y, 104, 78, 10), fill: c("color.white"), ...O() }),
|
|
125
|
-
el("path", { d: `M${x + 30},${y + 28} H${x + 52} V${y + 52} H${x + 74}`, fill: "none", stroke: ink(), "stroke-width": 3 }),
|
|
126
|
-
el("rect", { x: x + 12, y: y + 18, width: 22, height: 20, rx: 4, fill: c("color.caller"), stroke: ink(), "stroke-width": 3 }),
|
|
127
|
-
el("rect", { x: x + 70, y: y + 42, width: 22, height: 20, rx: 4, fill: c("color.healthy"), stroke: ink(), "stroke-width": 3 }),
|
|
128
|
-
el("rect", { x: x + 42, y: y + 8, width: 20, height: 18, rx: 4, fill: c("color.transitional"), stroke: ink(), "stroke-width": 3 }),
|
|
129
|
-
];
|
|
130
|
-
const wrenchProp = (x, y) => {
|
|
131
|
-
const d = `M${x},${y} L${x + 50},${y - 50} M${x + 50},${y - 50}`;
|
|
132
|
-
return [
|
|
133
|
-
el("path", { d, stroke: ink(), "stroke-width": 18, "stroke-linecap": "round" }),
|
|
134
|
-
el("path", { d, stroke: c("cast.metal"), "stroke-width": 10, "stroke-linecap": "round" }),
|
|
135
|
-
el("path", { d: `M${x + 40},${y - 74} A24,24 0 1 0 ${x + 76},${y - 40} L${x + 62},${y - 46} L${x + 56},${y - 60} Z`, fill: c("cast.metal"), ...O() }),
|
|
136
|
-
];
|
|
137
|
-
};
|
|
138
|
-
const magnifierProp = (x, y) => [
|
|
139
|
-
el("path", { d: `M${x},${y} L${x + 24},${y - 24}`, stroke: ink(), "stroke-width": 16, "stroke-linecap": "round" }),
|
|
140
|
-
el("circle", { cx: x + 44, cy: y - 44, r: 30, fill: c("cast.data.lens"), stroke: ink(), "stroke-width": 9 }),
|
|
141
|
-
el("circle", { cx: x + 44, cy: y - 44, r: 30, fill: "none", stroke: c("color.caller"), "stroke-width": 4 }),
|
|
142
|
-
el("path", { d: `M${x + 30},${y - 56} Q${x + 36},${y - 66} ${x + 48},${y - 66}`, fill: "none", stroke: c("color.white"), "stroke-width": 5, "stroke-linecap": "round" }),
|
|
143
|
-
];
|
|
144
|
-
const spark = (x, y) => el("path", { d: `M${x},${y - 14} L${x + 4},${y - 4} L${x + 14},${y} L${x + 4},${y + 4} L${x},${y + 14} L${x - 4},${y + 4} L${x - 14},${y} L${x - 4},${y - 4} Z`, fill: c("color.transitional"), ...O(), "stroke-width": 3 });
|
|
145
|
-
const CAST = () => ({
|
|
146
|
-
// DEV: modern all-in-one. Screen frame = body, code on the screen, face on the screen, </> on the chin, stand.
|
|
147
|
-
dev: {
|
|
148
|
-
family: COMPUTER, anchor: [110, 230], ground: 80, shoulders: [[22, 118], [198, 118]], hips: [[86, 200], [134, 200]], foot: 226,
|
|
149
|
-
faceAt: [110, 88], faceColour: ink(), mouthFill: c("cast.mouth"),
|
|
150
|
-
parts: () => [
|
|
151
|
-
g({ "data-part": "stand" }, ...solid("M88,184 H132 L140,212 H80 Z", c("cast.metal"), 6), ...solid(rr(62, 208, 96, 12, 6), c("cast.metal"), 5)),
|
|
152
|
-
g({ "data-part": "body" }, ...solid(rr(4, 24, 212, 168, 18), c("cast.dev.fill")), el("path", { d: "M8,152 H212 V174 Q212,188 198,188 H22 Q8,188 8,174 Z", fill: c("cast.dev.chin"), stroke: "none" }), el("path", { d: "M4,152 H216", stroke: ink(), "stroke-width": 4 }), el("path", { d: rr(18, 36, 184, 108, 10), fill: c("cast.dev.screen"), stroke: ink(), "stroke-width": 3.5 }), g({ "data-part": "screen-code", stroke: "none" }, el("rect", { x: 30, y: 48, width: 34, height: 7, rx: 3.5, fill: c("color.healthy") }), el("rect", { x: 36, y: 61, width: 22, height: 7, rx: 3.5, fill: c("cast.dev.fill") }), el("rect", { x: 156, y: 48, width: 34, height: 7, rx: 3.5, fill: c("color.healthy") }), el("rect", { x: 162, y: 61, width: 22, height: 7, rx: 3.5, fill: c("cast.dev.fill") }))),
|
|
153
|
-
g({ "data-part": "mark" }, el("path", { d: "M98,163 L90,170 L98,177 M122,163 L130,170 L122,177 M114,160 L106,180", fill: "none", stroke: c("color.white"), "stroke-width": 4.5, "stroke-linecap": "round", "stroke-linejoin": "round" })),
|
|
154
|
-
],
|
|
155
|
-
},
|
|
156
|
-
// AI AGENT: retro lamp all-in-one. Dome = body, chrome neck, the screen is the head (tilts on the neck).
|
|
157
|
-
agent: {
|
|
158
|
-
family: COMPUTER, anchor: [110, 250], ground: 82, shoulders: [[44, 196], [176, 196]], hips: [[84, 236], [136, 236]], foot: 248,
|
|
159
|
-
faceAt: [110, 58], faceColour: c("cast.glow"), mouthFill: c("cast.glow"), faceInHead: true,
|
|
160
|
-
parts: (tilt) => {
|
|
161
|
-
const top = [110 + tilt * 1.4, 110];
|
|
162
|
-
const neck = `M110,176 Q${108 + tilt},150 ${top[0]},${top[1]}`;
|
|
163
|
-
return [
|
|
164
|
-
g({ "data-part": "neck" }, el("path", { d: neck, fill: "none", stroke: ink(), "stroke-width": 16, "stroke-linecap": "round" }), el("path", { d: neck, fill: "none", stroke: c("cast.agent.neck"), "stroke-width": 8, "stroke-linecap": "round" })),
|
|
165
|
-
g({ "data-part": "body" }, ...solid("M30,240 Q30,166 110,164 Q190,166 190,240 Z", c("color.white")), el("path", { d: "M44,226 H176", stroke: c("cast.metal"), "stroke-width": 4, "stroke-dasharray": "3 6", "stroke-linecap": "round" }), el("path", { d: "M58,196 Q80,180 104,178", fill: "none", stroke: c("cast.agent.shine"), "stroke-width": 8, "stroke-linecap": "round" })),
|
|
166
|
-
g({ "data-part": "mark" }, spark(110, 206)),
|
|
167
|
-
];
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
// ARCHITECT: drafting set square with its hole, ruler ticks (mark), pencil; board as prop.
|
|
171
|
-
architect: {
|
|
172
|
-
family: OBJECT, anchor: [105, 216], ground: 76, shoulders: [[46, 152], [174, 152]], hips: [[78, 190], [146, 190]], foot: 212, hold: [64, 168],
|
|
173
|
-
faceAt: [110, 132], faceColour: ink(), mouthFill: c("cast.mouth"),
|
|
174
|
-
parts: () => [
|
|
175
|
-
g({ "data-part": "pencil", transform: "rotate(28 128 40)" }, el("path", { d: "M120,6 H136 V60 L128,74 L120,60 Z", fill: c("color.transitional"), ...O(), "stroke-width": 3.5 }), el("path", { d: "M120,6 H136 V16 H120 Z", fill: c("color.backend"), ...O(), "stroke-width": 3.5 })),
|
|
176
|
-
g({ "data-part": "body" }, ...solid("M99,30 Q110,13 121,30 L198,158 Q210,184 177,193 H35 Q6,187 21,160 Z", c("cast.architect.fill")), el("path", { d: "M110,58 L130,94 H90 Z", fill: c("color.panel"), stroke: ink(), "stroke-width": 3.5, "stroke-linejoin": "round" }), shine("M70,110 Q78,92 88,80", c("cast.architect.shine"))),
|
|
177
|
-
g({ "data-part": "mark", stroke: ink(), "stroke-width": 3, "stroke-linecap": "round" }, ...Array.from({ length: 9 }, (_, i) => { const x = 42 + i * 16; const h = i % 2 ? 9 : 15; return el("path", { d: `M${x},193 V${193 - h}` }); })),
|
|
178
|
-
],
|
|
179
|
-
prop: () => boardProp(118, 152),
|
|
180
|
-
},
|
|
181
|
-
// DEVOPS: gear with the infinity loop (mark); wrench as prop.
|
|
182
|
-
devops: {
|
|
183
|
-
family: OBJECT, anchor: [105, 216], ground: 76, shoulders: [[34, 138], [184, 138]], hips: [[68, 176], [146, 176]], foot: 212, hold: [72, 160],
|
|
184
|
-
faceAt: [110, 100], faceColour: ink(), mouthFill: c("cast.mouth"),
|
|
185
|
-
parts: () => {
|
|
186
|
-
const loop = "M110,160 C98,146 76,146 76,160 C76,174 98,174 110,160 C122,146 144,146 144,160 C144,174 122,174 110,160 Z";
|
|
187
|
-
return [
|
|
188
|
-
g({ "data-part": "body" }, ...solid("M86,22H128L137,42L161,36L183,58L175,82L196,94V128L174,141L182,163L158,187L136,178L124,197H87L77,180L54,186L28,163L37,138L16,125V93L39,81L31,57L53,35L76,42Z", c("cast.devops.fill")), shine("M60,60 Q80,46 104,46", c("cast.devops.shine"))),
|
|
189
|
-
g({ "data-part": "mark" }, el("path", { d: loop, fill: "none", stroke: c("color.white"), "stroke-width": 11, "stroke-linejoin": "round" }), el("path", { d: loop, fill: "none", stroke: ink(), "stroke-width": 4, "stroke-linejoin": "round" })),
|
|
190
|
-
];
|
|
191
|
-
},
|
|
192
|
-
prop: () => wrenchProp(168, 178),
|
|
193
|
-
},
|
|
194
|
-
// DATA: cylinder with lid and two bands (mark); magnifier as prop.
|
|
195
|
-
data: {
|
|
196
|
-
family: OBJECT, anchor: [105, 216], ground: 76, shoulders: [[38, 140], [172, 140]], hips: [[68, 196], [142, 196]], foot: 212, hold: [70, 170],
|
|
197
|
-
faceAt: [105, 104], faceColour: ink(), mouthFill: c("cast.mouth"),
|
|
198
|
-
parts: () => [
|
|
199
|
-
g({ "data-part": "body" }, ...solid("M35,60 V174 Q35,205 105,205 Q175,205 175,174 V60 Z", c("cast.data.fill"))),
|
|
200
|
-
g({ "data-part": "mark", fill: "none", stroke: ink(), "stroke-width": 4 }, el("path", { d: "M35,128 Q105,158 175,128" }), el("path", { d: "M35,166 Q105,196 175,166" })),
|
|
201
|
-
g({ "data-part": "lid" }, el("ellipse", { cx: 105, cy: 61, rx: 70, ry: 25, fill: c("cast.data.lid"), ...O() }), shine("M50,84 V112", c("cast.data.shine"))),
|
|
202
|
-
],
|
|
203
|
-
prop: () => magnifierProp(164, 186),
|
|
204
|
-
},
|
|
205
|
-
// REQUESTER: speech bubble in caller blue, the request line (mark).
|
|
206
|
-
request: {
|
|
207
|
-
family: OBJECT, anchor: [105, 216], ground: 76, shoulders: [[30, 120], [180, 120]], hips: [[78, 176], [134, 176]], foot: 212, hold: [70, 150],
|
|
208
|
-
faceAt: [105, 82], faceColour: ink(), mouthFill: c("cast.mouth"),
|
|
209
|
-
parts: () => [
|
|
210
|
-
g({ "data-part": "body" }, ...solid("M54,30 H156 Q186,30 186,60 V130 Q186,160 156,160 H96 L66,190 L72,160 H54 Q24,160 24,130 V60 Q24,30 54,30 Z", c("color.caller")), shine("M44,62 Q56,46 78,46", c("cast.request.shine"))),
|
|
211
|
-
g({ "data-part": "mark" }, el("rect", { x: 62, y: 134, width: 86, height: 12, rx: 6, fill: c("color.white"), stroke: ink(), "stroke-width": 3 })),
|
|
212
|
-
],
|
|
213
|
-
},
|
|
214
|
-
// MESSAGE: envelope (0.7 of the others), seal (mark).
|
|
215
|
-
message: {
|
|
216
|
-
family: OBJECT, anchor: [105, 216], scale: 0.7, ground: 76, shoulders: [[40, 140], [170, 140]], hips: [[78, 190], [132, 190]], foot: 212, hold: [70, 170],
|
|
217
|
-
faceAt: [105, 136], faceColour: ink(), mouthFill: c("cast.mouth"),
|
|
218
|
-
parts: () => [
|
|
219
|
-
g({ "data-part": "body" }, ...solid(rr(32, 88, 146, 106, 16), c("color.white"))),
|
|
220
|
-
g({ "data-part": "mark" }, el("path", { d: "M36,94 L105,140 L174,94", fill: "none", stroke: ink(), "stroke-width": 4, "stroke-linejoin": "round" }), el("circle", { cx: 105, cy: 140, r: 9, fill: c("color.transitional"), stroke: ink(), "stroke-width": 3 })),
|
|
221
|
-
],
|
|
222
|
-
},
|
|
223
|
-
});
|
|
224
|
-
const drawMascot = (p) => {
|
|
225
|
-
const ch = CAST()[p.who];
|
|
226
|
-
const f = p.face ?? "normal", act = p.action ?? "none", look = p.look ?? 0, tilt = p.headTilt ?? 0;
|
|
227
|
-
const k = (p.scale ?? 1) * (ch.scale ?? 1);
|
|
228
|
-
const fam = ch.family;
|
|
229
|
-
const [L, R] = ch.shoulders;
|
|
230
|
-
let arms = [];
|
|
231
|
-
let legs = null;
|
|
232
|
-
const front = act === "hold" || act === "type";
|
|
233
|
-
if (act !== "none") {
|
|
234
|
-
const [ol, or] = fam.offsets[act];
|
|
235
|
-
let targetL = [L[0] + ol[0], L[1] + ol[1]], targetR = [R[0] + or[0], R[1] + or[1]];
|
|
236
|
-
// mascots4: "hold" puts both mittens at the hold point, mirrored round x 105.
|
|
237
|
-
if (act === "hold" && ch.hold) {
|
|
238
|
-
targetL = ch.hold;
|
|
239
|
-
targetR = [210 - ch.hold[0], ch.hold[1]];
|
|
240
|
-
}
|
|
241
|
-
arms = [g({ "data-part": "arm-left" }, ...arm(L, targetL, -1, fam.armWidth)), g({ "data-part": "arm-right" }, ...arm(R, targetR, 1, fam.armWidth))];
|
|
242
|
-
legs = g({ "data-part": "legs" }, ...ch.hips.flatMap(([hx, hy], i) => {
|
|
243
|
-
const s = i ? 1 : -1;
|
|
244
|
-
return fam === COMPUTER
|
|
245
|
-
? [el("path", { d: `M${hx},${hy} L${hx + s * 4},${ch.foot - 6}`, stroke: ink(), "stroke-width": fam.legWidth, "stroke-linecap": "round" }), el("ellipse", { cx: hx + s * 11, cy: ch.foot, rx: 19, ry: 11, fill: ink() })]
|
|
246
|
-
: [el("path", { d: `M${hx},${hy} L${hx + s * 6},${ch.foot - 6}`, stroke: ink(), "stroke-width": fam.legWidth, "stroke-linecap": "round" }), el("ellipse", { cx: hx + s * 13, cy: ch.foot, rx: 19, ry: 11, fill: ink() })];
|
|
247
|
-
}));
|
|
248
|
-
}
|
|
249
|
-
let faceWrapped = face(ch.faceAt[0] + (ch.faceInHead ? tilt * 1.4 : 0), ch.faceAt[1], f, ch.faceColour, ch.mouthFill);
|
|
250
|
-
if (look !== 0)
|
|
251
|
-
faceWrapped = { ...faceWrapped, attrs: { ...faceWrapped.attrs, transform: `translate(${look * 6} 0)` } };
|
|
252
|
-
const showProp = (p.prop ?? true) && ch.prop && (act === "rest" || act === "hold");
|
|
253
|
-
const [ax, ay] = ch.anchor;
|
|
254
|
-
let parts = ch.parts(tilt);
|
|
255
|
-
if (ch.faceInHead) {
|
|
256
|
-
const top = [110 + tilt * 1.4, 110];
|
|
257
|
-
parts = [...parts, g({ "data-part": "head", transform: `rotate(${tilt} ${top[0]} ${top[1]})` }, ...solid(rr(top[0] - 96, 0, 192, 132, 22), c("color.white")), el("path", { d: rr(top[0] - 80, 14, 160, 104, 12), fill: c("illustration.codePanel"), stroke: ink(), "stroke-width": 4 }), faceWrapped)];
|
|
258
|
-
}
|
|
259
|
-
const root = g({ "data-mascot": p.who, transform: `translate(${p.x} ${p.y}) scale(${k}) translate(${-ax} ${-ay})`, stroke: "none" }, g({ "data-part": "ground" }, el("ellipse", { cx: ax, cy: ay, rx: ch.ground, ry: 9, fill: c("cast.ground") })), ...(front ? [] : arms), legs, ...parts, ch.faceInHead ? null : faceWrapped, showProp ? g({ "data-part": "prop" }, ...ch.prop()) : null, ...(front ? arms : []));
|
|
260
|
-
return drawn([p.surface === "dark" ? darken(root) : root]);
|
|
261
|
-
};
|
|
262
|
-
// ---------------------------------------------------------------- emotes (emotes.ts)
|
|
263
|
-
const rays = (cx, cy, r1, r2, n, from = -150, to = -30) => Array.from({ length: n }, (_, i) => {
|
|
264
|
-
const a = ((from + (i * (to - from)) / (n - 1)) * Math.PI) / 180;
|
|
265
|
-
const r = (v) => Math.round(v * 100) / 100;
|
|
266
|
-
return el("path", { d: `M${r(cx + r1 * Math.cos(a))},${r(cy + r1 * Math.sin(a))} L${r(cx + r2 * Math.cos(a))},${r(cy + r2 * Math.sin(a))}`, stroke: ink(), "stroke-width": 6, "stroke-linecap": "round" });
|
|
267
|
-
});
|
|
268
|
-
const EO = () => ({ stroke: ink(), "stroke-width": 5, "stroke-linejoin": "round", "stroke-linecap": "round" });
|
|
269
|
-
const disc = (cx, cy, r, fill) => [hard(el("circle", { cx: cx + 6, cy: cy + 6, r, fill: ink() })), el("circle", { cx, cy, r, fill, ...EO() })];
|
|
270
|
-
const zed = (x, y, s) => {
|
|
271
|
-
// A Z of height s with its top-left at (x, y - s): ink casing, caller fill.
|
|
272
|
-
const w = s * 0.72, d = `M${x},${y - s} H${x + w} L${x},${y} H${x + w}`;
|
|
273
|
-
return [el("path", { d, fill: "none", stroke: ink(), "stroke-width": s * 0.34, "stroke-linecap": "round", "stroke-linejoin": "round" }),
|
|
274
|
-
el("path", { d, fill: "none", stroke: c("color.caller"), "stroke-width": s * 0.16, "stroke-linecap": "round", "stroke-linejoin": "round" })];
|
|
275
|
-
};
|
|
276
|
-
const drawEmote = (p) => {
|
|
277
|
-
const { kind, x: cx, y: cy } = p, burst = p.burst ?? true, s = p.scale ?? 1;
|
|
278
|
-
const parts = [];
|
|
279
|
-
switch (kind) {
|
|
280
|
-
case "idea": {
|
|
281
|
-
if (burst)
|
|
282
|
-
parts.push(el("circle", { cx, cy: cy - 6, r: 62, fill: c("color.transitional"), opacity: 0.35 }), ...rays(cx, cy - 6, 50, 72, 7, -180, 0));
|
|
283
|
-
const bulb = `M${cx - 30},${cy - 10} A34,34 0 1 1 ${cx + 30},${cy - 10} Q${cx + 22},${cy + 6} ${cx + 18},${cy + 22} H${cx - 18} Q${cx - 22},${cy + 6} ${cx - 30},${cy - 10} Z`;
|
|
284
|
-
parts.push(hard(el("path", { d: bulb, fill: ink(), transform: "translate(6 6)" })), el("path", { d: bulb, fill: c("color.transitional"), ...EO() }), el("path", { d: `M${cx - 16},${cy - 22} Q${cx - 12},${cy - 32} ${cx - 2},${cy - 34}`, fill: "none", stroke: c("color.white"), "stroke-width": 6, "stroke-linecap": "round" }), el("path", { d: `M${cx - 8},${cy + 22} V${cy} L${cx},${cy + 8} L${cx + 8},${cy} V${cy + 22}`, fill: "none", stroke: ink(), "stroke-width": 4, "stroke-linejoin": "round" }), el("rect", { x: cx - 18, y: cy + 22, width: 36, height: 12, rx: 3, fill: c("cast.metal"), ...EO(), "stroke-width": 4 }), el("rect", { x: cx - 14, y: cy + 34, width: 28, height: 10, rx: 5, fill: c("cast.metal"), ...EO(), "stroke-width": 4 }));
|
|
285
|
-
break;
|
|
286
|
-
}
|
|
287
|
-
case "doubt":
|
|
288
|
-
parts.push(...disc(cx, cy, 40, c("color.white")), el("path", { d: `M${cx - 14},${cy - 12} Q${cx - 14},${cy - 28} ${cx},${cy - 28} Q${cx + 16},${cy - 28} ${cx + 16},${cy - 13} Q${cx + 16},${cy - 2} ${cx + 2},${cy + 4} V${cy + 10}`, fill: "none", stroke: ink(), "stroke-width": 9, "stroke-linecap": "round", "stroke-linejoin": "round" }), el("circle", { cx: cx + 2, cy: cy + 24, r: 6, fill: ink() }));
|
|
289
|
-
break;
|
|
290
|
-
case "problem":
|
|
291
|
-
if (burst)
|
|
292
|
-
parts.push(...rays(cx, cy, 48, 70, 5));
|
|
293
|
-
parts.push(hard(el("path", { d: `M${cx},${cy - 44} L${cx + 46},${cy + 34} H${cx - 46} Z`, fill: ink(), transform: "translate(6 6)" })), el("path", { d: `M${cx},${cy - 44} L${cx + 46},${cy + 34} H${cx - 46} Z`, fill: c("color.failure"), ...EO() }), el("path", { d: `M${cx},${cy - 18} V${cy + 8}`, stroke: ink(), "stroke-width": 9, "stroke-linecap": "round" }), el("circle", { cx, cy: cy + 22, r: 5.5, fill: ink() }));
|
|
294
|
-
break;
|
|
295
|
-
case "pressure":
|
|
296
|
-
for (const [dx, dy, k] of [[0, 0, 1], [30, 22, 0.6]])
|
|
297
|
-
parts.push(el("path", { d: `M${cx + dx},${cy + dy - 34 * k} Q${cx + dx + 24 * k},${cy + dy} ${cx + dx},${cy + dy + 12 * k} Q${cx + dx - 24 * k},${cy + dy} ${cx + dx},${cy + dy - 34 * k} Z`, fill: c("cast.glow"), ...EO(), "stroke-width": 4 }), el("path", { d: `M${cx + dx - 6 * k},${cy + dy - 2 * k} Q${cx + dx - 8 * k},${cy + dy + 6 * k} ${cx + dx - 2 * k},${cy + dy + 8 * k}`, fill: "none", stroke: c("color.white"), "stroke-width": 3, "stroke-linecap": "round" }));
|
|
298
|
-
break;
|
|
299
|
-
case "liked":
|
|
300
|
-
parts.push(el("path", { d: `M${cx},${cy + 30} C${cx - 50},${cy} ${cx - 34},${cy - 40} ${cx},${cy - 16} C${cx + 34},${cy - 40} ${cx + 50},${cy} ${cx},${cy + 30} Z`, fill: c("color.backend"), ...EO() }));
|
|
301
|
-
break;
|
|
302
|
-
case "worked":
|
|
303
|
-
if (burst)
|
|
304
|
-
parts.push(...rays(cx, cy, 48, 68, 5));
|
|
305
|
-
parts.push(...disc(cx, cy, 38, c("color.healthy")), el("path", { d: `M${cx - 16},${cy} L${cx - 4},${cy + 12} L${cx + 18},${cy - 12}`, fill: "none", stroke: ink(), "stroke-width": 8, "stroke-linecap": "round", "stroke-linejoin": "round" }));
|
|
306
|
-
break;
|
|
307
|
-
case "refused":
|
|
308
|
-
parts.push(...disc(cx, cy, 38, c("color.failure")), el("path", { d: `M${cx - 13},${cy - 13} L${cx + 13},${cy + 13} M${cx + 13},${cy - 13} L${cx - 13},${cy + 13}`, stroke: ink(), "stroke-width": 8, "stroke-linecap": "round" }));
|
|
309
|
-
break;
|
|
310
|
-
case "waiting":
|
|
311
|
-
parts.push(...zed(cx - 12, cy + 12, 26), ...zed(cx + 20, cy - 20, 20), ...zed(cx + 44, cy - 46, 14));
|
|
312
|
-
break;
|
|
313
|
-
}
|
|
314
|
-
const attrs = s === 1 ? { "data-emote": kind, stroke: "none" } : { "data-emote": kind, stroke: "none", transform: `translate(${cx} ${cy}) scale(${s}) translate(${-cx} ${-cy})` };
|
|
315
|
-
const root = g(attrs, ...parts);
|
|
316
|
-
return drawn([p.surface === "dark" ? darken(root) : root]);
|
|
317
|
-
};
|
|
318
|
-
const unit = { kind: "number", min: 0, exclusiveMin: true, max: 10 };
|
|
319
|
-
/** One character standing with the centre of its ground line at (x, y). */
|
|
320
|
-
export const mascot = definePiece("mascot", {
|
|
321
|
-
who: { kind: "enum", required: true, values: MASCOTS },
|
|
322
|
-
x: pos(),
|
|
323
|
-
y: pos(),
|
|
324
|
-
face: { kind: "enum", values: MASCOT_FACES },
|
|
325
|
-
action: { kind: "enum", values: MASCOT_ACTIONS },
|
|
326
|
-
scale: unit,
|
|
327
|
-
look: { kind: "number", min: -1, max: 1 },
|
|
328
|
-
headTilt: { kind: "number", min: -30, max: 30 },
|
|
329
|
-
prop: { kind: "boolean" },
|
|
330
|
-
surface: surfaceParam,
|
|
331
|
-
}, drawMascot, ({ who, headTilt }) => (headTilt !== undefined && headTilt !== 0 && who !== "agent" ? [{ path: "headTilt", message: "applies only to the agent" }] : []));
|
|
332
|
-
/** One reaction symbol with a fixed meaning, centred on (x, y), beside a head. */
|
|
333
|
-
export const emote = definePiece("emote", { kind: { kind: "enum", required: true, values: EMOTE_KINDS }, x: pos(), y: pos(), scale: unit, burst: { kind: "boolean" }, surface: surfaceParam }, drawEmote);
|