@lalalic/markcut 3.2.53 → 3.2.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -408,3 +408,7 @@ mirrors a view-only mobile preview when no ChatGPT thread is bound. Neither
408
408
  path embeds an APNs key or creates its own notification provider. Standalone
409
409
  Markcut compilation without human-review delivery does not require Neo Mobile
410
410
  or Agents Relay.
411
+
412
+ ### Offline schematic routes
413
+
414
+ Use `- map view:route mapType:schematic duration:5 waypoints:[45.4236,-75.7009,"Start";45.4295,-75.7090,"End"]` in a Markcut scene for a deterministic, Google-independent, animated geographic schematic. It labels connections as illustrative (not computed roads or recorded GPS tracks). The renderer accepts verified waypoint coordinates and produces real moving map frames without a web request. For a route chapter in a larger Vlog, render it separately, verify decode/motion, and insert the resulting MP4 into the main film. Other map types still require working provider credentials and render checks.
@@ -0,0 +1,108 @@
1
+ # Shotcraft recipe experiments in Markcut
2
+
3
+ A **12.65-second, 720 × 1280, 30-fps vertical demo** that tests three
4
+ video-shotcraft animation recipes as **native Markcut component scenes**.
5
+ It does not splice pre-rendered Shotcraft gallery movies.
6
+
7
+ ## Ten-scene comparison reel (new)
8
+
9
+ The editable **video-10.md** has **10 sequential scenes**, each driven by
10
+ a **different** Shotcraft shot card, expressed as a working Markcut JSX
11
+ component, not a pre-rendered Gallery clip. The demo uses intentionally
12
+ illustrative scenery rather than pretending to show real user footage.
13
+
14
+ | Scene | Recipe card | Gallery style key | Source frames | What to compare |
15
+ | --- | --- | --- | ---: | --- |
16
+ | 01 PaperTitle | paper-title-card | paper-title-card | 55 | Word-by-word embossed title |
17
+ | 02 Multiplane | depth-layer-moves | multiplane | 165 | Three speeds of parallax |
18
+ | 03 FreezeAnnotate | speed-ramp-freeze | freeze-annotate | 158 | Stop → ink annotation → move |
19
+ | 04 Letterspace | letterspace-materialize | letterspace-materialize | 112 | Simultaneous vector stroke draw |
20
+ | 05 BlurSlide | blur-slide | blur-slide | 120 | Shared blur, rise and opacity |
21
+ | 06 MosaicReframe | mosaic-reframe | mosaic-reframe | 214 | Grid → hero mosaic → waterfall |
22
+ | 07 CardFlip | card-flip-reveal | card-flip-reveal | 150 | 3D flip and distinct reverse side |
23
+ | 08 PageTurn | page-turn-transitions | barn-door-split | 150 | Lit center seam and two door halves |
24
+ | 09 CraneRise | crane-rise-reveal | crane-rise-reveal | 165 | 3× close-up to 1× full layout |
25
+ | 10 GrainDissolve | grain-dissolve | grain-dissolve | 90 | Noise breakup and wordmark reform |
26
+
27
+ The timings and principles were adapted for a vertical personal Vlog:
28
+ they are not pixel-for-pixel reproductions of the widescreen Shotcraft
29
+ references. The full reel has no narration or music to keep attention on
30
+ the animation itself. Its source is video-10.md; showcase-10.md embeds
31
+ the rendered output for phone-hosted preview, which currently cannot
32
+ resolve inline JS imports directly.
33
+
34
+ ~~~sh
35
+ node bin/markcut verify examples/shotcraft-recipes/video-10.md
36
+ node bin/markcut render examples/shotcraft-recipes/video-10.md --output out/shotcraft-ten-scenes.mp4
37
+ node bin/markcut preview examples/shotcraft-recipes/showcase-10.md
38
+ ~~~
39
+
40
+ The original three-scene video.md and showcase.md remain available.
41
+
42
+ ## Examples
43
+
44
+ | Scene | Frames | Shotcraft card + implementation | What to look for |
45
+ | --- | ---: | --- | --- |
46
+ | PaperTitle | 55 | typography/paper-title-card → demos/typography/paper-title-card/PaperTitleCard.tsx | Staggered word-by-word letterpress (4f offset, 9f per word, 1.28× scale and 7px blur), 18f underline, end fade |
47
+ | Multiplane | 165 | camera/depth-layer-moves → demos/camera/depth-layer-moves/MultiplaneReal.tsx | Three layers at 0.35×, 0.7× and 1.4× travel speed, fixed heading, 22f final-card lift |
48
+ | FreezeAnnotate | 158 | rhythm/speed-ramp-freeze → demos/rhythm/speed-ramp-freeze/FreezeAnnotateReal.tsx | Moving shot strip; abrupt 70f freeze; 3f shutter flash, 10f hand-drawn circle, then eased resume |
49
+
50
+ Recipe files live at:
51
+ ~/.agents/skills/video-shotcraft/references/shots/{typography,camera,rhythm}/.
52
+ Exact gallery keys (from gallery/api/library.json) are
53
+ paper-title-card, multiplane, and freeze-annotate.
54
+
55
+ These are **adaptations** of the recipe motion principles for a 9:16 Vlog;
56
+ they are *not* pixel-identical reproductions. Source scenes use built-in
57
+ drawn scenery, not imported footage or the private owner's media. The demo
58
+ has no narration/BGM/SFX so the movement is easier to isolate. A real Vlog
59
+ would substitute Visioner-selected stills/clips and synchronize SFX to
60
+ the rendered frames.
61
+
62
+ ## Run
63
+
64
+ From Markcut's repository root:
65
+
66
+ ~~~sh
67
+ node bin/markcut verify examples/shotcraft-recipes/video.md
68
+ node bin/markcut preview examples/shotcraft-recipes/video.md
69
+ node bin/markcut render examples/shotcraft-recipes/video.md \
70
+ --output out/shotcraft-recipe-demo.mp4
71
+ ffprobe -v error -show_entries stream=width,height,nb_frames \
72
+ -show_entries format=duration -of default=noprint_wrappers=1 \
73
+ out/shotcraft-recipe-demo.mp4
74
+ ~~~
75
+
76
+ The Markdown's JS imports block contains all three React/Remotion
77
+ components; Markcut resolves their imports and exposes them as JSX scene
78
+ nodes. Each scene can be used independently by deleting the other scenes
79
+ while keeping the imports block.
80
+
81
+ ## Preview in ChatGPT / Neo Mobile
82
+
83
+ Preview showcases the already-rendered MP4 using a separate Markcut
84
+ source, **showcase.md**, so the same clip plays on mobile without rebuilding
85
+ React components in the hosted player.
86
+
87
+ The regular desktop CLI renderer supports the custom JS imports used in
88
+ video.md. The current standalone Neo-hosted preview compiler does **not**
89
+ publish its JS imports registry; previewing video.md directly there can
90
+ produce missing JSX. Until that separate hosted capability is implemented,
91
+ use showcase.md for owner-facing playback, and use video.md to edit/re-render
92
+ the original animation.
93
+
94
+ ## What this experiment establishes
95
+
96
+ 1. A Vlog Editor can choose a Shotcraft **shot recipe** and express it
97
+ as an ordinary Markcut component within video.md.
98
+ 2. Effects driven by useCurrentFrame render deterministically in
99
+ Markcut via its shared Remotion runtime; not every Shotcraft recipe
100
+ needs a new Markcut engine primitive.
101
+ 3. Shotcraft is a *motion vocabulary*. The Director should decide
102
+ **why** to use it; the Editor should select and adapt the recipe to
103
+ footage/story and verify playback. Not every shot should be animated.
104
+
105
+ This example also exercises a Markcut CLI correction: custom component
106
+ bundles must be copied into the actual Remotion publicDir and referenced
107
+ by a *relative* import path. A previously absolute-path import produced
108
+ a nominally successful MP4 with 404 component-load errors.
@@ -0,0 +1,32 @@
1
+ # video
2
+ width:720 height:1280 fps:30 layout:series
3
+
4
+ ## PaperTitle
5
+ - video src:assets/shotcraft-ten-scenes.mp4 startFrom:0.000000 endAt:1.833334
6
+
7
+ ## Multiplane
8
+ - video src:assets/shotcraft-ten-scenes.mp4 startFrom:1.833334 endAt:7.333334
9
+
10
+ ## FreezeAnnotate
11
+ - video src:assets/shotcraft-ten-scenes.mp4 startFrom:7.333334 endAt:12.600001
12
+
13
+ ## Letterspace
14
+ - video src:assets/shotcraft-ten-scenes.mp4 startFrom:12.600001 endAt:16.333334
15
+
16
+ ## BlurSlide
17
+ - video src:assets/shotcraft-ten-scenes.mp4 startFrom:16.333334 endAt:20.333334
18
+
19
+ ## MosaicReframe
20
+ - video src:assets/shotcraft-ten-scenes.mp4 startFrom:20.333334 endAt:27.466667
21
+
22
+ ## CardFlip
23
+ - video src:assets/shotcraft-ten-scenes.mp4 startFrom:27.466667 endAt:32.466667
24
+
25
+ ## PageTurn
26
+ - video src:assets/shotcraft-ten-scenes.mp4 startFrom:32.466667 endAt:37.466667
27
+
28
+ ## CraneRise
29
+ - video src:assets/shotcraft-ten-scenes.mp4 startFrom:37.466667 endAt:42.966667
30
+
31
+ ## GrainDissolve
32
+ - video src:assets/shotcraft-ten-scenes.mp4 startFrom:42.966667 endAt:45.966667
@@ -0,0 +1,5 @@
1
+ # video
2
+ width:720 height:1280 fps:30 layout:series
3
+
4
+ ## ShotcraftRecipeShowcase
5
+ - video src:assets/shotcraft-recipe-demo.mp4 duration:12.650667
@@ -0,0 +1,501 @@
1
+ # video
2
+ seed:2210396671
3
+ width:720 height:1280 fps:30 layout:series
4
+
5
+ ## PaperTitle
6
+ - component duration:1.833333 jsx:"<PaperTitleCardDemo />"
7
+
8
+ ## Multiplane
9
+ - component duration:5.5 jsx:"<MultiplaneDemo />"
10
+
11
+ ## FreezeAnnotate
12
+ - component duration:5.266667 jsx:"<FreezeAnnotateDemo />"
13
+
14
+ ## Letterspace
15
+ - component duration:3.7333333333333334 jsx:"<LetterspaceDemo />"
16
+
17
+ ## BlurSlide
18
+ - component duration:4.0 jsx:"<BlurSlideDemo />"
19
+
20
+ ## MosaicReframe
21
+ - component duration:7.133333333333334 jsx:"<MosaicReframeDemo />"
22
+
23
+ ## CardFlip
24
+ - component duration:5.0 jsx:"<CardFlipDemo />"
25
+
26
+ ## PageTurn
27
+ - component duration:5.0 jsx:"<PageTurnDemo />"
28
+
29
+ ## CraneRise
30
+ - component duration:5.5 jsx:"<CraneRiseDemo />"
31
+
32
+ ## GrainDissolve
33
+ - component duration:3.0 jsx:"<GrainDissolveDemo />"
34
+
35
+ ~~~js imports
36
+ import React from 'react';
37
+ import {AbsoluteFill, useCurrentFrame, interpolate, Easing} from 'remotion';
38
+
39
+ // Adapted from video-shotcraft recipe paper-title-card, 55 frames.
40
+ const FONT = "'PingFang SC', 'Noto Sans CJK SC', 'Microsoft YaHei', sans-serif";
41
+ const SERIF = "'Songti SC', 'Noto Serif CJK SC', Georgia, serif";
42
+ const ease = Easing.bezier(0.2, 0.75, 0.3, 1);
43
+ const out = Easing.bezier(0.45, 0, 0.18, 1);
44
+ const bounded = (f, a, b, ev = Easing.linear) => interpolate(f, [a, b], [0, 1], {
45
+ extrapolateLeft: 'clamp', extrapolateRight: 'clamp', easing: ev
46
+ });
47
+ const SWATCH = {paper:'#f4efe5', ink:'#20292a', muted:'#697579', accent:'#b96a49', blue:'#2c637e'};
48
+ const badge = (num, name, light=false) => (
49
+ <div style={{position:'absolute',left:42,top:56,display:'flex',gap:14,alignItems:'center',zIndex:12}}>
50
+ <span style={{width:38,height:38,border:'1px solid '+(light?'#d6dedf':'#879395'),borderRadius:19,
51
+ display:'flex',alignItems:'center',justifyContent:'center',
52
+ fontFamily:FONT,fontSize:16,color:light?'#fff':SWATCH.muted}}>{num}</span>
53
+ <span style={{fontSize:20,fontWeight:600,letterSpacing:2,color:light?'#fff':SWATCH.muted,fontFamily:FONT}}>{name}</span>
54
+ </div>
55
+ );
56
+ const ScenicCard = ({name,kind=0,large=false}) => {
57
+ const palettes=[
58
+ ['#83b0bc','#ddd3bc','#3a5964'],
59
+ ['#a4b4c7','#dbdfd5','#667d7c'],
60
+ ['#bbad92','#e4cba7','#876d60'],
61
+ ['#96b3b1','#dce2d9','#3e6b65']
62
+ ];
63
+ const p=palettes[kind%palettes.length];
64
+ return <div style={{width:'100%',height:'100%',position:'relative',overflow:'hidden',
65
+ background:'linear-gradient(180deg,'+p[0]+' 0%,'+p[1]+' 70%)'}}>
66
+ <svg viewBox="0 0 420 450" preserveAspectRatio="xMidYMid slice" style={{height:'100%',width:'100%',position:'absolute'}}>
67
+ <circle cx={300-kind*35} cy={90+kind*12} r="46" fill="#fff8dc" opacity=".62"/>
68
+ <path d="M0 290 Q90 205 185 265 T420 230 L420 450 L0 450Z" fill={p[2]} opacity=".5"/>
69
+ <path d="M0 345 Q135 270 240 340 T420 315 L420 450 L0 450Z" fill={p[2]} opacity=".75"/>
70
+ <path d="M0 395 Q180 360 420 390 L420 450 L0 450Z" fill="#1f4049" opacity=".8"/>
71
+ {kind%2===0 ? <>
72
+ <path d="M100 375 L115 205 M98 258 L66 235 M112 255 L150 220 M114 300 L170 265" fill="none" stroke="#384d4e" strokeWidth="8" strokeLinecap="round"/>
73
+ <path d="M310 395 L323 150 M321 220 L285 192 M322 260 L360 230" fill="none" stroke="#304c4b" strokeWidth="7" strokeLinecap="round"/>
74
+ </> : <>
75
+ <path d="M20 380 L110 230 L210 380 M105 380 L205 200 L332 380 M234 380 L330 250 L420 380" stroke="#e6dbc7" strokeWidth="8" fill="none" opacity=".7"/>
76
+ <path d="M0 390 Q170 345 420 380" stroke="#f6f0dd" strokeWidth="5" fill="none" opacity=".9"/>
77
+ </>}
78
+ </svg>
79
+ <div style={{position:'absolute',bottom:0,left:0,right:0,padding:large?'28px 26px':'20px 22px',
80
+ background:'linear-gradient(0deg,rgba(15,32,37,.85),transparent)',color:'#fff',fontFamily:FONT,
81
+ fontWeight:650,fontSize:large?39:27}}>{name}</div>
82
+ </div>;
83
+ };
84
+
85
+ export function PaperTitleCardDemo() {
86
+ const f = useCurrentFrame();
87
+ const words = [{t:'给生活',br:true},{t:'加点料',accent:true}];
88
+ const fadeOut=interpolate(f,[47,55],[1,0],{extrapolateLeft:'clamp',extrapolateRight:'clamp'});
89
+ const under=bounded(f,16,34,Easing.bezier(.3,0,.2,1));
90
+ return <AbsoluteFill style={{background:SWATCH.paper,opacity:fadeOut,
91
+ backgroundImage:'radial-gradient(700px 780px at 47% 42%,#fffdf7,transparent 80%)',
92
+ display:'flex',alignItems:'center',justifyContent:'center',fontFamily:SERIF,color:SWATCH.ink}}>
93
+ {badge('01','PAPER TITLE')}
94
+ <div style={{width:625,textAlign:'center',marginTop:-55}}>
95
+ <div style={{fontSize:96,fontWeight:700,lineHeight:1.35,display:'flex',flexWrap:'wrap',
96
+ justifyContent:'center',columnGap:18}}>
97
+ {words.map((w,i)=>{
98
+ const t=bounded(f,4+i*4,13+i*4,ease);
99
+ return <React.Fragment key={i}><span style={{opacity:t,display:'inline-block',
100
+ transform:'scale('+(1.28-.28*t)+')',filter:'blur('+((1-t)*7)+'px)',
101
+ color:w.accent?SWATCH.accent:SWATCH.ink,
102
+ fontStyle:w.accent?'italic':'normal'}}>{w.t}</span>
103
+ {w.br&&<span style={{flexBasis:'100%',height:0}}/>}</React.Fragment>;
104
+ })}
105
+ </div>
106
+ <div style={{height:6,width:220,background:SWATCH.accent,borderRadius:3,margin:'35px auto',
107
+ transform:'scaleX('+under+')'}}/>
108
+ <div style={{fontSize:27,letterSpacing:4,fontFamily:FONT,color:SWATCH.muted,
109
+ opacity:bounded(f,12,25)}}>加拿大 · 周末散步</div>
110
+ </div>
111
+ <div style={{position:'absolute',bottom:72,fontFamily:FONT,fontSize:18,letterSpacing:2,color:SWATCH.muted}}>
112
+ WORD-BY-WORD LETTERPRESS
113
+ </div>
114
+ </AbsoluteFill>;
115
+ }
116
+
117
+ // Adapted from video-shotcraft depth-layer-moves: drive * 0.35 / 0.7 / 1.4, fixed type.
118
+ export function MultiplaneDemo() {
119
+ const f=useCurrentFrame();
120
+ const travel=bounded(f,6,136,out);
121
+ const drive=1030*travel;
122
+ const lift=bounded(f,122,144,Easing.out(Easing.cubic));
123
+ const cards=['清晨的街道','沿着小路走','河边的风景','停下来看看','把日子记下来'];
124
+ return <AbsoluteFill style={{background:'#e5e1d7',overflow:'hidden',fontFamily:FONT}}>
125
+ {badge('02','2.5D PARALLAX')}
126
+ <div style={{position:'absolute',inset:0,overflow:'hidden',opacity:.28,filter:'blur(5px) saturate(.7)',
127
+ transform:'translateX('+(-drive*.35)+'px) scale(1.18)'}}>
128
+ <div style={{position:'absolute',top:0,left:-180,width:1800,height:1280,
129
+ background:'linear-gradient(110deg,#a9b4ab,#ebd8b6 40%,#9db9b7 65%,#d3c9ad)'}}/>
130
+ {Array.from({length:10},(_,i)=><div key={i} style={{position:'absolute',
131
+ left:i*200-50,top:390+(i%3)*30,width:120,height:370,background:'#8b9991',borderRadius:20}} />)}
132
+ </div>
133
+ <div style={{position:'absolute',inset:0,background:'linear-gradient(180deg,rgba(245,242,231,.92),rgba(231,224,209,.7) 70%,rgba(211,197,176,.8))'}}/>
134
+ <div style={{position:'absolute',top:300,left:-316,display:'flex',gap:40,
135
+ transform:'translateX('+(-drive*.7)+'px)'}}>
136
+ {cards.map((name,i)=><div key={name} style={{width:365,height:575,background:'#e7e1d6',
137
+ border:'8px solid #fcf8ed',borderRadius:28,overflow:'hidden',
138
+ transform:i===3?'translateY('+(-18*lift)+'px) scale('+(1+.035*lift)+')':undefined,
139
+ boxShadow:i===3?'0 0 0 '+(4*lift)+'px #b96a49,0 32px 75px rgba(32,41,42,.24)':'0 17px 38px rgba(32,41,42,.18)'}}>
140
+ <ScenicCard name={name} kind={i} large/>
141
+ </div>)}
142
+ </div>
143
+ <div style={{position:'absolute',inset:0,filter:'blur(7px)',opacity:.68,transform:'translateX('+(-drive*1.4)+'px)'}}>
144
+ {['WINTER','WALK','OTTAWA','VLOG'].map((tag,i)=><div key={tag} style={{position:'absolute',
145
+ left:700+i*620,top:860+(i%2)*160,background:i%2?'#2d4c52':'#b96a49',color:'white',
146
+ borderRadius:70,padding:'20px 45px',fontSize:54,whiteSpace:'nowrap'}}>{tag}</div>)}
147
+ </div>
148
+ <div style={{position:'absolute',top:165,left:45,right:45,pointerEvents:'none',zIndex:5}}>
149
+ <div style={{fontSize:70,fontWeight:750,lineHeight:1.14,color:SWATCH.ink,
150
+ textShadow:'0 1px 0 #fff'}}>从街道,<br/>走到河边。</div>
151
+ <div style={{fontSize:27,marginTop:20,color:SWATCH.muted}}>镜头滑行 · 三层视差 · 主角落定</div>
152
+ </div>
153
+ <div style={{position:'absolute',bottom:72,left:45,right:45,fontSize:19,
154
+ color:SWATCH.muted,letterSpacing:1,zIndex:8}}>FAR 0.35× MID 0.7× NEAR 1.4×</div>
155
+ {lift>.01&&<div style={{position:'absolute',right:70,top:910,zIndex:10,
156
+ background:SWATCH.accent,color:'white',padding:'13px 23px',borderRadius:30,
157
+ opacity:lift,transform:'translateY('+((1-lift)*25)+'px)',fontSize:21}}>IN FOCUS</div>}
158
+ </AbsoluteFill>;
159
+ }
160
+
161
+ // Adapted from video-shotcraft speed-ramp-freeze: abrupt 70-frame stop,
162
+ // 3-frame shutter flash, 10-frame pen circle, smootherstep resume.
163
+ export function FreezeAnnotateDemo() {
164
+ const f=useCurrentFrame();
165
+ const freezeStart=43, freezeEnd=113;
166
+ const resume=Math.max(0,Math.min(1,(f-freezeEnd)/25));
167
+ const smooth=resume*resume*resume*(resume*(resume*6-15)+10);
168
+ const sourceFrame=f<freezeStart?f*1.28:f<freezeEnd?freezeStart*1.28:freezeStart*1.28+smooth*52+(f-freezeEnd>25?(f-freezeEnd-25)*1.6:0);
169
+ const x=225-sourceFrame*14;
170
+ const paused=f>=freezeStart&&f<freezeEnd;
171
+ const inkOut=f<freezeEnd-8?1:1-bounded(f,freezeEnd-8,freezeEnd);
172
+ const mark=bounded(f,53,63);
173
+ const note=bounded(f,69,80,Easing.out(Easing.cubic))*inkOut;
174
+ return <AbsoluteFill style={{background:'#edf3f3',overflow:'hidden',fontFamily:FONT}}>
175
+ {badge('03','FREEZE & ANNOTATE')}
176
+ <div style={{position:'absolute',top:170,left:42,fontWeight:800,fontSize:72,lineHeight:1.15,
177
+ color:SWATCH.ink}}>拍到这一刻,<br/><span style={{color:SWATCH.blue}}>停一下。</span></div>
178
+ <div style={{position:'absolute',top:385,left:42,fontSize:25,color:SWATCH.muted}}>流动 → 定格圈注 → 解冻</div>
179
+ <div style={{position:'absolute',top:540,left:0,height:440,display:'flex',gap:26,
180
+ transform:'translateX('+x+'px)'}}>
181
+ {['路口','雪后的公园','河边','日落','回家的路'].map((name,i)=><div key={i}
182
+ style={{width:355,height:430,borderRadius:25,overflow:'hidden',background:'white',
183
+ boxShadow:i===2&&paused?'0 15px 65px rgba(44,99,126,.31)':'0 12px 33px rgba(30,49,53,.17)',
184
+ transform:i===2&&paused?'translateY(-12px) scale(1.04)':undefined,
185
+ opacity:paused&&i!==2?.62:1,filter:paused&&i!==2?'saturate(.5)':'none'}}>
186
+ <ScenicCard name={name} kind={i} large />
187
+ </div>)}
188
+ </div>
189
+ <div style={{position:'absolute',top:500,left:42,right:42,display:'flex',justifyContent:'space-between',
190
+ fontSize:23,fontFamily:'monospace',fontWeight:700,color:paused?SWATCH.blue:SWATCH.accent}}>
191
+ <span>{paused?'❚❚ PAUSED':'● LIVE'}</span>
192
+ <span>{paused?'00:00:01:13':'REC • '+String(Math.floor(f/30)).padStart(2,'0')+':'+String(f%30).padStart(2,'0')}</span>
193
+ </div>
194
+ {paused&&<svg viewBox="0 0 720 1280" style={{position:'absolute',inset:0,zIndex:6,width:'100%',height:'100%',pointerEvents:'none'}}>
195
+ <rect x="142" y="575" width="436" height="370" fill="none" stroke="#2c637e" strokeWidth="4" strokeDasharray="14 13" opacity=".42"/>
196
+ <path d="M155 600 C175 510 535 520 560 660 C610 820 520 970 330 960 C130 965 110 810 155 600"
197
+ fill="none" stroke="#2c637e" strokeWidth="12" strokeLinecap="round"
198
+ strokeDasharray="1450" strokeDashoffset={1450*(1-mark)} opacity={inkOut}/>
199
+ <path d="M560 870 Q620 875 625 970 L604 950 M625 970 L639 945"
200
+ fill="none" stroke="#2c637e" strokeWidth="8" strokeLinecap="round"
201
+ strokeDasharray="200" strokeDashoffset={200*(1-bounded(f,68,77))} opacity={inkOut}/>
202
+ </svg>}
203
+ {paused&&<div style={{position:'absolute',bottom:110,left:60,right:60,opacity:note,
204
+ transform:'translateY('+((1-note)*20)+'px)',textAlign:'center',color:SWATCH.blue,zIndex:8}}>
205
+ <div style={{fontSize:59,fontWeight:800}}>这一帧值得留下</div>
206
+ <div style={{height:7,width:240,background:SWATCH.blue,margin:'16px auto',borderRadius:8}}/>
207
+ <div style={{fontSize:24,marginTop:23,color:SWATCH.muted}}>FREEZE THE MOMENT</div>
208
+ </div>}
209
+ {f>=freezeStart&&f<freezeStart+3&&<div style={{position:'absolute',inset:0,background:'white',
210
+ opacity:(1-(f-freezeStart)/3)*.62,zIndex:11}}/>}
211
+ {!paused&&<div style={{position:'absolute',bottom:70,left:45,fontSize:21,color:SWATCH.muted}}>
212
+ {f<freezeStart?'MOTION →':'→ RESUME'}
213
+ </div>}
214
+ </AbsoluteFill>;
215
+ }
216
+
217
+ // Shotcraft "letterspace-materialize": shared path-length pen progress,
218
+ // large letter spacing, 15f pre-hold and >30f final stillness.
219
+ export function LetterspaceDemo() {
220
+ const f=useCurrentFrame();
221
+ const pen=bounded(f,16,68,Easing.inOut(Easing.cubic));
222
+ const paths=[
223
+ 'M12 18 L46 112 L80 18',
224
+ 'M12 18 L12 112 L83 112',
225
+ 'M47 18 C-12 18 -12 112 47 112 C106 112 106 18 47 18 Z',
226
+ 'M84 43 C65 10 9 11 7 65 C6 126 69 130 84 93 L84 78 L49 78'
227
+ ];
228
+ return <AbsoluteFill style={{background:'linear-gradient(145deg,#182d37 0%,#315767 54%,#b38d76 100%)',
229
+ fontFamily:FONT,color:'#f6eee1',overflow:'hidden'}}>
230
+ <div style={{position:'absolute',left:0,top:550,right:0,height:620,
231
+ background:'linear-gradient(175deg,transparent,rgba(16,27,34,.6))'}}/>
232
+ <svg style={{position:'absolute',width:720,height:650,bottom:0}} viewBox="0 0 720 650">
233
+ <path d="M0 425 L105 340 L205 385 L348 295 L515 395 L600 335 L720 412 L720 650 L0 650Z" fill="#102934" opacity=".55"/>
234
+ <path d="M0 495 L180 408 L330 470 L555 385 L720 460 L720 650 L0 650Z" fill="#143b45" opacity=".7"/>
235
+ <path d="M0 560 Q210 530 365 565 T720 550" stroke="#efe3ca" strokeWidth="3" opacity=".4" fill="none"/>
236
+ </svg>
237
+ {badge('04','LETTERSPACE',true)}
238
+ <svg viewBox="0 0 720 210" style={{position:'absolute',top:420,left:0,width:720,height:210,overflow:'visible'}}>
239
+ {paths.map((d,i)=><path key={i} d={d} transform={'translate('+(105+i*145)+' 0) scale(1.05 1.05)'}
240
+ fill="none" stroke="#f3e9dc" strokeWidth="4.5" strokeLinejoin="round" strokeLinecap="round"
241
+ pathLength={1} strokeDasharray={1} strokeDashoffset={1-pen}
242
+ opacity={.18+.82*pen}/>)}
243
+ </svg>
244
+ <div style={{position:'absolute',top:675,left:0,right:0,textAlign:'center',
245
+ fontSize:32,letterSpacing:6,opacity:bounded(f,64,83),fontWeight:350}}>给生活加点料</div>
246
+ <div style={{position:'absolute',bottom:87,left:0,right:0,textAlign:'center',
247
+ fontSize:19,letterSpacing:4,opacity:bounded(f,74,91)}}>SIMULTANEOUS STROKE REVEAL</div>
248
+ </AbsoluteFill>;
249
+ }
250
+
251
+ // Shotcraft "blur-slide": semantic word groups share identical progress for
252
+ // blur, Y lift and opacity. Secondary text overlaps title entrance.
253
+ export function BlurSlideDemo() {
254
+ const f=useCurrentFrame();
255
+ const words=[['平凡','的','周末'],['也','值得','记录']];
256
+ const parts=['走走','看看','听听风声','再记下来'];
257
+ const main=words.flat();
258
+ let i=0;
259
+ const qw=(word,index,isHero=false)=>{
260
+ const p=bounded(f,10+index*4,32+index*4,Easing.out(Easing.poly(5)));
261
+ return <span key={index} style={{display:'inline-block',opacity:p,
262
+ transform:'translateY('+((1-p)*64)+'px)',filter:'blur('+((1-p)*18)+'px)',
263
+ fontStyle:isHero?'italic':'normal',color:isHero?SWATCH.accent:SWATCH.ink}}>{word}</span>;
264
+ };
265
+ return <AbsoluteFill style={{background:'#f6eee1',fontFamily:SERIF,color:SWATCH.ink,overflow:'hidden'}}>
266
+ {badge('05','BLUR SLIDE')}
267
+ <div style={{position:'absolute',right:-45,top:120,fontFamily:SERIF,fontSize:500,
268
+ color:'rgba(32,41,42,.055)',transform:'translateX('+(-32*bounded(f,0,120))+')'}}>05</div>
269
+ <div style={{position:'absolute',top:338,left:57,right:38}}>
270
+ <div style={{display:'flex',gap:16,flexWrap:'wrap',fontSize:92,fontWeight:680,lineHeight:1.5}}>
271
+ {words[0].map(word=>qw(word,i++))}
272
+ </div>
273
+ <div style={{display:'flex',gap:16,flexWrap:'wrap',fontSize:92,fontWeight:680,lineHeight:1.48}}>
274
+ {words[1].map(word=>qw(word,i++,word==='记录'))}
275
+ </div>
276
+ <div style={{display:'flex',gap:15,flexWrap:'wrap',marginTop:47,fontSize:34,fontFamily:FONT,
277
+ color:SWATCH.muted,maxWidth:585,lineHeight:1.65}}>
278
+ {parts.map((word,j)=>{
279
+ const p=bounded(f,34+j*4,54+j*4,Easing.out(Easing.poly(5)));
280
+ return <span key={j} style={{opacity:p,transform:'translateY('+((1-p)*26)+'px)',
281
+ filter:'blur('+((1-p)*9)+'px)'}}>{word}</span>;
282
+ })}
283
+ </div>
284
+ <div style={{height:2,background:SWATCH.accent,marginTop:45,
285
+ transformOrigin:'left',transform:'scaleX('+bounded(f,72,95)+')'}}/>
286
+ </div>
287
+ <div style={{position:'absolute',bottom:73,left:57,fontSize:19,
288
+ color:SWATCH.muted,fontFamily:FONT,letterSpacing:2}}>WORD STAGGER · BLUR + LIFT + OPACITY</div>
289
+ </AbsoluteFill>;
290
+ }
291
+
292
+ // Shotcraft "mosaic-reframe": 12 independent layout interpolations,
293
+ // A=regular grid, B=feature mosaic, C=diagonal waterfall with hold windows.
294
+ export function MosaicReframeDemo() {
295
+ const f=useCurrentFrame();
296
+ const names=['晨光','脚步','街角','路灯','树影','河流','小桥','晚霞','晴空','林间','远山','归程'];
297
+ const mix=(a,b,t)=>a+(b-a)*t;
298
+ return <AbsoluteFill style={{background:'#dce5df',fontFamily:FONT,overflow:'hidden'}}>
299
+ {badge('06','MOSAIC REFRAME')}
300
+ <div style={{position:'absolute',top:158,left:50,fontSize:63,fontWeight:760,color:'#243c3c'}}>把片段排成故事</div>
301
+ <div style={{position:'absolute',top:239,left:50,fontSize:23,color:SWATCH.muted}}>
302
+ {f<96?'GRID → FEATURE':f<175?'FEATURE → CASCADE':'CASCADE · HOLD'}</div>
303
+ {names.map((name,i)=>{
304
+ const col=i%3,row=Math.floor(i/3);
305
+ const a={x:49+col*207,y:310+row*191,w:194,h:175,rot:0};
306
+ const b=i===0?{x:50,y:305,w:394,h:391,rot:0}
307
+ :i===1?{x:463,y:305,w:206,h:185,rot:0}
308
+ :i===2?{x:463,y:511,w:206,h:185,rot:0}
309
+ :{x:50+((i-3)%3)*207,y:710+Math.floor((i-3)/3)*155,w:194,h:141,rot:0};
310
+ const c={x:20+i*49,y:185+i*80,w:275,h:335,rot:-17+i*2.3};
311
+ const p1=bounded(f,56+i*.7,82+i*.7,Easing.inOut(Easing.cubic));
312
+ const p2=bounded(f,132+i*1.1,162+i*1.1,Easing.inOut(Easing.cubic));
313
+ const trans=k=>mix(mix(a[k],b[k],p1),c[k],p2);
314
+ return <div key={name} style={{position:'absolute',left:trans('x'),top:trans('y'),
315
+ width:trans('w'),height:trans('h'),borderRadius:14,overflow:'hidden',
316
+ border:'5px solid #f9f6ee',boxShadow:'0 10px 25px rgba(30,45,43,.24)',
317
+ transform:'rotate('+trans('rot')+'deg)',zIndex:i+1}}>
318
+ <ScenicCard name={name} kind={i} />
319
+ </div>;
320
+ })}
321
+ </AbsoluteFill>;
322
+ }
323
+
324
+ // Shotcraft "card-flip-reveal": 4f prep -> 16f flip 194deg overshoot
325
+ // -> 12f spring-like settle, staggered 12f, 3D faces and angle-linked shading.
326
+ export function CardFlipDemo() {
327
+ const f=useCurrentFrame();
328
+ const details=[['出发','01','走出去'],['沿途','02','看风景'],['回味','03','再出发']];
329
+ const start=24;
330
+ return <AbsoluteFill style={{background:'linear-gradient(180deg,#19242d 0%,#31434c 65%,#192932 100%)',
331
+ fontFamily:FONT,color:'#f8f2e8',overflow:'hidden'}}>
332
+ {badge('07','CARD FLIP',true)}
333
+ <div style={{position:'absolute',top:165,left:47,right:47,fontWeight:740,fontSize:66}}>把一天,翻成三页。</div>
334
+ <div style={{position:'absolute',top:280,left:48,fontSize:27,color:'#bfc9c5'}}>每张卡片都藏着下一段故事</div>
335
+ {details.map(([front,num,back],i)=>{
336
+ const st=start+12*i;
337
+ const pre=bounded(f,st,st+4,Easing.out(Easing.cubic));
338
+ const flip=bounded(f,st+4,st+20,Easing.bezier(.55,0,.3,1));
339
+ const settle=bounded(f,st+20,st+32,Easing.out(Easing.cubic));
340
+ const angle=f<st+4?-10*pre:f<st+20?-10+204*flip:194-14*settle;
341
+ const shade=.38*(1-Math.abs(Math.cos(angle*Math.PI/180)));
342
+ return <div key={num} style={{position:'absolute',left:42+i*214,top:438,
343
+ width:204,height:402,perspective:1300}}>
344
+ <div style={{width:'100%',height:'100%',position:'relative',
345
+ transformStyle:'preserve-3d',
346
+ transform:'rotateY('+angle+'deg) translateZ('+(55*Math.abs(Math.sin(angle*Math.PI/180)))+'px)',
347
+ borderRadius:18,boxShadow:'0 20px 30px rgba(0,0,0,.28)'}}>
348
+ <div style={{position:'absolute',inset:0,backfaceVisibility:'hidden',
349
+ borderRadius:18,overflow:'hidden',border:'5px solid #63747b'}}>
350
+ <ScenicCard name={front} kind={i} />
351
+ </div>
352
+ <div style={{position:'absolute',inset:0,backfaceVisibility:'hidden',
353
+ transform:'rotateY(180deg)',background:'#f1ecdf',
354
+ border:'5px solid #fdf7e8',borderRadius:18,
355
+ display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',
356
+ color:'#223d47'}}>
357
+ <div style={{fontFamily:SERIF,fontSize:112,fontWeight:800}}>{num}</div>
358
+ <div style={{marginTop:20,fontSize:27,fontWeight:700}}>{back}</div>
359
+ </div>
360
+ <div style={{position:'absolute',inset:0,borderRadius:18,pointerEvents:'none',
361
+ background:'rgba(5,18,23,'+shade+')',
362
+ backfaceVisibility:'hidden'}}/>
363
+ <div style={{position:'absolute',top:10,bottom:10,left:'49%',width:9,
364
+ opacity:Math.max(0,1-Math.abs(angle-90)/36),
365
+ background:'linear-gradient(90deg,transparent,#fff9cb,transparent)',
366
+ transform:'translateZ(4px)'}}/>
367
+ </div>
368
+ </div>;
369
+ })}
370
+ <div style={{position:'absolute',bottom:174,left:60,right:60,height:2,background:'#6b8086',opacity:.4}}/>
371
+ <div style={{position:'absolute',bottom:116,left:48,right:48,textAlign:'center',
372
+ fontSize:21,letterSpacing:3,color:'#d6d4c9'}}>FRONT → SPINE HIGHLIGHT → REVEAL</div>
373
+ </AbsoluteFill>;
374
+ }
375
+
376
+ const StoryPage=({second})=><div style={{position:'absolute',inset:0,fontFamily:FONT,
377
+ background:second?'#e1ece7':'#ede4d3',overflow:'hidden'}}>
378
+ <div style={{position:'absolute',top:215,left:60,right:60,fontSize:60,fontWeight:800,
379
+ color:SWATCH.ink}}>{second?'暮色,慢慢落下来':'天亮,街道还很静'}</div>
380
+ <div style={{position:'absolute',top:318,left:60,fontSize:27,
381
+ color:SWATCH.muted}}>{second?'THE EVENING WALK':'THE MORNING WALK'}</div>
382
+ <div style={{position:'absolute',top:400,left:47,width:626,height:615,
383
+ border:'12px solid #faf7ee',borderRadius:24,overflow:'hidden',
384
+ boxShadow:'0 27px 60px rgba(20,40,35,.24)'}}>
385
+ <ScenicCard name={second?'最后一段路':'第一段路'} kind={second?2:0} large/>
386
+ </div>
387
+ <div style={{position:'absolute',bottom:145,left:60,fontSize:32,color:SWATCH.muted}}>不是赶路,是记录。</div>
388
+ </div>;
389
+
390
+ // Shotcraft "page-turn-transitions" — barn door split with seam cue,
391
+ // 24f accelerated exit and 36f incoming-page settle.
392
+ export function PageTurnDemo() {
393
+ const f=useCurrentFrame();
394
+ const seam=bounded(f,20,45,Easing.out(Easing.cubic));
395
+ const open=bounded(f,44,68,Easing.bezier(.42,0,.8,.25));
396
+ const settle=bounded(f,46,82,Easing.out(Easing.cubic));
397
+ const slide=900*open;
398
+ return <AbsoluteFill style={{background:'#dde8e3',overflow:'hidden',fontFamily:FONT}}>
399
+ <div style={{position:'absolute',inset:0,transform:'scale('+(1.08-.08*settle)+')'}}>
400
+ <StoryPage second/>
401
+ </div>
402
+ <div style={{position:'absolute',inset:0,clipPath:'inset(0 50% 0 0)',
403
+ transform:'translateX('+(-slide)+'px)'}}><StoryPage/></div>
404
+ <div style={{position:'absolute',inset:0,clipPath:'inset(0 0 0 50%)',
405
+ transform:'translateX('+slide+'px)'}}><StoryPage/></div>
406
+ <div style={{position:'absolute',left:359,top:0,width:4,height:1280,
407
+ transform:'scaleY('+seam+')',transformOrigin:'center',opacity:1-open,
408
+ background:'#f3dfb3',boxShadow:'0 0 30px 7px rgba(242,212,159,.6)'}}/>
409
+ <div style={{position:'absolute',left:0,top:0,width:720,height:1280,
410
+ pointerEvents:'none',opacity:.5*(1-bounded(f,68,95))*open,
411
+ background:'radial-gradient(ellipse at 50% 50%,rgba(255,247,216,.85),transparent 73%)'}}/>
412
+ {badge('08','BARN DOOR')}
413
+ <div style={{position:'absolute',bottom:55,left:60,fontSize:20,fontWeight:650,
414
+ letterSpacing:2,color:SWATCH.ink}}>PAGE SPLIT · LIGHT SEAM · NEW SCENE</div>
415
+ </AbsoluteFill>;
416
+ }
417
+
418
+ // Shotcraft "crane-rise-reveal": a single 3x→1x 102f camera move about
419
+ // a tracked row, anchored camera translation and a >30f final hold.
420
+ export function CraneRiseDemo() {
421
+ const f=useCurrentFrame();
422
+ const fly=bounded(f,24,126,Easing.bezier(.2,0,.25,1));
423
+ const scale=3-2*fly;
424
+ const tx=360-360*scale;
425
+ const ty=720-720*scale;
426
+ const names=['踏出家门','安静的街道','在桥上停留','看一眼河面','沿着路回家'];
427
+ const focus=bounded(f,24,50,Easing.out(Easing.cubic));
428
+ return <AbsoluteFill style={{background:'#cddcda',overflow:'hidden',fontFamily:FONT}}>
429
+ <div style={{position:'absolute',inset:0,transformOrigin:'top left',
430
+ transform:'translate('+tx+'px,'+ty+'px) scale('+scale+')'}}>
431
+ <div style={{position:'absolute',left:38,top:170,width:644,height:940,
432
+ background:'#f5f2e8',boxShadow:'0 25px 65px rgba(35,69,72,.28)',borderRadius:24}}>
433
+ <div style={{position:'absolute',top:39,left:35,fontSize:36,fontWeight:780,color:SWATCH.ink}}>一段路的五个瞬间</div>
434
+ <div style={{position:'absolute',top:97,left:35,fontSize:20,color:SWATCH.muted}}>WALK JOURNAL / 5 MOMENTS</div>
435
+ {names.map((name,i)=><div key={name} style={{position:'absolute',left:28,right:28,
436
+ top:161+i*146,height:130,borderRadius:17,overflow:'hidden',
437
+ display:'flex',alignItems:'center',gap:23,padding:12,
438
+ background:i===2?'#d8e7e4':'#eae8e0',
439
+ opacity:i===2?1:.38+.62*focus,
440
+ boxShadow:i===2?'0 0 0 2px #2c637e':'none'}}>
441
+ <div style={{width:115,height:105,flexShrink:0,borderRadius:12,overflow:'hidden'}}><ScenicCard name="" kind={i}/></div>
442
+ <div><div style={{fontSize:30,fontWeight:750,color:SWATCH.ink}}>{name}</div>
443
+ <div style={{fontSize:18,marginTop:12,color:SWATCH.muted}}>MOMENT 0{i+1}</div></div>
444
+ {i===2&&<div style={{marginLeft:'auto',width:14,height:14,borderRadius:7,background:'#2c637e',
445
+ boxShadow:'0 0 0 7px rgba(44,99,126,.13)'}}/>}
446
+ </div>)}
447
+ </div>
448
+ </div>
449
+ {badge('09','CRANE RISE')}
450
+ <div style={{position:'absolute',bottom:63,left:48,right:48,fontSize:21,
451
+ color:SWATCH.muted,letterSpacing:2,opacity:bounded(f,125,148)}}>
452
+ ONE CAMERA MOVE · 3.0× TO 1.0×
453
+ </div>
454
+ </AbsoluteFill>;
455
+ }
456
+
457
+ // Shotcraft "grain-dissolve": turbulence + displacement + gaussian blur,
458
+ // swap the statement at peak noise and settle into a crisp short wordmark.
459
+ export function GrainDissolveDemo() {
460
+ const f=useCurrentFrame();
461
+ const burst=bounded(f,9,19,Easing.out(Easing.cubic));
462
+ const lock=bounded(f,47,62,Easing.inOut(Easing.cubic));
463
+ const cross=bounded(f,42,52,Easing.inOut(Easing.cubic));
464
+ const scale=52*burst*(1-lock);
465
+ const grainBlur=1.1*burst*(1-lock);
466
+ const selected=bounded(f,10,18)*(1-bounded(f,40,49));
467
+ return <AbsoluteFill style={{background:'radial-gradient(ellipse at 49% 47%,#233f4a,#111b25 80%)',
468
+ fontFamily:FONT,overflow:'hidden'}}>
469
+ {badge('10','GRAIN DISSOLVE',true)}
470
+ <svg viewBox="0 0 720 1280" width="720" height="1280" style={{position:'absolute',inset:0}}>
471
+ <defs>
472
+ <filter id="shotcraftGrain10" x="-30%" y="-90%" width="160%" height="280%">
473
+ <feTurbulence baseFrequency={.9+.4*burst} type="fractalNoise"
474
+ numOctaves={1} seed={Math.floor(f*.85)} result="grain"/>
475
+ <feDisplacementMap in="SourceGraphic" in2="grain"
476
+ scale={scale} xChannelSelector="R" yChannelSelector="G" />
477
+ <feGaussianBlur stdDeviation={grainBlur}/>
478
+ </filter>
479
+ <pattern id="shotcraftStripe10" width="12" height="12" patternUnits="userSpaceOnUse" patternTransform="rotate(45)">
480
+ <line x1="0" y1="0" x2="0" y2="12" stroke="#d5d8d4" strokeWidth="4" opacity=".5"/>
481
+ </pattern>
482
+ </defs>
483
+ <rect x="65" y="505" width="590" height="206" fill="url(#shotcraftStripe10)" opacity={selected*.13}/>
484
+ <rect x="65" y="505" width="590" height="206" stroke="#dbe8e7"
485
+ strokeWidth="2" fill="none" strokeDasharray="8 8" opacity={selected*.8}/>
486
+ <g filter="url(#shotcraftGrain10)" textAnchor="middle" fill="#f1f7f5" fontWeight="750">
487
+ <text x="360" y="643" fontSize="59" opacity={1-cross}>今天的路,记住了</text>
488
+ <text x="360" y="648" fontSize="108" opacity={cross}
489
+ style={{filter:'drop-shadow(0 0 14px rgba(238,250,249,.6))'}}>下次见</text>
490
+ </g>
491
+ <circle cx="360" cy="658" r={160*burst*(1-lock)} fill="none" stroke="#d7e8e3"
492
+ opacity={.18*burst*(1-lock)} strokeWidth="2"/>
493
+ </svg>
494
+ <div style={{position:'absolute',bottom:160,left:0,right:0,textAlign:'center',
495
+ fontSize:29,color:'#e6e5d9',opacity:bounded(f,58,75)}}>生活,还在继续。</div>
496
+ <div style={{position:'absolute',bottom:84,left:0,right:0,textAlign:'center',
497
+ fontSize:19,color:'#94b2af',letterSpacing:2}}>NOISE → DISPLACE → REFORM</div>
498
+ </AbsoluteFill>;
499
+ }
500
+
501
+ ~~~
@@ -0,0 +1,195 @@
1
+ # video
2
+ seed:2210396671
3
+ width:720 height:1280 fps:30 layout:series
4
+
5
+ ## PaperTitle
6
+ - component duration:1.833333 jsx:"<PaperTitleCardDemo />"
7
+
8
+ ## Multiplane
9
+ - component duration:5.5 jsx:"<MultiplaneDemo />"
10
+
11
+ ## FreezeAnnotate
12
+ - component duration:5.266667 jsx:"<FreezeAnnotateDemo />"
13
+
14
+ ~~~js imports
15
+ import React from 'react';
16
+ import {AbsoluteFill, useCurrentFrame, interpolate, Easing} from 'remotion';
17
+
18
+ // Adapted from video-shotcraft recipe paper-title-card, 55 frames.
19
+ const FONT = "'PingFang SC', 'Noto Sans CJK SC', 'Microsoft YaHei', sans-serif";
20
+ const SERIF = "'Songti SC', 'Noto Serif CJK SC', Georgia, serif";
21
+ const ease = Easing.bezier(0.2, 0.75, 0.3, 1);
22
+ const out = Easing.bezier(0.45, 0, 0.18, 1);
23
+ const bounded = (f, a, b, ev = Easing.linear) => interpolate(f, [a, b], [0, 1], {
24
+ extrapolateLeft: 'clamp', extrapolateRight: 'clamp', easing: ev
25
+ });
26
+ const SWATCH = {paper:'#f4efe5', ink:'#20292a', muted:'#697579', accent:'#b96a49', blue:'#2c637e'};
27
+ const badge = (num, name, light=false) => (
28
+ <div style={{position:'absolute',left:42,top:56,display:'flex',gap:14,alignItems:'center',zIndex:12}}>
29
+ <span style={{width:38,height:38,border:'1px solid '+(light?'#d6dedf':'#879395'),borderRadius:19,
30
+ display:'flex',alignItems:'center',justifyContent:'center',
31
+ fontFamily:FONT,fontSize:16,color:light?'#fff':SWATCH.muted}}>{num}</span>
32
+ <span style={{fontSize:20,fontWeight:600,letterSpacing:2,color:light?'#fff':SWATCH.muted,fontFamily:FONT}}>{name}</span>
33
+ </div>
34
+ );
35
+ const ScenicCard = ({name,kind=0,large=false}) => {
36
+ const palettes=[
37
+ ['#83b0bc','#ddd3bc','#3a5964'],
38
+ ['#a4b4c7','#dbdfd5','#667d7c'],
39
+ ['#bbad92','#e4cba7','#876d60'],
40
+ ['#96b3b1','#dce2d9','#3e6b65']
41
+ ];
42
+ const p=palettes[kind%palettes.length];
43
+ return <div style={{width:'100%',height:'100%',position:'relative',overflow:'hidden',
44
+ background:'linear-gradient(180deg,'+p[0]+' 0%,'+p[1]+' 70%)'}}>
45
+ <svg viewBox="0 0 420 450" preserveAspectRatio="xMidYMid slice" style={{height:'100%',width:'100%',position:'absolute'}}>
46
+ <circle cx={300-kind*35} cy={90+kind*12} r="46" fill="#fff8dc" opacity=".62"/>
47
+ <path d="M0 290 Q90 205 185 265 T420 230 L420 450 L0 450Z" fill={p[2]} opacity=".5"/>
48
+ <path d="M0 345 Q135 270 240 340 T420 315 L420 450 L0 450Z" fill={p[2]} opacity=".75"/>
49
+ <path d="M0 395 Q180 360 420 390 L420 450 L0 450Z" fill="#1f4049" opacity=".8"/>
50
+ {kind%2===0 ? <>
51
+ <path d="M100 375 L115 205 M98 258 L66 235 M112 255 L150 220 M114 300 L170 265" fill="none" stroke="#384d4e" strokeWidth="8" strokeLinecap="round"/>
52
+ <path d="M310 395 L323 150 M321 220 L285 192 M322 260 L360 230" fill="none" stroke="#304c4b" strokeWidth="7" strokeLinecap="round"/>
53
+ </> : <>
54
+ <path d="M20 380 L110 230 L210 380 M105 380 L205 200 L332 380 M234 380 L330 250 L420 380" stroke="#e6dbc7" strokeWidth="8" fill="none" opacity=".7"/>
55
+ <path d="M0 390 Q170 345 420 380" stroke="#f6f0dd" strokeWidth="5" fill="none" opacity=".9"/>
56
+ </>}
57
+ </svg>
58
+ <div style={{position:'absolute',bottom:0,left:0,right:0,padding:large?'28px 26px':'20px 22px',
59
+ background:'linear-gradient(0deg,rgba(15,32,37,.85),transparent)',color:'#fff',fontFamily:FONT,
60
+ fontWeight:650,fontSize:large?39:27}}>{name}</div>
61
+ </div>;
62
+ };
63
+
64
+ export function PaperTitleCardDemo() {
65
+ const f = useCurrentFrame();
66
+ const words = [{t:'给生活',br:true},{t:'加点料',accent:true}];
67
+ const fadeOut=interpolate(f,[47,55],[1,0],{extrapolateLeft:'clamp',extrapolateRight:'clamp'});
68
+ const under=bounded(f,16,34,Easing.bezier(.3,0,.2,1));
69
+ return <AbsoluteFill style={{background:SWATCH.paper,opacity:fadeOut,
70
+ backgroundImage:'radial-gradient(700px 780px at 47% 42%,#fffdf7,transparent 80%)',
71
+ display:'flex',alignItems:'center',justifyContent:'center',fontFamily:SERIF,color:SWATCH.ink}}>
72
+ {badge('01','PAPER TITLE')}
73
+ <div style={{width:625,textAlign:'center',marginTop:-55}}>
74
+ <div style={{fontSize:96,fontWeight:700,lineHeight:1.35,display:'flex',flexWrap:'wrap',
75
+ justifyContent:'center',columnGap:18}}>
76
+ {words.map((w,i)=>{
77
+ const t=bounded(f,4+i*4,13+i*4,ease);
78
+ return <React.Fragment key={i}><span style={{opacity:t,display:'inline-block',
79
+ transform:'scale('+(1.28-.28*t)+')',filter:'blur('+((1-t)*7)+'px)',
80
+ color:w.accent?SWATCH.accent:SWATCH.ink,
81
+ fontStyle:w.accent?'italic':'normal'}}>{w.t}</span>
82
+ {w.br&&<span style={{flexBasis:'100%',height:0}}/>}</React.Fragment>;
83
+ })}
84
+ </div>
85
+ <div style={{height:6,width:220,background:SWATCH.accent,borderRadius:3,margin:'35px auto',
86
+ transform:'scaleX('+under+')'}}/>
87
+ <div style={{fontSize:27,letterSpacing:4,fontFamily:FONT,color:SWATCH.muted,
88
+ opacity:bounded(f,12,25)}}>加拿大 · 周末散步</div>
89
+ </div>
90
+ <div style={{position:'absolute',bottom:72,fontFamily:FONT,fontSize:18,letterSpacing:2,color:SWATCH.muted}}>
91
+ WORD-BY-WORD LETTERPRESS
92
+ </div>
93
+ </AbsoluteFill>;
94
+ }
95
+
96
+ // Adapted from video-shotcraft depth-layer-moves: drive * 0.35 / 0.7 / 1.4, fixed type.
97
+ export function MultiplaneDemo() {
98
+ const f=useCurrentFrame();
99
+ const travel=bounded(f,6,136,out);
100
+ const drive=1030*travel;
101
+ const lift=bounded(f,122,144,Easing.out(Easing.cubic));
102
+ const cards=['清晨的街道','沿着小路走','河边的风景','停下来看看','把日子记下来'];
103
+ return <AbsoluteFill style={{background:'#e5e1d7',overflow:'hidden',fontFamily:FONT}}>
104
+ {badge('02','2.5D PARALLAX')}
105
+ <div style={{position:'absolute',inset:0,overflow:'hidden',opacity:.28,filter:'blur(5px) saturate(.7)',
106
+ transform:'translateX('+(-drive*.35)+'px) scale(1.18)'}}>
107
+ <div style={{position:'absolute',top:0,left:-180,width:1800,height:1280,
108
+ background:'linear-gradient(110deg,#a9b4ab,#ebd8b6 40%,#9db9b7 65%,#d3c9ad)'}}/>
109
+ {Array.from({length:10},(_,i)=><div key={i} style={{position:'absolute',
110
+ left:i*200-50,top:390+(i%3)*30,width:120,height:370,background:'#8b9991',borderRadius:20}} />)}
111
+ </div>
112
+ <div style={{position:'absolute',inset:0,background:'linear-gradient(180deg,rgba(245,242,231,.92),rgba(231,224,209,.7) 70%,rgba(211,197,176,.8))'}}/>
113
+ <div style={{position:'absolute',top:300,left:-316,display:'flex',gap:40,
114
+ transform:'translateX('+(-drive*.7)+'px)'}}>
115
+ {cards.map((name,i)=><div key={name} style={{width:365,height:575,background:'#e7e1d6',
116
+ border:'8px solid #fcf8ed',borderRadius:28,overflow:'hidden',
117
+ transform:i===3?'translateY('+(-18*lift)+'px) scale('+(1+.035*lift)+')':undefined,
118
+ boxShadow:i===3?'0 0 0 '+(4*lift)+'px #b96a49,0 32px 75px rgba(32,41,42,.24)':'0 17px 38px rgba(32,41,42,.18)'}}>
119
+ <ScenicCard name={name} kind={i} large/>
120
+ </div>)}
121
+ </div>
122
+ <div style={{position:'absolute',inset:0,filter:'blur(7px)',opacity:.68,transform:'translateX('+(-drive*1.4)+'px)'}}>
123
+ {['WINTER','WALK','OTTAWA','VLOG'].map((tag,i)=><div key={tag} style={{position:'absolute',
124
+ left:700+i*620,top:860+(i%2)*160,background:i%2?'#2d4c52':'#b96a49',color:'white',
125
+ borderRadius:70,padding:'20px 45px',fontSize:54,whiteSpace:'nowrap'}}>{tag}</div>)}
126
+ </div>
127
+ <div style={{position:'absolute',top:165,left:45,right:45,pointerEvents:'none',zIndex:5}}>
128
+ <div style={{fontSize:70,fontWeight:750,lineHeight:1.14,color:SWATCH.ink,
129
+ textShadow:'0 1px 0 #fff'}}>从街道,<br/>走到河边。</div>
130
+ <div style={{fontSize:27,marginTop:20,color:SWATCH.muted}}>镜头滑行 · 三层视差 · 主角落定</div>
131
+ </div>
132
+ <div style={{position:'absolute',bottom:72,left:45,right:45,fontSize:19,
133
+ color:SWATCH.muted,letterSpacing:1,zIndex:8}}>FAR 0.35× MID 0.7× NEAR 1.4×</div>
134
+ {lift>.01&&<div style={{position:'absolute',right:70,top:910,zIndex:10,
135
+ background:SWATCH.accent,color:'white',padding:'13px 23px',borderRadius:30,
136
+ opacity:lift,transform:'translateY('+((1-lift)*25)+'px)',fontSize:21}}>IN FOCUS</div>}
137
+ </AbsoluteFill>;
138
+ }
139
+
140
+ // Adapted from video-shotcraft speed-ramp-freeze: abrupt 70-frame stop,
141
+ // 3-frame shutter flash, 10-frame pen circle, smootherstep resume.
142
+ export function FreezeAnnotateDemo() {
143
+ const f=useCurrentFrame();
144
+ const freezeStart=43, freezeEnd=113;
145
+ const resume=Math.max(0,Math.min(1,(f-freezeEnd)/25));
146
+ const smooth=resume*resume*resume*(resume*(resume*6-15)+10);
147
+ const sourceFrame=f<freezeStart?f*1.28:f<freezeEnd?freezeStart*1.28:freezeStart*1.28+smooth*52+(f-freezeEnd>25?(f-freezeEnd-25)*1.6:0);
148
+ const x=225-sourceFrame*14;
149
+ const paused=f>=freezeStart&&f<freezeEnd;
150
+ const inkOut=f<freezeEnd-8?1:1-bounded(f,freezeEnd-8,freezeEnd);
151
+ const mark=bounded(f,53,63);
152
+ const note=bounded(f,69,80,Easing.out(Easing.cubic))*inkOut;
153
+ return <AbsoluteFill style={{background:'#edf3f3',overflow:'hidden',fontFamily:FONT}}>
154
+ {badge('03','FREEZE & ANNOTATE')}
155
+ <div style={{position:'absolute',top:170,left:42,fontWeight:800,fontSize:72,lineHeight:1.15,
156
+ color:SWATCH.ink}}>拍到这一刻,<br/><span style={{color:SWATCH.blue}}>停一下。</span></div>
157
+ <div style={{position:'absolute',top:385,left:42,fontSize:25,color:SWATCH.muted}}>流动 → 定格圈注 → 解冻</div>
158
+ <div style={{position:'absolute',top:540,left:0,height:440,display:'flex',gap:26,
159
+ transform:'translateX('+x+'px)'}}>
160
+ {['路口','雪后的公园','河边','日落','回家的路'].map((name,i)=><div key={i}
161
+ style={{width:355,height:430,borderRadius:25,overflow:'hidden',background:'white',
162
+ boxShadow:i===2&&paused?'0 15px 65px rgba(44,99,126,.31)':'0 12px 33px rgba(30,49,53,.17)',
163
+ transform:i===2&&paused?'translateY(-12px) scale(1.04)':undefined,
164
+ opacity:paused&&i!==2?.62:1,filter:paused&&i!==2?'saturate(.5)':'none'}}>
165
+ <ScenicCard name={name} kind={i} large />
166
+ </div>)}
167
+ </div>
168
+ <div style={{position:'absolute',top:500,left:42,right:42,display:'flex',justifyContent:'space-between',
169
+ fontSize:23,fontFamily:'monospace',fontWeight:700,color:paused?SWATCH.blue:SWATCH.accent}}>
170
+ <span>{paused?'❚❚ PAUSED':'● LIVE'}</span>
171
+ <span>{paused?'00:00:01:13':'REC • '+String(Math.floor(f/30)).padStart(2,'0')+':'+String(f%30).padStart(2,'0')}</span>
172
+ </div>
173
+ {paused&&<svg viewBox="0 0 720 1280" style={{position:'absolute',inset:0,zIndex:6,width:'100%',height:'100%',pointerEvents:'none'}}>
174
+ <rect x="142" y="575" width="436" height="370" fill="none" stroke="#2c637e" strokeWidth="4" strokeDasharray="14 13" opacity=".42"/>
175
+ <path d="M155 600 C175 510 535 520 560 660 C610 820 520 970 330 960 C130 965 110 810 155 600"
176
+ fill="none" stroke="#2c637e" strokeWidth="12" strokeLinecap="round"
177
+ strokeDasharray="1450" strokeDashoffset={1450*(1-mark)} opacity={inkOut}/>
178
+ <path d="M560 870 Q620 875 625 970 L604 950 M625 970 L639 945"
179
+ fill="none" stroke="#2c637e" strokeWidth="8" strokeLinecap="round"
180
+ strokeDasharray="200" strokeDashoffset={200*(1-bounded(f,68,77))} opacity={inkOut}/>
181
+ </svg>}
182
+ {paused&&<div style={{position:'absolute',bottom:110,left:60,right:60,opacity:note,
183
+ transform:'translateY('+((1-note)*20)+'px)',textAlign:'center',color:SWATCH.blue,zIndex:8}}>
184
+ <div style={{fontSize:59,fontWeight:800}}>这一帧值得留下</div>
185
+ <div style={{height:7,width:240,background:SWATCH.blue,margin:'16px auto',borderRadius:8}}/>
186
+ <div style={{fontSize:24,marginTop:23,color:SWATCH.muted}}>FREEZE THE MOMENT</div>
187
+ </div>}
188
+ {f>=freezeStart&&f<freezeStart+3&&<div style={{position:'absolute',inset:0,background:'white',
189
+ opacity:(1-(f-freezeStart)/3)*.62,zIndex:11}}/>}
190
+ {!paused&&<div style={{position:'absolute',bottom:70,left:45,fontSize:21,color:SWATCH.muted}}>
191
+ {f<freezeStart?'MOTION →':'→ RESUME'}
192
+ </div>}
193
+ </AbsoluteFill>;
194
+ }
195
+ ~~~
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lalalic/markcut",
3
- "version": "3.2.53",
3
+ "version": "3.2.55",
4
4
  "description": "Markdown-to-video engine. Describe scenes in markdown, get a rendered video.",
