import React from 'react';
import { AbsoluteFill, Easing, interpolate, random, Series, spring, useCurrentFrame, useVideoConfig } from 'remotion';
const palette = { ink: '#0c1423', pale: '#eaf2ff', blue: '#45a4ff', gold: '#f7bd54', navy: '#152945' };
const fade = (frame, start, end) => interpolate(frame, [start, end], [0, 1], {
extrapolateLeft: 'clamp', extrapolateRight: 'clamp',
});
const center = (color) => ({display:'flex',alignItems:'center',justifyContent:'center',color,
fontFamily:'Segoe UI, Arial, sans-serif', backgroundColor:palette.ink});
const Spark = ({ index, progress }) => {
const angle = random('lighthouse-angle-' + index) * Math.PI * 2;
const ray = 100 + random('lighthouse-ray-' + index) * 650;
const distance = progress * ray;
return <span style={{position:'absolute', left:960 + Math.cos(angle)*distance,
top:515 + Math.sin(angle)*distance, background:palette.gold, borderRadius:10, width:13, height:13,
opacity:1-progress}} />;
};
export function LighthouseIntro() {
const frame=useCurrentFrame();
const {fps, durationInFrames}=useVideoConfig();
const rise=spring({frame:Math.max(0,frame-16),fps,config:{damping:15,stiffness:85}});
const spark=fade(frame,22,53);
const flash=1-fade(frame,23,30);
const shutter=fade(frame,3,40)*90;
const titleOpacity=fade(frame,10,25)*(1-fade(frame,durationInFrames-15,durationInFrames-1));
return <AbsoluteFill style={{...center(palette.pale), backgroundImage:'radial-gradient(at 51% 47%, #203b5d, #070c15 72%)'}}>
{frame>=22 && frame<53 && Array.from({length:26},(_,i)=><Spark key={i} index={i} progress={spark}/>)}
{frame>=22 && frame<=53 && <div style={{position:'absolute',left:960,top:515,width:960*spark,height:960*spark,
borderRadius:'50%',border:'7px solid #45a4ff', opacity:(1-spark)*0.65,transform:'translate(-50%, -50%)'}}/>}
<div style={{fontSize:150,fontWeight:800,letterSpacing:10,opacity:titleOpacity,
transform:'translateY(' + (170*(1-rise)) + 'px) scale(' + (0.62+0.38*rise) + ')',
textShadow: '' + (2+12*flash) + 'px 0 #1d87f4, -' + (1+9*flash) + 'px 0 #e8505b, 0 0 '+
(18 + 13*Math.sin(frame/8)) + 'px #67c23a'}}>灯塔计划</div>
{['top','bottom'].map((side)=><div key={side} style={{position:'absolute',[side]:0,left:0,right:0,
height:shutter,background:'#050910'}} />)}
</AbsoluteFill>;
}
export function HarborCounter(){
const frame=useCurrentFrame();
const n=Math.round(interpolate(frame,[0,200],[0,1000000],{
extrapolateRight:'clamp',easing:Easing.out(Easing.cubic),
}));
const bounce=spring({frame:Math.max(0,frame-182),fps:30,config:{damping:11,stiffness:175}});
const scale=1+0.13*fade(frame,182,192)*(1-bounce);
return <AbsoluteFill style={{...center(palette.gold),flexDirection:'column',background:'#152945'}}>
<div style={{fontSize:60,color:palette.pale}}>累计样本</div>
<div style={{fontSize:200, fontVariantNumeric:'tabular-nums',fontWeight:800,transform:'scale('+scale+')'}}>{n.toLocaleString('en-US')}</div>
<div style={{fontSize:80,opacity:fade(frame,200,218)}}>达到一百万</div>
</AbsoluteFill>;
}
const ReleaseScene = () => {
const frame=useCurrentFrame();
const step=Math.min(10,Math.floor(frame/30));
const local=frame%30;
return <AbsoluteFill style={{...center(palette.pale),background:'#0d1117'}}>
<span style={{position:'absolute',right:120,top:100,color:'#fff',background:'#bb2237',
padding:'18px 35px',borderRadius:18,fontWeight:700,fontSize:56}}>NEW</span>
<strong style={{fontSize:320,opacity:fade(local,0,8),
transform:'scale('+(0.8+0.2*fade(local,0,8))+')'}}>{10-step}</strong>
</AbsoluteFill>;
};
export function LaunchCountdown() {
const frame=useCurrentFrame();
return <Series>
<Series.Sequence durationInFrames={330}><ReleaseScene/></Series.Sequence>
<Series.Sequence durationInFrames={120}>
<AbsoluteFill style={{...center(palette.pale),background:palette.navy,
opacity:fade(frame,330,346),fontSize:146,fontWeight:800}}>星港 · 今日发布</AbsoluteFill>
</Series.Sequence>
</Series>;
}
本例需在 Node.js 24、Remotion 4.0.543、React 18.3.1 和本机 Chromium。视频素材由本站原创组件绘制。 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程
运行环境:Node.js 24、Remotion 4.0.543、React 18.3.1 和本机 Chromium。视频素材由本站原创组件绘制。
入口文件:projects/claude-code-remotion/src/scenes.jsx
本地运行步骤快速上手
- 点击上方“保存源码”保存为
scenes.jsx,或下载右侧课程工程包。 - 确认本地已准备 Node.js 24、Remotion 4.0.543、React 18.3.1 和本机 Chromium。视频素材由本站原创组件绘制。。
- 按对应章节命令执行,结合正文核对实际输出。
附件与关联工程包下载
课程关联工程包(登记关联42章) · 含当前章节或实例 · mbskycom202612a3117.zip
课程关联工程包(登记关联1章) · 含当前章节或实例 · mbskycom202612a3142.zip