diff --git a/.studies/cartoon-personagem-handoff/PROMPT.md b/.studies/cartoon-personagem-handoff/PROMPT.md new file mode 100644 index 0000000..55e9d8a --- /dev/null +++ b/.studies/cartoon-personagem-handoff/PROMPT.md @@ -0,0 +1,109 @@ +# Tarefa: subir o personagem cartoon (corpo e MÃOS) ao nível de uma ilustração de referência + +Você vai trabalhar num **workspace isolado** (pasta `workspace/` deste pacote), sem acesso ao projeto +original. Responda e comente em **português do Brasil**; nomes de código (variáveis, funções, tipos, +arquivos) em **inglês**. + +## Contexto + +Temos um gerador de vídeos curtos verticais (9:16) em estilo "cartoon explicativo". Cada personagem é um +**componente React que desenha SVG puro** (`workspace/src/CharacterFigure.tsx`). Ele não é uma imagem pronta: +é montado por peças a partir de uma ficha de aparência (`CharacterLook`, em `src/character.ts`) e animado por +um **rig** de parâmetros contínuos (`src/rig.ts`: rosto `FaceParams` e corpo `BodyParams`, braços e pernas em +dois segmentos). As poses e ações (`src/motion.ts`) mexem nesses parâmetros quadro a quadro, e a boca segue a +fala (`src/lipsync.ts`). O vídeo final é renderizado quadro a quadro pela Remotion (Chrome headless), então +**tudo precisa ser função pura dos parâmetros** (nada de aleatório sem semente, nada de relógio). + +O mesmo personagem aparece em close (só rosto e tronco), meio corpo e corpo inteiro, de frente para a câmera. + +## Referência (o NÍVEL de acabamento que queremos) + +Pasta `referencia/`: quadros de um vídeo de outra série (1080×1920) e recortes ampliados em +`referencia/recortes/` (mãos segurando, joinha, mão com prancheta, apontando, close de mãos, braços cruzados, +rosto). `00-video-inteiro-…png` mostra o vídeo todo. + +**Copie a qualidade, não o conteúdo.** Não reproduza aqueles personagens, nomes, roupas, logotipos ou cenas. +O que importa nelas: + +- **Proporção:** cabeça grande (≈ 1/3 da altura no corpo inteiro), pescoço visível e proporcional, ombros + largos e arredondados, tronco em "pera". +- **Sombreado cel em 2 tons**, luz de um lado só, sombra levemente fria, **sem contorno preto** (a borda é o + tom mais escuro da própria cor). +- **Rosto:** orelha com dobra interna; nariz como curva simples; rugas da testa como arcos suaves no tom da + pele; sobrancelha como forma cheia; pálpebra pesada; olhos com esclera branca; óculos de aro grosso com + reflexo. +- **Roupa com construção:** gola, zíper ou botões, costuras, 2–3 dobras (manga, cotovelo, barriga), barra; + pano pendurado (toalha) com dobras e sombra própria. +- **MÃOS (o problema principal):** formas macias e orgânicas, dedos de comprimentos diferentes que afinam na + ponta, nós em arco, polegar nascendo da base da palma, unhas visíveis quando a vista mostra, mão grande + (≈ do nariz ao queixo). Segurando objeto: o polegar por cima e os dedos por trás (objeto entre as camadas da + mão). Objeto largo (livro, camisa dobrada) com as duas mãos pelas bordas. Joinha com o punho de lado e os + dedos dobrados em fileira. A **mão sai de dentro da manga**: a manga termina numa borda com espessura e + abertura escura, o pulso afina e entra nela, e a manga faz sombra no pulso. + +## Onde estamos (pasta `nosso/`) + +- `01-folha-antes.png` → `02-folha-atual.png`: em cima a referência, embaixo o nosso, nos mesmos 6 + enquadramentos. Melhoramos muito, mas um olhar rápido ainda separa os dois. +- `03-maos-ref-antes-depois.png`, `04-formas-de-mao-3-rotacoes.png`: estado atual das mãos (biblioteca + `src/hands.tsx` com formas `relaxed`, `open`, `point`, `thumbs_up`, `grip`, `pinch_edge`, `pinch_low`, + `fist`, `on_face`, giradas pelo pulso). +- `05-poses-camadas.png`: a ordem das camadas do braço (`src/limbs.ts`, `armLayer`) para a mão nunca sumir + atrás do corpo. +- `08-folha-de-poses-do-workspace.png`: saída do script deste workspace (12 poses). + +O que o dono do projeto ainda reprova: + +1. **Mãos** ainda parecem recortadas/coladas: formas duras, sombra em cunha, dedos "salsicha". Exemplos na + folha 08: + - braços cruzados viram um losango de dedos; + - no apontar, a mão some; + - o martelo e o ramo atravessam a túnica, e o cabo não fica claramente dentro do punho; + - no pensar e no tapar a boca, a mão parece um bloco. +2. A **emenda pulso → manga** às vezes mostra corte ou degrau quando o braço gira. +3. O **corpo inteiro** ainda parece "boneco de recorte" perto da referência: + - pouco volume na roupa; + - pernas e braços muito retos; + - sapato simples; + - sobrancelhas claras viram mancha (veja o idoso de barba branca). +4. Falta **textura de ilustração**: a referência tem degradê suave dentro das áreas e um leve granulado. A + sombra cel deve continuar, mas com transição menos "vetor de ícone". + +## O que fazer + +1. Estude a referência (abra as imagens) e liste, por item acima, o que muda no desenho. +2. Reescreva o que precisar em `src/CharacterFigure.tsx`, `src/hands.tsx` e `src/limbs.ts` (e, se + necessário, presets de pose em `src/rig.ts`) para chegar ao nível da referência. Pode criar arquivos novos + em `src/`. +3. Use `npx tsx render-sheet.tsx` (corpo inteiro) e `npx tsx render-sheet.tsx close` (close) para gerar + `out/sheet-*.svg`/`.png` e **olhe as imagens a cada rodada**. Acrescente poses ao `CELLS` do script se + precisar (ex.: apontar para o outro lado, acenar com a outra mão, mãos na cintura, segurando celular). +4. Pare quando, lado a lado com os recortes da referência, a mão e o corpo não se separarem pela qualidade do + desenho. + +### Regras que NÃO podem quebrar (o projeto real depende delas) + +- **Mesma interface pública:** + - `CharacterFigure({ look, expression?, pose?, item?, t?, state?, shadeSide?, gesture? })`; + - viewBox `0 0 200 440` com os pés em (100, 440); + - `HandsInsert({ look, item?, t?, shadeSide? })` desenha o close de mãos num viewBox 1080×1080. +- **Tipos e campos:** `CharacterLook`, `FaceParams`, `BodyParams` e os nomes de poses e expressões continuam + existindo. Campo novo só **opcional**, porque personagens já salvos precisam continuar abrindo. +- **Rig:** o desenho continua dirigido pelo rig. Expressões, poses, fala (boca) e movimento (andar, acenar, + martelar, pular, sentar) precisam funcionar; a sombra acompanha a cabeça virando (`headTurn`) e as dobras + acompanham o braço. +- **Sem dependências novas no desenho:** só React e SVG, sem imagens rasterizadas e sem bibliotecas novas. +- **Sem custo alto de render:** nada de `feGaussianBlur` ou filtros SVG pesados repetidos por quadro (o vídeo + renderiza 30 quadros por segundo; hoje um trecho de 4 s leva ~4 s). Degradê linear ou radial e textura + barata são aceitos. +- **Função pura e camadas:** + - nada de `Math.random()` nem relógio; mesmos parâmetros = mesmo desenho; + - braço, mão e objeto na mão nunca somem atrás do tronco, da barba ou de acessório quando o personagem está + de frente; mantenha a lógica de `armLayer` (ou melhore-a). + +## Entrega + +- A pasta `workspace/src/` com os arquivos alterados ou novos (vou copiá-los de volta para o projeto). +- `out/sheet-full.png` e `out/sheet-close.png` finais, e uma folha **referência × seu resultado** (os recortes + da referência ao lado das mesmas situações no seu desenho). +- Um resumo curto: o que mudou em cada arquivo, campos novos (se houver) e o que ainda não ficou igual. diff --git a/.studies/cartoon-personagem-handoff/nosso/01-folha-antes.png b/.studies/cartoon-personagem-handoff/nosso/01-folha-antes.png new file mode 100644 index 0000000..84d6b24 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/nosso/01-folha-antes.png differ diff --git a/.studies/cartoon-personagem-handoff/nosso/02-folha-atual.png b/.studies/cartoon-personagem-handoff/nosso/02-folha-atual.png new file mode 100644 index 0000000..1989508 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/nosso/02-folha-atual.png differ diff --git a/.studies/cartoon-personagem-handoff/nosso/03-maos-ref-antes-depois.png b/.studies/cartoon-personagem-handoff/nosso/03-maos-ref-antes-depois.png new file mode 100644 index 0000000..89aa4d3 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/nosso/03-maos-ref-antes-depois.png differ diff --git a/.studies/cartoon-personagem-handoff/nosso/04-formas-de-mao-3-rotacoes.png b/.studies/cartoon-personagem-handoff/nosso/04-formas-de-mao-3-rotacoes.png new file mode 100644 index 0000000..f92d02c Binary files /dev/null and b/.studies/cartoon-personagem-handoff/nosso/04-formas-de-mao-3-rotacoes.png differ diff --git a/.studies/cartoon-personagem-handoff/nosso/05-poses-camadas.png b/.studies/cartoon-personagem-handoff/nosso/05-poses-camadas.png new file mode 100644 index 0000000..e993b54 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/nosso/05-poses-camadas.png differ diff --git a/.studies/cartoon-personagem-handoff/nosso/06-close-atual-recorte.png b/.studies/cartoon-personagem-handoff/nosso/06-close-atual-recorte.png new file mode 100644 index 0000000..942c5ef Binary files /dev/null and b/.studies/cartoon-personagem-handoff/nosso/06-close-atual-recorte.png differ diff --git a/.studies/cartoon-personagem-handoff/nosso/07-corpo-inteiro-atual-recorte.png b/.studies/cartoon-personagem-handoff/nosso/07-corpo-inteiro-atual-recorte.png new file mode 100644 index 0000000..736c732 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/nosso/07-corpo-inteiro-atual-recorte.png differ diff --git a/.studies/cartoon-personagem-handoff/nosso/08-folha-de-poses-do-workspace.png b/.studies/cartoon-personagem-handoff/nosso/08-folha-de-poses-do-workspace.png new file mode 100644 index 0000000..4609230 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/nosso/08-folha-de-poses-do-workspace.png differ diff --git a/.studies/cartoon-personagem-handoff/referencia/00-video-inteiro-1-quadro-a-cada-6s.png b/.studies/cartoon-personagem-handoff/referencia/00-video-inteiro-1-quadro-a-cada-6s.png new file mode 100644 index 0000000..8f24858 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/referencia/00-video-inteiro-1-quadro-a-cada-6s.png differ diff --git a/.studies/cartoon-personagem-handoff/referencia/01-close-segurando.png b/.studies/cartoon-personagem-handoff/referencia/01-close-segurando.png new file mode 100644 index 0000000..a1544cd Binary files /dev/null and b/.studies/cartoon-personagem-handoff/referencia/01-close-segurando.png differ diff --git a/.studies/cartoon-personagem-handoff/referencia/02-meio-corpo-apontando.png b/.studies/cartoon-personagem-handoff/referencia/02-meio-corpo-apontando.png new file mode 100644 index 0000000..37fd631 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/referencia/02-meio-corpo-apontando.png differ diff --git a/.studies/cartoon-personagem-handoff/referencia/03-corpo-inteiro-joinha.png b/.studies/cartoon-personagem-handoff/referencia/03-corpo-inteiro-joinha.png new file mode 100644 index 0000000..3b1586a Binary files /dev/null and b/.studies/cartoon-personagem-handoff/referencia/03-corpo-inteiro-joinha.png differ diff --git a/.studies/cartoon-personagem-handoff/referencia/04-externo-entardecer.png b/.studies/cartoon-personagem-handoff/referencia/04-externo-entardecer.png new file mode 100644 index 0000000..a6f2488 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/referencia/04-externo-entardecer.png differ diff --git a/.studies/cartoon-personagem-handoff/referencia/05-insert-maos.png b/.studies/cartoon-personagem-handoff/referencia/05-insert-maos.png new file mode 100644 index 0000000..871cf5d Binary files /dev/null and b/.studies/cartoon-personagem-handoff/referencia/05-insert-maos.png differ diff --git a/.studies/cartoon-personagem-handoff/referencia/06-bracos-cruzados.png b/.studies/cartoon-personagem-handoff/referencia/06-bracos-cruzados.png new file mode 100644 index 0000000..64f3a23 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/referencia/06-bracos-cruzados.png differ diff --git a/.studies/cartoon-personagem-handoff/referencia/07-multidao.png b/.studies/cartoon-personagem-handoff/referencia/07-multidao.png new file mode 100644 index 0000000..9f37176 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/referencia/07-multidao.png differ diff --git a/.studies/cartoon-personagem-handoff/referencia/recortes/apontando.png b/.studies/cartoon-personagem-handoff/referencia/recortes/apontando.png new file mode 100644 index 0000000..6be6419 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/referencia/recortes/apontando.png differ diff --git a/.studies/cartoon-personagem-handoff/referencia/recortes/bracos-cruzados.png b/.studies/cartoon-personagem-handoff/referencia/recortes/bracos-cruzados.png new file mode 100644 index 0000000..e547bb4 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/referencia/recortes/bracos-cruzados.png differ diff --git a/.studies/cartoon-personagem-handoff/referencia/recortes/insert-maos.png b/.studies/cartoon-personagem-handoff/referencia/recortes/insert-maos.png new file mode 100644 index 0000000..e3413c3 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/referencia/recortes/insert-maos.png differ diff --git a/.studies/cartoon-personagem-handoff/referencia/recortes/joinha.png b/.studies/cartoon-personagem-handoff/referencia/recortes/joinha.png new file mode 100644 index 0000000..9ca310c Binary files /dev/null and b/.studies/cartoon-personagem-handoff/referencia/recortes/joinha.png differ diff --git a/.studies/cartoon-personagem-handoff/referencia/recortes/mao-prancheta.png b/.studies/cartoon-personagem-handoff/referencia/recortes/mao-prancheta.png new file mode 100644 index 0000000..042d055 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/referencia/recortes/mao-prancheta.png differ diff --git a/.studies/cartoon-personagem-handoff/referencia/recortes/maos-segurando.png b/.studies/cartoon-personagem-handoff/referencia/recortes/maos-segurando.png new file mode 100644 index 0000000..6960766 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/referencia/recortes/maos-segurando.png differ diff --git a/.studies/cartoon-personagem-handoff/referencia/recortes/rosto-close.png b/.studies/cartoon-personagem-handoff/referencia/recortes/rosto-close.png new file mode 100644 index 0000000..a7ec2a7 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/referencia/recortes/rosto-close.png differ diff --git a/.studies/cartoon-personagem-handoff/workspace/README.md b/.studies/cartoon-personagem-handoff/workspace/README.md new file mode 100644 index 0000000..93f8c97 --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/README.md @@ -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`. diff --git a/.studies/cartoon-personagem-handoff/workspace/out/referencia-vs-resultado.png b/.studies/cartoon-personagem-handoff/workspace/out/referencia-vs-resultado.png new file mode 100644 index 0000000..580c943 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/workspace/out/referencia-vs-resultado.png differ diff --git a/.studies/cartoon-personagem-handoff/workspace/out/referencia-vs-resultado.svg b/.studies/cartoon-personagem-handoff/workspace/out/referencia-vs-resultado.svg new file mode 100644 index 0000000..78a2916 --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/out/referencia-vs-resultado.svg @@ -0,0 +1 @@ +REFERÊNCIA (recortes originais) × NOSSO RESULTADO (SVG puro / rig contínuo sem juntas)1. Rosto (close) — Ref1. Rosto (close) — Nosso2. Segurando (2 mãos) — Ref2. Segurando (2 mãos) — Nosso3. Joinha (thumbs_up) — Ref3. Joinha (thumbs_up) — Nosso4. Segurando (1 mão) — Ref4. Segurando (1 mão) — Nosso5. Apontando (point) — Ref5. Apontando (point) — Nosso6. Braços cruzados — Ref6. Braços cruzados — Nosso7. Insert de mãos — Ref7. Insert de mãos — Nosso \ No newline at end of file diff --git a/.studies/cartoon-personagem-handoff/workspace/out/sheet-close.png b/.studies/cartoon-personagem-handoff/workspace/out/sheet-close.png new file mode 100644 index 0000000..d651f8e Binary files /dev/null and b/.studies/cartoon-personagem-handoff/workspace/out/sheet-close.png differ diff --git a/.studies/cartoon-personagem-handoff/workspace/out/sheet-close.svg b/.studies/cartoon-personagem-handoff/workspace/out/sheet-close.svg new file mode 100644 index 0000000..0911cd3 --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/out/sheet-close.svg @@ -0,0 +1 @@ +stand / relaxedhold book (2 mãos)thumbs uphold ruler (1 mão)pointwavecross_armsthinkcover_mouthhold hammerhold olivecelebratepoint (manga curta)cross_arms (manga curta)hands_on_hipshold phoneshrugfacepalm \ No newline at end of file diff --git a/.studies/cartoon-personagem-handoff/workspace/out/sheet-full.png b/.studies/cartoon-personagem-handoff/workspace/out/sheet-full.png new file mode 100644 index 0000000..9c6e3f0 Binary files /dev/null and b/.studies/cartoon-personagem-handoff/workspace/out/sheet-full.png differ diff --git a/.studies/cartoon-personagem-handoff/workspace/out/sheet-full.svg b/.studies/cartoon-personagem-handoff/workspace/out/sheet-full.svg new file mode 100644 index 0000000..50e4564 --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/out/sheet-full.svg @@ -0,0 +1 @@ +stand / relaxedhold book (2 mãos)thumbs uphold ruler (1 mão)pointwavecross_armsthinkcover_mouthhold hammerhold olivecelebratepoint (manga curta)cross_arms (manga curta)hands_on_hipshold phoneshrugfacepalm \ No newline at end of file diff --git a/.studies/cartoon-personagem-handoff/workspace/package-lock.json b/.studies/cartoon-personagem-handoff/workspace/package-lock.json new file mode 100644 index 0000000..f2e7023 --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/package-lock.json @@ -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" + } + } + } +} diff --git a/.studies/cartoon-personagem-handoff/workspace/package.json b/.studies/cartoon-personagem-handoff/workspace/package.json new file mode 100644 index 0000000..4168b83 --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/package.json @@ -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" + } +} diff --git a/.studies/cartoon-personagem-handoff/workspace/render-sheet.tsx b/.studies/cartoon-personagem-handoff/workspace/render-sheet.tsx new file mode 100644 index 0000000..3233a72 --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/render-sheet.tsx @@ -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>; +const Insert = HandsInsert as unknown as React.FC>; + +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 = ( + + + {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 ( + + + + + + + + + + + + + {c.label} + + ); + })} + + ); + 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 ``. + 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 ( + + {node} + + ); + }; + 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, ), + }, + { + title: "2. Segurando (2 mãos)", + refFile: "maos-segurando.png", + bg: "#232d4b", + renderOur: (w, h) => cropFig(w, h, 100, 250, 128, ), + }, + { + title: "3. Joinha (thumbs_up)", + refFile: "joinha.png", + bg: "#68623e", + renderOur: (w, h) => cropFig(w, h, 122, 212, 130, ), + }, + { + title: "4. Segurando (1 mão)", + refFile: "mao-prancheta.png", + bg: "#3e4844", + renderOur: (w, h) => cropFig(w, h, 118, 224, 132, ), + }, + { + title: "5. Apontando (point)", + refFile: "apontando.png", + bg: "#6e4e3a", + renderOur: (w, h) => cropFig(w, h, 130, 178, 125, ), + }, + { + title: "6. Braços cruzados", + refFile: "bracos-cruzados.png", + bg: "#8c8275", + renderOur: (w, h) => cropFig(w, h, 100, 266, 142, ), + }, + { + title: "7. Insert de mãos", + refFile: "insert-maos.png", + bg: "#4a3322", + renderOur: (w, h) => ( + + + + + + ), + }, + ]; + + const cw = 320, ch = 320, pad = 16, topBanner = 52, labelH = 34; + const W = items.length * cw, H = topBanner + (ch + labelH) * 2 + 20; + const sheet = ( + + + + REFERÊNCIA (recortes originais) × NOSSO RESULTADO (SVG puro / rig contínuo sem juntas) + + {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 ( + + {it.title} — Ref + + + + + + + {refData && } + + {it.title} — Nosso + + + + {it.renderOur(boxW, boxH)} + + + + ); + })} + + ); + 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"); + } +} diff --git a/.studies/cartoon-personagem-handoff/workspace/src/CharacterFigure.tsx b/.studies/cartoon-personagem-handoff/workspace/src/CharacterFigure.tsx new file mode 100644 index 0000000..e3d067d --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/src/CharacterFigure.tsx @@ -0,0 +1,1310 @@ +// Desenho do personagem a partir do RIG (rig.ts): rosto e corpo por parâmetros contínuos, braços e pernas em +// dois segmentos (ombro/cotovelo, quadril/joelho) com SKINNING CONTÍNUO EM BÉZIER (sem juntas de boneco recortado). +// SVG puro, sem Remotion: o painel usa o mesmo componente. viewBox 200×440, pés em (100, 440). +import React, { useId } from "react"; +import { Icon } from "./icons"; +import type { IconId } from "./spec"; +import { DEFAULT_LOOK, type CharacterLook } from "./character"; +import { evaluate, type ActorState } from "./motion"; +import { POSE_PRESETS, type BodyParams, type FaceParams, type Limb } from "./rig"; +import { armLayer, type Point } from "./limbs"; +import { GRIP, HandArt, TWO_HANDED, handPlacement, wristForHold, type HandShape } from "./hands"; + +const INK = "#1d1a22"; +/** Escala da cabeça sobre o desenho-base da cabeça (centro (100,106), queixo em y 156). */ +const HEAD_SCALE = 1.2; + +export function shade(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 mix(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)}`; +} +/** Sombra com um pouco de azul (sombra fria sob luz quente, como na ilustração). */ +function cool(hex: string, k = 0.78): string { + const n = parseInt(hex.slice(1), 16); + const r = ((n >> 16) & 255) * k * 0.95, g = ((n >> 8) & 255) * k * 0.97, b = (n & 255) * k + 8; + 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)}`; +} +/** Ponta de um segmento: ângulo de tela em graus (0 = para baixo). */ +const tip = (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 }; +}; + +/** Textura barata de ilustração (granulado determinístico em `` 28×28, sem filtros SVG pesados). */ +function GrainDefs({ id }: { id: string }) { + const dots: [number, number, number, string][] = [ + [3, 4, 0.7, "#fff"], [11, 2, 0.6, "#000"], [19, 6, 0.8, "#fff"], [25, 3, 0.6, "#000"], + [6, 11, 0.7, "#000"], [15, 10, 0.7, "#fff"], [22, 13, 0.6, "#000"], [2, 18, 0.6, "#000"], + [9, 17, 0.8, "#fff"], [17, 20, 0.7, "#000"], [26, 19, 0.7, "#fff"], [5, 25, 0.7, "#fff"], + [13, 24, 0.6, "#000"], [21, 26, 0.7, "#fff"], [8, 7, 0.5, "#000"], [24, 9, 0.5, "#fff"], + ]; + return ( + + {dots.map(([cx, cy, r, fill], i) => ( + + ))} + + ); +} + +/** + * Forma com sombra cel de ilustração: base em tom frio de sombra e camada iluminada com degradê suave, + * recortadas pela própria forma. + */ +function Cel({ id, d, litD, fill, side, dx = 8, dy = -4, k = 0.82, transform, grainId }: { + id: string; d: string; litD?: string; fill: string; side: number; dx?: number; dy?: number; k?: number; transform?: string; grainId?: string; +}) { + const shCol = cool(fill, k); + return ( + + + + + + + + {grainId && } + + + ); +} + +/** + * Envelope contínuo de membro em 2 segmentos (ombro→cotovelo→pulso ou quadril→joelho→tornozelo), estilo RubberHose/Limber: + * gera UM ÚNICO path fechado em curvas de Bézier sem junta no cotovelo/joelho, mais `litD` com a raiz estendida (para a + * sombra cel nunca desenhar arco escuro na junta do ombro!). + */ +function buildSkinnedLimb(p0: Point, p1: Point, p2: Point, r0: number, r1: number, r2: number, s: 1 | -1) { + const v1 = { x: p1.x - p0.x, y: p1.y - p0.y }; + const v2 = { x: p2.x - p1.x, y: p2.y - p1.y }; + const L1 = Math.hypot(v1.x, v1.y) || 1; + const L2 = Math.hypot(v2.x, v2.y) || 1; + const u1 = { x: v1.x / L1, y: v1.y / L1 }; + const u2 = { x: v2.x / L2, y: v2.y / L2 }; + const n1 = { x: -u1.y, y: u1.x }; + const n2 = { x: -u2.y, y: u2.x }; + + const sumU = { x: u1.x + u2.x, y: u1.y + u2.y }; + const sumLen = Math.hypot(sumU.x, sumU.y); + const te = sumLen > 0.05 ? { x: sumU.x / sumLen, y: sumU.y / sumLen } : n1; + const ne = { x: -te.y, y: te.x }; + + const dot = Math.max(-0.98, Math.min(1, u1.x * u2.x + u1.y * u2.y)); + const cross = u1.x * u2.y - u1.y * u2.x; + const bendAmount = Math.sqrt(Math.max(0, (1 - dot) * 0.5)); + const rInner = r1 * (1 - 0.08 * bendAmount); + const rOuter = r1 * (1 + 0.12 * bendAmount); + + const aIsInner = cross > 0; + const rA = aIsInner ? rInner : rOuter; + const rB = !aIsInner ? rInner : rOuter; + + const A0 = { x: p0.x + n1.x * r0, y: p0.y + n1.y * r0 }; + const B0 = { x: p0.x - n1.x * r0, y: p0.y - n1.y * r0 }; + const A1 = { x: p1.x + ne.x * rA, y: p1.y + ne.y * rA }; + const B1 = { x: p1.x - ne.x * rB, y: p1.y - ne.y * rB }; + const A2 = { x: p2.x + n2.x * r2, y: p2.y + n2.y * r2 }; + const B2 = { x: p2.x - n2.x * r2, y: p2.y - n2.y * r2 }; + + const dA1 = Math.hypot(A1.x - A0.x, A1.y - A0.y); + const dA2 = Math.hypot(A2.x - A1.x, A2.y - A1.y); + const dB1 = Math.hypot(B1.x - B0.x, B1.y - B0.y); + const dB2 = Math.hypot(B2.x - B1.x, B2.y - B1.y); + + const projA1 = Math.max(4, (A1.x - A0.x) * u1.x + (A1.y - A0.y) * u1.y); + const projA2 = Math.max(4, (A2.x - A1.x) * u2.x + (A2.y - A1.y) * u2.y); + const projB1 = Math.max(4, (B1.x - B0.x) * u1.x + (B1.y - B0.y) * u1.y); + const projB2 = Math.max(4, (B2.x - B1.x) * u2.x + (B2.y - B1.y) * u2.y); + + const hA1 = aIsInner ? Math.min(dA1, projA1) * 0.26 : dA1 * 0.38; + const hA2 = aIsInner ? Math.min(dA2, projA2) * 0.26 : dA2 * 0.38; + const hB1 = !aIsInner ? Math.min(dB1, projB1) * 0.26 : dB1 * 0.38; + const hB2 = !aIsInner ? Math.min(dB2, projB2) * 0.26 : dB2 * 0.38; + + // No lado convexo (externo), a tangente no cotovelo é `te` (curva redonda contínua); + // no lado côncavo (interno da dobra), os handles seguem `u1` (chegando) e `u2` (saindo) para nunca formar laço em dobras agudas! + const tA1 = aIsInner ? u1 : te; + const tA2 = aIsInner ? u2 : te; + const tB1 = !aIsInner ? u1 : te; + const tB2 = !aIsInner ? u2 : te; + + const f = (n: number) => n.toFixed(1); + const bodySegs = [ + `C${f(A0.x + u1.x * hA1)} ${f(A0.y + u1.y * hA1)} ${f(A1.x - tA1.x * hA1)} ${f(A1.y - tA1.y * hA1)} ${f(A1.x)} ${f(A1.y)}`, + `C${f(A1.x + tA2.x * hA2)} ${f(A1.y + tA2.y * hA2)} ${f(A2.x - u2.x * hA2)} ${f(A2.y - u2.y * hA2)} ${f(A2.x)} ${f(A2.y)}`, + `A${f(r2)} ${f(r2)} 0 0 0 ${f(B2.x)} ${f(B2.y)}`, + `C${f(B2.x - u2.x * hB2)} ${f(B2.y - u2.y * hB2)} ${f(B1.x + tB2.x * hB2)} ${f(B1.y + tB2.y * hB2)} ${f(B1.x)} ${f(B1.y)}`, + `C${f(B1.x - tB1.x * hB1)} ${f(B1.y - tB1.y * hB1)} ${f(B0.x + u1.x * hB1)} ${f(B0.y + u1.y * hB1)} ${f(B0.x)} ${f(B0.y)}`, + ]; + const d = [`M${f(A0.x)} ${f(A0.y)}`, ...bodySegs, `A${f(r0)} ${f(r0)} 0 0 0 ${f(A0.x)} ${f(A0.y)} Z`].join(" "); + // Na cópia iluminada, estende a raiz do ombro para cima (mas mantém a borda direita alinhada à sombra do tronco quando s > 0). + const extB = s > 0 ? 0 : 8; + const extA0 = { x: A0.x - u1.x * 18 + n1.x * 8, y: A0.y - u1.y * 18 + n1.y * 8 }; + const extB0 = { x: B0.x - u1.x * 18 - n1.x * extB, y: B0.y - u1.y * 18 - n1.y * extB }; + const litD = [`M${f(A0.x)} ${f(A0.y)}`, ...bodySegs, `L${f(extB0.x)} ${f(extB0.y)} L${f(extA0.x)} ${f(extA0.y)} Z`].join(" "); + + const S0 = s > 0 ? { x: p0.x - n1.x * (r0 - 2.5), y: p0.y - n1.y * (r0 - 2.5) } : { x: p0.x + n1.x * (r0 - 2.5), y: p0.y + n1.y * (r0 - 2.5) }; + const S1 = s > 0 ? { x: B1.x + ne.x * 2.5, y: B1.y + ne.y * 2.5 } : { x: A1.x - ne.x * 2.5, y: A1.y - ne.y * 2.5 }; + const S2 = s > 0 ? { x: p2.x - n2.x * (r2 - 2.5), y: p2.y - n2.y * (r2 - 2.5) } : { x: p2.x + n2.x * (r2 - 2.5), y: p2.y + n2.y * (r2 - 2.5) }; + const hS1 = s > 0 ? hB1 : hA1; + const hS2 = s > 0 ? hB2 : hA2; + const stripePath = `M${f(S0.x)} ${f(S0.y)} C${f(S0.x + u1.x * hS1)} ${f(S0.y + u1.y * hS1)} ${f(S1.x - te.x * hS1)} ${f(S1.y - te.y * hS1)} ${f(S1.x)} ${f(S1.y)}` + + ` C${f(S1.x + te.x * hS2)} ${f(S1.y + te.y * hS2)} ${f(S2.x - u2.x * hS2)} ${f(S2.y - u2.y * hS2)} ${f(S2.x)} ${f(S2.y)}`; + + const EIn = aIsInner ? A1 : B1; + const nIn = aIsInner ? ne : { x: -ne.x, y: -ne.y }; + const elbowFold = bendAmount > 0.28 + ? `M${f(EIn.x)} ${f(EIn.y)} Q${f(EIn.x - nIn.x * 4.5 + te.x * 1.5)} ${f(EIn.y - nIn.y * 4.5 + te.y * 1.5)} ${f(EIn.x - nIn.x * 8)} ${f(EIn.y - nIn.y * 8)}` + : ""; + + return { d, litD, stripePath, elbowFold, A0, B0, A1, B1, A2, B2 }; +} + +/** Mantém `Limb2` exportado para compatibilidade caso algum módulo externo importe. */ +export function Limb2({ id, x, y, deg, len, w1, w2, fill, side, swell = 1.4 }: { + id: string; x: number; y: number; deg: number; len: number; w1: number; w2: number; fill: string; side: number; swell?: number; +}) { + const mw = ((w1 + w2) / 2) + swell * 2; + const d = `M${-w1 / 2} 0 C${-mw / 2} ${len * 0.36} ${-mw * 0.48} ${len * 0.72} ${-w2 / 2} ${len}` + + ` A${w2 / 2} ${w2 / 2} 0 0 0 ${w2 / 2} ${len}` + + ` C${mw * 0.48} ${len * 0.72} ${mw / 2} ${len * 0.36} ${w1 / 2} 0` + + ` A${w1 / 2} ${w1 / 2} 0 0 0 ${-w1 / 2} 0 Z`; + const r = (deg * Math.PI) / 180; + const local = Math.cos(r) >= 0 ? side : -side; + return ; +} + +/** Dobra de tecido afilada nas pontas (forma lenticular cheia, como nas roupas da referência). */ +function TaperFold({ x1, y1, cx, cy, x2, y2, color, thickness = 2.6, opacity = 0.85 }: { + x1: number; y1: number; cx: number; cy: number; x2: number; y2: number; color: string; thickness?: number; opacity?: number; +}) { + const dx = x2 - x1, dy = y2 - y1; + const len = Math.hypot(dx, dy) || 1; + const nx = (-dy / len) * thickness, ny = (dx / len) * thickness; + return ( + + ); +} + +function Mouth({ f, uid, skin, hasMustache }: { f: FaceParams; uid: string; skin: string; hasMustache?: boolean }) { + const w = 28 * f.mouthWidth * (1 - f.mouthRound * 0.35); + const baseCy = hasMustache ? 140.5 : 138.5; + const cy = baseCy - f.smile * 4.5; + const lipDark = shade(skin, 0.42); + const chinCrease = shade(skin, 0.78); + if (f.mouthOpen < 0.06 && f.mouthRound < 0.3) { + return ( + + + + + ); + } + const open = Math.max(f.mouthOpen, f.mouthRound * 0.25); + const up = cy + f.smile * 2 - open * 5.5 - f.mouthRound * 4.5; + const low = cy + open * 38 * (1 + f.mouthRound * 0.28) + f.smile * 10.5; + const d = `M${100 - w / 2} ${cy} Q100 ${up} ${100 + w / 2} ${cy} Q100 ${low} ${100 - w / 2} ${cy} Z`; + const fullTeethGrin = f.teeth && f.smile >= 0.65 && open < 0.45; + return ( + + + + + {!fullTeethGrin && f.teeth && open > 0.12 && ( + + )} + {!fullTeethGrin && open > 0.32 && ( + + )} + + + + + ); +} + +function Eyes({ f, lid, skin, uid, hasGlasses }: { f: FaceParams; lid: number; skin: string; uid: string; hasGlasses?: boolean }) { + const big = Math.max(f.eyeL, f.eyeR); + const maxGrow = hasGlasses ? 2.8 : 5.5; + const r = 10.6 + Math.min(maxGrow, Math.max(0, big - 1) * 5.5); + const cover = Math.max(0, Math.min(0.8, lid)); + const lidColor = shade(skin, 0.94); + const lidLine = shade(skin, 0.38); + const crease = shade(skin, 0.58); + const eye = (x: number, open: number, sideSign: number) => { + if (open < 0.3 && f.smile > 0.55) { + return ( + + + + + ); + } + if (open < 0.14) return ; + const rx = r * 1.15; + const vScale = Math.min(hasGlasses ? 1.05 : 1.16, open); + const lidY = -r + 2 * r * cover; + return ( + + + + + + {cover > 0.02 ? ( + <> + + + + ) : ( + + )} + + {!hasGlasses && ( + + )} + + ); + }; + return {eye(81, f.eyeL, -1)}{eye(119, f.eyeR, 1)}; +} + +function Brows({ f, thick, color, skin }: { f: FaceParams; thick: boolean; color: string; skin: string }) { + const h = thick ? 7 : 5; + const browShadow = shade(skin, 0.74); + const browDark = shade(color, 0.84); + const brow = (x0: number, x1: number, y: number, tilt: number, pivotX: number, inner: number) => { + const outer = x0 === pivotX ? x1 : x0; + const dir = outer > pivotX ? 1 : -1; + const midX = (pivotX + outer) / 2; + const d = `M${pivotX - dir * 1.5} ${y + h * 0.35}` + + ` C${pivotX - dir * 3.5} ${y + h * 0.1} ${pivotX - dir * 3} ${y - h * 0.55} ${pivotX + dir * 1} ${y - h * 0.65}` + + ` Q${midX} ${y - h * 1.12} ${outer - dir * 1.5} ${y - h * 0.2}` + + ` C${outer + dir * 2} ${y + h * 0.05} ${outer + dir * 1} ${y + h * 0.45} ${outer - dir * 2} ${y + h * 0.35}` + + ` Q${midX} ${y - h * 0.12} ${pivotX - dir * 1.5} ${y + h * 0.35} Z`; + return ( + + + + + + ); + }; + return ( + + {brow(67, 92, 88 + f.browL.y, f.browL.tilt, 92, -1)} + {brow(108, 133, 88 + f.browR.y, f.browR.tilt, 108, 1)} + + ); +} + +function Extras({ f, t, skin }: { f: FaceParams; t: number; skin: string }) { + return ( + + + + {f.sweat && } + {f.tears && [80, 120].map((x, i) => { + const k = ((t * 1.4 + i * 0.5) % 1); + return ; + })} + {f.anger && } + {skin && null} + + ); +} + +function MustacheShape({ color }: { color: string }) { + const dark = shade(color, 0.82); + return ( + + + + + ); +} + +function Beard({ style, color, uid, side, skin, part = "face" }: { + style: CharacterLook["beard"]["style"]; color: string; uid: string; side: number; skin: string; part?: "face" | "upperLip"; +}) { + if (part === "upperLip") { + if (style === "mustache" || style === "goatee" || style === "long") { + return ; + } + return null; + } + switch (style) { + case "full": { + const d = "M52 106 C52 142 65 166 100 168 C135 166 148 142 148 106 C142 124 132 132 123 134" + + " C118 122 109 118 100 119.5 C91 118 82 122 77 134 C68 132 58 124 52 106 Z"; + return ( + + + + + ); + } + case "stubble": + return ; + case "goatee": + return ; + case "long": { + const d = "M53 104 C51 146 64 186 78 216 C88 236 95 246 100 247 C105 246 112 236 122 216 C136 186 149 146 147 104 C140 126 126 126 116 125 C100 122 84 125 84 125 C74 126 60 126 53 104 Z"; + return ( + + + + + + ); + } + default: + return null; + } +} + +function Nose({ kind, skin }: { kind: CharacterLook["nose"]; skin: string }) { + const dark = shade(skin, 0.48); + switch (kind) { + case "round": + return ( + + + + + ); + case "long": + return ( + + + + + ); + case "wide": + return ( + + + + + ); + case "button": + return ; + default: + return ( + + + + + ); + } +} + +function Wrinkles({ k, skin }: { k: number; skin: string }) { + if (k <= 0.05) return null; + const c = shade(skin, 0.72); + return ( + + + {k > 0.3 && } + {k > 0.6 && } + + ); +} + +function headPath(shape: CharacterLook["head"]): string { + switch (shape) { + case "oval": return "M100 52 C127 52 144 76 144 106 C144 141 124 162 100 162 C76 162 56 141 56 106 C56 76 73 52 100 52 Z"; + case "square": return "M100 54 C131 54 149 71 149 100 L148 128 C146 151 127 160 100 160 C73 160 54 151 52 128 L51 100 C51 71 69 54 100 54 Z"; + case "wide": return "M100 55 C129 55 147 72 149 99 C152 129 140 158 100 160 C60 158 48 129 51 99 C53 72 71 55 100 55 Z"; + default: return "M100 54 C127 54 148 77 148 106 C148 135 127 158 100 158 C73 158 52 135 52 106 C52 77 73 54 100 54 Z"; + } +} + +function Glasses({ kind }: { kind: CharacterLook["glasses"] }) { + if (kind === "none") return null; + const frame = kind === "sun" ? "#1c1a20" : "#492b1a"; + const lens = (x: number) => kind === "square" + ? + : ; + return ( + + {lens(81)}{lens(119)} + {kind === "sun" && ( + + + + )} + {lens(81)}{lens(119)} + + + + ); +} + +function HairFront({ look, uid, side }: { look: CharacterLook; uid: string; side: number }) { + const c = look.hair.color; + const dark = shade(c, 0.8); + const cel = (d: string, k = 0.8) => ; + switch (look.hair.style) { + case "bald": + return ( + + {cel("M51 108 C46 92 48 72 62 62 C67 72 64 88 58 108 Z M149 108 C154 92 152 72 138 62 C133 72 136 88 142 108 Z", 0.86)} + + ); + case "short": + return ( + + {cel( + "M50 108 C47 84 49 62 64 52 C60 48 62 43 70 43 C68 38 76 35 88 38 C102 36 116 40 124 46" + + " C136 47 146 58 149 78 C151 90 150 100 148 108 C144 108 142 96 140 82" + + " C136 69 129 63 120 60 C106 70 84 71 67 66 C59 73 56 88 54 108 Z" + )} + + + ); + case "side": + return {cel("M50 108 C46 78 52 46 98 44 C138 42 153 64 149 108 C144 92 139 74 124 68 C102 62 78 74 62 82 C56 88 54 98 50 108 Z")}; + case "bun": + return <>{cel("M51 104 Q50 50 100 50 Q150 50 149 104 Q139 72 100 70 Q61 72 51 104 Z")}; + case "long": + return ( + + {cel( + "M49 114 C45 82 50 48 88 45 C96 44 104 44 112 45 C150 48 155 82 151 114" + + " C145 102 141 84 134 74 C124 62 110 59 100 63 C90 59 76 62 66 74 C59 84 55 102 49 114 Z", + 0.85 + )} + + + ); + case "curly": + return {[[58, 86], [70, 64], [89, 52], [111, 52], [130, 64], [142, 86], [100, 62], [79, 74], [121, 74]].map(([x, y], i) => )}; + case "spiky": + return cel("M52 102 L56 64 L71 75 L79 46 L94 69 L104 42 L115 69 L129 48 L133 75 L148 64 L148 102 Q130 79 100 79 Q70 79 52 102 Z"); + case "cap": + return <>; + default: + return null; + } +} + +function Head({ look, f, b, t, uid, side, grainId }: { + look: CharacterLook; f: FaceParams; b: BodyParams; t: number; uid: string; side: number; grainId: string; +}) { + const fx = b.headTurn * 9; + const fy = b.headNod * 6; + const browColor = look.hair.style === "bald" || look.hair.style === "cap" ? look.beard.color : look.hair.color; + const earWell = shade(look.skin, 0.82); + const hasMustache = ["mustache", "full", "goatee", "long"].includes(look.beard.style); + return ( + + {[51, 149].map((x, i) => { + const earSide = i === 0 ? -1 : 1; + const earFill = earSide === side ? cool(look.skin, 0.86) : look.skin; + return ( + + + + + ); + })} + + + + + + + + + + + + + + {look.accessories?.includes("helmet") && ( + + + + + + + )} + {look.accessories?.includes("headset") && ( + + )} + + ); +} + +function Hand({ x, y, deg, s, skin, curl, point, gesture, scale = 1, uid, light = 1, layer = "all", thumbFront, onFace, isThink }: { + x: number; y: number; deg: number; s: number; skin: string; curl: number; point?: boolean; gesture?: "thumbs_up"; + scale?: number; uid: string; light?: number; layer?: "all" | "back" | "front"; + thumbFront?: boolean; + onFace?: boolean; + isThink?: boolean; +}) { + const raised = Math.cos((deg * Math.PI) / 180) < -0.2; + const thumbOk = Math.abs(((deg - 126 * (s >= 0 ? 1 : -1) + 540) % 360) - 180) <= 75; + const shape: HandShape = gesture === "thumbs_up" + ? (thumbOk ? "thumbs_up" : "fist") + : point + ? "point" + : thumbFront + ? (raised ? "pinch_low" : "pinch_edge") + : curl >= 0.6 + ? "grip" + : onFace && isThink + ? "think" + : onFace + ? "on_face" + : raised + ? "open" + : "relaxed"; + return ; +} + +export function SleeveEnd({ x, y, deg, w, cloth, cuff, skin, wrist, light, uid, scale = 1, part = "all" }: { + x: number; y: number; deg: number; w: number; cloth: string; cuff?: string; skin: string; wrist: number; light: number; uid: string; scale?: number; + part?: "all" | "back" | "front"; +}) { + const up = Math.cos((deg * Math.PI) / 180) >= 0; + const band = cuff ?? shade(cloth, 0.86); + const h = cuff ? 8.2 : 5.5; + const ww = wrist > 0 ? wrist : 17.5; + return ( + + {part !== "front" && ( + <> + + + + + + + + + 0 ? 1 : -ww / 2} y={-3} width={ww * 0.45} height={10} fill={cool(skin, 0.85)} /> + + + + )} + {part !== "back" && ( + <> + + + + )} + + ); +} + +function Accessories({ look, x0, x1, top, bottom, hipY, side, part, uid, grainId }: { + look: CharacterLook; x0: number; x1: number; top: number; bottom: number; hipY: number; side: number; part: "torso" | "chest" | "drape"; uid: string; grainId: string; +}) { + const acc = look.accessories ?? []; + const c = look.accessoryColor; + if (part === "drape") return acc.includes("towel") ? : null; + if (part === "chest") { + return ( + + {acc.includes("tie") && <>} + {acc.includes("scarf") && <>} + {acc.includes("whistle") && ( + + + + + + + + + )} + {acc.includes("chain") && } + {acc.includes("badge") && <>} + {acc.includes("towel") && } + + ); + } + return ( + + {acc.includes("vest") && <> + + 0 ? 0.82 : 1)} /> + + + } + {acc.includes("apron") && } + + ); +} + +function TowelBody({ x1, top, hipY, color, side, uid, grainId }: { x1: number; top: number; hipY: number; color: string; side: number; uid: string; grainId: string }) { + const end = hipY - 22; + const backD = `M${x1 - 36} ${top + 8} L${x1 - 4} ${top + 10} C${x1 - 2} ${top + 40} ${x1 - 3} ${end - 12} ${x1 - 6} ${end + 6} L${x1 - 34} ${end + 4} Z`; + const frontD = `M${x1 - 46} ${top + 4} C${x1 - 44} ${top + 36} ${x1 - 47} ${end - 24} ${x1 - 45} ${end - 4} L${x1 - 16} ${end - 2} C${x1 - 14} ${end - 26} ${x1 - 16} ${top + 36} ${x1 - 18} ${top + 6} Z`; + return ( + + + + + + + ); +} + +function TowelDrape({ x1, top, color, side, uid, grainId }: { x1: number; top: number; color: string; side: number; uid: string; grainId: string }) { + const d = `M${x1 - 46} ${top + 8} C${x1 - 43} ${top - 5} ${x1 - 18} ${top - 8} ${x1 - 6} ${top - 1} C${x1 - 2} ${top + 3} ${x1 - 2} ${top + 10} ${x1 - 6} ${top + 15}` + + ` C${x1 - 12} ${top + 10} ${x1 - 26} ${top + 8} ${x1 - 46} ${top + 14} Z`; + return ( + + + + + ); +} + +export function CharacterFigure({ look = DEFAULT_LOOK, expression, pose, item, t = 0, state, shadeSide = 1, gesture }: { + look?: CharacterLook; expression?: string; pose?: string; item?: IconId; t?: number; + gesture?: "thumbs_up"; + state?: Pick; + shadeSide?: 1 | -1; +}) { + const uid = useId().replace(/:/g, ""); + const grainId = `gr${uid}`; + const st = state ?? evaluate({ x: 0, expression, pose }, t, 3600, 1); + const f = st.face; + const twoHanded = !!item && TWO_HANDED.includes(item) && (st.body.armR.raise > 20 || st.body.armR.bend > 40); + const b: BodyParams = twoHanded ? { ...st.body, armL: { ...POSE_PRESETS.hold_both.arms }, armR: { ...POSE_PRESETS.hold_both.arms } } : st.body; + const gest = gesture ?? (pose === "thumbs_up" ? "thumbs_up" : undefined); + const HAND_K = 0.7; + const side = shadeSide; + const w = look.build === "slim" ? 0.86 : look.build === "heavy" ? 1.2 : 1; + const breathe = Math.sin(t * 2.2) * 1.4; + const top = look.top; + + const hipY = 306 + b.crouch * 56; + const legW = 35 * w; + const longTop = top.style === "dress" || top.style === "robe"; + const pants = longTop || look.bottom.style !== "pants" ? look.skin : look.bottom.color; + const footwear = look.footwear ?? "shoes"; + const thighLen = 62 * (1 - 0.72 * b.crouch); + const isTracksuit = top.style === "jacket" && !!top.accent && look.bottom.color === top.color; + + /** Calça inteira como UMA ÚNICA FORMA CONTÍNUA (sem juntas nos quadris nem nos joelhos, como na referência). */ + const renderLowerBody = () => { + const legGeom = (s: 1 | -1, l: Limb) => { + const hx = 100 + s * 19.5 * w; + const thighDeg = -s * (l.raise + b.crouch * 55); + const knee = tip(hx, hipY, thighDeg, thighLen); + const shinDeg = thighDeg + s * (l.bend + b.crouch * 55); + const foot = tip(knee.x, knee.y, shinDeg, 58); + const skinned = buildSkinnedLimb({ x: hx, y: hipY }, knee, foot, (legW + 4) * 0.5, legW * 0.44, legW * 0.36, s); + return { s, hx, thighDeg, knee, shinDeg, foot, skinned }; + }; + const L = legGeom(-1, b.legL); + const R = legGeom(1, b.legR); + const shorts = look.bottom.style === "shorts" && !longTop; + const shoeFor = ({ s, foot }: { s: 1 | -1; foot: Point }) => { + const fw = legW + 12; + const fy = foot.y + 2; + const shoeColor = look.shoes; + const isLightShoe = parseInt(shoeColor.slice(1), 16) > 0xaaaaaa; + const soleColor = isLightShoe ? "#7c8594" : shade(shoeColor, 0.55); + return ( + + {footwear === "shoes" && ( + + + {isLightShoe ? ( + <> + + + + + ) : ( + <> + + + + + + )} + + )} + {footwear !== "shoes" && ( + + )} + {footwear === "sandals" && ( + + + + + + )} + + ); + }; + + // Calça comprida: une quadril + perna esquerda + perna direita num envelope único sem juntas. + if (!longTop && look.bottom.style === "pants") { + const crotchY = hipY + 15 + b.crouch * 12; + const waistL = { x: L.skinned.A0.x, y: hipY - 8 }; + const waistR = { x: R.skinned.B0.x, y: hipY - 8 }; + const pantsHull = [ + `M${waistL.x.toFixed(1)} ${waistL.y.toFixed(1)}`, + `C${L.skinned.A0.x.toFixed(1)} ${(hipY + 18).toFixed(1)} ${L.skinned.A1.x.toFixed(1)} ${(L.knee.y - 18).toFixed(1)} ${L.skinned.A1.x.toFixed(1)} ${L.skinned.A1.y.toFixed(1)}`, + `C${L.skinned.A1.x.toFixed(1)} ${(L.knee.y + 18).toFixed(1)} ${L.skinned.A2.x.toFixed(1)} ${(L.foot.y - 18).toFixed(1)} ${L.skinned.A2.x.toFixed(1)} ${(L.foot.y - 4).toFixed(1)}`, + `L${L.skinned.B2.x.toFixed(1)} ${(L.foot.y - 4).toFixed(1)}`, + `C${L.skinned.B2.x.toFixed(1)} ${(L.foot.y - 18).toFixed(1)} ${L.skinned.B1.x.toFixed(1)} ${(L.knee.y + 18).toFixed(1)} ${L.skinned.B1.x.toFixed(1)} ${L.skinned.B1.y.toFixed(1)}`, + `C${L.skinned.B1.x.toFixed(1)} ${(L.knee.y - 16).toFixed(1)} ${(100 - 3 * w).toFixed(1)} ${(crotchY + 8).toFixed(1)} ${(100 - 2.5 * w).toFixed(1)} ${crotchY.toFixed(1)}`, + `Q100 ${(crotchY - 2).toFixed(1)} ${(100 + 2.5 * w).toFixed(1)} ${crotchY.toFixed(1)}`, + `C${(100 + 3 * w).toFixed(1)} ${(crotchY + 8).toFixed(1)} ${R.skinned.A1.x.toFixed(1)} ${(R.knee.y - 16).toFixed(1)} ${R.skinned.A1.x.toFixed(1)} ${R.skinned.A1.y.toFixed(1)}`, + `C${R.skinned.A1.x.toFixed(1)} ${(R.knee.y + 18).toFixed(1)} ${R.skinned.A2.x.toFixed(1)} ${(R.foot.y - 18).toFixed(1)} ${R.skinned.A2.x.toFixed(1)} ${(R.foot.y - 4).toFixed(1)}`, + `L${R.skinned.B2.x.toFixed(1)} ${(R.foot.y - 4).toFixed(1)}`, + `C${R.skinned.B2.x.toFixed(1)} ${(R.foot.y - 18).toFixed(1)} ${R.skinned.B1.x.toFixed(1)} ${(R.knee.y + 18).toFixed(1)} ${R.skinned.B1.x.toFixed(1)} ${R.skinned.B1.y.toFixed(1)}`, + `C${R.skinned.B1.x.toFixed(1)} ${(R.knee.y - 18).toFixed(1)} ${R.skinned.B0.x.toFixed(1)} ${(hipY + 18).toFixed(1)} ${waistR.x.toFixed(1)} ${waistR.y.toFixed(1)} Z`, + ].join(" "); + return ( + + + {/* Sombra interna entre as coxas (como no Ex-Lateral e no Técnico da referência). */} + + {isTracksuit && ( + <> + + + + )} + + + {shoeFor(L)} + {shoeFor(R)} + + ); + } + + // Caso de túnica/vestido/bermuda/saia: pernas em envelope contínuo sem junta no joelho. + return ( + + {[L, R].map((g) => ( + + + {shorts && ( + + )} + {shoeFor(g)} + + ))} + {look.bottom.style === "skirt" && !longTop && ( + + )} + + ); + }; + + const shY = hipY - 100; + const torsoTop = hipY - 114; + const longSleeve = ["jacket", "hoodie", "uniform", "robe"].includes(top.style); + const sleeve = top.style === "dress" ? look.skin : top.color; + const holdItem = !twoHanded && (b.armR.raise > 20 || b.armR.bend > 40) ? item : undefined; + const isCrossedArms = !holdItem && !twoHanded && b.armL.bend > 108 && b.armR.bend > 108 && b.armL.raise < 55 && b.armR.raise < 55; + const isThinkPose = pose === "think" || (b.armR.raise >= 12 && b.armR.raise < 20 && b.armR.bend >= 159); + + /** + * Braço inteiro em envelope contínuo (ombro → cotovelo → pulso), SEM JUNTA no cotovelo e fundido ao ombro do tronco! + */ + const arm = (s: 1 | -1, l: Limb, holds?: IconId) => { + const x = 100 + s * 46 * w; + const shPt = { x, y: shY + 3 }; + const upperDeg = -s * l.raise; + const isOnFace = (s > 0 ? layerR : layerL) === "face"; + const upperLen = twoHanded ? 50 : isOnFace && l.raise < 20 ? 44 : 54; + const elbow = tip(shPt.x, shPt.y, upperDeg, upperLen); + const foreDeg = upperDeg + s * l.bend; + const bothRaised = Math.abs(b.armL.bend - b.armR.bend) < 15 && Math.abs(b.armL.raise - b.armR.raise) < 15; + const pointing = !holds && !gest && !bothRaised && ( + (l.raise > 55 && l.raise < 130 && Math.abs(l.bend) < 35) || + (l.raise > 18 && l.raise < 65 && l.bend < -105) + ); + const HAND = HAND_K; + // Escorço natural de perspectiva frontal quando o antebraço aponta para a câmera (segurar objeto na frente do peito, joinha), + // e extensão diagonal natural quando o cotovelo fica ao lado e o antebraço sobe até o queixo/boca. + const foreScale = twoHanded + ? 0.54 + : isOnFace && l.raise < 20 + ? (isThinkPose ? 1.08 : 1.18) + : l.raise >= 20 && l.raise < 70 && l.bend > 85 + ? 0.72 + : 1; + const wristL = (longSleeve ? 42.5 : 41) * foreScale; + const cuffL = wristL - 1.2; + const wrist = tip(elbow.x, elbow.y, foreDeg, wristL); + const cuffEnd = tip(elbow.x, elbow.y, foreDeg, cuffL); + const gripDeg = foreDeg - s * 27; + const gp = handPlacement("grip", wrist.x, wrist.y, gripDeg, s, HAND); + const gi = holds ? (GRIP[holds] ?? { x: 50, y: 60, rot: 0 }) : null; + + const rShoulder = 17.5 * Math.max(0.9, w * 0.95); + const rElbow = longSleeve ? 13.8 : 12.2; + const rWrist = longSleeve ? 12.2 : 8.8; + const endPt = longSleeve ? tip(elbow.x, elbow.y, foreDeg, Math.max(8, cuffL - 1.5)) : wrist; + const skinned = buildSkinnedLimb(shPt, elbow, endPt, rShoulder, rElbow, rWrist, s); + + const handDeg = holds && !twoHanded ? gripDeg : s > 0 && !holds && !pointing && gest === "thumbs_up" ? foreDeg + s * 9 : foreDeg; + const hand = { + x: wrist.x, y: wrist.y, deg: handDeg, s, skin: look.skin, light: side, + scale: HAND, uid: `${uid}${s}`, onFace: isOnFace, isThink: isThinkPose, + }; + + const shortSleeveD = "M-18.5 0 C-19.2 9 -18.2 18 -16.8 25.5 Q0 27.2 16.8 25.5 C18.2 18 19.2 9 18.5 0 A18.5 18.5 0 0 0 -18.5 0 Z"; + const shortSleeveLitD = `M-20 -18 L-20 26 Q0 28 20 26 L${s > 0 ? 18.5 : 26} -18 Z`; + + if (isCrossedArms) { + const elCr = tip(shPt.x, shPt.y, upperDeg, 50); + const uaSkinned = buildSkinnedLimb(shPt, tip(shPt.x, shPt.y, upperDeg, 25), elCr, rShoulder, (rShoulder + rElbow) * 0.5, rElbow, s); + return ( + + + {isTracksuit && ( + + )} + {!longSleeve && top.style !== "dress" && ( + <> + + {(() => { const e = tip(shPt.x, shY, upperDeg, 25.6); return ; })()} + + )} + + ); + } + + const axilaX = shPt.x - s * (rShoulder - 2); + const axilaY = shPt.y + 22; + const axilaEnd = tip(axilaX, axilaY, upperDeg, 26); + const hasRightTowel = s > 0 && look.accessories?.includes("towel"); + + return ( + + {/* Envelope único contínuo do braço inteiro (ombro → cotovelo → pulso), ZERO junta no cotovelo ou no ombro! */} + + {/* Listra contínua do agasalho do ombro até o punho (como em referencia/03-corpo-inteiro-joinha.png). */} + {isTracksuit && ( + + )} + {/* Manga curta integrada sem costura no ombro (como em referencia/02-meio-corpo-apontando.png). */} + {!longSleeve && top.style !== "dress" && (() => { + const slLen = l.bend < -85 ? 20.5 : 25.5; + const slW = l.bend < -85 ? 29.8 : 33.2; + const slHalf = slW * 0.5; + const slD = `M-18.2 0 C-18.8 ${slLen * 0.36} ${-(slHalf + 0.8)} ${slLen * 0.72} ${-slHalf} ${slLen} Q0 ${slLen + 1.6} ${slHalf} ${slLen} C${slHalf + 0.8} ${slLen * 0.72} 18.8 ${slLen * 0.36} 18.2 0 A18.2 18.2 0 0 0 -18.2 0 Z`; + const slLitD = `M-20 -18 L-20 ${slLen + 1} Q0 ${slLen + 3} 20 ${slLen + 1} L${s > 0 ? 18.2 : 26} -18 Z`; + const e = tip(shPt.x, shY, upperDeg, slLen + 0.1); + return ( + <> + + + + ); + })()} + {/* Vinco da axila só quando o braço está caído ao lado do corpo, e dobra interna do cotovelo em manga longa. */} + {longSleeve && l.raise < 16 && Math.abs(l.bend) < 30 && !hasRightTowel && ( + + )} + {longSleeve && skinned.elbowFold && ( + + + + )} + {longSleeve && } + {s < 0 && look.accessories?.includes("watch") && (() => { + const c = tip(elbow.x, elbow.y, foreDeg, wristL + 1); + return ; + })()} + {/* Objeto de 1 mão: parte de trás da palma → objeto (cabo dentro da mão) → dedos e polegar na frente. */} + {holds && !twoHanded && } + {holds && gi && gp.hold && ( + + + + )} + {twoHanded && } + {!twoHanded && ( + 0 && !holds && !pointing ? gest : undefined} + layer={holds ? "front" : "all"} + /> + )} + {longSleeve && ( + + )} + + ); + }; + + /** Antebraços cruzados no peito (como na imagem 5 de referência do Ex-Lateral): cruzamento contínuo de cotovelo a cotovelo. */ + const crossedForearms = () => { + if (!isCrossedArms) return null; + const xL = 100 - 46 * w, xR = 100 + 46 * w; + const elL = tip(xL, shY + 3, b.armL.raise, 50); + const elR = tip(xR, shY + 3, -b.armR.raise, 50); + const yMid = (elL.y + elR.y) * 0.5 - 3; + const armFill = longSleeve ? sleeve : look.skin; + const cuffColor = isTracksuit || top.style === "uniform" ? (top.accent ?? shade(sleeve, 0.8)) : undefined; + const lowerPath = `M${elL.x - 13} ${elL.y - 10} C${elL.x + 20} ${yMid - 16} ${100 + 18 * w} ${yMid - 12} ${elR.x - 2} ${elR.y - 2}` + + ` C${elR.x + 4} ${elR.y + 12} ${100 + 18 * w} ${yMid + 16} ${elL.x + 10} ${elL.y + 15}` + + ` C${elL.x - 8} ${elL.y + 13} ${elL.x - 16} ${elL.y} ${elL.x - 13} ${elL.y - 10} Z`; + const upperPath = `M${elR.x + 13} ${elR.y - 8} C${elR.x - 18} ${yMid - 18} ${100 - 14 * w} ${yMid - 18} ${elL.x + 18} ${elL.y - 14}` + + ` C${elL.x + 10} ${elL.y} ${100 - 12 * w} ${yMid + 12} ${elR.x - 6} ${elR.y + 15}` + + ` C${elR.x + 10} ${elR.y + 13} ${elR.x + 16} ${elR.y + 2} ${elR.x + 13} ${elR.y - 8} Z`; + const upperLitPath = `M${elR.x + 24} ${elR.y - 16} C${elR.x - 18} ${yMid - 18} ${100 - 14 * w} ${yMid - 18} ${elL.x + 18} ${elL.y - 14}` + + ` C${elL.x + 10} ${elL.y} ${100 - 12 * w} ${yMid + 12} ${elR.x - 6} ${elR.y + 15}` + + ` C${elR.x + 12} ${elR.y + 13} ${elR.x + 24} ${elR.y + 2} ${elR.x + 24} ${elR.y - 16} Z`; + const handX = elL.x + 25; + const handY = yMid - 10; + return ( + + + + + + {longSleeve && cuffColor && ( + + )} + + + ); + }; + + const layerL = armLayer(b, -1, { w, holds: twoHanded }); + const layerR = armLayer(b, 1, { w, holds: !!holdItem || twoHanded }); + + const twoHand = () => { + if (!twoHanded || !item) return null; + const grab = (s: 1 | -1) => { + const l = s > 0 ? b.armR : b.armL; + const upperDeg = -s * l.raise; + const elbow = tip(100 + s * 46 * w, shY + 3, upperDeg, 50); + const foreDeg = upperDeg + s * l.bend; + const wrist = tip(elbow.x, elbow.y, foreDeg, (longSleeve ? 42.5 : 41) * 0.54); + return { s, wrist, foreDeg, hold: handPlacement("pinch_edge", wrist.x, wrist.y, foreDeg, s, HAND_K).hold! }; + }; + const [L, R] = [grab(-1), grab(1)]; + const span = item === "tablet" ? 0.68 : 0.72; + const size = Math.abs(R.hold.x - L.hold.x) / span; + const cx = (L.hold.x + R.hold.x) / 2; + const cy = (L.hold.y + R.hold.y) / 2; + return ( + <> + + + {[L, R].map((g) => ( + + ))} + + ); + }; + + // Cada braço sai INTEIRO na sua camada (sem quebrar no cotovelo!). + const arms = (layer: string) => ( + <> + {layerL === layer && arm(-1, b.armL)} + {layerR === layer && arm(1, b.armR, layer === "face" ? undefined : holdItem)} + {layer === "front" && crossedForearms()} + + ); + + const x0 = 100 - 54 * w; + const x1 = 100 + 54 * w; + const torsoBottom = top.style === "dress" ? hipY + 58 : top.style === "robe" ? hipY + 108 - b.crouch * 40 : hipY + 6; + const flare = top.style === "dress" ? 16 : top.style === "robe" ? 20 : 0; + const accent = top.accent ?? shade(top.color, 1.3); + const bulge = look.belly ? 18 : look.build === "heavy" ? 10 : 3; + // Tronco em "pera" com ombros largos e arredondados integrados aos braços. + const torsoPath = `M${100 - 30 * w} ${torsoTop - 4} C${x0 - 8} ${torsoTop - 2} ${x0 - 13} ${torsoTop + 28} ${x0 - 5} ${torsoTop + 60}` + + ` C${x0 - bulge} ${torsoTop + 88} ${x0 - flare - bulge * 0.65} ${torsoBottom - 10} ${x0 - flare + 2} ${torsoBottom}` + + ` L${x1 + flare - 2} ${torsoBottom} C${x1 + flare + bulge * 0.65} ${torsoBottom - 10} ${x1 + bulge} ${torsoTop + 88} ${x1 + 5} ${torsoTop + 60}` + + ` C${x1 + 13} ${torsoTop + 28} ${x1 + 8} ${torsoTop - 2} ${100 + 30 * w} ${torsoTop - 4} Z`; + const fold = shade(top.color, 0.72); + const neckH = look.belly ? 13 : 16; + const nw = 26 * (HEAD_SCALE / 1.2) * (look.build === "heavy" ? 1.12 : look.build === "slim" ? 0.92 : 1); + const headTransform = `translate(0 ${torsoTop - neckH + 6 + breathe * 0.4}) rotate(${b.headTilt} 100 0) translate(100 0) scale(${HEAD_SCALE}) translate(-100 -156)`; + + return ( + + + + + + + {look.hair.style === "long" && ( + + + + + + )} + {renderLowerBody()} + + + {top.style === "hoodie" && } + {/* Pescoço com sombra do queixo e sombra lateral. */} + + + + + + + {/* Em personagem de barriga saliente com agasalho (como o Técnico em 03-corpo-inteiro-joinha.png), a barra arqueia mostrando a barriga arredondada. */} + {!longTop && ( + look.belly && top.style === "jacket" ? ( + + + + + + + ) : ( + + + + ) + )} + + {/* Dobras lenticulares afiladas nas pontas (idênticas às dobras de roupa de 03-corpo-inteiro-joinha.png). */} + + + + + + + {top.style === "shirt" && ( + + + {[0, 1].map((i) => )} + + + + {top.accent && } + + )} + {top.style === "uniform" && ( + + + + {[0, 1, 2, 3].map((i) => )} + + + + )} + {(top.style === "jacket" || top.style === "hoodie") && ( + + + {top.style === "jacket" && } + + {top.style === "jacket" && ( + isTracksuit ? ( + <> + + + + + + + + ) : ( + <> + + + + + + ) + )} + {top.style === "hoodie" && ( + <> + + + + )} + + )} + {top.style === "dress" && ( + + + {[0, 1, 2, 3, 4, 5].map((i) => )} + + + )} + {top.style === "robe" && ( + + + + + + + + + + + + + + + )} + + + {/* Camadas com braços contínuos (sem quebrar no cotovelo!). */} + + + {arms("side")} + + + {st.emote && ( + + + {st.emote.text} + + )} + + {arms("front")} + {twoHand()} + {arms("face")} + + + + ); +} + +/** + * Vista "insert": close das MÃOS fazendo algo (segurando o objeto, escrevendo), antebraços entrando por baixo + * com a manga da roupa do personagem. Ocupa a área inteira de quem desenha (viewBox 1080×1080). + */ +export function HandsInsert({ look = DEFAULT_LOOK, item, t = 0, shadeSide = 1 }: { look?: CharacterLook; item?: IconId; t?: number; shadeSide?: 1 | -1 }) { + const uid = useId().replace(/:/g, ""); + const grainId = `gri${uid}`; + const sway = Math.sin(t * 1.6) * 6; + const long = ["jacket", "hoodie", "uniform", "robe"].includes(look.top.style); + const cloth = look.top.style === "dress" ? look.skin : look.top.color; + const isTracksuit = look.top.style === "jacket" && !!look.top.accent && look.bottom.color === look.top.color; + const cuff = isTracksuit || look.top.style === "uniform" ? (look.top.accent ?? shade(cloth, 0.8)) : shade(cloth, 0.84); + const K = 2.7; + const S = 5; + const cy = 560 + sway * 0.5; + const arms = ([-1, 1] as const).map((s) => { + const deg = 180 - s * 30; + const edge = { x: 540 + s * 250 + (s > 0 ? sway : 0), y: 660 + (s > 0 ? -sway : 0) }; + const wrist = item ? wristForHold("pinch_low", edge.x, edge.y, deg, s, K) : { x: edge.x + s * 40, y: edge.y + 120 }; + const end = tip(wrist.x, wrist.y, deg, -3 * S); + const start = tip(end.x, end.y, deg, -560); + const hand = { x: wrist.x, y: wrist.y, deg, s, skin: look.skin, light: shadeSide, scale: K, uid: `${uid}i${s}` }; + return { s, deg, wrist, end, start, hand }; + }); + return ( + + + + + {arms.map(({ s, deg, end, start, hand }) => ( + + {long ? ( + <> + + + + + ) : ( + + )} + {item && } + + ))} + {item && } + {arms.map(({ s, hand }) => )} + {long && arms.map(({ s, deg, end }) => )} + + ); +} diff --git a/.studies/cartoon-personagem-handoff/workspace/src/character.ts b/.studies/cartoon-personagem-handoff/workspace/src/character.ts new file mode 100644 index 0000000..1ab5e1b --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/src/character.ts @@ -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//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; + 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 = (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 | 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); diff --git a/.studies/cartoon-personagem-handoff/workspace/src/colors.ts b/.studies/cartoon-personagem-handoff/workspace/src/colors.ts new file mode 100644 index 0000000..ad953fc --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/src/colors.ts @@ -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 = { + 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 = { info: "#ffcf3f", danger: "#ff4d4d", ok: "#3ddc84" }; +export const TONE_FG: Record = { info: "#141414", danger: "#ffffff", ok: "#0c2a18" }; + +export const FONT_CAPTION = "CartoonAnton"; +export const FONT_LABEL = "CartoonBebas"; + diff --git a/.studies/cartoon-personagem-handoff/workspace/src/hands.tsx b/.studies/cartoon-personagem-handoff/workspace/src/hands.tsx new file mode 100644 index 0000000..e983b24 --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/src/hands.tsx @@ -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 = { + // 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> = { + 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) => ( + + ); + + const bodyLayer = def.bodyBehind ? "back" : def.hold ? "front" : "all"; + const showBody = layer === "all" || layer === bodyLayer || (bodyLayer === "all" && layer === "front"); + const showOver = layer !== "back"; + + return ( + + + + + + + + {def.over && } + + {showBody && ( + <> + + + + + {def.lines && } + {(def.nails ?? []).map(nail)} + + )} + {showOver && def.over && ( + <> + + + {def.over.shadow && } + + {def.over.lines && } + {(def.overNails ?? []).map(nail)} + + )} + + ); +} diff --git a/.studies/cartoon-personagem-handoff/workspace/src/icons.tsx b/.studies/cartoon-personagem-handoff/workspace/src/icons.tsx new file mode 100644 index 0000000..eff42b4 --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/src/icons.tsx @@ -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 = { + house: (<> + + + + + + ), + generator: (<> + + + + {[0, 1, 2, 3, 4].map((i) => )} + + + + ), + fuel: (<> + + + + + + ), + battery: (<> + + + + ), + phone: (<> + + + + ), + door: (<> + + + + + ), + eye: (<> + + + ), + bulb: (<> + + + ), + solar: (<> + + + + ), + warning: (<> + + + ), + money: (<> + + $ + ), + clock: (<> + + + ), + // Itens de mão e objetos de história antiga (também servem como objeto solto na cena). + olive: (<> + + + {[[38, 62, -38], [48, 52, 28], [58, 42, -38], [68, 32, 28], [78, 22, -38], [84, 15, -12]].map(([x, y, r], i) => ( + + + + + + ))} + + + ), + hammer: (<> + + + + + + + + + + + + + ), + tablet: (<> + + + {Array.from({ length: 7 }, (_, i) => )} + + ), + book: (<> + + + + + + {[0, 1, 2, 3].map((i) => )} + ), + ruler: (<> + + + + + {Array.from({ length: 11 }, (_, i) => )} + + ), +}; + +export function Icon({ id }: { id: IconId }) { + return {DRAW[id]}; +} diff --git a/.studies/cartoon-personagem-handoff/workspace/src/limbs.ts b/.studies/cartoon-personagem-handoff/workspace/src/limbs.ts new file mode 100644 index 0000000..81cfc7c --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/src/limbs.ts @@ -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"; +} diff --git a/.studies/cartoon-personagem-handoff/workspace/src/lipsync.ts b/.studies/cartoon-personagem-handoff/workspace/src/lipsync.ts new file mode 100644 index 0000000..29151b3 --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/src/lipsync.ts @@ -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 = { + 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 }, + }; +} diff --git a/.studies/cartoon-personagem-handoff/workspace/src/motion.ts b/.studies/cartoon-personagem-handoff/workspace/src/motion.ts new file mode 100644 index 0000000..8722d5f --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/src/motion.ts @@ -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 = { + 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, 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; +} diff --git a/.studies/cartoon-personagem-handoff/workspace/src/rig.ts b/.studies/cartoon-personagem-handoff/workspace/src/rig.ts new file mode 100644 index 0000000..4690bda --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/src/rig.ts @@ -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> & { browL?: Partial; browR?: Partial; brows?: Partial; eyes?: number }; +type BodyPatch = Partial> & { armL?: Partial; armR?: Partial; legL?: Partial; legR?: Partial; arms?: Partial; legs?: Partial }; + +/** 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; + +/** 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; + +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)[name ?? "neutral"] ?? {}), patch); +export const bodyOf = (name: string | undefined, patch?: BodyPatch): BodyParams => + withBody(withBody(NEUTRAL_BODY, (POSE_PRESETS as Record)[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 = (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 }; diff --git a/.studies/cartoon-personagem-handoff/workspace/src/spec.ts b/.studies/cartoon-personagem-handoff/workspace/src/spec.ts new file mode 100644 index 0000000..85e287b --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/src/spec.ts @@ -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]; diff --git a/.studies/cartoon-personagem-handoff/workspace/tsconfig.json b/.studies/cartoon-personagem-handoff/workspace/tsconfig.json new file mode 100644 index 0000000..cf4e95a --- /dev/null +++ b/.studies/cartoon-personagem-handoff/workspace/tsconfig.json @@ -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"] +} diff --git a/AGENTS.md b/AGENTS.md index a576f27..d45845e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -23,3 +23,5 @@ este resumo basta, não é preciso abrir o `CLAUDE.md` inteiro. `frame_check.py` e abra só a imagem que ele indicar (uma por render). Reaproveite as cenas da biblioteca. - **Windows/PowerShell:** rode o pnpm como `pnpm.cmd` (o `pnpm.ps1` é bloqueado pela política de execução) e leia texto com `Get-Content -Raw -Encoding UTF8`. Economize: leia só o que a tarefa pede. + +