5
5
  "bin": {
6
6
  "markcut": "bin/markcut"
@@ -158,7 +158,7 @@ export interface DescriptiveMap extends DescriptiveBaseNode {
158
158
  routeWeight?: number;
159
159
  zoom?: number;
160
160
  center?: { lat: number; lng: number };
161
- mapType?: "roadmap" | "satellite" | "hybrid" | "terrain";
161
+ mapType?: "roadmap" | "satellite" | "hybrid" | "terrain" | "schematic";
162
162
  language?: string;
163
163
  region?: string;
164
164
  travelMode?: "DRIVING" | "WALKING" | "BICYCLING" | "TRANSIT";
@@ -7,7 +7,7 @@
7
7
  * (TTS/STT/durations)
8
8
  */
9
9
  import { execSync, spawn } from "node:child_process";
10
- import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";
10
+ import { readFileSync, writeFileSync, mkdirSync, existsSync, copyFileSync } from "node:fs";
11
11
  import { resolve, dirname, join } from "node:path";
12
12
  import { fileURLToPath } from "node:url";
13
13
  import {
@@ -401,7 +401,15 @@ edit=${DEFAULT_EDIT_CLI}`);
401
401
  mkdirSync(bundleDir, { recursive: true });
402
402
  const bundle = await bundleFromEntries(entries, extraSpecs, rawSource, bundleDir);
403
403
  if (bundle.url) {
404
- streamTree.imports = join(bundleDir, bundle.url.split("/").pop());
404
+ // Remotion fetches modules from its publicDir, not absolute host paths.
405
+ // Stage this cached bundle alongside the Markdown's generated media.
406
+ const bundleName = bundle.url.split("/").pop();
407
+ const publicDir = renderPublicDir || join(ROOT, "public");
408
+ const relativeBundle = join(".markcut", "generated", "components", bundleName);
409
+ const target = join(publicDir, relativeBundle);
410
+ mkdirSync(dirname(target), { recursive: true });
411
+ copyFileSync(join(bundleDir, bundleName), target);
412
+ streamTree.imports = relativeBundle;
405
413
  console.log(` \u2705 components \u2192 ${bundle.exports.join(", ")}`);
406
414
  }
407
415
  }
@@ -284,7 +284,7 @@ export const mapStream = base.extend({
284
284
  routeWeight: z.number().default(4),
285
285
  zoom: z.number().optional().describe("Optional fixed zoom; route view auto-fits when omitted"),
286
286
  center: z.object({ lat: z.number(), lng: z.number() }).optional().describe("map view center (defaults to first waypoint)"),
287
- mapType: z.enum(["roadmap", "satellite", "hybrid", "terrain"]).default("roadmap").describe("Google Maps style"),
287
+ mapType: z.enum(["roadmap", "satellite", "hybrid", "terrain", "schematic"]).default("roadmap").describe("Google Maps style, or deterministic offline route schematic"),
288
288
  language: z.string().optional().describe("Google Maps UI/label language, e.g. zh-CN"),
289
289
  region: z.string().optional().describe("Google Maps region code, e.g. CN"),
290
290
  travelMode: z.enum(["DRIVING", "WALKING", "BICYCLING", "TRANSIT"]).default("DRIVING").describe("Directions API travel mode"),
package/src/types/Map.tsx CHANGED
@@ -48,6 +48,7 @@ import {
48
48
  type RouteStopWindow,
49
49
  } from "../utils/route-legs";
50
50
  import type { MapStream, Stream } from "../schema/index";
51
+ import { SchematicRouteMap } from "./SchematicRouteMap";
51
52
 
52
53
  // API key is injected by the compiler onto the stream node (see compileLeaf in compiler.ts).
53
54
  // This fallback handles the case where Map.tsx is used directly without the compiler.
@@ -357,6 +358,7 @@ export function MapLeaf({ stream }: { stream: MapStream }) {
357
358
  const mapLoadContinuedRef = React.useRef(false);
358
359
 
359
360
  React.useEffect(() => {
361
+ if (stream.mapType === "schematic") return;
360
362
  // Strip Google Maps attribution / UI text from the rendered video.
361
363
  hideGoogleMapsUi();
362
364
 
@@ -379,7 +381,7 @@ export function MapLeaf({ stream }: { stream: MapStream }) {
379
381
  }
380
382
  mapLoadHandleRef.current = null;
381
383
  };
382
- }, [stream.id, start, end]);
384
+ }, [stream.id, stream.mapType, start, end]);
383
385
 
384
386
  const handleMapReady = React.useCallback(() => {
385
387
  if (!mapLoadContinuedRef.current && mapLoadHandleRef.current !== null) {
@@ -395,6 +397,17 @@ export function MapLeaf({ stream }: { stream: MapStream }) {
395
397
  stream.cinematic?.fallback === "none" &&
396
398
  (stream.cinematic.mode === "flyTo" || stream.cinematic.mode === "orbit");
397
399
 
400
+ if (stream.mapType === "schematic" && view !== "route") {
401
+ throw Error("mapType:schematic currently supports only view:route");
402
+ }
403
+ if (stream.mapType === "schematic" && view === "route") {
404
+ return (
405
+ <Sequence durationInFrames={durFrames} from={Math.floor(fps * start)} layout="none">
406
+ <SchematicRouteMap stream={stream} />
407
+ </Sequence>
408
+ );
409
+ }
410
+
398
411
  return (
399
412
  <Sequence
400
413
  durationInFrames={durFrames}
@@ -0,0 +1,61 @@
1
+ import React from 'react';
2
+ import { AbsoluteFill, useCurrentFrame, useVideoConfig } from 'remotion';
3
+ import type { MapStream } from '../schema/index';
4
+ import { pointAtRouteProgress, projectSchematicRoute, routeSvgPath } from '../utils/schematic-route';
5
+
6
+ /** Google-independent, reproducible map chapter. No road map or actual travel track is inferred. */
7
+ export function SchematicRouteMap({stream}: {stream: MapStream}) {
8
+ const {width, height, fps} = useVideoConfig();
9
+ const frame = useCurrentFrame();
10
+ const waypoints = stream.waypoints ?? [];
11
+ const points = React.useMemo(() => projectSchematicRoute(waypoints, width, height), [waypoints, width, height]);
12
+ if (!points.length) return null;
13
+ const duration = Math.max(1, Math.round((stream.end ?? (stream.start ?? 0) + (stream.duration ?? 1)) * fps) - Math.round((stream.start ?? 0) * fps));
14
+ const progress = Math.max(0, Math.min(1, frame / Math.max(1, duration - 1)));
15
+ const marker = pointAtRouteProgress(points, progress);
16
+ const path = routeSvgPath(points);
17
+ const total = points.slice(1).reduce((sum, p, i) => sum + Math.hypot(p.x - points[i]!.x, p.y - points[i]!.y), 0);
18
+ const color = stream.routeColor ?? '#4285F4';
19
+ const headingSize = Math.round(Math.min(width * 0.06, 34));
20
+ const subtitleSize = Math.round(headingSize * .55);
21
+ const pinRadius = Math.max(8, width * .016);
22
+ const first = points[0], last = points[points.length - 1];
23
+ return <AbsoluteFill style={{backgroundColor: '#0d2032'}}>
24
+ <svg viewBox={`0 0 ${width} ${height}`} width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
25
+ <defs>
26
+ <linearGradient id="schematic-bg" x1="0" x2="1" y1="0" y2="1">
27
+ <stop offset="0" stopColor="#163450"/><stop offset="1" stopColor="#091726"/>
28
+ </linearGradient>
29
+ <pattern id="schematic-grid" width="54" height="54" patternUnits="userSpaceOnUse">
30
+ <path d="M 54 0 L 0 0 0 54" fill="none" stroke="#ffffff" strokeOpacity=".075" strokeWidth="1" />
31
+ </pattern>
32
+ </defs>
33
+ <rect width={width} height={height} fill="url(#schematic-bg)" />
34
+ <rect width={width} height={height} fill="url(#schematic-grid)" />
35
+ <text x={width * .08} y={height * .093} fontSize={headingSize} fill="#ffffff" fontWeight="700" fontFamily="sans-serif">路线示意</text>
36
+ <text x={width * .08} y={height * .14} fontSize={subtitleSize} fill="#9dc2d3" fontFamily="sans-serif">按已验证地点连接 · 非道路导航</text>
37
+ {points.length > 1 && <>
38
+ <path d={path} fill="none" stroke="#ffffff" strokeOpacity=".32" strokeWidth={Math.max(2, stream.routeWeight ?? 4)} strokeDasharray="8 8" strokeLinecap="round" strokeLinejoin="round" />
39
+ <path d={path} fill="none" stroke={color} strokeWidth={Math.max(3, stream.routeWeight ?? 4)} strokeLinecap="round" strokeLinejoin="round" strokeDasharray={`${total} ${total}`} strokeDashoffset={total * (1 - progress)} />
40
+ </>}
41
+ {points.map((p, i) => {
42
+ if (points.length > 6 && i > 0 && i < points.length - 1) return null;
43
+ const name = (p.label || (i === 0 ? '出发' : i === points.length - 1 ? '到达' : `站点${i + 1}`)).slice(0, 18);
44
+ const alignRight = p.x > width * .58;
45
+ const nearBottom = p.y > height * .77;
46
+ const labelX = p.x + (alignRight ? -pinRadius * 2 : pinRadius * 2);
47
+ return <g key={i}>
48
+ <circle cx={p.x} cy={p.y} r={pinRadius * .64} fill="#ffffff" opacity=".96" />
49
+ <circle cx={p.x} cy={p.y} r={pinRadius * .33} fill={color} />
50
+ <text x={labelX} y={p.y + (nearBottom ? -pinRadius : -pinRadius * .65)} textAnchor={alignRight ? 'end' : 'start'} fill="#f2f7fa" fontFamily="sans-serif" fontWeight="600" fontSize={Math.max(15, headingSize * .66)}>{name}</text>
51
+ </g>;
52
+ })}
53
+ <circle cx={marker.x} cy={marker.y} r={pinRadius * 2} fill={color} fillOpacity=".2" />
54
+ <circle cx={marker.x} cy={marker.y} r={pinRadius} fill={color} stroke="#ffffff" strokeWidth="3" />
55
+ <rect x={width * .08} y={height * .886} width={width * .84} height={3} rx={1.5} fill="#b9d9e6" opacity=".28" />
56
+ <rect x={width * .08} y={height * .886} width={width * .84 * progress} height={3} rx={1.5} fill={color} />
57
+ <text x={width * .08} y={height * .925} fontSize={subtitleSize} fill="#c8dee7" fontFamily="sans-serif">{(first?.label || '出发').slice(0,14)}</text>
58
+ <text x={width * .92} y={height * .925} textAnchor="end" fontSize={subtitleSize} fill="#c8dee7" fontFamily="sans-serif">{(last?.label || '到达').slice(0,14)}</text>
59
+ </svg>
60
+ </AbsoluteFill>;
61
+ }
@@ -0,0 +1,56 @@
1
+ /** Deterministic offline projection for route visuals; connecting samples is illustrative, not road geometry. */
2
+ export interface RoutePoint { lat: number; lng: number; label?: string }
3
+ export interface ScreenPoint { x: number; y: number; label?: string }
4
+
5
+ function mercatorY(lat: number): number {
6
+ const r = Math.max(-85, Math.min(85, lat)) * Math.PI / 180;
7
+ return Math.log(Math.tan(Math.PI / 4 + r / 2));
8
+ }
9
+
10
+ export function projectSchematicRoute(points: RoutePoint[], width: number, height: number): ScreenPoint[] {
11
+ if (!points.length) return [];
12
+ const map = points.map((p, i) => {
13
+ if (!Number.isFinite(p.lat) || !Number.isFinite(p.lng) || Math.abs(p.lat) > 90 || Math.abs(p.lng) > 180)
14
+ throw Error(`Invalid route coordinate at index ${i}`);
15
+ return { x: p.lng, y: -mercatorY(p.lat), label: p.label };
16
+ });
17
+ // Unwrap the antimeridian so nearby points at +179/-179 do not span the world.
18
+ for (let i = 1; i < map.length; i++) {
19
+ const prev = map[i - 1]!.x;
20
+ const original = map[i]!.x;
21
+ map[i]!.x = prev + ((((original - prev + 540) % 360) + 360) % 360) - 180;
22
+ }
23
+ let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
24
+ for (const p of map) {
25
+ minX = Math.min(minX, p.x); maxX = Math.max(maxX, p.x);
26
+ minY = Math.min(minY, p.y); maxY = Math.max(maxY, p.y);
27
+ }
28
+ const spreadX = Math.max(1e-6, maxX - minX), spreadY = Math.max(1e-6, maxY - minY);
29
+ const insetX = width * 0.17, insetY = height * 0.23;
30
+ const scale = Math.min((width - 2 * insetX) / spreadX, (height - 2 * insetY) / spreadY);
31
+ const cx = (minX + maxX) / 2, cy = (minY + maxY) / 2;
32
+ return map.map(p => ({x: width / 2 + (p.x - cx) * scale, y: height / 2 + (p.y - cy) * scale, label: p.label}));
33
+ }
34
+
35
+ export function pointAtRouteProgress(points: ScreenPoint[], progress: number): ScreenPoint {
36
+ if (!points.length) throw Error('Route requires at least one waypoint');
37
+ if (points.length === 1) return points[0]!;
38
+ const distances = points.slice(1).map((p, i) => Math.hypot(p.x - points[i]!.x, p.y - points[i]!.y));
39
+ const total = distances.reduce((a, b) => a + b, 0);
40
+ if (total < 1e-6) return points[0]!;
41
+ let remaining = Math.max(0, Math.min(1, progress)) * total;
42
+ for (let i = 0; i < distances.length; i++) {
43
+ const length = distances[i]!;
44
+ if (remaining <= length || i === distances.length - 1) {
45
+ const f = length > 0 ? Math.min(1, remaining / length) : 0;
46
+ return { x: points[i]!.x + (points[i + 1]!.x - points[i]!.x) * f,
47
+ y: points[i]!.y + (points[i + 1]!.y - points[i]!.y) * f };
48
+ }
49
+ remaining -= length;
50
+ }
51
+ return points[points.length - 1]!;
52
+ }
53
+
54
+ export function routeSvgPath(points: ScreenPoint[]): string {
55
+ return points.map((p, i) => `${i ? 'L' : 'M'} ${p.x.toFixed(2)} ${p.y.toFixed(2)}`).join(' ');
56
+ }
@@ -0,0 +1,24 @@
1
+ import {describe, it, expect} from 'vitest';
2
+ import {projectSchematicRoute, pointAtRouteProgress, routeSvgPath} from '../src/utils/schematic-route';
3
+
4
+ describe('offline Markcut schematic route', () => {
5
+ it('keeps endpoints in bounds and animates marker between them', () => {
6
+ const pts = projectSchematicRoute([{lat:45.4236,lng:-75.7009,label:'Start'},{lat:45.4295,lng:-75.709,label:'End'}],540,960);
7
+ expect(pts).toHaveLength(2);
8
+ expect(pts.every(p=>p.x>0&&p.x<540&&p.y>0&&p.y<960)).toBe(true);
9
+ expect(pointAtRouteProgress(pts,0)).toMatchObject({x:pts[0]!.x,y:pts[0]!.y});
10
+ expect(pointAtRouteProgress(pts,1)).toMatchObject({x:pts[1]!.x,y:pts[1]!.y});
11
+ const mid = pointAtRouteProgress(pts,.5);
12
+ expect(mid.x).toBeCloseTo((pts[0]!.x+pts[1]!.x)/2,3);
13
+ expect(routeSvgPath(pts)).toMatch(/^M .* L /);
14
+ });
15
+ it('unwraps the dateline, rather than sending the route across the world', () => {
16
+ const pts=projectSchematicRoute([{lat:0,lng:179.7},{lat:0,lng:-179.7}],540,960);
17
+ expect(pts[0]!.x).toBeLessThan(pts[1]!.x);
18
+ });
19
+ it('handles stationary route and rejects invalid coordinates', () => {
20
+ const pts=projectSchematicRoute([{lat:45,lng:-75},{lat:45,lng:-75}],540,960);
21
+ expect(pointAtRouteProgress(pts,.75)).toMatchObject({x:pts[0]!.x,y:pts[0]!.y});
22
+ expect(() => projectSchematicRoute([{lat:91,lng:1}],540,960)).toThrow(/Invalid route coordinate/);
23
+ });
24
+ });