// Base do kit metal-liquido: cores, fontes, curvas e medidas. Todo número visual sai daqui. // Os elementos importam só este arquivo, 'react' e 'remotion'. Nada de fora da pasta do kit. import {continueRender, delayRender} from 'remotion'; import fonteA from './fontes/unbounded-latin.woff2'; import fonteB from './fontes/grotesk-latin.woff2'; // ---------- tela ---------- export const LARGURA = 1080, ALTURA = 1920, FPS = 30; // área segura (Reels/TikTok): o que se lê fica entre estas linhas export const SEGURA = {topo: 168, base: 1330, lado: 96}; export const LARGURA_UTIL = LARGURA - SEGURA.lado * 2; // 888 px // ---------- cor ---------- export const COR = { grafite: '#0C0D12', grafiteClaro: '#1A1D27', cromo1: '#F4F7FC', cromo2: '#C9D0DE', cromo3: '#727A8E', cromo4: '#12141B', lima: '#C8FF3D', gelo: '#8FD3FF', }; /** fundo do cromo: horizonte (céu claro, linha escura, chão claro) */ export const CROMO = `linear-gradient(180deg, ${'#F4F7FC'} 0%, ${'#C9D0DE'} 24%, ${'#727A8E'} 46%, ${'#12141B'} 50%, ${'#8E96AA'} 64%, ${'#F4F7FC'} 100%)`; // ---------- fonte ---------- // Famílias com o prefixo do kit, pra não colidir com outro kit no mesmo estúdio. export const FAM_A = 'ML Unbounded'; export const FONTE_A = '"ML Unbounded", Impact, sans-serif'; export const FAM_B = 'ML Space Grotesk'; export const FONTE_B = '"ML Space Grotesk", system-ui, sans-serif'; // As medidas de texto (caber) só valem depois das fontes: a Montagem espera `esperarFontes()` antes de desenhar. const TOTAL_FONTES = 2; let nProntas = 0; const aguardando: (() => void)[] = []; const marcarFonte = () => {nProntas++; if (nProntas >= TOTAL_FONTES) aguardando.splice(0).forEach((r) => r());}; export const fontesProntas = () => nProntas >= TOTAL_FONTES || typeof document === 'undefined'; export const esperarFontes = () => new Promise((res) => {if (fontesProntas()) res(); else aguardando.push(res);}); if (typeof document !== 'undefined' && !(globalThis as Record).__mlA) { (globalThis as Record).__mlA = true; const hA = delayRender('metal-liquido: ML Unbounded'); new FontFace('ML Unbounded', `url(${fonteA}) format('woff2')`, {weight: '600 900', style: 'normal'}).load() .then((ff) => {document.fonts.add(ff); marcarFonte(); continueRender(hA);}) .catch(() => {marcarFonte(); continueRender(hA);}); } if (typeof document !== 'undefined' && !(globalThis as Record).__mlB) { (globalThis as Record).__mlB = true; const hB = delayRender('metal-liquido: ML Space Grotesk'); new FontFace('ML Space Grotesk', `url(${fonteB}) format('woff2')`, {weight: '500 700', style: 'normal'}).load() .then((ff) => {document.fonts.add(ff); marcarFonte(); continueRender(hB);}) .catch(() => {marcarFonte(); continueRender(hB);}); } // ---------- tempo e curva ---------- export const c01 = (t: number) => Math.max(0, Math.min(1, t)); /** progresso 0..1 de f entre a e b */ export const seg = (f: number, a: number, b: number) => c01((f - a) / (b - a)); /** saída rápida e pouso longo, ≈ cubic-bezier(.2,.8,.2,1) */ export const e5 = (t: number) => 1 - Math.pow(1 - c01(t), 5); /** saída com overshoot (passa de 1 e volta): toda entrada do kit usa esta ou a e5 */ export const ob = (t: number, s = 1.7) => {const x = c01(t) - 1; return 1 + (s + 1) * x * x * x + s * x * x;}; export const lerp = (a: number, b: number, t: number) => a + (b - a) * t; /** pseudo-aleatório estável (0..1) a partir de um inteiro */ export const rnd = (n: number) => {const x = Math.sin(n * 127.1 + 311.7) * 43758.5453; return x - Math.floor(x);}; /** uma batida da trilha do kit em quadros */ export const BATIDA = 15.789; // ---------- medida de texto ---------- let canvas: HTMLCanvasElement | null = null; const cache = new Map(); export const larguraTexto = (texto: string, tamanho: number, fam: string, peso = 800, trackingEm = 0): number => { const chave = `${texto}|${tamanho}|${fam}|${peso}|${trackingEm}`; const c = cache.get(chave); if (c !== undefined) return c; if (typeof document === 'undefined') return texto.length * tamanho * 0.58; canvas = canvas || document.createElement('canvas'); const ctx = canvas.getContext('2d'); if (!ctx) return texto.length * tamanho * 0.58; const fonte = `${peso} ${tamanho}px "${fam}"`; ctx.font = fonte; const w = ctx.measureText(texto).width + texto.length * trackingEm * tamanho; if (fontesProntas() && document.fonts.check(fonte)) cache.set(chave, w); return w; }; /** o maior tamanho até `tamanho` em que o texto cabe em `largura` (nunca palavra cortada) */ export const caber = (texto: string, tamanho: number, fam: string, largura = LARGURA_UTIL, peso = 800, trackingEm = 0) => { const w = larguraTexto(texto, tamanho, fam, peso, trackingEm); return w > largura ? Math.floor(tamanho * (largura / w)) : tamanho; }; /** tira os asteriscos de destaque: "Usar *IA*" -> "Usar IA" */ export const textoLimpo = (t: string) => t.replace(/\*/g, ''); /** corta "a *b* c" em [{t:'a ', d:false}, {t:'b', d:true}, {t:' c', d:false}] */ export const partes = (t: string) => t.split('*').map((p, i) => ({t: p, d: i % 2 === 1})).filter((p) => p.t.length > 0);