From e4a5bc026c2ea2926dc14044f1a7319e94f726be Mon Sep 17 00:00:00 2001 From: Mateuus <5893666+Mateuus@users.noreply.github.com> Date: Wed, 18 Nov 2026 04:50:20 -0300 Subject: [PATCH] =?UTF-8?q?Cartoon:=20corpo=20cont=C3=ADnuo=20sem=20juntas?= =?UTF-8?q?=20e=20novas=20m=C3=A3os=20em=202=20camadas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cartoon/src/CharacterFigure.tsx | 1402 +++++++++++++++++++++---------- cartoon/src/hands.tsx | 413 +++++---- cartoon/src/icons.tsx | 52 +- cartoon/src/limbs.ts | 11 +- cartoon/src/rig.ts | 18 +- 5 files changed, 1268 insertions(+), 628 deletions(-) diff --git a/cartoon/src/CharacterFigure.tsx b/cartoon/src/CharacterFigure.tsx index 6b29e3e..e3d067d 100644 --- a/cartoon/src/CharacterFigure.tsx +++ b/cartoon/src/CharacterFigure.tsx @@ -1,20 +1,13 @@ // 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). SVG puro, sem Remotion: o painel usa o mesmo componente. -// viewBox 200×440, pés em (100, 440). O movimento (andar, pular, falar…) vem de motion.ts como `state`; sem ele, -// usa a expressão/pose pedida com a "vida" (piscar, respirar). Posição, giro e espelho ficam por conta de quem -// desenha a cena (Shot.tsx). -// -// Acabamento de ilustração (v2): cabeça grande (~1/3 da altura), tronco em "pera" com ombros redondos, membros -// afinando na ponta, SOMBREADO CEL em 2 tons em tudo (luz de um lado só, `shadeSide`), sem contorno preto (a borda -// é o tom escuro da própria cor), sobrancelha como forma, nariz de traço, pálpebra pesada, mãos com dedos que -// seguram o objeto por cima, roupa com gola/zíper/botões/dobras/barra e sapato com volume. +// 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 } from "./limbs"; +import { armLayer, type Point } from "./limbs"; import { GRIP, HandArt, TWO_HANDED, handPlacement, wristForHold, type HandShape } from "./hands"; const INK = "#1d1a22"; @@ -26,121 +19,292 @@ export function shade(hex: string, k: number): string { 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.94, g = ((n >> 8) & 255) * k * 0.97, b = (n & 255) * k + 10; + 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) => { +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: desenha a forma no tom da sombra e por cima a cópia iluminada deslocada para o lado da - * luz, recortada pela própria forma. Sobra um crescente de sombra no lado oposto à luz (e embaixo). + * 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, fill, side, dx = 8, dy = -4, k = 0.8, transform }: { id: string; d: string; fill: string; side: number; dx?: number; dy?: number; k?: number; transform?: string }) { +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 && } ); } -/** Membro afinando (ombro→cotovelo, cotovelo→punho, quadril→joelho…), com sombra cel no lado oposto à luz. */ -export function Limb2({ id, x, y, deg, len, w1, w2, fill, side }: { id: string; x: number; y: number; deg: number; len: number; w1: number; w2: number; fill: string; side: number }) { - const d = `M${-w1 / 2} 0 L${-w2 / 2} ${len} A${w2 / 2} ${w2 / 2} 0 0 0 ${w2 / 2} ${len} L${w1 / 2} 0 A${w1 / 2} ${w1 / 2} 0 0 0 ${-w1 / 2} 0 Z`; - // A sombra fica do lado da tela oposto à luz; no sistema local do membro esse lado gira junto. - const r = (deg * Math.PI) / 180; - const local = Math.cos(r) >= 0 ? side : -side; - return ; +/** + * 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 }; } -function Mouth({ f, uid, skin }: { f: FaceParams; uid: string; skin: string }) { - const w = 30 * f.mouthWidth * (1 - f.mouthRound * 0.35); - const cy = 138 - f.smile * 6; +/** 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 ( - - {/* Lábio de baixo: sombra curta sob a boca. */} - + + ); } const open = Math.max(f.mouthOpen, f.mouthRound * 0.25); - // A curva quadrática só chega à metade do ponto de controle: os controles ficam no dobro da abertura desejada. - const up = cy + f.smile * 2 - open * 8 - f.mouthRound * 6; - // A boca aberta (riso, grito) nunca passa do queixo (y ≈ 156): cresce até ali e para. - const low = Math.min(152, cy + open * 44 * (1 + f.mouthRound * 0.3) + f.smile * 12); + 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 ( - + - {f.teeth && open > 0.12 && } - {open > 0.35 && } + {!fullTeethGrin && f.teeth && open > 0.12 && ( + + )} + {!fullTeethGrin && open > 0.32 && ( + + )} + + ); } -function Eyes({ f, lid, skin, uid }: { f: FaceParams; lid: number; skin: string; uid: string }) { +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 r = 11 + Math.max(0, big - 1) * 7; - const cover = Math.max(0, Math.min(0.85, lid)); - const lidColor = shade(skin, 0.96); - const crease = shade(skin, 0.7); + 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) => { - // Olho de riso: fechado em arco para cima quando quase fechado e sorrindo. - if (open < 0.3 && f.smile > 0.55) return ; - if (open < 0.14) return ; - const rx = r * 1.12; - return ( - - - {/* Cavidade: leve sombra ao redor do olho. */} - - - - - - - {cover > 0.02 && <> - - - } + if (open < 0.3 && f.smile > 0.55) { + return ( + + + - {/* Dobra da pálpebra acima do olho. */} - + ); + } + 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)}; } -/** Sobrancelha como FORMA grossa (afina na ponta de fora), girando pelo rig. */ -function Brows({ f, thick, color }: { f: FaceParams; thick: boolean; color: string }) { - const h = thick ? 8 : 5.5; +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) => { - // Ponta de dentro (pivô) mais grossa; a de fora afina. const outer = x0 === pivotX ? x1 : x0; - const d = `M${pivotX} ${y - h * 0.55} Q${(pivotX + outer) / 2} ${y - h * 1.15} ${outer} ${y - h * 0.1} Q${(pivotX + outer) / 2} ${y + h * 0.15} ${pivotX} ${y + h * 0.55} Z`; - return ; + 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(68, 93, 88 + f.browL.y, f.browL.tilt, 93, -1)} - {brow(107, 132, 88 + f.browR.y, f.browR.tilt, 107, 1)} + {brow(67, 92, 88 + f.browL.y, f.browL.tilt, 92, -1)} + {brow(108, 133, 88 + f.browR.y, f.browR.tilt, 108, 1)} ); } @@ -148,9 +312,8 @@ function Brows({ f, thick, color }: { f: FaceParams; thick: boolean; color: stri function Extras({ f, t, skin }: { f: FaceParams; t: number; skin: string }) { return ( - {/* Bochechas: rubor leve sempre; mais forte com vergonha. */} - - + + {f.sweat && } {f.tears && [80, 120].map((x, i) => { const k = ((t * 1.4 + i * 0.5) % 1); @@ -162,155 +325,217 @@ function Extras({ f, t, skin }: { f: FaceParams; t: number; skin: string }) { ); } -function Beard({ style, color, uid, side }: { style: CharacterLook["beard"]["style"]; color: string; uid: string; side: number }) { - const strands = (d: string) => ; +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 = "M54 106 Q56 166 100 174 Q144 166 146 106 Q140 128 125 127 Q100 122 75 127 Q60 128 54 106 Z"; - return {strands("M78 150 Q84 162 92 166 M108 166 Q116 162 122 150")} - ; - } - case "stubble": return ; - case "goatee": return ; - case "mustache": return ( - - {/* Bigode cheio, com volume (claro em cima, escuro embaixo). */} - - - {strands("M84 126 L86 131 M96 124 L97 129 M106 124 L105 129 M116 126 L114 131")} - - ); - // Barba longa: desce do rosto até o peito em ponta, com fios marcados e bigode por cima. - case "long": { - const d = "M54 104 Q52 152 68 192 Q84 230 100 246 Q116 230 132 192 Q148 152 146 104 Q138 128 124 126 Q100 121 76 126 Q62 128 54 104 Z"; + 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 ( - - - + + ); } - default: return null; + 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; } } -/** Nariz: traço curvo simples no tom escuro da pele (padrão, como na ilustração) ou formas cheias. */ function Nose({ kind, skin }: { kind: CharacterLook["nose"]; skin: string }) { - const dark = shade(skin, 0.62); - const shadow = ; + const dark = shade(skin, 0.48); switch (kind) { - case "round": return <>{shadow}; - case "long": return <>{shadow}; - case "wide": return <>{shadow}; - case "button": return <>{shadow}; - default: return <>{shadow}; + 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.8); + const c = shade(skin, 0.72); return ( - - {/* Testa: arcos suaves no tom da pele. */} - - {k > 0.3 && } - {k > 0.6 && } - {k > 0.5 && <>} - {k > 0.4 && <>} + + + {k > 0.3 && } + {k > 0.6 && } ); } -/** Formato da cabeça (centro (100,106)). */ 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 56 C128 56 146 72 149 98 C153 128 142 158 100 160 C58 158 47 128 51 98 C54 72 72 56 100 56 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" : "#4a2e1e"; + const frame = kind === "sun" ? "#1c1a20" : "#492b1a"; const lens = (x: number) => kind === "square" - ? - : ; + ? + : ; return ( - {lens(81)}{lens(119)} - {/* Reflexo diagonal na lente. */} - - {lens(81)}{lens(119)} - - + {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 lite = shade(c, 1.25); - const cel = (d: string, k = 0.78) => ; + const dark = shade(c, 0.8); + const cel = (d: string, k = 0.8) => ; switch (look.hair.style) { - case "bald": return <>{cel("M50 100 Q46 78 64 68 Q72 82 62 100 Z M150 100 Q154 78 136 68 Q128 82 138 100 Z")}; - case "short": return <>{cel("M51 104 Q50 48 100 48 Q150 48 149 104 Q141 74 100 72 Q59 74 51 104 Z")}; - case "side": return <>{cel("M51 106 Q48 46 104 48 Q152 52 149 104 Q134 68 92 78 Q64 86 51 106 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("M51 110 Q48 48 100 48 Q152 48 149 110 Q137 70 100 68 Q63 70 51 110 Z")}; - 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; + 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; } } -/** Cabeça inteira no sistema de 200×440 (centro ~ (100,106)); `turn` desloca o rosto para fingir 3/4, `nod` sobe/desce. */ -function Head({ look, f, b, t, uid, side }: { look: CharacterLook; f: FaceParams; b: BodyParams; t: number; uid: string; side: number }) { - // Girar/acenar a cabeça: o rosto anda pouco e o contorno da cabeça acompanha um pouco (senão o rosto parece um - // adesivo descolando). Barba e bigode ficam presos ao queixo (andam junto com o contorno, não com os olhos). - const fx = b.headTurn * 6; - const fy = b.headNod * 4; - const hx = fx * 0.35; +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 skinDark = shade(look.skin, 0.72); + const earWell = shade(look.skin, 0.82); + const hasMustache = ["mustache", "full", "goatee", "long"].includes(look.beard.style); return ( - {[52, 148].map((x, i) => ( - - - {/* Dobra interna da orelha em tom escuro. */} - - - ))} - - - {/* Brilho suave na testa (lado da luz). */} - - + {[51, 149].map((x, i) => { + const earSide = i === 0 ? -1 : 1; + const earFill = earSide === side ? cool(look.skin, 0.86) : look.skin; + return ( + + + + + ); + })} + - - {/* Barba presa ao queixo: segue o contorno da cabeça e só um pouco o aceno. */} - - - - - + + + + - + - - {(look.beard.style === "full" || look.beard.style === "long") && } {look.accessories?.includes("helmet") && ( - + @@ -323,77 +548,100 @@ function Head({ look, f, b, t, uid, side }: { look: CharacterLook; f: FaceParams ); } -/** - * Mão: escolhe a forma desenhada da biblioteca (hands.tsx) pelo estado — gesto, apontar, pegada de borda, punho - * segurando, mão no rosto, braço erguido (aberta) ou caída — e a põe no pulso (x, y) com o giro do antebraço (`deg`). - * `scale` = escala do desenho de 120×120. `layer`: com objeto, "back" = atrás dele e "front" = na frente. - */ -function Hand({ x, y, deg, s, skin, curl, point, gesture, scale = 1, uid, light = 1, layer = "all", thumbFront, onFace }: { +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"; - /** Pegada de borda (objeto largo, em par): dedos atrás do objeto e só o polegar por cima dele. */ thumbFront?: boolean; - /** Mão apoiada no rosto (queixo, boca, testa). */ onFace?: boolean; + isThink?: boolean; }) { const raised = Math.cos((deg * Math.PI) / 180) < -0.2; - // Joinha só com o antebraço perto do ângulo para o qual o desenho foi feito (subindo na diagonal); fora disso, - // o polegar apontaria para o lado: vira punho fechado. - const thumbOk = Math.abs(((deg - 135 * (s >= 0 ? 1 : -1) + 540) % 360) - 180) <= 70; - const shape: HandShape = gesture === "thumbs_up" ? (thumbOk ? "thumbs_up" : "fist") : point ? "point" : thumbFront ? (raised ? "pinch_low" : "pinch_edge") - : curl >= 0.6 ? "grip" : onFace ? "on_face" : raised ? "open" : "relaxed"; + 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 ; } -/** - * Fim da manga: barra (punho) com espessura e dobra, a abertura escura por dentro e o pulso saindo DE DENTRO dela, - * com a sombra da manga caindo sobre a pele. Eixo local: (x, y) = borda da manga, +y = para fora (para a mão). - * `w` = largura da manga na borda. Sem `cuff` (manga curta), a barra fica no tom escuro do pano. - */ 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; - /** "back" = abertura escura (e o pulso, se `wrist` > 0), antes da mão; "front" = sombra no pulso e barra, depois. */ part?: "all" | "back" | "front"; }) { const up = Math.cos((deg * Math.PI) / 180) >= 0; const band = cuff ?? shade(cloth, 0.86); - const h = cuff ? 7.5 : 5; + const h = cuff ? 8.2 : 5.5; + const ww = wrist > 0 ? wrist : 17.5; return ( - {/* Abertura da manga (o escuro de dentro) e o pulso saindo dela. */} - {part !== "front" && <> - - {wrist > 0 && } - } - {part !== "back" && <> - {/* Sombra da manga caindo no pulso e a barra do punho por cima da sobra do pulso. */} - - - - } + {part !== "front" && ( + <> + + + + + + + + + 0 ? 1 : -ww / 2} y={-3} width={ww * 0.45} height={10} fill={cool(skin, 0.85)} /> + + + + )} + {part !== "back" && ( + <> + + + + )} ); } -/** - * Acessórios em camadas: "torso" = parte da roupa (colete, avental), por baixo de qualquer braço; "chest" = sobre o - * peito (toalha, cachecol, gravata, apito, corrente, crachá), entre o braço ao lado do corpo e o braço na frente do - * peito; "drape" = o pano da toalha apoiado no ombro, sempre por cima da raiz do braço daquele lado. - */ -function Accessories({ look, x0, x1, top, bottom, hipY, side, part, uid }: { look: CharacterLook; x0: number; x1: number; top: number; bottom: number; hipY: number; side: number; part: "torso" | "chest" | "drape"; uid: string }) { +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 === "drape") return acc.includes("towel") ? : null; if (part === "chest") { return ( {acc.includes("tie") && <>} {acc.includes("scarf") && <>} - {acc.includes("whistle") && <>} + {acc.includes("whistle") && ( + + + + + + + + + )} {acc.includes("chain") && } {acc.includes("badge") && <>} - {acc.includes("towel") && } + {acc.includes("towel") && } ); } @@ -410,100 +658,190 @@ function Accessories({ look, x0, x1, top, bottom, hipY, side, part, uid }: { loo ); } -/** - * Toalha no ombro, parte de baixo: pano largo caindo pela frente do peito, com volume (sombra cel), dobras, listras - * e franja na ponta, e a sombra que ela faz no casaco. - */ -function TowelBody({ x1, top, hipY, color, side, uid }: { x1: number; top: number; hipY: number; color: string; side: number; uid: string }) { - const end = hipY - 18; - const d = `M${x1 - 47} ${top + 6} C${x1 - 44} ${top + 40} ${x1 - 49} ${end - 30} ${x1 - 47} ${end} L${x1 - 9} ${end + 4} C${x1 - 8} ${end - 30} ${x1 - 4} ${top + 40} ${x1 - 6} ${top + 10} Z`; - const stripe = shade(color, 0.72); +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 ( - {/* Sombra do pano no casaco (lado de dentro). */} - - - {/* Dobras verticais do pano. */} - - {/* Duas listras perto da ponta e a franja. */} - - { const x = x1 - 45 + i * 5.6; const y = end + 0.6 + i * 0.6; return `M${x} ${y} L${x - 0.6} ${y + 5}`; }).join(" ")} stroke={shade(color, 0.8)} strokeWidth={2} strokeLinecap="round" /> + + + + ); } -/** Toalha no ombro, parte de cima: a dobra arredondada sobre o ombro, por cima da raiz do braço. */ -function TowelDrape({ x1, top, color, side, uid }: { x1: number; top: number; color: string; side: number; uid: string }) { - // Pano dobrado deitado sobre o ombro (segue a linha do ombro, não sobe no pescoço) e caindo um pouco para trás. - const d = `M${x1 - 48} ${top + 10} C${x1 - 44} ${top - 4} ${x1 - 16} ${top - 9} ${x1 + 4} ${top - 4} C${x1 + 14} ${top} ${x1 + 17} ${top + 12} ${x1 + 13} ${top + 24}` - + ` C${x1 + 9} ${top + 29} ${x1 + 2} ${top + 27} ${x1} ${top + 20} C${x1 - 6} ${top + 8} ${x1 - 28} ${top + 6} ${x1 - 48} ${top + 16} Z`; +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 ( - - {/* Dobra do pano por cima do ombro e a borda de baixo que cai para trás. */} - - + + ); } 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; - /** Gesto da mão direita quando ela não segura nem aponta ("thumbs_up" = polegar para cima). */ gesture?: "thumbs_up"; - /** Estado calculado pela linha do tempo (motion.ts). Sem ele: expressão/pose pedidas + piscar/respirar. */ state?: Pick; - /** Lado da sombra no desenho (1 = direita, -1 = esquerda). Quem espelha o personagem inverte para a luz ficar - * do mesmo lado da cena. */ 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; - // Objeto largo (livro, tábua) vai nas DUAS mãos: os dois braços vão para a pose de segurar pelas bordas. 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); - /** Escala do desenho da mão (quadro 120×120): mão ≈ do nariz ao queixo. */ - const HAND_K = 0.62; + 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; - // Quadril desce ao sentar; coxas abrem e encurtam (perspectiva), canelas voltam para baixo. const hipY = 306 + b.crouch * 56; - const legW = 30 * w; + 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 leg = (s: 1 | -1, l: Limb) => { - const hx = 100 + s * 24 * 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 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 fw = legW + 14; - const fy = foot.y + 2; + 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 ( - - - - {/* Barra da calça. */} - {pants !== look.skin && } - {footwear === "shoes" && <> - - - - } - {footwear !== "shoes" && } - {/* Sandália: sola fina e duas tiras cruzando o peito do pé. */} - {footwear === "sandals" && <> - - - } + + {[L, R].map((g) => ( + + + {shorts && ( + + )} + {shoeFor(g)} + + ))} + {look.bottom.style === "skirt" && !longTop && ( + + )} ); }; @@ -513,212 +851,398 @@ export function CharacterFigure({ look = DEFAULT_LOOK, expression, pose, item, t 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 arm = (s: 1 | -1, l: Limb, holds?: IconId, part: "all" | "upper" | "lower" = "all") => { - const x = 100 + s * 54 * w; + 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 elbow = tip(x, shY, upperDeg, 56); + 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; - // Aponta com o braço esticado para a frente (point, reach); erguido acima da cabeça (wave, arms_up) a mão fica aberta. - const pointing = !holds && s > 0 && l.raise > 60 && l.raise < 125 && Math.abs(l.bend) < 30; - // Manga longa termina numa borda (punho) e o pulso sai de dentro dela; manga curta: o braço segue em pele até a - // mão. A mão nasce do pulso, com a mesma pele e a mesma luz do rosto. + 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; - const cuffL = 40; - const wristL = longSleeve ? 43 : 41; + // 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); - // Objeto de uma mão: o cabo passa por dentro do punho (ponto `hold` da forma "grip"), em pé. - const gp = handPlacement("grip", wrist.x, wrist.y, foreDeg, s, HAND); - const gi = holds ? (GRIP[holds] ?? { x: 50, y: 60, rot: 0 }) : null; const cuffEnd = tip(elbow.x, elbow.y, foreDeg, cuffL); - const bareArm = !longSleeve; - // Borda de dentro do braço no tom escuro do pano: separa o braço caído do tronco da mesma cor. - const innerEdge = (px: number, py: number, d: number, len: number, w1: number, w2: number, color: string) => { - const ix = Math.cos((d * Math.PI) / 180) >= 0 ? -s : s; - return ; + 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 hand = { x: wrist.x, y: wrist.y, deg: foreDeg, s, skin: look.skin, light: side, scale: HAND, uid: `${uid}${s}`, onFace: (s > 0 ? layerR : layerL) === "face" }; - // Parte de cima (braço e manga curta) e de baixo (antebraço, punho, mão e objeto) podem ir em camadas diferentes: - // o antebraço que cruza o peito passa por cima do pano no ombro, a raiz do braço fica por baixo dele. - const up = part !== "lower"; - const low = part !== "upper"; - return ( - - {up && <> - - {!bareArm && innerEdge(x, shY, upperDeg, 56, 33 * Math.max(0.9, w * 0.95), 26, sleeve)} - {!longSleeve && top.style !== "dress" && <> - {/* Manga curta com a ponta reta (borda de pano), não arredondada: o braço sai de dentro dela. */} - = 0 ? side : -side} dx={11} dy={0} transform={`translate(${x} ${shY - 2}) rotate(${upperDeg})`} /> - {innerEdge(x, shY - 2, upperDeg, 34, 37, 32.4, sleeve)} - {(() => { const e = tip(x, shY - 2, upperDeg, 34.4); return ; })()} - } - } - {low && <> - {longSleeve - ? - : } - {longSleeve && innerEdge(elbow.x, elbow.y, foreDeg, cuffL - 6, 25, 23, sleeve)} - {/* Dobra no cotovelo e punho da manga. */} - {longSleeve && } - {/* Punho da manga com espessura e a abertura escura; o pulso sai de dentro, com a sombra da manga por cima. */} - {longSleeve && } - {s < 0 && look.accessories?.includes("watch") && (() => { const c = tip(elbow.x, elbow.y, foreDeg, wristL + 1); return ; })()} - {/* Segurando: dorso atrás do objeto, dedos dobrados e polegar por cima dele. */} - {holds && gi && gp.hold && ( - - - + + 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 && ( + )} - {/* Duas mãos num objeto largo: aqui só a parte de trás (dedos atrás do objeto); objeto e polegares depois. */} - {twoHanded && } - {!twoHanded && 0 && !holds && !pointing ? gest : undefined} layer={holds ? "front" : "all"} />} - {longSleeve && } - } + {!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 && ( + + )} ); }; - // Profundidade de cada braço pelo estado do rig (limbs.ts): ao lado do corpo, na frente do peito ou no rosto. - // Com o personagem de frente, braço e mão nunca somem atrás do tronco, de acessório ou da barba. + + /** 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 }); - // Objeto largo: entre as duas pegadas de borda, na frente do tronco; os polegares por cima dele. + 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 * 54 * w, shY, upperDeg, 56); + 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 ? 43 : 41); + 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)]; - // Borda do desenho do ícone (fração da largura): o livro vai de 8 a 92, a tábua de 14 a 86. - const span = item === "tablet" ? 0.72 : 0.84; + 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) => )} - ; + return ( + <> + + + {[L, R].map((g) => ( + + ))} + + ); }; - // Braço "side" inteiro na camada dele; braço "front"/"face": a raiz junto com os de lado (por baixo do pano do - // ombro) e o antebraço/mão na camada própria (por cima do pano, do peito ou do rosto). - const arms = (layer: string) => <> - {layer === "side" && <> - {layerL === "side" ? arm(-1, b.armL) : arm(-1, b.armL, undefined, "upper")} - {layerR === "side" ? arm(1, b.armR, holdItem) : arm(1, b.armR, undefined, "upper")} - } - {layer !== "side" && layerL === layer && arm(-1, b.armL, undefined, "lower")} - {layer !== "side" && layerR === layer && arm(1, b.armR, layer === "face" ? undefined : holdItem, "lower")} - ; - const x0 = 100 - 56 * w; - const x1 = 100 + 56 * w; + // 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 ? 14 : look.build === "heavy" ? 8 : 2; - // Tronco em "pera": ombros redondos, cintura e barriga mais largas embaixo. - const torsoPath = `M${100 - 36 * w} ${torsoTop} C${x0 - 6} ${torsoTop + 2} ${x0 - 8} ${torsoTop + 34} ${x0 - 2} ${torsoTop + 62}` - + ` C${x0 - bulge} ${torsoTop + 88} ${x0 - flare - bulge * 0.6} ${torsoBottom - 10} ${x0 - flare + 2} ${torsoBottom}` - + ` L${x1 + flare - 2} ${torsoBottom} C${x1 + flare + bulge * 0.6} ${torsoBottom - 10} ${x1 + bulge} ${torsoTop + 88} ${x1 + 2} ${torsoTop + 62}` - + ` C${x1 + 8} ${torsoTop + 34} ${x1 + 6} ${torsoTop + 2} ${100 + 36 * w} ${torsoTop} Z`; - const fold = shade(top.color, 0.74); - const neckH = 28; - // Largura do pescoço proporcional à cabeça (≈ metade dela), um pouco mais grosso em corpo forte. + 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 ( + + + - {/* Sombra de contato no chão. */} - + {look.hair.style === "long" && ( - + )} - {leg(-1, b.legL)} - {leg(1, b.legR)} - {look.bottom.style === "skirt" && !longTop && ( - - )} - {!longTop && } + {renderLowerBody()} {top.style === "hoodie" && } - {/* Pescoço com a sombra do queixo. */} - {/* Pescoço visível: alarga na base (trapézio), sombra do queixo em cima e o lado da sombra mais escuro. */} + {/* Pescoço com sombra do queixo e sombra lateral. */} - - - - - {/* Barra / cós embaixo do tronco. */} - {!longTop && } - {/* Dobras do tecido: axilas, barriga. */} - - {(look.belly || look.build === "heavy") && } - - {/* Construção da roupa por estilo. */} - {top.style === "shirt" && <> - - - {[0, 1, 2].map((i) => )} - {top.accent && } - } - {top.style === "uniform" && <> - - - {[0, 1, 2, 3].map((i) => )} - - - } - {(top.style === "jacket" || top.style === "hoodie") && <> - {/* Camiseta clara por baixo, zíper com puxador, gola. */} - - - - {top.style === "jacket" && <> - - - } - {top.style === "hoodie" && <> - - - } - } - {top.style === "dress" && <> - - {[0, 1, 2, 3, 4, 5].map((i) => )} - - } - {top.style === "robe" && <> - {/* Gola em V, dobras do pano e faixa amarrada na cintura com a ponta caindo. */} - - - - - - } - + + + + + + {/* 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: braço ao lado do corpo (e a raiz dos outros) → pano do peito → pano no ombro → antebraço/mão na - frente do peito → cabeça → mão no rosto. */} + {/* Camadas com braços contínuos (sem quebrar no cotovelo!). */} + + {arms("side")} - - - {arms("front")} - {twoHand()} - + {st.emote && ( @@ -726,6 +1250,8 @@ export function CharacterFigure({ look = DEFAULT_LOOK, expression, pose, item, t )} + {arms("front")} + {twoHand()} {arms("face")} @@ -739,20 +1265,18 @@ export function CharacterFigure({ look = DEFAULT_LOOK, expression, pose, item, t */ 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 cuff = look.top.style === "uniform" || look.top.style === "jacket" ? (look.top.accent ?? shade(cloth, 0.8)) : undefined; - // Mão grande (close): a mesma biblioteca de mãos em escala; a manga/punho na mesma proporção do braço. + 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) => { - // O antebraço sobe do canto de baixo, inclinado para dentro; no pulso a mão dobra: os dedos ficam ATRÁS da - // borda lateral do objeto e o polegar comprido apoia por cima da página (pegada de quem segura um livro aberto). const deg = 180 - s * 30; const edge = { x: 540 + s * 250 + (s > 0 ? sway : 0), y: 660 + (s > 0 ? -sway : 0) }; - // Pegada de borda com o antebraço vindo de baixo: o pulso segue o eixo do antebraço até a mão. 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); @@ -761,24 +1285,26 @@ export function HandsInsert({ look = DEFAULT_LOOK, item, t = 0, shadeSide = 1 }: }); return ( + + + {arms.map(({ s, deg, end, start, hand }) => ( - {long - ? <> - - {/* Dobras do pano no antebraço. */} - - + {long ? ( + <> + + + - : } + ) : ( + + )} {item && } ))} {item && } - {/* Só o polegar por cima do objeto; sem objeto, as mãos relaxadas inteiras. */} {arms.map(({ s, hand }) => )} - {/* Barra do punho por cima da sobra do pulso. */} - {long && arms.map(({ s, deg, end }) => )} + {long && arms.map(({ s, deg, end }) => )} ); } diff --git a/cartoon/src/hands.tsx b/cartoon/src/hands.tsx index 8cc7c52..e983b24 100644 --- a/cartoon/src/hands.tsx +++ b/cartoon/src/hands.tsx @@ -1,187 +1,247 @@ -// Biblioteca de MÃOS desenhadas (não montadas com cápsulas): cada forma é um desenho num quadro fixo de 120×120, -// com a silhueta inteira num path só (Bézier contínuas: dedos afinando em 3 falanges, nós em arco, polegar nascendo -// do montinho da base da palma), as linhas internas no tom escuro da pele, unhas, e uma sombra cel DESENHADA -// (recortada pela silhueta). O rig só ESCOLHE a forma, posiciona no pulso, gira e espelha. -// -// Regras de construção seguidas (ensino de desenho de mão): palma ≈ quadrada com laterais curvas; dedo médio ≈ altura -// da palma, médio o maior, indicador ≈ anelar, mínimo o menor; nós da base e pontas em ARCO (o médio mais à frente); -// dedo afina para a ponta; polegar com 2 segmentos e unha, girando em outro eixo; pulso mais estreito que a palma; -// volume com sombra no lado oposto à luz e embaixo dos dedos; linhas internas sempre curvas. -// -// Quadro canônico: braço da DIREITA da tela (s = 1), luz vinda da esquerda (sombra desenhada à direita/embaixo). -// - formas "alinhadas" (relaxed, open, point, fist, on_face): o antebraço chega por cima (pulso em (60, 4)) e os dedos -// apontam para +y; o polegar fica do lado −x. O rig gira pelo ângulo do antebraço. -// - formas "em pé" (thumbs_up, grip, pinch_edge): desenhadas na orientação da tela, com o pulso num canto e o ângulo -// do antebraço para o qual foram feitas (`wristDeg`); o rig só inclina um pouco para acompanhar o braço. +// 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"] as const; +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 inteira (um path). */ + /** Silhueta principal (camada de trás quando `bodyBehind` é true). */ body: string; - /** Sombra cel desenhada (recortada pela silhueta do corpo). */ + /** Sombra cel em crescente macio (recortada pela silhueta `body`). */ shadow: string; - /** Linhas internas do corpo: separação dos dedos, nós, dobras. */ + /** Linhas internas quentes: separação dos dedos, nós e dobras da palma. */ lines: string; - /** Peça por cima (polegar dobrado por cima dos dedos ou do objeto), com sombra e linhas próprias. */ + /** 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: [cx, cy, rx, ry, giro]. A primeira do corpo, as de `overNails` por cima. */ + /** 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 (onde encosta o fim do antebraço). */ + /** 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: o corpo fica ATRÁS do objeto (só a peça `over` na frente) — pinch_edge. */ + /** Com objeto: `body` fica ATRÁS do objeto e `over` fica NA FRENTE dele (objeto dentro da mão). */ bodyBehind?: boolean; - /** Onde fica o objeto: cabo (grip) ou borda (pinch_edge). */ + /** Ponto onde passa o cabo (`grip`) ou encosta a borda (`pinch_edge`/`pinch_low`). */ hold?: [number, number]; }; -// Pulso: cilindro com ≈ 60 % da largura da palma (27 unidades), centrado no ponto `wrist`, com uma sobra de 10 -// unidades que entra por baixo da manga (fica escondida pelo punho da manga). Sombra do lado oposto à luz (direita): -// no pulso ela tem a mesma largura da sombra do antebraço (≈ 1/3) e vai afinando na borda da mão; sob os dedos dobrados -// e sob o polegar. -const WRIST_TOP = "M46.5 -10 L46.5 3"; -const WRIST_RIGHT_END = "C74.4 6.5 73.6 3 73.5 0 L73.5 -10 Z"; +// 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, vista pelo dorso: dedos juntos levemente curvos (nós e pontas em arco), polegar na frente. + // Caída ao lado do corpo: formas arredondadas e carnudas, polegar voltado para dentro, dedos juntos curvando suavemente. relaxed: { - body: `${WRIST_TOP} C45.5 12 41 18 38.5 25 C35.5 33 34 42 35 50 C35.8 57 38.5 61 42 60.5 C45 60 46 57 45.6 53 C45.3 49 45 46 44.8 44` - + " C43.6 52 42.8 62 43 72 C43.2 79 45.2 82.5 48.3 82.5 C51.3 82.5 52.6 80 52.6 76.5 L52.8 74 C53 80 53.4 86 55.2 89" - + " C56.6 91.6 60 92 61.8 89.8 C63 88 63.2 85 63.2 81 L63.4 78 C63.8 82 64.6 85.5 66.4 87.2 C68.4 89 71.4 88.2 72.2 85.4" - + " C72.8 83 72.8 80 72.6 77 L72.8 74 C73.8 76.5 75.4 78 77.4 77.6 C79.6 77 80.6 74.6 80.7 71.5 C81 64 81.8 54 82 46" - + ` C82.2 34 79.5 20 75.5 10 ${WRIST_RIGHT_END}`, - shadow: "M64.6 -12 L65 1 C69 6 75 12 78 22 C79.6 32 80 42 79.6 52 C79.2 62 78.6 70 78.8 76 L96 80 L96 -12 Z" - + " M40 77 C48 84.5 62 90.5 80 76 L80 100 L40 100 Z M45.2 45 C46.6 52 47 59 46.6 65 L49.6 66 C49.8 58 49.2 50 47.6 44 Z", - lines: "M52.8 74 C52.7 68 52.8 62 53.2 56 M63.4 78 C63.4 71 63.2 64 63 57 M72.8 74 C73 68 73.4 62 73.8 55 M44.8 44 C44.5 38 43 32 41 27", - nails: [[40.6, 54.2, 2.8, 3.8, 6]], + 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, }, - // Aberta, palma para a câmera (acenando): dedos levemente abertos, polegar saindo da eminência tenar. + + // Mão aberta (acenando / comemorando): palma carnuda, dedos abrindo em leque macio que afinam na ponta, polegar na base. open: { - body: `${WRIST_TOP} C44 12 39 18 35 22 C29 26 24 31 21 37 C18.5 42 19.5 47 23.5 47.5 C26.5 48 28.5 45.5 30 42.5 C32.5 38 35.5 35 38.5 34.5` - + " C39 38 39.2 41 39.5 44 C38.6 54 38 64 38.4 72 C38.6 78 41 80.6 44 80.4 C47 80.2 48.4 78 48.4 74.6 C48.6 64 48.8 55 49.4 47.5" - + " C50.4 58 50.8 70 51.2 80 C51.4 86 54.2 88.6 57.2 88.4 C60.2 88.2 61.6 85.6 61.4 82 C61 70 60.8 58 61.2 48" - + " C62.6 58 63.6 68 64.4 76 C64.8 81.4 67.6 83.6 70.4 83 C73 82.4 74 79.8 73.6 76.6 C72.6 66 72 56 72 47.4" - + " C73.8 54 75.6 61 77.6 66.6 C79 70.6 82 71.6 84.2 70 C86 68.6 86 66 85.2 63 C83 54 82.6 42 81.6 30 C80.6 18 76 8 73.5 2 L73.5 -10 Z", - shadow: "M64.6 -12 L65 1 C70 6 77 14 80.6 32 C81.6 44 82 54 83.4 64 L96 64 L96 -12 Z M50 30 C56 36 66 38.4 75 34 C70 42 60 44.4 51 40 Z" - + " M45.6 50 C46.2 60 46.4 70 46 80.4 L49 80 L49.2 50 Z M58.4 50 C58.8 62 59.2 74 59 88.4 L62 88 L61.6 50 Z M70.4 50 C71.2 60 71.8 70 72 82 L74.6 81 L73.6 50 Z", - lines: "M48 46 C58 42.4 70 42.4 80 46 M42 40 C46 32 50 22 52 12", + 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, vista pelo lado da palma: indicador esticado (3 falanges, afinando, unha na ponta, leve curva); médio, - // anelar e mínimo dobrados como gomos empilhados em arco (médio mais à frente), com a ponta virada para a palma e a - // UNHA de cada um aparecendo; o polegar fecha por cima do médio, com a unha dele. + + // 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_TOP} C45 12 40 18 37.5 26 C36 34 36.2 42 38.2 48 C37.8 60 37.9 72 38.5 82 C39 90 39.6 96 40.6 101.4` - + " C41.4 106.6 46 108.4 49.2 106 C51.6 104.2 52.2 100.4 52.2 96.6 C52.2 88 52.6 76 53.4 64" - + " C54 68.6 56.8 71 60.6 70.6 C64 70.2 65.6 67.6 65.8 64.8 C68 68 71.6 68.4 74 66.6 C76 65 76.4 62 76 59.8" - + ` C78.4 60.6 81 59.4 81.8 56.4 C82.6 53 82.4 49 82 46 C82 34 79.5 20 75.5 10 ${WRIST_RIGHT_END}`, - shadow: "M64.6 -12 L65 1 C70 6 78 14 80.8 30 C81.6 40 81 48 79.6 52 C76 50 70 49 64 50 L96 50 L96 -12 Z" - + " M50 66 C56 72.6 68 72 74 68 C78 66 81 62 83 56 L86 80 L48 80 Z M49.6 66 C50.2 78 50.6 92 50.2 108 L58 108 L58 66 Z" - + " M44 58 C48 62 52 64.4 56.4 63.6 L58 67 L44 64 Z", - lines: "M65.8 64.8 C65.4 60.6 64.4 57.6 62.8 55.4 M76 59.8 C75.4 56 74.2 53.4 72.6 51.6 M53 57.4 C60 53.6 70 51.4 81 47" - + " M38.8 81 Q45.4 82.6 52.4 81 M40.2 93 Q46 94.4 52.2 93", - nails: [[59.6, 66.6, 3.2, 2.4, 6], [70.8, 63.4, 2.9, 2.2, -8], [79.2, 54.6, 2.3, 1.9, -30], [45.8, 102, 3, 3.6, -4]], + 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: "M38.4 30 C42 38 47 46 52.8 52 C56.2 55.4 57 60 54 61.6 C51 63.2 47.4 60.4 44.4 56.6 C40.8 52 38 46 37.6 40 Z", - shadow: "M39.6 46 C42 51 46 56 50 59 L46 62 L38 52 Z", + 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", }, - overNails: [[53.2, 57.2, 3, 2.6, 40]], wrist: [60, 0], wristDeg: 0, upright: false, }, - // Joinha: punho de lado, os 4 dedos dobrados na horizontal (um em cima do outro, nós e pontas na frente), - // polegar grosso saindo do topo, com unha, levemente inclinado para trás. Antebraço chegando de baixo, na diagonal. + + // 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: "M56 42 C46 39.5 34 40 29 44.5 C24.6 48.6 25.2 54.4 29.6 56 C25.2 58.6 24.8 65.4 29.4 67.8 C25.8 70.6 26.4 77.6 31 79.4" - + " C28.6 82.6 30.6 88.4 36 89.4 C46 91.2 60 92.6 72 93.6 C78 94.4 83 97.2 86.5 101.5 L93.6 108.6 L112.6 89.6 L105.5 82.5" - + " C101 77.6 96 70.4 92 61 C89.4 54.4 85 48 78 45 C77.6 40 76.8 30 75.4 20 C74.4 13 71.6 7 66 6.4" - + " C60.6 5.8 57.4 9.6 56.8 15.6 C56.2 24 55.8 33 56 42 Z", - shadow: "M84 46 C90 52 95 62 98 72 L104 82 L120 96 L120 40 Z M28 54.6 C38 57.8 50 58 60 56.6 L60 59.6 C48 61 38 60.6 28 58 Z" - + " M28 66.4 C38 69.6 50 70 60 68.6 L60 71.6 C48 73 38 72.6 28 70 Z M30 78 C40 81 50 81.6 58 80.6 L58 83.6 C48 84.6 40 84 30 81.4 Z" - + " M30 88 C46 92 62 94 74 95 L86 104 L40 104 Z M71 8 C74 14 76 24 77 40 L84 44 L84 4 Z", - lines: "M29.6 56 C38 58 48 58.4 58 57 M29.4 67.8 C38 70 48 70.4 58 69 M31 79.4 C39 81.4 48 81.8 56 81" - + " M58 57 C62 55.6 64.6 52.6 65.4 49 M58 69 C62.6 67.6 65.6 64.6 66.4 60.6 M56 81 C60.4 80 63.4 77.4 64.4 73.6 M57 34.5 C62 37 70 37.4 77 33.6", - nails: [[65.4, 13.8, 5, 6, 4]], - wrist: [96, 92], wristDeg: 135, upright: true, + 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 em volta de um cabo (martelo, régua, ramo, celular): o cabo passa por dentro, o polegar fecha por cima. + + // 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: "M44 42 C34 41.6 26.6 43.6 26.2 49 C25.8 53.4 26.8 55.6 29.6 56 C25.2 58.6 24.8 65.4 29.4 67.8 C25.8 70.6 26.4 77.6 31 79.4" - + " C28.6 82.6 30.6 88.4 36 89.4 C48 91.4 64 92 76 89.6 C86 87.4 92.6 80 94.4 70 C96 62 100 55 105.5 49.5 L112.6 42.4 L93.6 23.4 L86.5 30.5" - + " C80 36 72 39.6 62 41 C56 41.8 50 42 44 42 Z", - shadow: "M86 34 C92 44 95 58 94 70 C92 82 84 90 74 92 L120 120 L120 30 Z M28 54.6 C38 57.8 50 58 60 56.6 L60 59.6 C48 61 38 60.6 28 58 Z" - + " M28 66.4 C38 69.6 50 70 60 68.6 L60 71.6 C48 73 38 72.6 28 70 Z M30 78 C40 81 50 81.6 58 80.6 L58 83.6 C48 84.6 40 84 30 81.4 Z" - + " M30 88 C46 92 62 93 78 90 L78 100 L30 100 Z", - lines: "M29.6 56 C38 58 48 58.4 58 57 M29.4 67.8 C38 70 48 70.4 58 69 M31 79.4 C39 81.4 48 81.8 56 81" - + " M58 57 C62 55.6 64.6 52.6 65.4 49 M58 69 C62.6 67.6 65.6 64.6 66.4 60.6 M56 81 C60.4 80 63.4 77.4 64.4 73.6", + 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: "M80 36 C72 30.6 58 29.6 46 32.6 C37 34.8 33.4 40.6 36.6 44.2 C40.6 47.6 52 46.6 62 45.6 C70 44.8 76 43 79 40.6 Z", - shadow: "M36 43 C44 46.6 58 46.4 72 44 L72 48 L36 48 Z", + 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", }, - overNails: [[40.6, 39.4, 4.2, 3.6, -12]], - wrist: [96, 40], wristDeg: 45, upright: true, hold: [44, 66], + wrist: [86, 64], wristDeg: 45, upright: true, bodyBehind: true, hold: [44, 65], }, - // Segurando a borda de um objeto largo (em par): dedos atrás do objeto, polegar grosso por cima da frente dele. - // Antebraço chegando de cima, por fora (pose hold_both). + + // 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: "M56 32 C62 27 72 26.6 80 30.6 C83.6 32.6 85.6 37 87 42 L94.4 35.3 L112.4 55.3 L105 62 C102 70.4 97 78 90 83.4" - + " C82.6 89 72.6 92 64 90.6 C58.6 89.6 55.6 86 55 80 C54 64 54 46 56 32 Z", - shadow: "M82 30 C90 38 94 50 94 62 C92 74 86 82 76 88 L120 120 L120 20 Z M55 78 C60 86 70 90 84 88 L84 96 L54 96 Z", - lines: "M56 46 C62 46 68.6 47.6 74 50.6 M55.6 60 C61.4 60.4 67.6 62 73 64.8 M55.6 73.6 C60.6 74 65.4 75.6 69.6 78", + 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: "M70 46 C62 40 52 34.6 45 31.6 C38.4 28.8 33 32.4 35 38.4 C37.4 45 46.4 51 55.6 57 C62 61 70.4 57.6 70 46 Z", - shadow: "M36.4 40.6 C43 47 52 53 60 58 L68 58 L68 64 L34 46 Z", + 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", }, - overNails: [[39.8, 35.2, 4.2, 3.6, 30]], - wrist: [96, 52], wristDeg: 48, upright: true, bodyBehind: true, hold: [56, 52], + wrist: [85, 60], wristDeg: 62, upright: true, bodyBehind: true, hold: [44, 60], }, - // A mesma pegada de borda com o antebraço chegando de baixo (close de mãos segurando um livro aberto). + + // 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: "M56 30 C64 25 78 26 85 34 C90 41 93 52 95 62 C96.6 70 100 78 105.5 86.5 L112.6 93.6 L93.6 112.6 L86.5 105.5" - + " C80 98 72 94.6 66 92.4 C59 90 56 85.6 55 79 C53.6 64 53.6 44 56 30 Z", - shadow: "M80 28 C90 40 94 56 96 68 C98 78 102 84 110 92 L120 120 L120 20 Z M55 78 C60 86 68 91 80 96 L80 104 L54 100 Z", - lines: "M56 46 C62 46 68.6 47.6 74 50.6 M55.6 60 C61.4 60.4 67.6 62 73 64.8 M55.6 73.6 C60.6 74 65.4 75.6 69.6 78", + 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: "M70 46 C62 40 52 34.6 45 31.6 C38.4 28.8 33 32.4 35 38.4 C37.4 45 46.4 51 55.6 57 C62 61 70.4 57.6 70 46 Z", - shadow: "M36.4 40.6 C43 47 52 53 60 58 L68 58 L68 64 L34 46 Z", + 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", }, - overNails: [[39.8, 35.2, 4.2, 3.6, 30]], - wrist: [96, 96], wristDeg: 135, upright: true, bodyBehind: true, hold: [56, 52], + wrist: [94, 96], wristDeg: 135, upright: true, bodyBehind: true, hold: [56, 52], }, - // Fechada, vista pelo lado da palma: os 4 dedos dobrados como gomos em arco (médio mais à frente, mínimo menor), - // com a ponta virada para a palma e a UNHA de cada um; o polegar fecha por cima do indicador e do médio. + + // Punho fechado: 4 dedos dobrados em arco macio, polegar travando por cima do indicador e do médio. fist: { - body: `${WRIST_TOP} C45 12 40 18 37.5 26 C36 34 36.2 42 38 50 C39.4 57 42.4 62 46.6 63.6 C50 65 53.2 64 54.4 61.4` - + " C56 66.4 60 69 64 68.4 C67.4 67.8 69 65.2 69.2 62.4 C71.4 65.8 75 66.2 77.4 64.2 C79.4 62.4 79.8 59.4 79.4 57" - + ` C81.6 57 82.6 53 82.4 48 C82.2 34 79.5 20 75.5 10 ${WRIST_RIGHT_END}`, - shadow: "M64.6 -12 L65 1 C70 6 78 14 80.8 30 C81.6 40 81 46 80 50 L96 50 L96 -12 Z M40 58 C48 68 66 72 82 54 L84 80 L38 80 Z", - lines: "M54.4 61.4 C53.8 57 52.4 54 50.6 52 M69.2 62.4 C68.8 58.4 67.6 55.6 66 53.6 M79.4 57 C78.6 53.6 77.4 51.2 75.8 49.6 M44 51 C54 47.6 68 45.6 81 43.6", - nails: [[46, 59.6, 3, 2.3, 10], [62.6, 64.4, 3.2, 2.4, 0], [74.2, 61.2, 2.8, 2.1, -10], [80, 53, 2.2, 1.8, -30]], + 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: "M38 30 C42 39 48 47 55 52 C59 54.6 60.4 59 57 60.6 C53 62.4 47.6 59 43.6 54.6 C39.8 50.4 37.4 42 38 30 Z", - shadow: "M39.4 46 C42.6 52 47 57 52 60 L48 63 L38 52 Z", + 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", }, - overNails: [[56.6, 56.8, 3.1, 2.7, 35]], wrist: [60, 0], wristDeg: 0, upright: false, }, - // Apoiada no rosto (queixo, boca, lateral da cabeça): dorso, dedos juntos e mais retos, polegar recolhido. + + // 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_TOP} C45.5 12 41.5 18 39.5 25 C37.5 32 37.5 40 39 46 C39.5 58 39.6 70 40.4 82 C40.8 88 43.4 91.4 46.4 91.2` - + " C49.4 91 50.6 88.4 50.8 85 L51 83 C51.4 90 53.6 94.4 57 94.4 C60.4 94.4 62 91.4 62.2 87.6 L62.3 85.6 C63 91 65.4 93.4 68.4 93" - + " C71.4 92.6 72.4 89.8 72.4 86.4 L72.5 83.6 C73.6 87 75.6 88.2 77.6 87.6 C79.8 86.8 80.6 84 80.8 80.6 C81.6 70 82.2 56 82 44" - + ` C81.8 32 79.2 20 75.5 10 ${WRIST_RIGHT_END}`, - shadow: "M64.6 -12 L65 1 C70 6 78 14 80.4 36 C81 50 80.6 66 79.6 84 L96 84 L96 -12 Z M40 84 C48 92 66 97 82 84 L82 104 L40 104 Z", - lines: "M51 83 C51 74 51.2 66 51.6 58 M62.3 85.6 C62.3 76 62.2 67 62 58 M72.5 83.6 C72.8 75 73 66 73.2 57", - over: { - body: "M39.5 25 C35 31 33.6 40 35.4 46 C36.8 50.4 41 50 41.6 46 C42.2 41 42 34 41.8 28 Z", - }, - overNails: [[37.4, 44.6, 2.4, 3.2, 6]], + 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, }, }; @@ -191,31 +251,29 @@ 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). Sem entrada: pelo meio, sem girar. + * (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: 80, rot: 20 }, - olive: { x: 26, y: 80, rot: -43 }, - ruler: { x: 14, y: 58, rot: -78 }, - phone: { x: 50, y: 74, rot: 0 }, + 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: 82, 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é" só inclinam até ±30° para acompanhá-lo. + * 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) { - // Desenhada para o braço da direita; o pulso acompanha o eixo do antebraço (gira em torno do centro do pulso). mirror = s >= 0 ? 1 : -1; rot = foreDeg - def.wristDeg * mirror; } else { - // Polegar do lado do corpo; com o braço erguido o eixo local vira e o espelho inverte junto. const up = Math.cos((foreDeg * Math.PI) / 180) >= 0; mirror = up ? s : -s; rot = foreDeg; @@ -251,14 +309,14 @@ function mixHex(a: string, b: string, t: number): string { } function coolHex(hex: string, k: number): string { const n = parseInt(hex.slice(1), 16); - const r = ((n >> 16) & 255) * k * 0.94, g = ((n >> 8) & 255) * k * 0.97, b = (n & 255) * k + 10; + 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). Sem contorno: a borda é o tom escuro da pele. + * "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; @@ -266,38 +324,69 @@ export function HandArt({ shape, x, y, foreDeg, s, k, skin, light = 1, layer = " }) { const p = handPlacement(shape, x, y, foreDeg, s, k); const def = p.def; - // A sombra foi desenhada à direita; se, depois de espelhar e girar, a direita do desenho não cai do lado da sombra - // pedido, a sombra vira para o outro lado (sempre recortada pela silhueta). const rightOnScreen = p.mirror * Math.cos((p.rot * Math.PI) / 180); const flipShadow = Math.sign(rightOnScreen || 1) !== Math.sign(light || 1); - const shadowT = flipShadow ? "translate(120 0) scale(-1 1)" : undefined; - const dark = shadeHex(skin, 0.62); - const shadow = coolHex(skin, 0.8); - const lineProps = { stroke: dark, strokeWidth: 1.7, strokeLinecap: "round" as const, strokeLinejoin: "round" as const, fill: "none", opacity: 0.55 }; + 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.nails ?? []).map(nail)} - } - {showOver && def.over && <> - - {def.over.shadow && } - {def.over.lines && } - {(def.overNails ?? []).map(nail)} - } + {showBody && ( + <> + + + + + {def.lines && } + {(def.nails ?? []).map(nail)} + + )} + {showOver && def.over && ( + <> + + + {def.over.shadow && } + + {def.over.lines && } + {(def.overNails ?? []).map(nail)} + + )} ); } diff --git a/cartoon/src/icons.tsx b/cartoon/src/icons.tsx index 4195688..eff42b4 100644 --- a/cartoon/src/icons.tsx +++ b/cartoon/src/icons.tsx @@ -72,31 +72,53 @@ const DRAW: Record = { ), // Itens de mão e objetos de história antiga (também servem como objeto solto na cena). olive: (<> - - {[[34, 66, -40], [44, 56, 30], [54, 46, -40], [64, 36, 30], [74, 26, -40], [28, 76, 30]].map(([x, y, r], i) => ( - + + + {[[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) => )} + + + {Array.from({ length: 7 }, (_, i) => )} ), book: (<> - - - {[0, 1, 2, 3].map((i) => )} - + + + + + + {[0, 1, 2, 3].map((i) => )} ), ruler: (<> - - {Array.from({ length: 10 }, (_, i) => )} + + + + + {Array.from({ length: 11 }, (_, i) => )} + ), }; diff --git a/cartoon/src/limbs.ts b/cartoon/src/limbs.ts index 17006e8..81cfc7c 100644 --- a/cartoon/src/limbs.ts +++ b/cartoon/src/limbs.ts @@ -47,12 +47,15 @@ export function armGeometry(b: BodyParams, s: 1 | -1, w = 1) { 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. - const atFace = (p: Point) => p.y < g.torsoTop + 12 && Math.abs(p.x - 100) < 66; - if (atFace(g.hand)) return "face"; + // 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"; - const chest = { x0: 100 - half + 16, x1: 100 + half - 16, y0: g.torsoTop + 6, y1: g.hipY + 10 }; + // 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++) { diff --git a/cartoon/src/rig.ts b/cartoon/src/rig.ts index ee3a31a..4690bda 100644 --- a/cartoon/src/rig.ts +++ b/cartoon/src/rig.ts @@ -110,26 +110,26 @@ export const EXPRESSION_PRESETS = { /** Poses prontas = atalhos de ângulos (ajustáveis por cima com `body`). */ export const POSE_PRESETS = { stand: {}, - point: { armR: { raise: 92, bend: 0 } }, + point: { armR: { raise: 46, bend: -128 } }, wave: { armR: { raise: 140, bend: -25 } }, - hold: { armR: { raise: 28, bend: 75 } }, + hold: { armR: { raise: 34, bend: 106 } }, arms_up: { arms: { raise: 158, bend: -10 } }, - celebrate: { arms: { raise: 150, bend: -30 }, headNod: -0.4 }, + celebrate: { arms: { raise: 146, bend: -26 }, headNod: -0.35 }, shrug: { arms: { raise: 38, bend: 100 }, headTilt: 7 }, - think: { armR: { raise: -19, bend: 141 }, headTilt: -6 }, + think: { armR: { raise: -24, bend: 138 }, headTilt: -5 }, hands_on_hips: { arms: { raise: 42, bend: 105 } }, - cross_arms: { arms: { raise: 22, bend: 128 } }, + cross_arms: { arms: { raise: 24, bend: 128 } }, facepalm: { armR: { raise: 125, bend: -103 }, headNod: 0.5, headTilt: 8 }, - cover_mouth: { armR: { raise: -60, bend: 119 } }, + cover_mouth: { armR: { raise: -34, bend: 130 } }, defend: { arms: { raise: 62, bend: 118 }, lean: -4 }, - reach: { armR: { raise: 70, bend: -10 }, lean: 6 }, + 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: 51, bend: 99 } }, + 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: 17, bend: 149 } }, + thumbs_up: { armR: { raise: 22, bend: 148 } }, } satisfies Record; export type ExpressionName = keyof typeof EXPRESSION_PRESETS;