@guilhermebkel/scenec 0.0.0-stage → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +242 -2
- package/dist/catalog.d.ts +21 -0
- package/dist/catalog.js +35 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +118 -0
- package/dist/data/europe.json +1 -0
- package/dist/drawing/assets.d.ts +8 -0
- package/dist/drawing/assets.js +612 -0
- package/dist/drawing/kits.d.ts +7 -0
- package/dist/drawing/kits.js +92 -0
- package/dist/drawing/person.d.ts +18 -0
- package/dist/drawing/person.js +287 -0
- package/dist/drawing/themes.d.ts +4 -0
- package/dist/drawing/themes.js +45 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +2 -0
- package/dist/modes/map.d.ts +5 -0
- package/dist/modes/map.js +365 -0
- package/dist/modes/plane.d.ts +5 -0
- package/dist/modes/plane.js +716 -0
- package/dist/pipeline/compile.d.ts +2 -0
- package/dist/pipeline/compile.js +581 -0
- package/dist/pipeline/custom.d.ts +2 -0
- package/dist/pipeline/custom.js +120 -0
- package/dist/pipeline/groups.d.ts +2 -0
- package/dist/pipeline/groups.js +189 -0
- package/dist/pipeline/index.d.ts +16 -0
- package/dist/pipeline/index.js +7 -0
- package/dist/pipeline/parse.d.ts +10 -0
- package/dist/pipeline/parse.js +80 -0
- package/dist/protocols/options.d.ts +14 -0
- package/dist/protocols/options.js +1 -0
- package/dist/protocols/scene.d.ts +299 -0
- package/dist/protocols/scene.js +118 -0
- package/dist/protocols/theme.d.ts +25 -0
- package/dist/protocols/theme.js +1 -0
- package/dist/render/check.d.ts +6 -0
- package/dist/render/check.js +10 -0
- package/dist/render/critic.d.ts +1 -0
- package/dist/render/critic.js +235 -0
- package/dist/render/files.d.ts +2 -0
- package/dist/render/files.js +16 -0
- package/dist/render/fonts.d.ts +2 -0
- package/dist/render/fonts.js +4 -0
- package/dist/render/png.d.ts +9 -0
- package/dist/render/png.js +13 -0
- package/dist/render.d.ts +5 -0
- package/dist/render.js +3 -0
- package/dist/schema.d.ts +3 -0
- package/dist/schema.js +6 -0
- package/dist/utils/color.d.ts +5 -0
- package/dist/utils/color.js +35 -0
- package/dist/utils/recolor.d.ts +1 -0
- package/dist/utils/recolor.js +56 -0
- package/dist/utils/sanitize.d.ts +5 -0
- package/dist/utils/sanitize.js +169 -0
- package/dist/utils/suggest.d.ts +1 -0
- package/dist/utils/suggest.js +22 -0
- package/dist/utils/svg.d.ts +2 -0
- package/dist/utils/svg.js +11 -0
- package/fonts/OFL.txt +50 -0
- package/fonts/Poppins-Bold.ttf +0 -0
- package/fonts/Poppins-Medium.ttf +0 -0
- package/fonts/Poppins-Regular.ttf +0 -0
- package/package.json +96 -4
- package/skills/scenec/SKILL.md +46 -0
- package/skills/scenec/recipes/anuncios-variacoes.yaml +58 -0
- package/skills/scenec/recipes/carrossel.yaml +58 -0
- package/skills/scenec/recipes/elearning.yaml +64 -0
- package/skills/scenec/recipes/historia-ilustrada.yaml +48 -0
- package/skills/scenec/recipes/ilustracoes-produto.yaml +44 -0
- package/skills/scenec/recipes/mapas-jornadas.yaml +27 -0
- package/skills/scenec/recipes/reels-explicativo.yaml +41 -0
- package/skills/scenec/recipes/wrapped-personalizado.yaml +64 -0
- package/skills/scenec/references/catalog.md +125 -0
- package/skills/scenec/references/dsl.md +111 -0
- package/skills/scenec/references/fontes.md +8 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const KITS: Record<string, any>;
|
|
2
|
+
export declare function outlineFilter(id: any, r: any, ink: any): string;
|
|
3
|
+
export declare function dropFilter(id: any, s: any): string;
|
|
4
|
+
export declare function innerStroke(art: any, w: any, ink: any): string;
|
|
5
|
+
export declare function hatchDefs(ink: any): string;
|
|
6
|
+
export declare function sceneFilter(kind: any, t: any): string;
|
|
7
|
+
export declare function texture(kind: any, W: any, H: any): string;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Kits de estilo: a mesma cena com outra linguagem visual (não só outra paleta).
|
|
2
|
+
// canvas.kit: flat (padrão) | outline | hatch | riso | paper | sketch
|
|
3
|
+
// Cada kit decide: cores de base, como a luz aparece (gradiente, hachura ou nada), contorno por objeto,
|
|
4
|
+
// filtro de cena inteira e textura por cima (abaixo do texto). Tudo SVG puro, renderizável no resvg.
|
|
5
|
+
export const KITS = {
|
|
6
|
+
flat: { desc: "vetor chapado com luz suave (padrão)" },
|
|
7
|
+
outline: {
|
|
8
|
+
desc: "contorno de desenho animado: borda grossa na silhueta e traço fino por dentro",
|
|
9
|
+
outline: { w: 2.6, inner: 0.9 }, light: { strength: 0.45 },
|
|
10
|
+
},
|
|
11
|
+
hatch: {
|
|
12
|
+
desc: "gravura/HQ: contorno a nanquim, sombras em hachura em vez de gradiente, papel claro",
|
|
13
|
+
outline: { w: 2.4, inner: 1.0 }, light: { mode: "hatch" }, texture: "paper",
|
|
14
|
+
colors: { shadow: "rgba(40,30,30,0.18)" },
|
|
15
|
+
},
|
|
16
|
+
riso: {
|
|
17
|
+
desc: "risografia: poucas tintas vivas, granulado de impressão e registro levemente desalinhado",
|
|
18
|
+
colors: { primary: "#0078BF", accent: "#FF48B0", secondary: "#1F3A93", paper: "#FFF8EC", text: "#1A1F4A", ink: "#1A1F4A" },
|
|
19
|
+
light: { mode: "none" }, scene: "riso",
|
|
20
|
+
},
|
|
21
|
+
paper: {
|
|
22
|
+
desc: "recorte de papel: cada peça com sombra própria e textura de fibra",
|
|
23
|
+
light: { strength: 0.18, casts: false }, drop: true, texture: "fiber",
|
|
24
|
+
},
|
|
25
|
+
sketch: {
|
|
26
|
+
desc: "esboço: cores lavadas como aquarela e linhas de lápis nas bordas",
|
|
27
|
+
light: { mode: "none" }, scene: "sketch", texture: "paper",
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
const n = (v) => (+v).toFixed(3);
|
|
31
|
+
// contorno de silhueta (dilata o alfa e pinta de tinta por baixo do objeto)
|
|
32
|
+
export function outlineFilter(id, r, ink) {
|
|
33
|
+
return `<filter id="${id}" x="-15%" y="-15%" width="130%" height="130%"><feMorphology in="SourceAlpha" operator="dilate" radius="${n(r)}" result="d"/>` +
|
|
34
|
+
`<feFlood flood-color="${ink}"/><feComposite in2="d" operator="in" result="o"/><feMerge><feMergeNode in="o"/><feMergeNode in="SourceGraphic"/></feMerge></filter>`;
|
|
35
|
+
}
|
|
36
|
+
// sombra de recorte de papel
|
|
37
|
+
export function dropFilter(id, s) {
|
|
38
|
+
return `<filter id="${id}" x="-20%" y="-20%" width="140%" height="150%"><feGaussianBlur in="SourceAlpha" stdDeviation="${n(2.2 / s)}"/>` +
|
|
39
|
+
`<feOffset dx="${n(2.5 / s)}" dy="${n(4 / s)}" result="b"/><feFlood flood-color="#2B1D10" flood-opacity="0.42"/><feComposite in2="b" operator="in" result="sh"/>` +
|
|
40
|
+
`<feMerge><feMergeNode in="sh"/><feMergeNode in="SourceGraphic"/></feMerge></filter>`;
|
|
41
|
+
}
|
|
42
|
+
// traço fino por dentro: formas sem stroke ganham contorno; brilhos e transparências ficam sem
|
|
43
|
+
export function innerStroke(art, w, ink) {
|
|
44
|
+
const a = art.replace(/<(rect|path|circle|ellipse|polygon)\b([^>]*?)\/>/g, (m, tag, attrs) => /\bopacity=|fill-opacity=|fill="none"|fill="url\(/.test(attrs) || /\bstroke=/.test(attrs) ? (/\bstroke=/.test(attrs) ? m : `<${tag}${attrs} stroke="none"/>`) : m);
|
|
45
|
+
return `<g stroke="${ink}" stroke-width="${n(w)}" stroke-linejoin="round">${a}</g>`;
|
|
46
|
+
}
|
|
47
|
+
// padrões de hachura (sombra própria e sombra projetada)
|
|
48
|
+
export function hatchDefs(ink) {
|
|
49
|
+
return `<pattern id="hatchP" width="7" height="7" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"><rect x="0" y="0" width="1.5" height="7" fill="${ink}" fill-opacity="0.5"/></pattern>` +
|
|
50
|
+
`<pattern id="hatchC" width="6" height="6" patternUnits="userSpaceOnUse" patternTransform="rotate(-35)"><rect x="0" y="0" width="1.4" height="6" fill="${ink}" fill-opacity="0.42"/><rect x="0" y="0" width="6" height="1.2" fill="${ink}" fill-opacity="0.22"/></pattern>`;
|
|
51
|
+
}
|
|
52
|
+
// filtros de cena inteira
|
|
53
|
+
export function sceneFilter(kind, t) {
|
|
54
|
+
if (kind === "riso") {
|
|
55
|
+
// posteriza (tinta chapada) -> cópia deslocada em rosa multiplicada (registro) -> poros de papel claros
|
|
56
|
+
return `<filter id="kitScene" x="0" y="0" width="100%" height="100%" color-interpolation-filters="sRGB">` +
|
|
57
|
+
`<feComponentTransfer in="SourceGraphic" result="post"><feFuncR type="discrete" tableValues="0.1 0.35 0.6 0.85 1"/><feFuncG type="discrete" tableValues="0.1 0.35 0.6 0.85 1"/><feFuncB type="discrete" tableValues="0.12 0.38 0.62 0.86 1"/></feComponentTransfer>` +
|
|
58
|
+
`<feOffset in="post" dx="2.2" dy="1.4" result="off"/>` +
|
|
59
|
+
// cópia deslocada vira tinta rosa só onde há tinta (alfa = 1 - luminância): áreas claras não mudam
|
|
60
|
+
`<feColorMatrix in="off" type="matrix" values="0 0 0 0 1 0 0 0 0 0.36 0 0 0 0 0.66 -0.2 -0.4 -0.08 0.62 0" result="tint"/>` +
|
|
61
|
+
`<feBlend in="post" in2="tint" mode="multiply" result="reg"/>` +
|
|
62
|
+
`<feTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves="1" seed="7" result="nz"/>` +
|
|
63
|
+
`<feColorMatrix in="nz" type="matrix" values="0 0 0 0 1 0 0 0 0 0.98 0 0 0 0 0.94 0 0 0 -2.4 1.25" result="spk"/>` +
|
|
64
|
+
`<feComposite in="spk" in2="reg" operator="in" result="spk2"/>` +
|
|
65
|
+
`<feMerge><feMergeNode in="reg"/><feMergeNode in="spk2"/></feMerge></filter>`;
|
|
66
|
+
}
|
|
67
|
+
if (kind === "sketch") {
|
|
68
|
+
// cores lavadas + bordas por convolução (laplaciano) desenhadas como grafite
|
|
69
|
+
return `<filter id="kitScene" x="0" y="0" width="100%" height="100%" color-interpolation-filters="sRGB">` +
|
|
70
|
+
`<feColorMatrix in="SourceGraphic" type="saturate" values="0.55" result="ds"/>` +
|
|
71
|
+
`<feComponentTransfer in="ds" result="wash"><feFuncR type="linear" slope="0.58" intercept="0.42"/><feFuncG type="linear" slope="0.58" intercept="0.42"/><feFuncB type="linear" slope="0.58" intercept="0.4"/></feComponentTransfer>` +
|
|
72
|
+
`<feColorMatrix in="SourceGraphic" type="matrix" values="0.3 0.59 0.11 0 0 0.3 0.59 0.11 0 0 0.3 0.59 0.11 0 0 0 0 0 1 0" result="g"/>` +
|
|
73
|
+
`<feConvolveMatrix in="g" order="3" kernelMatrix="-1 -1 -1 -1 8 -1 -1 -1 -1" preserveAlpha="true" result="e1"/>` +
|
|
74
|
+
`<feConvolveMatrix in="g" order="3" kernelMatrix="1 1 1 1 -8 1 1 1 1" preserveAlpha="true" result="e2"/>` +
|
|
75
|
+
`<feComposite in="e1" in2="e2" operator="arithmetic" k2="1" k3="1" result="e"/>` +
|
|
76
|
+
`<feColorMatrix in="e" type="matrix" values="0 0 0 0 0.22 0 0 0 0 0.22 0 0 0 0 0.26 2.2 2.2 2.2 0 0" result="lines"/>` +
|
|
77
|
+
`<feMorphology in="lines" operator="dilate" radius="0.6" result="lines2"/>` +
|
|
78
|
+
`<feMerge><feMergeNode in="wash"/><feMergeNode in="lines2"/></feMerge></filter>`;
|
|
79
|
+
}
|
|
80
|
+
return "";
|
|
81
|
+
}
|
|
82
|
+
// texturas por cima da cena (abaixo do texto)
|
|
83
|
+
export function texture(kind, W, H) {
|
|
84
|
+
if (kind === "paper")
|
|
85
|
+
return `<filter id="kitTex" x="0" y="0" width="100%" height="100%"><feTurbulence type="fractalNoise" baseFrequency="0.75" numOctaves="2" seed="3"/>` +
|
|
86
|
+
`<feColorMatrix type="matrix" values="0 0 0 0 0.45 0 0 0 0 0.4 0 0 0 0 0.33 0 0 0 -1.6 1.05"/></filter><rect width="${W}" height="${H}" filter="url(#kitTex)" opacity="0.05"/>`;
|
|
87
|
+
if (kind === "fiber")
|
|
88
|
+
return `<filter id="kitTex" x="0" y="0" width="100%" height="100%"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="2" seed="5" result="f"/>` +
|
|
89
|
+
`<feTurbulence type="fractalNoise" baseFrequency="0.02" numOctaves="3" seed="11" result="m"/><feComposite in="f" in2="m" operator="arithmetic" k2="0.6" k3="0.4" result="mix"/>` +
|
|
90
|
+
`<feColorMatrix in="mix" type="matrix" values="0 0 0 0 0.42 0 0 0 0 0.36 0 0 0 0 0.28 0.5 0 0 0 -0.12"/></filter><rect width="${W}" height="${H}" filter="url(#kitTex)" opacity="0.55"/>`;
|
|
91
|
+
return "";
|
|
92
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const EXPRESSION_NAMES: string[];
|
|
2
|
+
export declare const POSE_NAMES: {
|
|
3
|
+
standing: string[];
|
|
4
|
+
seated: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare function bodyScale(p?: Record<string, any>): {
|
|
7
|
+
bx: number;
|
|
8
|
+
by: number;
|
|
9
|
+
hs: any;
|
|
10
|
+
};
|
|
11
|
+
export declare function person(p: any, t: any): {
|
|
12
|
+
svg: any;
|
|
13
|
+
hand: number[];
|
|
14
|
+
box: {
|
|
15
|
+
w: number;
|
|
16
|
+
h: number;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
// Personagem riggado. Braços por cinemática inversa (2 ossos): cada pose define só onde
|
|
2
|
+
// ficam as mãos; o cotovelo é calculado. Unidades: pessoa em pé = 100, origem nos pés.
|
|
3
|
+
import { sh } from "../utils/color.js";
|
|
4
|
+
import { SKIN, HAIR } from "./themes.js";
|
|
5
|
+
const r = (n) => Math.round(n * 100) / 100;
|
|
6
|
+
const UPPER = 17, FORE = 16;
|
|
7
|
+
// Alvos das mãos (x>0 = lado direito da imagem) para vista frontal
|
|
8
|
+
const FRONT_POSES = {
|
|
9
|
+
standing: { L: [-15, -46], R: [15, -46] },
|
|
10
|
+
waving: { L: [-15, -46], R: [27, -105], openR: true },
|
|
11
|
+
pointing: { L: [-15, -46], R: [46, -77] },
|
|
12
|
+
presenting: { L: [-15, -46], R: [36, -66], openR: true, bendR: "down" },
|
|
13
|
+
celebrating: { L: [-24, -108], R: [24, -108], openL: true, openR: true },
|
|
14
|
+
holding: { L: [-15, -46], R: [21, -57] },
|
|
15
|
+
hands_on_hips: { L: [-12, -50], R: [12, -50] },
|
|
16
|
+
thinking: { L: [-7, -57], R: [5, -82], bendR: "down" },
|
|
17
|
+
shrugging: { L: [-27, -66], R: [27, -66], openL: true, openR: true },
|
|
18
|
+
walking: { L: [-8, -49], R: [19, -51] },
|
|
19
|
+
phone: { L: [-15, -46], R: [10, -88] },
|
|
20
|
+
};
|
|
21
|
+
export const EXPRESSION_NAMES = ["happy", "neutral", "surprised", "sad", "worried", "angry", "laughing", "wink", "thinking"];
|
|
22
|
+
// Vista lateral sentada (f = 1 olhando para a direita)
|
|
23
|
+
const SIDE_POSES = {
|
|
24
|
+
sitting: [20, -50], typing: [35, -55], reading: [22, -66], drinking: [10, -82],
|
|
25
|
+
};
|
|
26
|
+
export const POSE_NAMES = { standing: Object.keys(FRONT_POSES), seated: Object.keys(SIDE_POSES) };
|
|
27
|
+
// Proporções do corpo. age: child | teen | adult | elder; build: slim | average | broad | heavy;
|
|
28
|
+
// height: multiplicador da altura do corpo (0.85 a 1.15). A cabeça escala menos que o corpo (criança tem cabeça grande).
|
|
29
|
+
const AGE = { child: { bx: 0.8, by: 0.58, hs: 0.93 }, teen: { bx: 0.9, by: 0.86, hs: 0.97 }, adult: { bx: 1, by: 1, hs: 1 }, elder: { bx: 1, by: 0.95, hs: 1 } };
|
|
30
|
+
const BUILD = { slim: 0.88, average: 1, broad: 1.12, heavy: 1.16 };
|
|
31
|
+
export function bodyScale(p = {}) {
|
|
32
|
+
const a = AGE[p.age] || AGE.adult;
|
|
33
|
+
const hk = Math.max(0.8, Math.min(1.2, Number(p.height) || 1));
|
|
34
|
+
return { bx: a.bx * (BUILD[p.build] || 1), by: a.by * hk, hs: a.hs };
|
|
35
|
+
}
|
|
36
|
+
// Para onde os olhos olham: [gx, gy] em -1..1 (gy < 0 = para cima). Aceita palavras ou o vetor já resolvido pelo compilador.
|
|
37
|
+
const LOOK = { left: [-1, 0], right: [1, 0], up: [0, -1], down: [0, 1], "up-left": [-0.8, -0.7], "up-right": [0.8, -0.7], "down-left": [-0.8, 0.7], "down-right": [0.8, 0.7], camera: [0, 0], forward: [0, 0] };
|
|
38
|
+
const POSE_GAZE = { pointing: [1, -0.3], presenting: [0.8, 0], thinking: [-0.5, -0.8], celebrating: [0, -0.5], phone: [0.5, 0.4], holding: [0.5, 0.3],
|
|
39
|
+
reading: [0.5, 0.9], typing: [1, 0.15], drinking: [0.6, 0], sitting: [0.6, 0] };
|
|
40
|
+
function gazeOf(p, pose, f = 1) {
|
|
41
|
+
if (Array.isArray(p.gaze))
|
|
42
|
+
return p.gaze;
|
|
43
|
+
if (typeof p.look === "string" && LOOK[p.look])
|
|
44
|
+
return LOOK[p.look];
|
|
45
|
+
const g = POSE_GAZE[pose];
|
|
46
|
+
return g ? [g[0] * f, g[1]] : [0, 0];
|
|
47
|
+
}
|
|
48
|
+
function ik(S, T, side, bend = "out") {
|
|
49
|
+
let dx = T[0] - S[0], dy = T[1] - S[1];
|
|
50
|
+
let d = Math.hypot(dx, dy);
|
|
51
|
+
const max = UPPER + FORE - 0.01, min = Math.abs(UPPER - FORE) + 0.5;
|
|
52
|
+
if (d > max) {
|
|
53
|
+
dx *= max / d;
|
|
54
|
+
dy *= max / d;
|
|
55
|
+
d = max;
|
|
56
|
+
}
|
|
57
|
+
if (d < min)
|
|
58
|
+
d = min;
|
|
59
|
+
const a = Math.acos((UPPER ** 2 + d ** 2 - FORE ** 2) / (2 * UPPER * d));
|
|
60
|
+
const th = Math.atan2(dy, dx);
|
|
61
|
+
const e1 = [S[0] + UPPER * Math.cos(th + a), S[1] + UPPER * Math.sin(th + a)];
|
|
62
|
+
const e2 = [S[0] + UPPER * Math.cos(th - a), S[1] + UPPER * Math.sin(th - a)];
|
|
63
|
+
const pick = bend === "down" ? (e1[1] > e2[1] ? e1 : e2) : (side * e1[0] > side * e2[0] ? e1 : e2);
|
|
64
|
+
return { E: pick, H: [S[0] + dx, S[1] + dy] };
|
|
65
|
+
}
|
|
66
|
+
// Mão com forma: punho (palma + polegar) ou aberta (palma + dedos em leque + polegar), orientada pelo antebraço.
|
|
67
|
+
function hand(H, skin, open, side, E) {
|
|
68
|
+
const dx = E ? H[0] - E[0] : 0, dy = E ? H[1] - E[1] : 1;
|
|
69
|
+
const ang = (Math.atan2(dy, dx) * 180) / Math.PI;
|
|
70
|
+
// polegar do lado de cima/de dentro: escolhe a perpendicular que aponta para o centro do corpo
|
|
71
|
+
const n = [-dy, dx], toBody = [-H[0], -60 - H[1]];
|
|
72
|
+
const ts = n[0] * toBody[0] + n[1] * toBody[1] >= 0 ? 1 : -1;
|
|
73
|
+
const sk = sh(skin, -0.12);
|
|
74
|
+
const g = (inner) => `<g transform="translate(${r(H[0])} ${r(H[1])}) rotate(${r(ang)})">${inner}</g>`;
|
|
75
|
+
if (!open)
|
|
76
|
+
return g(`<ellipse cx="1.2" cy="${0.9 * ts}" rx="1.9" ry="1.3" fill="${sk}" transform="rotate(${-30 * ts} 1.2 ${0.9 * ts})"/>` +
|
|
77
|
+
`<rect x="-1.2" y="-3.1" width="6.4" height="6.2" rx="3" fill="${skin}"/>` +
|
|
78
|
+
`<ellipse cx="2.4" cy="${2.6 * ts}" rx="2.2" ry="1.25" fill="${skin}" transform="rotate(${-20 * ts} 2.4 ${2.6 * ts})"/>` +
|
|
79
|
+
`<path d="M4.2 -1.6 L4.2 1.6" stroke="${sk}" stroke-width="0.6" stroke-linecap="round"/>`);
|
|
80
|
+
const fingers = [-27, -9, 9, 27].map((a, i) => {
|
|
81
|
+
const len = [2.4, 3.1, 2.9, 2.1][i], rad = (a * Math.PI) / 180;
|
|
82
|
+
return `<path d="M3 ${r(Math.sin(rad) * 1.9)} L${r(3 + Math.cos(rad) * len)} ${r(Math.sin(rad) * (1.9 + len))}" stroke="${skin}" stroke-width="2.25" stroke-linecap="round"/>`;
|
|
83
|
+
}).join("");
|
|
84
|
+
return g(`<ellipse cx="1.3" cy="0" rx="3.7" ry="3.5" fill="${skin}"/>` + fingers +
|
|
85
|
+
`<path d="M0.6 ${2.2 * ts} L1.8 ${5 * ts}" stroke="${skin}" stroke-width="2.3" stroke-linecap="round"/>`);
|
|
86
|
+
}
|
|
87
|
+
function armPath(S, E, H, sleeve, skin, shortSleeve) {
|
|
88
|
+
const base = `fill="none" stroke-linecap="round" stroke-linejoin="round"`;
|
|
89
|
+
if (!shortSleeve)
|
|
90
|
+
return `<path d="M${r(S[0])} ${r(S[1])} L${r(E[0])} ${r(E[1])} L${r(H[0])} ${r(H[1])}" stroke="${sleeve}" ${base} stroke-width="7"/>`;
|
|
91
|
+
const mid = [S[0] + (E[0] - S[0]) * 0.6, S[1] + (E[1] - S[1]) * 0.6];
|
|
92
|
+
return `<path d="M${r(mid[0])} ${r(mid[1])} L${r(E[0])} ${r(E[1])} L${r(H[0])} ${r(H[1])}" stroke="${skin}" ${base} stroke-width="6"/>` +
|
|
93
|
+
`<path d="M${r(S[0])} ${r(S[1])} L${r(mid[0])} ${r(mid[1])}" stroke="${sleeve}" ${base} stroke-width="8"/>`;
|
|
94
|
+
}
|
|
95
|
+
function head(p, t, side, back, gz = [0, 0]) {
|
|
96
|
+
const skin = SKIN[p.skin] || SKIN.medium;
|
|
97
|
+
const hair = HAIR[p.hair_color] || p.hair_color || (p.age === "elder" ? HAIR.gray : HAIR.brown);
|
|
98
|
+
const cx = 0, cy = -91;
|
|
99
|
+
const style = p.hair || "short";
|
|
100
|
+
let backHair = "", front = "";
|
|
101
|
+
if (style === "long") {
|
|
102
|
+
backHair = `<path d="M-12 -93 Q-15 -70 -10 -68 L10 -68 Q15 -70 12 -93 Z" fill="${hair}"/>`;
|
|
103
|
+
front = `<path d="M-12 -92 Q-11 -105 0 -104 Q11 -105 12 -92 Q4 -99 -12 -92 Z" fill="${hair}"/>`;
|
|
104
|
+
}
|
|
105
|
+
else if (style === "bun") {
|
|
106
|
+
backHair = `<circle cx="0" cy="-105" r="6" fill="${hair}"/>`;
|
|
107
|
+
front = `<path d="M-11.5 -92 Q-11 -104 0 -103.5 Q11 -104 11.5 -92 Q2 -100 -11.5 -92 Z" fill="${hair}"/>`;
|
|
108
|
+
}
|
|
109
|
+
else if (style === "curly") {
|
|
110
|
+
front = [[-9, -6], [-4, -10], [2, -11], [8, -8], [11, -2], [-11, 0]].map(([dx, dy]) => `<circle cx="${cx + dx}" cy="${cy + dy}" r="5" fill="${hair}"/>`).join("");
|
|
111
|
+
}
|
|
112
|
+
else if (style === "ponytail") {
|
|
113
|
+
backHair = `<path d="M${-side * 9 - (side ? 0 : 9)} -96 Q${-side * 22 - (side ? 0 : 14)} -86 ${-side * 15 - (side ? 0 : 12)} -72" stroke="${hair}" stroke-width="6" fill="none" stroke-linecap="round"/>`;
|
|
114
|
+
front = `<path d="M-11.5 -92 Q-11 -104 0 -103.5 Q11 -104 11.5 -92 Q2 -100 -11.5 -92 Z" fill="${hair}"/>`;
|
|
115
|
+
}
|
|
116
|
+
else if (style === "short") {
|
|
117
|
+
front = `<path d="M-11 -93 Q-10 -104 1 -103 Q11 -102 11 -94 Q6 -98 -2 -97 Q-7 -96 -11 -93 Z" fill="${hair}"/>`;
|
|
118
|
+
}
|
|
119
|
+
else if (style === "bald") {
|
|
120
|
+
front = "";
|
|
121
|
+
}
|
|
122
|
+
const neck = `<rect x="-3" y="-85" width="6" height="7" fill="${sh(skin, -0.12)}"/>`;
|
|
123
|
+
if (back) {
|
|
124
|
+
// de costas: cabelo cobre a cabeça, sem rosto
|
|
125
|
+
const cover = style === "bald"
|
|
126
|
+
? `<circle cx="0" cy="${cy}" r="11" fill="${skin}"/>`
|
|
127
|
+
: `<circle cx="0" cy="${cy}" r="11" fill="${skin}"/><path d="M-11.3 -88 Q-12 -103 0 -103 Q12 -103 11.3 -88 Q0 -84 -11.3 -88 Z" fill="${hair}"/>` +
|
|
128
|
+
(style === "long" ? `<path d="M-11 -90 Q-13 -70 -9 -68 L9 -68 Q13 -70 11 -90 Z" fill="${hair}"/>` : "") + (style === "bun" ? `<circle cx="0" cy="-104" r="6" fill="${hair}"/>` : "");
|
|
129
|
+
return neck + backHair + cover;
|
|
130
|
+
}
|
|
131
|
+
const expr = p.expr || "happy";
|
|
132
|
+
// de frente, olhar para o lado também desloca o rosto (a cabeça "vira" um pouco)
|
|
133
|
+
const ex = side * 1.8 + (side ? 0 : gz[0] * 1.3);
|
|
134
|
+
const px = gz[0] * 1.1, py = gz[1] * 1.1;
|
|
135
|
+
const eye = (x) => `<circle cx="${r(x + px)}" cy="${r(cy + py)}" r="1.45" fill="${t.ink}"/><circle cx="${r(x + px + 0.45)}" cy="${r(cy + py - 0.5)}" r="0.42" fill="#FFFFFF" opacity="0.85"/>`;
|
|
136
|
+
const eyes = expr === "wink"
|
|
137
|
+
? eye(-4 + ex) + `<path d="M${r(2.4 + ex)} ${cy} Q${r(4 + ex)} ${cy - 1.6} ${r(5.6 + ex)} ${cy}" stroke="${t.ink}" stroke-width="1.1" fill="none" stroke-linecap="round"/>`
|
|
138
|
+
: eye(-4 + ex) + eye(4 + ex);
|
|
139
|
+
const mx = side * 2 + (side ? 0 : gz[0] * 1.3);
|
|
140
|
+
const mouth = expr === "surprised"
|
|
141
|
+
? `<ellipse cx="${mx}" cy="${cy + 5.5}" rx="1.6" ry="2" fill="${t.ink}"/>`
|
|
142
|
+
: expr === "neutral"
|
|
143
|
+
? `<path d="M${mx - 2.5} ${cy + 5.5} L${mx + 2.5} ${cy + 5.5}" stroke="${t.ink}" stroke-width="1.2" stroke-linecap="round"/>`
|
|
144
|
+
: expr === "sad" || expr === "worried" || expr === "angry"
|
|
145
|
+
? `<path d="M${mx - 3} ${cy + 6.5} Q${mx} ${cy + 3.8} ${mx + 3} ${cy + 6.5}" stroke="${t.ink}" stroke-width="1.2" fill="none" stroke-linecap="round"/>`
|
|
146
|
+
: expr === "laughing"
|
|
147
|
+
? `<path d="M${mx - 3.5} ${cy + 4} Q${mx} ${cy + 9.5} ${mx + 3.5} ${cy + 4} Z" fill="${t.ink}"/>`
|
|
148
|
+
: `<path d="M${mx - 3} ${cy + 4.5} Q${mx} ${cy + 7.5} ${mx + 3} ${cy + 4.5}" stroke="${t.ink}" stroke-width="1.2" fill="none" stroke-linecap="round"/>`;
|
|
149
|
+
const brows = expr === "thinking" || expr === "surprised"
|
|
150
|
+
? `<path d="M${-6 + ex} ${cy - 4.5} L${-2 + ex} ${cy - 5.2} M${2 + ex} ${cy - 5.2} L${6 + ex} ${cy - 4.5}" stroke="${hair}" stroke-width="1.1" stroke-linecap="round"/>`
|
|
151
|
+
: expr === "worried"
|
|
152
|
+
? `<path d="M${-6 + ex} ${cy - 4.2} L${-2 + ex} ${cy - 5.6} M${2 + ex} ${cy - 5.6} L${6 + ex} ${cy - 4.2}" stroke="${hair}" stroke-width="1.1" stroke-linecap="round"/>`
|
|
153
|
+
: expr === "angry" ? `<path d="M${-6 + ex} ${cy - 5.6} L${-2 + ex} ${cy - 4} M${2 + ex} ${cy - 4} L${6 + ex} ${cy - 5.6}" stroke="${hair}" stroke-width="1.3" stroke-linecap="round"/>` : "";
|
|
154
|
+
const blush = `<circle cx="${-6.5 + ex}" cy="${cy + 3.5}" r="2" fill="#E9806E" opacity="0.35"/><circle cx="${6.5 + ex}" cy="${cy + 3.5}" r="2" fill="#E9806E" opacity="0.35"/>`;
|
|
155
|
+
const glasses = p.glasses ? `<g stroke="${t.ink}" stroke-width="1" fill="none"><circle cx="${-4 + ex}" cy="${cy}" r="3.2"/><circle cx="${4 + ex}" cy="${cy}" r="3.2"/><path d="M${-0.8 + ex} ${cy} L${0.8 + ex} ${cy}"/></g>` : "";
|
|
156
|
+
const beard = p.beard ? `<path d="M-10 -89 Q-10 -76 0 -76 Q10 -76 10 -89 Q8 -83 ${mx + 4} ${cy + 3} L${mx - 4} ${cy + 3} Q-8 -83 -10 -89 Z" fill="${hair}"/>` : "";
|
|
157
|
+
const lines = p.age === "elder" ? `<path d="M${r(-8.2 + ex)} ${cy - 1.5} l-1.4 -0.6 M${r(8.2 + ex)} ${cy - 1.5} l1.4 -0.6 M${r(-5 + ex)} ${cy - 7.5} L${r(5 + ex)} ${cy - 7.5}" stroke="${sh(skin, -0.25)}" stroke-width="0.6" stroke-linecap="round"/>` : "";
|
|
158
|
+
const ear = side ? `<ellipse cx="${-side * 10}" cy="${cy + 1}" rx="2" ry="3" fill="${sh(skin, -0.08)}"/>` : "";
|
|
159
|
+
return neck + backHair + ear + `<circle cx="${cx}" cy="${cy}" r="11" fill="${skin}"/>` +
|
|
160
|
+
front + beard + lines + eyes + brows + mouth + blush + glasses;
|
|
161
|
+
}
|
|
162
|
+
export function person(p, t) {
|
|
163
|
+
const skin = SKIN[p.skin] || SKIN.medium;
|
|
164
|
+
const top = t[p.shirt] || p.shirt || t.primary;
|
|
165
|
+
const bottomC = t[p.pants] || p.pants || t.secondary;
|
|
166
|
+
const jacket = p.jacket ? (t[p.jacket] || p.jacket) : null;
|
|
167
|
+
const outfit = p.outfit || "tshirt"; // tshirt | sweater | dress
|
|
168
|
+
const bottom = outfit === "dress" ? "dress" : (p.bottom || "pants"); // pants | shorts | skirt
|
|
169
|
+
const shoes = t[p.shoes] || p.shoes || t.ink;
|
|
170
|
+
const pose = p.pose || "standing";
|
|
171
|
+
const gownC = outfit === "gown" ? (t[p.gown] || p.gown || t.ink) : null;
|
|
172
|
+
const sleeve = outfit === "labcoat" ? "#FBFBF8" : gownC || jacket || top;
|
|
173
|
+
const shortSleeve = !jacket && outfit === "tshirt";
|
|
174
|
+
const k = bodyScale(p);
|
|
175
|
+
const shadow = `<ellipse cx="0" cy="0" rx="${r(20 * k.bx)}" ry="3.2" fill="${t.shadow}"/>`;
|
|
176
|
+
const B = (x) => `<g transform="scale(${r(k.bx)} ${r(k.by)})">${x}</g>`;
|
|
177
|
+
const HD = (x, tilt = 0) => `<g transform="translate(0 ${r(-81 * k.by + 81 * k.hs)}) scale(${r(k.hs)}) rotate(${r(tilt)} 0 -82)">${x}</g>`;
|
|
178
|
+
const box = { w: 40 * k.bx, h: 81 * k.by + 27 * k.hs };
|
|
179
|
+
const out = (svg, H) => ({ svg, hand: [H[0] * k.bx, H[1] * k.by], box });
|
|
180
|
+
// ---------- sentado (perfil) ----------
|
|
181
|
+
if (SIDE_POSES[pose] || pose === "sitting_typing") {
|
|
182
|
+
const f = p.facing === "left" ? -1 : 1;
|
|
183
|
+
const T = SIDE_POSES[pose] || SIDE_POSES.typing;
|
|
184
|
+
const legColor = bottom === "pants" ? bottomC : skin;
|
|
185
|
+
let legs = `<path d="M0 -45 L${f * 24} -45 L${f * 24} -4" stroke="${legColor}" stroke-width="11" fill="none" stroke-linejoin="round"/>` +
|
|
186
|
+
`<path d="M${f * 2} -41 L${f * 24} -41" stroke="${sh(legColor, -0.12)}" stroke-width="3" fill="none"/>` +
|
|
187
|
+
`<path d="M${f * 21} -3 L${f * 32} -3 Q${f * 32} -8 ${f * 25} -8 L${f * 21} -8 Z" fill="${shoes}"/>`;
|
|
188
|
+
if (bottom === "shorts")
|
|
189
|
+
legs += `<path d="M0 -45 L${f * 14} -45" stroke="${bottomC}" stroke-width="12" stroke-linecap="butt"/>`;
|
|
190
|
+
if (bottom === "skirt" || bottom === "dress")
|
|
191
|
+
legs += `<path d="M${-f * 6} -52 L${f * 18} -50 L${f * 20} -39 L${-f * 7} -40 Z" fill="${bottom === "dress" ? top : bottomC}"/>`;
|
|
192
|
+
const torsoC = jacket || top;
|
|
193
|
+
const torso = `<rect x="-10" y="-81" width="20" height="40" rx="7" fill="${torsoC}"/>` +
|
|
194
|
+
`<path d="M${-f * 10} -74 Q${-f * 10} -81 ${-f * 4} -81 L${-f * 3} -81 L${-f * 3} -41 L${-f * 10} -41 Z" fill="${sh(torsoC, -0.13)}"/>` +
|
|
195
|
+
(jacket ? `<path d="M${f * 5} -80 L${f * 9} -76 L${f * 9} -44 L${f * 4} -44 Z" fill="${top}"/>` : "");
|
|
196
|
+
// braço de trás (mais escuro) + braço da frente
|
|
197
|
+
const S = [f * 2, -75];
|
|
198
|
+
const back = ik(S, [T[0] * f - f * 4, T[1] + 2], f, "down");
|
|
199
|
+
const front = ik(S, [T[0] * f, T[1]], f, "down");
|
|
200
|
+
const armsBack = armPath(S, back.E, back.H, sh(sleeve, -0.18), sh(skin, -0.15), shortSleeve) + hand(back.H, sh(skin, -0.15), false, f, back.E);
|
|
201
|
+
const armsFront = armPath(S, front.E, front.H, sleeve, skin, shortSleeve) + hand(front.H, skin, false, f, front.E);
|
|
202
|
+
const prop = pose === "reading"
|
|
203
|
+
? `<path d="M${r(front.H[0] - f * 2)} ${r(front.H[1] - 9)} L${r(front.H[0] + f * 8)} ${r(front.H[1] - 6)} L${r(front.H[0] + f * 8)} ${r(front.H[1] + 4)} L${r(front.H[0] - f * 2)} ${r(front.H[1] + 1)} Z" fill="${t.accent}"/>`
|
|
204
|
+
: pose === "drinking" ? `<path d="M${r(front.H[0] + f * 1)} ${r(front.H[1] - 7)} L${r(front.H[0] + f * 9)} ${r(front.H[1] - 7)} L${r(front.H[0] + f * 8)} ${r(front.H[1] + 3)} L${r(front.H[0] + f * 2)} ${r(front.H[1] + 3)} Z" fill="${t.paper}"/>` : "";
|
|
205
|
+
const gz = gazeOf(p, pose, f);
|
|
206
|
+
return out(shadow + B(armsBack + legs + torso) + HD(head(p, t, f, false, gz), f * gz[1] * 7) + B(armsFront + prop), front.H);
|
|
207
|
+
}
|
|
208
|
+
// ---------- em pé (frente ou costas) ----------
|
|
209
|
+
const back = p.view === "back";
|
|
210
|
+
const P = FRONT_POSES[pose] || FRONT_POSES.standing;
|
|
211
|
+
const side = p.facing === "left" ? -1 : p.facing === "right" ? 1 : 0;
|
|
212
|
+
const walk = pose === "walking";
|
|
213
|
+
let legs = "";
|
|
214
|
+
const legC = bottom === "pants" ? bottomC : skin;
|
|
215
|
+
if (walk) {
|
|
216
|
+
legs = `<path d="M-3 -45 L-12 -3" stroke="${legC}" stroke-width="8" stroke-linecap="round"/><path d="M3 -45 L11 -3" stroke="${sh(legC, -0.12)}" stroke-width="8" stroke-linecap="round"/>` +
|
|
217
|
+
`<ellipse cx="-14" cy="-2.5" rx="5.5" ry="2.8" fill="${shoes}"/><ellipse cx="14" cy="-2.5" rx="5.5" ry="2.8" fill="${shoes}"/>`;
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
const lw = bottom === "pants" ? 8 : 6.5;
|
|
221
|
+
legs = `<rect x="${-1 - lw}" y="-47" width="${lw}" height="45" rx="3" fill="${legC}"/><rect x="1" y="-47" width="${lw}" height="45" rx="3" fill="${legC}"/>` +
|
|
222
|
+
`<rect x="${1 + lw * 0.45}" y="-47" width="${lw * 0.55}" height="45" rx="2" fill="${sh(legC, -0.12)}"/>` +
|
|
223
|
+
`<ellipse cx="-5.5" cy="-2.5" rx="5.5" ry="2.8" fill="${shoes}"/><ellipse cx="5.5" cy="-2.5" rx="5.5" ry="2.8" fill="${shoes}"/>`;
|
|
224
|
+
}
|
|
225
|
+
if (bottom === "shorts")
|
|
226
|
+
legs += `<path d="M-11 -47 L11 -47 L12 -30 L1 -30 L0 -36 L-1 -30 L-12 -30 Z" fill="${bottomC}"/><path d="M4 -47 L11 -47 L12 -30 L5 -30 Z" fill="${sh(bottomC, -0.12)}"/>`;
|
|
227
|
+
if (bottom === "skirt")
|
|
228
|
+
legs += `<path d="M-12 -48 L12 -48 L17 -27 L-17 -27 Z" fill="${bottomC}"/><path d="M4 -48 L12 -48 L17 -27 L7 -27 Z" fill="${sh(bottomC, -0.12)}"/>`;
|
|
229
|
+
if (bottom === "dress")
|
|
230
|
+
legs += `<path d="M-12 -48 L12 -48 L18 -24 L-18 -24 Z" fill="${top}"/><path d="M4 -48 L12 -48 L18 -24 L7 -24 Z" fill="${sh(top, -0.12)}"/>`;
|
|
231
|
+
const torsoC = jacket || top;
|
|
232
|
+
const heavy = p.build === "heavy";
|
|
233
|
+
let torso = heavy
|
|
234
|
+
? `<path d="M-13 -74 Q-13 -81 -6 -81 L6 -81 Q13 -81 13 -74 Q18 -58 13 -44 L-13 -44 Q-18 -58 -13 -74 Z" fill="${torsoC}"/>` +
|
|
235
|
+
`<path d="M5 -81 L6 -81 Q13 -81 13 -74 Q18 -58 13 -44 L5 -44 Z" fill="${sh(torsoC, -0.13)}"/>`
|
|
236
|
+
: `<path d="M-13 -74 Q-13 -81 -6 -81 L6 -81 Q13 -81 13 -74 L12 -44 L-12 -44 Z" fill="${torsoC}"/>` +
|
|
237
|
+
`<path d="M5 -81 L6 -81 Q13 -81 13 -74 L12 -44 L5 -44 Z" fill="${sh(torsoC, -0.13)}"/>`;
|
|
238
|
+
if (jacket && !back)
|
|
239
|
+
torso += `<path d="M-5 -81 L5 -81 L3 -45 L-3 -45 Z" fill="${top}"/><path d="M-5 -81 L-1 -70 L-4 -60 M5 -81 L1 -70 L4 -60" stroke="${sh(jacket, -0.25)}" stroke-width="1.2" fill="none"/>`;
|
|
240
|
+
if (!jacket && outfit === "sweater" && !back)
|
|
241
|
+
torso += `<path d="M-6 -81 Q0 -76 6 -81" stroke="${sh(top, -0.25)}" stroke-width="1.5" fill="none"/>`;
|
|
242
|
+
if (outfit === "tshirt" && !jacket && !back)
|
|
243
|
+
torso += `<path d="M-5 -81 Q0 -77 5 -81" fill="${sh(skin, -0.12)}"/>`;
|
|
244
|
+
// beca (gown) e jaleco (labcoat) por cima de tudo
|
|
245
|
+
if (gownC) {
|
|
246
|
+
torso += `<path d="M-13 -76 Q-13 -81 -6 -81 L6 -81 Q13 -81 13 -76 L18 -14 L-18 -14 Z" fill="${gownC}"/><path d="M5 -81 L6 -81 Q13 -81 13 -76 L18 -14 L6 -14 Z" fill="${sh(gownC, -0.15)}"/>` +
|
|
247
|
+
(back ? "" : `<path d="M-6 -81 L-3 -81 L-4 -46 L-7 -46 Z M3 -81 L6 -81 L7 -46 L4 -46 Z" fill="${t[p.stole] || t.accent}"/><path d="M-5 -81 Q0 -74 5 -81" fill="${sh(skin, -0.12)}"/>`);
|
|
248
|
+
}
|
|
249
|
+
if (outfit === "labcoat") {
|
|
250
|
+
const lc = "#FBFBF8";
|
|
251
|
+
torso += `<path d="M-13 -76 Q-13 -81 -6 -81 L6 -81 Q13 -81 13 -76 L15 -27 L-15 -27 Z" fill="${lc}"/><path d="M5 -81 L6 -81 Q13 -81 13 -76 L15 -27 L5 -27 Z" fill="${sh(lc, -0.1)}"/>` +
|
|
252
|
+
(back
|
|
253
|
+
? ""
|
|
254
|
+
: `<path d="M-5 -81 L5 -81 L1 -60 L-1 -60 Z" fill="${top}"/><path d="M0 -60 L0 -27" stroke="${sh(lc, -0.25)}" stroke-width="1"/>` +
|
|
255
|
+
`<rect x="-11" y="-42" width="7" height="6" rx="1" fill="none" stroke="${sh(lc, -0.25)}" stroke-width="1"/><path d="M6 -72 L6 -66" stroke="${t.primary}" stroke-width="1.6"/>`);
|
|
256
|
+
}
|
|
257
|
+
let pack = "";
|
|
258
|
+
if (p.backpack) {
|
|
259
|
+
const bc = t[p.backpack] || (p.backpack === true ? t.accent : p.backpack);
|
|
260
|
+
pack = back ? "" : `<rect x="-16" y="-79" width="32" height="32" rx="7" fill="${sh(bc, -0.2)}"/>`;
|
|
261
|
+
if (back)
|
|
262
|
+
torso += `<rect x="-11" y="-78" width="22" height="30" rx="7" fill="${bc}"/><rect x="-7" y="-62" width="14" height="10" rx="3" fill="${sh(bc, -0.15)}"/>`;
|
|
263
|
+
else
|
|
264
|
+
torso += `<path d="M-8 -81 L-9 -50 M8 -81 L9 -50" stroke="${sh(bc, -0.1)}" stroke-width="2.5" stroke-linecap="round"/>`;
|
|
265
|
+
}
|
|
266
|
+
const hat = p.hat === "grad_cap"
|
|
267
|
+
? `<path d="M-9 -103 L9 -103 L9 -98 Q0 -95 -9 -98 Z" fill="${t.ink}"/><path d="M-18 -103 L0 -110 L18 -103 L0 -96 Z" fill="${t.ink}"/><path d="M-18 -103 L0 -96 L18 -103 L0 -98.5 Z" fill="${sh(t.ink, 0.15)}"/>` +
|
|
268
|
+
`<path d="M0 -103 L13 -102 L14 -93" stroke="${t.accent}" stroke-width="1.3" fill="none"/><circle cx="14" cy="-92" r="1.8" fill="${t.accent}"/>`
|
|
269
|
+
: p.hat === "cap" ? `<path d="M-11 -97 Q-11 -108 0 -108 Q11 -108 11 -97 Z" fill="${t[p.hat_color] || t.primary}"/><path d="M${side >= 0 ? 4 : -18} -98 L${side >= 0 ? 18 : -4} -98 L${side >= 0 ? 16 : -6} -95 L${side >= 0 ? 4 : -4} -95 Z" fill="${sh(t[p.hat_color] || t.primary, -0.2)}"/>` : "";
|
|
270
|
+
const SL = [-12, -76], SR = [12, -76];
|
|
271
|
+
const L = ik(SL, P.L, -1, P.bendL), R = ik(SR, P.R, 1, P.bendR);
|
|
272
|
+
const arms = armPath(SL, L.E, L.H, sleeve, skin, shortSleeve) + hand(L.H, skin, P.openL, -1, L.E) +
|
|
273
|
+
armPath(SR, R.E, R.H, sleeve, skin, shortSleeve) + hand(R.H, skin, P.openR, 1, R.E);
|
|
274
|
+
// braço que cruza o corpo (pensando) vai na frente; demais também na frente do tronco
|
|
275
|
+
const gz = gazeOf(p, pose, side || 1);
|
|
276
|
+
const tilt = side ? side * gz[1] * 6 : gz[0] * 4;
|
|
277
|
+
// bengala (idoso): apoiada na mão esquerda quando ela está em repouso
|
|
278
|
+
const cane = p.cane && Math.abs(P.L[1] + 46) < 6
|
|
279
|
+
? `<path d="M${r(L.H[0] - 1)} ${r(L.H[1] + 2)} L${r(L.H[0] - 4)} -1" stroke="${t.trunk || "#6B4A33"}" stroke-width="2.4" stroke-linecap="round"/>` +
|
|
280
|
+
`<path d="M${r(L.H[0] - 1)} ${r(L.H[1] + 2)} Q${r(L.H[0] + 1)} ${r(L.H[1] - 4)} ${r(L.H[0] + 5)} ${r(L.H[1] - 1)}" stroke="${t.trunk || "#6B4A33"}" stroke-width="2.4" fill="none" stroke-linecap="round"/>`
|
|
281
|
+
: "";
|
|
282
|
+
const phone = pose === "phone" && !back ? `<rect x="${r(R.H[0] - 1.5)}" y="${r(R.H[1] - 8)}" width="4.6" height="8.5" rx="1.2" fill="${t.ink}"/><rect x="${r(R.H[0] - 0.8)}" y="${r(R.H[1] - 7.2)}" width="3.2" height="6.4" rx="0.6" fill="${t.glass || "#BFD7EA"}"/>` : "";
|
|
283
|
+
const svg = back
|
|
284
|
+
? B(legs + torso + arms) + HD(head(p, t, 0, true) + hat)
|
|
285
|
+
: B(legs + pack + torso) + HD(head(p, t, side, false, gz) + hat, tilt) + B(cane + arms + phone);
|
|
286
|
+
return out(shadow + svg, R.H);
|
|
287
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Temas: paletas aplicadas a todos os assets via "slots" de cor.
|
|
2
|
+
export const THEMES = {
|
|
3
|
+
"flat-autumn": {
|
|
4
|
+
skyTop: "#F6E7CF", skyBottom: "#FBEFDD", ground: "#C98B4E", groundDark: "#A86F3A",
|
|
5
|
+
wall: "#F3E3CC", floor: "#D9A86C",
|
|
6
|
+
primary: "#D9643A", secondary: "#3E6E6A", accent: "#F2B134",
|
|
7
|
+
foliage: ["#C8552E", "#E08A2E", "#B8442A"], trunk: "#6B3F26", wood: "#9A5B34", woodDark: "#7A4426",
|
|
8
|
+
ink: "#3A2418", paper: "#FFF8EE", glass: "#BFD9D6", metal: "#7D6B60",
|
|
9
|
+
text: "#3A2418", textOnDark: "#FFF8EE", shadow: "rgba(58,36,24,0.14)",
|
|
10
|
+
},
|
|
11
|
+
"flat-cool": {
|
|
12
|
+
skyTop: "#DCEBF7", skyBottom: "#EEF5FB", ground: "#8CC08A", groundDark: "#6FA56E",
|
|
13
|
+
wall: "#E9EEF4", floor: "#B8C4D1",
|
|
14
|
+
primary: "#3A6FD8", secondary: "#25344F", accent: "#F5A524",
|
|
15
|
+
foliage: ["#4E9E5C", "#6BB36A", "#3D8550"], trunk: "#6E5444", wood: "#B98A5E", woodDark: "#8E6542",
|
|
16
|
+
ink: "#1F2A3D", paper: "#FFFFFF", glass: "#BCD7F2", metal: "#8592A6",
|
|
17
|
+
text: "#1F2A3D", textOnDark: "#FFFFFF", shadow: "rgba(31,42,61,0.13)",
|
|
18
|
+
},
|
|
19
|
+
"night": {
|
|
20
|
+
skyTop: "#141B3A", skyBottom: "#2E3A6E", ground: "#1E2647", groundDark: "#161D38",
|
|
21
|
+
wall: "#2A3360", floor: "#1E2647",
|
|
22
|
+
primary: "#F2C14E", secondary: "#7A86C2", accent: "#FF7A59",
|
|
23
|
+
foliage: ["#2F5A5E", "#38686B", "#26494D"], trunk: "#3A2E3E", wood: "#5A4A63", woodDark: "#43374B",
|
|
24
|
+
ink: "#0E1330", paper: "#F5F1E6", glass: "#FFD97A", metal: "#59618F",
|
|
25
|
+
text: "#F5F1E6", textOnDark: "#F5F1E6", shadow: "rgba(0,0,0,0.25)",
|
|
26
|
+
},
|
|
27
|
+
"warm-cafe": {
|
|
28
|
+
skyTop: "#F4E1D2", skyBottom: "#F4E1D2", ground: "#8C5A3C", groundDark: "#6E452E",
|
|
29
|
+
wall: "#EAD2BE", floor: "#9C6844",
|
|
30
|
+
primary: "#B5482E", secondary: "#2F4A3E", accent: "#E8A93B",
|
|
31
|
+
foliage: ["#4F7A4A", "#628F57", "#3F6640"], trunk: "#5A3B28", wood: "#7A4A2E", woodDark: "#5C3620",
|
|
32
|
+
ink: "#2B1A12", paper: "#FFF6EC", glass: "#F6E2B8", metal: "#3A2B24",
|
|
33
|
+
text: "#2B1A12", textOnDark: "#FFF6EC", shadow: "rgba(43,26,18,0.16)",
|
|
34
|
+
},
|
|
35
|
+
"beach": {
|
|
36
|
+
skyTop: "#7FD0E8", skyBottom: "#D6F1F7", ground: "#F1D49B", groundDark: "#E2BF7E",
|
|
37
|
+
wall: "#FFF", floor: "#F1D49B", sea: "#2FA5C4", seaLight: "#5BC2DA",
|
|
38
|
+
primary: "#F0644B", secondary: "#126E86", accent: "#FFC845",
|
|
39
|
+
foliage: ["#2E9E6B", "#3DB37A", "#24855A"], trunk: "#9A6A3F", wood: "#B07A48", woodDark: "#8A5A32",
|
|
40
|
+
ink: "#0F3A47", paper: "#FFFFFF", glass: "#CFEFF7", metal: "#6D8790",
|
|
41
|
+
text: "#0F3A47", textOnDark: "#FFFFFF", shadow: "rgba(15,58,71,0.15)",
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
export const SKIN = { light: "#F2C9A5", medium: "#D19A6E", tan: "#B87A50", dark: "#7A4B30", deep: "#5A3522" };
|
|
45
|
+
export const HAIR = { black: "#1E1A1A", brown: "#5A3825", blonde: "#E2B45A", red: "#B0462A", gray: "#9C9C9C" };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { compile } from "./pipeline/index.ts";
|
|
2
|
+
export type { CompileResult, LayoutEntry } from "./pipeline/index.ts";
|
|
3
|
+
export { parseScene, SceneError } from "./pipeline/parse.ts";
|
|
4
|
+
export type { ParsedScene } from "./pipeline/parse.ts";
|
|
5
|
+
export type { Scene } from "./protocols/scene.ts";
|
|
6
|
+
export type { BBox, CompileOptions, FileReader } from "./protocols/options.ts";
|
package/dist/index.js
ADDED