11import React from "react" ;
22import {
33 AbsoluteFill ,
4+ Img ,
45 interpolate ,
56 spring ,
67 useCurrentFrame ,
@@ -13,12 +14,23 @@ export const HookScene: React.FC<HookSceneProps> = ({
1314 hook,
1415 durationInFrames,
1516 isVertical = false ,
17+ infographicUrl,
1618} ) => {
1719 const frame = useCurrentFrame ( ) ;
1820 const { fps } = useVideoConfig ( ) ;
1921 const fonts = isVertical ? FONT_SIZES . portrait : FONT_SIZES . landscape ;
2022
21- // --- Background pulse animation ---
23+ const hasInfographic = ! ! infographicUrl ;
24+
25+ // --- Ken Burns zoom for infographic background ---
26+ const infographicScale = interpolate (
27+ frame ,
28+ [ 0 , durationInFrames ] ,
29+ [ 1.0 , isVertical ? 1.12 : 1.06 ] ,
30+ { extrapolateLeft : "clamp" , extrapolateRight : "clamp" } ,
31+ ) ;
32+
33+ // --- Background pulse animation (only used when no infographic) ---
2234 const bgPulse = interpolate (
2335 frame ,
2436 [ 0 , durationInFrames ] ,
@@ -75,38 +87,62 @@ export const HookScene: React.FC<HookSceneProps> = ({
7587
7688 return (
7789 < AbsoluteFill style = { { opacity : fadeOut } } >
78- { /* Animated gradient background */ }
79- < AbsoluteFill
80- style = { {
81- background : `linear-gradient(${ bgPulse } deg, ${ COLORS . gradientStart } , ${ COLORS . backgroundDark } , ${ COLORS . primary } )` ,
82- } }
83- />
90+ { /* Background: infographic or animated gradient */ }
91+ { hasInfographic ? (
92+ < AbsoluteFill style = { { overflow : "hidden" } } >
93+ < Img
94+ src = { infographicUrl }
95+ style = { {
96+ width : "100%" ,
97+ height : "100%" ,
98+ objectFit : "cover" ,
99+ transform : `scale(${ infographicScale } )` ,
100+ transformOrigin : "center center" ,
101+ } }
102+ />
103+ { /* Dark overlay for text readability */ }
104+ < AbsoluteFill
105+ style = { {
106+ backgroundColor : "rgba(0, 0, 0, 0.5)" ,
107+ } }
108+ />
109+ </ AbsoluteFill >
110+ ) : (
111+ < >
112+ { /* Animated gradient background */ }
113+ < AbsoluteFill
114+ style = { {
115+ background : `linear-gradient(${ bgPulse } deg, ${ COLORS . gradientStart } , ${ COLORS . backgroundDark } , ${ COLORS . primary } )` ,
116+ } }
117+ />
84118
85- { /* Decorative circles */ }
86- < div
87- style = { {
88- position : "absolute" ,
89- top : isVertical ? "15%" : "10%" ,
90- right : isVertical ? "-10%" : "-5%" ,
91- width : isVertical ? 300 : 500 ,
92- height : isVertical ? 300 : 500 ,
93- borderRadius : "50%" ,
94- background : `radial-gradient(circle, ${ COLORS . secondary } 33, transparent)` ,
95- transform : `scale(${ interpolate ( frame , [ 0 , 60 ] , [ 0.5 , 1.2 ] , { extrapolateRight : "clamp" } ) } )` ,
96- } }
97- />
98- < div
99- style = { {
100- position : "absolute" ,
101- bottom : isVertical ? "20%" : "15%" ,
102- left : isVertical ? "-15%" : "-8%" ,
103- width : isVertical ? 250 : 400 ,
104- height : isVertical ? 250 : 400 ,
105- borderRadius : "50%" ,
106- background : `radial-gradient(circle, ${ COLORS . accent } 22, transparent)` ,
107- transform : `scale(${ interpolate ( frame , [ 10 , 70 ] , [ 0.3 , 1 ] , { extrapolateRight : "clamp" } ) } )` ,
108- } }
109- />
119+ { /* Decorative circles */ }
120+ < div
121+ style = { {
122+ position : "absolute" ,
123+ top : isVertical ? "15%" : "10%" ,
124+ right : isVertical ? "-10%" : "-5%" ,
125+ width : isVertical ? 300 : 500 ,
126+ height : isVertical ? 300 : 500 ,
127+ borderRadius : "50%" ,
128+ background : `radial-gradient(circle, ${ COLORS . secondary } 33, transparent)` ,
129+ transform : `scale(${ interpolate ( frame , [ 0 , 60 ] , [ 0.5 , 1.2 ] , { extrapolateRight : "clamp" } ) } )` ,
130+ } }
131+ />
132+ < div
133+ style = { {
134+ position : "absolute" ,
135+ bottom : isVertical ? "20%" : "15%" ,
136+ left : isVertical ? "-15%" : "-8%" ,
137+ width : isVertical ? 250 : 400 ,
138+ height : isVertical ? 250 : 400 ,
139+ borderRadius : "50%" ,
140+ background : `radial-gradient(circle, ${ COLORS . accent } 22, transparent)` ,
141+ transform : `scale(${ interpolate ( frame , [ 10 , 70 ] , [ 0.3 , 1 ] , { extrapolateRight : "clamp" } ) } )` ,
142+ } }
143+ />
144+ </ >
145+ ) }
110146
111147 { /* Content container */ }
112148 < AbsoluteFill
0 commit comments