Logo Flicker
Logo reveal intro: a fast image flicker that settles on your logo. Images flip across a central card very fast, the flicker decelerates and fades, and the logo and brand name resolve underneath — a strobe of imagery settling onto the mark.
Source
components/kuchi/logo-flicker.tsx
1"use client";23import {4 Easing,5 getRemotionEnvironment,6 Img,7 interpolate,8 staticFile,9 useCurrentFrame,10 useVideoConfig,11} from "remotion";12import {13 resolveFont,14 type KuchiTheme,15 useKuchiTheme,16} from "@/lib/kuchi-ui";1718/**19 * A Marvel-Studios-style flicker reveal: images flip full-screen at a constant20 * fast rate right to the end, then cross-fade — the flicker fading OUT while the21 * logo and brand name fade IN, together, in one move.22 */2324export interface LogoFlickerProps {25 /** The logo mark (simple/monochrome — it resolves over the dark backdrop). */26 logoSrc?: string;27 /** Brand name shown under the logo. */28 brandName?: string;29 /** Image pool the flicker flips through, full-screen. */30 images?: string[];31 /** Frames each image holds — the (constant) flip speed. */32 flipInterval?: number;33 /** Backdrop color. Overrides the design system's `background`. */34 background?: string;35 speed?: number;36 className?: string;37 /** Design-system token overrides. */38 theme?: Partial<KuchiTheme>;39 /**40 * Defaults to `"dark"`: the shipped `logoSrc` is a white mark, so the stage41 * has to be dark for it to read. Pass `"light"` with a dark logo asset.42 */43 mode?: "light" | "dark";44 /**45 * The face this scene paints its words in — a label from `fonts.ts`46 * ("Inter", "Space Grotesk", "Instrument Serif") or a CSS family you have47 * loaded yourself. Unset, the scene keeps the face it was designed around.48 *49 * Overrides `theme.fontFamily`, which is how a brand kit re-skins a whole50 * timeline from one value.51 */52 fontFamily?: string;53}5455const FONT_FAMILY =56 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif';5758/** Sample images. Absolute, because a root-relative default becomes59 * `staticFile()` in a render and 404s in the project this file was just60 * copied into. Pass your own — root-relative or remote, both resolve. */61const DEFAULT_IMAGES = [62 "https://kuchi-media.kalarislabs.com/components/art/art-11.svg",63 "https://kuchi-media.kalarislabs.com/components/art/art-11.svg",64 "https://kuchi-media.kalarislabs.com/components/art/art-02.svg",65 "https://kuchi-media.kalarislabs.com/components/art/art-08.svg",66 "https://kuchi-media.kalarislabs.com/components/art/art-08.svg",67 "https://kuchi-media.kalarislabs.com/components/art/art-07.svg",68 "https://kuchi-media.kalarislabs.com/components/art/art-07.svg",69 "https://kuchi-media.kalarislabs.com/components/art/art-02.svg",70];7172// ─── Timeline (frames @ 30fps; ~3.5s) ──────────────────────────────────────────73/** Default frames per image — the flip speed, held constant to the very end. */74export const FLIP_INTERVAL = 2;75/**76 * The single cross-fade window: the flicker fades OUT and the logo + name fade77 * IN across exactly these frames — simultaneously, not one after the other.78 */79export const FADE_START = 66;80export const FADE_END = 84;8182export const EASE = Easing.bezier(0.2, 0.6, 0.35, 1);83const CLAMP = { extrapolateLeft: "clamp", extrapolateRight: "clamp" } as const;8485/**86 * Which image shows at `frame`. A constant `interval` (no deceleration) and a87 * coprime stride so it hops through the whole pool as it flips.88 */89export function flickerImage(90 frame: number,91 count: number,92 interval: number = FLIP_INTERVAL,93): number {94 const n = Math.max(1, count);95 const step = Math.floor(frame / Math.max(1, interval));96 return (step * 7) % n;97}9899/** Flicker opacity — solid, then fades out across the cross-fade window. */100export function flickerOpacity(frame: number): number {101 return interpolate(frame, [FADE_START, FADE_END], [1, 0], CLAMP);102}103104/** Logo + name opacity — the INVERSE of the flicker, on the SAME window. */105export function revealOpacity(frame: number): number {106 return interpolate(frame, [FADE_START, FADE_END], [0, 1], CLAMP);107}108109/** A small settle on the lockup as it fades in (shared by logo and name). */110export function revealScale(frame: number): number {111 return interpolate(frame, [FADE_START, FADE_END], [0.92, 1], {112 ...CLAMP,113 easing: EASE,114 });115}116117/** Rewrite root-relative assets through staticFile everywhere but the Player. */118function resolveSrc(src: string): string {119 const isLocal = src.startsWith("/") && !src.startsWith("//");120 if (!isLocal || getRemotionEnvironment().isPlayer) return src;121 // A value that already came out of staticFile() carries the static base122 // (`/static-<hash>/…`); running it through again would prefix it twice.123 const base = staticFile("_").slice(0, -2);124 if (base && src.startsWith(`${base}/`)) return src;125 try {126 return staticFile(src.replace(/^\/+/, ""));127 } catch {128 return src;129 }130}131132export function LogoFlicker({133 logoSrc = "https://kuchi-media.kalarislabs.com/components/art/mark-white.svg",134 brandName = "kuchi",135 images = DEFAULT_IMAGES,136 flipInterval = FLIP_INTERVAL,137 background,138 speed = 1,139 className,140 theme,141 mode,142 fontFamily,143}: LogoFlickerProps) {144 const frame = useCurrentFrame() * speed;145 const { width, height } = useVideoConfig();146 const t = useKuchiTheme(theme, mode ?? "dark");147 const face = resolveFont(fontFamily ?? t.fontFamily) ?? FONT_FAMILY;148 const stage = background ?? t.background;149 const short = Math.min(width, height);150 const isRendering = getRemotionEnvironment().isRendering;151152 const flkOpacity = flickerOpacity(frame);153 const reveal = revealOpacity(frame);154 const scale = revealScale(frame);155 const imgIdx = flickerImage(frame, images.length, flipInterval);156157 const logoSize = Math.round(short * 0.15);158 const nameSize = Math.round(short * 0.055);159160 return (161 <div162 className={className}163 style={{164 position: "absolute",165 inset: 0,166 overflow: "hidden",167 backgroundColor: stage,168 fontFamily: face,169 textRendering: "geometricPrecision",170 }}171 >172 {/* Full-screen flicker */}173 {flkOpacity > 0 && (174 <Img175 src={resolveSrc(images[imgIdx] ?? images[0])}176 style={{177 position: "absolute",178 inset: 0,179 width: "100%",180 height: "100%",181 maxWidth: "none",182 objectFit: "cover",183 opacity: flkOpacity,184 ...(isRendering ? {} : { willChange: "opacity" as const }),185 }}186 />187 )}188189 {/* Logo + brand name — fade IN on the same window the flicker fades OUT */}190 {reveal > 0 && (191 <div192 style={{193 position: "absolute",194 inset: 0,195 display: "flex",196 flexDirection: "column",197 alignItems: "center",198 justifyContent: "center",199 gap: Math.round(short * 0.02),200 opacity: reveal,201 transform: `scale(${scale})`,202 transformOrigin: "center center",203 }}204 >205 <Img206 src={resolveSrc(logoSrc)}207 style={{208 width: logoSize,209 height: logoSize,210 maxWidth: "none",211 objectFit: "contain",212 }}213 />214 <div215 style={{216 color: t.foreground,217 fontSize: nameSize,218 fontWeight: 600,219 letterSpacing: "-0.02em",220 }}221 >222 {brandName}223 </div>224 </div>225 )}226 </div>227 );228}






