Cartoon: mãos, membros e cenários novos; elenco de Noé e a Arca
- Mãos com formas e rotações próprias, membros articulados (limbs) e animais. - Elementos de cenário separados (natureza, construções, interiores) e testes de lugares. - Personagens reaproveitáveis de Noé e a Arca (Noé, esposa, Sem, Cam e Jafé) e a fonte Barlow Semi Condensed. - História noe-e-a-arca: pauta, bíblia, roteiro do ep. 1, tomadas Cartoon e montagem. - Montagem: narração mais corrida (tira silêncios longos) e cabeçalho com o número do vídeo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+330
-33
@@ -1,9 +1,13 @@
|
||||
// Camadas por cima da cena: etiqueta, onomatopeia, contador, ondas de som, X vermelho, painel do topo (HUD) e a
|
||||
// legenda palavra por palavra (cada palavra entra pequena e cresce; palavra-chave em amarelo, perigo em vermelho).
|
||||
// Camadas por cima da cena: etiqueta, onomatopeia, ondas de som, X vermelho, painel do topo (HUD), cartão de nome,
|
||||
// cartelas de dado (número grande, lista com caixas, tabela, barra de progresso, grade de quadradinhos) e a legenda
|
||||
// palavra por palavra (cada palavra entra pequena e cresce; palavra-chave maior e em amarelo, perigo em vermelho).
|
||||
//
|
||||
// Tudo é função pura do quadro (mola da Remotion + tempo do spec): o mesmo quadro sai sempre igual.
|
||||
// Tamanhos em `u(n)` = n% da largura de um quadro vertical 9:16 (num quadro mais largo, limita pela altura).
|
||||
import React from "react";
|
||||
import { spring } from "remotion";
|
||||
import { COLORS, FONT_CAPTION, FONT_LABEL, TONE_BG, TONE_FG } from "./theme";
|
||||
import type { ShotSpec, TextItem, Tone, Word } from "./spec";
|
||||
import { COLORS, FONT_CAPTION, FONT_LABEL, FONT_TEXT, TONE_BG, TONE_FG } from "./theme";
|
||||
import { numberOf, type Hud as HudSpec, type TextItem, type TextRow, type Tone, type Word } from "./spec";
|
||||
|
||||
/** 0 → 1 com mola, a partir de `startS` (antes disso, 0). */
|
||||
export function pop(frame: number, fps: number, startS = 0, stiffness = 220): number {
|
||||
@@ -16,6 +20,32 @@ export function shake(frame: number, amp = 3): { x: number; y: number } {
|
||||
return { x: Math.sin(frame * 12.9898) * amp, y: Math.cos(frame * 78.233) * amp * 0.7 };
|
||||
}
|
||||
|
||||
/** 0 → 1 sem mola (desacelera no fim), de `startS` a `startS + durS`: barra enchendo, número contando. */
|
||||
export function ease(frame: number, fps: number, startS: number, durS: number): number {
|
||||
const p = Math.max(0, Math.min(1, (frame / fps - startS) / Math.max(0.01, durS)));
|
||||
return 1 - (1 - p) ** 3;
|
||||
}
|
||||
|
||||
/** Medida proporcional ao quadro: n% da largura de um vertical 9:16. */
|
||||
export const u = (n: number) => `calc(${n.toFixed(3)} * min(1cqw, 0.5625cqh))`;
|
||||
|
||||
/** Cores do grafismo (cartelas, HUD, cartão de nome). */
|
||||
export const UI = {
|
||||
ink: "#151a31",
|
||||
box: "rgba(15,18,30,0.94)",
|
||||
boxEdge: "rgba(150,160,210,0.16)",
|
||||
cell: "#252c48",
|
||||
cream: "#f3efe6",
|
||||
yellow: "#fcc430",
|
||||
red: "#ea4752",
|
||||
redSoft: "#f4646d",
|
||||
green: "#2f9a55",
|
||||
muted: "#c3c8dd",
|
||||
dim: "#7f87a8",
|
||||
track: "#2a3050",
|
||||
};
|
||||
const TONE_TEXT: Record<Tone, string> = { danger: UI.red, info: UI.yellow, ok: "#45c97a" };
|
||||
|
||||
const at = (x: number, y: number): React.CSSProperties => ({ position: "absolute", left: `${x * 100}%`, top: `${y * 100}%` });
|
||||
|
||||
export function TagLabel({ text, tone = "info", size = 3.6 }: { text: string; tone?: Tone; size?: number }) {
|
||||
@@ -28,24 +58,244 @@ export function TagLabel({ text, tone = "info", size = 3.6 }: { text: string; to
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cartão de nome do personagem: cartão creme arredondado, nome grande em letra condensada escura e 1–2 linhas
|
||||
* menores (função, dado). Sem posição nem animação: quem usa posiciona e faz a entrada.
|
||||
*/
|
||||
export function NameCard({ name, lines = [], size = 1 }: { name: string; lines?: string[]; size?: number }) {
|
||||
const s = size;
|
||||
return (
|
||||
<div style={{ display: "inline-block", background: UI.cream, borderRadius: u(2.4 * s), padding: `${u(2.2 * s)} ${u(3.4 * s)} ${u(2.5 * s)}`,
|
||||
boxShadow: `0 ${u(0.9 * s)} 0 rgba(8,10,22,0.34)`, textAlign: "left", whiteSpace: "nowrap" }}>
|
||||
<div style={{ fontFamily: FONT_CAPTION, fontSize: u(6 * s), color: UI.ink, lineHeight: 1.12, letterSpacing: "0.005em" }}>{name.toUpperCase()}</div>
|
||||
{lines.filter((l) => l.trim()).slice(0, 3).map((l, i) => (
|
||||
<div key={i} style={{ fontFamily: FONT_TEXT, fontSize: u(3.3 * s), color: "#1c2138", lineHeight: 1.55, letterSpacing: "0.035em",
|
||||
marginTop: i === 0 ? u(0.3 * s) : 0 }}>
|
||||
{l.toUpperCase()}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Conta o número do texto de 0 até o valor ("R$ 134.273", "-R$ 47.312.904", "297"), mantendo prefixo e sufixo. */
|
||||
export function countUp(value: string, p: number): string {
|
||||
const m = /^(\D*?)(\d{1,3}(?:\.\d{3})+|\d+)(,\d+)?(\D*)$/.exec(value.trim());
|
||||
if (!m || p >= 1) return value;
|
||||
const target = Number(m[2].replace(/\./g, ""));
|
||||
if (target < 10) return value;
|
||||
const n = String(Math.round(target * Math.max(0, p)));
|
||||
const digits = m[2].includes(".") ? n.replace(/\B(?=(\d{3})+(?!\d))/g, ".") : n;
|
||||
return `${m[1]}${digits}${m[3] ?? ""}${m[4]}`;
|
||||
}
|
||||
|
||||
/** Caixa escura arredondada das cartelas flutuantes. */
|
||||
function Box({ s, children, style }: { s: number; children: React.ReactNode; style?: React.CSSProperties }) {
|
||||
return (
|
||||
<div style={{ background: UI.box, borderRadius: u(3 * s), border: `${u(0.22 * s)} solid ${UI.boxEdge}`,
|
||||
boxShadow: `0 ${u(0.8 * s)} 0 rgba(0,0,0,0.3)`, ...style }}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Fundo escuro de tela inteira (cartela "panel"), com leve luz no centro como a referência. */
|
||||
function PanelBackdrop({ k }: { k: number }) {
|
||||
return (
|
||||
<div style={{ position: "absolute", inset: "-4%", opacity: Math.min(1, k * 2.2),
|
||||
background: "radial-gradient(ellipse 62% 42% at 50% 46%, #1d2342 0%, #151a31 55%, #0e1222 100%)" }} />
|
||||
);
|
||||
}
|
||||
|
||||
const label = (size: number, color = UI.muted, spacing = 0.16): React.CSSProperties => ({
|
||||
fontFamily: FONT_TEXT, fontSize: u(size), color, letterSpacing: `${spacing}em`, lineHeight: 1.1, whiteSpace: "nowrap",
|
||||
});
|
||||
|
||||
function StatCard({ t, s, frame, fps }: { t: TextItem; s: number; frame: number; fps: number }) {
|
||||
const atS = t.atS ?? 0;
|
||||
const value = countUp(String(t.value ?? ""), ease(frame, fps, atS + 0.1, 0.9));
|
||||
const inner = (
|
||||
<div style={{ textAlign: "center" }}>
|
||||
{t.text.trim() && <div style={{ ...label(4.4 * s), marginBottom: u(1.2 * s), paddingLeft: "0.16em" }}>{t.text.toUpperCase()}</div>}
|
||||
<div style={{ fontFamily: FONT_CAPTION, fontSize: u(15.5 * s), lineHeight: 1.08, whiteSpace: "nowrap",
|
||||
color: t.tone ? TONE_TEXT[t.tone] : "#ffffff", textShadow: `0 ${u(0.6 * s)} 0 rgba(0,0,0,0.3)` }}>{value.toUpperCase()}</div>
|
||||
</div>
|
||||
);
|
||||
return t.panel ? inner : <Box s={s} style={{ padding: `${u(2.6 * s)} ${u(5 * s)} ${u(2 * s)}` }}>{inner}</Box>;
|
||||
}
|
||||
|
||||
function CounterCard({ t, s, frame, fps }: { t: TextItem; s: number; frame: number; fps: number }) {
|
||||
const value = countUp(String(t.value ?? ""), ease(frame, fps, (t.atS ?? 0) + 0.1, 0.8));
|
||||
return (
|
||||
<Box s={s} style={{ padding: `${u(2.2 * s)} ${u(4.6 * s)} ${u(1.4 * s)}`, textAlign: "center", borderRadius: u(2.8 * s) }}>
|
||||
<div style={{ ...label(3.5 * s, UI.muted, 0.12), paddingLeft: "0.12em" }}>{t.text.toUpperCase()}</div>
|
||||
<div style={{ fontFamily: FONT_CAPTION, fontSize: u(11 * s), color: t.tone ? TONE_TEXT[t.tone] : "#ffffff", lineHeight: 1.12 }}>{value}</div>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
/** Caixa de seleção: vazia (contorno), marcada (verde enche da esquerda e o ✓ se desenha) ou riscada (vermelha com X). */
|
||||
function CheckBox({ state, m, s }: { state: TextRow["state"]; m: number; s: number }) {
|
||||
const side = u(8.2 * s);
|
||||
const fill = state === "crossed" ? UI.red : UI.green;
|
||||
const marked = state === "checked" || state === "crossed";
|
||||
const draw = Math.max(0, Math.min(1, (m - 0.45) / 0.55));
|
||||
return (
|
||||
<div style={{ position: "relative", width: side, height: side, flex: "none", borderRadius: u(1.6 * s), overflow: "hidden",
|
||||
boxSizing: "border-box", border: `${u(0.7 * s)} solid ${marked && m > 0 ? fill : state === "empty" ? "#4d5476" : "#6d7598"}` }}>
|
||||
{marked && m > 0 && <div style={{ position: "absolute", left: 0, top: 0, bottom: 0, width: `${Math.min(1, m * 1.8) * 100}%`, background: fill }} />}
|
||||
{marked && draw > 0 && (
|
||||
<svg viewBox="0 0 100 100" style={{ position: "absolute", inset: "-12%", width: "124%", height: "124%" }}>
|
||||
{state === "checked"
|
||||
? <path d="M27 52 L44 68 L74 34" fill="none" stroke="#fff" strokeWidth={12} strokeLinecap="round" strokeLinejoin="round"
|
||||
strokeDasharray={80} strokeDashoffset={80 * (1 - draw)} />
|
||||
: <g stroke="#fff" strokeWidth={12} strokeLinecap="round">
|
||||
<line x1={34} y1={34} x2={34 + 32 * Math.min(1, draw * 2)} y2={34 + 32 * Math.min(1, draw * 2)} />
|
||||
{draw > 0.5 && <line x1={66} y1={34} x2={66 - 32 * (draw - 0.5) * 2} y2={34 + 32 * (draw - 0.5) * 2} />}
|
||||
</g>}
|
||||
</svg>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ChecklistCard({ t, s, frame, fps }: { t: TextItem; s: number; frame: number; fps: number }) {
|
||||
const atS = t.atS ?? 0;
|
||||
const step = t.stepS ?? 0.5;
|
||||
const items = t.items ?? [];
|
||||
let order = 0;
|
||||
return (
|
||||
<Box s={s} style={{ padding: `${u(5 * s)} ${u(7 * s)} ${u(5 * s)} ${u(6.4 * s)}`, minWidth: u((t.panel ? 84 : 30) * s), boxSizing: "border-box",
|
||||
...(t.panel ? { background: "rgba(9,11,22,0.6)", boxShadow: "none" } : {}) }}>
|
||||
{t.text.trim() && <div style={{ ...label(3.8 * s), marginBottom: u(3 * s) }}>{t.text.toUpperCase()}</div>}
|
||||
{items.map((it, i) => {
|
||||
const kIn = pop(frame, fps, atS + i * 0.07, 260);
|
||||
const marked = it.state === "checked" || it.state === "crossed";
|
||||
// Marcadas e riscadas em sequência, na ordem da lista.
|
||||
const m = marked ? ease(frame, fps, atS + 0.45 + step * order++, 0.38) : 0;
|
||||
const color = it.state === "crossed" && m > 0.5 ? UI.redSoft : marked && m > 0.5 ? "#ffffff" : it.state === "empty" ? UI.dim : UI.muted;
|
||||
return (
|
||||
<div key={i} style={{ display: "flex", alignItems: "center", gap: u(4 * s), marginTop: i ? u(3.3 * s) : 0,
|
||||
opacity: Math.min(1, kIn * 1.6), transform: `translateX(${(1 - kIn) * -6}%)` }}>
|
||||
<CheckBox state={it.state ?? "empty"} m={m} s={s} />
|
||||
<span style={{ ...label(6.1 * s, color, 0.05) }}>{it.text.toUpperCase()}</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
function TableCard({ t, s, frame, fps }: { t: TextItem; s: number; frame: number; fps: number }) {
|
||||
const atS = t.atS ?? 0;
|
||||
const items = t.items ?? [];
|
||||
const hl = t.highlight;
|
||||
const hlK = hl === undefined ? 0 : pop(frame, fps, atS + 0.35 + items.length * 0.1, 200);
|
||||
const hlColor = t.tone === "ok" ? UI.green : t.tone === "info" ? UI.yellow : UI.red;
|
||||
return (
|
||||
<Box s={s} style={{ padding: `${u(3.8 * s)} ${u(3.6 * s)}`, width: u(80 * s), boxSizing: "border-box" }}>
|
||||
{t.text.trim() && <div style={{ ...label(3.8 * s), marginBottom: u(2.2 * s), paddingLeft: u(1.6 * s) }}>{t.text.toUpperCase()}</div>}
|
||||
{items.map((it, i) => {
|
||||
const kIn = pop(frame, fps, atS + 0.1 + i * 0.1, 260);
|
||||
const on = i === hl;
|
||||
const fg = on && hlK > 0.5 ? (t.tone === "info" ? UI.ink : "#ffffff") : "#ffffff";
|
||||
return (
|
||||
<div key={i} style={{ position: "relative", display: "flex", alignItems: "center", gap: u(2.6 * s), padding: `${u(1.5 * s)} ${u(2.2 * s)}`,
|
||||
borderTop: i ? `${u(0.2 * s)} solid rgba(255,255,255,0.07)` : "none", opacity: Math.min(1, kIn * 1.6),
|
||||
transform: `translateY(${(1 - kIn) * 25}%) scale(${on ? 1 + 0.04 * hlK : 1})` }}>
|
||||
{on && <div style={{ position: "absolute", inset: `${u(-0.3 * s)} ${u(-1 * s)}`, borderRadius: u(1.4 * s), background: hlColor, opacity: hlK,
|
||||
boxShadow: `0 ${u(0.5 * s)} 0 rgba(0,0,0,0.3)` }} />}
|
||||
<span style={{ position: "relative", fontFamily: FONT_CAPTION, fontSize: u(4.6 * s), color: on && hlK > 0.5 ? fg : UI.dim, width: u(4.4 * s), lineHeight: 1.15 }}>{i + 1}</span>
|
||||
<span style={{ position: "relative", ...label(5 * s, fg, 0.04), flex: 1, overflow: "hidden", textOverflow: "ellipsis" }}>{it.text.toUpperCase()}</span>
|
||||
{it.value !== undefined && <span style={{ position: "relative", fontFamily: FONT_CAPTION, fontSize: u(5.2 * s), color: fg, lineHeight: 1.15 }}>{it.value.toUpperCase()}</span>}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
function ProgressCard({ t, s, frame, fps }: { t: TextItem; s: number; frame: number; fps: number }) {
|
||||
const target = Math.max(0, Math.min(100, numberOf(t.value)));
|
||||
const f = ease(frame, fps, (t.atS ?? 0) + 0.25, 1.1);
|
||||
const pct = Math.round(target * f);
|
||||
const color = t.tone ? TONE_TEXT[t.tone] : UI.yellow;
|
||||
return (
|
||||
<Box s={s} style={{ padding: `${u(2.6 * s)} ${u(3.6 * s)} ${u(3 * s)}`, width: u(82 * s), boxSizing: "border-box" }}>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline" }}>
|
||||
<span style={{ ...label(4 * s, "#ffffff", 0.12) }}>{t.text.toUpperCase()}</span>
|
||||
<span style={{ fontFamily: FONT_CAPTION, fontSize: u(5.6 * s), color, lineHeight: 1.1 }}>{pct}%</span>
|
||||
</div>
|
||||
<div style={{ marginTop: u(1.6 * s), height: u(2.6 * s), borderRadius: u(1.3 * s), background: UI.track, overflow: "hidden" }}>
|
||||
<div style={{ height: "100%", width: `${target * f}%`, borderRadius: u(1.3 * s), background: color,
|
||||
boxShadow: `inset 0 ${u(0.6 * s)} 0 rgba(255,255,255,0.28)` }} />
|
||||
</div>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
function GridCard({ t, s, frame, fps }: { t: TextItem; s: number; frame: number; fps: number }) {
|
||||
const atS = t.atS ?? 0;
|
||||
const total = Math.max(1, Math.min(40, Math.round(t.total ?? 1)));
|
||||
const filled = Math.max(0, Math.min(total, Math.round(numberOf(t.value) || 0)));
|
||||
const cols = total <= 6 ? total : total <= 24 ? 6 : 8;
|
||||
const side = 7.4 * s;
|
||||
return (
|
||||
<Box s={s} style={{ padding: `${u(3.4 * s)} ${u(4 * s)} ${u(3.2 * s)}` }}>
|
||||
<div style={{ fontFamily: FONT_CAPTION, fontSize: u(6.4 * s), color: "#ffffff", lineHeight: 1.15, marginBottom: u(2.2 * s), whiteSpace: "nowrap" }}>{t.text.toUpperCase()}</div>
|
||||
<div style={{ display: "grid", gridTemplateColumns: `repeat(${cols}, ${u(side)})`, gap: u(1.3 * s) }}>
|
||||
{Array.from({ length: total }, (_, i) => {
|
||||
const k = i < filled ? pop(frame, fps, atS + 0.35 + i * 0.14, 260) : 0;
|
||||
return (
|
||||
<div key={i} style={{ position: "relative", width: u(side), height: u(side), boxSizing: "border-box", borderRadius: u(1 * s),
|
||||
border: `${u(0.45 * s)} solid #3a4166` }}>
|
||||
{k > 0.001 && (
|
||||
<div style={{ position: "absolute", inset: u(-0.45 * s), borderRadius: u(1 * s), background: UI.cream, transform: `scale(${0.4 + 0.6 * k})`,
|
||||
opacity: Math.min(1, k * 1.8), display: "flex", alignItems: "center", justifyContent: "center",
|
||||
fontFamily: FONT_CAPTION, fontSize: u(4.4 * s), color: UI.ink, lineHeight: 1 }}>{i + 1}</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<div style={{ ...label(3.6 * s, UI.yellow, 0.12), marginTop: u(2.4 * s) }}>{filled} DE {total}</div>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
const CARDS = { stat: StatCard, counter: CounterCard, checklist: ChecklistCard, table: TableCard, progress: ProgressCard, grid: GridCard } as const;
|
||||
|
||||
export function TextLayer({ t, frame, fps }: { t: TextItem; frame: number; fps: number }) {
|
||||
const k = pop(frame, fps, t.atS ?? 0);
|
||||
if (k <= 0.001) return null;
|
||||
const base = { ...at(t.x, t.y), transform: `translate(-50%, -50%) rotate(${t.rotate ?? 0}deg) scale(${0.4 + 0.6 * k})`, opacity: Math.min(1, k * 1.4) };
|
||||
if (t.kind === "tag") return <div style={base}><TagLabel text={t.text} tone={t.tone} /></div>;
|
||||
if (t.kind === "counter") {
|
||||
const s = t.size ?? 1;
|
||||
if (t.kind === "namecard") {
|
||||
// Entra deslizando do lado de fora do quadro, com mola.
|
||||
const dir = t.x < 0.5 ? -1 : 1;
|
||||
return (
|
||||
<div style={{ ...base, textAlign: "center", border: "0.35cqw solid #fff", borderRadius: "1.4cqw", padding: "0.8cqw 2.6cqw",
|
||||
background: "rgba(10,12,28,0.85)" }}>
|
||||
<div style={{ fontFamily: FONT_LABEL, fontSize: "2.6cqw", color: "#c9cbe0", letterSpacing: "0.08em" }}>{t.text.toUpperCase()}</div>
|
||||
<div style={{ fontFamily: FONT_CAPTION, fontSize: "8cqw", color: "#fff", lineHeight: 1 }}>{t.value ?? ""}</div>
|
||||
<div style={{ ...at(t.x, t.y), transform: `translate(-50%, -50%) translateX(${dir * (1 - k) * 18}%) scale(${0.82 + 0.18 * k})`,
|
||||
opacity: Math.min(1, k * 1.6) }}>
|
||||
<NameCard name={t.text} lines={t.lines} size={s} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
const s = t.kind === "onomatopoeia" ? shake(frame, 4) : { x: 0, y: 0 };
|
||||
if (t.kind in CARDS) {
|
||||
const Card = CARDS[t.kind as keyof typeof CARDS];
|
||||
return (
|
||||
<>
|
||||
{t.panel && <PanelBackdrop k={k} />}
|
||||
<div style={{ ...at(t.x, t.y), transform: `translate(-50%, -50%) translateY(${(1 - k) * 6}%) scale(${0.8 + 0.2 * k})`, opacity: Math.min(1, k * 1.6) }}>
|
||||
<Card t={t} s={s} frame={frame} fps={fps} />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
const base = { ...at(t.x, t.y), transform: `translate(-50%, -50%) rotate(${t.rotate ?? 0}deg) scale(${0.4 + 0.6 * k})`, opacity: Math.min(1, k * 1.4) };
|
||||
if (t.kind === "tag") return <div style={base}><TagLabel text={t.text} tone={t.tone} /></div>;
|
||||
const sh = t.kind === "onomatopoeia" ? shake(frame, 4) : { x: 0, y: 0 };
|
||||
const color = t.tone === "danger" ? COLORS.danger : t.kind === "big" ? "#ffffff" : COLORS.key;
|
||||
return (
|
||||
<div style={{ ...base, transform: `${base.transform} translate(${s.x}px, ${s.y}px)`, fontFamily: FONT_CAPTION, color,
|
||||
<div style={{ ...base, transform: `${base.transform} translate(${sh.x}px, ${sh.y}px)`, fontFamily: FONT_CAPTION, color,
|
||||
fontSize: t.kind === "big" ? "12cqw" : "9cqw", whiteSpace: "nowrap", WebkitTextStroke: "0.35cqw #121326",
|
||||
paintOrder: "stroke fill", textShadow: "0 0.6cqw 0 rgba(0,0,0,0.35)" }}>
|
||||
{t.text.toUpperCase()}
|
||||
@@ -77,21 +327,61 @@ export function CrossOut({ k }: { k: number }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function Hud({ hud, frame, fps }: { hud: NonNullable<ShotSpec["hud"]>; frame: number; fps: number }) {
|
||||
let clock = hud.clock;
|
||||
if (clock && /^\d{1,2}:\d{2}$/.test(clock) && hud.clockMinutesPerSecond) {
|
||||
const [h, m] = clock.split(":").map(Number);
|
||||
const total = (h * 60 + m + Math.floor((frame / fps) * hud.clockMinutesPerSecond)) % (24 * 60);
|
||||
clock = `${String(Math.floor(total / 60)).padStart(2, "0")}:${String(total % 60).padStart(2, "0")}`;
|
||||
}
|
||||
/** Hora do HUD andando: "10:06" + minutos por segundo de trecho. */
|
||||
export function hudClock(clock: string | undefined, t: number, minutesPerSecond?: number): string | undefined {
|
||||
if (!clock || !/^\d{1,2}:\d{2}$/.test(clock) || !minutesPerSecond) return clock;
|
||||
const [h, m] = clock.split(":").map(Number);
|
||||
const total = (h * 60 + m + Math.floor(t * minutesPerSecond)) % (24 * 60);
|
||||
return `${String(Math.floor(total / 60)).padStart(2, "0")}:${String(total % 60).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
/** Valor do HUD zerado ou negativo ("R$ 0,00", "-12") pede vermelho. */
|
||||
export function hudValueTone(value: string, tone?: Tone): Tone | undefined {
|
||||
if (tone) return tone;
|
||||
const v = value.trim();
|
||||
if (/^[^\d]*-/.test(v)) return "danger";
|
||||
const digits = v.replace(/[^\d]/g, "");
|
||||
return digits && Number(digits) === 0 ? "danger" : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Painel do topo (fixo, sem animação de entrada: continua igual de um trecho para o outro). Esquerda: bloco amarelo
|
||||
* (`badge`) + hora com ponto vermelho sobre fundo escuro e, embaixo, faixa clara com o lugar. Direita, opcional:
|
||||
* rótulo pequeno + valor grande e faixa amarela com a nota.
|
||||
*/
|
||||
export function Hud({ hud, frame, fps }: { hud: HudSpec; frame: number; fps: number }) {
|
||||
const clock = hudClock(hud.clock, frame / fps, hud.clockMinutesPerSecond);
|
||||
const place = hud.place ?? hud.label;
|
||||
const row = u(8);
|
||||
const big: React.CSSProperties = { fontFamily: FONT_CAPTION, fontSize: u(5.8), lineHeight: 1, whiteSpace: "nowrap", paddingTop: u(0.3) };
|
||||
const strip: React.CSSProperties = { ...label(2.5, UI.ink, 0.07), height: u(4.2), display: "flex", alignItems: "center", padding: `0 ${u(2.2)}` };
|
||||
const shadow = `0 ${u(0.55)} 0 rgba(6,8,18,0.6)`;
|
||||
const tone = hud.value ? hudValueTone(hud.value, hud.valueTone) : undefined;
|
||||
return (
|
||||
<div style={{ position: "absolute", top: "5.5%", left: 0, right: 0, display: "flex", justifyContent: "center", alignItems: "center",
|
||||
gap: "1.4cqw", fontFamily: FONT_LABEL }}>
|
||||
<span style={{ background: COLORS.danger, color: "#fff", fontSize: "3.4cqw", padding: "0.2em 0.5em 0.1em", borderRadius: "0.25em" }}>⚡ {hud.badge.toUpperCase()}</span>
|
||||
<span style={{ color: "#fff", fontSize: "4.2cqw" }}>{hud.label.toUpperCase()}</span>
|
||||
{clock && <span style={{ background: "#0d0f1f", color: COLORS.key, fontSize: "3.4cqw", padding: "0.2em 0.45em 0.1em", borderRadius: "0.25em",
|
||||
border: "0.25cqw solid #3a3f6b" }}>{clock}</span>}
|
||||
</div>
|
||||
<>
|
||||
<div style={{ position: "absolute", left: u(4), top: u(4.5), display: "inline-flex", flexDirection: "column", alignItems: "stretch", boxShadow: shadow }}>
|
||||
<div style={{ display: "flex", height: row, background: clock ? "#11141f" : undefined }}>
|
||||
<div style={{ ...big, background: UI.yellow, color: UI.ink, display: "flex", alignItems: "center", padding: `0 ${u(2.2)}` }}>{hud.badge.toUpperCase()}</div>
|
||||
{clock && (
|
||||
<div style={{ ...big, color: "#ffffff", display: "flex", alignItems: "center", gap: u(1.5), padding: `0 ${u(2.4)} 0 ${u(2.2)}` }}>
|
||||
<span style={{ width: u(1.6), height: u(1.6), borderRadius: "50%", background: UI.red, marginTop: u(-0.3) }} />
|
||||
{clock}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{place && <div style={{ ...strip, background: UI.cream }}>{place.toUpperCase()}</div>}
|
||||
</div>
|
||||
{hud.value && (
|
||||
<div style={{ position: "absolute", right: u(4), top: u(4.5), display: "inline-flex", flexDirection: "column", alignItems: "flex-end" }}>
|
||||
<div style={{ display: "flex", height: row, boxShadow: hud.note ? "none" : shadow }}>
|
||||
{hud.valueLabel && <div style={{ ...label(2.5, UI.muted, 0.1), background: UI.cell, display: "flex", alignItems: "center", padding: `0 ${u(1.5)}` }}>{hud.valueLabel.toUpperCase()}</div>}
|
||||
<div style={{ ...big, background: "#11141f", color: tone === "danger" ? UI.redSoft : tone ? TONE_TEXT[tone] : "#ffffff", display: "flex", alignItems: "center",
|
||||
padding: `0 ${u(2.2)}` }}>{hud.value.toUpperCase()}</div>
|
||||
</div>
|
||||
{hud.note && <div style={{ ...strip, background: UI.yellow, boxShadow: shadow }}>{hud.note.toUpperCase()}</div>}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -107,22 +397,29 @@ export function captionChunks(words: Word[]): Word[][] {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
export function Captions({ words, frame, fps, y = 0.665 }: { words: Word[]; frame: number; fps: number; y?: number }) {
|
||||
/**
|
||||
* Legenda: 2–3 palavras grandes em letra condensada branca, contorno e sombra escuros (deslocada para baixo e à
|
||||
* esquerda, como a referência); palavra-chave maior e amarela, perigo vermelho.
|
||||
*/
|
||||
export function Captions({ words, frame, fps, y = 0.8 }: { words: Word[]; frame: number; fps: number; y?: number }) {
|
||||
const t = frame / fps;
|
||||
const chunks = captionChunks(words);
|
||||
const chunk = chunks.find((c, i) => t >= c[0].startS && (i === chunks.length - 1 || t < chunks[i + 1][0].startS));
|
||||
if (!chunk) return null;
|
||||
const last = chunk[chunk.length - 1];
|
||||
if (t > last.endS + 0.6) return null;
|
||||
const ink = "#0f1226";
|
||||
return (
|
||||
<div style={{ position: "absolute", left: "6%", right: "6%", top: `${y * 100}%`, transform: "translateY(-50%)", display: "flex",
|
||||
flexWrap: "wrap", justifyContent: "center", alignItems: "baseline", columnGap: "2.2cqw", fontFamily: FONT_CAPTION, lineHeight: 1.05 }}>
|
||||
<div style={{ position: "absolute", left: "5%", right: "5%", top: `${y * 100}%`, transform: "translateY(-50%)", display: "flex",
|
||||
flexWrap: "wrap", justifyContent: "center", alignItems: "baseline", columnGap: u(2.4), fontFamily: FONT_CAPTION, lineHeight: 1.08 }}>
|
||||
{chunk.filter((w) => t >= w.startS).map((w, i) => {
|
||||
const k = pop(frame, fps, w.startS, 320);
|
||||
const color = w.tone === "danger" ? COLORS.danger : w.tone === "key" ? COLORS.key : "#ffffff";
|
||||
const strong = w.tone === "key" || w.tone === "danger";
|
||||
const color = w.tone === "danger" ? COLORS.danger : w.tone === "key" ? UI.yellow : "#ffffff";
|
||||
return (
|
||||
<span key={i} style={{ fontSize: "8.4cqw", color, transform: `scale(${0.55 + 0.45 * k})`, display: "inline-block",
|
||||
textShadow: "0 0.5cqw 0 rgba(0,0,0,0.55), 0 0 1.4cqw rgba(0,0,0,0.5)" }}>
|
||||
<span key={i} style={{ fontSize: u(strong ? 12.2 : 9.6), color, transform: `scale(${0.55 + 0.45 * k})`, transformOrigin: "50% 80%", display: "inline-block",
|
||||
WebkitTextStroke: `${u(strong ? 1.1 : 0.9)} ${ink}`, paintOrder: "stroke fill",
|
||||
textShadow: `${u(-0.7)} ${u(0.9)} 0 ${ink}, ${u(-0.35)} ${u(0.45)} 0 ${ink}, 0 0 ${u(2)} rgba(0,0,0,0.35)` }}>
|
||||
{w.text.toUpperCase().replace(/[.,;:]$/, "")}
|
||||
</span>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user