// Fundos do estilo Cartoon, desenhados num espaço fixo de 1080×1920 (o SVG escala para o tamanho do vídeo). import React from "react"; import { COLORS, FONT_CAPTION, FONT_LABEL, SKY } from "./theme"; import { rng } from "./random"; import { PlaceBackground } from "./places"; import type { ShotSpec, TimeOfDay } from "./spec"; export const W = 1080; export const H = 1920; type SceneProps = { spec: ShotSpec; frame: number; progress: number }; function Sky({ time, seed, frame }: { time: TimeOfDay; seed: number; frame: number }) { const [top, bottom] = SKY[time]; const rand = rng(seed + 7); const stars = time === "day" ? [] : Array.from({ length: 70 }, () => ({ x: rand() * W, y: rand() * H * 0.45, r: 1 + rand() * 2.2, p: rand() * 6 })); return ( <> {stars.map((s, i) => ( ))} {time === "night" && } {time === "dawn" && } {time === "day" && } ); } /** Casa chapada: corpo, telhado, janelas (acesas ou não) e porta. */ export function HouseShape({ x, base, w, h, color, lit, detail = true }: { x: number; base: number; w: number; h: number; color: string; lit?: boolean; detail?: boolean; }) { const roofH = h * 0.42; const win = w * 0.18; const winY = base - h * 0.62; const windowFill = lit ? COLORS.light : COLORS.window; return ( {lit && } {detail && ( <> )} ); } function Street({ spec, frame, progress }: SceneProps) { const time = spec.scene.time ?? "night"; const pan = (spec.camera?.panX ?? 0) * W * progress; const rand = rng(spec.seed); const rows = [ { base: H * 0.43, w: 92, h: 70, gap: 6, color: COLORS.houseFar, depth: 0.25, detail: false }, { base: H * 0.5, w: 150, h: 110, gap: 14, color: COLORS.house[2], depth: 0.5, detail: true }, { base: H * 0.6, w: 250, h: 180, gap: 30, color: COLORS.house[0], depth: 1, detail: true }, ]; return ( {rows.map((row, r) => { const count = Math.ceil((W * 1.6) / (row.w + row.gap)) + 2; const start = -W * 0.3 - pan * row.depth; const litIndex = spec.scene.litHouse && r === 2 ? Math.floor(count / 2) - 1 : -1; return ( {Array.from({ length: count }, (_, i) => { const jitter = (rand() - 0.5) * row.h * 0.18; return ( ); })} ); })} {Array.from({ length: 9 }, (_, i) => ( ))} ); } function HouseFront({ spec, frame }: SceneProps) { const time = spec.scene.time ?? "night"; const lit = !!spec.scene.litHouse; return ( {Array.from({ length: 13 }, (_, i) => ( ))} ); } function Plain({ spec, frame }: SceneProps) { const time = spec.scene.time ?? "night"; return ( ); } function Blueprint() { return ( {Array.from({ length: 28 }, (_, i) => )} {Array.from({ length: 49 }, (_, i) => )} ); } function Card({ spec }: SceneProps) { const card = spec.card!; return (
{card.title}
{card.subtitle &&
{card.subtitle}
} {card.footer &&
{card.footer}
}
); } export function SceneBackground(props: SceneProps) { switch (props.spec.scene.kind) { case "place": return ; case "street": return ; case "house": return ; case "blueprint": return ; case "card": return ; default: return ; } }