Cartoon: estudo de handoff do personagem (.studies) e AGENTS.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
215faa331c
commit
b923132a69
@@ -0,0 +1,392 @@
|
||||
// Biblioteca de MÃOS desenhadas no estilo de ilustração cartoon de referência (quadro canônico 120×120):
|
||||
// - Proporções cheias, compactas e arredondadas (como em referencia/recortes/joinha.png, maos-segurando.png,
|
||||
// mao-prancheta.png e apontando.png): sem dedos compridos em salsicha;
|
||||
// - Base do pulso cilíndrica arredondada centrada em `wrist` (emenda perfeita com o antebraço ou punho da manga);
|
||||
// - Sulcos quentes e curtos entre os dedos dobrados, e sombreado cel limpo em 2 tons acompanhando o volume;
|
||||
// - Camadas `back` (atrás do objeto) e `front` (dedos/polegar na frente do objeto) para que qualquer objeto seguro
|
||||
// fique claramente DENTRO da mão.
|
||||
import React from "react";
|
||||
import type { IconId } from "./spec";
|
||||
|
||||
export const HAND_SHAPES = [
|
||||
"relaxed",
|
||||
"open",
|
||||
"point",
|
||||
"thumbs_up",
|
||||
"grip",
|
||||
"pinch_edge",
|
||||
"pinch_low",
|
||||
"fist",
|
||||
"on_face",
|
||||
"think",
|
||||
"crossed",
|
||||
] as const;
|
||||
export type HandShape = (typeof HAND_SHAPES)[number];
|
||||
|
||||
type ShapeDef = {
|
||||
/** Silhueta principal (camada de trás quando `bodyBehind` é true). */
|
||||
body: string;
|
||||
/** Sombra cel em crescente macio (recortada pela silhueta `body`). */
|
||||
shadow: string;
|
||||
/** Linhas internas quentes: separação dos dedos, nós e dobras da palma. */
|
||||
lines: string;
|
||||
/** Peça por cima (polegar ou dedos que abraçam o objeto pela frente), com sombra e linhas próprias. */
|
||||
over?: { body: string; shadow?: string; lines?: string };
|
||||
/** Unhas discretas (só quando a vista pede): [cx, cy, rx, ry, giro]. */
|
||||
nails?: [number, number, number, number, number][];
|
||||
overNails?: [number, number, number, number, number][];
|
||||
/** Pulso no quadro (centro da junta redonda onde termina o antebraço). */
|
||||
wrist: [number, number];
|
||||
/** Ângulo do antebraço para o qual a forma foi desenhada (0 = descendo; formas alinhadas = 0). */
|
||||
wristDeg: number;
|
||||
upright: boolean;
|
||||
/** Com objeto: `body` fica ATRÁS do objeto e `over` fica NA FRENTE dele (objeto dentro da mão). */
|
||||
bodyBehind?: boolean;
|
||||
/** Ponto onde passa o cabo (`grip`) ou encosta a borda (`pinch_edge`/`pinch_low`). */
|
||||
hold?: [number, number];
|
||||
};
|
||||
|
||||
// Base redonda no pulso (centro (60, 0), raio ~13.5): garante emenda contínua em qualquer rotação.
|
||||
const WRIST_CAP = "M46.5 0 A13.5 11 0 0 1 73.5 0";
|
||||
|
||||
const SHAPES: Record<HandShape, ShapeDef> = {
|
||||
// Caída ao lado do corpo: formas arredondadas e carnudas, polegar voltado para dentro, dedos juntos curvando suavemente.
|
||||
relaxed: {
|
||||
body: `${WRIST_CAP}`
|
||||
+ " C76 8 82.5 18 84 31 C85.2 43 84.4 55 82 65 C80.8 70.5 77.8 73.5 74.5 73 C72.2 72.6 70.8 70.5 70.4 67.5"
|
||||
+ " C69.8 74 68 79 64.2 79.6 C60.8 80.2 58.6 77.5 58.2 73"
|
||||
+ " C57.4 78.5 55.2 82 51.2 82 C47.5 82 45.4 78.5 45.2 73.5"
|
||||
+ " C44.2 76.5 42 78 39.2 77.4 C35.8 76.6 34.2 72.5 34.8 66 C35.5 57 37.2 48 39 41"
|
||||
+ " C37 46.5 35 51.5 32.2 54 C29 56.8 25 55.5 24.2 51 C23.2 45.8 25.5 37.5 29.5 29.5"
|
||||
+ " C34 21 41 13.5 45 5.5 C46 3.5 46.5 1.8 46.5 0 Z",
|
||||
shadow: "M66 -10 C69 5 75.5 16 78 30 C79.8 43 78.8 56 76 67 C72.5 75 62 80 44 78 L44 90 L92 90 L92 -10 Z",
|
||||
lines: "M39 41 C40.8 35 41.5 28.5 40.5 22.5 M45.2 73.5 C45.8 65.5 46.8 58 48.2 52 M58.2 73 C58.8 65 59.5 57.5 60.2 51.5 M70.4 67.5 C71 61 71.6 55 72 50",
|
||||
wrist: [60, 0], wristDeg: 0, upright: false,
|
||||
},
|
||||
|
||||
// Mão aberta (acenando / comemorando): palma carnuda, dedos abrindo em leque macio que afinam na ponta, polegar na base.
|
||||
open: {
|
||||
body: `${WRIST_CAP}`
|
||||
+ " C75.5 7 81.5 16 83.8 28 C85 35 86 43 88 51.5 C89.2 56.8 88 61.2 84.8 62.2 C81.5 63.2 78.6 60.4 76.6 55"
|
||||
+ " C74.8 50.2 73.2 45.2 71.8 41.2 C73 50 74.2 60.5 74.6 68.8 C74.9 74.6 72.2 78.2 68.4 78.2 C64.8 78.2 62.6 74.8 62.2 69"
|
||||
+ " C61.8 60.5 61.2 51.5 60.8 44 C60.5 54 60.2 65.5 59.6 74.2 C59.2 80.4 56.2 83.6 52.2 83.4 C48.4 83.2 46.2 79.6 46.2 73.5"
|
||||
+ " C46.2 64.5 46.8 54 47.5 44.5 C46 52.5 44.5 61.5 43.5 68.5 C42.6 74 39.6 76.8 36 76.2 C32.4 75.5 30.8 72 31.5 66.2"
|
||||
+ " C32.8 56 35.2 44.5 37.5 35 C33.5 38.8 29.2 42.8 25 45.5 C20.8 48.2 16.4 47 15.2 43 C14 39 16.5 34 21.2 30.2"
|
||||
+ " C27.2 25.4 34.8 20.8 40.2 14.5 C43.8 10.2 46 5 46.5 0 Z",
|
||||
shadow: "M67 -10 C70 5 77 16 80 30 C82 40 83.5 50 86 60 L96 60 L96 -10 Z"
|
||||
+ " M46 28 C53 33.5 63 35.5 72 32 C68 38.5 57 40.5 47 35.5 Z",
|
||||
lines: "M43 37 C53 34 64.5 34.5 73.5 38.5 M38.5 34 C42.8 28 46 21 47 14",
|
||||
wrist: [60, 0], wristDeg: 0, upright: false,
|
||||
},
|
||||
|
||||
// Apontando (como em referencia/recortes/apontando.png):
|
||||
// Polegar redondo na lateral interna (esquerda), indicador comprido subindo firme ao lado dele,
|
||||
// e os 3 outros dedos (médio, anelar, mínimo) dobrados em escada arredondada macia na direita.
|
||||
point: {
|
||||
body: `${WRIST_CAP}`
|
||||
+ " C76 8 82.5 18 84.5 30 C86 39 86.5 48 84 55.5 C82 61 77.2 63.5 72.5 61.5"
|
||||
+ " C71 66.8 66.2 69.8 60.8 68.6 C58 68 55.8 66 54.6 63.5"
|
||||
+ " C53 67.5 51 69.5 48.8 69.5 C48.8 79.5 48.8 90.5 48.4 98.5"
|
||||
+ " C48 105.5 44.2 109.2 39.4 109 C34.6 108.8 31.4 104.6 31.8 97.5"
|
||||
+ " C32.4 85 33.8 69.5 35 55.5 C29 51.5 25 44.5 25.8 36.2 C26.6 28 32.2 21 38.8 15.2"
|
||||
+ " C43.2 11 45.8 5.2 46.5 0 Z",
|
||||
shadow: "M65 -10 C68.5 5 76 15 79 29 C81 39 80.5 49 78 56 C73 60.5 63 64.5 50 65.5 L50 75 L93 75 L93 -10 Z"
|
||||
+ " M42.8 58 C44.2 72 44.2 88 43.2 109 L49.5 109 L49.5 58 Z",
|
||||
lines: "M50.5 68.5 C50.8 60.5 51.6 53 53.5 47.5 M61.8 68 C62.4 60 63.2 53 64.8 47.5 M72.5 61.5 C73.2 55 74 49 75.2 44.5"
|
||||
+ " M49 48.5 C57.5 46 67.5 44.5 78 43",
|
||||
over: {
|
||||
body: "M25.8 36.2 C26.6 27.5 33.8 21 41.2 24.2 C47 26.8 52.2 34.5 55.5 42.2 C58.5 49 57.5 56.5 52.2 58.8 C47 61.2 39.2 57.8 33.2 51.5 C27.8 45.8 25.2 41.2 25.8 36.2 Z",
|
||||
shadow: "M28.5 43.5 C33.8 50.8 42.2 56.5 50.5 58 L47.5 62 L26.5 48.5 Z",
|
||||
lines: "M35 27.5 C41.2 32.5 48 39.5 52.5 46.5",
|
||||
},
|
||||
wrist: [60, 0], wristDeg: 0, upright: false,
|
||||
},
|
||||
|
||||
// Joinha (proporção compacta e redonda idêntica a referencia/recortes/joinha.png):
|
||||
// Punho cheio e arredondado (largura ~52, altura ~56 na palma), 4 dedos gordinhos empilhados com sulcos curtos,
|
||||
// e polegar forte subindo na vertical do topo da palma.
|
||||
thumbs_up: {
|
||||
body: "M74 88 A13.5 13.5 0 0 0 90 66"
|
||||
+ " C87 57 82 49 75 43"
|
||||
+ " C75.5 32 75 19 73 10.5 C71.2 3.5 66.5 0 60.5 0.5 C54.8 1 51.2 6 51 14.5"
|
||||
+ " C50.8 23.5 51.2 32.5 50 39 C41 38.5 33 40 29.5 45.5 C26.2 50.6 27.8 57 33 58.8"
|
||||
+ " C27.2 61.2 26.8 68.8 32.2 71.6 C28.2 74.4 28.8 81.8 34 84"
|
||||
+ " C31.8 87.5 34.2 93.8 41 95 C51 96.8 63 96 70.5 91.5 C72.5 90.2 73.5 89 74 88 Z",
|
||||
shadow: "M67 2 C70.8 10 72 25 72 41 C78.5 46 84 55 87 65 L92 74 L74 92 L34 97 L30 89"
|
||||
+ " C44 93.5 59 93 68.5 88.5 C75.5 85 78.5 76 77 65 C75.5 54 72 46.5 66 42.5 L66 2 Z"
|
||||
+ " M31.5 57.2 C40.5 59.8 50.5 60 59 58.5 L59 61.2 C49.5 62.6 40.5 62.2 31 59.8 Z"
|
||||
+ " M31 70 C40 72.6 50.5 72.8 59 71.2 L59 74 C49.5 75.4 40 75 30.5 72.6 Z"
|
||||
+ " M33 82.4 C41.5 84.8 50 85 57.5 83.8 L57.5 86.5 C49 87.6 41.5 87.2 32.5 85 Z",
|
||||
lines: "M33 58.8 C41 60.8 50 61 58 59.5 M32.2 71.6 C40.5 73.6 50 73.8 58 72.2 M34 84 C41.8 85.8 49.5 86 56.5 84.8"
|
||||
+ " M51 36.5 C56.5 39.8 64.5 40.2 71.5 37.5",
|
||||
wrist: [82, 76], wristDeg: 135, upright: true,
|
||||
},
|
||||
|
||||
// Punho segurando um cabo ou prancheta (proporção compacta e redonda idêntica a referencia/recortes/mao-prancheta.png):
|
||||
// - `body` (atrás do cabo): base da palma;
|
||||
// - `over` (na frente do cabo): mão redonda e carnuda com 4 dedos roliços empilhados e 3 sulcos curtos.
|
||||
grip: {
|
||||
body: "M88 77 A13.5 13.5 0 0 0 88 50"
|
||||
+ " C81 44 71 40 59 40 C47 40 37 43 33.5 51 C30 59 31 73 36 83"
|
||||
+ " C41 91 54 93 67 90 C77 87.5 84 83 88 77 Z",
|
||||
shadow: "M76 44 C83 52 86 64 83 75 C80 84 72 90 60 92 L92 92 L92 44 Z",
|
||||
lines: "",
|
||||
over: {
|
||||
body: "M86 48 C79 38 66 33.5 53 34 C41 34.5 33 38 30.5 44.5 C28.5 49.5 30.2 53.5 34.5 55.2"
|
||||
+ " C28 57 26 63 29.5 68 C31 70 33 71 35.5 71.6"
|
||||
+ " C29.5 73.8 29 80.5 34 83.5 C32 86.8 34.2 92.5 41 93.8"
|
||||
+ " C51.5 95.8 65 95 75 90.5 C83 87 88 81 89.5 74 C91 66 90 55 86 48 Z",
|
||||
shadow: "M76 41 C84 49 87.5 61 85 73 C82 83 73.5 90 61.5 92.5 C49.5 95 39 94 32 90.5 L32 97 L92 97 L92 41 Z"
|
||||
+ " M33.5 53.8 C42 56.2 52.5 56.2 61 54.5 L61 57.2 C52 59 41.5 58.8 32.5 56.2 Z"
|
||||
+ " M33.8 70.2 C42 72.5 52 72.8 60 71.2 L60 74 C51 75.5 41 75 32.8 72.8 Z"
|
||||
+ " M33.5 82.2 C41.5 84.5 51 84.8 58.5 83.5 L58.5 86.2 C50 87.5 40.5 87.2 32.5 84.8 Z",
|
||||
lines: "M34.5 55.2 C43 57.2 53 57 60.5 55.2 M35.5 71.6 C43.5 73.6 52.5 73.8 59.5 72.2 M34 83.5 C42 85.5 50.5 85.8 57.5 84.5",
|
||||
},
|
||||
wrist: [86, 64], wristDeg: 45, upright: true, bodyBehind: true, hold: [44, 65],
|
||||
},
|
||||
|
||||
// Segurando a borda lateral de um objeto largo (proporção redonda e compacta idêntica a referencia/recortes/maos-segurando.png):
|
||||
// - `body` (atrás): palma arredondada que apoia por trás do objeto;
|
||||
// - `over` (na frente da borda): mão redonda e gordinha (`largura ~50, altura ~58`) com 4 dedos roliços e 3 sulcos curtos!
|
||||
pinch_edge: {
|
||||
body: "M88 73 A13.5 13.5 0 0 0 88 46"
|
||||
+ " C81 39 70 35 59 36 C47 37 40 44 40 58 C40 72 45 83 54 88"
|
||||
+ " C63 93 75 91 83 83 C86 79.5 87.5 76 88 73 Z",
|
||||
shadow: "M76 40 C83 48 86 60 83.5 72 C81 82 73 88 61 90 L92 92 L92 40 Z",
|
||||
lines: "",
|
||||
over: {
|
||||
body: "M85 44 C77 34 63 30 49 31.5 C37.5 32.8 30.5 38.5 32.5 45.8"
|
||||
+ " C26.8 48 25 55.2 30 59.5 C25 62.2 24.8 70 30.5 73.5"
|
||||
+ " C27.2 77.2 29.2 84.5 36 87 C46 90.5 60 91 72 87"
|
||||
+ " C80.5 84 86.5 78 88.2 70.5 C90 62 89 51 85 44 Z",
|
||||
shadow: "M75 38 C83 47 86.5 59.5 84 71.5 C81.5 81.5 73 87.5 60.5 89 C47.5 90.5 37 88 31.5 83.5 L31.5 93 L92 93 L92 38 Z"
|
||||
+ " M32 44.5 C40.5 47.2 50.5 47.5 58.5 46 L58.5 48.8 C49.5 50.2 39.5 50 31 47.2 Z"
|
||||
+ " M29.5 58.2 C38 61 48 61.2 56 59.8 L56 62.5 C47 64 37 63.8 28.5 61 Z"
|
||||
+ " M30 72.2 C38.5 74.8 48 75 55.5 73.6 L55.5 76.4 C46.5 77.8 37.5 77.5 29 75 Z",
|
||||
lines: "M32.5 45.8 C41 48 50.5 48.2 58 46.8 M30 59.5 C38.5 61.8 48 62 55.5 60.5 M30.5 73.5 C38.8 75.8 47.8 76 54.8 74.6",
|
||||
},
|
||||
wrist: [85, 60], wristDeg: 62, upright: true, bodyBehind: true, hold: [44, 60],
|
||||
},
|
||||
|
||||
// Pegada de borda com o antebraço vindo de baixo (HandsInsert): dedos atrás da página e polegar comprido + palma na frente.
|
||||
pinch_low: {
|
||||
body: "M84 106 A14 14 0 0 0 104 86"
|
||||
+ " C99 76 95 64 92 52 C89 39 81 28 69 26 C59 24.5 52 30 51 40"
|
||||
+ " C49.5 55 50 72 54 84 C58 93 69 98 84 106 Z",
|
||||
shadow: "M78 28 C88 39 92 55 95 70 C97 80 100 86 105 92 L112 104 L76 108 L54 90 C66 93 78 90 83 80 C88 68 85 45 78 28 Z",
|
||||
lines: "M52 44 C59 44.5 66.5 46.5 72.5 50 M51.5 58 C58.5 58.8 65.5 60.8 71.5 64 M52.5 72 C58.5 72.8 64.5 74.8 69.5 78",
|
||||
over: {
|
||||
body: "M84 106 A14 14 0 0 0 104 86"
|
||||
+ " C98 76 91 64 82 54 C72 44 56 34 45 30.5 C36.5 27.8 30.5 32.5 33 40"
|
||||
+ " C35.5 47.5 45 54.5 55 61 C61 65 65 73 68 84 C71 94 77 101 84 106 Z",
|
||||
shadow: "M34 41 C42 49 52 56 60 62 C65 68 68 78 72 90 L98 106 L82 110 L62 92 L32 46 Z",
|
||||
lines: "M56 61 C62 64 67 69 70 76",
|
||||
},
|
||||
wrist: [94, 96], wristDeg: 135, upright: true, bodyBehind: true, hold: [56, 52],
|
||||
},
|
||||
|
||||
// Punho fechado: 4 dedos dobrados em arco macio, polegar travando por cima do indicador e do médio.
|
||||
fist: {
|
||||
body: `${WRIST_CAP}`
|
||||
+ " C75.5 8 81 18 82.8 30 C84.2 40 84.2 50 81.5 56.5 C79.2 61.5 75.2 63.2 71.5 61.8"
|
||||
+ " C69.8 66.2 65.5 68.5 60.8 67.6 C58.2 67 56.2 65.2 55 62.8"
|
||||
+ " C53.2 66.8 48.8 68.8 44.2 67.6 C39.5 66.4 36.2 62.2 35 55.5"
|
||||
+ " C33.2 46 33.5 35 36.5 25.5 C39.5 16.5 44 9 46.2 2.5 C46.4 1.5 46.5 0.8 46.5 0 Z",
|
||||
shadow: "M65 -10 C68 5 75 15 78 29 C80 40 79 50 75 57 C68 63 54 66 38 62 L38 74 L92 74 L92 -10 Z",
|
||||
lines: "M46 67 C46.2 59.5 47 52.5 48.8 47 M60.8 67.6 C61.2 60 61.8 53 63.4 47.5 M71.5 61.8 C72 55.5 72.6 49.5 73.8 45"
|
||||
+ " M42 48.5 C53 45.8 65 44.5 76.5 43.2",
|
||||
over: {
|
||||
body: "M35.5 28 C41 34 49 41 55.5 46.5 C60.2 50.5 61 56.8 56.5 59.8 C52 62.8 44.8 60 39.5 54.2 C34.5 48.8 32.5 39.5 35.5 28 Z",
|
||||
shadow: "M35 44 C39.5 51 46.5 56.5 54 58.5 L50 62.5 L33 50 Z",
|
||||
},
|
||||
wrist: [60, 0], wristDeg: 0, upright: false,
|
||||
},
|
||||
|
||||
// Mão no rosto (tapar a boca / facepalm): palma arredondada e macia, dedos unidos em concha com sulcos curtos nas pontas.
|
||||
on_face: {
|
||||
body: `${WRIST_CAP}`
|
||||
+ " C75 8 80 18 81.5 30 C82.8 41 82.4 55 80.5 67 C79.5 73 76.8 76 73.5 75.5 C71.5 75.2 70.2 73.5 69.8 71"
|
||||
+ " C69.2 76.5 67.2 81.5 63.2 82 C59.8 82.4 58 80 57.6 76.5"
|
||||
+ " C57 81.5 54.6 85 50.6 85 C46.8 85 44.8 81.5 44.6 76.5"
|
||||
+ " C43.8 79.8 41.4 81.8 38.2 81.2 C34.8 80.5 33 76.5 33.6 69.5 C34.5 58 36.2 46.5 38 38"
|
||||
+ " C35.5 42.5 33 46.5 30 48.5 C26.8 50.5 23.2 49 22.6 45 C22 40 24.8 32.5 29.5 25.5"
|
||||
+ " C34.5 18 41.8 11 45.2 4 C46 2.5 46.5 1.2 46.5 0 Z",
|
||||
shadow: "M65 -10 C68 5 74.5 16 77 30 C78.5 43 78 58 75.5 71 C72.5 79 61 84 44 83 L44 92 L90 92 L90 -10 Z",
|
||||
lines: "M38 38 C39.8 32.5 40.6 27 40 21 M44.6 76.5 C45 69.5 45.8 63 46.8 57.5 M57.6 76.5 C58 69.5 58.4 63 59 57.5 M69.8 71 C70.2 65 70.6 59.5 71 55",
|
||||
wrist: [60, 0], wristDeg: 0, upright: false,
|
||||
},
|
||||
|
||||
// Mão pensando (apoiada no queixo): punho macio sob o queixo com o indicador estendido na bochecha/queixo
|
||||
// e os outros 3 dedos dobrados em gomos arredondados (sem aspecto de garfo ou bloco).
|
||||
think: {
|
||||
body: `${WRIST_CAP}`
|
||||
+ " C75.5 8 81.5 18 83.2 30 C84.5 40 84 50 81 57 C78.5 62.5 73.8 64.5 69.5 62.5"
|
||||
+ " C67.8 67.2 63 69.5 58 68.2 C55.2 67.5 53.2 65.5 52.2 63"
|
||||
+ " C50.5 66.5 47.8 68.2 44.8 67.5 C44.5 75 44 83.5 43 90"
|
||||
+ " C42 96.2 38.2 99.5 33.8 98.8 C29.4 98 26.8 93.8 27.6 87"
|
||||
+ " C29 75.5 31.2 61 33.5 48 C29.5 50.5 25 51.5 21.5 49.5 C17.8 47.5 16.5 42.5 18.8 37.5"
|
||||
+ " C21.5 31.5 28 25.5 34.5 19.5 C40.5 14 44.8 7 46.5 0 Z",
|
||||
shadow: "M65 -10 C68 5 75.5 16 78 30 C80 41 79 50 75 57 C69 63.5 57 66.5 43 65 L43 74 L91 74 L91 -10 Z"
|
||||
+ " M38 56 C39.5 68 39.5 82 38.5 99 L44.5 99 L45 56 Z",
|
||||
lines: "M33.5 48 C37.5 43 41 37 42.5 31 M45 66.5 C45.8 59 47 52 48.8 46.5 M58 68.2 C58.8 60.5 59.8 53.5 61.5 47.5 M69.5 62.5 C70.2 56 71 50 72.2 45",
|
||||
wrist: [60, 0], wristDeg: 0, upright: false,
|
||||
},
|
||||
|
||||
// Mão de braços cruzados apoiada no bíceps oposto (como em referencia/recortes/bracos-cruzados.png):
|
||||
// 3 dedos roliços e macios pousados diagonalmente sobre o braço.
|
||||
crossed: {
|
||||
body: `${WRIST_CAP}`
|
||||
+ " C74.5 8 79 18 80 29 C81 40 79.5 52 75.8 61.5 C73.2 68 68.5 71 63.8 69.5"
|
||||
+ " C61.4 75.8 56.2 79.2 50.5 77.6 C47 76.6 44.6 73.6 43.8 69.5"
|
||||
+ " C41.2 74 36.2 76 31.2 73.8 C26.4 71.6 24.4 66 26.8 59.2"
|
||||
+ " C30 50 34.8 38.5 39 27.5 C42.2 19 45.4 9.5 46.5 0 Z",
|
||||
shadow: "M64 -10 C67 5 72.5 16 74 30 C75 42 73.5 53 70 62 C65.5 70 52 75 33 72 L33 82 L88 82 L88 -10 Z",
|
||||
lines: "M43.8 69.5 C46.5 59.5 49.8 50 53.2 42 M63.8 69.5 C65.8 60 67.8 51 70.2 43.5",
|
||||
wrist: [60, 0], wristDeg: 0, upright: false,
|
||||
},
|
||||
};
|
||||
|
||||
/** Objetos seguros com as DUAS mãos (pelas bordas, na frente do peito). O resto vai numa mão só (`grip`). */
|
||||
export const TWO_HANDED: IconId[] = ["book", "tablet"];
|
||||
|
||||
/**
|
||||
* Como cada objeto entra no punho (`grip`): ponto do cabo no quadro 100×100 do ícone e o giro que deixa o cabo em pé
|
||||
* (cabeça do martelo, ponta do ramo e da régua para cima) com sobra visível do cabo abaixo da mão.
|
||||
*/
|
||||
export const GRIP: Partial<Record<IconId, { x: number; y: number; rot: number }>> = {
|
||||
hammer: { x: 50, y: 68, rot: 20 },
|
||||
olive: { x: 36, y: 68, rot: -42 },
|
||||
ruler: { x: 32, y: 50, rot: -78 },
|
||||
phone: { x: 50, y: 62, rot: -6 },
|
||||
fuel: { x: 50, y: 30, rot: 0 },
|
||||
bulb: { x: 50, y: 74, rot: 0 },
|
||||
};
|
||||
|
||||
/**
|
||||
* Posição da forma: espelho (`mirror`), giro em graus e escala, a partir do pulso na tela, do ângulo do antebraço e do
|
||||
* lado do braço. Formas alinhadas giram com o antebraço; as "em pé" acompanham o ângulo para o qual foram desenhadas.
|
||||
*/
|
||||
export function handPlacement(shape: HandShape, x: number, y: number, foreDeg: number, s: number, k: number) {
|
||||
const def = SHAPES[shape];
|
||||
let mirror: number;
|
||||
let rot: number;
|
||||
if (def.upright) {
|
||||
mirror = s >= 0 ? 1 : -1;
|
||||
rot = foreDeg - def.wristDeg * mirror;
|
||||
} else {
|
||||
const up = Math.cos((foreDeg * Math.PI) / 180) >= 0;
|
||||
mirror = up ? s : -s;
|
||||
rot = foreDeg;
|
||||
}
|
||||
const [wx, wy] = def.wrist;
|
||||
const transform = `translate(${x} ${y}) rotate(${rot}) scale(${k * mirror} ${k}) translate(${-wx} ${-wy})`;
|
||||
const r = (rot * Math.PI) / 180;
|
||||
/** Ponto do quadro 120×120 → tela. */
|
||||
const map = (px: number, py: number) => {
|
||||
const lx = (px - wx) * k * mirror;
|
||||
const ly = (py - wy) * k;
|
||||
return { x: x + lx * Math.cos(r) - ly * Math.sin(r), y: y + lx * Math.sin(r) + ly * Math.cos(r) };
|
||||
};
|
||||
return { def, mirror, rot, transform, map, hold: def.hold ? map(def.hold[0], def.hold[1]) : null };
|
||||
}
|
||||
|
||||
/** Pulso que põe o ponto `hold` da forma em (hx, hy) — para pôr as mãos nas bordas do objeto. */
|
||||
export function wristForHold(shape: HandShape, hx: number, hy: number, foreDeg: number, s: number, k: number) {
|
||||
const p = handPlacement(shape, 0, 0, foreDeg, s, k);
|
||||
return { x: hx - (p.hold?.x ?? 0), y: hy - (p.hold?.y ?? 0) };
|
||||
}
|
||||
|
||||
function shadeHex(hex: string, k: number): string {
|
||||
const n = parseInt(hex.slice(1), 16);
|
||||
const c = (v: number) => Math.max(0, Math.min(255, Math.round(v * k))).toString(16).padStart(2, "0");
|
||||
return `#${c((n >> 16) & 255)}${c((n >> 8) & 255)}${c(n & 255)}`;
|
||||
}
|
||||
/** Mistura duas cores hex (0 = a, 1 = b). */
|
||||
function mixHex(a: string, b: string, t: number): string {
|
||||
const pa = parseInt(a.slice(1), 16), pb = parseInt(b.slice(1), 16);
|
||||
const ch = (sh: number) => Math.round(((pa >> sh) & 255) * (1 - t) + ((pb >> sh) & 255) * t).toString(16).padStart(2, "0");
|
||||
return `#${ch(16)}${ch(8)}${ch(0)}`;
|
||||
}
|
||||
function coolHex(hex: string, k: number): string {
|
||||
const n = parseInt(hex.slice(1), 16);
|
||||
const r = ((n >> 16) & 255) * k * 0.96, g = ((n >> 8) & 255) * k * 0.96, b = (n & 255) * k + 6;
|
||||
const c = (v: number) => Math.max(0, Math.min(255, Math.round(v))).toString(16).padStart(2, "0");
|
||||
return `#${c(r)}${c(g)}${c(b)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Desenha a forma de mão no lugar. `layer`: "back" = o que fica atrás do objeto, "front" = o que fica na frente,
|
||||
* "all" = tudo. `light` = lado da sombra na tela (1 = direita).
|
||||
*/
|
||||
export function HandArt({ shape, x, y, foreDeg, s, k, skin, light = 1, layer = "all", uid }: {
|
||||
shape: HandShape; x: number; y: number; foreDeg: number; s: number; k: number; skin: string; light?: number;
|
||||
layer?: "all" | "back" | "front"; uid: string;
|
||||
}) {
|
||||
const p = handPlacement(shape, x, y, foreDeg, s, k);
|
||||
const def = p.def;
|
||||
const rightOnScreen = p.mirror * Math.cos((p.rot * Math.PI) / 180);
|
||||
const flipShadow = Math.sign(rightOnScreen || 1) !== Math.sign(light || 1);
|
||||
const shadowT = flipShadow && !def.upright ? "translate(120 0) scale(-1 1)" : undefined;
|
||||
const creaseColor = shadeHex(skin, 0.76);
|
||||
const shadowFill = coolHex(skin, 0.86);
|
||||
const skinLite = mixHex(skin, "#fff6ea", 0.06);
|
||||
const gradId = `hg${uid}${layer}`;
|
||||
|
||||
const lineProps = {
|
||||
stroke: creaseColor,
|
||||
strokeWidth: 3.1,
|
||||
strokeLinecap: "round" as const,
|
||||
strokeLinejoin: "round" as const,
|
||||
fill: "none",
|
||||
opacity: 0.9,
|
||||
};
|
||||
const nail = ([cx, cy, rx, ry, a]: [number, number, number, number, number], i: number) => (
|
||||
<ellipse
|
||||
key={i}
|
||||
cx={cx}
|
||||
cy={cy}
|
||||
rx={rx}
|
||||
ry={ry}
|
||||
transform={`rotate(${a} ${cx} ${cy})`}
|
||||
fill={mixHex(skin, "#fae5de", 0.38)}
|
||||
opacity={0.8}
|
||||
/>
|
||||
);
|
||||
|
||||
const bodyLayer = def.bodyBehind ? "back" : def.hold ? "front" : "all";
|
||||
const showBody = layer === "all" || layer === bodyLayer || (bodyLayer === "all" && layer === "front");
|
||||
const showOver = layer !== "back";
|
||||
|
||||
return (
|
||||
<g transform={p.transform}>
|
||||
<defs>
|
||||
<linearGradient id={gradId} x1="15%" y1="10%" x2="85%" y2="90%">
|
||||
<stop offset="0%" stopColor={skinLite} />
|
||||
<stop offset="100%" stopColor={skin} />
|
||||
</linearGradient>
|
||||
<clipPath id={`hb${uid}${layer}`}><path d={def.body} /></clipPath>
|
||||
{def.over && <clipPath id={`ho${uid}${layer}`}><path d={def.over.body} /></clipPath>}
|
||||
</defs>
|
||||
{showBody && (
|
||||
<>
|
||||
<path d={def.body} fill={`url(#${gradId})`} />
|
||||
<g clipPath={`url(#hb${uid}${layer})`}>
|
||||
<path d={def.shadow} fill={shadowFill} transform={shadowT} opacity={0.88} />
|
||||
</g>
|
||||
{def.lines && <path d={def.lines} {...lineProps} />}
|
||||
{(def.nails ?? []).map(nail)}
|
||||
</>
|
||||
)}
|
||||
{showOver && def.over && (
|
||||
<>
|
||||
<path d={def.over.body} fill={`url(#${gradId})`} />
|
||||
<g clipPath={`url(#ho${uid}${layer})`}>
|
||||
{def.over.shadow && <path d={def.over.shadow} fill={shadowFill} opacity={0.88} />}
|
||||
</g>
|
||||
{def.over.lines && <path d={def.over.lines} {...lineProps} />}
|
||||
{(def.overNails ?? []).map(nail)}
|
||||
</>
|
||||
)}
|
||||
</g>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user