Cartoon: estudo de handoff do personagem (.studies) e AGENTS.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Mateuus
2026-11-18 05:08:57 -03:00
co-authored by Claude Opus 5.5
parent 215faa331c
commit b923132a69
46 changed files with 3775 additions and 0 deletions
@@ -0,0 +1,16 @@
# Workspace isolado do personagem cartoon
Cópia mínima do desenho do personagem do CenaForge (`src/`), sem Remotion e sem o resto do projeto.
`src/spec.ts` aqui é uma versão reduzida, só com os tipos que o desenho usa.
```sh
npm install
npx tsx render-sheet.tsx # out/sheet-full.svg + out/sheet-full.png (12 poses, corpo inteiro)
npx tsx render-sheet.tsx close # out/sheet-close.svg + .png (rosto e tronco ampliados)
npx tsc --noEmit # tipos
```
O PNG sai pelo `@resvg/resvg-js`. Se ele não instalar, abra o `.svg` no navegador ou converta com um Chrome
headless: `chrome --headless --screenshot=out.png --window-size=2160,1520 file:///.../out/sheet-full.svg`.
A tarefa está em `../PROMPT.md`.
Binary file not shown.

After

Width:  |  Height:  |  Size: 967 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 465 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 873 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 465 KiB

@@ -0,0 +1,847 @@
{
"name": "cenaforge-personagem-sandbox",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "cenaforge-personagem-sandbox",
"dependencies": {
"react": "19.3.0",
"react-dom": "19.3.0"
},
"devDependencies": {
"@resvg/resvg-js": "2.6.2",
"@types/react": "19.3.0",
"@types/react-dom": "19.3.0",
"tsx": "4.23.15",
"typescript": "5.9.3"
}
},
"node_modules/@esbuild/aix-ppc64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz",
"integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==",
"cpu": [
"ppc64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"aix"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/android-arm": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz",
"integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==",
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/android-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz",
"integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/android-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz",
"integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/darwin-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz",
"integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/darwin-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz",
"integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/freebsd-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz",
"integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/freebsd-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz",
"integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-arm": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz",
"integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==",
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz",
"integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-ia32": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz",
"integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==",
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-loong64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz",
"integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==",
"cpu": [
"loong64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-mips64el": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz",
"integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==",
"cpu": [
"mips64el"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-ppc64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz",
"integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==",
"cpu": [
"ppc64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-riscv64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz",
"integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==",
"cpu": [
"riscv64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-s390x": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz",
"integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==",
"cpu": [
"s390x"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/linux-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz",
"integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/netbsd-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz",
"integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"netbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/netbsd-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz",
"integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"netbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/openbsd-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz",
"integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/openbsd-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz",
"integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/openharmony-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz",
"integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openharmony"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/sunos-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz",
"integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"sunos"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/win32-arm64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz",
"integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/win32-ia32": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz",
"integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==",
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@esbuild/win32-x64": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz",
"integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@resvg/resvg-js": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/@resvg/resvg-js/-/resvg-js-2.6.2.tgz",
"integrity": "sha512-xBaJish5OeGmniDj9cW5PRa/PtmuVU3ziqrbr5xJj901ZDN4TosrVaNZpEiLZAxdfnhAe7uQ7QFWfjPe9d9K2Q==",
"dev": true,
"license": "MPL-2.0",
"engines": {
"node": ">= 10"
},
"optionalDependencies": {
"@resvg/resvg-js-android-arm-eabi": "2.6.2",
"@resvg/resvg-js-android-arm64": "2.6.2",
"@resvg/resvg-js-darwin-arm64": "2.6.2",
"@resvg/resvg-js-darwin-x64": "2.6.2",
"@resvg/resvg-js-linux-arm-gnueabihf": "2.6.2",
"@resvg/resvg-js-linux-arm64-gnu": "2.6.2",
"@resvg/resvg-js-linux-arm64-musl": "2.6.2",
"@resvg/resvg-js-linux-x64-gnu": "2.6.2",
"@resvg/resvg-js-linux-x64-musl": "2.6.2",
"@resvg/resvg-js-win32-arm64-msvc": "2.6.2",
"@resvg/resvg-js-win32-ia32-msvc": "2.6.2",
"@resvg/resvg-js-win32-x64-msvc": "2.6.2"
}
},
"node_modules/@resvg/resvg-js-android-arm-eabi": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/@resvg/resvg-js-android-arm-eabi/-/resvg-js-android-arm-eabi-2.6.2.tgz",
"integrity": "sha512-FrJibrAk6v29eabIPgcTUMPXiEz8ssrAk7TXxsiZzww9UTQ1Z5KAbFJs+Z0Ez+VZTYgnE5IQJqBcoSiMebtPHA==",
"cpu": [
"arm"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@resvg/resvg-js-android-arm64": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/@resvg/resvg-js-android-arm64/-/resvg-js-android-arm64-2.6.2.tgz",
"integrity": "sha512-VcOKezEhm2VqzXpcIJoITuvUS/fcjIw5NA/w3tjzWyzmvoCdd+QXIqy3FBGulWdClvp4g+IfUemigrkLThSjAQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@resvg/resvg-js-darwin-arm64": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/@resvg/resvg-js-darwin-arm64/-/resvg-js-darwin-arm64-2.6.2.tgz",
"integrity": "sha512-nmok2LnAd6nLUKI16aEB9ydMC6Lidiiq2m1nEBDR1LaaP7FGs4AJ90qDraxX+CWlVuRlvNjyYJTNv8qFjtL9+A==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@resvg/resvg-js-darwin-x64": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/@resvg/resvg-js-darwin-x64/-/resvg-js-darwin-x64-2.6.2.tgz",
"integrity": "sha512-GInyZLjgWDfsVT6+SHxQVRwNzV0AuA1uqGsOAW+0th56J7Nh6bHHKXHBWzUrihxMetcFDmQMAX1tZ1fZDYSRsw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@resvg/resvg-js-linux-arm-gnueabihf": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/@resvg/resvg-js-linux-arm-gnueabihf/-/resvg-js-linux-arm-gnueabihf-2.6.2.tgz",
"integrity": "sha512-YIV3u/R9zJbpqTTNwTZM5/ocWetDKGsro0SWp70eGEM9eV2MerWyBRZnQIgzU3YBnSBQ1RcxRZvY/UxwESfZIw==",
"cpu": [
"arm"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@resvg/resvg-js-linux-arm64-gnu": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/@resvg/resvg-js-linux-arm64-gnu/-/resvg-js-linux-arm64-gnu-2.6.2.tgz",
"integrity": "sha512-zc2BlJSim7YR4FZDQ8OUoJg5holYzdiYMeobb9pJuGDidGL9KZUv7SbiD4E8oZogtYY42UZEap7dqkkYuA91pg==",
"cpu": [
"arm64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MPL-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@resvg/resvg-js-linux-arm64-musl": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/@resvg/resvg-js-linux-arm64-musl/-/resvg-js-linux-arm64-musl-2.6.2.tgz",
"integrity": "sha512-3h3dLPWNgSsD4lQBJPb4f+kvdOSJHa5PjTYVsWHxLUzH4IFTJUAnmuWpw4KqyQ3NA5QCyhw4TWgxk3jRkQxEKg==",
"cpu": [
"arm64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MPL-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@resvg/resvg-js-linux-x64-gnu": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/@resvg/resvg-js-linux-x64-gnu/-/resvg-js-linux-x64-gnu-2.6.2.tgz",
"integrity": "sha512-IVUe+ckIerA7xMZ50duAZzwf1U7khQe2E0QpUxu5MBJNao5RqC0zwV/Zm965vw6D3gGFUl7j4m+oJjubBVoftw==",
"cpu": [
"x64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MPL-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@resvg/resvg-js-linux-x64-musl": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/@resvg/resvg-js-linux-x64-musl/-/resvg-js-linux-x64-musl-2.6.2.tgz",
"integrity": "sha512-UOf83vqTzoYQO9SZ0fPl2ZIFtNIz/Rr/y+7X8XRX1ZnBYsQ/tTb+cj9TE+KHOdmlTFBxhYzVkP2lRByCzqi4jQ==",
"cpu": [
"x64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MPL-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@resvg/resvg-js-win32-arm64-msvc": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/@resvg/resvg-js-win32-arm64-msvc/-/resvg-js-win32-arm64-msvc-2.6.2.tgz",
"integrity": "sha512-7C/RSgCa+7vqZ7qAbItfiaAWhyRSoD4l4BQAbVDqRRsRgY+S+hgS3in0Rxr7IorKUpGE69X48q6/nOAuTJQxeQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@resvg/resvg-js-win32-ia32-msvc": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/@resvg/resvg-js-win32-ia32-msvc/-/resvg-js-win32-ia32-msvc-2.6.2.tgz",
"integrity": "sha512-har4aPAlvjnLcil40AC77YDIk6loMawuJwFINEM7n0pZviwMkMvjb2W5ZirsNOZY4aDbo5tLx0wNMREp5Brk+w==",
"cpu": [
"ia32"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@resvg/resvg-js-win32-x64-msvc": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/@resvg/resvg-js-win32-x64-msvc/-/resvg-js-win32-x64-msvc-2.6.2.tgz",
"integrity": "sha512-ZXtYhtUr5SSaBrUDq7DiyjOFJqBVL/dOBN7N/qmi/pO0IgiWW/f/ue3nbvu9joWE5aAKDoIzy/CxsY0suwGosQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@types/react": {
"version": "19.3.0",
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.0.tgz",
"integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==",
"dev": true,
"license": "MIT",
"dependencies": {
"csstype": "^3.2.2"
}
},
"node_modules/@types/react-dom": {
"version": "19.3.0",
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.3.0.tgz",
"integrity": "sha512-ZI7bU42mZXXKHn/qNLEw2IrbiINU7X5+vfgdixBHkCNpYWXjKgfQ/P+uyGb5CjOLB9UcnTeg3rylQtV2hym44Q==",
"dev": true,
"license": "MIT",
"peerDependencies": {
"@types/react": "^19.3.0"
}
},
"node_modules/csstype": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.4.tgz",
"integrity": "sha512-PoKaoPzQapnEoqUSnHx1u6W6ku8CVEgKsnpmmzU3m1nwkidpPBQ8V/Zq2+bWNrsOKoKLwTGdbx6xF7BXP1zLVQ==",
"dev": true,
"license": "MIT"
},
"node_modules/esbuild": {
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz",
"integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"bin": {
"esbuild": "bin/esbuild"
},
"engines": {
"node": ">=18"
},
"optionalDependencies": {
"@esbuild/aix-ppc64": "0.28.2",
"@esbuild/android-arm": "0.28.2",
"@esbuild/android-arm64": "0.28.2",
"@esbuild/android-x64": "0.28.2",
"@esbuild/darwin-arm64": "0.28.2",
"@esbuild/darwin-x64": "0.28.2",
"@esbuild/freebsd-arm64": "0.28.2",
"@esbuild/freebsd-x64": "0.28.2",
"@esbuild/linux-arm": "0.28.2",
"@esbuild/linux-arm64": "0.28.2",
"@esbuild/linux-ia32": "0.28.2",
"@esbuild/linux-loong64": "0.28.2",
"@esbuild/linux-mips64el": "0.28.2",
"@esbuild/linux-ppc64": "0.28.2",
"@esbuild/linux-riscv64": "0.28.2",
"@esbuild/linux-s390x": "0.28.2",
"@esbuild/linux-x64": "0.28.2",
"@esbuild/netbsd-arm64": "0.28.2",
"@esbuild/netbsd-x64": "0.28.2",
"@esbuild/openbsd-arm64": "0.28.2",
"@esbuild/openbsd-x64": "0.28.2",
"@esbuild/openharmony-arm64": "0.28.2",
"@esbuild/sunos-x64": "0.28.2",
"@esbuild/win32-arm64": "0.28.2",
"@esbuild/win32-ia32": "0.28.2",
"@esbuild/win32-x64": "0.28.2"
}
},
"node_modules/fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/react": {
"version": "19.3.0",
"resolved": "https://registry.npmjs.org/react/-/react-19.3.0.tgz",
"integrity": "sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/react-dom": {
"version": "19.3.0",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.0.tgz",
"integrity": "sha512-JDk8dgif51OjFoDE70+OT9ICyYr+69HlmihNwp1+Nsfbna3t5sIiCa9ZJktDmQ4/1b/rn26hIAR2uYXDMr5r0Q==",
"license": "MIT",
"dependencies": {
"scheduler": "^0.28.0"
},
"peerDependencies": {
"react": "^19.3.0"
}
},
"node_modules/scheduler": {
"version": "0.28.0",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.28.0.tgz",
"integrity": "sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw==",
"license": "MIT"
},
"node_modules/tsx": {
"version": "4.23.15",
"resolved": "https://registry.npmjs.org/tsx/-/tsx-4.23.15.tgz",
"integrity": "sha512-Yiex1Ovn8z2xPpOWckIiysV1SSyRMY9BkLF++q0yKiDxCqRhosKfMg3janKkiLBwZ5c/YryloKwGZcrEmtwxKw==",
"dev": true,
"license": "MIT",
"dependencies": {
"esbuild": "~0.28.0"
},
"bin": {
"tsx": "dist/cli.mjs"
},
"engines": {
"node": ">=18.0.0"
},
"optionalDependencies": {
"fsevents": "~2.3.3"
}
},
"node_modules/typescript": {
"version": "5.9.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
}
}
}
@@ -0,0 +1,21 @@
{
"name": "cenaforge-personagem-sandbox",
"private": true,
"type": "module",
"scripts": {
"sheet": "tsx render-sheet.tsx",
"sheet:close": "tsx render-sheet.tsx close",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"react": "19.3.0",
"react-dom": "19.3.0"
},
"devDependencies": {
"@resvg/resvg-js": "2.6.2",
"@types/react": "19.3.0",
"@types/react-dom": "19.3.0",
"tsx": "4.23.15",
"typescript": "5.9.3"
}
}
@@ -0,0 +1,242 @@
// Folha de conferência do personagem, SEM Remotion: renderiza o mesmo componente do projeto (CharacterFigure / HandsInsert)
// em várias poses/expressões/objetos e grava out/sheet-full.png, out/sheet-close.png e out/referencia-vs-resultado.png.
//
// npm install
// npx tsx render-sheet.tsx → out/sheet-full.svg + .png (e out/referencia-vs-resultado.png)
// npx tsx render-sheet.tsx close → só o close (rosto + tronco + mãos), como no vídeo
// npx tsx render-sheet.tsx compare → folha referência × resultado lado a lado
import fs from "node:fs";
import path from "node:path";
import React from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { CharacterFigure, HandsInsert } from "./src/CharacterFigure";
import type { CharacterLook } from "./src/character";
import type { IconId } from "./src/spec";
// Personagens de teste (genéricos; não são da série de referência).
const OLD: CharacterLook = {
build: "average", height: 0.95, skin: "#e0a77a", hair: { style: "bald", color: "#9a9aa2" }, beard: { style: "mustache", color: "#8e8e96" },
glasses: "square", brows: "thick", top: { style: "jacket", color: "#4f7a4a", accent: "#e9ecef" }, bottom: { style: "pants", color: "#2c3346" },
shoes: "#2a2a30", head: "wide", nose: "curve", lids: 0.45, wrinkles: 0.6, accessories: ["towel"],
};
const COACH: CharacterLook = {
build: "heavy", height: 0.98, skin: "#d9a27a", hair: { style: "short", color: "#5a4a3a" }, beard: { style: "mustache", color: "#4a3a2a" },
glasses: "none", brows: "thick", top: { style: "jacket", color: "#22335e", accent: "#e8b13a" }, bottom: { style: "pants", color: "#22335e" },
shoes: "#f2f2f2", head: "round", nose: "round", lids: 0.15, wrinkles: 0.3, belly: true, accessories: ["whistle"],
};
const NOAH: CharacterLook = {
build: "slim", height: 0.96, skin: "#c98a5e", hair: { style: "long", color: "#e2e2e8" }, beard: { style: "long", color: "#eeeef2" },
glasses: "none", brows: "thick", top: { style: "robe", color: "#a8865a", accent: "#6b4a2a" }, bottom: { style: "pants", color: "#5a4a3a" },
shoes: "#6b4a2a", footwear: "sandals", head: "oval", nose: "long", lids: 0.5, wrinkles: 0.85,
};
const WORKER: CharacterLook = {
build: "average", height: 0.98, skin: "#dfa678", hair: { style: "short", color: "#4e3829" }, beard: { style: "full", color: "#78604c" },
glasses: "none", brows: "thick", top: { style: "shirt", color: "#6e6545" }, bottom: { style: "pants", color: "#34465e" },
shoes: "#423127", head: "round", nose: "curve", lids: 0.35, wrinkles: 0.25,
};
const MECHANIC: CharacterLook = {
build: "average", height: 0.97, skin: "#e2a878", hair: { style: "short", color: "#4a3525" }, beard: { style: "mustache", color: "#4a3525" },
glasses: "none", brows: "thick", top: { style: "shirt", color: "#687a52" }, bottom: { style: "pants", color: "#3b4c5e" },
shoes: "#4a372b", head: "round", nose: "round", lids: 0.2, wrinkles: 0.2,
};
type Cell = { look: CharacterLook; label: string; expression?: string; pose?: string; item?: IconId; gesture?: "thumbs_up" };
const CELLS: Cell[] = [
{ look: OLD, label: "stand / relaxed", pose: "stand", expression: "smile" },
{ look: OLD, label: "hold book (2 mãos)", pose: "hold", item: "book", expression: "smile" },
{ look: COACH, label: "thumbs up", pose: "thumbs_up", gesture: "thumbs_up", expression: "happy" },
{ look: COACH, label: "hold ruler (1 mão)", pose: "hold", item: "ruler", expression: "laugh" },
{ look: OLD, label: "point", pose: "point", expression: "surprised" },
{ look: OLD, label: "wave", pose: "wave", expression: "happy" },
{ look: COACH, label: "cross_arms", pose: "cross_arms", expression: "suspicious" },
{ look: OLD, label: "think", pose: "think", expression: "confused" },
{ look: OLD, label: "cover_mouth", pose: "cover_mouth", expression: "shocked" },
{ look: NOAH, label: "hold hammer", pose: "hold", item: "hammer", expression: "determined" },
{ look: NOAH, label: "hold olive", pose: "hold", item: "olive", expression: "smile" },
{ look: NOAH, label: "celebrate", pose: "celebrate", expression: "laugh" },
{ look: MECHANIC, label: "point (manga curta)", pose: "point", expression: "happy" },
{ look: WORKER, label: "cross_arms (manga curta)", pose: "cross_arms", expression: "sad" },
{ look: MECHANIC, label: "hands_on_hips", pose: "hands_on_hips", expression: "proud" },
{ look: WORKER, label: "hold phone", pose: "hold", item: "phone", expression: "neutral" },
{ look: OLD, label: "shrug", pose: "shrug", expression: "confused" },
{ look: WORKER, label: "facepalm", pose: "facepalm", expression: "sad" },
];
const Fig = CharacterFigure as unknown as React.FC<Record<string, unknown>>;
const Insert = HandsInsert as unknown as React.FC<Record<string, unknown>>;
function renderPoseSheet(mode: "full" | "close") {
const cw = 360, ch = mode === "close" ? 580 : 760, cols = 6;
const rows = Math.ceil(CELLS.length / cols);
const W = cw * cols, H = ch * rows;
const sheet = (
<svg xmlns="http://www.w3.org/2000/svg" viewBox={`0 0 ${W} ${H}`} width={W} height={H}>
<rect width={W} height={H} fill="#8f9bb3" />
{CELLS.map((c, i) => {
const x = (i % cols) * cw, y = Math.floor(i / cols) * ch;
const fw = mode === "close" ? 400 : 330, fh = fw * 2.2;
const fx = x + (cw - fw) / 2, fy = mode === "close" ? y - 42 : y + ch - fh - 10;
const cid = `cell${mode}${i}`;
return (
<g key={i}>
<defs>
<clipPath id={cid}>
<rect x={x + 4} y={y + 4} width={cw - 8} height={ch - 8} rx={14} />
</clipPath>
</defs>
<rect x={x + 4} y={y + 4} width={cw - 8} height={ch - 8} rx={14} fill={i % 2 ? "#a3adc2" : "#97a3ba"} />
<g clipPath={`url(#${cid})`}>
<svg x={fx} y={fy} width={fw} height={fh} viewBox="0 0 200 440" overflow="hidden">
<Fig look={c.look} expression={c.expression} pose={c.pose} item={c.item} gesture={c.gesture} t={0.6} />
</svg>
</g>
<text x={x + 16} y={y + 34} fontSize={22} fontFamily="Arial" fontWeight={700} fill="#1b1d26">{c.label}</text>
</g>
);
})}
</svg>
);
return { svg: renderToStaticMarkup(sheet), W };
}
function renderCompareSheet() {
const refDir = path.resolve("..", "referencia", "recortes");
const loadRef = (name: string) => {
const p = path.join(refDir, name);
if (!fs.existsSync(p)) return "";
return `data:image/png;base64,${fs.readFileSync(p).toString("base64")}`;
};
// Enquadra nosso SVG (viewBox 0 0 200 440) na mesma janela de recorte usando um `<g transform="translate(...) scale(...)">`.
const cropFig = (boxW: number, boxH: number, cx: number, cy: number, span: number, node: React.ReactNode) => {
const k = boxW / span;
const tx = boxW / 2 - cx * k;
const ty = boxH / 2 - cy * k;
return (
<g transform={`translate(${tx} ${ty}) scale(${k})`}>
<svg width={200} height={440} viewBox="0 0 200 440" overflow="visible">{node}</svg>
</g>
);
};
const items: {
title: string;
refFile: string;
bg: string;
renderOur: (w: number, h: number) => React.ReactNode;
}[] = [
{
title: "1. Rosto (close)",
refFile: "rosto-close.png",
bg: "#1e2742",
renderOur: (w, h) => cropFig(w, h, 100, 148, 138, <Fig look={OLD} expression="smile" pose="stand" t={0.6} />),
},
{
title: "2. Segurando (2 mãos)",
refFile: "maos-segurando.png",
bg: "#232d4b",
renderOur: (w, h) => cropFig(w, h, 100, 250, 128, <Fig look={OLD} expression="smile" pose="hold" item="book" t={0.6} />),
},
{
title: "3. Joinha (thumbs_up)",
refFile: "joinha.png",
bg: "#68623e",
renderOur: (w, h) => cropFig(w, h, 122, 212, 130, <Fig look={COACH} expression="happy" pose="thumbs_up" gesture="thumbs_up" t={0.6} />),
},
{
title: "4. Segurando (1 mão)",
refFile: "mao-prancheta.png",
bg: "#3e4844",
renderOur: (w, h) => cropFig(w, h, 118, 224, 132, <Fig look={COACH} expression="happy" pose="hold" item="ruler" t={0.6} />),
},
{
title: "5. Apontando (point)",
refFile: "apontando.png",
bg: "#6e4e3a",
renderOur: (w, h) => cropFig(w, h, 130, 178, 125, <Fig look={MECHANIC} expression="happy" pose="point" t={0.6} />),
},
{
title: "6. Braços cruzados",
refFile: "bracos-cruzados.png",
bg: "#8c8275",
renderOur: (w, h) => cropFig(w, h, 100, 266, 142, <Fig look={WORKER} expression="sad" pose="cross_arms" t={0.6} />),
},
{
title: "7. Insert de mãos",
refFile: "insert-maos.png",
bg: "#4a3322",
renderOur: (w, h) => (
<g transform={`translate(${-w * 0.12} ${-h * 0.14}) scale(${(w * 1.24) / 1080})`}>
<svg width={1080} height={1080} viewBox="0 0 1080 1080" overflow="visible">
<Insert look={OLD} item="book" t={0.6} />
</svg>
</g>
),
},
];
const cw = 320, ch = 320, pad = 16, topBanner = 52, labelH = 34;
const W = items.length * cw, H = topBanner + (ch + labelH) * 2 + 20;
const sheet = (
<svg xmlns="http://www.w3.org/2000/svg" viewBox={`0 0 ${W} ${H}`} width={W} height={H}>
<rect width={W} height={H} fill="#181c26" />
<text x={20} y={36} fontSize={24} fontFamily="Arial" fontWeight={700} fill="#f2c230">
REFERÊNCIA (recortes originais) × NOSSO RESULTADO (SVG puro / rig contínuo sem juntas)
</text>
{items.map((it, i) => {
const x = i * cw;
const yRef = topBanner + labelH;
const yOur = yRef + ch + labelH;
const boxW = cw - pad, boxH = ch - pad;
const refData = loadRef(it.refFile);
return (
<g key={i}>
<text x={x + 12} y={yRef - 10} fontSize={18} fontFamily="Arial" fontWeight={700} fill="#d5dce8">{it.title} — Ref</text>
<defs>
<clipPath id={`cref${i}`}><rect x={x + 8} y={yRef} width={boxW} height={boxH} rx={12} /></clipPath>
<clipPath id={`cour${i}`}><rect x={x + 8} y={yOur} width={boxW} height={boxH} rx={12} /></clipPath>
</defs>
<g clipPath={`url(#cref${i})`}>
<rect x={x + 8} y={yRef} width={boxW} height={boxH} fill="#2a3040" />
{refData && <image href={refData} x={x + 8} y={yRef} width={boxW} height={boxH} preserveAspectRatio="xMidYMid slice" />}
</g>
<text x={x + 12} y={yOur - 10} fontSize={18} fontFamily="Arial" fontWeight={700} fill="#7be08a">{it.title} — Nosso</text>
<g clipPath={`url(#cour${i})`}>
<g transform={`translate(${x + 8} ${yOur})`}>
<rect width={boxW} height={boxH} fill={it.bg} />
{it.renderOur(boxW, boxH)}
</g>
</g>
</g>
);
})}
</svg>
);
return { svg: renderToStaticMarkup(sheet), W };
}
fs.mkdirSync("out", { recursive: true });
const arg = process.argv[2] ?? "full";
const { Resvg } = await import("@resvg/resvg-js").catch(() => ({ Resvg: null as unknown as typeof import("@resvg/resvg-js").Resvg }));
if (arg === "compare") {
const { svg, W } = renderCompareSheet();
fs.writeFileSync("out/referencia-vs-resultado.svg", svg);
if (Resvg) {
fs.writeFileSync("out/referencia-vs-resultado.png", new Resvg(svg, { fitTo: { mode: "width", value: W } }).render().asPng());
console.log("out/referencia-vs-resultado.png");
}
} else {
const mode = arg === "close" ? "close" : "full";
const { svg, W } = renderPoseSheet(mode);
fs.writeFileSync(`out/sheet-${mode}.svg`, svg);
console.log(`out/sheet-${mode}.svg`);
if (Resvg) {
fs.writeFileSync(`out/sheet-${mode}.png`, new Resvg(svg, { fitTo: { mode: "width", value: W } }).render().asPng());
console.log(`out/sheet-${mode}.png`);
}
const cmp = renderCompareSheet();
fs.writeFileSync("out/referencia-vs-resultado.svg", cmp.svg);
if (Resvg) {
fs.writeFileSync("out/referencia-vs-resultado.png", new Resvg(cmp.svg, { fitTo: { mode: "width", value: cmp.W } }).render().asPng());
console.log("out/referencia-vs-resultado.png");
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,111 @@
// Personagem do estilo Cartoon montado por PEÇAS (não é desenho pronto): o mesmo personagem sai igual em
// qualquer cena e história, mudando só expressão, pose e o que tem na mão. Guardado na biblioteca de
// personagens (assets/characters/<id>/character.json) e copiado no spec de cada trecho.
export const BUILDS = ["slim", "average", "heavy"] as const;
export const HAIR_STYLES = ["short", "side", "bun", "long", "curly", "spiky", "bald", "cap"] as const;
export const BEARD_STYLES = ["none", "stubble", "mustache", "full", "goatee", "long"] as const;
export const GLASSES = ["none", "round", "square", "sun"] as const;
export const BROWS = ["thin", "thick"] as const;
/** "robe" = túnica longa até a canela (com faixa na cintura), de roupa antiga. */
export const TOP_STYLES = ["shirt", "jacket", "hoodie", "dress", "uniform", "robe"] as const;
export const BOTTOM_STYLES = ["pants", "shorts", "skirt"] as const;
export const HEAD_SHAPES = ["round", "oval", "square", "wide"] as const;
export const NOSES = ["button", "curve", "round", "long", "wide"] as const;
/** Calçado: sapato fechado (cor em `shoes`), sandália de tiras ou pé descalço. */
export const FOOTWEAR = ["shoes", "sandals", "bare"] as const;
/** Acessórios desenhados por cima da roupa (combináveis). */
export const ACCESSORIES = ["towel", "whistle", "tie", "vest", "helmet", "watch", "badge", "apron", "scarf", "headset", "chain"] as const;
export type Accessory = (typeof ACCESSORIES)[number];
// Expressões e poses são ATALHOS do rig (rig.ts): parâmetros contínuos que dá para ajustar e misturar.
import { EXPRESSION_NAMES, POSE_NAMES, type ExpressionName, type PoseName } from "./rig";
export const EXPRESSIONS = EXPRESSION_NAMES;
export const POSES = POSE_NAMES;
export type Expression = ExpressionName;
export type Pose = PoseName;
export type CharacterLook = {
build: (typeof BUILDS)[number];
/** Altura relativa (0,85 a 1,15). Criança ≈ 0,8 é aceito também. */
height: number;
skin: string;
hair: { style: (typeof HAIR_STYLES)[number]; color: string };
beard: { style: (typeof BEARD_STYLES)[number]; color: string };
glasses: (typeof GLASSES)[number];
brows: (typeof BROWS)[number];
top: { style: (typeof TOP_STYLES)[number]; color: string; accent?: string };
bottom: { style: (typeof BOTTOM_STYLES)[number]; color: string };
shoes: string;
/** Tipo de calçado (padrão "shoes"); a cor continua em `shoes`. */
footwear?: (typeof FOOTWEAR)[number];
/** Detalhe de ilustração (opcionais; sem eles o personagem sai no traço simples). */
head?: (typeof HEAD_SHAPES)[number];
nose?: (typeof NOSES)[number];
/** Pálpebra de cima de base (0 olho aberto … 0,6 meio caído, olhar cansado/esperto). */
lids?: number;
/** Rugas (0 nenhuma … 1 muitas: testa e canto dos olhos). */
wrinkles?: number;
/** Barriga saliente (o "forte" de barriga). */
belly?: boolean;
accessories?: Accessory[];
/** Cor dos acessórios principais (toalha, gravata, colete, capacete…). */
accessoryColor?: string;
};
/** Ficha do personagem na biblioteca. `kind: "3d"` aponta para a pessoa articulada da Godot (godot/kits). */
export type Character = {
schemaVersion: 1;
id: string;
name: string;
/** Texto curto que aparece na etiqueta (ex.: "Engenheiro de minas · 58 anos"). */
caption?: string;
description?: string;
kind: "cartoon" | "3d";
look: CharacterLook;
/** Só kind "3d": parâmetros da pessoa articulada da Godot. */
godot?: Record<string, unknown>;
createdAt?: string;
updatedAt?: string;
};
export const DEFAULT_LOOK: CharacterLook = {
build: "average", height: 1, skin: "#c98a5e",
hair: { style: "short", color: "#3a2a1e" }, beard: { style: "none", color: "#3a2a1e" },
glasses: "none", brows: "thin",
top: { style: "shirt", color: "#4f7a4a", accent: "#e8b13a" }, bottom: { style: "pants", color: "#2b3350" }, shoes: "#1b1b22",
};
const HEX = /^#[0-9a-f]{6}$/i;
const one = <T extends readonly string[]>(list: T, v: unknown): v is T[number] => typeof v === "string" && list.includes(v);
/** Confere a aparência e devolve os problemas (vazio = ok). */
export function validateLook(look: unknown): string[] {
const l = look as Partial<CharacterLook> | null;
if (!l || typeof l !== "object") return ["look precisa ser um objeto"];
const errors: string[] = [];
if (!one(BUILDS, l.build)) errors.push(`build: ${BUILDS.join("|")}`);
if (typeof l.height !== "number" || !(l.height >= 0.6 && l.height <= 1.2)) errors.push("height entre 0,6 e 1,2");
for (const [k, v] of [["skin", l.skin], ["hair.color", l.hair?.color], ["beard.color", l.beard?.color], ["top.color", l.top?.color],
["bottom.color", l.bottom?.color], ["shoes", l.shoes]] as const) {
if (typeof v !== "string" || !HEX.test(v)) errors.push(`${k}: cor #rrggbb`);
}
if (l.top?.accent !== undefined && !HEX.test(l.top.accent)) errors.push("top.accent: cor #rrggbb");
if (!one(HAIR_STYLES, l.hair?.style)) errors.push(`hair.style: ${HAIR_STYLES.join("|")}`);
if (!one(BEARD_STYLES, l.beard?.style)) errors.push(`beard.style: ${BEARD_STYLES.join("|")}`);
if (!one(GLASSES, l.glasses)) errors.push(`glasses: ${GLASSES.join("|")}`);
if (!one(BROWS, l.brows)) errors.push(`brows: ${BROWS.join("|")}`);
if (!one(TOP_STYLES, l.top?.style)) errors.push(`top.style: ${TOP_STYLES.join("|")}`);
if (!one(BOTTOM_STYLES, l.bottom?.style)) errors.push(`bottom.style: ${BOTTOM_STYLES.join("|")}`);
if (l.head !== undefined && !one(HEAD_SHAPES, l.head)) errors.push(`head: ${HEAD_SHAPES.join("|")}`);
if (l.nose !== undefined && !one(NOSES, l.nose)) errors.push(`nose: ${NOSES.join("|")}`);
if (l.lids !== undefined && !(typeof l.lids === "number" && l.lids >= 0 && l.lids <= 0.8)) errors.push("lids entre 0 e 0,8");
if (l.wrinkles !== undefined && !(typeof l.wrinkles === "number" && l.wrinkles >= 0 && l.wrinkles <= 1)) errors.push("wrinkles entre 0 e 1");
if (l.accessories !== undefined && (!Array.isArray(l.accessories) || l.accessories.some((a) => !one(ACCESSORIES, a)))) errors.push(`accessories: ${ACCESSORIES.join("|")}`);
if (l.footwear !== undefined && !one(FOOTWEAR, l.footwear)) errors.push(`footwear: ${FOOTWEAR.join("|")}`);
if (l.accessoryColor !== undefined && !HEX.test(l.accessoryColor)) errors.push("accessoryColor: cor #rrggbb");
return errors;
}
export const isExpression = (v: unknown): v is Expression => typeof v === "string" && (EXPRESSIONS as string[]).includes(v);
export const isPose = (v: unknown): v is Pose => typeof v === "string" && (POSES as string[]).includes(v);
@@ -0,0 +1,32 @@
// Cores e nomes de fonte do estilo Cartoon (vetor chapado). Sem Remotion: o painel também usa.
import type { TimeOfDay, Tone } from "./spec";
export const SKY: Record<TimeOfDay, [string, string]> = {
night: ["#0b0e22", "#1c2147"],
dawn: ["#2a2c5c", "#8a6a9c"],
day: ["#5aa9e6", "#bfe3f5"],
};
export const COLORS = {
ground: "#14172e",
road: "#1a1d38",
roadLine: "#3a3f6b",
house: ["#3b3f74", "#34386a", "#2f3362", "#41467e"],
houseFar: "#2a2d57",
roof: "#272a52",
window: "#1b1d3a",
light: "#ffc94a",
glow: "rgba(255, 190, 70, 0.35)",
text: "#ffffff",
key: "#ffcf3f",
danger: "#ff4d4d",
ok: "#3ddc84",
ink: "#0c0d1a",
blueprint: "#10245a",
grid: "rgba(120, 160, 255, 0.12)",
};
export const TONE_BG: Record<Tone, string> = { info: "#ffcf3f", danger: "#ff4d4d", ok: "#3ddc84" };
export const TONE_FG: Record<Tone, string> = { info: "#141414", danger: "#ffffff", ok: "#0c2a18" };
export const FONT_CAPTION = "CartoonAnton";
export const FONT_LABEL = "CartoonBebas";
@@ -0,0 +1,392 @@
// Biblioteca de MÃOS desenhadas no estilo de ilustração cartoon de referência (quadro canônico 120×120):
// - Proporções cheias, compactas e arredondadas (como em referencia/recortes/joinha.png, maos-segurando.png,
// mao-prancheta.png e apontando.png): sem dedos compridos em salsicha;
// - Base do pulso cilíndrica arredondada centrada em `wrist` (emenda perfeita com o antebraço ou punho da manga);
// - Sulcos quentes e curtos entre os dedos dobrados, e sombreado cel limpo em 2 tons acompanhando o volume;
// - Camadas `back` (atrás do objeto) e `front` (dedos/polegar na frente do objeto) para que qualquer objeto seguro
// fique claramente DENTRO da mão.
import React from "react";
import type { IconId } from "./spec";
export const HAND_SHAPES = [
"relaxed",
"open",
"point",
"thumbs_up",
"grip",
"pinch_edge",
"pinch_low",
"fist",
"on_face",
"think",
"crossed",
] as const;
export type HandShape = (typeof HAND_SHAPES)[number];
type ShapeDef = {
/** Silhueta principal (camada de trás quando `bodyBehind` é true). */
body: string;
/** Sombra cel em crescente macio (recortada pela silhueta `body`). */
shadow: string;
/** Linhas internas quentes: separação dos dedos, nós e dobras da palma. */
lines: string;
/** Peça por cima (polegar ou dedos que abraçam o objeto pela frente), com sombra e linhas próprias. */
over?: { body: string; shadow?: string; lines?: string };
/** Unhas discretas (só quando a vista pede): [cx, cy, rx, ry, giro]. */
nails?: [number, number, number, number, number][];
overNails?: [number, number, number, number, number][];
/** Pulso no quadro (centro da junta redonda onde termina o antebraço). */
wrist: [number, number];
/** Ângulo do antebraço para o qual a forma foi desenhada (0 = descendo; formas alinhadas = 0). */
wristDeg: number;
upright: boolean;
/** Com objeto: `body` fica ATRÁS do objeto e `over` fica NA FRENTE dele (objeto dentro da mão). */
bodyBehind?: boolean;
/** Ponto onde passa o cabo (`grip`) ou encosta a borda (`pinch_edge`/`pinch_low`). */
hold?: [number, number];
};
// Base redonda no pulso (centro (60, 0), raio ~13.5): garante emenda contínua em qualquer rotação.
const WRIST_CAP = "M46.5 0 A13.5 11 0 0 1 73.5 0";
const SHAPES: Record<HandShape, ShapeDef> = {
// Caída ao lado do corpo: formas arredondadas e carnudas, polegar voltado para dentro, dedos juntos curvando suavemente.
relaxed: {
body: `${WRIST_CAP}`
+ " C76 8 82.5 18 84 31 C85.2 43 84.4 55 82 65 C80.8 70.5 77.8 73.5 74.5 73 C72.2 72.6 70.8 70.5 70.4 67.5"
+ " C69.8 74 68 79 64.2 79.6 C60.8 80.2 58.6 77.5 58.2 73"
+ " C57.4 78.5 55.2 82 51.2 82 C47.5 82 45.4 78.5 45.2 73.5"
+ " C44.2 76.5 42 78 39.2 77.4 C35.8 76.6 34.2 72.5 34.8 66 C35.5 57 37.2 48 39 41"
+ " C37 46.5 35 51.5 32.2 54 C29 56.8 25 55.5 24.2 51 C23.2 45.8 25.5 37.5 29.5 29.5"
+ " C34 21 41 13.5 45 5.5 C46 3.5 46.5 1.8 46.5 0 Z",
shadow: "M66 -10 C69 5 75.5 16 78 30 C79.8 43 78.8 56 76 67 C72.5 75 62 80 44 78 L44 90 L92 90 L92 -10 Z",
lines: "M39 41 C40.8 35 41.5 28.5 40.5 22.5 M45.2 73.5 C45.8 65.5 46.8 58 48.2 52 M58.2 73 C58.8 65 59.5 57.5 60.2 51.5 M70.4 67.5 C71 61 71.6 55 72 50",
wrist: [60, 0], wristDeg: 0, upright: false,
},
// Mão aberta (acenando / comemorando): palma carnuda, dedos abrindo em leque macio que afinam na ponta, polegar na base.
open: {
body: `${WRIST_CAP}`
+ " C75.5 7 81.5 16 83.8 28 C85 35 86 43 88 51.5 C89.2 56.8 88 61.2 84.8 62.2 C81.5 63.2 78.6 60.4 76.6 55"
+ " C74.8 50.2 73.2 45.2 71.8 41.2 C73 50 74.2 60.5 74.6 68.8 C74.9 74.6 72.2 78.2 68.4 78.2 C64.8 78.2 62.6 74.8 62.2 69"
+ " C61.8 60.5 61.2 51.5 60.8 44 C60.5 54 60.2 65.5 59.6 74.2 C59.2 80.4 56.2 83.6 52.2 83.4 C48.4 83.2 46.2 79.6 46.2 73.5"
+ " C46.2 64.5 46.8 54 47.5 44.5 C46 52.5 44.5 61.5 43.5 68.5 C42.6 74 39.6 76.8 36 76.2 C32.4 75.5 30.8 72 31.5 66.2"
+ " C32.8 56 35.2 44.5 37.5 35 C33.5 38.8 29.2 42.8 25 45.5 C20.8 48.2 16.4 47 15.2 43 C14 39 16.5 34 21.2 30.2"
+ " C27.2 25.4 34.8 20.8 40.2 14.5 C43.8 10.2 46 5 46.5 0 Z",
shadow: "M67 -10 C70 5 77 16 80 30 C82 40 83.5 50 86 60 L96 60 L96 -10 Z"
+ " M46 28 C53 33.5 63 35.5 72 32 C68 38.5 57 40.5 47 35.5 Z",
lines: "M43 37 C53 34 64.5 34.5 73.5 38.5 M38.5 34 C42.8 28 46 21 47 14",
wrist: [60, 0], wristDeg: 0, upright: false,
},
// Apontando (como em referencia/recortes/apontando.png):
// Polegar redondo na lateral interna (esquerda), indicador comprido subindo firme ao lado dele,
// e os 3 outros dedos (médio, anelar, mínimo) dobrados em escada arredondada macia na direita.
point: {
body: `${WRIST_CAP}`
+ " C76 8 82.5 18 84.5 30 C86 39 86.5 48 84 55.5 C82 61 77.2 63.5 72.5 61.5"
+ " C71 66.8 66.2 69.8 60.8 68.6 C58 68 55.8 66 54.6 63.5"
+ " C53 67.5 51 69.5 48.8 69.5 C48.8 79.5 48.8 90.5 48.4 98.5"
+ " C48 105.5 44.2 109.2 39.4 109 C34.6 108.8 31.4 104.6 31.8 97.5"
+ " C32.4 85 33.8 69.5 35 55.5 C29 51.5 25 44.5 25.8 36.2 C26.6 28 32.2 21 38.8 15.2"
+ " C43.2 11 45.8 5.2 46.5 0 Z",
shadow: "M65 -10 C68.5 5 76 15 79 29 C81 39 80.5 49 78 56 C73 60.5 63 64.5 50 65.5 L50 75 L93 75 L93 -10 Z"
+ " M42.8 58 C44.2 72 44.2 88 43.2 109 L49.5 109 L49.5 58 Z",
lines: "M50.5 68.5 C50.8 60.5 51.6 53 53.5 47.5 M61.8 68 C62.4 60 63.2 53 64.8 47.5 M72.5 61.5 C73.2 55 74 49 75.2 44.5"
+ " M49 48.5 C57.5 46 67.5 44.5 78 43",
over: {
body: "M25.8 36.2 C26.6 27.5 33.8 21 41.2 24.2 C47 26.8 52.2 34.5 55.5 42.2 C58.5 49 57.5 56.5 52.2 58.8 C47 61.2 39.2 57.8 33.2 51.5 C27.8 45.8 25.2 41.2 25.8 36.2 Z",
shadow: "M28.5 43.5 C33.8 50.8 42.2 56.5 50.5 58 L47.5 62 L26.5 48.5 Z",
lines: "M35 27.5 C41.2 32.5 48 39.5 52.5 46.5",
},
wrist: [60, 0], wristDeg: 0, upright: false,
},
// Joinha (proporção compacta e redonda idêntica a referencia/recortes/joinha.png):
// Punho cheio e arredondado (largura ~52, altura ~56 na palma), 4 dedos gordinhos empilhados com sulcos curtos,
// e polegar forte subindo na vertical do topo da palma.
thumbs_up: {
body: "M74 88 A13.5 13.5 0 0 0 90 66"
+ " C87 57 82 49 75 43"
+ " C75.5 32 75 19 73 10.5 C71.2 3.5 66.5 0 60.5 0.5 C54.8 1 51.2 6 51 14.5"
+ " C50.8 23.5 51.2 32.5 50 39 C41 38.5 33 40 29.5 45.5 C26.2 50.6 27.8 57 33 58.8"
+ " C27.2 61.2 26.8 68.8 32.2 71.6 C28.2 74.4 28.8 81.8 34 84"
+ " C31.8 87.5 34.2 93.8 41 95 C51 96.8 63 96 70.5 91.5 C72.5 90.2 73.5 89 74 88 Z",
shadow: "M67 2 C70.8 10 72 25 72 41 C78.5 46 84 55 87 65 L92 74 L74 92 L34 97 L30 89"
+ " C44 93.5 59 93 68.5 88.5 C75.5 85 78.5 76 77 65 C75.5 54 72 46.5 66 42.5 L66 2 Z"
+ " M31.5 57.2 C40.5 59.8 50.5 60 59 58.5 L59 61.2 C49.5 62.6 40.5 62.2 31 59.8 Z"
+ " M31 70 C40 72.6 50.5 72.8 59 71.2 L59 74 C49.5 75.4 40 75 30.5 72.6 Z"
+ " M33 82.4 C41.5 84.8 50 85 57.5 83.8 L57.5 86.5 C49 87.6 41.5 87.2 32.5 85 Z",
lines: "M33 58.8 C41 60.8 50 61 58 59.5 M32.2 71.6 C40.5 73.6 50 73.8 58 72.2 M34 84 C41.8 85.8 49.5 86 56.5 84.8"
+ " M51 36.5 C56.5 39.8 64.5 40.2 71.5 37.5",
wrist: [82, 76], wristDeg: 135, upright: true,
},
// Punho segurando um cabo ou prancheta (proporção compacta e redonda idêntica a referencia/recortes/mao-prancheta.png):
// - `body` (atrás do cabo): base da palma;
// - `over` (na frente do cabo): mão redonda e carnuda com 4 dedos roliços empilhados e 3 sulcos curtos.
grip: {
body: "M88 77 A13.5 13.5 0 0 0 88 50"
+ " C81 44 71 40 59 40 C47 40 37 43 33.5 51 C30 59 31 73 36 83"
+ " C41 91 54 93 67 90 C77 87.5 84 83 88 77 Z",
shadow: "M76 44 C83 52 86 64 83 75 C80 84 72 90 60 92 L92 92 L92 44 Z",
lines: "",
over: {
body: "M86 48 C79 38 66 33.5 53 34 C41 34.5 33 38 30.5 44.5 C28.5 49.5 30.2 53.5 34.5 55.2"
+ " C28 57 26 63 29.5 68 C31 70 33 71 35.5 71.6"
+ " C29.5 73.8 29 80.5 34 83.5 C32 86.8 34.2 92.5 41 93.8"
+ " C51.5 95.8 65 95 75 90.5 C83 87 88 81 89.5 74 C91 66 90 55 86 48 Z",
shadow: "M76 41 C84 49 87.5 61 85 73 C82 83 73.5 90 61.5 92.5 C49.5 95 39 94 32 90.5 L32 97 L92 97 L92 41 Z"
+ " M33.5 53.8 C42 56.2 52.5 56.2 61 54.5 L61 57.2 C52 59 41.5 58.8 32.5 56.2 Z"
+ " M33.8 70.2 C42 72.5 52 72.8 60 71.2 L60 74 C51 75.5 41 75 32.8 72.8 Z"
+ " M33.5 82.2 C41.5 84.5 51 84.8 58.5 83.5 L58.5 86.2 C50 87.5 40.5 87.2 32.5 84.8 Z",
lines: "M34.5 55.2 C43 57.2 53 57 60.5 55.2 M35.5 71.6 C43.5 73.6 52.5 73.8 59.5 72.2 M34 83.5 C42 85.5 50.5 85.8 57.5 84.5",
},
wrist: [86, 64], wristDeg: 45, upright: true, bodyBehind: true, hold: [44, 65],
},
// Segurando a borda lateral de um objeto largo (proporção redonda e compacta idêntica a referencia/recortes/maos-segurando.png):
// - `body` (atrás): palma arredondada que apoia por trás do objeto;
// - `over` (na frente da borda): mão redonda e gordinha (`largura ~50, altura ~58`) com 4 dedos roliços e 3 sulcos curtos!
pinch_edge: {
body: "M88 73 A13.5 13.5 0 0 0 88 46"
+ " C81 39 70 35 59 36 C47 37 40 44 40 58 C40 72 45 83 54 88"
+ " C63 93 75 91 83 83 C86 79.5 87.5 76 88 73 Z",
shadow: "M76 40 C83 48 86 60 83.5 72 C81 82 73 88 61 90 L92 92 L92 40 Z",
lines: "",
over: {
body: "M85 44 C77 34 63 30 49 31.5 C37.5 32.8 30.5 38.5 32.5 45.8"
+ " C26.8 48 25 55.2 30 59.5 C25 62.2 24.8 70 30.5 73.5"
+ " C27.2 77.2 29.2 84.5 36 87 C46 90.5 60 91 72 87"
+ " C80.5 84 86.5 78 88.2 70.5 C90 62 89 51 85 44 Z",
shadow: "M75 38 C83 47 86.5 59.5 84 71.5 C81.5 81.5 73 87.5 60.5 89 C47.5 90.5 37 88 31.5 83.5 L31.5 93 L92 93 L92 38 Z"
+ " M32 44.5 C40.5 47.2 50.5 47.5 58.5 46 L58.5 48.8 C49.5 50.2 39.5 50 31 47.2 Z"
+ " M29.5 58.2 C38 61 48 61.2 56 59.8 L56 62.5 C47 64 37 63.8 28.5 61 Z"
+ " M30 72.2 C38.5 74.8 48 75 55.5 73.6 L55.5 76.4 C46.5 77.8 37.5 77.5 29 75 Z",
lines: "M32.5 45.8 C41 48 50.5 48.2 58 46.8 M30 59.5 C38.5 61.8 48 62 55.5 60.5 M30.5 73.5 C38.8 75.8 47.8 76 54.8 74.6",
},
wrist: [85, 60], wristDeg: 62, upright: true, bodyBehind: true, hold: [44, 60],
},
// Pegada de borda com o antebraço vindo de baixo (HandsInsert): dedos atrás da página e polegar comprido + palma na frente.
pinch_low: {
body: "M84 106 A14 14 0 0 0 104 86"
+ " C99 76 95 64 92 52 C89 39 81 28 69 26 C59 24.5 52 30 51 40"
+ " C49.5 55 50 72 54 84 C58 93 69 98 84 106 Z",
shadow: "M78 28 C88 39 92 55 95 70 C97 80 100 86 105 92 L112 104 L76 108 L54 90 C66 93 78 90 83 80 C88 68 85 45 78 28 Z",
lines: "M52 44 C59 44.5 66.5 46.5 72.5 50 M51.5 58 C58.5 58.8 65.5 60.8 71.5 64 M52.5 72 C58.5 72.8 64.5 74.8 69.5 78",
over: {
body: "M84 106 A14 14 0 0 0 104 86"
+ " C98 76 91 64 82 54 C72 44 56 34 45 30.5 C36.5 27.8 30.5 32.5 33 40"
+ " C35.5 47.5 45 54.5 55 61 C61 65 65 73 68 84 C71 94 77 101 84 106 Z",
shadow: "M34 41 C42 49 52 56 60 62 C65 68 68 78 72 90 L98 106 L82 110 L62 92 L32 46 Z",
lines: "M56 61 C62 64 67 69 70 76",
},
wrist: [94, 96], wristDeg: 135, upright: true, bodyBehind: true, hold: [56, 52],
},
// Punho fechado: 4 dedos dobrados em arco macio, polegar travando por cima do indicador e do médio.
fist: {
body: `${WRIST_CAP}`
+ " C75.5 8 81 18 82.8 30 C84.2 40 84.2 50 81.5 56.5 C79.2 61.5 75.2 63.2 71.5 61.8"
+ " C69.8 66.2 65.5 68.5 60.8 67.6 C58.2 67 56.2 65.2 55 62.8"
+ " C53.2 66.8 48.8 68.8 44.2 67.6 C39.5 66.4 36.2 62.2 35 55.5"
+ " C33.2 46 33.5 35 36.5 25.5 C39.5 16.5 44 9 46.2 2.5 C46.4 1.5 46.5 0.8 46.5 0 Z",
shadow: "M65 -10 C68 5 75 15 78 29 C80 40 79 50 75 57 C68 63 54 66 38 62 L38 74 L92 74 L92 -10 Z",
lines: "M46 67 C46.2 59.5 47 52.5 48.8 47 M60.8 67.6 C61.2 60 61.8 53 63.4 47.5 M71.5 61.8 C72 55.5 72.6 49.5 73.8 45"
+ " M42 48.5 C53 45.8 65 44.5 76.5 43.2",
over: {
body: "M35.5 28 C41 34 49 41 55.5 46.5 C60.2 50.5 61 56.8 56.5 59.8 C52 62.8 44.8 60 39.5 54.2 C34.5 48.8 32.5 39.5 35.5 28 Z",
shadow: "M35 44 C39.5 51 46.5 56.5 54 58.5 L50 62.5 L33 50 Z",
},
wrist: [60, 0], wristDeg: 0, upright: false,
},
// Mão no rosto (tapar a boca / facepalm): palma arredondada e macia, dedos unidos em concha com sulcos curtos nas pontas.
on_face: {
body: `${WRIST_CAP}`
+ " C75 8 80 18 81.5 30 C82.8 41 82.4 55 80.5 67 C79.5 73 76.8 76 73.5 75.5 C71.5 75.2 70.2 73.5 69.8 71"
+ " C69.2 76.5 67.2 81.5 63.2 82 C59.8 82.4 58 80 57.6 76.5"
+ " C57 81.5 54.6 85 50.6 85 C46.8 85 44.8 81.5 44.6 76.5"
+ " C43.8 79.8 41.4 81.8 38.2 81.2 C34.8 80.5 33 76.5 33.6 69.5 C34.5 58 36.2 46.5 38 38"
+ " C35.5 42.5 33 46.5 30 48.5 C26.8 50.5 23.2 49 22.6 45 C22 40 24.8 32.5 29.5 25.5"
+ " C34.5 18 41.8 11 45.2 4 C46 2.5 46.5 1.2 46.5 0 Z",
shadow: "M65 -10 C68 5 74.5 16 77 30 C78.5 43 78 58 75.5 71 C72.5 79 61 84 44 83 L44 92 L90 92 L90 -10 Z",
lines: "M38 38 C39.8 32.5 40.6 27 40 21 M44.6 76.5 C45 69.5 45.8 63 46.8 57.5 M57.6 76.5 C58 69.5 58.4 63 59 57.5 M69.8 71 C70.2 65 70.6 59.5 71 55",
wrist: [60, 0], wristDeg: 0, upright: false,
},
// Mão pensando (apoiada no queixo): punho macio sob o queixo com o indicador estendido na bochecha/queixo
// e os outros 3 dedos dobrados em gomos arredondados (sem aspecto de garfo ou bloco).
think: {
body: `${WRIST_CAP}`
+ " C75.5 8 81.5 18 83.2 30 C84.5 40 84 50 81 57 C78.5 62.5 73.8 64.5 69.5 62.5"
+ " C67.8 67.2 63 69.5 58 68.2 C55.2 67.5 53.2 65.5 52.2 63"
+ " C50.5 66.5 47.8 68.2 44.8 67.5 C44.5 75 44 83.5 43 90"
+ " C42 96.2 38.2 99.5 33.8 98.8 C29.4 98 26.8 93.8 27.6 87"
+ " C29 75.5 31.2 61 33.5 48 C29.5 50.5 25 51.5 21.5 49.5 C17.8 47.5 16.5 42.5 18.8 37.5"
+ " C21.5 31.5 28 25.5 34.5 19.5 C40.5 14 44.8 7 46.5 0 Z",
shadow: "M65 -10 C68 5 75.5 16 78 30 C80 41 79 50 75 57 C69 63.5 57 66.5 43 65 L43 74 L91 74 L91 -10 Z"
+ " M38 56 C39.5 68 39.5 82 38.5 99 L44.5 99 L45 56 Z",
lines: "M33.5 48 C37.5 43 41 37 42.5 31 M45 66.5 C45.8 59 47 52 48.8 46.5 M58 68.2 C58.8 60.5 59.8 53.5 61.5 47.5 M69.5 62.5 C70.2 56 71 50 72.2 45",
wrist: [60, 0], wristDeg: 0, upright: false,
},
// Mão de braços cruzados apoiada no bíceps oposto (como em referencia/recortes/bracos-cruzados.png):
// 3 dedos roliços e macios pousados diagonalmente sobre o braço.
crossed: {
body: `${WRIST_CAP}`
+ " C74.5 8 79 18 80 29 C81 40 79.5 52 75.8 61.5 C73.2 68 68.5 71 63.8 69.5"
+ " C61.4 75.8 56.2 79.2 50.5 77.6 C47 76.6 44.6 73.6 43.8 69.5"
+ " C41.2 74 36.2 76 31.2 73.8 C26.4 71.6 24.4 66 26.8 59.2"
+ " C30 50 34.8 38.5 39 27.5 C42.2 19 45.4 9.5 46.5 0 Z",
shadow: "M64 -10 C67 5 72.5 16 74 30 C75 42 73.5 53 70 62 C65.5 70 52 75 33 72 L33 82 L88 82 L88 -10 Z",
lines: "M43.8 69.5 C46.5 59.5 49.8 50 53.2 42 M63.8 69.5 C65.8 60 67.8 51 70.2 43.5",
wrist: [60, 0], wristDeg: 0, upright: false,
},
};
/** Objetos seguros com as DUAS mãos (pelas bordas, na frente do peito). O resto vai numa mão só (`grip`). */
export const TWO_HANDED: IconId[] = ["book", "tablet"];
/**
* Como cada objeto entra no punho (`grip`): ponto do cabo no quadro 100×100 do ícone e o giro que deixa o cabo em pé
* (cabeça do martelo, ponta do ramo e da régua para cima) com sobra visível do cabo abaixo da mão.
*/
export const GRIP: Partial<Record<IconId, { x: number; y: number; rot: number }>> = {
hammer: { x: 50, y: 68, rot: 20 },
olive: { x: 36, y: 68, rot: -42 },
ruler: { x: 32, y: 50, rot: -78 },
phone: { x: 50, y: 62, rot: -6 },
fuel: { x: 50, y: 30, rot: 0 },
bulb: { x: 50, y: 74, rot: 0 },
};
/**
* Posição da forma: espelho (`mirror`), giro em graus e escala, a partir do pulso na tela, do ângulo do antebraço e do
* lado do braço. Formas alinhadas giram com o antebraço; as "em pé" acompanham o ângulo para o qual foram desenhadas.
*/
export function handPlacement(shape: HandShape, x: number, y: number, foreDeg: number, s: number, k: number) {
const def = SHAPES[shape];
let mirror: number;
let rot: number;
if (def.upright) {
mirror = s >= 0 ? 1 : -1;
rot = foreDeg - def.wristDeg * mirror;
} else {
const up = Math.cos((foreDeg * Math.PI) / 180) >= 0;
mirror = up ? s : -s;
rot = foreDeg;
}
const [wx, wy] = def.wrist;
const transform = `translate(${x} ${y}) rotate(${rot}) scale(${k * mirror} ${k}) translate(${-wx} ${-wy})`;
const r = (rot * Math.PI) / 180;
/** Ponto do quadro 120×120 → tela. */
const map = (px: number, py: number) => {
const lx = (px - wx) * k * mirror;
const ly = (py - wy) * k;
return { x: x + lx * Math.cos(r) - ly * Math.sin(r), y: y + lx * Math.sin(r) + ly * Math.cos(r) };
};
return { def, mirror, rot, transform, map, hold: def.hold ? map(def.hold[0], def.hold[1]) : null };
}
/** Pulso que põe o ponto `hold` da forma em (hx, hy) — para pôr as mãos nas bordas do objeto. */
export function wristForHold(shape: HandShape, hx: number, hy: number, foreDeg: number, s: number, k: number) {
const p = handPlacement(shape, 0, 0, foreDeg, s, k);
return { x: hx - (p.hold?.x ?? 0), y: hy - (p.hold?.y ?? 0) };
}
function shadeHex(hex: string, k: number): string {
const n = parseInt(hex.slice(1), 16);
const c = (v: number) => Math.max(0, Math.min(255, Math.round(v * k))).toString(16).padStart(2, "0");
return `#${c((n >> 16) & 255)}${c((n >> 8) & 255)}${c(n & 255)}`;
}
/** Mistura duas cores hex (0 = a, 1 = b). */
function mixHex(a: string, b: string, t: number): string {
const pa = parseInt(a.slice(1), 16), pb = parseInt(b.slice(1), 16);
const ch = (sh: number) => Math.round(((pa >> sh) & 255) * (1 - t) + ((pb >> sh) & 255) * t).toString(16).padStart(2, "0");
return `#${ch(16)}${ch(8)}${ch(0)}`;
}
function coolHex(hex: string, k: number): string {
const n = parseInt(hex.slice(1), 16);
const r = ((n >> 16) & 255) * k * 0.96, g = ((n >> 8) & 255) * k * 0.96, b = (n & 255) * k + 6;
const c = (v: number) => Math.max(0, Math.min(255, Math.round(v))).toString(16).padStart(2, "0");
return `#${c(r)}${c(g)}${c(b)}`;
}
/**
* Desenha a forma de mão no lugar. `layer`: "back" = o que fica atrás do objeto, "front" = o que fica na frente,
* "all" = tudo. `light` = lado da sombra na tela (1 = direita).
*/
export function HandArt({ shape, x, y, foreDeg, s, k, skin, light = 1, layer = "all", uid }: {
shape: HandShape; x: number; y: number; foreDeg: number; s: number; k: number; skin: string; light?: number;
layer?: "all" | "back" | "front"; uid: string;
}) {
const p = handPlacement(shape, x, y, foreDeg, s, k);
const def = p.def;
const rightOnScreen = p.mirror * Math.cos((p.rot * Math.PI) / 180);
const flipShadow = Math.sign(rightOnScreen || 1) !== Math.sign(light || 1);
const shadowT = flipShadow && !def.upright ? "translate(120 0) scale(-1 1)" : undefined;
const creaseColor = shadeHex(skin, 0.76);
const shadowFill = coolHex(skin, 0.86);
const skinLite = mixHex(skin, "#fff6ea", 0.06);
const gradId = `hg${uid}${layer}`;
const lineProps = {
stroke: creaseColor,
strokeWidth: 3.1,
strokeLinecap: "round" as const,
strokeLinejoin: "round" as const,
fill: "none",
opacity: 0.9,
};
const nail = ([cx, cy, rx, ry, a]: [number, number, number, number, number], i: number) => (
<ellipse
key={i}
cx={cx}
cy={cy}
rx={rx}
ry={ry}
transform={`rotate(${a} ${cx} ${cy})`}
fill={mixHex(skin, "#fae5de", 0.38)}
opacity={0.8}
/>
);
const bodyLayer = def.bodyBehind ? "back" : def.hold ? "front" : "all";
const showBody = layer === "all" || layer === bodyLayer || (bodyLayer === "all" && layer === "front");
const showOver = layer !== "back";
return (
<g transform={p.transform}>
<defs>
<linearGradient id={gradId} x1="15%" y1="10%" x2="85%" y2="90%">
<stop offset="0%" stopColor={skinLite} />
<stop offset="100%" stopColor={skin} />
</linearGradient>
<clipPath id={`hb${uid}${layer}`}><path d={def.body} /></clipPath>
{def.over && <clipPath id={`ho${uid}${layer}`}><path d={def.over.body} /></clipPath>}
</defs>
{showBody && (
<>
<path d={def.body} fill={`url(#${gradId})`} />
<g clipPath={`url(#hb${uid}${layer})`}>
<path d={def.shadow} fill={shadowFill} transform={shadowT} opacity={0.88} />
</g>
{def.lines && <path d={def.lines} {...lineProps} />}
{(def.nails ?? []).map(nail)}
</>
)}
{showOver && def.over && (
<>
<path d={def.over.body} fill={`url(#${gradId})`} />
<g clipPath={`url(#ho${uid}${layer})`}>
{def.over.shadow && <path d={def.over.shadow} fill={shadowFill} opacity={0.88} />}
</g>
{def.over.lines && <path d={def.over.lines} {...lineProps} />}
{(def.overNails ?? []).map(nail)}
</>
)}
</g>
);
}
@@ -0,0 +1,127 @@
// Ícones chapados (viewBox 100×100). Formas simples, sem contorno, na paleta do estilo.
import React from "react";
import { COLORS } from "./colors";
import type { IconId } from "./spec";
const INK = COLORS.ink;
const DRAW: Record<IconId, React.ReactNode> = {
house: (<>
<polygon points="8,46 50,12 92,46" fill={COLORS.roof} />
<rect x={16} y={44} width={68} height={48} fill={COLORS.house[3]} />
<rect x={24} y={54} width={14} height={14} rx={2} fill={COLORS.light} />
<rect x={62} y={54} width={14} height={14} rx={2} fill={COLORS.light} />
<rect x={44} y={66} width={12} height={26} fill={COLORS.window} />
</>),
generator: (<>
<rect x={8} y={30} width={84} height={56} rx={8} fill="#2a2d3c" />
<rect x={14} y={22} width={58} height={16} rx={6} fill="#e8463d" />
<rect x={16} y={44} width={34} height={34} rx={4} fill="#4a4e63" />
{[0, 1, 2, 3, 4].map((i) => <rect key={i} x={19} y={48 + i * 6} width={28} height={3} fill="#2a2d3c" />)}
<circle cx={64} cy={52} r={4} fill="#11121a" /><circle cx={76} cy={52} r={4} fill="#11121a" />
<circle cx={70} cy={68} r={3} fill={COLORS.ok} />
<rect x={10} y={86} width={14} height={6} fill="#11121a" /><rect x={76} y={86} width={14} height={6} fill="#11121a" />
</>),
fuel: (<>
<rect x={20} y={22} width={60} height={72} rx={8} fill="#c8352f" />
<rect x={26} y={50} width={48} height={38} rx={4} fill="#e6b347" />
<path d="M30 22 L30 12 L60 12 L60 22" stroke="#c8352f" strokeWidth={6} fill="none" />
<rect x={66} y={8} width={12} height={14} fill="#c8352f" />
<path d="M30 56 L70 84 M70 56 L30 84" stroke="#c8352f" strokeWidth={3} />
</>),
battery: (<>
<rect x={28} y={14} width={44} height={80} rx={8} fill="#1d2b2a" stroke={COLORS.ok} strokeWidth={4} />
<rect x={40} y={6} width={20} height={10} rx={3} fill={COLORS.ok} />
<polygon points="54,30 38,58 50,58 46,80 62,50 50,50" fill={COLORS.ok} />
</>),
phone: (<>
<rect x={30} y={8} width={40} height={84} rx={8} fill="#15161f" />
<rect x={35} y={16} width={30} height={64} rx={3} fill="#2c3150" />
<rect x={42} y={40} width={16} height={8} rx={2} fill={COLORS.danger} />
</>),
door: (<>
<rect x={24} y={6} width={52} height={90} rx={3} fill="#4a2f22" />
<rect x={30} y={14} width={40} height={34} rx={2} fill="#3c251b" />
<rect x={30} y={54} width={40} height={34} rx={2} fill="#3c251b" />
<circle cx={66} cy={56} r={3.5} fill="#e6c27a" />
</>),
eye: (<>
<path d="M6 50 Q50 10 94 50 Q50 90 6 50 Z" fill="#f4f6ff" />
<circle cx={50} cy={50} r={20} fill="#2c3466" /><circle cx={50} cy={50} r={9} fill={INK} /><circle cx={56} cy={44} r={4} fill="#fff" />
</>),
bulb: (<>
<circle cx={50} cy={40} r={28} fill={COLORS.light} />
<rect x={38} y={64} width={24} height={16} rx={3} fill="#9aa0b8" /><rect x={42} y={80} width={16} height={8} rx={3} fill="#6c7190" />
</>),
solar: (<>
<polygon points="10,70 30,30 92,30 72,70" fill="#2b4fb8" />
<path d="M30 50 L82 50 M27 40 L87 40 M24 60 L77 60 M45 30 L35 70 M61 30 L51 70 M77 30 L67 70" stroke="#8fb0ff" strokeWidth={2} />
<rect x={46} y={70} width={6} height={22} fill="#6c7190" />
</>),
warning: (<>
<polygon points="50,8 94,88 6,88" fill={COLORS.key} />
<rect x={46} y={34} width={8} height={30} rx={3} fill={INK} /><circle cx={50} cy={74} r={5} fill={INK} />
</>),
money: (<>
<rect x={8} y={26} width={84} height={48} rx={6} fill="#3a9e5f" />
<circle cx={50} cy={50} r={14} fill="#2b7a49" /><text x={50} y={57} textAnchor="middle" fontSize={20} fontWeight={700} fill="#d9f5e3">$</text>
</>),
clock: (<>
<circle cx={50} cy={50} r={40} fill="#f4f6ff" /><circle cx={50} cy={50} r={34} fill="#232850" />
<rect x={48} y={24} width={4} height={28} rx={2} fill="#fff" /><rect x={48} y={48} width={22} height={4} rx={2} fill={COLORS.key} />
</>),
// Itens de mão e objetos de história antiga (também servem como objeto solto na cena).
olive: (<>
<path d="M14 94 Q44 62 86 14" stroke="#3d2814" strokeWidth={8.5} fill="none" strokeLinecap="round" />
<path d="M14 94 Q44 62 86 14" stroke="#7d5632" strokeWidth={5.5} fill="none" strokeLinecap="round" />
{[[38, 62, -38], [48, 52, 28], [58, 42, -38], [68, 32, 28], [78, 22, -38], [84, 15, -12]].map(([x, y, r], i) => (
<g key={i} transform={`rotate(${r} ${x} ${y})`}>
<ellipse cx={x} cy={y} rx={13.5} ry={6} fill={i % 2 ? "#557d32" : "#446827"} />
<ellipse cx={x} cy={y - 1} rx={12} ry={4.2} fill={i % 2 ? "#84ab4c" : "#6c943c"} />
<path d={`M${x - 9} ${y} L${x + 9} ${y}`} stroke="#9ec462" strokeWidth={1.2} strokeLinecap="round" opacity={0.7} />
</g>
))}
<circle cx={54} cy={54} r={4.5} fill="#2e2b4a" /><circle cx={52.5} cy={52.5} r={1.5} fill="#76729e" />
<circle cx={72} cy={35} r={4.5} fill="#2e2b4a" /><circle cx={70.5} cy={33.5} r={1.5} fill="#76729e" />
</>),
hammer: (<>
<g transform="rotate(-20 50 64)">
<rect x={42.5} y={28} width={15} height={68} rx={6} fill="#5c381c" />
<rect x={44} y={29} width={12} height={66} rx={5} fill="#9c6638" />
<rect x={45.5} y={30} width={4.5} height={64} rx={2} fill="#b87e4a" opacity={0.75} />
<rect x={42} y={32} width={16} height={6} rx={2} fill="#4a2e16" />
</g>
<g transform="rotate(-20 47 25)">
<rect x={18} y={11} width={58} height={25} rx={5} fill="#4d525e" />
<rect x={19} y={12} width={56} height={22} rx={4} fill="#8f96a3" />
<rect x={21} y={14} width={52} height={8} rx={3} fill="#b4bac6" opacity={0.7} />
<rect x={18} y={11} width={14} height={25} rx={4} fill="#686e7a" />
</g>
</>),
tablet: (<>
<path d="M18 10 Q50 4 82 10 L86 88 Q50 96 14 88 Z" fill="#8f6c4a" />
<path d="M20 12 Q50 6 80 12 L84 86 Q50 93 16 86 Z" fill="#b8916a" />
{Array.from({ length: 7 }, (_, i) => <path key={i} d={`M24 ${22 + i * 10} L76 ${22 + i * 10}`} stroke="#785638" strokeWidth={2.5} strokeDasharray="5 3 2 3" />)}
<path d="M70 70 L86 60 L86 88 L64 92 Z" fill="#000" opacity={0.18} />
</>),
book: (<>
<path d="M6 26 Q28 18 50 28 Q72 18 94 26 L94 86 Q72 78 50 88 Q28 78 6 86 Z" fill="#6b3022" />
<path d="M8 22 Q30 14 50 24 Q70 14 92 22 L92 80 Q70 72 50 82 Q30 72 8 80 Z" fill="#dfd2b5" />
<path d="M9 20 Q30 12 50 22 Q70 12 91 20 L91 77 Q70 69 50 79 Q30 69 9 77 Z" fill="#f5ecd6" />
<path d="M44 20 Q47 21 50 22 Q53 21 56 20 L56 78 Q53 78.5 50 79 Q47 78.5 44 78 Z" fill="#e2d5b8" />
<path d="M50 22 L50 79" stroke="#b9a882" strokeWidth={2.5} />
{[0, 1, 2, 3].map((i) => <g key={i}><path d={`M16 ${32 + i * 10.5} Q29 ${29 + i * 10.5} 43 ${34 + i * 10.5}`} stroke="#9a8a6a" strokeWidth={2.4} fill="none" strokeLinecap="round" /><path d={`M57 ${34 + i * 10.5} Q71 ${29 + i * 10.5} 84 ${32 + i * 10.5}`} stroke="#9a8a6a" strokeWidth={2.4} fill="none" strokeLinecap="round" /></g>)}
</>),
ruler: (<>
<g transform="rotate(-12 50 50)">
<rect x={4} y={36} width={92} height={26} rx={4} fill="#8c6230" />
<rect x={6} y={37} width={88} height={23} rx={3} fill="#e8c374" />
<rect x={8} y={53} width={84} height={6} rx={2} fill="#cfa656" />
{Array.from({ length: 11 }, (_, i) => <rect key={i} x={11 + i * 7.6} y={37} width={2.2} height={i % 2 ? 7 : 12} rx={0.8} fill="#5c3d1b" />)}
</g>
</>),
};
export function Icon({ id }: { id: IconId }) {
return <svg viewBox="0 0 100 100" width="100%" height="100%" overflow="visible">{DRAW[id]}</svg>;
}
@@ -0,0 +1,66 @@
// Profundidade dos braços do personagem de frente para a câmera (função pura do estado do rig, sem React).
//
// O desenho (CharacterFigure.tsx) empilha as camadas assim:
// tronco → braços "side" → acessórios do peito (toalha, cachecol, crachá, apito) → braços "front" →
// parte da toalha apoiada no ombro → cabeça → braços "face".
// Regra: com o personagem de frente, braço e mão NUNCA somem atrás do tronco, da roupa, de acessório ou da barba.
// - "face": a mão sobe até a altura do pescoço/rosto, dentro da largura da cabeça (pensar, tapar a boca, mão na
// testa) — desenhado por cima da cabeça e da barba;
// - "front": a mão ou o antebraço entram na frente do peito (segurar objeto diante do corpo, cruzar os braços,
// apontar para o outro lado, mão na cintura) — por cima do tronco e dos acessórios do peito;
// - "side": o braço fica ao lado do corpo (caído, acenando para fora, apontando para o lado) — por cima do tronco,
// mas por baixo do pano apoiado no ombro/peito (o braço sai por baixo da toalha).
// Não há caso "atrás do tronco": nenhuma pose do rig leva a mão às costas.
import type { BodyParams } from "./rig";
export type ArmLayer = "side" | "front" | "face";
export type Point = { x: number; y: number };
/** Ponta de um segmento: ângulo de tela em graus (0 = para baixo). Igual ao `tip` do desenho. */
export const tipOf = (x: number, y: number, deg: number, len: number): Point => {
const r = (deg * Math.PI) / 180;
return { x: x - Math.sin(r) * len, y: y + Math.cos(r) * len };
};
/** Medidas do desenho (viewBox 200×440) que a regra usa — as mesmas de CharacterFigure.tsx. */
export const ARM = { shoulderX: 54, upper: 56, wrist: 43, hand: 28, torsoHalf: 56 } as const;
/** Ombro, cotovelo, pulso e centro da mão do braço `s` (1 = direita da tela, -1 = esquerda). `w` = largura do corpo. */
export function armGeometry(b: BodyParams, s: 1 | -1, w = 1) {
const hipY = 306 + b.crouch * 56;
const shY = hipY - 100;
const torsoTop = hipY - 114;
const l = s > 0 ? b.armR : b.armL;
const shoulder = { x: 100 + s * ARM.shoulderX * w, y: shY };
const upperDeg = -s * l.raise;
const elbow = tipOf(shoulder.x, shoulder.y, upperDeg, ARM.upper);
const foreDeg = upperDeg + s * l.bend;
const wrist = tipOf(elbow.x, elbow.y, foreDeg, ARM.wrist);
const hand = tipOf(elbow.x, elbow.y, foreDeg, ARM.wrist + ARM.hand);
return { shoulder, elbow, wrist, hand, upperDeg, foreDeg, torsoTop, hipY };
}
/**
* Camada do braço `s` no quadro. `holds` = segura objeto (sempre na frente do corpo, salvo na altura do rosto).
* O "peito" é o tronco sem as faixas laterais onde o braço caído naturalmente encosta.
*/
export function armLayer(b: BodyParams, s: 1 | -1, opts: { holds?: boolean; w?: number } = {}): ArmLayer {
const w = opts.w ?? 1;
const g = armGeometry(b, s, w);
const l = s > 0 ? b.armR : b.armL;
const half = ARM.torsoHalf * w;
// Altura do pescoço/rosto: acima do topo do tronco (+ folga da gola), dentro da largura da cabeça, ou braço dobrado ao queixo/boca.
const atFace = (p: Point) => p.y < g.torsoTop + 20 && Math.abs(p.x - 100) < 60;
if (atFace(g.hand) || atFace(g.wrist) || (l.raise < 20 && l.bend > 138)) return "face";
if (opts.holds) return "front";
// Cotovelo bem dobrado para dentro com o braço baixo (segurar, joinha, mão na cintura, braços cruzados): antebraço na frente.
if (l.raise < 90 && l.bend > 85) return "front";
const chest = { x0: 100 - half + 14, x1: 100 + half - 14, y0: g.torsoTop + 4, y1: g.hipY + 12 };
const inChest = (p: Point) => p.x > chest.x0 && p.x < chest.x1 && p.y > chest.y0 && p.y < chest.y1;
// Amostra o antebraço (cotovelo → mão): basta um trecho na frente do peito.
for (let i = 0; i <= 8; i++) {
const k = i / 8;
if (inChest({ x: g.elbow.x + (g.hand.x - g.elbow.x) * k, y: g.elbow.y + (g.hand.y - g.elbow.y) * k })) return "front";
}
return "side";
}
@@ -0,0 +1,87 @@
// Boca acompanhando a fala SEM perder a expressão. O formato vem das letras da palavra que está sendo dita
// (tempos de cada palavra da transcrição): "a" abre, "e/i" esticam, "o/u" arredondam, "m/b/p" fecham, "f/v"
// mostram os dentes; vogal dura mais que consoante e as letras vizinhas se misturam (coarticulação). Se houver
// o volume do áudio quadro a quadro (`env`), ele fecha a boca nas pausas e abre mais nas sílabas fortes.
// A expressão continua por cima: os cantos (sorriso/tristeza), as sobrancelhas e os olhos são dela.
import type { FaceParams } from "./rig";
export type Viseme = { open: number; wide: number; round: number; teeth: boolean };
export type SpokenWord = { text: string; startS: number; endS: number };
const CLOSED: Viseme = { open: 0, wide: 0, round: 0, teeth: false };
const V: Record<string, Viseme> = {
a: { open: 0.85, wide: 0.3, round: 0, teeth: false },
e: { open: 0.55, wide: 0.65, round: 0, teeth: true },
i: { open: 0.3, wide: 0.95, round: 0, teeth: true },
o: { open: 0.65, wide: 0, round: 0.75, teeth: false },
u: { open: 0.35, wide: 0, round: 1, teeth: false },
mbp: { open: 0, wide: 0.1, round: 0, teeth: false },
fv: { open: 0.12, wide: 0.2, round: 0, teeth: true },
cons: { open: 0.3, wide: 0.3, round: 0, teeth: true },
};
function visemeOf(ch: string): Viseme {
if ("aáàâã".includes(ch)) return V.a;
if ("eéê".includes(ch)) return V.e;
if ("iíy".includes(ch)) return V.i;
if ("oóôõ".includes(ch)) return V.o;
if ("uúü".includes(ch)) return V.u;
if ("mbp".includes(ch)) return V.mbp;
if ("fv".includes(ch)) return V.fv;
return V.cons;
}
const isVowel = (ch: string) => /[aáàâãeéêiíyoóôõuúü]/.test(ch);
function mix(a: Viseme, b: Viseme, k: number): Viseme {
return { open: a.open + (b.open - a.open) * k, wide: a.wide + (b.wide - a.wide) * k, round: a.round + (b.round - a.round) * k, teeth: k < 0.5 ? a.teeth : b.teeth };
}
/** Formato da boca no instante `t` (segundos do trecho) para as palavras dadas; fechada fora das palavras. */
export function visemeAt(words: SpokenWord[], t: number, env?: { values: number[]; fps: number }): Viseme {
const w = words.find((x) => t >= x.startS && t < x.endS);
if (!w) {
// Fim de palavra: fecha em ~60 ms em vez de bater a boca.
const prev = [...words].reverse().find((x) => x.endS <= t);
return prev && t - prev.endS < 0.06 ? mix(V.cons, CLOSED, (t - prev.endS) / 0.06) : CLOSED;
}
const letters = [...w.text.toLowerCase().replace(/(ch|lh|nh|qu)/g, "c").replace(/[^a-záàâãéêíóôõúüçy]/g, "")];
if (!letters.length) return CLOSED;
// Vogal pesa o dobro da consoante no tempo da palavra.
const weights = letters.map((ch) => (isVowel(ch) ? 1.7 : 0.8));
const total = weights.reduce((a, b) => a + b, 0);
let pos = ((t - w.startS) / Math.max(0.04, w.endS - w.startS)) * total;
let i = 0;
while (i < letters.length - 1 && pos > weights[i]) { pos -= weights[i]; i++; }
const frac = Math.min(1, pos / weights[i]);
const cur = visemeOf(letters[i]);
const next = i + 1 < letters.length ? visemeOf(letters[i + 1]) : CLOSED;
// Coarticulação: a 2ª metade da letra já caminha para a próxima.
let v = frac > 0.5 ? mix(cur, next, (frac - 0.5) * 0.9) : cur;
if (env?.values.length) {
const a = env.values[Math.min(env.values.length - 1, Math.max(0, Math.floor(t * env.fps)))] ?? 0;
const k = Math.max(0, Math.min(1.15, (a - 0.03) / 0.3));
v = { ...v, open: v.open * (0.25 + 0.75 * Math.min(1, k)) * (k < 0.05 ? 0.2 : 1) };
}
return v;
}
/** Ênfase (0–1) no instante: o volume perto do pico levanta um pouco as sobrancelhas. */
export function emphasisAt(t: number, env?: { values: number[]; fps: number }): number {
if (!env?.values.length) return 0;
const a = env.values[Math.min(env.values.length - 1, Math.max(0, Math.floor(t * env.fps)))] ?? 0;
return Math.max(0, Math.min(1, (a - 0.45) / 0.4));
}
/** Põe a fala na boca mantendo a expressão (cantos, sobrancelhas, olhos). `k` = quanto da fala entra (0–1). */
export function speak(face: FaceParams, v: Viseme, k = 1, emphasis = 0): FaceParams {
const open = Math.max(face.mouthOpen * 0.35, v.open * 0.9);
return {
...face,
mouthOpen: face.mouthOpen + (open - face.mouthOpen) * k,
mouthWidth: face.mouthWidth * (1 + (v.wide * 0.22 - v.round * 0.45) * k),
mouthRound: face.mouthRound + (v.round - face.mouthRound) * k,
teeth: k > 0.5 ? v.teeth && v.open > 0.1 : face.teeth,
browL: { ...face.browL, y: face.browL.y - emphasis * 3 * k },
browR: { ...face.browR, y: face.browR.y - emphasis * 3 * k },
};
}
@@ -0,0 +1,222 @@
// Movimento do personagem: uma LINHA DO TEMPO de ações que se combinam (não animações prontas). Cada ação tem
// início (segundos `at`, fração do trecho `atP` ou a palavra da narração `cue`) e duração; o estado em cada
// quadro sai de aplicar as ações em ordem sobre a expressão/pose de base, mais a "vida" (piscar, respirar).
// Ações permanentes mudam o estado dali em diante (express, pose, walk, sit, fall, turn, look); as momentâneas
// voltam ao fim (nod, shake_head, tremble, bounce, wave, jump, talk, emote).
import { emphasisAt, speak, visemeAt, type SpokenWord } from "./lipsync";
import { blendBody, blendFace, bodyOf, faceOf, withBody, withFace, type BodyParams, type BodyPatch, type FaceParams, type FacePatch } from "./rig";
export const ACTIONS = ["express", "pose", "walk", "run", "enter", "exit", "jump", "nod", "shake_head", "tremble", "bounce", "fall",
"sit", "stand_up", "turn", "talk", "look", "emote", "wave", "hammer"] as const;
export type ActionKind = (typeof ACTIONS)[number];
export type Action = {
do: ActionKind;
/** Início: segundos, fração do trecho (0–1) ou a 1ª palavra da narração que começa com `cue`. */
at?: number; atP?: number; cue?: string;
dur?: number;
/** talk: termina no fim desta palavra da narração (a fala vai de `cue` até `cueEnd`). */
cueEnd?: string;
expression?: string; face?: FacePatch;
pose?: string; body?: BodyPatch;
/** walk/run/enter: x de destino (fração). */
to?: number;
/** look: para onde; fall: para que lado. */
dir?: "left" | "right" | "up" | "down";
/** nod/shake_head/bounce/wave: repetições. jump: altura (fração da altura do quadro). */
times?: number; height?: number;
/** emote: símbolo sobre a cabeça ("!", "?", "…", "♥", "zzz", "💢"). talk: o texto falado (sem tempos de palavra, é
* repartido pela duração). */
text?: string;
};
export type ActorInput = {
x: number; expression?: string; pose?: string; face?: FacePatch; body?: BodyPatch; flip?: boolean; timeline?: Action[];
};
export type ActorState = {
face: FaceParams; body: BodyParams;
x: number; dy: number; dx: number; rot: number; sx: number; sy: number; flip: boolean;
emote: { text: string; k: number } | null;
};
const DEFAULT_DUR: Record<ActionKind, number> = {
express: 0.25, pose: 0.35, walk: 1.6, run: 0.9, enter: 1.2, exit: 1.2, jump: 0.8, nod: 0.7, shake_head: 0.8, tremble: 1, bounce: 0.8,
fall: 0.6, sit: 0.5, stand_up: 0.5, turn: 0.3, talk: 1.5, look: 0.3, emote: 1.2, wave: 1.2, hammer: 2.4,
};
const clamp01 = (v: number) => Math.max(0, Math.min(1, v));
const ease = (p: number) => (p < 0.5 ? 2 * p * p : 1 - (-2 * p + 2) ** 2 / 2);
/** Passa um pouco do alvo e volta (dá vida às poses). */
const easeBack = (p: number) => { const c = 1.4; return 1 + (c + 1) * (p - 1) ** 3 + c * (p - 1) ** 2; };
const norm = (s: string) => s.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]/g, "");
/** Início da ação em segundos (cue = palavra falada; sem a palavra, cai para atP/at/0). */
export function startOf(a: Action, durationS: number, words: { text: string; startS: number }[] = []): number {
if (a.cue) {
const c = norm(a.cue);
const w = words.find((x) => norm(x.text).startsWith(c));
if (w) return w.startS;
}
if (a.atP !== undefined) return a.atP * durationS;
return a.at ?? 0;
}
/** Piscar em intervalos variados (2,4–4,6 s), determinístico pela semente. */
function blinkAt(t: number, seed: number): number {
let s = 0.6 + (seed % 7) * 0.13;
let k = 1;
while (s < t + 0.2) {
const d = t - s;
if (d >= 0 && d < 0.13) k = Math.min(k, Math.abs(d - 0.065) / 0.065);
s += 2.4 + ((Math.sin(s * 12.9898 + seed) + 1) / 2) * 2.2;
}
return k;
}
/** Fala do trecho: palavras com tempo (narração) e, se houver, o volume do áudio quadro a quadro. */
export type Speech = { words: SpokenWord[]; env?: { values: number[]; fps: number } };
/** Fim da fala: o fim da palavra `cueEnd` (depois do início), senão início + dur. */
function endOf(a: Action, s: number, words: SpokenWord[]): number | null {
if (!a.cueEnd) return null;
const c = norm(a.cueEnd);
const w = words.find((x) => x.startS >= s - 0.01 && norm(x.text).startsWith(c));
return w ? w.endS : null;
}
export function evaluate(actor: ActorInput, t: number, durationS: number, seed = 1, speech: Speech = { words: [] }): ActorState {
const words = speech.words;
const st: ActorState = {
face: faceOf(actor.expression, actor.face), body: bodyOf(actor.pose, actor.body),
x: actor.x, dy: 0, dx: 0, rot: 0, sx: 1, sy: 1, flip: !!actor.flip, emote: null,
};
const timeline = (actor.timeline ?? []).map((a) => ({ a, s: startOf(a, durationS, words) })).sort((p, q) => p.s - q.s);
for (const { a, s } of timeline) {
if (t < s) break;
const end = a.do === "talk" ? endOf(a, s, words) : null;
const d = Math.max(0.05, end !== null ? end - s : a.dur ?? DEFAULT_DUR[a.do]);
const p = clamp01((t - s) / d);
const active = t - s < d;
const env = active ? Math.min(1, (t - s) / 0.15, (s + d - t) / 0.15) : 0; // entra e sai suave (momentâneas)
switch (a.do) {
case "express": {
const target = a.expression ? faceOf(a.expression, a.face) : withFace(st.face, a.face);
st.face = blendFace(st.face, target, ease(p));
break;
}
case "pose": {
const target = a.pose ? bodyOf(a.pose, a.body) : withBody(st.body, a.body);
st.body = blendBody(st.body, target, clamp01(easeBack(p)));
break;
}
case "walk": case "run": case "enter": case "exit": {
const from = a.do === "enter" ? (a.to ?? st.x) < 0.5 ? -0.25 : 1.25 : st.x;
const to = a.do === "exit" ? (st.x < 0.5 ? -0.3 : 1.3) : a.to ?? st.x;
const run = a.do === "run";
st.x = from + (to - from) * (run ? p : ease(p));
if (to !== from) st.flip = to < from;
if (active) {
const phase = (t - s) * Math.PI * 2 * (run ? 3.2 : 2.1);
const amp = run ? 1.6 : 1;
const sw = Math.sin(phase);
st.body = withBody(st.body, {
armL: { raise: 8 + sw * 20 * amp, bend: run ? 85 : 15 }, armR: { raise: 8 - sw * 20 * amp, bend: run ? 85 : 15 },
legL: { raise: 3 + Math.max(0, sw) * 6, bend: Math.max(0, sw) * 38 * amp }, legR: { raise: 3 + Math.max(0, -sw) * 6, bend: Math.max(0, -sw) * 38 * amp },
lean: (to < from ? -1 : 1) * (run ? 8 : 3),
});
st.dy -= Math.abs(Math.sin(phase)) * (run ? 0.012 : 0.006);
}
break;
}
case "jump": {
if (!active) break;
const h = a.height ?? 0.08;
if (p < 0.15) { st.sy *= 1 - 0.1 * (p / 0.15); st.sx *= 1 + 0.06 * (p / 0.15); st.body = withBody(st.body, { crouch: 0.35 * (p / 0.15) }); }
else if (p < 0.85) {
const q = (p - 0.15) / 0.7;
st.dy -= h * 4 * q * (1 - q);
st.sy *= 1.07; st.sx *= 0.95;
st.body = withBody(st.body, { arms: { raise: 120, bend: -10 }, legs: { raise: 6, bend: 30 } });
} else { const q = (p - 0.85) / 0.15; st.sy *= 1 - 0.08 * (1 - q); st.sx *= 1 + 0.05 * (1 - q); }
break;
}
case "nod": st.body = withBody(st.body, { headNod: st.body.headNod + Math.sin(p * Math.PI * 2 * (a.times ?? 2)) * 0.6 * env }); break;
case "shake_head": st.body = withBody(st.body, { headTurn: st.body.headTurn + Math.sin(p * Math.PI * 2 * (a.times ?? 2)) * 0.7 * env }); break;
case "tremble": if (active) { st.dx += Math.sin(t * 77.7) * 0.004 * env; st.dy += Math.cos(t * 91.3) * 0.002 * env; } break;
case "bounce": st.dy -= Math.abs(Math.sin(p * Math.PI * (a.times ?? 2))) * 0.02 * env; break;
case "fall": {
const side = a.dir === "right" ? 1 : -1;
st.rot = side * 88 * ease(p);
st.dy += 0.02 * ease(p);
st.face = blendFace(st.face, faceOf("shocked"), Math.min(1, p * 3));
break;
}
case "sit": st.body = blendBody(st.body, withBody(st.body, { crouch: 1, arms: { raise: 14, bend: 40 } }), ease(p)); break;
case "stand_up": st.body = blendBody(st.body, withBody(st.body, { crouch: 0 }), ease(p)); break;
case "turn": {
const flipped = !st.flip;
if (p >= 0.5) st.flip = flipped;
if (active) st.sx *= Math.max(0.15, Math.abs(Math.cos(p * Math.PI)));
break;
}
case "talk": {
if (!active) break;
// Palavras da narração dentro da fala; sem elas, o texto da ação repartido pela duração (vogal pesa mais).
let spoken = words.filter((w) => w.endS > s && w.startS < s + d);
if (!spoken.length && a.text) {
const list = a.text.split(/\s+/).filter(Boolean);
const total = list.reduce((n, w) => n + w.length + 1, 0);
let c = s;
spoken = list.map((w) => { const len = (d * (w.length + 1)) / total; const out = { text: w, startS: c, endS: c + len * 0.88 }; c += len; return out; });
}
if (spoken.length) {
st.face = speak(st.face, visemeAt(spoken, t, speech.env), Math.min(1, (t - s) / 0.08, (s + d - t) / 0.08 + 0.2), emphasisAt(t, speech.env));
} else {
const flap = Math.abs(Math.sin((t - s) * Math.PI * 2 * 4.3 + seed)) * (0.6 + 0.4 * Math.sin((t - s) * 9.1 + seed));
st.face = { ...st.face, mouthOpen: Math.max(st.face.mouthOpen, (0.12 + 0.5 * flap) * env), teeth: st.face.teeth || flap > 0.6 };
}
// Quem fala mexe a cabeça de leve e acompanha as sílabas fortes.
st.body = withBody(st.body, { headTilt: st.body.headTilt + Math.sin((t - s) * 5.3) * 2 * env, headNod: st.body.headNod + emphasisAt(t, speech.env) * 0.25 });
break;
}
case "look": {
const gx = a.dir === "left" ? -0.9 : a.dir === "right" ? 0.9 : 0;
const gy = a.dir === "up" ? -0.8 : a.dir === "down" ? 0.8 : 0;
const k = ease(p);
st.face = { ...st.face, gazeX: st.face.gazeX + (gx - st.face.gazeX) * k, gazeY: st.face.gazeY + (gy - st.face.gazeY) * k };
st.body = withBody(st.body, { headTurn: st.body.headTurn + (gx * 0.5 - st.body.headTurn) * k, headNod: st.body.headNod + (gy * -0.4 - st.body.headNod) * k });
break;
}
case "emote": if (active) st.emote = { text: a.text ?? "!", k: env }; break;
// Martelar: braço direito sobe e desce batendo (`times` golpes), cabeça acompanha cada batida.
case "hammer": if (active) {
const beat = Math.abs(Math.sin(p * Math.PI * (a.times ?? 5)));
st.body = withBody(st.body, { armR: { raise: 40 + beat * 95 * Math.min(1, env * 1.5), bend: 60 + beat * 40 }, headNod: st.body.headNod + (1 - beat) * 0.15 * env });
break;
}
case "wave": if (active) st.body = withBody(st.body, { armR: { raise: 140 * Math.min(1, env * 1.5), bend: -25 + Math.sin(p * Math.PI * 2 * (a.times ?? 3)) * 30 } }); break;
}
}
// Vida: piscar (a não ser de olhos quase fechados), respirar e um balanço leve de cabeça.
const blink = blinkAt(t, seed);
if (blink < 1) st.face = { ...st.face, eyeL: st.face.eyeL * Math.max(0.08, blink), eyeR: st.face.eyeR * Math.max(0.08, blink) };
st.body = withBody(st.body, { headTilt: st.body.headTilt + Math.sin(t * 0.9 + seed) * 1.2 });
return st;
}
/** Confere uma linha do tempo (lista de problemas; vazia = ok). */
export function validateTimeline(timeline: unknown): string[] {
if (timeline === undefined) return [];
if (!Array.isArray(timeline) || timeline.length > 40) return ["timeline: lista de até 40 ações"];
const errors: string[] = [];
timeline.forEach((a: Partial<Action>, i) => {
if (!a || !ACTIONS.includes(a.do as ActionKind)) errors.push(`timeline[${i}].do: ${ACTIONS.join(", ")}`);
for (const k of ["at", "atP", "dur", "to", "times", "height"] as const) {
if (a[k] !== undefined && (typeof a[k] !== "number" || !Number.isFinite(a[k]))) errors.push(`timeline[${i}].${k}: número`);
}
if (a.atP !== undefined && !(a.atP >= 0 && a.atP <= 1)) errors.push(`timeline[${i}].atP entre 0 e 1`);
if (a.dur !== undefined && !(a.dur > 0 && a.dur <= 30)) errors.push(`timeline[${i}].dur entre 0 e 30 s`);
});
return errors;
}
@@ -0,0 +1,167 @@
// Rig do personagem: o rosto e o corpo são PARÂMETROS contínuos, não desenhos prontos. Uma expressão ou uma
// pose é só um conjunto de valores; dá para misturar (blend), ajustar um valor ("sorriso 0,3 a mais") e criar
// novas sem mexer no desenho. Ângulos em graus; "para fora" positivo nos dois lados (o desenho espelha).
export type FaceParams = {
/** Sobrancelha: y (px; negativo sobe) e tilt (graus; positivo = ponta de dentro sobe, como triste/preocupado). */
browL: { y: number; tilt: number };
browR: { y: number; tilt: number };
/** Abertura dos olhos (0 fechado · 1 normal · 1,35 arregalado). */
eyeL: number;
eyeR: number;
/** Tamanho da pupila (0,4 pavor · 1 normal · 1,3 encantado). */
pupil: number;
/** Direção do olhar (-1…1). */
gazeX: number;
gazeY: number;
/** Boca: abertura 0…1, sorriso -1 (triste) … 1 (feliz), largura 0,5…1,4, dentes à mostra. */
mouthOpen: number;
smile: number;
mouthWidth: number;
/** Arredondamento dos lábios (0 normal … 1 bico de "o/u"): vem da fala (lipsync.ts). */
mouthRound: number;
/** Pálpebra de cima somada à de base do personagem (−0,5 arregala … 0,6 quase fecha). */
lid: number;
teeth: boolean;
/** Extras: rubor 0…1, gota de suor, lágrimas, veia de raiva. */
blush: number;
sweat: boolean;
tears: boolean;
anger: boolean;
};
export type Limb = {
/** Abertura a partir do corpo (0 = para baixo; 90 = horizontal para fora; 180 = para cima). */
raise: number;
/** Dobra do cotovelo/joelho (positivo = antebraço/canela para dentro, na frente do corpo). */
bend: number;
};
export type BodyParams = {
/** Inclinação do tronco (graus; positivo = para a direita de quem olha). */
lean: number;
/** Cabeça: inclinação (graus), virada (-1…1, finge 3/4) e aceno (-1 olha para cima … 1 para baixo). */
headTilt: number;
headTurn: number;
headNod: number;
armL: Limb;
armR: Limb;
legL: Limb;
legR: Limb;
/** Agachar/sentar: 0 em pé … 1 sentado (quadril desce, coxa encurta em perspectiva). */
crouch: number;
};
export const NEUTRAL_FACE: FaceParams = {
browL: { y: 0, tilt: 0 }, browR: { y: 0, tilt: 0 }, eyeL: 1, eyeR: 1, pupil: 1, gazeX: 0, gazeY: 0,
mouthOpen: 0, smile: 0.1, mouthWidth: 1, mouthRound: 0, lid: 0, teeth: false, blush: 0, sweat: false, tears: false, anger: false,
};
export const NEUTRAL_BODY: BodyParams = {
lean: 0, headTilt: 0, headTurn: 0, headNod: 0,
armL: { raise: 8, bend: 6 }, armR: { raise: 8, bend: 6 }, legL: { raise: 2, bend: 0 }, legR: { raise: 2, bend: 0 }, crouch: 0,
};
type FacePatch = Partial<Omit<FaceParams, "browL" | "browR">> & { browL?: Partial<FaceParams["browL"]>; browR?: Partial<FaceParams["browR"]>; brows?: Partial<FaceParams["browL"]>; eyes?: number };
type BodyPatch = Partial<Omit<BodyParams, "armL" | "armR" | "legL" | "legR">> & { armL?: Partial<Limb>; armR?: Partial<Limb>; legL?: Partial<Limb>; legR?: Partial<Limb>; arms?: Partial<Limb>; legs?: Partial<Limb> };
/** Aplica um ajuste parcial (aceita `brows`/`eyes`/`arms`/`legs` para os dois lados de uma vez). */
export function withFace(base: FaceParams, p: FacePatch = {}): FaceParams {
const { brows, eyes, browL, browR, ...rest } = p;
return {
...base, ...rest,
browL: { ...base.browL, ...brows, ...browL }, browR: { ...base.browR, ...brows, ...browR },
eyeL: rest.eyeL ?? eyes ?? base.eyeL, eyeR: rest.eyeR ?? eyes ?? base.eyeR,
};
}
export function withBody(base: BodyParams, p: BodyPatch = {}): BodyParams {
const { arms, legs, armL, armR, legL, legR, ...rest } = p;
return {
...base, ...rest,
armL: { ...base.armL, ...arms, ...armL }, armR: { ...base.armR, ...arms, ...armR },
legL: { ...base.legL, ...legs, ...legL }, legR: { ...base.legR, ...legs, ...legR },
};
}
/** Expressões prontas = atalhos de parâmetros (dá para ajustar qualquer valor por cima com `face`). */
export const EXPRESSION_PRESETS = {
neutral: {},
smile: { smile: 0.7, eyes: 0.9 },
happy: { smile: 0.9, mouthOpen: 0.3, teeth: true, eyes: 0.85, brows: { y: -3 } },
laugh: { smile: 1, mouthOpen: 0.75, teeth: true, eyes: 0.18, brows: { y: -5 }, blush: 0.4 },
proud: { smile: 0.6, lid: 0.35, brows: { y: -2 } },
sad: { smile: -0.7, brows: { tilt: 16 }, eyes: 0.8, gazeY: 0.5 },
cry: { smile: -0.9, mouthOpen: 0.35, brows: { tilt: 20 }, eyes: 0.4, tears: true },
worried: { smile: -0.3, brows: { tilt: 14, y: -2 }, eyes: 1.05, sweat: true },
angry: { smile: -0.4, brows: { tilt: -18, y: 3 }, lid: 0.25, mouthWidth: 0.9 },
furious: { smile: -0.6, mouthOpen: 0.6, teeth: true, brows: { tilt: -24, y: 4 }, lid: 0.3, anger: true },
surprised: { mouthOpen: 0.6, mouthWidth: 0.55, smile: 0, brows: { y: -8 }, eyes: 1.25, pupil: 0.8, lid: -0.5 },
scared: { mouthOpen: 0.5, mouthWidth: 0.9, smile: -0.5, teeth: true, brows: { tilt: 18, y: -6 }, eyes: 1.3, pupil: 0.55, sweat: true, lid: -0.5 },
shocked: { mouthOpen: 0.95, mouthWidth: 0.6, smile: 0, brows: { y: -10 }, eyes: 1.35, pupil: 0.45, lid: -0.5 },
suspicious: { smile: -0.1, mouthWidth: 0.8, browL: { y: -6, tilt: 0 }, browR: { y: 4, tilt: -10 }, lid: 0.45, gazeX: 0.6 },
smirk: { smile: 0.45, mouthWidth: 0.8, browL: { y: -5 }, lid: 0.3, gazeX: -0.3 },
confused: { smile: -0.2, mouthWidth: 0.75, browL: { y: -7 }, browR: { tilt: -8 }, gazeY: -0.6, gazeX: 0.4 },
disgusted: { smile: -0.7, mouthWidth: 1.1, brows: { tilt: -10, y: 2 }, lid: 0.35 },
sleepy: { lid: 0.6, brows: { y: 3 }, mouthOpen: 0.1, smile: 0 },
determined: { smile: 0.1, mouthWidth: 0.85, brows: { tilt: -10, y: 2 }, lid: 0.2 },
embarrassed: { smile: 0.3, blush: 1, gazeY: 0.6, gazeX: -0.4, eyes: 0.8, sweat: true },
} satisfies Record<string, FacePatch>;
/** Poses prontas = atalhos de ângulos (ajustáveis por cima com `body`). */
export const POSE_PRESETS = {
stand: {},
point: { armR: { raise: 46, bend: -128 } },
wave: { armR: { raise: 140, bend: -25 } },
hold: { armR: { raise: 34, bend: 106 } },
arms_up: { arms: { raise: 158, bend: -10 } },
celebrate: { arms: { raise: 146, bend: -26 }, headNod: -0.35 },
shrug: { arms: { raise: 38, bend: 100 }, headTilt: 7 },
think: { armR: { raise: -24, bend: 138 }, headTilt: -5 },
hands_on_hips: { arms: { raise: 42, bend: 105 } },
cross_arms: { arms: { raise: 24, bend: 128 } },
facepalm: { armR: { raise: 125, bend: -103 }, headNod: 0.5, headTilt: 8 },
cover_mouth: { armR: { raise: -34, bend: 130 } },
defend: { arms: { raise: 62, bend: 118 }, lean: -4 },
reach: { armR: { raise: 68, bend: -15 }, lean: 6 },
sit: { crouch: 1, arms: { raise: 14, bend: 40 } },
kneel: { crouch: 0.6, arms: { raise: 10, bend: 20 } },
lean_in: { lean: 8, headTilt: 6 },
// Duas mãos segurando um objeto largo (livro, tábua) pelas bordas, na frente do peito.
hold_both: { arms: { raise: 42, bend: 104 } },
// Joinha: cotovelo dobrado, mão na altura do peito/ombro (a forma da mão vem do desenho: `thumbs_up`).
thumbs_up: { armR: { raise: 22, bend: 148 } },
} satisfies Record<string, BodyPatch>;
export type ExpressionName = keyof typeof EXPRESSION_PRESETS;
export type PoseName = keyof typeof POSE_PRESETS;
export const EXPRESSION_NAMES = Object.keys(EXPRESSION_PRESETS) as ExpressionName[];
export const POSE_NAMES = Object.keys(POSE_PRESETS) as PoseName[];
export const faceOf = (name: string | undefined, patch?: FacePatch): FaceParams =>
withFace(withFace(NEUTRAL_FACE, (EXPRESSION_PRESETS as Record<string, FacePatch>)[name ?? "neutral"] ?? {}), patch);
export const bodyOf = (name: string | undefined, patch?: BodyPatch): BodyParams =>
withBody(withBody(NEUTRAL_BODY, (POSE_PRESETS as Record<string, BodyPatch>)[name ?? "stand"] ?? {}), patch);
const lerp = (a: number, b: number, k: number) => a + (b - a) * k;
const limb = (a: Limb, b: Limb, k: number): Limb => ({ raise: lerp(a.raise, b.raise, k), bend: lerp(a.bend, b.bend, k) });
/** Mistura duas expressões (k = 0 → a, 1 → b). Os "liga/desliga" trocam na metade. */
export function blendFace(a: FaceParams, b: FaceParams, k: number): FaceParams {
const pick = <T,>(x: T, y: T) => (k < 0.5 ? x : y);
return {
browL: { y: lerp(a.browL.y, b.browL.y, k), tilt: lerp(a.browL.tilt, b.browL.tilt, k) },
browR: { y: lerp(a.browR.y, b.browR.y, k), tilt: lerp(a.browR.tilt, b.browR.tilt, k) },
eyeL: lerp(a.eyeL, b.eyeL, k), eyeR: lerp(a.eyeR, b.eyeR, k), pupil: lerp(a.pupil, b.pupil, k),
gazeX: lerp(a.gazeX, b.gazeX, k), gazeY: lerp(a.gazeY, b.gazeY, k),
mouthOpen: lerp(a.mouthOpen, b.mouthOpen, k), smile: lerp(a.smile, b.smile, k), mouthWidth: lerp(a.mouthWidth, b.mouthWidth, k), mouthRound: lerp(a.mouthRound, b.mouthRound, k), lid: lerp(a.lid, b.lid, k),
teeth: pick(a.teeth, b.teeth), blush: lerp(a.blush, b.blush, k), sweat: pick(a.sweat, b.sweat), tears: pick(a.tears, b.tears), anger: pick(a.anger, b.anger),
};
}
export function blendBody(a: BodyParams, b: BodyParams, k: number): BodyParams {
return {
lean: lerp(a.lean, b.lean, k), headTilt: lerp(a.headTilt, b.headTilt, k), headTurn: lerp(a.headTurn, b.headTurn, k), headNod: lerp(a.headNod, b.headNod, k),
armL: limb(a.armL, b.armL, k), armR: limb(a.armR, b.armR, k), legL: limb(a.legL, b.legL, k), legR: limb(a.legR, b.legR, k), crouch: lerp(a.crouch, b.crouch, k),
};
}
export type { FacePatch, BodyPatch };
@@ -0,0 +1,9 @@
// Versão REDUZIDA do contrato do CenaForge (cartoon/src/spec.ts): só os tipos que o desenho do personagem usa.
// No projeto real este arquivo é bem maior (cena, lugar, animais, textos…); não é preciso mexer nele.
export const TIMES = ["night", "dawn", "day"] as const;
export type TimeOfDay = (typeof TIMES)[number];
export const ICONS = ["house", "generator", "fuel", "battery", "phone", "door", "eye", "bulb", "solar", "warning", "money", "clock",
"olive", "hammer", "tablet", "book", "ruler"] as const;
export type IconId = (typeof ICONS)[number];
export const TONES = ["info", "danger", "ok"] as const;
export type Tone = (typeof TONES)[number];
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "Bundler",
"jsx": "react-jsx",
"strict": true,
"skipLibCheck": true,
"noEmit": true
},
"include": ["src", "render-sheet.tsx"]
}