cortico-world-agent-speed 0.2.0 → 0.2.2
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 +64 -0
- package/LICENSE +0 -14
- package/README.md +29 -11
- package/THIRD_PARTY_NOTICES.md +69 -0
- package/activity.d.ts +15 -0
- package/activity.js +88 -3
- package/describe.json +806 -0
- package/dist/webui.css +2 -0
- package/dist/webui.css.map +7 -0
- package/dist/webui.js +2 -0
- package/dist/webui.js.map +7 -0
- package/host/app-store.cjs +68 -0
- package/host/cursor.cjs +67 -0
- package/host/electron-main.cjs +666 -0
- package/host/input-shape.cjs +63 -0
- package/host/mouse-lease.cjs +77 -0
- package/host/overlay.cjs +139 -0
- package/host/portrait.cjs +52 -0
- package/host/preload.cjs +60 -14
- package/host/renderer-gone.cjs +24 -0
- package/host/windows.cjs +251 -0
- package/package.json +27 -7
- package/scripts/build-webui.mjs +40 -0
- package/scripts/speech-bank/build.py +166 -0
- package/scripts/speech-bank/dicts.py +76 -0
- package/src/ENV_PROMPT.en.md +51 -0
- package/src/ENV_PROMPT.md +51 -0
- package/src/asr/address.ts +25 -0
- package/src/asr/hotkey.ts +335 -0
- package/src/asr/result.ts +51 -0
- package/src/asr/segmenter.ts +269 -0
- package/src/asr/sherpa.ts +280 -0
- package/src/asr/simplify.ts +38 -0
- package/src/asr/system-recognizer.ts +292 -0
- package/src/asr/system-sapi.ps1 +173 -0
- package/src/asr/transcription-api.ts +176 -0
- package/src/chat.ts +212 -0
- package/src/config.ts +481 -0
- package/src/cua/ENV_PROMPT.en.md +29 -0
- package/src/cua/ENV_PROMPT.md +29 -0
- package/src/cua/config.ts +88 -0
- package/src/cua/cua.ts +712 -0
- package/src/cua/engine/darwin.ts +410 -0
- package/src/cua/engine/display.ts +55 -0
- package/src/cua/engine/fail.ts +15 -0
- package/src/cua/engine/foreground.ts +8 -0
- package/src/cua/engine/image.ts +57 -0
- package/src/cua/engine/keys.ts +70 -0
- package/src/cua/engine/linux-keys.ts +29 -0
- package/src/cua/engine/linux.ts +343 -0
- package/src/cua/engine/mac-keys.ts +57 -0
- package/src/cua/engine/user-activity.ts +54 -0
- package/src/cua/engine/wait-idle.ts +31 -0
- package/src/cua/engine/win32.ts +299 -0
- package/src/cua/engine-child.ts +274 -0
- package/src/cua/engine-ipc.ts +140 -0
- package/src/cua/i18n/de.ts +53 -0
- package/src/cua/i18n/en.ts +63 -0
- package/src/cua/i18n/es-419.ts +53 -0
- package/src/cua/i18n/fr.ts +53 -0
- package/src/cua/i18n/index.ts +26 -0
- package/src/cua/i18n/it.ts +53 -0
- package/src/cua/i18n/ja.ts +53 -0
- package/src/cua/i18n/ko.ts +53 -0
- package/src/cua/i18n/pt-BR.ts +53 -0
- package/src/cua/i18n/ru.ts +59 -0
- package/src/cua/i18n/zh-Hant.ts +53 -0
- package/src/cua/i18n/zh.ts +59 -0
- package/src/cua/model-text.ts +252 -0
- package/src/cua/terminal.ts +31 -0
- package/src/cua/tools.ts +153 -0
- package/src/definition.ts +146 -0
- package/src/host-reason.ts +32 -0
- package/src/i18n/de.ts +409 -0
- package/src/i18n/en.ts +443 -0
- package/src/i18n/es-419.ts +409 -0
- package/src/i18n/fr.ts +409 -0
- package/src/i18n/index.ts +56 -0
- package/src/i18n/it.ts +409 -0
- package/src/i18n/ja.ts +409 -0
- package/src/i18n/ko.ts +409 -0
- package/src/i18n/pt-BR.ts +409 -0
- package/src/i18n/ru.ts +415 -0
- package/src/i18n/zh-Hant.ts +409 -0
- package/src/i18n/zh.ts +440 -0
- package/src/index.ts +15 -0
- package/src/model-text.ts +344 -0
- package/src/moves.ts +101 -0
- package/src/pack-import.ts +361 -0
- package/src/packs.ts +449 -0
- package/src/runtime/download.ts +29 -0
- package/src/runtime/store.ts +293 -0
- package/src/script.ts +202 -0
- package/src/self.ts +247 -0
- package/src/server.ts +479 -0
- package/src/speech/data/CMUDICT-LICENSE +33 -0
- package/src/speech/data/IPADIC-COPYING +71 -0
- package/src/speech/data/UNICODE-LICENSE +39 -0
- package/src/speech/data/en.tsv.gz +0 -0
- package/src/speech/data/ja-ipadic.tsv.gz +0 -0
- package/src/speech/data/ja-unihan.tsv.gz +0 -0
- package/src/speech/data/zh.json +1 -0
- package/src/speech/index.ts +204 -0
- package/src/speech/ipa.ts +83 -0
- package/src/speech/japanese.ts +105 -0
- package/src/speech/jukujikun.ts +22 -0
- package/src/speech/korean.ts +35 -0
- package/src/speech/lang.ts +151 -0
- package/src/speech/rules.ts +72 -0
- package/src/speech/syllable.ts +76 -0
- package/src/status.ts +164 -0
- package/src/tools.ts +110 -0
- package/src/webui/api-rows.css +2 -0
- package/src/webui/api-rows.ts +44 -0
- package/src/webui/client.ts +451 -0
- package/src/webui/dress-dialog.css +14 -0
- package/src/webui/dress-dialog.ts +117 -0
- package/src/webui/dress-panel.ts +160 -0
- package/src/webui/key-capture.ts +60 -0
- package/src/webui/shared/modal.css +13 -0
- package/src/webui/shared/modal.ts +77 -0
- package/src/webui/shared/problem.css +15 -0
- package/src/webui/shared/problem.ts +217 -0
- package/src/webui/shared/strings.ts +5 -0
- package/src/webui/style.css +50 -0
- package/src/window-host.ts +116 -0
- package/src/world.ts +2926 -0
- package/web/activity-motion.js +117 -0
- package/web/appearance.js +60 -0
- package/web/body-host.js +257 -0
- package/web/coo/coo.js +384 -0
- package/web/coo/figure.js +15 -0
- package/web/coo/figure.json +1224 -0
- package/web/dist/dress-dialog.css +1 -0
- package/web/dist/dress-dialog.js +1 -0
- package/web/drag-row.js +49 -0
- package/web/drag.js +149 -0
- package/web/dress.css +170 -0
- package/web/dress.html +37 -0
- package/web/dress.js +786 -0
- package/web/figure-frame.html +16 -0
- package/web/figure-frame.js +128 -0
- package/web/frame-loop.js +55 -0
- package/web/hints.js +77 -0
- package/web/i18n/de.js +170 -0
- package/web/i18n/en.js +177 -0
- package/web/i18n/es-419.js +170 -0
- package/web/i18n/fr.js +170 -0
- package/web/i18n/it.js +170 -0
- package/web/i18n/ja.js +170 -0
- package/web/i18n/ko.js +170 -0
- package/web/i18n/pt-BR.js +170 -0
- package/web/i18n/ru.js +170 -0
- package/web/i18n/zh-Hant.js +170 -0
- package/web/i18n/zh.js +175 -0
- package/web/i18n.js +54 -0
- package/{renderer/vendor → web}/kit/body.js +31 -58
- package/web/looks.js +70 -0
- package/web/mic-worklet.js +36 -0
- package/web/mic.js +117 -0
- package/web/motion-frames.js +80 -0
- package/web/motion-level.js +40 -0
- package/web/new-year-2027.svg +238 -0
- package/web/overlay.html +16 -0
- package/web/overlay.js +100 -0
- package/web/pet-app.js +3000 -0
- package/web/pet.css +642 -0
- package/web/pet.html +21 -0
- package/web/scale-slider.js +259 -0
- package/web/show-hide.js +49 -0
- package/web/sound.js +245 -0
- package/web/speech/zh.json +1 -0
- package/web/speech/zh.ogg +0 -0
- package/web/speech.js +197 -0
- package/web/stage.js +160 -0
- package/web/swap-motion.js +119 -0
- package/web/ui.js +195 -0
- package/host/launch.js +0 -187
- package/host/library.cjs +0 -638
- package/host/main.cjs +0 -389
- package/index.js +0 -93
- package/renderer/index.html +0 -22
- package/renderer/pet-sandbox.html +0 -11
- package/renderer/pet.css +0 -38
- package/renderer/pet.js +0 -251
- package/renderer/vendor/activity-motion.js +0 -101
- package/renderer/vendor/figure-frame.js +0 -115
- package/renderer/vendor/pack.css +0 -2
- /package/{renderer/vendor → web}/kit/rig.js +0 -0
package/web/coo/coo.js
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coo, the built-in figure: its drawing (a C-shaped body with two ring eyes and two short legs),
|
|
3
|
+
* its palettes and accessories, and the skin that picks them. The Coo pack (figure.js here) draws
|
|
4
|
+
* with it inside the figure frame; the pages use it for the menu's avatar, the dressing page's
|
|
5
|
+
* tiles and the colours of their own bubbles and buttons, which follow Coo's palette.
|
|
6
|
+
*
|
|
7
|
+
* Coordinates: logo units, facing right, ground at y=256 (the kit's space, web/kit/body.js).
|
|
8
|
+
*/
|
|
9
|
+
import { DEFAULT_HITS, DROP, FACES, LEG_W, STAND, f, heartD } from '../kit/body.js';
|
|
10
|
+
|
|
11
|
+
const EYES = [[113, 117], [163, 117]];
|
|
12
|
+
const BODY_W = 36;
|
|
13
|
+
const pol = (a, r) => [128 + r * Math.cos(a * Math.PI / 180), 128 - r * Math.sin(a * Math.PI / 180)];
|
|
14
|
+
const pt = p => `${f(p[0])} ${f(p[1])}`;
|
|
15
|
+
|
|
16
|
+
function cPath(gt, gb) {
|
|
17
|
+
return `M${pt(pol(gt, 84))}A84 84 0 1 0 ${pt(pol(-gb, 84))}`;
|
|
18
|
+
}
|
|
19
|
+
function ellipse(cx, cy, rx, ry) {
|
|
20
|
+
if (ry < 1.6) return `M${f(cx - rx)} ${f(cy)}L${f(cx + rx)} ${f(cy)}`;
|
|
21
|
+
return `M${f(cx - rx)} ${f(cy)}A${f(rx)} ${f(ry)} 0 1 0 ${f(cx + rx)} ${f(cy)}A${f(rx)} ${f(ry)} 0 1 0 ${f(cx - rx)} ${f(cy)}Z`;
|
|
22
|
+
}
|
|
23
|
+
function eyePath(e, cx, cy) {
|
|
24
|
+
cx += e.dx || 0; cy += e.dy || 0;
|
|
25
|
+
switch (e.shape) {
|
|
26
|
+
case 'ring': return ellipse(cx, cy, e.rx, e.ry);
|
|
27
|
+
case 'lid': return e.ry < 1.6 ? `M${f(cx - 16)} ${f(cy)}L${f(cx + 16)} ${f(cy)}` : `M${f(cx - 16)} ${f(cy)}A16 ${f(e.ry)} 0 0 0 ${f(cx + 16)} ${f(cy)}Z`;
|
|
28
|
+
case 'up': return `M${f(cx - 15)} ${f(cy + 6)}Q${f(cx)} ${f(cy - 17)} ${f(cx + 15)} ${f(cy + 6)}`;
|
|
29
|
+
case 'down': return `M${f(cx - 15)} ${f(cy - 3)}Q${f(cx)} ${f(cy + 15)} ${f(cx + 15)} ${f(cy - 3)}`;
|
|
30
|
+
case 'gt': return `M${f(cx - 10)} ${f(cy - 13)}L${f(cx + 11)} ${f(cy)}L${f(cx - 10)} ${f(cy + 13)}`;
|
|
31
|
+
case 'lt': return `M${f(cx + 10)} ${f(cy - 13)}L${f(cx - 11)} ${f(cy)}L${f(cx + 10)} ${f(cy + 13)}`;
|
|
32
|
+
case 'heart': return heartD(cx, cy, e.s);
|
|
33
|
+
case 'spiral': {
|
|
34
|
+
let d = '';
|
|
35
|
+
const max = Math.PI * 4.4;
|
|
36
|
+
for (let i = 0; i <= 44; i++) {
|
|
37
|
+
const a = max * i / 44, r = 2 + 15 * i / 44;
|
|
38
|
+
d += (i ? 'L' : 'M') + f(cx + r * Math.cos(a + e.rot)) + ' ' + f(cy + r * Math.sin(a + e.rot));
|
|
39
|
+
}
|
|
40
|
+
return d;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return '';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* ---------- accessories ----------
|
|
47
|
+
Solid shapes first; lines only where a piece is a line (band, stalk, frame), never thinner than 10.
|
|
48
|
+
Every part is painted through a color channel: c-<slot>-main / c-<slot>-acc. The names people see
|
|
49
|
+
are in figure.json (palettes and accessories) and the pages' tables (`color.<id>`).
|
|
50
|
+
A palette is [ink, eyes] per theme; ink draws the body and the pages' lines and buttons. Its `fixed` colours are
|
|
51
|
+
the figure's alone and the same in both themes: `body` in place of ink, `inside` filling the C, `pupils` the eyes. */
|
|
52
|
+
export const PALETTES = [
|
|
53
|
+
{ id: 'mint', l: ['#1B1626', '#00A870'], d: ['#FFFFFF', '#2FD59B'] },
|
|
54
|
+
{ id: 'mono', l: ['#1B1626', '#1B1626'], d: ['#FFFFFF', '#FFFFFF'] },
|
|
55
|
+
{ id: 'navigator', l: ['#14213A', '#1F6FE0'], d: ['#FFFFFF', '#5EA3FF'] },
|
|
56
|
+
{ id: 'claude', l: ['#2A1C16', '#C9623F'], d: ['#FFFFFF', '#E58B69'] },
|
|
57
|
+
{ id: 'fox', l: ['#26140F', '#DD3526'], d: ['#FFFFFF', '#FF6655'] },
|
|
58
|
+
{ id: 'purple', l: ['#1D1430', '#8B3DF0'], d: ['#FFFFFF', '#B98AFF'] },
|
|
59
|
+
{ id: 'lemon', l: ['#252010', '#D9B300'], d: ['#FFFFFF', '#FFE14F'] },
|
|
60
|
+
// after principles of Cultist Simulator, offered with the personas of the same names (core/guide.ts): the dark
|
|
61
|
+
// theme's eyes take the principle's colour on the game's wiki, the light theme's a deeper shade of the same hue
|
|
62
|
+
{ id: 'lantern', l: ['#252010', '#C9A000'], d: ['#FFFFFF', '#FFE300'] },
|
|
63
|
+
{ id: 'grail', l: ['#2A120F', '#E0452F'], d: ['#FFFFFF', '#FE6150'] },
|
|
64
|
+
{ id: 'forge', l: ['#2A1A10', '#E06A12'], d: ['#FFFFFF', '#FF8E3E'] },
|
|
65
|
+
{ id: 'heart', l: ['#2A1420', '#D9506A'], d: ['#FFFFFF', '#FE7E8B'] },
|
|
66
|
+
{ id: 'winter', l: ['#12202A', '#3A9DC4'], d: ['#FFFFFF', '#BEEEFF'] },
|
|
67
|
+
// the eyes sit on the yellow in both themes, so they keep the light theme's green
|
|
68
|
+
{ id: 'naicoo', l: ['#1B1626', '#00A870'], d: ['#FFFFFF', '#00A870'], fixed: { body: '#1B1626', inside: '#FCE44E', pupils: '#07060B' } },
|
|
69
|
+
];
|
|
70
|
+
export const HEADS = ['none', 'cat', 'bear', 'bunny', 'antenna', 'halo', 'tophat', 'party', 'sailor'];
|
|
71
|
+
export const SIDES = ['none', 'headphones', 'feather', 'earring', 'clip', 'bow'];
|
|
72
|
+
export const GLASSES = ['none', 'round', 'square', 'monocle'];
|
|
73
|
+
export const NECKS = ['none', 'bowtie', 'bell', 'scarf'];
|
|
74
|
+
export const HEAD_TOP = { none: 12, cat: -14, bear: -4, bunny: -34, antenna: -34, halo: -8, tophat: -28, party: -34, sailor: -20 };
|
|
75
|
+
|
|
76
|
+
/* color mapping: channel -> source. 'body' / 'eye' follow the palette; the rest are fixed accessory colors with a dark twin */
|
|
77
|
+
export const ACC_COLORS = [
|
|
78
|
+
{ id: 'mint', l: '#00A870', d: '#2FD59B' },
|
|
79
|
+
{ id: 'leaf', l: '#3C9A2C', d: '#80D46B' },
|
|
80
|
+
{ id: 'lemon', l: '#D9B300', d: '#FFE14F' },
|
|
81
|
+
{ id: 'fox', l: '#DD3526', d: '#FF6655' },
|
|
82
|
+
{ id: 'claude', l: '#C9623F', d: '#E58B69' },
|
|
83
|
+
{ id: 'rose', l: '#DB3F76', d: '#FF85AE' },
|
|
84
|
+
{ id: 'purple', l: '#8B3DF0', d: '#B98AFF' },
|
|
85
|
+
{ id: 'navigator', l: '#1F6FE0', d: '#5EA3FF' },
|
|
86
|
+
{ id: 'holo', l: '#1AA3D9', d: '#6FD3FF' },
|
|
87
|
+
];
|
|
88
|
+
export const LINKED = [{ id: 'body' }, { id: 'eye' }];
|
|
89
|
+
export const SLOTS = ['head', 'side', 'glasses', 'neck'];
|
|
90
|
+
export const SLOT_LISTS = { head: HEADS, side: SIDES, glasses: GLASSES, neck: NECKS };
|
|
91
|
+
export const CHANNEL_DEFAULT = { head: { main: 'body', acc: 'eye' }, side: { main: 'eye', acc: 'eye' }, glasses: { main: 'body', acc: 'eye' }, neck: { main: 'eye', acc: 'eye' } };
|
|
92
|
+
// side and neck pieces lie on top of the body outline: mapping them to the body color would make them vanish
|
|
93
|
+
export const NO_BODY = { head: false, side: true, glasses: false, neck: true };
|
|
94
|
+
// character pieces carry their original colors; picking one fills its channels, which stay editable afterwards
|
|
95
|
+
export const ITEM_COLORS = {
|
|
96
|
+
sailor: { main: 'body', acc: 'navigator' },
|
|
97
|
+
feather: { main: 'holo', acc: 'navigator' },
|
|
98
|
+
headphones: { main: 'claude', acc: 'holo' },
|
|
99
|
+
};
|
|
100
|
+
export const ROLES = {
|
|
101
|
+
cat: ['main'], bear: ['main'], bunny: ['main'], antenna: ['main', 'acc'], halo: ['acc'],
|
|
102
|
+
tophat: ['main', 'acc'], party: ['main', 'acc'], round: ['main'], square: ['main'], monocle: ['main'],
|
|
103
|
+
bowtie: ['main'], bell: ['main', 'acc'], scarf: ['main'], sailor: ['main', 'acc'],
|
|
104
|
+
headphones: ['main', 'acc'], feather: ['main', 'acc'], earring: ['main'], clip: ['main'], bow: ['main'],
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const mount = (a, r = 96) => `translate(${pt(pol(a, r))}) rotate(${f(90 - a)})`;
|
|
108
|
+
const TOPHAT_MOUNT = 104;
|
|
109
|
+
const CROWN = { top: -48, halfWidth: 22, height: 46 };
|
|
110
|
+
/** Coo's hit circles with the top hat on: the kit's body circle and one round the crown, which reaches above it. Neither
|
|
111
|
+
* follows the pose: with the hat swung its 8° at most and Coo sitting, under 3% of the crown falls outside them. */
|
|
112
|
+
const TOPHAT_HITS = [...DEFAULT_HITS, [...pol(TOPHAT_MOUNT, 96 - CROWN.top - CROWN.height / 2), Math.hypot(CROWN.halfWidth, CROWN.height / 2)]];
|
|
113
|
+
const stroke = (cls, w) => `class="${cls}" fill="none" stroke-width="${w}" stroke-linecap="round" stroke-linejoin="round"`;
|
|
114
|
+
// solid shape with rounded corners: filled and stroked in the same channel color
|
|
115
|
+
const blob = (slot, ch, w) => `class="f-${slot}-${ch} c-${slot}-${ch}" stroke-width="${w}" stroke-linejoin="round" stroke-linecap="round"`;
|
|
116
|
+
|
|
117
|
+
function headBack(id, sw) {
|
|
118
|
+
switch (id) {
|
|
119
|
+
case 'cat':
|
|
120
|
+
return [126, 82].map(a => `<path ${blob('head', 'main', 10)} transform="${mount(a)}" d="M-17 8L0 -28L17 8Z"/>`).join('');
|
|
121
|
+
case 'bear':
|
|
122
|
+
return [128, 80].map(a => `<circle class="f-head-main" transform="${mount(a)}" cx="0" cy="-8" r="18"/>`).join('');
|
|
123
|
+
case 'bunny':
|
|
124
|
+
return [[116, -10, .7], [92, 6, 1]].map(([a, off, k]) =>
|
|
125
|
+
`<g transform="${mount(a)} rotate(${f(off + sw * k)})"><ellipse class="f-head-main" cx="0" cy="-28" rx="14" ry="30"/></g>`).join('');
|
|
126
|
+
case 'antenna':
|
|
127
|
+
return `<g transform="${mount(98)} rotate(${f(sw)})"><path ${stroke('c-head-main', 14)} d="M0 0Q5 -20 0 -38"/><circle class="f-head-acc" cx="0" cy="-50" r="12"/></g>`;
|
|
128
|
+
}
|
|
129
|
+
return '';
|
|
130
|
+
}
|
|
131
|
+
function headFront(id, sw, t) {
|
|
132
|
+
switch (id) {
|
|
133
|
+
case 'sailor':
|
|
134
|
+
return `<g transform="${mount(106)} rotate(${f(sw * .2)})"><path class="f-head-main" d="M-34 3L-38 -30Q0 -40 38 -30L34 3Q0 -3 -34 3Z"/><path class="f-head-acc" d="M-37.1 -23Q0 -31 37.1 -23L36.1 -15Q0 -23 -36.1 -15ZM-35.6 -11Q0 -19 35.6 -11L34.8 -4Q0 -12 -34.8 -4Z"/></g>`;
|
|
135
|
+
case 'halo':
|
|
136
|
+
return `<g transform="${mount(98)}"><ellipse ${stroke('c-head-acc', 12)} cx="0" cy="${f(-28 + 3 * Math.sin(t * 2.2))}" rx="36" ry="9"/></g>`;
|
|
137
|
+
case 'tophat':
|
|
138
|
+
return `<g transform="${mount(TOPHAT_MOUNT)} rotate(${f(sw * .2)})"><rect class="f-head-main" x="-40" y="-7" width="80" height="12" rx="6"/><rect class="f-head-main" x="${-CROWN.halfWidth}" y="${CROWN.top}" width="${CROWN.halfWidth * 2}" height="${CROWN.height}" rx="7"/><rect class="f-head-acc" x="-22" y="-20" width="44" height="10"/></g>`;
|
|
139
|
+
case 'party':
|
|
140
|
+
return `<g transform="${mount(110)} rotate(${f(sw * .3)})"><path ${blob('head', 'main', 8)} d="M-24 2L0 -46L24 2Z"/><circle class="f-head-acc" cx="0" cy="-55" r="11"/></g>`;
|
|
141
|
+
}
|
|
142
|
+
return '';
|
|
143
|
+
}
|
|
144
|
+
// Side pieces sit where an ear would be on this profile: the back of the head, around 130–172°.
|
|
145
|
+
function sideBack(id, sw) {
|
|
146
|
+
if (id !== 'feather') return '';
|
|
147
|
+
const blade = (L, w) => `M0 0C${-w} ${f(-L * .3)} ${f(-w * .8)} ${f(-L * .8)} ${f(-L * .14)} ${-L}C${f(w * .6)} ${f(-L * .75)} ${w} ${f(-L * .3)} 0 0Z`;
|
|
148
|
+
return `<g transform="${mount(166, 92)} rotate(${f(sw * .6)})">` +
|
|
149
|
+
`<path class="f-side-acc" transform="rotate(58)" d="${blade(66, 18)}"/>` +
|
|
150
|
+
`<path class="f-side-main" transform="rotate(26)" d="${blade(56, 16)}"/>` +
|
|
151
|
+
`<path class="f-side-main" d="${blade(42, 14)}"/></g>`;
|
|
152
|
+
}
|
|
153
|
+
function sideFront(id, sw) {
|
|
154
|
+
switch (id) {
|
|
155
|
+
case 'headphones':
|
|
156
|
+
return `<path ${stroke('c-side-main', 16)} d="M${pt(pol(150, 113))}A113 113 0 0 1 ${pt(pol(76, 113))}"/>` +
|
|
157
|
+
`<rect class="f-side-acc" transform="${mount(166, 98)}" x="-24" y="-17" width="48" height="34" rx="17"/>`;
|
|
158
|
+
case 'earring':
|
|
159
|
+
return `<g transform="translate(${pt(pol(172, 99))}) rotate(${f(sw * .8)})"><circle class="f-side-main" cx="0" cy="13" r="10"/></g>`;
|
|
160
|
+
case 'clip':
|
|
161
|
+
return `<rect class="f-side-main" transform="${mount(140, 86)}" x="-17" y="-6.5" width="34" height="13" rx="6.5"/>`;
|
|
162
|
+
case 'bow':
|
|
163
|
+
return `<g class="f-side-main" transform="${mount(132, 100)} rotate(${f(sw * .3)})"><path d="M-4 0L-24 -14Q-28 0 -24 14ZM4 0L24 -14Q28 0 24 14Z"/><circle r="7"/></g>`;
|
|
164
|
+
}
|
|
165
|
+
return '';
|
|
166
|
+
}
|
|
167
|
+
function glassesD(id, gx, gy) {
|
|
168
|
+
// frames sit one ring-width outside the eyes so the two never touch
|
|
169
|
+
const L = [113 + gx, 117 + gy], R = [163 + gx, 117 + gy], M = stroke('c-glasses-main', 10);
|
|
170
|
+
switch (id) {
|
|
171
|
+
case 'round':
|
|
172
|
+
return `<circle ${M} cx="${f(L[0])}" cy="${f(L[1])}" r="31"/><circle ${M} cx="${f(R[0])}" cy="${f(R[1])}" r="31"/><path ${M} d="M${f(L[0] - 31)} ${f(L[1] - 6)}L62 106"/>`;
|
|
173
|
+
case 'square':
|
|
174
|
+
return `<rect ${M} x="${f(L[0] - 26)}" y="${f(L[1] - 22)}" width="52" height="44" rx="15"/><rect ${M} x="${f(R[0] - 26)}" y="${f(R[1] - 22)}" width="52" height="44" rx="15"/><path ${M} d="M${f(L[0] - 26)} ${f(L[1] - 6)}L62 106"/>`;
|
|
175
|
+
case 'monocle':
|
|
176
|
+
return `<circle ${M} cx="${f(R[0])}" cy="${f(R[1])}" r="31"/>`;
|
|
177
|
+
}
|
|
178
|
+
return '';
|
|
179
|
+
}
|
|
180
|
+
function neckD(id, sw) {
|
|
181
|
+
switch (id) {
|
|
182
|
+
case 'bowtie':
|
|
183
|
+
return `<g ${blob('neck', 'main', 6)} transform="translate(176 206) rotate(-32)"><path d="M-4 0L-22 -13V13ZM4 0L22 -13V13Z"/><circle r="7"/></g>`;
|
|
184
|
+
case 'bell': {
|
|
185
|
+
const a = pol(-150, 84), b = pol(-60, 84);
|
|
186
|
+
return `<path ${stroke('c-neck-main', 12)} d="M${pt(a)}A84 84 0 0 0 ${pt(b)}"/><g transform="translate(${pt(b)}) rotate(${f(sw * .6)})"><circle class="f-neck-acc" cx="0" cy="14" r="13"/></g>`;
|
|
187
|
+
}
|
|
188
|
+
case 'scarf': {
|
|
189
|
+
const a = pol(-150, 84), b = pol(-72, 84), S2 = stroke('c-neck-main', 18);
|
|
190
|
+
return `<path ${S2} d="M${pt(a)}A84 84 0 0 0 ${pt(b)}"/><g transform="rotate(${f(sw * .8)} ${pt(a)})"><path ${S2} d="M${pt(a)}q-12 22 -6 40"/></g>`;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return '';
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** A fixed body colour in place of the theme's ink, also on the accessory channels that follow the body. */
|
|
197
|
+
function fixedBody(acc, body) {
|
|
198
|
+
let v = `--skin-ink:${body}`;
|
|
199
|
+
for (const slot of SLOTS) for (const ch of ['main', 'acc']) if (acc.colors[slot][ch] === 'body') v += `;--c-${slot}-${ch}:${body}`;
|
|
200
|
+
return v;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** One frame of the figure as SVG markup, in logo units. */
|
|
204
|
+
export function figure(fc, o) {
|
|
205
|
+
const t = o.t, lx = o.look[0], ly = o.look[1], acc = o.acc, sw = o.swing || 0;
|
|
206
|
+
const fixed = PALETTES.find(p => p.id === acc.palette)?.fixed;
|
|
207
|
+
let s = fixed?.body ? `<g style="${fixedBody(acc, fixed.body)}">` : '<g>';
|
|
208
|
+
s += `<g class="ink" fill="none" stroke-width="${LEG_W}" stroke-linecap="round">`;
|
|
209
|
+
for (const l of o.legs) s += `<path d="M${f(l[0])} ${f(l[1])}L${f(l[2])} ${f(l[3])}"/>`;
|
|
210
|
+
s += `</g><g transform="translate(0 ${f(o.low)})">`;
|
|
211
|
+
s += sideBack(acc.side, sw);
|
|
212
|
+
s += headBack(acc.head, sw);
|
|
213
|
+
// reaches 2 under the body's inner edge (84 - 36 / 2) so no seam shows; the mouth shows its rim
|
|
214
|
+
if (fixed?.inside) s += `<circle fill="${fixed.inside}" cx="128" cy="128" r="68"/>`;
|
|
215
|
+
s += `<path class="ink" fill="none" stroke-width="${BODY_W}" stroke-linecap="round" d="${cPath(fc.gap[0], fc.gap[1])}"/>`;
|
|
216
|
+
s += neckD(acc.neck, sw);
|
|
217
|
+
if (fc.blush > .02) {
|
|
218
|
+
s += `<g class="blush" opacity="${f(fc.blush * .8)}"><ellipse cx="${f(99 + lx)}" cy="146" rx="11" ry="5.5"/><ellipse cx="${f(167 + lx)}" cy="146" rx="11" ry="5.5"/></g>`;
|
|
219
|
+
}
|
|
220
|
+
const close = o.eyeClose || 0;
|
|
221
|
+
fc.eyes.forEach((e, i) => {
|
|
222
|
+
const ee = { ...e };
|
|
223
|
+
if ((ee.shape === 'ring' || ee.shape === 'lid') && o.blink) ee.ry *= (1 - o.blink);
|
|
224
|
+
const cx = EYES[i][0] + lx, cy = EYES[i][1] + ly;
|
|
225
|
+
const tr = close > .01 ? ` transform="translate(0 ${f(cy)}) scale(1 ${f(Math.max(.08, 1 - close) * 100) / 100}) translate(0 ${f(-cy)})"` : '';
|
|
226
|
+
// rings and lids are the eye open and take the pupil
|
|
227
|
+
const pupil = fixed?.pupils && (ee.shape === 'ring' || ee.shape === 'lid') ? fixed.pupils : 'none';
|
|
228
|
+
s += `<path class="eye" fill="${pupil}" stroke-width="${e.sw || 12}" stroke-linecap="round" stroke-linejoin="round"${tr} d="${eyePath(ee, cx, cy)}"/>`;
|
|
229
|
+
});
|
|
230
|
+
s += glassesD(acc.glasses, lx * .4, ly * .3);
|
|
231
|
+
if (fc.brows) {
|
|
232
|
+
const bx = lx * .5, by = ly * .4;
|
|
233
|
+
const d = fc.brows === 'angry'
|
|
234
|
+
? `M${f(98 + bx)} ${f(88 + by)}L${f(124 + bx)} ${f(97 + by)}M${f(152 + bx)} ${f(97 + by)}L${f(178 + bx)} ${f(88 + by)}`
|
|
235
|
+
: `M${f(98 + bx)} ${f(96 + by)}L${f(123 + bx)} ${f(88 + by)}M${f(153 + bx)} ${f(88 + by)}L${f(178 + bx)} ${f(96 + by)}`;
|
|
236
|
+
s += `<path class="ink" fill="none" stroke-width="9" stroke-linecap="round" d="${d}"/>`;
|
|
237
|
+
}
|
|
238
|
+
s += sideFront(acc.side, sw);
|
|
239
|
+
s += headFront(acc.head, sw, t);
|
|
240
|
+
if (fc.orbit) {
|
|
241
|
+
const top = HEAD_TOP[acc.head] ?? 12;
|
|
242
|
+
for (let i = 0; i < 3; i++) {
|
|
243
|
+
const a = t * 3.2 + i * 2.094, sn = Math.sin(a);
|
|
244
|
+
s += `<circle class="eye" fill="none" stroke-width="4" cx="${f(128 + 62 * Math.cos(a))}" cy="${f(top + 12 * sn)}" r="${sn < 0 ? 5 : 7}" opacity="${sn < 0 ? .55 : 1}"/>`;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (fc.listen) {
|
|
248
|
+
// sound waves drifting in toward the face
|
|
249
|
+
for (let i = 0; i < 3; i++) {
|
|
250
|
+
const p = (t * .9 + i / 3) % 1, r = 46 - 30 * p, a0 = -.55, a1 = .55;
|
|
251
|
+
s += `<path class="eye" fill="none" stroke-width="7" stroke-linecap="round" opacity="${f(Math.sin(Math.PI * p))}" d="M${f(196 + r * Math.cos(a0))} ${f(104 + r * Math.sin(a0))}A${f(r)} ${f(r)} 0 0 1 ${f(196 + r * Math.cos(a1))} ${f(104 + r * Math.sin(a1))}"/>`;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
if (fc.think) {
|
|
255
|
+
// three rings rising from the head, the eye's own shape
|
|
256
|
+
for (let i = 0; i < 3; i++) {
|
|
257
|
+
const k = ((t * .8 + i / 3) % 1);
|
|
258
|
+
s += `<circle class="eye" fill="none" stroke-width="5" cx="${f(214 + 10 * i)}" cy="${f(46 - 22 * i - 6 * k)}" r="${4 + 3 * i}" opacity="${f(.4 + .6 * Math.sin(Math.PI * k))}"/>`;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (fc.sweat) s += `<path class="tearf" transform="translate(56 ${f(64 + 3 * Math.sin(t * 7))}) scale(1.3)" d="${DROP}"/>`;
|
|
262
|
+
if (fc.anger) {
|
|
263
|
+
const k = 1 + .12 * Math.sin(t * 10);
|
|
264
|
+
s += `<g class="angry" transform="translate(210 44) scale(${f(k * 10) / 10})" fill="none" stroke-width="7" stroke-linecap="round"><path d="M-13 -4Q-4 -4 -4 -13M4 -13Q4 -4 13 -4M13 4Q4 4 4 13M-4 13Q-4 4 -13 4"/></g>`;
|
|
265
|
+
}
|
|
266
|
+
if (fc.bang) s += `<g transform="translate(222 30)"><path class="ink" fill="none" stroke-width="11" stroke-linecap="round" d="M0 -18V4"/><circle class="inkf" cx="0" cy="18" r="5.5"/></g>`;
|
|
267
|
+
if (fc.question) s += `<g transform="translate(222 30)"><path class="ink" fill="none" stroke-width="9" stroke-linecap="round" stroke-linejoin="round" d="M-10 -12Q-10 -24 0 -24Q11 -24 11 -13Q11 -5 0 -1V5"/><circle class="inkf" cx="0" cy="18" r="5.5"/></g>`;
|
|
268
|
+
if (fc.sparkle) {
|
|
269
|
+
// a twinkling four-point glint inside each eye ring
|
|
270
|
+
EYES.forEach(([ex, ey], i) => {
|
|
271
|
+
const k = .8 + .3 * Math.sin(t * 7 + i * 2);
|
|
272
|
+
s += `<path class="eye" fill="none" stroke-width="4" stroke-linecap="round" transform="translate(${f(ex + lx)} ${f(ey + ly - 1)}) scale(${f(k)})" d="M0 -8V8M-8 0H8"/>`;
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
if (fc.streams) {
|
|
276
|
+
// tears running from each eye down the cheek
|
|
277
|
+
EYES.forEach(([ex, ey], i) => {
|
|
278
|
+
const w = 2 * Math.sin(t * 6 + i);
|
|
279
|
+
s += `<path class="tearf" opacity=".75" d="M${f(ex + lx - 5)} ${f(ey + 6)}Q${f(ex + lx - 7 + w)} ${f(ey + 30)} ${f(ex + lx - 3)} ${f(ey + 52)}L${f(ex + lx + 5)} ${f(ey + 52)}Q${f(ex + lx + 3 + w)} ${f(ey + 30)} ${f(ex + lx + 5)} ${f(ey + 6)}Z"/>`;
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
if (o.zmark) s += '<path class="eye" fill="none" stroke-width="6" stroke-linecap="round" stroke-linejoin="round" d="M204 22H220L204 42H220M226 4H236L226 16H236"/>';
|
|
283
|
+
return s + '</g></g>';
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** A static figure for previews and tiles. */
|
|
287
|
+
export function mini(face, acc, t = 0, extra = {}) {
|
|
288
|
+
return figure(FACES[face].f(t), { look: [0, 0], legs: STAND, low: 0, t, blink: 0, acc, ...extra });
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/* ---------- skin ---------- */
|
|
292
|
+
/**
|
|
293
|
+
* The body is `figure`, the id of a figure pack (src/packs.ts; Coo's is `coo`, drawn here); `scheme` is
|
|
294
|
+
* another pack's dress-up pick, Coo's picks are the fields below. Whether a pack with that id is installed
|
|
295
|
+
* is the pages' to find out: an id that is not falls back to Coo there.
|
|
296
|
+
*/
|
|
297
|
+
const FIGURE_ID = /^[a-z0-9][a-z0-9-]{0,31}$/;
|
|
298
|
+
export function defaultSkin() {
|
|
299
|
+
return { figure: 'coo', scheme: 'deepseek', palette: 'mint', head: 'none', side: 'none', glasses: 'none', neck: 'none', colors: JSON.parse(JSON.stringify(CHANNEL_DEFAULT)) };
|
|
300
|
+
}
|
|
301
|
+
const validColor = (slot, v) => (v === 'eye' || (v === 'body' && !NO_BODY[slot]) || ACC_COLORS.some(c => c.id === v));
|
|
302
|
+
/** Keeps what is valid in `raw`, defaults the rest. */
|
|
303
|
+
export function normalizeSkin(raw) {
|
|
304
|
+
const skin = defaultSkin();
|
|
305
|
+
if (!raw || typeof raw !== 'object') return skin;
|
|
306
|
+
if (typeof raw.figure === 'string' && FIGURE_ID.test(raw.figure)) skin.figure = raw.figure;
|
|
307
|
+
// a pack lists its picks in its manifest; it falls back to its first for one it does not know
|
|
308
|
+
// a pack with no picks has the empty one; the World checks a scheme against the pack's manifest
|
|
309
|
+
if (typeof raw.scheme === 'string' && /^[a-z0-9-]*$/.test(raw.scheme)) skin.scheme = raw.scheme;
|
|
310
|
+
if (PALETTES.some(p => p.id === raw.palette)) skin.palette = raw.palette;
|
|
311
|
+
for (const slot of SLOTS) if (SLOT_LISTS[slot].includes(raw[slot])) skin[slot] = raw[slot];
|
|
312
|
+
for (const slot of SLOTS) for (const ch of ['main', 'acc']) {
|
|
313
|
+
const v = raw.colors?.[slot]?.[ch];
|
|
314
|
+
if (validColor(slot, v)) skin.colors[slot][ch] = v;
|
|
315
|
+
}
|
|
316
|
+
return skin;
|
|
317
|
+
}
|
|
318
|
+
/** Picking an item: fills the character colors of pieces that carry them. */
|
|
319
|
+
export function wear(skin, slot, id) {
|
|
320
|
+
const next = { ...skin, colors: JSON.parse(JSON.stringify(skin.colors)) };
|
|
321
|
+
next[slot] = id;
|
|
322
|
+
if (ITEM_COLORS[id]) Object.assign(next.colors[slot], ITEM_COLORS[id]);
|
|
323
|
+
return next;
|
|
324
|
+
}
|
|
325
|
+
function channelValue(skin, slot, ch, dark) {
|
|
326
|
+
const v = skin.colors[slot][ch];
|
|
327
|
+
if (v === 'body') return 'var(--skin-ink)';
|
|
328
|
+
if (v === 'eye') return 'var(--skin-eye)';
|
|
329
|
+
const c = ACC_COLORS.find(x => x.id === v);
|
|
330
|
+
return dark ? c.d : c.l;
|
|
331
|
+
}
|
|
332
|
+
/** CSS custom properties for one theme side. */
|
|
333
|
+
export function skinVars(skin, dark) {
|
|
334
|
+
const p = PALETTES.find(x => x.id === skin.palette) || PALETTES[0];
|
|
335
|
+
let s = `--skin-ink:${p[dark ? 'd' : 'l'][0]};--skin-eye:${p[dark ? 'd' : 'l'][1]};`;
|
|
336
|
+
for (const slot of SLOTS) for (const ch of ['main', 'acc']) s += `--c-${slot}-${ch}:${channelValue(skin, slot, ch, dark)};`;
|
|
337
|
+
return s;
|
|
338
|
+
}
|
|
339
|
+
/** A stylesheet applying `skin` under `selector`, following the page's light/dark choice. */
|
|
340
|
+
export function skinCss(skin, selector = 'html:root') {
|
|
341
|
+
return `${selector}{${skinVars(skin, false)}}` +
|
|
342
|
+
`@media (prefers-color-scheme: dark){${selector}:not([data-theme="light"]){${skinVars(skin, true)}}}` +
|
|
343
|
+
`${selector}[data-theme="dark"]{${skinVars(skin, true)}}`;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/** Colours of Coo's drawing classes; the palette and the accessory channels come from skinCss. */
|
|
347
|
+
export const COO_CSS = `
|
|
348
|
+
:root{--skin-ink:#1B1626;--skin-eye:#00A870;--blush:#FF8FA8;--tear:#5AAEF0;--anger:#E5484D}
|
|
349
|
+
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){--skin-ink:#FFFFFF;--skin-eye:#2FD59B;--blush:#FF7F9E;--tear:#6BBDF7;--anger:#FF6369}}
|
|
350
|
+
:root[data-theme="dark"]{--skin-ink:#FFFFFF;--skin-eye:#2FD59B;--blush:#FF7F9E;--tear:#6BBDF7;--anger:#FF6369}
|
|
351
|
+
.ink{stroke:var(--skin-ink)} .inkf{fill:var(--skin-ink)} .eye{stroke:var(--skin-eye)}
|
|
352
|
+
.blush{fill:var(--blush)} .tearf{fill:var(--tear)} .angry{stroke:var(--anger)}
|
|
353
|
+
.c-head-main{stroke:var(--c-head-main, var(--skin-ink))} .c-head-acc{stroke:var(--c-head-acc, var(--skin-eye))}
|
|
354
|
+
.c-glasses-main{stroke:var(--c-glasses-main, var(--skin-ink))} .c-glasses-acc{stroke:var(--c-glasses-acc, var(--skin-eye))}
|
|
355
|
+
.c-side-main{stroke:var(--c-side-main, var(--skin-eye))} .c-side-acc{stroke:var(--c-side-acc, var(--skin-eye))}
|
|
356
|
+
.c-neck-main{stroke:var(--c-neck-main, var(--skin-eye))} .c-neck-acc{stroke:var(--c-neck-acc, var(--skin-eye))}
|
|
357
|
+
.f-head-main{fill:var(--c-head-main, var(--skin-ink))} .f-head-acc{fill:var(--c-head-acc, var(--skin-eye))}
|
|
358
|
+
.f-side-main{fill:var(--c-side-main, var(--skin-eye))} .f-side-acc{fill:var(--c-side-acc, var(--skin-eye))}
|
|
359
|
+
.f-neck-main{fill:var(--c-neck-main, var(--skin-eye))} .f-neck-acc{fill:var(--c-neck-acc, var(--skin-eye))}
|
|
360
|
+
`;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Coo as the kit's figure (createPet's `opts.figure`): draws each frame into the body's group from the
|
|
364
|
+
* skin the kit hands it (`frame.acc`); the bubble and the top of its box follow the head accessory.
|
|
365
|
+
*/
|
|
366
|
+
export function cooFigure() {
|
|
367
|
+
let skin = defaultSkin();
|
|
368
|
+
const top = () => HEAD_TOP[skin.head] ?? 12;
|
|
369
|
+
/** The markup last put in the group: a body at rest gives the same markup frame after frame. */
|
|
370
|
+
let drawn = '';
|
|
371
|
+
return {
|
|
372
|
+
draw(petG, face, frame) {
|
|
373
|
+
const s = figure(face, frame);
|
|
374
|
+
// an emptied group (the kit's setFigure swapping this figure back in) is filled again
|
|
375
|
+
if (s === drawn && petG.firstChild) return;
|
|
376
|
+
petG.innerHTML = s;
|
|
377
|
+
drawn = s;
|
|
378
|
+
},
|
|
379
|
+
setSkin(s) { if (s) skin = s; },
|
|
380
|
+
get anchors() { return { tears: [[116, 136], [166, 136]], bubble: [146, top() - 8] }; },
|
|
381
|
+
get extent() { return [20, Math.min(20, top()), 236, 256]; },
|
|
382
|
+
get hits() { return skin.head === 'tophat' ? TOPHAT_HITS : DEFAULT_HITS; },
|
|
383
|
+
};
|
|
384
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Coo pack's entry (figure.json here): Coo's body for the figure frame, the kit's body
|
|
3
|
+
* (web/kit/body.js) drawn by cooFigure. Its dress-up picks are the skin's own fields (palette and
|
|
4
|
+
* the four accessory slots, with their colour channels), so `scheme` is not used.
|
|
5
|
+
*/
|
|
6
|
+
import { COO_CSS, cooFigure, normalizeSkin, skinCss } from './coo.js';
|
|
7
|
+
|
|
8
|
+
export function createCooBody(base, { kit, host }) {
|
|
9
|
+
const start = { ...host.start, skin: normalizeSkin(host.start?.skin) };
|
|
10
|
+
const body = kit.createBody({ ...host, start }, { figure: cooFigure(), css: COO_CSS, skinCss: (s) => skinCss(s) });
|
|
11
|
+
const set = body.set;
|
|
12
|
+
// the skin comes from the World's config as it was saved; unknown values fall back to Coo's defaults
|
|
13
|
+
body.set = (s) => set(s.skin ? { ...s, skin: normalizeSkin(s.skin) } : s);
|
|
14
|
+
return body;
|
|
15
|
+
}
|