Spaces:
Running
Running
Add kkndme 论房价 project source (in kkndme/) (part 2)
Browse files- kkndme/frontend/src/lib/utils.ts +6 -0
- kkndme/frontend/src/rv/Main.tsx +288 -0
- kkndme/frontend/src/rv/assets.ts +52 -0
- kkndme/frontend/src/rv/brand.tsx +346 -0
- kkndme/frontend/src/rv/charts.tsx +188 -0
- kkndme/frontend/src/rv/ctx.tsx +65 -0
- kkndme/frontend/src/rv/fonts.ts +32 -0
- kkndme/frontend/src/rv/kit.tsx +185 -0
- kkndme/frontend/src/rv/layers.tsx +255 -0
- kkndme/frontend/src/rv/pcm.tsx +73 -0
- kkndme/frontend/src/rv/photos.tsx +91 -0
- kkndme/frontend/src/rv/render.ts +135 -0
- kkndme/frontend/src/rv/scenes.tsx +22 -0
- kkndme/frontend/src/rv/scenesA.tsx +841 -0
- kkndme/frontend/src/rv/scenesB.tsx +963 -0
- kkndme/frontend/src/rv/scenesC.tsx +974 -0
- kkndme/frontend/src/rv/scenesD.tsx +310 -0
- kkndme/frontend/src/rv/theme.ts +107 -0
- kkndme/frontend/src/rv/ui.tsx +336 -0
- kkndme/frontend/src/video/audio.ts +1911 -0
- kkndme/frontend/src/video/clawd.ts +44 -0
- kkndme/frontend/src/video/covers.ts +468 -0
- kkndme/frontend/src/video/draw.ts +272 -0
- kkndme/frontend/src/video/export.ts +159 -0
- kkndme/frontend/src/video/fonts.ts +26 -0
- kkndme/frontend/src/video/kit.ts +566 -0
- kkndme/frontend/src/video/render.ts +193 -0
- kkndme/frontend/src/video/scenes1.ts +650 -0
- kkndme/frontend/src/video/scenes2.ts +593 -0
- kkndme/frontend/src/video/scenes3.ts +976 -0
- kkndme/frontend/src/video/script.ts +123 -0
- kkndme/frontend/src/video/series.ts +60 -0
- kkndme/frontend/src/video/timeline.ts +136 -0
- kkndme/frontend/src/vite-env.d.ts +1 -0
- kkndme/frontend/tsconfig.json +22 -0
- kkndme/frontend/vite.config.ts +57 -0
kkndme/frontend/src/lib/utils.ts
ADDED
|
@@ -0,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'@remotion/media'
|
| 4 |
+
import { noise2D } from '@remotion/noise'
|
| 5 |
+
import { SCENE_INFO, CARD, COVER, ampAt, AMP_RATE } from '../video/timeline'
|
| 6 |
+
import type { SceneKey } from '../video/script'
|
| 7 |
+
import { C, E, F, clamp, lerp, tw, hexA } from './theme'
|
| 8 |
+
import { SceneCtx, makeS, type VProps } from './ctx'
|
| 9 |
+
import { Atmosphere, FxOverlay, accentAt } from './layers'
|
| 10 |
+
import { txtStyle, goldText, Chars } from './ui'
|
| 11 |
+
import { SCENES } from './scenes'
|
| 12 |
+
import { BgPhotos } from './photos'
|
| 13 |
+
import { Cover, VoiceAvatar } from './brand'
|
| 14 |
+
import { PcmTrack } from './pcm'
|
| 15 |
+
|
| 16 |
+
export const Main: React.FC<VProps> = ({ tl, subs, music, mainSrc, musicSrc, pcm }) => {
|
| 17 |
+
const frame = useCurrentFrame()
|
| 18 |
+
const { fps, width: W, height: H } = useVideoConfig()
|
| 19 |
+
const t = frame / fps
|
| 20 |
+
const P = H > W
|
| 21 |
+
const accent = accentAt(tl, t)
|
| 22 |
+
const live = tl.scenes.filter((s) => t >= s.start - 0.02 && t < s.end + 0.02)
|
| 23 |
+
// 手持感镜头漂移:极慢、幅度很小,内容与背景反向视差
|
| 24 |
+
const amp = Math.max(W, H) / 1920
|
| 25 |
+
const cam: [number, number] = [noise2D('camx', t * 0.07, 0) * 9 * amp, noise2D('camy', 0, t * 0.07) * 6 * amp]
|
| 26 |
+
|
| 27 |
+
return (
|
| 28 |
+
<AbsoluteFill style={{ backgroundColor: C.bg, overflow: 'hidden', fontFamily: F.sans }}>
|
| 29 |
+
<Atmosphere W={W} H={H} t={t} accent={accent} cam={cam} />
|
| 30 |
+
<BgPhotos W={W} H={H} t={t} tl={tl} cam={cam} />
|
| 31 |
+
{live.map((sc) => {
|
| 32 |
+
const Comp = SCENES[sc.key as SceneKey]
|
| 33 |
+
const S = makeS(t, tl, sc, W, H)
|
| 34 |
+
const last = sc.idx === tl.scenes.length - 1
|
| 35 |
+
const x = last ? 0 : tw(t, sc.end - 0.7, 0.7, E.in)
|
| 36 |
+
const zoom = 1 + Math.min(S.u, 60) * 0.0006
|
| 37 |
+
return (
|
| 38 |
+
<SceneCtx.Provider key={sc.key} value={S}>
|
| 39 |
+
<div
|
| 40 |
+
style={{
|
| 41 |
+
position: 'absolute',
|
| 42 |
+
inset: 0,
|
| 43 |
+
opacity: 1 - x,
|
| 44 |
+
transform: `translate(${cam[0].toFixed(2)}px, ${cam[1].toFixed(2)}px) scale(${(zoom * (1 + 0.07 * x)).toFixed(5)})`,
|
| 45 |
+
transformOrigin: '50% 48%',
|
| 46 |
+
filter: x > 0.01 ? `blur(${(x * 16).toFixed(1)}px)` : undefined,
|
| 47 |
+
}}
|
| 48 |
+
>
|
| 49 |
+
<Comp />
|
| 50 |
+
</div>
|
| 51 |
+
{sc.idx > 0 && <Chapter />}
|
| 52 |
+
</SceneCtx.Provider>
|
| 53 |
+
)
|
| 54 |
+
})}
|
| 55 |
+
<Hud t={t} W={W} H={H} P={P} tl={tl} />
|
| 56 |
+
{subs && <Subtitles t={t} W={W} H={H} P={P} tl={tl} />}
|
| 57 |
+
<FxOverlay W={W} H={H} t={t} tl={tl} frame={frame} />
|
| 58 |
+
{t < COVER + 0.4 && (
|
| 59 |
+
<div style={{ position: 'absolute', inset: 0, opacity: 1 - tw(t, COVER - 0.12, 0.45, E.soft), transform: `scale(${(1 + tw(t, COVER - 0.12, 0.45, E.in) * 0.06).toFixed(4)})`, filter: t > COVER - 0.1 ? `blur(${(tw(t, COVER - 0.12, 0.45) * 12).toFixed(1)}px)` : undefined }}>
|
| 60 |
+
<Cover W={W} H={H} P={P} t={t} />
|
| 61 |
+
</div>
|
| 62 |
+
)}
|
| 63 |
+
{pcm ? (
|
| 64 |
+
<PcmTrack pcm={pcm} />
|
| 65 |
+
) : (
|
| 66 |
+
<>
|
| 67 |
+
{mainSrc && <Audio src={mainSrc} />}
|
| 68 |
+
{musicSrc && music && <Audio src={musicSrc} />}
|
| 69 |
+
</>
|
| 70 |
+
)}
|
| 71 |
+
</AbsoluteFill>
|
| 72 |
+
)
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
/** 章节标题卡:大号描边数字 + 标题,随后收为左上角页眉 */
|
| 76 |
+
function Chapter() {
|
| 77 |
+
const S = React.useContext(SceneCtx)!
|
| 78 |
+
const { u, P, W, H, M, sc, t } = S
|
| 79 |
+
const info = SCENE_INFO[sc.key as SceneKey]
|
| 80 |
+
const last = sc.idx === S.tl.scenes.length - 1
|
| 81 |
+
const exitX = last ? 0 : tw(t, sc.end - 0.7, 0.7, E.in)
|
| 82 |
+
const m = tw(u, 1.7, 0.9, E.inOut) // 收拢进度
|
| 83 |
+
const cardA = 1 - tw(u, 1.75, 0.55, E.soft)
|
| 84 |
+
const big = P ? 132 : 150
|
| 85 |
+
const small = P ? 60 : 58
|
| 86 |
+
const headerY = P ? 270 : 168
|
| 87 |
+
const cy = H * (P ? 0.47 : 0.5)
|
| 88 |
+
const s = lerp(1, small / big, m)
|
| 89 |
+
// 标题位置:居中 → 左上
|
| 90 |
+
const tx = lerp(W / 2, M, m)
|
| 91 |
+
const ty = lerp(cy + (P ? 40 : 30), headerY, m)
|
| 92 |
+
const numP = tw(u, 0.05, 1.1)
|
| 93 |
+
const enP = tw(u, 0.55, 0.9)
|
| 94 |
+
const lineP = tw(u, 0.2, 1.0)
|
| 95 |
+
const sweep = clamp((u - 0.6) / 1.1)
|
| 96 |
+
return (
|
| 97 |
+
<div style={{ position: 'absolute', inset: 0, opacity: 1 - exitX }}>
|
| 98 |
+
{cardA > 0.001 && (
|
| 99 |
+
<>
|
| 100 |
+
{/* 暗场 */}
|
| 101 |
+
<div style={{ position: 'absolute', inset: 0, background: 'rgba(4,5,7,0.55)', opacity: cardA * (1 - tw(u, 1.4, 0.6)) }} />
|
| 102 |
+
{/* 巨型章节号 */}
|
| 103 |
+
<div
|
| 104 |
+
style={{
|
| 105 |
+
position: 'absolute',
|
| 106 |
+
left: W / 2,
|
| 107 |
+
top: cy - (P ? 330 : 300),
|
| 108 |
+
transform: `translateX(-50%) scale(${lerp(1.25, 1, E.out(numP)) * lerp(1, 0.92, m)})`,
|
| 109 |
+
opacity: clamp(numP * 1.5) * cardA,
|
| 110 |
+
filter: numP < 0.98 ? `blur(${((1 - numP) * 18).toFixed(1)}px)` : undefined,
|
| 111 |
+
...txtStyle({ f: 'num', size: P ? 400 : 420, w: 800, ls: -12, lh: 1 }),
|
| 112 |
+
color: 'transparent',
|
| 113 |
+
WebkitTextStroke: `2px ${hexA(C.gold, 0.55)}`,
|
| 114 |
+
}}
|
| 115 |
+
>
|
| 116 |
+
{info.no}
|
| 117 |
+
</div>
|
| 118 |
+
{/* 数字填充光扫 */}
|
| 119 |
+
<div
|
| 120 |
+
style={{
|
| 121 |
+
position: 'absolute',
|
| 122 |
+
left: W / 2,
|
| 123 |
+
top: cy - (P ? 330 : 300),
|
| 124 |
+
transform: `translateX(-50%) scale(${lerp(1.25, 1, E.out(numP)) * lerp(1, 0.92, m)})`,
|
| 125 |
+
opacity: 0.16 * cardA * clamp(numP * 1.5),
|
| 126 |
+
clipPath: `inset(0 ${(100 - sweep * 100).toFixed(1)}% 0 0)`,
|
| 127 |
+
...txtStyle({ f: 'num', size: P ? 400 : 420, w: 800, ls: -12, lh: 1 }),
|
| 128 |
+
...goldText(),
|
| 129 |
+
}}
|
| 130 |
+
>
|
| 131 |
+
{info.no}
|
| 132 |
+
</div>
|
| 133 |
+
{/* 横向金线 */}
|
| 134 |
+
<div
|
| 135 |
+
style={{
|
| 136 |
+
position: 'absolute',
|
| 137 |
+
left: W / 2 - (W * 0.36 * E.out(lineP)),
|
| 138 |
+
width: W * 0.72 * E.out(lineP),
|
| 139 |
+
top: cy - (P ? 70 : 62),
|
| 140 |
+
height: 1.5,
|
| 141 |
+
background: `linear-gradient(90deg, transparent, ${C.goldHi}, transparent)`,
|
| 142 |
+
opacity: cardA,
|
| 143 |
+
}}
|
| 144 |
+
/>
|
| 145 |
+
{/* 章节英文 */}
|
| 146 |
+
<div
|
| 147 |
+
style={{
|
| 148 |
+
position: 'absolute',
|
| 149 |
+
left: W / 2,
|
| 150 |
+
top: cy + (P ? 170 : 150),
|
| 151 |
+
transform: 'translateX(-50%)',
|
| 152 |
+
opacity: clamp(enP * 1.4) * cardA,
|
| 153 |
+
...txtStyle({ f: 'mono', size: P ? 24 : 22, w: 700, color: C.gold, ls: lerp(26, 12, E.out(enP)) }),
|
| 154 |
+
}}
|
| 155 |
+
>
|
| 156 |
+
{`CHAPTER ${info.no} — ${info.en}`}
|
| 157 |
+
</div>
|
| 158 |
+
</>
|
| 159 |
+
)}
|
| 160 |
+
{/* 标题(居中 → 页眉) */}
|
| 161 |
+
<div
|
| 162 |
+
style={{
|
| 163 |
+
position: 'absolute',
|
| 164 |
+
left: tx,
|
| 165 |
+
top: ty,
|
| 166 |
+
transform: `translate(${lerp(-50, 0, m)}%, -50%) scale(${s.toFixed(4)})`,
|
| 167 |
+
transformOrigin: `${lerp(50, 0, m)}% 50%`,
|
| 168 |
+
...txtStyle({ f: 'serif', size: big, w: 900, lh: 1.1 }),
|
| 169 |
+
}}
|
| 170 |
+
>
|
| 171 |
+
<Chars text={info.title} t={u - 0.25} st={0.09} d={0.9} dy={0.35} blur={16} />
|
| 172 |
+
</div>
|
| 173 |
+
{/* 页眉附属:章节号与英文 */}
|
| 174 |
+
{m > 0.6 && (
|
| 175 |
+
<>
|
| 176 |
+
<div
|
| 177 |
+
style={{
|
| 178 |
+
position: 'absolute',
|
| 179 |
+
left: M,
|
| 180 |
+
top: headerY - (P ? 82 : 76),
|
| 181 |
+
opacity: tw(u, 2.2, 0.5),
|
| 182 |
+
...txtStyle({ f: 'mono', size: P ? 22 : 18, w: 700, color: C.gold, ls: 5 }),
|
| 183 |
+
}}
|
| 184 |
+
>
|
| 185 |
+
{`CHAPTER ${info.no} · ${info.en}`}
|
| 186 |
+
</div>
|
| 187 |
+
<div style={{ position: 'absolute', left: M, top: headerY + (P ? 48 : 44), width: 64 * tw(u, 2.3, 0.6), height: 2, background: C.gold }} />
|
| 188 |
+
</>
|
| 189 |
+
)}
|
| 190 |
+
</div>
|
| 191 |
+
)
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
function Hud({ t, W, H, P, tl }: { t: number; W: number; H: number; P: boolean; tl: VProps['tl'] }) {
|
| 195 |
+
const M = P ? 80 : 140
|
| 196 |
+
const sc = tl.scenes.find((s) => t >= s.start && t < s.end) ?? tl.scenes[0]
|
| 197 |
+
const info = SCENE_INFO[sc.key as SceneKey]
|
| 198 |
+
const a = tw(t, COVER + 0.6, 1.2) * (1 - tw(t, tl.duration - 2.2, 1.5))
|
| 199 |
+
const top = P ? 120 : 62
|
| 200 |
+
const barY = P ? H - 70 : H - 40
|
| 201 |
+
const pw = W - M * 2
|
| 202 |
+
return (
|
| 203 |
+
<div style={{ position: 'absolute', inset: 0, opacity: a }}>
|
| 204 |
+
<div style={{ position: 'absolute', left: M, top, display: 'flex', alignItems: 'center', gap: 12 }}>
|
| 205 |
+
<div style={{ width: 9, height: 9, background: C.gold, transform: 'rotate(45deg)' }} />
|
| 206 |
+
<div style={txtStyle({ f: 'mono', size: P ? 20 : 16, w: 700, color: C.mute, ls: 4 })}>KKNDME · 15-YEAR AUDIT</div>
|
| 207 |
+
</div>
|
| 208 |
+
{sc.idx > 0 && (
|
| 209 |
+
<div style={{ position: 'absolute', right: M, top, display: 'flex', alignItems: 'baseline', gap: 10 }}>
|
| 210 |
+
<div style={txtStyle({ f: 'mono', size: P ? 20 : 16, w: 700, color: C.gold, ls: 3 })}>{info.no}</div>
|
| 211 |
+
<div style={txtStyle({ f: 'mono', size: P ? 20 : 16, w: 500, color: C.dim, ls: 3 })}>/ 13</div>
|
| 212 |
+
</div>
|
| 213 |
+
)}
|
| 214 |
+
{/* 进度条 */}
|
| 215 |
+
<div style={{ position: 'absolute', left: M, top: barY, width: pw, height: 2, background: 'rgba(243,238,228,0.08)' }} />
|
| 216 |
+
<div style={{ position: 'absolute', left: M, top: barY, width: pw * clamp(t / tl.duration), height: 2, background: `linear-gradient(90deg, ${C.goldDeep}, ${C.goldHi})` }} />
|
| 217 |
+
{tl.scenes.map((s) =>
|
| 218 |
+
s.idx === 0 ? null : (
|
| 219 |
+
<div key={s.key} style={{ position: 'absolute', left: M + pw * (s.start / tl.duration) - 1, top: barY - 3, width: 2, height: 8, background: t >= s.start ? C.goldHi : 'rgba(243,238,228,0.25)' }} />
|
| 220 |
+
),
|
| 221 |
+
)}
|
| 222 |
+
</div>
|
| 223 |
+
)
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
function Subtitles({ t, W, H, P, tl }: { t: number; W: number; H: number; P: boolean; tl: VProps['tl'] }) {
|
| 227 |
+
const l = tl.lines.find((x) => t >= x.start - 0.15 && t < x.end + 0.3)
|
| 228 |
+
if (!l) return null
|
| 229 |
+
const a = tw(t, l.start - 0.15, 0.3, E.soft) * (1 - tw(t, l.end + 0.05, 0.25, E.soft))
|
| 230 |
+
const rise = (1 - tw(t, l.start - 0.15, 0.45)) * 14
|
| 231 |
+
const parts = l.text.split(/(\d[\d.,]*%?|“[^”]*”)/g)
|
| 232 |
+
const size = P ? 44 : 38
|
| 233 |
+
// 音量:取前后几帧的最大值再平滑,避免闪烁
|
| 234 |
+
const dt = 1 / AMP_RATE
|
| 235 |
+
const raw = Math.max(ampAt(tl, t), ampAt(tl, t - dt) * 0.85, ampAt(tl, t - dt * 2) * 0.6)
|
| 236 |
+
const amp = clamp(raw) * a
|
| 237 |
+
return (
|
| 238 |
+
<>
|
| 239 |
+
<div
|
| 240 |
+
style={{
|
| 241 |
+
position: 'absolute',
|
| 242 |
+
left: 0,
|
| 243 |
+
right: 0,
|
| 244 |
+
top: P ? H - 380 : H - 210,
|
| 245 |
+
height: P ? 380 : 210,
|
| 246 |
+
background: 'linear-gradient(180deg, rgba(4,5,7,0) 0%, rgba(4,5,7,0.62) 60%, rgba(4,5,7,0.75) 100%)',
|
| 247 |
+
}}
|
| 248 |
+
/>
|
| 249 |
+
<div
|
| 250 |
+
style={{
|
| 251 |
+
position: 'absolute',
|
| 252 |
+
left: P ? 50 : 160,
|
| 253 |
+
right: P ? 50 : 160,
|
| 254 |
+
top: P ? H - 330 : H - 150,
|
| 255 |
+
opacity: a,
|
| 256 |
+
transform: `translateY(${rise.toFixed(1)}px)`,
|
| 257 |
+
display: 'flex',
|
| 258 |
+
alignItems: 'center',
|
| 259 |
+
justifyContent: 'center',
|
| 260 |
+
gap: P ? 26 : 24,
|
| 261 |
+
}}
|
| 262 |
+
>
|
| 263 |
+
<VoiceAvatar d={Math.round(size * 1.45)} amp={amp} t={t} />
|
| 264 |
+
<div
|
| 265 |
+
style={{
|
| 266 |
+
flex: '0 1 auto',
|
| 267 |
+
minWidth: 0,
|
| 268 |
+
textAlign: 'center',
|
| 269 |
+
...txtStyle({ f: 'cn', size, w: 700, color: C.ink, lh: 1.45, nowrap: false }),
|
| 270 |
+
textShadow: '0 2px 12px rgba(0,0,0,0.8)',
|
| 271 |
+
}}
|
| 272 |
+
>
|
| 273 |
+
{parts.map((p, i) =>
|
| 274 |
+
i % 2 === 1 ? (
|
| 275 |
+
<span key={i} style={{ color: C.goldHi }}>
|
| 276 |
+
{p}
|
| 277 |
+
</span>
|
| 278 |
+
) : (
|
| 279 |
+
<React.Fragment key={i}>{p}</React.Fragment>
|
| 280 |
+
),
|
| 281 |
+
)}
|
| 282 |
+
</div>
|
| 283 |
+
</div>
|
| 284 |
+
</>
|
| 285 |
+
)
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
export { CARD }
|
kkndme/frontend/src/rv/assets.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* 导出前把视频里用到的图片一次性下载成本地 blob 地址,渲染过程中不再访问网络。
|
| 3 |
+
* 长时间导出时站点登录凭证可能过期或网络抖动,现取图片会失败并中断整个导出。
|
| 4 |
+
*/
|
| 5 |
+
const local = new Map<string, string>()
|
| 6 |
+
|
| 7 |
+
/** 渲染时使用:已缓存则返回本地地址,否则返回原地址 */
|
| 8 |
+
export const asset = (url: string) => local.get(url) ?? url
|
| 9 |
+
|
| 10 |
+
async function fetchOne(url: string, tries = 3): Promise<void> {
|
| 11 |
+
if (local.has(url)) return
|
| 12 |
+
let last: unknown
|
| 13 |
+
for (let i = 0; i < tries; i++) {
|
| 14 |
+
try {
|
| 15 |
+
const r = await fetch(url, { credentials: 'same-origin' })
|
| 16 |
+
if (!r.ok) throw new Error(`HTTP ${r.status}`)
|
| 17 |
+
const b = await r.blob()
|
| 18 |
+
if (!b.type.startsWith('image/') && b.size < 1024) throw new Error('not an image')
|
| 19 |
+
local.set(url, URL.createObjectURL(b))
|
| 20 |
+
return
|
| 21 |
+
} catch (e) {
|
| 22 |
+
last = e
|
| 23 |
+
await new Promise((res) => setTimeout(res, 600 * (i + 1)))
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
throw last
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/** 预先缓存全部图片;任何一张失败都会抛错,让导出在开头就给出明确提示 */
|
| 30 |
+
export async function preloadAssets(urls: string[]): Promise<void> {
|
| 31 |
+
const list = [...new Set(urls)]
|
| 32 |
+
let i = 0
|
| 33 |
+
const worker = async () => {
|
| 34 |
+
while (i < list.length) {
|
| 35 |
+
const u = list[i++]
|
| 36 |
+
await fetchOne(u)
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
await Promise.all([worker(), worker(), worker(), worker()])
|
| 40 |
+
// 等浏览器解码好,避免渲染时再等待
|
| 41 |
+
await Promise.all(
|
| 42 |
+
list.map(
|
| 43 |
+
(u) =>
|
| 44 |
+
new Promise<void>((res) => {
|
| 45 |
+
const im = new Image()
|
| 46 |
+
im.onload = im.onerror = () => res()
|
| 47 |
+
im.src = asset(u)
|
| 48 |
+
im.decode?.().then(() => res(), () => res())
|
| 49 |
+
}),
|
| 50 |
+
),
|
| 51 |
+
)
|
| 52 |
+
}
|
kkndme/frontend/src/rv/brand.tsx
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// 主持人品牌元素:片头封面、Claude 吉祥物、字幕头像(随声音跳动)、片尾关注卡
|
| 2 |
+
import React from 'react'
|
| 3 |
+
import { Img } from 'remotion'
|
| 4 |
+
import { asset } from './assets'
|
| 5 |
+
import { C, E, clamp, hexA, lerp, tw, spr } from './theme'
|
| 6 |
+
import { txtStyle, goldText, shineStyle } from './ui'
|
| 7 |
+
import { CLAWD_PX, CLAWD_W, CLAWD_H, CLAWD_ORANGE, HOST_IMG, burstPath } from '../video/clawd'
|
| 8 |
+
import { all, rows } from '../data/science'
|
| 9 |
+
|
| 10 |
+
type CSS = React.CSSProperties
|
| 11 |
+
const BASE = import.meta.env.BASE_URL
|
| 12 |
+
export const HOST_SRC = `${BASE}brand/host.png`
|
| 13 |
+
export const AVATAR_SRC = `${BASE}brand/avatar.jpg`
|
| 14 |
+
export const HOST_NAME = '子木土土'
|
| 15 |
+
|
| 16 |
+
/** Claude 吉祥物 Clawd(像素风) */
|
| 17 |
+
export function Clawd({ w, t = 0, style }: { w: number; t?: number; style?: CSS }) {
|
| 18 |
+
const h = (w * CLAWD_H) / CLAWD_W
|
| 19 |
+
const blink = (t % 3.2) > 3.05 ? 0.15 : 1
|
| 20 |
+
const step = Math.sin(t * 9)
|
| 21 |
+
return (
|
| 22 |
+
<svg width={w} height={h} viewBox={`0 0 ${CLAWD_W} ${CLAWD_H}`} shapeRendering="crispEdges" style={{ overflow: 'visible', ...style }}>
|
| 23 |
+
{CLAWD_PX.map((p, i) => {
|
| 24 |
+
let { y, h: ph } = p
|
| 25 |
+
if (p.part === 'eye') {
|
| 26 |
+
const c = y + ph / 2
|
| 27 |
+
ph *= blink
|
| 28 |
+
y = c - ph / 2
|
| 29 |
+
}
|
| 30 |
+
if (p.part === 'leg') ph -= (i % 2 ? step : -step) > 0.6 ? 0.25 : 0
|
| 31 |
+
const dy = p.part === 'arm' ? Math.sin(t * 4 + i) * 0.25 : 0
|
| 32 |
+
return <rect key={i} x={p.x} y={y + dy} width={p.w} height={ph} fill={p.c} />
|
| 33 |
+
})}
|
| 34 |
+
</svg>
|
| 35 |
+
)
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/** Claude 星芒 */
|
| 39 |
+
export function Burst({ size, color = CLAWD_ORANGE, rot = 0 }: { size: number; color?: string; rot?: number }) {
|
| 40 |
+
return (
|
| 41 |
+
<svg width={size} height={size} viewBox="0 0 20 20" style={{ flex: 'none', transform: `rotate(${rot}deg)` }}>
|
| 42 |
+
<path d={burstPath(10, 10, 10)} fill={color} />
|
| 43 |
+
</svg>
|
| 44 |
+
)
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/** 名字标签:Opus 5.5 */
|
| 48 |
+
export function NameTag({ size = 32, t = 0 }: { size?: number; t?: number }) {
|
| 49 |
+
return (
|
| 50 |
+
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
| 51 |
+
<div
|
| 52 |
+
style={{
|
| 53 |
+
display: 'flex',
|
| 54 |
+
alignItems: 'center',
|
| 55 |
+
gap: size * 0.3,
|
| 56 |
+
padding: `${size * 0.26}px ${size * 0.55}px ${size * 0.26}px ${size * 0.42}px`,
|
| 57 |
+
borderRadius: size,
|
| 58 |
+
background: '#141110',
|
| 59 |
+
border: `${Math.max(2, size * 0.08)}px solid ${CLAWD_ORANGE}`,
|
| 60 |
+
boxShadow: `0 0 ${size}px ${hexA(CLAWD_ORANGE, 0.45)}, 0 10px 30px rgba(0,0,0,0.5)`,
|
| 61 |
+
}}
|
| 62 |
+
>
|
| 63 |
+
<Burst size={size * 0.9} rot={t * 40} />
|
| 64 |
+
<div style={txtStyle({ f: 'num', size, w: 800, color: '#FFF6EE', ls: 0.5 })}>Opus 5.5</div>
|
| 65 |
+
</div>
|
| 66 |
+
<svg width={size * 0.8} height={size * 0.45} viewBox="0 0 16 9" style={{ marginTop: -Math.max(2, size * 0.08) }}>
|
| 67 |
+
<path d="M0 0 L8 9 L16 0 Z" fill={CLAWD_ORANGE} />
|
| 68 |
+
</svg>
|
| 69 |
+
</div>
|
| 70 |
+
)
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
/** 主持人照片 + 手掌上的吉祥物 */
|
| 74 |
+
function HostWithMascot({ x, y, h, t }: { x: number; y: number; h: number; t: number }) {
|
| 75 |
+
const w = (h * HOST_IMG.w) / HOST_IMG.h
|
| 76 |
+
const mw = w * HOST_IMG.mascotW
|
| 77 |
+
const mh = (mw * CLAWD_H) / CLAWD_W
|
| 78 |
+
const px = x + w * HOST_IMG.palmX
|
| 79 |
+
const py = y + h * HOST_IMG.palmY
|
| 80 |
+
const bob = Math.abs(Math.sin(t * 3.2)) * mh * 0.08
|
| 81 |
+
return (
|
| 82 |
+
<>
|
| 83 |
+
<div style={{ position: 'absolute', left: px - mw * 1.3, top: py - mh * 2.2, width: mw * 2.6, height: mw * 2.6, borderRadius: '50%', background: `radial-gradient(circle, ${hexA(CLAWD_ORANGE, 0.28)} 0%, ${hexA(CLAWD_ORANGE, 0)} 65%)` }} />
|
| 84 |
+
<Img src={asset(HOST_SRC)} style={{ position: 'absolute', left: x, top: y, width: w, height: h }} />
|
| 85 |
+
{/* 手掌上的光晕阴影 */}
|
| 86 |
+
<div style={{ position: 'absolute', left: px - mw * 0.42, top: py - mh * 0.07, width: mw * 0.84, height: mh * 0.16, borderRadius: '50%', background: 'rgba(40,20,10,0.35)', filter: 'blur(4px)' }} />
|
| 87 |
+
<div style={{ position: 'absolute', left: px - mw / 2, top: py - mh + mh * 0.02 - bob }}>
|
| 88 |
+
<Clawd w={mw} t={t} />
|
| 89 |
+
</div>
|
| 90 |
+
<div style={{ position: 'absolute', left: px, top: py - mh - bob - mw * 0.06, transform: 'translate(-50%, -100%)' }}>
|
| 91 |
+
<NameTag size={mw * 0.15} t={t} />
|
| 92 |
+
</div>
|
| 93 |
+
</>
|
| 94 |
+
)
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
/** 片头封面(视频第 1 秒) */
|
| 98 |
+
export function Cover({ W, H, P, t }: { W: number; H: number; P: boolean; t: number }) {
|
| 99 |
+
const stats: [string, string, string][] = [
|
| 100 |
+
[String(rows.length), '条预测', C.ink],
|
| 101 |
+
[String(all.correct), '条说对', C.green],
|
| 102 |
+
[String(all.wrong), '条说错', C.red],
|
| 103 |
+
]
|
| 104 |
+
const shine = shineStyle(clamp(t / 1.0) * 1.4 - 0.2)
|
| 105 |
+
const L = P ? 90 : 130
|
| 106 |
+
const hostH = P ? 1160 : 1040
|
| 107 |
+
const hostW = (hostH * HOST_IMG.w) / HOST_IMG.h
|
| 108 |
+
const hostX = P ? (W - hostW) / 2 : W - hostW - 30
|
| 109 |
+
const hostY = P ? H - hostH + 20 : 50
|
| 110 |
+
return (
|
| 111 |
+
<div style={{ position: 'absolute', inset: 0, background: `linear-gradient(160deg, ${C.bg2} 0%, ${C.bg} 70%)`, overflow: 'hidden' }}>
|
| 112 |
+
<div style={{ position: 'absolute', left: P ? W * 0.5 - 700 : W * 0.78 - 700, top: P ? H * 0.68 - 700 : H * 0.52 - 700, width: 1400, height: 1400, borderRadius: '50%', background: `radial-gradient(circle, ${hexA(C.gold, 0.2)} 0%, ${hexA(C.gold, 0.05)} 40%, transparent 68%)` }} />
|
| 113 |
+
{/* 细网格 */}
|
| 114 |
+
<svg width={W} height={H} style={{ position: 'absolute', left: 0, top: 0, opacity: 0.5 }}>
|
| 115 |
+
{Array.from({ length: Math.ceil(W / 120) }, (_, i) => (
|
| 116 |
+
<line key={`v${i}`} x1={i * 120} x2={i * 120} y1={0} y2={H} stroke="rgba(243,238,228,0.035)" />
|
| 117 |
+
))}
|
| 118 |
+
{Array.from({ length: Math.ceil(H / 120) }, (_, i) => (
|
| 119 |
+
<line key={`h${i}`} y1={i * 120} y2={i * 120} x1={0} x2={W} stroke="rgba(243,238,228,0.035)" />
|
| 120 |
+
))}
|
| 121 |
+
</svg>
|
| 122 |
+
<div style={{ position: 'absolute', left: 34, top: 34, right: 34, bottom: 34, border: `1px solid ${hexA(C.gold, 0.22)}`, borderRadius: 18 }} />
|
| 123 |
+
|
| 124 |
+
<HostWithMascot x={hostX} y={hostY} h={hostH} t={t} />
|
| 125 |
+
|
| 126 |
+
{/* 文字 */}
|
| 127 |
+
<div style={{ position: 'absolute', left: L, top: P ? 110 : 110, right: P ? L : undefined, display: 'flex', alignItems: 'center', gap: 16, justifyContent: P ? 'center' : undefined }}>
|
| 128 |
+
<div style={{ width: 8, height: 32, background: C.gold }} />
|
| 129 |
+
<div style={txtStyle({ f: 'cn', size: P ? 32 : 30, w: 700, color: C.ink2, ls: 4 })}>天涯神贴 · 房地产圣经 · 十五年对账</div>
|
| 130 |
+
</div>
|
| 131 |
+
<div style={{ position: 'absolute', left: P ? 0 : L, width: P ? W : undefined, top: P ? 180 : 180, display: 'flex', alignItems: 'center', gap: P ? 26 : 34, justifyContent: P ? 'center' : undefined }}>
|
| 132 |
+
<div style={{ display: 'flex', alignItems: 'baseline', filter: `drop-shadow(0 0 30px ${hexA(C.gold, 0.35)})` }}>
|
| 133 |
+
<span style={{ ...txtStyle({ f: 'serif', size: P ? 176 : 206, w: 900, lh: 1 }), ...shine }}>KK</span>
|
| 134 |
+
<span style={{ ...txtStyle({ f: 'serif', size: P ? 132 : 154, w: 900, lh: 1 }), ...goldText() }}>ndme</span>
|
| 135 |
+
</div>
|
| 136 |
+
<div
|
| 137 |
+
style={{
|
| 138 |
+
border: `5px solid ${C.red}`,
|
| 139 |
+
borderRadius: 14,
|
| 140 |
+
padding: P ? '8px 18px' : '10px 22px',
|
| 141 |
+
transform: 'rotate(-8deg)',
|
| 142 |
+
boxShadow: `0 0 34px ${hexA(C.red, 0.45)}`,
|
| 143 |
+
background: hexA(C.red, 0.08),
|
| 144 |
+
textAlign: 'center',
|
| 145 |
+
}}
|
| 146 |
+
>
|
| 147 |
+
<div style={txtStyle({ f: 'serif', size: P ? 54 : 62, w: 900, color: C.red, lh: 1, ls: 4 })}>KK大神</div>
|
| 148 |
+
<div style={{ ...txtStyle({ f: 'mono', size: P ? 14 : 15, w: 700, color: C.red, ls: 3 }), marginTop: 6 }}>天涯 · 2010</div>
|
| 149 |
+
</div>
|
| 150 |
+
</div>
|
| 151 |
+
<div style={{ position: 'absolute', left: P ? 0 : L, width: P ? W : undefined, top: P ? 395 : 430, textAlign: P ? 'center' : 'left' }}>
|
| 152 |
+
<div style={{ ...txtStyle({ f: 'serif', size: P ? 80 : 90, w: 900, lh: 1.15 }) }}>
|
| 153 |
+
神贴到底<span style={goldText()}>说对了多少?</span>
|
| 154 |
+
</div>
|
| 155 |
+
</div>
|
| 156 |
+
<div style={{ position: 'absolute', left: P ? 0 : L, width: P ? W : undefined, top: P ? 520 : 580, display: 'flex', gap: P ? 50 : 64, justifyContent: P ? 'center' : undefined }}>
|
| 157 |
+
{stats.map(([v, l, c]) => (
|
| 158 |
+
<div key={l} style={{ display: 'flex', alignItems: 'baseline', gap: 8 }}>
|
| 159 |
+
<div style={txtStyle({ f: 'num', size: P ? 76 : 92, w: 800, color: c, ls: -2 })}>{v}</div>
|
| 160 |
+
<div style={txtStyle({ f: 'cn', size: P ? 28 : 30, w: 700, color: C.mute })}>{l}</div>
|
| 161 |
+
</div>
|
| 162 |
+
))}
|
| 163 |
+
</div>
|
| 164 |
+
<div
|
| 165 |
+
style={{
|
| 166 |
+
position: 'absolute',
|
| 167 |
+
left: P ? '50%' : L,
|
| 168 |
+
top: P ? 650 : 760,
|
| 169 |
+
transform: P ? 'translateX(-50%)' : undefined,
|
| 170 |
+
display: 'flex',
|
| 171 |
+
alignItems: 'center',
|
| 172 |
+
gap: P ? 18 : 24,
|
| 173 |
+
padding: P ? '16px 30px' : '22px 34px',
|
| 174 |
+
borderRadius: 22,
|
| 175 |
+
background: 'linear-gradient(155deg, rgba(217,119,87,0.16), rgba(255,255,255,0.03))',
|
| 176 |
+
border: `1.5px solid ${hexA(CLAWD_ORANGE, 0.55)}`,
|
| 177 |
+
whiteSpace: 'nowrap',
|
| 178 |
+
}}
|
| 179 |
+
>
|
| 180 |
+
<Clawd w={P ? 70 : 92} t={t} />
|
| 181 |
+
<div>
|
| 182 |
+
<div style={{ ...txtStyle({ f: 'cn', size: P ? 30 : 36, w: 800 }) }}>
|
| 183 |
+
我用 <span style={{ color: '#F3A283' }}>Claude Opus 5.5</span> 通读
|
| 184 |
+
</div>
|
| 185 |
+
<div style={{ ...txtStyle({ f: 'cn', size: P ? 24 : 28, w: 600, color: C.ink2 }), marginTop: 6 }}>
|
| 186 |
+
2 份文件 · <span style={shine}>986</span> 页 · 约 <span style={shine}>54</span> 万字
|
| 187 |
+
</div>
|
| 188 |
+
</div>
|
| 189 |
+
</div>
|
| 190 |
+
</div>
|
| 191 |
+
)
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
/** 字幕头像:圆形头像 + 随旁白音量跳动的声波环 */
|
| 195 |
+
export function VoiceAvatar({ d, amp, t }: { d: number; amp: number; t: number }) {
|
| 196 |
+
const n = 28
|
| 197 |
+
const r0 = d / 2 + 4
|
| 198 |
+
const maxL = d * 0.32
|
| 199 |
+
const box = d + maxL * 2 + 12
|
| 200 |
+
const c = box / 2
|
| 201 |
+
return (
|
| 202 |
+
<div style={{ position: 'relative', width: d, height: d, flex: 'none' }}>
|
| 203 |
+
<svg width={box} height={box} style={{ position: 'absolute', left: (d - box) / 2, top: (d - box) / 2, overflow: 'visible' }}>
|
| 204 |
+
<circle cx={c} cy={c} r={d / 2 + 2 + amp * 6} fill="none" stroke={C.goldHi} strokeOpacity={0.25 + amp * 0.6} strokeWidth={2} />
|
| 205 |
+
<circle cx={c} cy={c} r={d / 2 + 8 + amp * 14} fill="none" stroke={C.gold} strokeOpacity={amp * 0.35} strokeWidth={1.5} />
|
| 206 |
+
{Array.from({ length: n }, (_, i) => {
|
| 207 |
+
const a = (i / n) * Math.PI * 2 - Math.PI / 2
|
| 208 |
+
const wob = 0.55 + 0.45 * Math.sin(t * 11 + i * 1.7) * Math.cos(t * 7 - i * 0.9)
|
| 209 |
+
const L = 2 + maxL * amp * Math.abs(wob)
|
| 210 |
+
const x1 = c + Math.cos(a) * (r0 + 6)
|
| 211 |
+
const y1 = c + Math.sin(a) * (r0 + 6)
|
| 212 |
+
const x2 = c + Math.cos(a) * (r0 + 6 + L)
|
| 213 |
+
const y2 = c + Math.sin(a) * (r0 + 6 + L)
|
| 214 |
+
return <line key={i} x1={x1} y1={y1} x2={x2} y2={y2} stroke={i % 2 ? C.goldHi : C.gold} strokeWidth={2.4} strokeLinecap="round" opacity={0.45 + amp * 0.55} />
|
| 215 |
+
})}
|
| 216 |
+
</svg>
|
| 217 |
+
<Img src={asset(AVATAR_SRC)} style={{ position: 'absolute', left: 0, top: 0, width: d, height: d, borderRadius: '50%', objectFit: 'cover', border: `2px solid ${C.goldHi}`, boxSizing: 'border-box', transform: `scale(${(1 + amp * 0.06).toFixed(3)})` }} />
|
| 218 |
+
</div>
|
| 219 |
+
)
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
/** 片尾关注卡:头像 + 关注 / 点赞 / 评论(按旁白节奏依次点亮) */
|
| 223 |
+
export function CtaCard({ W, P, u, at }: { W: number; P: boolean; u: number; at: [number, number, number] }) {
|
| 224 |
+
const pin = tw(u, 0, 0.9)
|
| 225 |
+
const D = P ? 260 : 230
|
| 226 |
+
const btn = P ? 34 : 32
|
| 227 |
+
const items = [
|
| 228 |
+
{ key: 'follow', label: '关注', done: '已关注', color: C.goldHi },
|
| 229 |
+
{ key: 'like', label: '点赞', done: '已点赞', color: '#FF5C7A' },
|
| 230 |
+
{ key: 'comment', label: '评论', done: '评论区见', color: C.sky },
|
| 231 |
+
] as const
|
| 232 |
+
const pulse = (u * 0.8) % 1
|
| 233 |
+
return (
|
| 234 |
+
<div style={{ position: 'relative', width: W, display: 'flex', flexDirection: 'column', alignItems: 'center', opacity: clamp(pin * 1.4), transform: `translateY(${((1 - pin) * 40).toFixed(1)}px)` }}>
|
| 235 |
+
<div style={{ position: 'relative', width: D, height: D }}>
|
| 236 |
+
{[0, 0.5].map((o) => {
|
| 237 |
+
const q = (pulse + o) % 1
|
| 238 |
+
return <div key={o} style={{ position: 'absolute', left: -D * 0.25 * q, top: -D * 0.25 * q, width: D * (1 + 0.5 * q), height: D * (1 + 0.5 * q), borderRadius: '50%', border: `2px solid ${hexA(C.gold, 0.6 * (1 - q))}` }} />
|
| 239 |
+
})}
|
| 240 |
+
<svg width={D + 28} height={D + 28} style={{ position: 'absolute', left: -14, top: -14, transform: `rotate(${(u * 30).toFixed(1)}deg)` }}>
|
| 241 |
+
<circle cx={(D + 28) / 2} cy={(D + 28) / 2} r={D / 2 + 9} fill="none" stroke={C.goldHi} strokeWidth={3} strokeDasharray="22 14" strokeLinecap="round" />
|
| 242 |
+
</svg>
|
| 243 |
+
<Img src={asset(AVATAR_SRC)} style={{ position: 'absolute', left: 0, top: 0, width: D, height: D, borderRadius: '50%', objectFit: 'cover', border: `4px solid ${C.goldHi}`, boxSizing: 'border-box', boxShadow: `0 0 60px ${hexA(C.gold, 0.4)}` }} />
|
| 244 |
+
{/* 关注 + 号 */}
|
| 245 |
+
{(() => {
|
| 246 |
+
const q = spr(u - (at[0] - 0.05), { k: 12, z: 0.45 })
|
| 247 |
+
const done = q > 0.5
|
| 248 |
+
return (
|
| 249 |
+
<div style={{ position: 'absolute', left: D / 2 - 26, top: D - 30, width: 52, height: 52, borderRadius: '50%', background: done ? C.green : '#FF4D5E', border: `4px solid ${C.bg}`, display: 'flex', alignItems: 'center', justifyContent: 'center', transform: `scale(${(1 + Math.max(0, Math.sin(clamp(q) * Math.PI)) * 0.35).toFixed(3)})` }}>
|
| 250 |
+
<svg width={24} height={24} viewBox="0 0 24 24">
|
| 251 |
+
{done ? <path d="M5 12.5 L10 17 L19 7" stroke="#fff" strokeWidth={3.4} fill="none" strokeLinecap="round" strokeLinejoin="round" /> : <path d="M12 4 V20 M4 12 H20" stroke="#fff" strokeWidth={3.4} strokeLinecap="round" />}
|
| 252 |
+
</svg>
|
| 253 |
+
</div>
|
| 254 |
+
)
|
| 255 |
+
})()}
|
| 256 |
+
</div>
|
| 257 |
+
<div style={{ ...txtStyle({ f: 'serif', size: P ? 64 : 58, w: 900 }), marginTop: P ? 44 : 34 }}>{HOST_NAME}</div>
|
| 258 |
+
<div style={{ ...txtStyle({ f: 'cn', size: P ? 28 : 24, w: 600, color: C.mute }), marginTop: 10 }}>用数据,把神贴的账一笔笔算清楚</div>
|
| 259 |
+
<div style={{ display: 'flex', gap: P ? 22 : 30, marginTop: P ? 56 : 40 }}>
|
| 260 |
+
{items.map((it, i) => {
|
| 261 |
+
const s0 = at[i]
|
| 262 |
+
const appear = spr(u - 0.25 - i * 0.12, { k: 10, z: 0.6 })
|
| 263 |
+
const hit = spr(u - s0, { k: 13, z: 0.4 })
|
| 264 |
+
const on = u >= s0
|
| 265 |
+
const pop = on ? 1 + Math.max(0, Math.sin(clamp(hit) * Math.PI)) * 0.16 : 1
|
| 266 |
+
return (
|
| 267 |
+
<div key={it.key} style={{ position: 'relative', opacity: clamp(appear * 2), transform: `translateY(${((1 - clamp(appear)) * 30).toFixed(1)}px) scale(${pop.toFixed(3)})` }}>
|
| 268 |
+
{on && <Ripple u={u - s0} color={it.color} w={P ? 280 : 260} h={P ? 100 : 92} />}
|
| 269 |
+
<div
|
| 270 |
+
style={{
|
| 271 |
+
width: P ? 280 : 260,
|
| 272 |
+
height: P ? 100 : 92,
|
| 273 |
+
borderRadius: 999,
|
| 274 |
+
display: 'flex',
|
| 275 |
+
alignItems: 'center',
|
| 276 |
+
justifyContent: 'center',
|
| 277 |
+
gap: 14,
|
| 278 |
+
background: on ? `linear-gradient(135deg, ${hexA(it.color, 0.32)}, ${hexA(it.color, 0.12)})` : 'rgba(255,255,255,0.06)',
|
| 279 |
+
border: `2px solid ${on ? it.color : 'rgba(243,238,228,0.2)'}`,
|
| 280 |
+
boxShadow: on ? `0 0 40px ${hexA(it.color, 0.35)}` : 'none',
|
| 281 |
+
}}
|
| 282 |
+
>
|
| 283 |
+
<CtaIcon kind={it.key} on={on} q={hit} size={btn + 8} color={it.color} />
|
| 284 |
+
<div style={txtStyle({ f: 'cn', size: btn, w: 800, color: on ? '#fff' : C.ink2 })}>{on ? it.done : it.label}</div>
|
| 285 |
+
</div>
|
| 286 |
+
{it.key === 'like' && on && <Hearts u={u - s0} />}
|
| 287 |
+
</div>
|
| 288 |
+
)
|
| 289 |
+
})}
|
| 290 |
+
</div>
|
| 291 |
+
</div>
|
| 292 |
+
)
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
function Ripple({ u, color, w, h }: { u: number; color: string; w: number; h: number }) {
|
| 296 |
+
const q = clamp(u / 0.7)
|
| 297 |
+
if (q >= 1) return null
|
| 298 |
+
return <div style={{ position: 'absolute', left: (-w * 0.2 * q) / 2, top: (-h * 0.5 * q) / 2, width: w * (1 + 0.2 * q), height: h * (1 + 0.5 * q), borderRadius: 999, border: `3px solid ${hexA(color, 0.8 * (1 - q))}` }} />
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
function Hearts({ u }: { u: number }) {
|
| 302 |
+
return (
|
| 303 |
+
<>
|
| 304 |
+
{Array.from({ length: 7 }, (_, i) => {
|
| 305 |
+
const q = clamp((u - i * 0.06) / 1.3)
|
| 306 |
+
if (q <= 0 || q >= 1) return null
|
| 307 |
+
const dx = (i - 3) * 26 + Math.sin(i * 2.1 + u * 3) * 10
|
| 308 |
+
const dy = -E.out(q) * (120 + (i % 3) * 30)
|
| 309 |
+
return (
|
| 310 |
+
<svg key={i} width={30} height={28} viewBox="0 0 24 22" style={{ position: 'absolute', left: 115 + dx, top: 20 + dy, opacity: 1 - q, transform: `scale(${lerp(0.6, 1.1, q).toFixed(2)})` }}>
|
| 311 |
+
<path d={HEART} fill="#FF5C7A" />
|
| 312 |
+
</svg>
|
| 313 |
+
)
|
| 314 |
+
})}
|
| 315 |
+
</>
|
| 316 |
+
)
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
const HEART = 'M12 21 C12 21 2 14.5 2 8 C2 4.7 4.6 2.5 7.4 2.5 C9.4 2.5 11 3.6 12 5.2 C13 3.6 14.6 2.5 16.6 2.5 C19.4 2.5 22 4.7 22 8 C22 14.5 12 21 12 21 Z'
|
| 320 |
+
|
| 321 |
+
function CtaIcon({ kind, on, q, size, color }: { kind: 'follow' | 'like' | 'comment'; on: boolean; q: number; size: number; color: string }) {
|
| 322 |
+
const s = on ? 1 + Math.max(0, Math.sin(clamp(q) * Math.PI)) * 0.4 : 1
|
| 323 |
+
const st = { transform: `scale(${s.toFixed(3)})`, flex: 'none' as const }
|
| 324 |
+
if (kind === 'like')
|
| 325 |
+
return (
|
| 326 |
+
<svg width={size} height={size} viewBox="0 0 24 22" style={st}>
|
| 327 |
+
<path d={HEART} fill={on ? color : 'none'} stroke={on ? color : C.ink2} strokeWidth={2} />
|
| 328 |
+
</svg>
|
| 329 |
+
)
|
| 330 |
+
if (kind === 'comment')
|
| 331 |
+
return (
|
| 332 |
+
<svg width={size} height={size} viewBox="0 0 24 24" style={st}>
|
| 333 |
+
<path d="M4 5 H20 A2 2 0 0 1 22 7 V15 A2 2 0 0 1 20 17 H10 L5 21 V17 H4 A2 2 0 0 1 2 15 V7 A2 2 0 0 1 4 5 Z" fill={on ? hexA(color, 0.35) : 'none'} stroke={on ? color : C.ink2} strokeWidth={2} strokeLinejoin="round" />
|
| 334 |
+
{[8, 12, 16].map((x) => (
|
| 335 |
+
<circle key={x} cx={x} cy={11} r={1.4} fill={on ? '#fff' : C.ink2} />
|
| 336 |
+
))}
|
| 337 |
+
</svg>
|
| 338 |
+
)
|
| 339 |
+
return (
|
| 340 |
+
<svg width={size} height={size} viewBox="0 0 24 24" style={st}>
|
| 341 |
+
<circle cx={10} cy={8} r={4} fill="none" stroke={on ? color : C.ink2} strokeWidth={2} />
|
| 342 |
+
<path d="M3 20 C3 15.5 6.5 13.5 10 13.5 C12 13.5 13.6 14 14.8 15" fill="none" stroke={on ? color : C.ink2} strokeWidth={2} strokeLinecap="round" />
|
| 343 |
+
{on ? <path d="M15 18 L17.5 20.5 L22 15.5" fill="none" stroke={color} strokeWidth={2.4} strokeLinecap="round" strokeLinejoin="round" /> : <path d="M19 14 V22 M15 18 H23" stroke={C.ink2} strokeWidth={2} strokeLinecap="round" />}
|
| 344 |
+
</svg>
|
| 345 |
+
)
|
| 346 |
+
}
|
kkndme/frontend/src/rv/charts.tsx
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react'
|
| 2 |
+
import { getLength, getPointAtLength } from '@remotion/paths'
|
| 3 |
+
import { C, E, F, clamp, hexA } from './theme'
|
| 4 |
+
|
| 5 |
+
export interface Fr {
|
| 6 |
+
x: number
|
| 7 |
+
y: number
|
| 8 |
+
w: number
|
| 9 |
+
h: number
|
| 10 |
+
x0: number
|
| 11 |
+
x1: number
|
| 12 |
+
y0: number
|
| 13 |
+
y1: number
|
| 14 |
+
}
|
| 15 |
+
export const sx = (f: Fr, v: number) => f.x + ((v - f.x0) / (f.x1 - f.x0)) * f.w
|
| 16 |
+
export const sy = (f: Fr, v: number) => f.y + f.h - ((v - f.y0) / (f.y1 - f.y0)) * f.h
|
| 17 |
+
|
| 18 |
+
export function linePath(f: Fr, pts: [number, number][]) {
|
| 19 |
+
return pts.map(([a, b], i) => `${i ? 'L' : 'M'}${sx(f, a).toFixed(1)},${sy(f, b).toFixed(1)}`).join(' ')
|
| 20 |
+
}
|
| 21 |
+
/** Catmull-Rom 平滑曲线 */
|
| 22 |
+
export function smoothPath(f: Fr, pts: [number, number][], k = 0.5) {
|
| 23 |
+
const P = pts.map(([a, b]) => [sx(f, a), sy(f, b)])
|
| 24 |
+
if (P.length < 3) return linePath(f, pts)
|
| 25 |
+
let d = `M${P[0][0].toFixed(1)},${P[0][1].toFixed(1)}`
|
| 26 |
+
for (let i = 0; i < P.length - 1; i++) {
|
| 27 |
+
const p0 = P[i - 1] ?? P[i]
|
| 28 |
+
const p1 = P[i]
|
| 29 |
+
const p2 = P[i + 1]
|
| 30 |
+
const p3 = P[i + 2] ?? p2
|
| 31 |
+
const c1x = p1[0] + ((p2[0] - p0[0]) / 6) * k * 2
|
| 32 |
+
const c1y = p1[1] + ((p2[1] - p0[1]) / 6) * k * 2
|
| 33 |
+
const c2x = p2[0] - ((p3[0] - p1[0]) / 6) * k * 2
|
| 34 |
+
const c2y = p2[1] - ((p3[1] - p1[1]) / 6) * k * 2
|
| 35 |
+
d += ` C${c1x.toFixed(1)},${c1y.toFixed(1)} ${c2x.toFixed(1)},${c2y.toFixed(1)} ${p2[0].toFixed(1)},${p2[1].toFixed(1)}`
|
| 36 |
+
}
|
| 37 |
+
return d
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
/** 全画幅 SVG 容器 */
|
| 41 |
+
export function Svg({ W, H, children, o = 1, style }: { W: number; H: number; children: React.ReactNode; o?: number; style?: React.CSSProperties }) {
|
| 42 |
+
if (o <= 0.001) return null
|
| 43 |
+
return (
|
| 44 |
+
<svg width={W} height={H} viewBox={`0 0 ${W} ${H}`} style={{ position: 'absolute', left: 0, top: 0, overflow: 'visible', opacity: o < 1 ? o : undefined, ...style }}>
|
| 45 |
+
{children}
|
| 46 |
+
</svg>
|
| 47 |
+
)
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
export const svgText = (size: number, w = 600, f: keyof typeof F = 'sans'): React.CSSProperties => ({ fontFamily: F[f], fontSize: size, fontWeight: w })
|
| 51 |
+
|
| 52 |
+
/** 网格与坐标 */
|
| 53 |
+
export function Grid({
|
| 54 |
+
f,
|
| 55 |
+
yt,
|
| 56 |
+
xt,
|
| 57 |
+
fy = String,
|
| 58 |
+
fx = String,
|
| 59 |
+
p = 1,
|
| 60 |
+
size = 18,
|
| 61 |
+
yLabelX,
|
| 62 |
+
}: {
|
| 63 |
+
f: Fr
|
| 64 |
+
yt: number[]
|
| 65 |
+
xt: number[]
|
| 66 |
+
fy?: (v: number) => string
|
| 67 |
+
fx?: (v: number) => string
|
| 68 |
+
p?: number
|
| 69 |
+
size?: number
|
| 70 |
+
yLabelX?: number
|
| 71 |
+
}) {
|
| 72 |
+
return (
|
| 73 |
+
<g>
|
| 74 |
+
{yt.map((v, i) => {
|
| 75 |
+
const q = E.out(clamp(p * 1.6 - i * 0.08))
|
| 76 |
+
const y = sy(f, v)
|
| 77 |
+
return (
|
| 78 |
+
<g key={'y' + v} opacity={q}>
|
| 79 |
+
<line x1={f.x} x2={f.x + f.w * q} y1={y} y2={y} stroke="rgba(243,238,228,0.09)" strokeWidth={1} strokeDasharray="3 7" />
|
| 80 |
+
<text x={yLabelX ?? f.x - 16} y={y + size * 0.35} textAnchor="end" fill={C.dim} style={svgText(size, 500, 'mono')}>
|
| 81 |
+
{fy(v)}
|
| 82 |
+
</text>
|
| 83 |
+
</g>
|
| 84 |
+
)
|
| 85 |
+
})}
|
| 86 |
+
{xt.map((v, i) => {
|
| 87 |
+
const q = E.out(clamp(p * 1.6 - i * 0.06))
|
| 88 |
+
const x = sx(f, v)
|
| 89 |
+
return (
|
| 90 |
+
<g key={'x' + v} opacity={q}>
|
| 91 |
+
<line x1={x} x2={x} y1={f.y + f.h} y2={f.y + f.h + 8} stroke="rgba(243,238,228,0.3)" strokeWidth={1} />
|
| 92 |
+
<text x={x} y={f.y + f.h + 12 + size} textAnchor="middle" fill={C.mute} style={svgText(size, 500, 'mono')}>
|
| 93 |
+
{fx(v)}
|
| 94 |
+
</text>
|
| 95 |
+
</g>
|
| 96 |
+
)
|
| 97 |
+
})}
|
| 98 |
+
<line x1={f.x} x2={f.x + f.w * E.out(clamp(p * 1.3))} y1={f.y + f.h} y2={f.y + f.h} stroke="rgba(243,238,228,0.35)" strokeWidth={1.2} />
|
| 99 |
+
</g>
|
| 100 |
+
)
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
/** 折线:按路径长度描绘 + 渐变面积 + 光头 */
|
| 104 |
+
export function Series({
|
| 105 |
+
d,
|
| 106 |
+
p,
|
| 107 |
+
color,
|
| 108 |
+
width = 4,
|
| 109 |
+
area,
|
| 110 |
+
baseY,
|
| 111 |
+
id,
|
| 112 |
+
glow = true,
|
| 113 |
+
dash,
|
| 114 |
+
head = true,
|
| 115 |
+
clipX,
|
| 116 |
+
}: {
|
| 117 |
+
d: string
|
| 118 |
+
p: number
|
| 119 |
+
color: string
|
| 120 |
+
width?: number
|
| 121 |
+
area?: number
|
| 122 |
+
baseY?: number
|
| 123 |
+
id: string
|
| 124 |
+
glow?: boolean
|
| 125 |
+
dash?: string
|
| 126 |
+
head?: boolean
|
| 127 |
+
clipX?: [number, number]
|
| 128 |
+
}) {
|
| 129 |
+
if (p <= 0.0005) return null
|
| 130 |
+
const L = getLength(d)
|
| 131 |
+
const q = clamp(p)
|
| 132 |
+
const pt = getPointAtLength(d, Math.max(0.01, L * q)) ?? { x: 0, y: 0 }
|
| 133 |
+
return (
|
| 134 |
+
<g>
|
| 135 |
+
<defs>
|
| 136 |
+
<linearGradient id={`${id}-a`} x1="0" y1="0" x2="0" y2="1">
|
| 137 |
+
<stop offset="0" stopColor={color} stopOpacity={area ?? 0} />
|
| 138 |
+
<stop offset="1" stopColor={color} stopOpacity={0} />
|
| 139 |
+
</linearGradient>
|
| 140 |
+
<filter id={`${id}-g`} x="-20%" y="-20%" width="140%" height="140%">
|
| 141 |
+
<feGaussianBlur stdDeviation={width * 2.2} />
|
| 142 |
+
</filter>
|
| 143 |
+
{area !== undefined && baseY !== undefined && clipX && (
|
| 144 |
+
<clipPath id={`${id}-c`}>
|
| 145 |
+
<rect x={clipX[0]} y={0} width={Math.max(0, pt.x - clipX[0])} height={baseY + 2} />
|
| 146 |
+
</clipPath>
|
| 147 |
+
)}
|
| 148 |
+
</defs>
|
| 149 |
+
{area !== undefined && baseY !== undefined && clipX && (
|
| 150 |
+
<path d={`${d} L${clipX[1]},${baseY} L${clipX[0]},${baseY} Z`} fill={`url(#${id}-a)`} clipPath={`url(#${id}-c)`} />
|
| 151 |
+
)}
|
| 152 |
+
{glow && <path d={d} fill="none" stroke={color} strokeWidth={width * 2.2} strokeOpacity={0.45} filter={`url(#${id}-g)`} strokeDasharray={`${L * q} ${L}`} strokeLinecap="round" />}
|
| 153 |
+
<path d={d} fill="none" stroke={color} strokeWidth={width} strokeLinecap="round" strokeLinejoin="round" strokeDasharray={dash ?? `${L * q} ${L}`} style={dash ? { clipPath: undefined } : undefined} />
|
| 154 |
+
{head && q < 0.999 && (
|
| 155 |
+
<g>
|
| 156 |
+
<circle cx={pt.x} cy={pt.y} r={width * 4} fill={color} opacity={0.25} filter={`url(#${id}-g)`} />
|
| 157 |
+
<circle cx={pt.x} cy={pt.y} r={width * 1.5} fill="#FFFFFF" />
|
| 158 |
+
</g>
|
| 159 |
+
)}
|
| 160 |
+
</g>
|
| 161 |
+
)
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
/** 端点光点 */
|
| 165 |
+
export function SvgDot({ x, y, r = 7, color, o = 1, id, pulse = 0 }: { x: number; y: number; r?: number; color: string; o?: number; id: string; pulse?: number }) {
|
| 166 |
+
if (o <= 0.001) return null
|
| 167 |
+
return (
|
| 168 |
+
<g opacity={o}>
|
| 169 |
+
<defs>
|
| 170 |
+
<radialGradient id={`${id}-rg`}>
|
| 171 |
+
<stop offset="0" stopColor={color} stopOpacity={0.55} />
|
| 172 |
+
<stop offset="1" stopColor={color} stopOpacity={0} />
|
| 173 |
+
</radialGradient>
|
| 174 |
+
</defs>
|
| 175 |
+
<circle cx={x} cy={y} r={r * 4.5} fill={`url(#${id}-rg)`} />
|
| 176 |
+
{pulse > 0 && <circle cx={x} cy={y} r={r * (1 + pulse * 3)} fill="none" stroke={color} strokeWidth={2} opacity={1 - pulse} />}
|
| 177 |
+
<circle cx={x} cy={y} r={r} fill={color} stroke="#0A0B0F" strokeWidth={2.5} />
|
| 178 |
+
</g>
|
| 179 |
+
)
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
/** 引线标注 */
|
| 183 |
+
export function Leader({ x1, y1, x2, y2, p, color = C.gold, elbow = true }: { x1: number; y1: number; x2: number; y2: number; p: number; color?: string; elbow?: boolean }) {
|
| 184 |
+
if (p <= 0.001) return null
|
| 185 |
+
const d = elbow ? `M${x1},${y1} L${x1},${y2} L${x2},${y2}` : `M${x1},${y1} L${x2},${y2}`
|
| 186 |
+
const L = getLength(d)
|
| 187 |
+
return <path d={d} fill="none" stroke={hexA(color, 0.85)} strokeWidth={1.5} strokeDasharray={`${L * E.out(p)} ${L}`} />
|
| 188 |
+
}
|
kkndme/frontend/src/rv/ctx.tsx
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { createContext, useContext } from 'react'
|
| 2 |
+
import type { Pcm } from './pcm'
|
| 3 |
+
import { useCurrentFrame, useVideoConfig } from 'remotion'
|
| 4 |
+
import type { Timeline, TScene } from '../video/timeline'
|
| 5 |
+
import { E, tw } from './theme'
|
| 6 |
+
|
| 7 |
+
export interface VProps extends Record<string, unknown> {
|
| 8 |
+
tl: Timeline
|
| 9 |
+
subs: boolean
|
| 10 |
+
music: boolean
|
| 11 |
+
mainSrc?: string
|
| 12 |
+
musicSrc?: string
|
| 13 |
+
/** 导出时用:已混好的整段 PCM(有它就不再挂 <Audio>) */
|
| 14 |
+
pcm?: Pcm
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
/** 当前秒数(与帧率无关) */
|
| 18 |
+
export function useTime() {
|
| 19 |
+
const f = useCurrentFrame()
|
| 20 |
+
const { fps } = useVideoConfig()
|
| 21 |
+
return f / fps
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
export interface S {
|
| 25 |
+
/** 全局秒数 */
|
| 26 |
+
t: number
|
| 27 |
+
/** 场景内秒数 */
|
| 28 |
+
u: number
|
| 29 |
+
P: boolean
|
| 30 |
+
W: number
|
| 31 |
+
H: number
|
| 32 |
+
/** 左右边距 */
|
| 33 |
+
M: number
|
| 34 |
+
sc: TScene
|
| 35 |
+
tl: Timeline
|
| 36 |
+
/** 距第 k 句开始的秒数 */
|
| 37 |
+
lt: (k: number) => number
|
| 38 |
+
/** 第 k 句时长 */
|
| 39 |
+
ld: (k: number) => number
|
| 40 |
+
/** 第 k 句起出现、第 to 句开始前消失的可见度 */
|
| 41 |
+
on: (k: number, to?: number, fin?: number) => number
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
export const SceneCtx = createContext<S | null>(null)
|
| 45 |
+
export function useS(): S {
|
| 46 |
+
const s = useContext(SceneCtx)
|
| 47 |
+
if (!s) throw new Error('SceneCtx missing')
|
| 48 |
+
return s
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
export function makeS(t: number, tl: Timeline, sc: TScene, W: number, H: number): S {
|
| 52 |
+
const P = H > W
|
| 53 |
+
const lt = (k: number) => t - (sc.lines[k]?.start ?? sc.start)
|
| 54 |
+
const ld = (k: number) => {
|
| 55 |
+
const l = sc.lines[k]
|
| 56 |
+
return l ? l.end - l.start : 4
|
| 57 |
+
}
|
| 58 |
+
const on = (k: number, to?: number, fin = 0.6) => {
|
| 59 |
+
const a = tw(lt(k), -0.25, fin, E.out)
|
| 60 |
+
if (to === undefined || to >= sc.lines.length) return a
|
| 61 |
+
const b = 1 - tw(lt(to), -0.5, 0.45, E.soft)
|
| 62 |
+
return Math.min(a, b)
|
| 63 |
+
}
|
| 64 |
+
return { t, u: t - sc.start, P, W, H, M: P ? 80 : 140, sc, tl, lt, ld, on }
|
| 65 |
+
}
|
kkndme/frontend/src/rv/fonts.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { loadFont } from '@remotion/fonts'
|
| 2 |
+
|
| 3 |
+
let loading: Promise<void> | null = null
|
| 4 |
+
|
| 5 |
+
/** 视频用字体:通过 Remotion 注册,导出时可嵌入 SVG */
|
| 6 |
+
export function loadRvFonts(): Promise<void> {
|
| 7 |
+
if (loading) return loading
|
| 8 |
+
const base = import.meta.env.BASE_URL
|
| 9 |
+
const list: [string, string, string][] = [
|
| 10 |
+
['KKSerif', '900', 'kkserif-900'],
|
| 11 |
+
['KKSerif', '700', 'kkserif-700'],
|
| 12 |
+
['KKSans', '400', 'kksans-400'],
|
| 13 |
+
['KKSans', '500', 'kksans-400'],
|
| 14 |
+
['KKSans', '700', 'kksans-700'],
|
| 15 |
+
['KKSans', '800', 'kksans-700'],
|
| 16 |
+
['KKSans', '900', 'kksans-700'],
|
| 17 |
+
['Inter', '300', 'inter-300'],
|
| 18 |
+
['Inter', '400', 'inter-300'],
|
| 19 |
+
['Inter', '500', 'inter-500'],
|
| 20 |
+
['Inter', '700', 'inter-700'],
|
| 21 |
+
['Inter', '800', 'inter-800'],
|
| 22 |
+
['Inter', '900', 'inter-800'],
|
| 23 |
+
['JBMono', '500', 'mono-500'],
|
| 24 |
+
['JBMono', '700', 'mono-700'],
|
| 25 |
+
]
|
| 26 |
+
loading = Promise.all(
|
| 27 |
+
list.map(([family, weight, file]) =>
|
| 28 |
+
loadFont({ family, weight, url: `${base}fonts/${file}.woff2`, format: 'woff2' }).catch(() => undefined),
|
| 29 |
+
),
|
| 30 |
+
).then(() => undefined)
|
| 31 |
+
return loading
|
| 32 |
+
}
|
kkndme/frontend/src/rv/kit.tsx
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// 场景通用积木:节拍显隐、引文、数据卡
|
| 2 |
+
import React from 'react'
|
| 3 |
+
import { C, E, F, clamp, hexA, lerp, tw } from './theme'
|
| 4 |
+
import { useS } from './ctx'
|
| 5 |
+
import { Chars, Roll, txtStyle } from './ui'
|
| 6 |
+
|
| 7 |
+
type CSS = React.CSSProperties
|
| 8 |
+
|
| 9 |
+
/** 第 k 句前后的进度:p(k, 延迟, 时长) */
|
| 10 |
+
export function useP() {
|
| 11 |
+
const S = useS()
|
| 12 |
+
return (k: number, d = 0, dur = 0.9, e: (x: number) => number = E.out) => tw(S.lt(k) - d, 0, dur, e)
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
/** 节拍容器:第 k 句(+d 秒)入场,第 to 句开始前退场(模糊推远) */
|
| 16 |
+
export function Beat({ k, to, d = 0, x = 0, y = 0, w, h, children, style, rise = 40, keep }: { k: number; to?: number; d?: number; x?: number; y?: number; w?: number; h?: number; children?: React.ReactNode; style?: CSS; rise?: number; keep?: boolean }) {
|
| 17 |
+
const S = useS()
|
| 18 |
+
const a = tw(S.lt(k) - d, -0.3, 0.85)
|
| 19 |
+
const b = keep || to === undefined || to >= S.sc.lines.length ? 0 : tw(S.lt(to), -0.62, 0.5, E.in)
|
| 20 |
+
if (a <= 0.001 || b >= 0.999) return null
|
| 21 |
+
const bl = (1 - a) * 12 + b * 18
|
| 22 |
+
return (
|
| 23 |
+
<div
|
| 24 |
+
style={{
|
| 25 |
+
position: 'absolute',
|
| 26 |
+
left: x,
|
| 27 |
+
top: y,
|
| 28 |
+
width: w,
|
| 29 |
+
height: h,
|
| 30 |
+
opacity: clamp(a * 1.3) * (1 - b),
|
| 31 |
+
transform: `translateY(${((1 - a) * rise - b * 20).toFixed(1)}px) scale(${(1 + b * 0.06).toFixed(4)})`,
|
| 32 |
+
filter: bl > 0.4 ? `blur(${bl.toFixed(1)}px)` : undefined,
|
| 33 |
+
...style,
|
| 34 |
+
}}
|
| 35 |
+
>
|
| 36 |
+
{children}
|
| 37 |
+
</div>
|
| 38 |
+
)
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/** 句内淡出(不移位),用于持久元素在后面某句隐藏 */
|
| 42 |
+
export function useVis() {
|
| 43 |
+
const S = useS()
|
| 44 |
+
return (k: number, to?: number, d = 0) => {
|
| 45 |
+
const a = tw(S.lt(k) - d, -0.3, 0.8)
|
| 46 |
+
const b = to === undefined || to >= S.sc.lines.length ? 0 : tw(S.lt(to), -0.62, 0.5, E.in)
|
| 47 |
+
return a * (1 - b)
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
/** 引文:金色竖线 + 逐字显现 */
|
| 52 |
+
export function Quote({ text, t, size = 34, w, color = C.ink, src }: { text: string; t: number; size?: number; w?: number; color?: string; src?: string }) {
|
| 53 |
+
const bar = tw(t, 0, 0.7)
|
| 54 |
+
return (
|
| 55 |
+
<div style={{ position: 'relative', paddingLeft: size * 0.85, width: w }}>
|
| 56 |
+
<div style={{ position: 'absolute', left: 0, top: size * 0.1, width: 3, height: `calc(${(bar * 100).toFixed(1)}% - ${size * 0.1}px)`, background: `linear-gradient(180deg, ${C.goldHi}, ${hexA(C.gold, 0.2)})` }} />
|
| 57 |
+
<Chars text={text} t={t - 0.15} st={0.028} d={0.6} dy={0.35} blur={8} style={{ flexWrap: 'wrap', ...txtStyle({ f: 'serif', size, w: 700, color, lh: 1.5 }) }} />
|
| 58 |
+
{src && <div style={{ marginTop: size * 0.4, opacity: tw(t, 0.8 + text.length * 0.028, 0.6), ...txtStyle({ f: 'mono', size: size * 0.52, w: 500, color: C.dim, ls: 2 }) }}>{src}</div>}
|
| 59 |
+
</div>
|
| 60 |
+
)
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
/** 大数字 + 单位 */
|
| 64 |
+
export function Big({ v, p, size = 140, unit, color = C.ink, unitColor = C.gold, f = 'num', w = 800, ls = -4, style }: { v: string; p: number; size?: number; unit?: string; color?: string; unitColor?: string; f?: keyof typeof F; w?: number; ls?: number; style?: CSS }) {
|
| 65 |
+
return (
|
| 66 |
+
<div style={{ display: 'flex', alignItems: 'baseline', gap: size * 0.06, ...style }}>
|
| 67 |
+
<Roll value={v} p={p} color={color} style={txtStyle({ f, size, w, ls, lh: 1.04 })} />
|
| 68 |
+
{unit && <div style={{ ...txtStyle({ f: 'cn', size: size * 0.32, w: 800, color: unitColor }), opacity: clamp(p * 2 - 0.4) }}>{unit}</div>}
|
| 69 |
+
</div>
|
| 70 |
+
)
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
/** 流式玻璃卡(相对定位) */
|
| 74 |
+
export function Card({ children, tint, glow, pad = 28, r = 22, style }: { children?: React.ReactNode; tint?: string; glow?: string; pad?: number | string; r?: number; style?: CSS }) {
|
| 75 |
+
return (
|
| 76 |
+
<div
|
| 77 |
+
style={{
|
| 78 |
+
position: 'relative',
|
| 79 |
+
borderRadius: r,
|
| 80 |
+
padding: pad,
|
| 81 |
+
background: `linear-gradient(155deg, ${tint ? hexA(tint, 0.15) : 'rgba(255,255,255,0.07)'} 0%, rgba(255,255,255,0.025) 60%, rgba(255,255,255,0.012) 100%)`,
|
| 82 |
+
border: `1px solid ${tint ? hexA(tint, 0.42) : 'rgba(243,238,228,0.12)'}`,
|
| 83 |
+
boxShadow: glow ? `0 0 60px ${hexA(glow, 0.2)}, 0 24px 60px rgba(0,0,0,0.45)` : '0 24px 60px rgba(0,0,0,0.45)',
|
| 84 |
+
zIndex: 0,
|
| 85 |
+
...style,
|
| 86 |
+
}}
|
| 87 |
+
>
|
| 88 |
+
{/* 玻璃体积:顶部受光、底部收暗(垫在内容下面) */}
|
| 89 |
+
<div style={{ position: 'absolute', inset: 0, borderRadius: r, zIndex: -1, background: 'linear-gradient(172deg, rgba(255,255,255,0.055) 0%, rgba(255,255,255,0) 34%, rgba(0,0,0,0) 62%, rgba(0,0,0,0.2) 100%)' }} />
|
| 90 |
+
<div style={{ position: 'absolute', left: 0, top: r, bottom: r, width: 1, zIndex: -1, background: `linear-gradient(180deg, ${tint ? hexA(tint, 0.5) : 'rgba(255,255,255,0.18)'}, transparent)` }} />
|
| 91 |
+
<div style={{ position: 'absolute', left: r, right: r, top: 0, height: 1, background: `linear-gradient(90deg, transparent, ${tint ? hexA(tint, 0.85) : 'rgba(255,255,255,0.32)'}, transparent)` }} />
|
| 92 |
+
{children}
|
| 93 |
+
</div>
|
| 94 |
+
)
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
/** 进度驱动的文字(模糊上浮) */
|
| 98 |
+
export function T({ p, children, style, dy = 18 }: { p: number; children: React.ReactNode; style?: CSS; dy?: number }) {
|
| 99 |
+
if (p <= 0.001) return <div style={{ ...style, opacity: 0 }}>{children}</div>
|
| 100 |
+
const b = (1 - p) * 10
|
| 101 |
+
return (
|
| 102 |
+
<div style={{ ...style, opacity: clamp(p * 1.4) * (typeof style?.opacity === 'number' ? style.opacity : 1), transform: `translateY(${((1 - p) * dy).toFixed(1)}px)`, filter: b > 0.4 ? `blur(${b.toFixed(1)}px)` : undefined }}>
|
| 103 |
+
{children}
|
| 104 |
+
</div>
|
| 105 |
+
)
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
/** 小标签(等宽、字距随进度收拢) */
|
| 109 |
+
export function Tag({ text, p = 1, color = C.gold, size = 18 }: { text: string; p?: number; color?: string; size?: number }) {
|
| 110 |
+
return (
|
| 111 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 12, opacity: clamp(p * 1.5) }}>
|
| 112 |
+
<div style={{ width: 28 * E.out(p), height: 2, background: color }} />
|
| 113 |
+
<div style={txtStyle({ f: 'mono', size, w: 700, color, ls: lerp(9, 3, E.out(p)) })}>{text}</div>
|
| 114 |
+
</div>
|
| 115 |
+
)
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
/** 盖章 */
|
| 119 |
+
export function Stamp({ text, sub, p, color = C.red, size = 120, rot = -12, style }: { text: string; sub?: string; p: number; color?: string; size?: number; rot?: number; style?: CSS }) {
|
| 120 |
+
if (p <= 0.001) return null
|
| 121 |
+
const s = lerp(2.4, 1, E.out(clamp(p * 1.4)))
|
| 122 |
+
const shake = p < 0.5 ? 0 : Math.sin(p * 40) * (1 - p) * 4
|
| 123 |
+
return (
|
| 124 |
+
<div
|
| 125 |
+
style={{
|
| 126 |
+
border: `${Math.max(3, size * 0.045)}px solid ${color}`,
|
| 127 |
+
borderRadius: size * 0.1,
|
| 128 |
+
padding: `${size * 0.1}px ${size * 0.18}px`,
|
| 129 |
+
transform: `rotate(${rot + shake}deg) scale(${s.toFixed(3)})`,
|
| 130 |
+
opacity: clamp(p * 3) * 0.92,
|
| 131 |
+
boxShadow: `0 0 40px ${hexA(color, 0.35)}`,
|
| 132 |
+
textAlign: 'center',
|
| 133 |
+
...style,
|
| 134 |
+
}}
|
| 135 |
+
>
|
| 136 |
+
<div style={{ ...txtStyle({ f: 'serif', size, w: 900, color, lh: 1, ls: size * 0.06 }) }}>{text}</div>
|
| 137 |
+
{sub && <div style={{ ...txtStyle({ f: 'mono', size: size * 0.16, w: 700, color, ls: 3 }), marginTop: size * 0.08 }}>{sub}</div>}
|
| 138 |
+
</div>
|
| 139 |
+
)
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
/** 中文圆点 + 文本 */
|
| 143 |
+
export function Dot({ color, size = 12 }: { color: string; size?: number }) {
|
| 144 |
+
return <div style={{ width: size, height: size, borderRadius: '50%', background: color, boxShadow: `0 0 ${size}px ${hexA(color, 0.6)}`, flex: 'none' }} />
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
export const cn = (size: number, w = 700, color: string = C.ink, lh = 1.3): CSS => txtStyle({ f: 'cn', size, w, color, lh, nowrap: false })
|
| 148 |
+
export const serif = (size: number, color: string = C.ink, w = 900, lh = 1.2): CSS => txtStyle({ f: 'serif', size, w, color, lh, nowrap: false })
|
| 149 |
+
export const mono = (size: number, color: string = C.mute, w = 600, ls = 2): CSS => txtStyle({ f: 'mono', size, w, color, ls })
|
| 150 |
+
|
| 151 |
+
/** 环形图(SVG) */
|
| 152 |
+
export function Ring({ size, stroke, segs, p, gap = 0.012, track = true }: { size: number; stroke: number; segs: { v: number; color: string }[]; p: number; gap?: number; track?: boolean }) {
|
| 153 |
+
const r = (size - stroke) / 2
|
| 154 |
+
const c = size / 2
|
| 155 |
+
const tot = segs.reduce((a, s) => a + s.v, 0)
|
| 156 |
+
const L = 2 * Math.PI * r
|
| 157 |
+
let acc = 0
|
| 158 |
+
return (
|
| 159 |
+
<svg width={size} height={size} viewBox={`0 0 ${size} ${size}`} style={{ position: 'absolute', left: 0, top: 0, overflow: 'visible' }}>
|
| 160 |
+
{track && <circle cx={c} cy={c} r={r} fill="none" stroke="rgba(243,238,228,0.07)" strokeWidth={stroke} />}
|
| 161 |
+
{segs.map((s, i) => {
|
| 162 |
+
const f0 = acc / tot
|
| 163 |
+
acc += s.v
|
| 164 |
+
const f1 = acc / tot
|
| 165 |
+
const q = E.out(clamp(p * 1.1 - f0 * 0.25))
|
| 166 |
+
const len = Math.max(0, (f1 - f0 - gap) * L * q)
|
| 167 |
+
return (
|
| 168 |
+
<circle
|
| 169 |
+
key={i}
|
| 170 |
+
cx={c}
|
| 171 |
+
cy={c}
|
| 172 |
+
r={r}
|
| 173 |
+
fill="none"
|
| 174 |
+
stroke={s.color}
|
| 175 |
+
strokeWidth={stroke}
|
| 176 |
+
strokeDasharray={`${len} ${L}`}
|
| 177 |
+
strokeDashoffset={-f0 * L}
|
| 178 |
+
transform={`rotate(-90 ${c} ${c})`}
|
| 179 |
+
style={{ filter: `drop-shadow(0 0 ${stroke * 0.5}px ${hexA(s.color, 0.55)})` }}
|
| 180 |
+
/>
|
| 181 |
+
)
|
| 182 |
+
})}
|
| 183 |
+
</svg>
|
| 184 |
+
)
|
| 185 |
+
}
|
kkndme/frontend/src/rv/layers.tsx
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useLayoutEffect, useRef } from 'react'
|
| 2 |
+
import { noise2D } from '@remotion/noise'
|
| 3 |
+
import { C, E, clamp, hexA, rand, tw } from './theme'
|
| 4 |
+
import type { Timeline } from '../video/timeline'
|
| 5 |
+
|
| 6 |
+
export function CanvasLayer({ W, H, draw, res = 1, style }: { W: number; H: number; draw: (c: CanvasRenderingContext2D, W: number, H: number) => void; res?: number; style?: React.CSSProperties }) {
|
| 7 |
+
const ref = useRef<HTMLCanvasElement>(null)
|
| 8 |
+
useLayoutEffect(() => {
|
| 9 |
+
const cv = ref.current
|
| 10 |
+
if (!cv) return
|
| 11 |
+
const c = cv.getContext('2d')
|
| 12 |
+
if (!c) return
|
| 13 |
+
c.setTransform(res, 0, 0, res, 0, 0)
|
| 14 |
+
c.clearRect(0, 0, W, H)
|
| 15 |
+
draw(c, W, H)
|
| 16 |
+
})
|
| 17 |
+
return <canvas ref={ref} width={Math.round(W * res)} height={Math.round(H * res)} style={{ position: 'absolute', left: 0, top: 0, width: W, height: H, ...style }} />
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
const rgb = (hex: string) => {
|
| 21 |
+
const n = parseInt(hex.replace('#', ''), 16)
|
| 22 |
+
return [(n >> 16) & 255, (n >> 8) & 255, n & 255]
|
| 23 |
+
}
|
| 24 |
+
const mix = (a: string, b: string, p: number) => {
|
| 25 |
+
const x = rgb(a)
|
| 26 |
+
const y = rgb(b)
|
| 27 |
+
const r = x.map((v, i) => Math.round(v + (y[i] - v) * p))
|
| 28 |
+
return `#${r.map((v) => v.toString(16).padStart(2, '0')).join('')}`
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function drawBokeh(c: CanvasRenderingContext2D, W: number, H: number, t: number, accent: string, k: number, cam: [number, number]) {
|
| 32 |
+
const u = Math.max(W, H) / 1920
|
| 33 |
+
const cols = [accent, C.goldHi, '#8FB3FF', accent, '#F4DDA8']
|
| 34 |
+
for (let i = 0; i < 18; i++) {
|
| 35 |
+
const z = 0.15 + rand(i, 41) * 0.85 // 越大越近
|
| 36 |
+
const R = (22 + z * z * 120) * u
|
| 37 |
+
const px = (rand(i, 42) * 1.3 - 0.15) * W + noise2D('bkx', i, t * 0.02) * 120 * u - cam[0] * z * 1.6
|
| 38 |
+
const py = (rand(i, 43) * 1.2 - 0.1) * H + noise2D('bky', t * 0.02, i) * 90 * u - cam[1] * z * 1.6 - t * 3 * z * u
|
| 39 |
+
const y = ((py % (H + R * 2)) + H + R * 2) % (H + R * 2) - R
|
| 40 |
+
const life = 0.5 + 0.5 * Math.sin(t * (0.12 + rand(i, 44) * 0.18) + i * 2.3)
|
| 41 |
+
const a = (0.018 + 0.05 * (1 - Math.abs(z - 0.55) * 1.2)) * life * k
|
| 42 |
+
if (a < 0.004) continue
|
| 43 |
+
const col = cols[i % cols.length]
|
| 44 |
+
const g = c.createRadialGradient(px, y, 0, px, y, R)
|
| 45 |
+
g.addColorStop(0, hexA(col, a * 0.55))
|
| 46 |
+
g.addColorStop(0.72, hexA(col, a * 0.7))
|
| 47 |
+
g.addColorStop(0.9, hexA(col, a))
|
| 48 |
+
g.addColorStop(1, hexA(col, 0))
|
| 49 |
+
c.fillStyle = g
|
| 50 |
+
c.beginPath()
|
| 51 |
+
c.arc(px, y, R, 0, Math.PI * 2)
|
| 52 |
+
c.fill()
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/** 背景氛围:渐变底、极光光斑、点阵、浮尘、暗角 */
|
| 57 |
+
export function Atmosphere({ W, H, t, accent, intensity = 1, cam = [0, 0] }: { W: number; H: number; t: number; accent: string; intensity?: number; cam?: [number, number] }) {
|
| 58 |
+
return (
|
| 59 |
+
<CanvasLayer
|
| 60 |
+
W={W}
|
| 61 |
+
H={H}
|
| 62 |
+
draw={(c) => {
|
| 63 |
+
const g = c.createLinearGradient(0, 0, 0, H)
|
| 64 |
+
g.addColorStop(0, '#080A0F')
|
| 65 |
+
g.addColorStop(1, '#040507')
|
| 66 |
+
c.fillStyle = g
|
| 67 |
+
c.fillRect(0, 0, W, H)
|
| 68 |
+
const D = Math.max(W, H)
|
| 69 |
+
// 极光光斑
|
| 70 |
+
const blobs: [string, number, number, number, number][] = [
|
| 71 |
+
[accent, 0.13, 0.78, 0.18, 0.62],
|
| 72 |
+
['#2A3D6B', 0.32, 0.12, 0.85, 0.7],
|
| 73 |
+
[C.gold, 0.07, 0.2, 0.3, 0.45],
|
| 74 |
+
]
|
| 75 |
+
c.globalCompositeOperation = 'lighter'
|
| 76 |
+
blobs.forEach(([col, a, bx, by, rr], i) => {
|
| 77 |
+
const x = (bx + noise2D('bx' + i, t * 0.035, i) * 0.16) * W
|
| 78 |
+
const y = (by + noise2D('by' + i, i, t * 0.035) * 0.16) * H
|
| 79 |
+
const r = rr * D * (1 + 0.08 * Math.sin(t * 0.3 + i))
|
| 80 |
+
const rg = c.createRadialGradient(x, y, 0, x, y, r)
|
| 81 |
+
rg.addColorStop(0, hexA(col, a * intensity))
|
| 82 |
+
rg.addColorStop(0.45, hexA(col, a * 0.35 * intensity))
|
| 83 |
+
rg.addColorStop(1, hexA(col, 0))
|
| 84 |
+
c.fillStyle = rg
|
| 85 |
+
c.fillRect(0, 0, W, H)
|
| 86 |
+
})
|
| 87 |
+
// 景深光斑:远近两层,随镜头反向视差
|
| 88 |
+
drawBokeh(c, W, H, t, accent, intensity, cam)
|
| 89 |
+
c.globalCompositeOperation = 'source-over'
|
| 90 |
+
// 点阵
|
| 91 |
+
const sp = 42
|
| 92 |
+
const ox = (t * 4) % sp
|
| 93 |
+
const cx = W / 2
|
| 94 |
+
const cy = H * 0.45
|
| 95 |
+
for (let x = -sp + ox; x < W + sp; x += sp) {
|
| 96 |
+
for (let y = 0; y < H + sp; y += sp) {
|
| 97 |
+
const d = Math.hypot((x - cx) / W, (y - cy) / H)
|
| 98 |
+
const a = 0.085 * clamp(1 - d * 1.5)
|
| 99 |
+
if (a < 0.006) continue
|
| 100 |
+
c.fillStyle = `rgba(243,238,228,${a.toFixed(3)})`
|
| 101 |
+
c.fillRect(x, y, 2, 2)
|
| 102 |
+
}
|
| 103 |
+
}
|
| 104 |
+
// 浮尘
|
| 105 |
+
for (let i = 0; i < 70; i++) {
|
| 106 |
+
const z = 0.3 + rand(i, 1) * 0.7
|
| 107 |
+
const x = ((rand(i, 2) * W + t * 9 * z + noise2D('dx', i, t * 0.05) * 40) % (W + 40)) - 20
|
| 108 |
+
const y = ((rand(i, 3) * H - t * 6 * z) % H + H) % H
|
| 109 |
+
const tw2 = 0.5 + 0.5 * Math.sin(t * (0.6 + rand(i, 4)) + i)
|
| 110 |
+
const r = 0.8 + z * 2.4
|
| 111 |
+
const a = (0.05 + 0.22 * z) * tw2 * intensity
|
| 112 |
+
const rg = c.createRadialGradient(x, y, 0, x, y, r * 3)
|
| 113 |
+
rg.addColorStop(0, `rgba(244,221,168,${a.toFixed(3)})`)
|
| 114 |
+
rg.addColorStop(1, 'rgba(244,221,168,0)')
|
| 115 |
+
c.fillStyle = rg
|
| 116 |
+
c.fillRect(x - r * 3, y - r * 3, r * 6, r * 6)
|
| 117 |
+
}
|
| 118 |
+
// 暗角
|
| 119 |
+
const vg = c.createRadialGradient(W / 2, H / 2, D * 0.25, W / 2, H / 2, D * 0.75)
|
| 120 |
+
vg.addColorStop(0, 'rgba(0,0,0,0)')
|
| 121 |
+
vg.addColorStop(1, 'rgba(0,0,0,0.7)')
|
| 122 |
+
c.fillStyle = vg
|
| 123 |
+
c.fillRect(0, 0, W, H)
|
| 124 |
+
}}
|
| 125 |
+
/>
|
| 126 |
+
)
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
let grainTiles: HTMLCanvasElement[] | null = null
|
| 130 |
+
function getGrain() {
|
| 131 |
+
if (grainTiles) return grainTiles
|
| 132 |
+
grainTiles = [0, 1, 2, 3].map((k) => {
|
| 133 |
+
const cv = document.createElement('canvas')
|
| 134 |
+
cv.width = 256
|
| 135 |
+
cv.height = 256
|
| 136 |
+
const c = cv.getContext('2d')!
|
| 137 |
+
const img = c.createImageData(256, 256)
|
| 138 |
+
// 零均值颗粒:亮点与暗点各半,不会把暗部抬灰
|
| 139 |
+
for (let i = 0; i < 256 * 256; i++) {
|
| 140 |
+
const v = rand(i, k + 7) + rand(i, k + 17) + rand(i, k + 27) - 1.5
|
| 141 |
+
const on = v > 0 ? 255 : 0
|
| 142 |
+
img.data[i * 4] = on
|
| 143 |
+
img.data[i * 4 + 1] = on
|
| 144 |
+
img.data[i * 4 + 2] = on
|
| 145 |
+
img.data[i * 4 + 3] = Math.min(255, Math.abs(v) * 0.2 * 255)
|
| 146 |
+
}
|
| 147 |
+
c.putImageData(img, 0, 0)
|
| 148 |
+
return cv
|
| 149 |
+
})
|
| 150 |
+
return grainTiles
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
/** 前景特效:转场光、颗粒 */
|
| 154 |
+
export function FxOverlay({ W, H, t, tl, frame }: { W: number; H: number; t: number; tl: Timeline; frame: number }) {
|
| 155 |
+
return (
|
| 156 |
+
<CanvasLayer
|
| 157 |
+
W={W}
|
| 158 |
+
H={H}
|
| 159 |
+
draw={(c) => {
|
| 160 |
+
// 转场漏光
|
| 161 |
+
tl.scenes.forEach((s) => {
|
| 162 |
+
if (s.idx === 0) return
|
| 163 |
+
const k = t - s.start
|
| 164 |
+
if (k < -0.5 || k > 1.6) return
|
| 165 |
+
const a = Math.exp(-Math.pow((k - 0.15) / 0.38, 2))
|
| 166 |
+
if (a < 0.01) return
|
| 167 |
+
const x = W * (-0.2 + 1.4 * E.inOut(clamp((k + 0.5) / 1.6)))
|
| 168 |
+
const y = H * 0.42
|
| 169 |
+
c.globalCompositeOperation = 'lighter'
|
| 170 |
+
const rg = c.createRadialGradient(x, y, 0, x, y, Math.max(W, H) * 0.55)
|
| 171 |
+
rg.addColorStop(0, `rgba(255,214,150,${(0.32 * a).toFixed(3)})`)
|
| 172 |
+
rg.addColorStop(0.3, `rgba(216,150,80,${(0.14 * a).toFixed(3)})`)
|
| 173 |
+
rg.addColorStop(1, 'rgba(216,150,80,0)')
|
| 174 |
+
c.fillStyle = rg
|
| 175 |
+
c.fillRect(0, 0, W, H)
|
| 176 |
+
// 横向光带
|
| 177 |
+
c.save()
|
| 178 |
+
c.translate(W / 2, y)
|
| 179 |
+
c.scale(1, 0.018)
|
| 180 |
+
const sg = c.createRadialGradient(0, 0, 0, 0, 0, W * 0.6)
|
| 181 |
+
sg.addColorStop(0, `rgba(255,236,200,${(0.55 * a).toFixed(3)})`)
|
| 182 |
+
sg.addColorStop(1, 'rgba(255,236,200,0)')
|
| 183 |
+
c.fillStyle = sg
|
| 184 |
+
c.fillRect(-W, -W * 0.6, W * 2, W * 1.2)
|
| 185 |
+
c.restore()
|
| 186 |
+
c.globalCompositeOperation = 'source-over'
|
| 187 |
+
})
|
| 188 |
+
// 镜头边缘漏光:暖色左上、冷色右下,缓慢呼吸
|
| 189 |
+
c.globalCompositeOperation = 'lighter'
|
| 190 |
+
const D = Math.max(W, H)
|
| 191 |
+
const leaks: [number, number, number, number, number, number][] = [
|
| 192 |
+
[-0.06, 0.18, 255, 168, 92, 0.075],
|
| 193 |
+
[1.05, 0.86, 110, 150, 255, 0.05],
|
| 194 |
+
[0.55, -0.12, 255, 214, 160, 0.035],
|
| 195 |
+
]
|
| 196 |
+
leaks.forEach(([lx, ly, r, g, b, a0], i) => {
|
| 197 |
+
const n = 0.55 + 0.45 * noise2D('leak', i, t * 0.06)
|
| 198 |
+
const x = (lx + noise2D('lx', i, t * 0.03) * 0.05) * W
|
| 199 |
+
const y = (ly + noise2D('ly', t * 0.03, i) * 0.08) * H
|
| 200 |
+
const rg = c.createRadialGradient(x, y, 0, x, y, D * 0.48)
|
| 201 |
+
rg.addColorStop(0, `rgba(${r},${g},${b},${(a0 * n).toFixed(3)})`)
|
| 202 |
+
rg.addColorStop(0.5, `rgba(${r},${g},${b},${(a0 * n * 0.3).toFixed(3)})`)
|
| 203 |
+
rg.addColorStop(1, `rgba(${r},${g},${b},0)`)
|
| 204 |
+
c.fillStyle = rg
|
| 205 |
+
c.fillRect(0, 0, W, H)
|
| 206 |
+
})
|
| 207 |
+
c.globalCompositeOperation = 'source-over'
|
| 208 |
+
// 镜头暗角(压在内容之上,四角自然衰减)
|
| 209 |
+
const vg = c.createRadialGradient(W / 2, H * 0.47, D * 0.36, W / 2, H * 0.47, D * 0.8)
|
| 210 |
+
vg.addColorStop(0, 'rgba(0,0,0,0)')
|
| 211 |
+
vg.addColorStop(1, 'rgba(0,0,0,0.3)')
|
| 212 |
+
c.fillStyle = vg
|
| 213 |
+
c.fillRect(0, 0, W, H)
|
| 214 |
+
// 颗粒
|
| 215 |
+
const tiles = getGrain()
|
| 216 |
+
const tile = tiles[frame % tiles.length]
|
| 217 |
+
const pat = c.createPattern(tile, 'repeat')
|
| 218 |
+
if (pat) {
|
| 219 |
+
const ox = Math.floor(rand(frame, 1) * 256)
|
| 220 |
+
const oy = Math.floor(rand(frame, 2) * 256)
|
| 221 |
+
c.save()
|
| 222 |
+
c.globalAlpha = 0.6
|
| 223 |
+
c.translate(-ox, -oy)
|
| 224 |
+
c.fillStyle = pat
|
| 225 |
+
c.fillRect(0, 0, W + 256, H + 256)
|
| 226 |
+
c.restore()
|
| 227 |
+
}
|
| 228 |
+
}}
|
| 229 |
+
/>
|
| 230 |
+
)
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
export const ACCENT: Record<string, string> = {
|
| 234 |
+
intro: '#C89B5A',
|
| 235 |
+
method: '#6E9BF5',
|
| 236 |
+
score: '#D8B26E',
|
| 237 |
+
price: '#E07A5F',
|
| 238 |
+
cities: '#4CC38A',
|
| 239 |
+
money: '#D8B26E',
|
| 240 |
+
policy: '#C9A25E',
|
| 241 |
+
rulers: '#6E9BF5',
|
| 242 |
+
brier: '#E0A84A',
|
| 243 |
+
blind: '#EA6A5F',
|
| 244 |
+
pending: '#6E9BF5',
|
| 245 |
+
outlook: '#E0A84A',
|
| 246 |
+
outro: '#D8B26E',
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
export function accentAt(tl: Timeline, t: number) {
|
| 250 |
+
const i = tl.scenes.findIndex((s) => t >= s.start && t < s.end)
|
| 251 |
+
const s = tl.scenes[Math.max(0, i)]
|
| 252 |
+
const prev = tl.scenes[Math.max(0, i - 1)]
|
| 253 |
+
const p = tw(t, s.start - 0.3, 1.2, E.soft)
|
| 254 |
+
return mix(ACCENT[prev.key], ACCENT[s.key], i <= 0 ? 1 : p)
|
| 255 |
+
}
|
kkndme/frontend/src/rv/pcm.tsx
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// 导出专用音轨:把已经混好的整段 PCM 按帧切片,同步交给渲染器。
|
| 2 |
+
// 代替逐帧异步解码 <Audio>,省掉每帧的解码与等待;声音数据逐采样不变。
|
| 3 |
+
import { useContext, useLayoutEffect } from 'react'
|
| 4 |
+
import { Internals, useCurrentFrame, useVideoConfig } from 'remotion'
|
| 5 |
+
|
| 6 |
+
export interface Pcm {
|
| 7 |
+
/** 16-bit 立体声交错采样 */
|
| 8 |
+
data: Int16Array
|
| 9 |
+
sampleRate: number
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
const ID = 'kk-pcm-mix'
|
| 13 |
+
|
| 14 |
+
export function PcmTrack({ pcm }: { pcm: Pcm }) {
|
| 15 |
+
const frame = useCurrentFrame()
|
| 16 |
+
const { fps } = useVideoConfig()
|
| 17 |
+
const { registerRenderAsset, unregisterRenderAsset } = useContext(Internals.RenderAssetManager)
|
| 18 |
+
useLayoutEffect(() => {
|
| 19 |
+
const sr = pcm.sampleRate
|
| 20 |
+
const s = Math.round((frame * sr) / fps)
|
| 21 |
+
const e = Math.round(((frame + 1) * sr) / fps)
|
| 22 |
+
registerRenderAsset({
|
| 23 |
+
type: 'inline-audio',
|
| 24 |
+
id: ID,
|
| 25 |
+
audio: pcm.data.subarray(Math.min(pcm.data.length, s * 2), Math.min(pcm.data.length, e * 2)),
|
| 26 |
+
frame,
|
| 27 |
+
startInVideo: 0,
|
| 28 |
+
timestamp: s / sr,
|
| 29 |
+
duration: ((e - s) / sr) * 1e6,
|
| 30 |
+
toneFrequency: 1,
|
| 31 |
+
})
|
| 32 |
+
return () => unregisterRenderAsset(ID)
|
| 33 |
+
}, [frame, fps, pcm, registerRenderAsset, unregisterRenderAsset])
|
| 34 |
+
return null
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/** 读取 16-bit PCM WAV 的数据区(只接受自己生成的 44 字节头 WAV) */
|
| 38 |
+
async function wavInfo(blob: Blob) {
|
| 39 |
+
const v = new DataView(await blob.slice(0, 44).arrayBuffer())
|
| 40 |
+
const tag = (o: number) => String.fromCharCode(v.getUint8(o), v.getUint8(o + 1), v.getUint8(o + 2), v.getUint8(o + 3))
|
| 41 |
+
if (tag(0) !== 'RIFF' || tag(8) !== 'WAVE' || tag(36) !== 'data') return null
|
| 42 |
+
if (v.getUint16(20, true) !== 1 || v.getUint16(22, true) !== 2 || v.getUint16(34, true) !== 16) return null
|
| 43 |
+
return { sampleRate: v.getUint32(24, true), bytes: Math.min(v.getUint32(40, true), blob.size - 44) }
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
/** 主轨 (+ 配乐) 混成一条 16-bit 交错 PCM;格式不符返回 null,由调用方回退到 <Audio> */
|
| 47 |
+
export async function loadMixPcm(mainUrl: string, musicUrl: string | undefined): Promise<Pcm | null> {
|
| 48 |
+
const main = await (await fetch(mainUrl)).blob()
|
| 49 |
+
const mi = await wavInfo(main)
|
| 50 |
+
if (!mi) return null
|
| 51 |
+
const out = new Int16Array(mi.bytes >> 1)
|
| 52 |
+
const CH = 8 << 20
|
| 53 |
+
for (let o = 0; o < mi.bytes; o += CH) {
|
| 54 |
+
const buf = await main.slice(44 + o, 44 + Math.min(mi.bytes, o + CH)).arrayBuffer()
|
| 55 |
+
out.set(new Int16Array(buf, 0, buf.byteLength >> 1), o >> 1)
|
| 56 |
+
}
|
| 57 |
+
if (musicUrl) {
|
| 58 |
+
const music = await (await fetch(musicUrl)).blob()
|
| 59 |
+
const ui = await wavInfo(music)
|
| 60 |
+
if (!ui || ui.sampleRate !== mi.sampleRate) return null
|
| 61 |
+
const n = Math.min(mi.bytes, ui.bytes)
|
| 62 |
+
for (let o = 0; o < n; o += CH) {
|
| 63 |
+
const buf = await music.slice(44 + o, 44 + Math.min(n, o + CH)).arrayBuffer()
|
| 64 |
+
const m = new Int16Array(buf, 0, buf.byteLength >> 1)
|
| 65 |
+
const base = o >> 1
|
| 66 |
+
for (let i = 0; i < m.length; i++) {
|
| 67 |
+
const s = out[base + i] + m[i]
|
| 68 |
+
out[base + i] = s > 32767 ? 32767 : s < -32768 ? -32768 : s
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
return { data: out, sampleRate: mi.sampleRate }
|
| 73 |
+
}
|
kkndme/frontend/src/rv/photos.tsx
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react'
|
| 2 |
+
import { Img } from 'remotion'
|
| 3 |
+
import type { Timeline } from '../video/timeline'
|
| 4 |
+
import type { SceneKey } from '../video/script'
|
| 5 |
+
import { E, clamp, tw } from './theme'
|
| 6 |
+
import { asset } from './assets'
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* 背景实景照片层:每章一到三张与内容相关的城市 / 楼市 / 金融实景,
|
| 10 |
+
* 极低透明度 + 缓慢推拉平移,章节间交叉淡化。图片来源见 public/rvbg/CREDITS.txt(CC0 / CC BY / CC BY-SA)。
|
| 11 |
+
* 图片已预先统一调色(压暗高光、降饱和、偏冷、上下压暗、轻微柔化),亮度一致,所以这里用统一透明度。
|
| 12 |
+
*/
|
| 13 |
+
const SET: Record<SceneKey, string[]> = {
|
| 14 |
+
intro: ['intro'],
|
| 15 |
+
method: ['method'],
|
| 16 |
+
score: ['score'],
|
| 17 |
+
price: ['price1', 'price2'],
|
| 18 |
+
cities: ['cities1', 'cities2', 'cities3'],
|
| 19 |
+
money: ['money'],
|
| 20 |
+
policy: ['policy'],
|
| 21 |
+
rulers: ['rulers'],
|
| 22 |
+
brier: ['brier'],
|
| 23 |
+
blind: ['blind'],
|
| 24 |
+
pending: ['pending'],
|
| 25 |
+
outlook: ['outlook'],
|
| 26 |
+
outro: ['outro'],
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
const BASE = import.meta.env.BASE_URL
|
| 30 |
+
const src = (n: string) => `${BASE}rvbg/${n}.jpg?v=3`
|
| 31 |
+
/** 全部背景照片地址(导出前预先缓存) */
|
| 32 |
+
export const PHOTO_URLS = Object.values(SET).flat().map(src)
|
| 33 |
+
const ALPHA = 0.34 // 整体存在感:隐约可见
|
| 34 |
+
const FADE = 1.8 // 交叉淡化时长(秒)
|
| 35 |
+
const LEAD = 0.8 // 比章节切换略早开始淡入,与内容的模糊转场重叠
|
| 36 |
+
|
| 37 |
+
interface Seg { n: string; a: number; b: number; alpha: number; k: number }
|
| 38 |
+
|
| 39 |
+
function buildSegs(tl: Timeline): Seg[] {
|
| 40 |
+
const out: Seg[] = []
|
| 41 |
+
tl.scenes.forEach((sc) => {
|
| 42 |
+
const list = SET[sc.key as SceneKey] ?? []
|
| 43 |
+
const len = (sc.end - sc.start) / Math.max(1, list.length)
|
| 44 |
+
list.forEach((n, j) => {
|
| 45 |
+
const a = sc.start + j * len - (j === 0 ? LEAD : 0)
|
| 46 |
+
const b = sc.start + (j + 1) * len - (j === list.length - 1 ? LEAD : 0)
|
| 47 |
+
out.push({ n, a, b, alpha: ALPHA, k: out.length })
|
| 48 |
+
})
|
| 49 |
+
})
|
| 50 |
+
if (out.length) out[0].a = -1
|
| 51 |
+
return out
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
let preloaded = false
|
| 55 |
+
|
| 56 |
+
export function BgPhotos({ W, H, t, tl, cam }: { W: number; H: number; t: number; tl: Timeline; cam: [number, number] }) {
|
| 57 |
+
const segs = React.useMemo(() => buildSegs(tl), [tl])
|
| 58 |
+
React.useEffect(() => {
|
| 59 |
+
if (preloaded || typeof Image === 'undefined') return
|
| 60 |
+
preloaded = true
|
| 61 |
+
Object.values(SET).flat().forEach((n) => { const im = new Image(); im.src = asset(src(n)) })
|
| 62 |
+
}, [])
|
| 63 |
+
// 当前可见:自身区间内,或下一张仍在淡入时保留
|
| 64 |
+
const live = segs.filter((s) => t >= s.a - 0.05 && t < s.b + FADE + 0.05)
|
| 65 |
+
return (
|
| 66 |
+
<>
|
| 67 |
+
{live.map((s) => {
|
| 68 |
+
const fin = s.k === 0 ? 1 : tw(t, s.a, FADE, E.inOut)
|
| 69 |
+
const p = clamp((t - s.a) / (s.b + FADE - s.a))
|
| 70 |
+
const dir = s.k % 2 === 0 ? 1 : -1
|
| 71 |
+
const sc = 1.07 + (dir > 0 ? p : 1 - p) * 0.07
|
| 72 |
+
const tx = dir * (p - 0.5) * W * 0.03 + cam[0] * 0.4
|
| 73 |
+
const ty = (s.k % 3 === 0 ? -1 : 1) * (p - 0.5) * H * 0.015 + cam[1] * 0.4
|
| 74 |
+
return (
|
| 75 |
+
<div
|
| 76 |
+
key={s.k}
|
| 77 |
+
style={{
|
| 78 |
+
position: 'absolute',
|
| 79 |
+
inset: 0,
|
| 80 |
+
opacity: +(fin * s.alpha).toFixed(4),
|
| 81 |
+
transform: `translate(${tx.toFixed(2)}px, ${ty.toFixed(2)}px) scale(${sc.toFixed(5)})`,
|
| 82 |
+
transformOrigin: '50% 50%',
|
| 83 |
+
}}
|
| 84 |
+
>
|
| 85 |
+
<Img src={asset(src(s.n))} style={{ position: 'absolute', left: 0, top: 0, width: W, height: H, objectFit: 'cover' }} />
|
| 86 |
+
</div>
|
| 87 |
+
)
|
| 88 |
+
})}
|
| 89 |
+
</>
|
| 90 |
+
)
|
| 91 |
+
}
|
kkndme/frontend/src/rv/render.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Remotion 版:音频转 WAV、浏览器本地导出 MP4
|
| 2 |
+
import { renderMediaOnWeb, canRenderMediaOnWeb } from '@remotion/web-renderer'
|
| 3 |
+
import type { Timeline } from '../video/timeline'
|
| 4 |
+
import type { Stems } from '../video/audio'
|
| 5 |
+
import { Main } from './Main'
|
| 6 |
+
import type { VProps } from './ctx'
|
| 7 |
+
import { loadMixPcm } from './pcm'
|
| 8 |
+
import { preloadAssets } from './assets'
|
| 9 |
+
import { PHOTO_URLS } from './photos'
|
| 10 |
+
import { HOST_SRC, AVATAR_SRC } from './brand'
|
| 11 |
+
|
| 12 |
+
export type Res = '2k' | '1080' | '720'
|
| 13 |
+
export type Orient = 'landscape' | 'portrait'
|
| 14 |
+
export interface ExportOpts {
|
| 15 |
+
res: Res
|
| 16 |
+
fps: 24 | 30 | 60
|
| 17 |
+
music: boolean
|
| 18 |
+
orient: Orient
|
| 19 |
+
subtitles: boolean
|
| 20 |
+
}
|
| 21 |
+
export interface ExportProgress {
|
| 22 |
+
p: number
|
| 23 |
+
/** 剩余秒数 */
|
| 24 |
+
eta?: number
|
| 25 |
+
frames?: number
|
| 26 |
+
total?: number
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
export const PREVIEW_FPS = 30
|
| 30 |
+
/** 渲染循环多久让出一次主线程(毫秒):越大越快,页面略钝一点 */
|
| 31 |
+
const PAGE_RESPONSIVENESS = 'low' as const
|
| 32 |
+
const SCALE: Record<Res, number> = { '2k': 4 / 3, '1080': 1, '720': 2 / 3 }
|
| 33 |
+
const BITRATE: Record<Res, number> = { '2k': 14_000_000, '1080': 8_000_000, '720': 4_500_000 }
|
| 34 |
+
|
| 35 |
+
/** 合成画布尺寸(逻辑像素),导出时按 scale 放大/缩小 */
|
| 36 |
+
export const baseDims = (o: Orient): [number, number] => (o === 'portrait' ? [1080, 1920] : [1920, 1080])
|
| 37 |
+
export function dims(o: Pick<ExportOpts, 'res' | 'orient'>) {
|
| 38 |
+
const [w, h] = baseDims(o.orient)
|
| 39 |
+
return [Math.round(w * SCALE[o.res]), Math.round(h * SCALE[o.res])]
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/** AudioBuffer → 16-bit PCM WAV 的 blob URL */
|
| 43 |
+
export function bufferToWavUrl(buf: AudioBuffer): string {
|
| 44 |
+
const ch = Math.min(2, buf.numberOfChannels)
|
| 45 |
+
const n = buf.length
|
| 46 |
+
const sr = buf.sampleRate
|
| 47 |
+
const bytes = n * ch * 2
|
| 48 |
+
const ab = new ArrayBuffer(44 + bytes)
|
| 49 |
+
const v = new DataView(ab)
|
| 50 |
+
const w = (o: number, s: string) => {
|
| 51 |
+
for (let i = 0; i < s.length; i++) v.setUint8(o + i, s.charCodeAt(i))
|
| 52 |
+
}
|
| 53 |
+
w(0, 'RIFF')
|
| 54 |
+
v.setUint32(4, 36 + bytes, true)
|
| 55 |
+
w(8, 'WAVE')
|
| 56 |
+
w(12, 'fmt ')
|
| 57 |
+
v.setUint32(16, 16, true)
|
| 58 |
+
v.setUint16(20, 1, true)
|
| 59 |
+
v.setUint16(22, ch, true)
|
| 60 |
+
v.setUint32(24, sr, true)
|
| 61 |
+
v.setUint32(28, sr * ch * 2, true)
|
| 62 |
+
v.setUint16(32, ch * 2, true)
|
| 63 |
+
v.setUint16(34, 16, true)
|
| 64 |
+
w(36, 'data')
|
| 65 |
+
v.setUint32(40, bytes, true)
|
| 66 |
+
const out = new Int16Array(ab, 44, n * ch)
|
| 67 |
+
const chans = Array.from({ length: ch }, (_, c) => buf.getChannelData(c))
|
| 68 |
+
for (let i = 0; i < n; i++) {
|
| 69 |
+
for (let c = 0; c < ch; c++) {
|
| 70 |
+
const s = Math.max(-1, Math.min(1, chans[c][i]))
|
| 71 |
+
out[i * ch + c] = s < 0 ? s * 0x8000 : s * 0x7fff
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
return URL.createObjectURL(new Blob([ab], { type: 'audio/wav' }))
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
export interface AudioUrls {
|
| 78 |
+
main: string
|
| 79 |
+
music: string
|
| 80 |
+
}
|
| 81 |
+
export function stemsToUrls(s: Stems): AudioUrls {
|
| 82 |
+
return { main: bufferToWavUrl(s.main), music: bufferToWavUrl(s.music) }
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
export function exportSupported() {
|
| 86 |
+
return typeof window !== 'undefined' && 'VideoEncoder' in window && 'AudioEncoder' in window
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
export async function checkExport(o: ExportOpts) {
|
| 90 |
+
const [width, height] = baseDims(o.orient)
|
| 91 |
+
const r = await canRenderMediaOnWeb({ container: 'mp4', videoCodec: 'h264', width, height, scale: SCALE[o.res] })
|
| 92 |
+
return r
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
export async function exportMp4(tl: Timeline, urls: AudioUrls, o: ExportOpts, onProgress: (p: ExportProgress) => void, signal: AbortSignal, frameRange?: [number, number]): Promise<Blob> {
|
| 96 |
+
const [width, height] = baseDims(o.orient)
|
| 97 |
+
const chk = await canRenderMediaOnWeb({ container: 'mp4', videoCodec: 'h264', width, height, scale: SCALE[o.res] })
|
| 98 |
+
if (!chk.canRender) {
|
| 99 |
+
const msg = chk.issues.filter((i) => i.severity === 'error').map((i) => i.message).join(';')
|
| 100 |
+
throw new Error(`当前浏览器无法导出这个规格:${msg || '不支持 H.264 编码'}。请尝试降低分辨率,或换用电脑版 Chrome / Edge。`)
|
| 101 |
+
}
|
| 102 |
+
const durationInFrames = Math.ceil(tl.duration * o.fps)
|
| 103 |
+
// 图片:开头一次性缓存到本地,导出过程中不再联网(避免长时间导出中途凭证过期 / 网络抖动导致失败)
|
| 104 |
+
try {
|
| 105 |
+
await preloadAssets([...PHOTO_URLS, HOST_SRC, AVATAR_SRC])
|
| 106 |
+
} catch {
|
| 107 |
+
throw new Error('视频用到的图片没能加载完整,可能是网络不稳定或登录已过期。请刷新页面后再导出。')
|
| 108 |
+
}
|
| 109 |
+
signal.throwIfAborted()
|
| 110 |
+
// 音频:先把旁白和配乐混成一条整段 PCM,逐帧直接切片交给渲染器(不再逐帧解码),读不了再回退到 <Audio>
|
| 111 |
+
const pcm = await loadMixPcm(urls.main, o.music ? urls.music : undefined).catch(() => null)
|
| 112 |
+
signal.throwIfAborted()
|
| 113 |
+
const props: VProps = pcm
|
| 114 |
+
? { tl, subs: o.subtitles, music: o.music, pcm }
|
| 115 |
+
: { tl, subs: o.subtitles, music: o.music, mainSrc: urls.main, musicSrc: o.music ? urls.music : undefined }
|
| 116 |
+
const fpsK = o.fps === 60 ? 1.4 : o.fps === 24 ? 0.9 : 1
|
| 117 |
+
const { getBlob } = await renderMediaOnWeb({
|
| 118 |
+
composition: { id: 'kk-15y', component: Main, durationInFrames, fps: o.fps, width, height, defaultProps: props },
|
| 119 |
+
inputProps: props,
|
| 120 |
+
container: 'mp4',
|
| 121 |
+
videoCodec: 'h264',
|
| 122 |
+
audioCodec: chk.resolvedAudioCodec ?? undefined,
|
| 123 |
+
videoBitrate: Math.round(BITRATE[o.res] * fpsK),
|
| 124 |
+
audioBitrate: 192_000,
|
| 125 |
+
keyframeIntervalInSeconds: 2,
|
| 126 |
+
scale: SCALE[o.res],
|
| 127 |
+
signal,
|
| 128 |
+
licenseKey: 'free-license',
|
| 129 |
+
pageResponsiveness: PAGE_RESPONSIVENESS,
|
| 130 |
+
sampleRate: pcm?.sampleRate ?? 48000,
|
| 131 |
+
frameRange: frameRange ?? null,
|
| 132 |
+
onProgress: (pr) => onProgress({ p: pr.progress, eta: pr.renderEstimatedTime / 1000, frames: pr.encodedFrames, total: frameRange ? frameRange[1] - frameRange[0] + 1 : durationInFrames }),
|
| 133 |
+
})
|
| 134 |
+
return getBlob()
|
| 135 |
+
}
|
kkndme/frontend/src/rv/scenes.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type React from 'react'
|
| 2 |
+
import type { SceneKey } from '../video/script'
|
| 3 |
+
import { Intro, Method, Score } from './scenesA'
|
| 4 |
+
import { Price, Cities, Money, Policy } from './scenesB'
|
| 5 |
+
import { Rulers, Brier, Blind, Pending, Outro } from './scenesC'
|
| 6 |
+
import { Outlook } from './scenesD'
|
| 7 |
+
|
| 8 |
+
export const SCENES: Record<SceneKey, React.FC> = {
|
| 9 |
+
intro: Intro,
|
| 10 |
+
method: Method,
|
| 11 |
+
score: Score,
|
| 12 |
+
price: Price,
|
| 13 |
+
cities: Cities,
|
| 14 |
+
money: Money,
|
| 15 |
+
policy: Policy,
|
| 16 |
+
rulers: Rulers,
|
| 17 |
+
brier: Brier,
|
| 18 |
+
blind: Blind,
|
| 19 |
+
pending: Pending,
|
| 20 |
+
outlook: Outlook,
|
| 21 |
+
outro: Outro,
|
| 22 |
+
}
|
kkndme/frontend/src/rv/scenesA.tsx
ADDED
|
@@ -0,0 +1,841 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// 序章 · 方法 · 总成绩
|
| 2 |
+
import React from 'react'
|
| 3 |
+
import { C, E, clamp, hexA, lerp, rand, spr, tw, fmt, STATUS_COLOR } from './theme'
|
| 4 |
+
import { useS } from './ctx'
|
| 5 |
+
import { Chars, Roll, shineStyle, goldText, txtStyle, Icon } from './ui'
|
| 6 |
+
import { Beat, Big, Card, Quote, Stamp, T, Tag, Ring, cn, mono, serif, useP, useVis, Dot } from './kit'
|
| 7 |
+
import { svgText } from './charts'
|
| 8 |
+
import { Clawd } from './brand'
|
| 9 |
+
import { CLAWD_ORANGE } from '../video/clawd'
|
| 10 |
+
import { wordAt } from '../video/script'
|
| 11 |
+
import { SALES } from '../video/series'
|
| 12 |
+
import { rows, all, subCounts, weighted, byTopic, rateOf } from '../data/science'
|
| 13 |
+
|
| 14 |
+
const pct = (v: number) => Math.round(v * 100)
|
| 15 |
+
|
| 16 |
+
// ================= 序章 =================
|
| 17 |
+
const AVG = [5032, 5357, 5791, 6237, 6324, 6793, 7476, 7892, 8737, 9310, 9860]
|
| 18 |
+
const POST = '2010 年的房地产调控,让很多人看到了希望:让房价降得再猛烈些吧。'
|
| 19 |
+
|
| 20 |
+
export function Intro() {
|
| 21 |
+
const S = useS()
|
| 22 |
+
const { P, W, H, M } = S
|
| 23 |
+
const p = useP()
|
| 24 |
+
/** 第 k 句中某个词开始朗读的大致秒数 */
|
| 25 |
+
const fr = (k: number, w: string) => wordAt(S.sc.lines[k]?.text ?? '', w) * S.ld(k)
|
| 26 |
+
// ---- 1:帖子
|
| 27 |
+
const typed = Math.max(0, Math.floor((S.lt(1) - 2.2) * 13))
|
| 28 |
+
const caret = Math.floor(S.t * 2.2) % 2 === 0
|
| 29 |
+
// ---- 1:均价柱
|
| 30 |
+
const cw = W - M * 2
|
| 31 |
+
const ch = P ? 560 : 380
|
| 32 |
+
const cy0 = P ? 760 : 470
|
| 33 |
+
const bw = (cw / AVG.length) * 0.56
|
| 34 |
+
const grow = (i: number) => E.out(clamp((S.lt(3) - 0.5 - i * 0.26) / 0.9))
|
| 35 |
+
const cnt = clamp((S.lt(3) - 0.5) / (0.26 * 10 + 0.9))
|
| 36 |
+
const curV = Math.round(lerp(5032, 9860, E.soft(cnt)))
|
| 37 |
+
// ---- 2:圣经 → 反转
|
| 38 |
+
const rv = S.lt(4) - 3.7
|
| 39 |
+
const glitch = rv > 0 && rv < 0.7
|
| 40 |
+
const broke = tw(rv, 0, 0.6)
|
| 41 |
+
// ---- 3:销售面积
|
| 42 |
+
const sMax = 18
|
| 43 |
+
const sgrow = (i: number) => E.out(clamp((S.lt(5) - 0.3 - i * 0.12) / 0.7))
|
| 44 |
+
const drop = p(5, 3.4, 1.4)
|
| 45 |
+
return (
|
| 46 |
+
<>
|
| 47 |
+
{/* 0:2010 年的楼市 */}
|
| 48 |
+
<Beat k={0} to={1} x={M} y={P ? 300 : 280} w={P ? W - M * 2 : 760}>
|
| 49 |
+
<Tag text="CHINA · 2010" p={p(0, 0.2)} />
|
| 50 |
+
<div style={{ marginTop: 22, display: 'flex', alignItems: 'flex-end', gap: 26 }}>
|
| 51 |
+
<Roll value="2010" p={p(0, 0.3, 1.6)} color={C.ink} style={txtStyle({ f: 'num', size: P ? 200 : 210, w: 800, ls: -6, lh: 1 })} />
|
| 52 |
+
<RiseIcon w={P ? 118 : 128} h={P ? 150 : 160} p={p(0, 0.9, 1.8)} />
|
| 53 |
+
</div>
|
| 54 |
+
<T p={p(0, 1.0)} style={{ ...serif(P ? 64 : 62), marginTop: 18 }}>
|
| 55 |
+
楼市正在<span style={{ color: C.red }}>狂飙</span>
|
| 56 |
+
</T>
|
| 57 |
+
</Beat>
|
| 58 |
+
{[
|
| 59 |
+
{ at: fr(0, '4月'), d: '2010.04.17 · 国务院', h: '“新国十条”出台', s: '坚决遏制部分城市房价过快上涨' },
|
| 60 |
+
{ at: fr(0, '北京'), d: '2010.04.30 · 北京', h: '率先限购', s: '同一家庭只能新购一套商品住房' },
|
| 61 |
+
].map((it, i) => (
|
| 62 |
+
<Beat key={it.h} k={0} to={1} d={it.at} x={P ? M : 1000} y={P ? 830 + i * 230 : 250 + i * 230} w={P ? W - M * 2 : 780}>
|
| 63 |
+
<Card pad={P ? '26px 34px' : '26px 34px'} tint={C.red}>
|
| 64 |
+
<div style={mono(P ? 20 : 18, C.dim, 600, 3)}>{it.d}</div>
|
| 65 |
+
<div style={{ ...serif(P ? 50 : 48), marginTop: 10 }}>{it.h}</div>
|
| 66 |
+
<div style={{ ...cn(P ? 26 : 24, 500, C.mute), marginTop: 8 }}>{it.s}</div>
|
| 67 |
+
</Card>
|
| 68 |
+
</Beat>
|
| 69 |
+
))}
|
| 70 |
+
<Beat k={0} to={1} d={fr(0, '人人')} x={P ? M : 1000} y={P ? 1300 : 730} w={P ? W - M * 2 : 780}>
|
| 71 |
+
<div style={{ display: 'inline-block', position: 'relative', padding: P ? '24px 40px' : '22px 40px', borderRadius: 28, background: hexA(C.gold, 0.14), border: `2px solid ${hexA(C.gold, 0.6)}` }}>
|
| 72 |
+
<div style={{ ...serif(P ? 56 : 54, C.goldHi) }}>房价,到底会不会跌?</div>
|
| 73 |
+
<div style={{ position: 'absolute', left: 60, bottom: -22, width: 0, height: 0, borderLeft: '16px solid transparent', borderRight: '16px solid transparent', borderTop: `22px solid ${hexA(C.gold, 0.6)}` }} />
|
| 74 |
+
</div>
|
| 75 |
+
</Beat>
|
| 76 |
+
|
| 77 |
+
{/* 1:KKndme 开帖 */}
|
| 78 |
+
<Beat k={1} to={2} x={M} y={P ? 280 : 270} w={P ? W - M * 2 : 760}>
|
| 79 |
+
<Tag text="TIANYA FORUM · 2010.08" p={p(1, 0.2)} />
|
| 80 |
+
<div style={{ marginTop: 26, display: 'flex', alignItems: 'baseline', flexWrap: 'wrap' }}>
|
| 81 |
+
<span style={{ ...txtStyle({ f: 'serif', size: P ? 170 : 180, w: 900, lh: 1 }), ...shineStyle(clamp((S.lt(1) - fr(1, 'KK')) / 1.6) * 1.6 - 0.3) }}>KK</span>
|
| 82 |
+
<span style={{ ...txtStyle({ f: 'serif', size: P ? 130 : 136, w: 900, lh: 1 }), ...goldText() }}>ndme</span>
|
| 83 |
+
</div>
|
| 84 |
+
<T p={p(1, 0.8)} style={{ ...cn(P ? 34 : 32, 500, C.mute), marginTop: 20 }}>
|
| 85 |
+
天涯论坛,一个帖子开始了
|
| 86 |
+
</T>
|
| 87 |
+
<div style={{ display: 'flex', gap: P ? 14 : 16, marginTop: P ? 34 : 40, flexWrap: 'wrap' }}>
|
| 88 |
+
{['土地', '货币', '制度', '人性'].map((w, i) => {
|
| 89 |
+
const q = tw(S.lt(1), fr(1, w) - 0.1, 0.5)
|
| 90 |
+
return (
|
| 91 |
+
<div key={w} style={{ opacity: clamp(q * 1.5), transform: `translateY(${((1 - E.out(q)) * 20).toFixed(1)}px) scale(${lerp(0.8, 1, E.out(q)).toFixed(3)})`, padding: P ? '12px 28px' : '12px 30px', borderRadius: 999, border: `1.5px solid ${hexA(C.gold, 0.6)}`, background: hexA(C.gold, i === 3 ? 0.22 : 0.08), ...cn(P ? 36 : 34, 800, i === 3 ? C.goldHi : C.ink) }}>
|
| 92 |
+
{w}
|
| 93 |
+
</div>
|
| 94 |
+
)
|
| 95 |
+
})}
|
| 96 |
+
</div>
|
| 97 |
+
</Beat>
|
| 98 |
+
<Beat k={1} to={2} d={0.8} x={P ? M : 960} y={P ? 900 : 300} w={P ? W - M * 2 : 820}>
|
| 99 |
+
<Card pad={P ? 40 : 36}>
|
| 100 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 18 }}>
|
| 101 |
+
<div style={{ width: 64, height: 64, borderRadius: '50%', background: `linear-gradient(140deg, ${C.goldHi}, ${C.goldDeep})`, display: 'flex', alignItems: 'center', justifyContent: 'center', ...txtStyle({ f: 'num', size: 28, w: 800, color: C.bg }) }}>KK</div>
|
| 102 |
+
<div>
|
| 103 |
+
<div style={txtStyle({ f: 'num', size: 32, w: 700 })}>KKndme</div>
|
| 104 |
+
<div style={{ ...mono(18, C.dim), marginTop: 6 }}>楼主 · 天涯论坛 · 2010-08</div>
|
| 105 |
+
</div>
|
| 106 |
+
<div style={{ flex: 1 }} />
|
| 107 |
+
<div style={{ ...mono(18, C.gold, 700), border: `1px solid ${hexA(C.gold, 0.5)}`, padding: '6px 12px', borderRadius: 8 }}>#1</div>
|
| 108 |
+
</div>
|
| 109 |
+
<div style={{ height: 1, background: C.hair, margin: '26px 0' }} />
|
| 110 |
+
<div style={{ ...serif(P ? 40 : 36, C.ink, 700, 1.6), minHeight: P ? 192 : 172 }}>
|
| 111 |
+
{POST.slice(0, typed)}
|
| 112 |
+
<span style={{ display: 'inline-block', width: 3, height: '1em', marginLeft: 4, verticalAlign: '-0.12em', background: C.goldHi, opacity: caret || typed < POST.length ? 1 : 0 }} />
|
| 113 |
+
</div>
|
| 114 |
+
<div style={{ ...mono(18, C.dim), marginTop: 18 }}>—— 摘自原帖第一楼</div>
|
| 115 |
+
</Card>
|
| 116 |
+
</Beat>
|
| 117 |
+
|
| 118 |
+
{/* 2:11 个月 · 一千多层楼 · KK大神 */}
|
| 119 |
+
<Beat k={2} to={3} x={0} y={P ? 330 : 250} w={W} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }} rise={0}>
|
| 120 |
+
<Tag text="2010.08 — 2011.07" p={p(2, 0.2)} size={20} />
|
| 121 |
+
<div style={{ display: 'flex', flexDirection: P ? 'column' : 'row', gap: P ? 40 : 120, marginTop: P ? 50 : 46, alignItems: 'center' }}>
|
| 122 |
+
{[
|
| 123 |
+
{ v: '11', u: '个月', at: fr(2, '整整') - 0.3, l: '持续更新' },
|
| 124 |
+
{ v: '1000+', u: '层楼', at: fr(2, '一千') - 0.2, l: '整理后的原帖楼层' },
|
| 125 |
+
].map((it) => (
|
| 126 |
+
<div key={it.u} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', opacity: clamp(p(2, Math.max(0.3, it.at), 0.6) * 1.4) }}>
|
| 127 |
+
<Big v={it.v} p={p(2, Math.max(0.3, it.at), 1.4)} size={P ? 170 : 170} unit={it.u} color={C.ink} />
|
| 128 |
+
<div style={{ ...cn(P ? 28 : 26, 500, C.mute), marginTop: 6 }}>{it.l}</div>
|
| 129 |
+
</div>
|
| 130 |
+
))}
|
| 131 |
+
</div>
|
| 132 |
+
<div style={{ display: 'flex', gap: P ? 14 : 18, marginTop: P ? 50 : 50 }}>
|
| 133 |
+
{['追更', '抄笔记', '整理成册'].map((w, i) => {
|
| 134 |
+
const q = tw(S.lt(2), fr(2, w) - 0.1, 0.5)
|
| 135 |
+
return (
|
| 136 |
+
<div key={w} style={{ opacity: clamp(q * 1.5), transform: `translateY(${((1 - E.out(q)) * 18).toFixed(1)}px)`, padding: '10px 26px', borderRadius: 12, background: 'rgba(243,238,228,0.06)', border: `1px solid ${C.hair}`, ...cn(P ? 32 : 30, 700, C.ink) }}>
|
| 137 |
+
{w}
|
| 138 |
+
</div>
|
| 139 |
+
)
|
| 140 |
+
})}
|
| 141 |
+
</div>
|
| 142 |
+
<div style={{ marginTop: P ? 70 : 50, height: P ? 180 : 170, display: 'flex', alignItems: 'center' }}>
|
| 143 |
+
<Stamp text="KK大神" sub="网友尊称" p={p(2, fr(2, '尊称') + 0.4, 0.7, E.lin)} size={P ? 110 : 104} rot={-8} color={C.goldHi} />
|
| 144 |
+
</div>
|
| 145 |
+
</Beat>
|
| 146 |
+
|
| 147 |
+
{/* 1 */}
|
| 148 |
+
<Beat k={3} to={4} x={M} y={P ? 380 : 270} w={cw}>
|
| 149 |
+
<Tag text="全国商品房平均销售价格 · 元/㎡" p={p(3, 0.1)} />
|
| 150 |
+
<div style={{ display: 'flex', alignItems: 'baseline', gap: 26, marginTop: 14 }}>
|
| 151 |
+
<div style={{ ...txtStyle({ f: 'num', size: P ? 150 : 120, w: 800, ls: -4, lh: 1.05 }), fontVariantNumeric: 'tabular-nums', ...goldText() }}>{fmt(curV)}</div>
|
| 152 |
+
<T p={p(3, 3.6)} style={txtStyle({ f: 'num', size: P ? 40 : 44, w: 700, color: C.ink })}>
|
| 153 |
+
× {(curV / 5032).toFixed(2)}
|
| 154 |
+
</T>
|
| 155 |
+
</div>
|
| 156 |
+
</Beat>
|
| 157 |
+
<Beat k={3} to={4} x={0} y={0} rise={0}>
|
| 158 |
+
<svg width={W} height={H} style={{ position: 'absolute', left: 0, top: 0 }}>
|
| 159 |
+
<defs>
|
| 160 |
+
<linearGradient id="avgbar" x1="0" y1="0" x2="0" y2="1">
|
| 161 |
+
<stop offset="0" stopColor={C.goldHi} />
|
| 162 |
+
<stop offset="1" stopColor={C.goldDeep} stopOpacity={0.25} />
|
| 163 |
+
</linearGradient>
|
| 164 |
+
</defs>
|
| 165 |
+
<line x1={M} x2={M + cw} y1={cy0 + ch} y2={cy0 + ch} stroke={C.faint} />
|
| 166 |
+
{AVG.map((v, i) => {
|
| 167 |
+
const g = grow(i)
|
| 168 |
+
const x = M + (cw / AVG.length) * (i + 0.5) - bw / 2
|
| 169 |
+
const h = (v / 10000) * ch * g
|
| 170 |
+
const key = i === 0 || i === AVG.length - 1
|
| 171 |
+
return (
|
| 172 |
+
<g key={i}>
|
| 173 |
+
<rect x={x} y={cy0 + ch - h} width={bw} height={Math.max(0, h)} rx={6} fill="url(#avgbar)" opacity={key ? 1 : 0.55} />
|
| 174 |
+
{g > 0.05 && (
|
| 175 |
+
<text x={x + bw / 2} y={cy0 + ch - h - 14} textAnchor="middle" fill={key ? C.goldHi : C.mute} opacity={g} style={svgText(key ? (P ? 26 : 24) : P ? 17 : 19, key ? 800 : 500, key ? 'num' : 'mono')}>
|
| 176 |
+
{fmt(v)}
|
| 177 |
+
</text>
|
| 178 |
+
)}
|
| 179 |
+
<text x={x + bw / 2} y={cy0 + ch + (P ? 40 : 36)} textAnchor="middle" fill={C.dim} opacity={clamp(g * 2)} style={svgText(P ? 20 : 18, 500, 'mono')}>
|
| 180 |
+
{P ? `’${String(10 + i)}` : 2010 + i}
|
| 181 |
+
</text>
|
| 182 |
+
</g>
|
| 183 |
+
)
|
| 184 |
+
})}
|
| 185 |
+
</svg>
|
| 186 |
+
</Beat>
|
| 187 |
+
|
| 188 |
+
{/* 2 */}
|
| 189 |
+
<Beat k={4} to={5} x={0} y={P ? 640 : 300} w={W} style={{ textAlign: 'center' }} rise={0}>
|
| 190 |
+
<T p={p(4, 0.1)} style={{ display: 'flex', justifyContent: 'center' }}>
|
| 191 |
+
<Tag text="“THE BIBLE OF REAL ESTATE”" p={p(4, 0.1)} />
|
| 192 |
+
</T>
|
| 193 |
+
<div style={{ position: 'relative', marginTop: 40, height: P ? 170 : 220 }}>
|
| 194 |
+
{glitch &&
|
| 195 |
+
[C.red, C.sky].map((col, i) => (
|
| 196 |
+
<div key={col} style={{ position: 'absolute', left: 0, right: 0, top: 0, ...serif(P ? 150 : 200, col, 900, 1), whiteSpace: 'nowrap', opacity: 0.6, transform: `translate(${((rand(Math.floor(S.t * 30), i) - 0.5) * 40).toFixed(1)}px, ${((rand(Math.floor(S.t * 30), i + 4) - 0.5) * 14).toFixed(1)}px)`, clipPath: `inset(${(rand(Math.floor(S.t * 24), i + 9) * 60).toFixed(0)}% 0 ${(rand(Math.floor(S.t * 24), i + 13) * 30).toFixed(0)}% 0)` }}>
|
| 197 |
+
“房地产圣经”
|
| 198 |
+
</div>
|
| 199 |
+
))}
|
| 200 |
+
<div
|
| 201 |
+
style={{
|
| 202 |
+
position: 'absolute',
|
| 203 |
+
left: 0,
|
| 204 |
+
right: 0,
|
| 205 |
+
top: 0,
|
| 206 |
+
...serif(P ? 150 : 200, C.ink, 900, 1),
|
| 207 |
+
whiteSpace: 'nowrap',
|
| 208 |
+
transform: `scale(${lerp(1.12, 1, p(4, 0, 2.4)).toFixed(4)})`,
|
| 209 |
+
filter: `blur(${((1 - p(4, 0, 1.2)) * 20).toFixed(1)}px)${broke > 0 ? ` grayscale(${broke.toFixed(2)}) brightness(${lerp(1, 0.55, broke).toFixed(2)})` : ''}`,
|
| 210 |
+
opacity: clamp(p(4, 0, 1) * 1.5),
|
| 211 |
+
...(broke < 0.01 ? shineStyle(clamp((S.lt(4) - 1.2) / 1.6), C.goldHi) : {}),
|
| 212 |
+
}}
|
| 213 |
+
>
|
| 214 |
+
“房地产圣经”
|
| 215 |
+
</div>
|
| 216 |
+
{/* 斜向红色划痕 */}
|
| 217 |
+
{broke > 0 && <div style={{ position: 'absolute', left: W / 2 - (P ? 440 : 620), top: P ? 80 : 104, width: (P ? 880 : 1240) * broke, height: 6, background: C.red, boxShadow: `0 0 24px ${C.red}`, transform: 'rotate(-4deg)', transformOrigin: 'left center' }} />}
|
| 218 |
+
</div>
|
| 219 |
+
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', gap: 22, marginTop: P ? 70 : 60, opacity: clamp(broke * 2) }}>
|
| 220 |
+
<div style={{ ...txtStyle({ f: 'num', size: P ? 72 : 64, w: 800, color: C.red }) }}>2021</div>
|
| 221 |
+
<svg width={50} height={60} viewBox="0 0 50 60" style={{ display: 'block' }}>
|
| 222 |
+
<path d="M25 4 L25 52 M8 36 L25 54 L42 36" stroke={C.red} strokeWidth={6} fill="none" strokeLinecap="round" strokeLinejoin="round" strokeDasharray={120} strokeDashoffset={120 * (1 - broke)} />
|
| 223 |
+
</svg>
|
| 224 |
+
<div style={cn(P ? 48 : 44, 800, C.ink)}>剧情反转</div>
|
| 225 |
+
</div>
|
| 226 |
+
</Beat>
|
| 227 |
+
|
| 228 |
+
{/* 3 */}
|
| 229 |
+
<Beat k={5} to={6} x={M} y={P ? 380 : 270} w={cw}>
|
| 230 |
+
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', flexDirection: P ? 'column' : 'row', gap: P ? 16 : 0 }}>
|
| 231 |
+
<div>
|
| 232 |
+
<Tag text="全国商品房销售面积 · 亿㎡" p={p(5, 0.1)} />
|
| 233 |
+
<T p={p(5, 0.4)} style={{ ...serif(P ? 56 : 54), marginTop: 18 }}>
|
| 234 |
+
从 17.9 亿,到 8.8 亿
|
| 235 |
+
</T>
|
| 236 |
+
</div>
|
| 237 |
+
<div style={{ opacity: clamp(drop * 2) }}>
|
| 238 |
+
<Big v="−51%" p={drop} size={P ? 150 : 140} color={C.red} f="num" />
|
| 239 |
+
</div>
|
| 240 |
+
</div>
|
| 241 |
+
</Beat>
|
| 242 |
+
<Beat k={5} to={6} x={0} y={0} rise={0}>
|
| 243 |
+
<svg width={W} height={H} style={{ position: 'absolute', left: 0, top: 0 }}>
|
| 244 |
+
<defs>
|
| 245 |
+
<linearGradient id="sl-g" x1="0" y1="0" x2="0" y2="1">
|
| 246 |
+
<stop offset="0" stopColor={C.gold} />
|
| 247 |
+
<stop offset="1" stopColor={C.gold} stopOpacity={0.15} />
|
| 248 |
+
</linearGradient>
|
| 249 |
+
<linearGradient id="sl-r" x1="0" y1="0" x2="0" y2="1">
|
| 250 |
+
<stop offset="0" stopColor={C.red} />
|
| 251 |
+
<stop offset="1" stopColor={C.red} stopOpacity={0.15} />
|
| 252 |
+
</linearGradient>
|
| 253 |
+
</defs>
|
| 254 |
+
{(() => {
|
| 255 |
+
const top = P ? 820 : 540
|
| 256 |
+
const hh = P ? 520 : 330
|
| 257 |
+
const sw = cw / SALES.length
|
| 258 |
+
const bww = sw * 0.6
|
| 259 |
+
const X = (i: number) => M + sw * (i + 0.5)
|
| 260 |
+
const Y = (v: number) => top + hh - (v / sMax) * hh
|
| 261 |
+
const pk = 11
|
| 262 |
+
return (
|
| 263 |
+
<g>
|
| 264 |
+
<line x1={M} x2={M + cw} y1={top + hh} y2={top + hh} stroke={C.faint} />
|
| 265 |
+
{SALES.map((v, i) => {
|
| 266 |
+
const g = sgrow(i)
|
| 267 |
+
const red = i > pk
|
| 268 |
+
const h = (v / sMax) * hh * g
|
| 269 |
+
return (
|
| 270 |
+
<g key={i}>
|
| 271 |
+
<rect x={X(i) - bww / 2} y={top + hh - h} width={bww} height={Math.max(0, h)} rx={5} fill={red ? 'url(#sl-r)' : 'url(#sl-g)'} opacity={i === pk || i === 15 ? 1 : 0.6} />
|
| 272 |
+
{(i % (P ? 3 : 1) === 0 || i === 15) && (
|
| 273 |
+
<text x={X(i)} y={top + hh + 34} textAnchor="middle" fill={C.dim} opacity={clamp(g * 2)} style={svgText(P ? 20 : 17, 500, 'mono')}>
|
| 274 |
+
{P ? `’${10 + i}` : 2010 + i}
|
| 275 |
+
</text>
|
| 276 |
+
)}
|
| 277 |
+
</g>
|
| 278 |
+
)
|
| 279 |
+
})}
|
| 280 |
+
{/* 峰值与当前 */}
|
| 281 |
+
<g opacity={clamp(sgrow(pk) * 2 - 1)}>
|
| 282 |
+
<text x={X(pk)} y={Y(SALES[pk]) - 18} textAnchor="middle" fill={C.goldHi} style={svgText(P ? 28 : 26, 800, 'num')}>
|
| 283 |
+
17.94
|
| 284 |
+
</text>
|
| 285 |
+
</g>
|
| 286 |
+
<g opacity={clamp(sgrow(15) * 2 - 1)}>
|
| 287 |
+
<text x={X(15)} y={Y(SALES[15]) - 18} textAnchor="middle" fill={C.red} style={svgText(P ? 28 : 26, 800, 'num')}>
|
| 288 |
+
8.81
|
| 289 |
+
</text>
|
| 290 |
+
</g>
|
| 291 |
+
{drop > 0 && (
|
| 292 |
+
<g opacity={drop}>
|
| 293 |
+
<line x1={X(pk) + bww / 2 + 6} x2={X(pk) + bww / 2 + 6 + (X(15) - X(pk) - bww / 2 - 6) * drop} y1={Y(SALES[pk])} y2={Y(SALES[pk])} stroke={hexA(C.red, 0.8)} strokeDasharray="6 6" strokeWidth={2} />
|
| 294 |
+
<line x1={X(15)} x2={X(15)} y1={Y(SALES[pk])} y2={Y(SALES[pk]) + (Y(SALES[15]) - 50 - Y(SALES[pk])) * drop} stroke={C.red} strokeWidth={3} />
|
| 295 |
+
<path d={`M${X(15) - 10},${Y(SALES[15]) - 62} L${X(15)},${Y(SALES[15]) - 48} L${X(15) + 10},${Y(SALES[15]) - 62}`} stroke={C.red} strokeWidth={3} fill="none" opacity={drop > 0.9 ? 1 : 0} />
|
| 296 |
+
</g>
|
| 297 |
+
)}
|
| 298 |
+
</g>
|
| 299 |
+
)
|
| 300 |
+
})()}
|
| 301 |
+
</svg>
|
| 302 |
+
</Beat>
|
| 303 |
+
|
| 304 |
+
{/* 4:标题 */}
|
| 305 |
+
<Ledger />
|
| 306 |
+
<Beat k={6} x={0} y={P ? 640 : 300} w={W} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }} rise={0}>
|
| 307 |
+
<T p={p(6, 0.2)}>
|
| 308 |
+
<div style={mono(P ? 22 : 20, C.gold, 700, 8)}>2010 — 2026 · AN AUDIT</div>
|
| 309 |
+
</T>
|
| 310 |
+
<div style={{ position: 'relative', marginTop: 34 }}>
|
| 311 |
+
<Chars text="神贴十五年" t={S.lt(6) - 0.3} st={0.12} d={1.1} dy={0.3} blur={22} style={{ ...txtStyle({ f: 'serif', size: P ? 150 : 170, w: 900, lh: 1.05, ls: 10 }) }} />
|
| 312 |
+
<div style={{ position: 'absolute', right: P ? -40 : -236, top: P ? -150 : -24 }}>
|
| 313 |
+
<Stamp text="对账" sub="2010—2026" p={p(6, 3.2, 0.7, E.lin)} size={P ? 74 : 92} rot={-10} />
|
| 314 |
+
</div>
|
| 315 |
+
</div>
|
| 316 |
+
<div style={{ marginTop: P ? 36 : 28, ...txtStyle({ f: 'serif', size: P ? 86 : 92, w: 900, ls: 22 }), ...goldText(), opacity: clamp(p(6, 1.3, 1.2) * 1.4), filter: p(6, 1.3, 1.2) < 0.97 ? `blur(${((1 - p(6, 1.3, 1.2)) * 14).toFixed(1)}px)` : undefined }}>
|
| 317 |
+
一笔一笔对账
|
| 318 |
+
</div>
|
| 319 |
+
<T p={p(6, 2.4)} style={{ marginTop: P ? 50 : 44 }}>
|
| 320 |
+
<div style={mono(P ? 20 : 19, C.mute, 600, 5)}>986 PAGES · 123 PREDICTIONS · CHECKED TO 2026.10</div>
|
| 321 |
+
</T>
|
| 322 |
+
</Beat>
|
| 323 |
+
</>
|
| 324 |
+
)
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
/** 账本横线背景 */
|
| 328 |
+
function Ledger() {
|
| 329 |
+
const S = useS()
|
| 330 |
+
const vis = useVis()
|
| 331 |
+
const v = vis(6)
|
| 332 |
+
if (v <= 0.001) return null
|
| 333 |
+
const n = S.P ? 26 : 14
|
| 334 |
+
const gap = S.H / (n + 1)
|
| 335 |
+
return (
|
| 336 |
+
<div style={{ position: 'absolute', inset: 0, opacity: v * 0.9 }}>
|
| 337 |
+
{Array.from({ length: n }, (_, i) => {
|
| 338 |
+
const q = tw(S.lt(6), 0.05 * i, 1.4, E.inOut)
|
| 339 |
+
const fromL = i % 2 === 0
|
| 340 |
+
return (
|
| 341 |
+
<div key={i} style={{ position: 'absolute', top: gap * (i + 1), left: fromL ? 0 : S.W * (1 - q), width: S.W * q, height: 1, background: i % 4 === 0 ? hexA(C.gold, 0.16) : 'rgba(243,238,228,0.05)' }} />
|
| 342 |
+
)
|
| 343 |
+
})}
|
| 344 |
+
{Array.from({ length: S.P ? 8 : 12 }, (_, i) => (
|
| 345 |
+
<div key={'n' + i} style={{ position: 'absolute', left: S.P ? 40 + (i % 2) * (S.W - 200) : 60 + (i % 2) * (S.W - 220), top: gap * (2 * i + 1.6) - 12, ...mono(15, 'rgba(243,238,228,0.12)', 500, 1), transform: `translateY(${(-S.lt(6) * 8).toFixed(1)}px)`, opacity: tw(S.lt(6), 0.8 + i * 0.1, 1) }}>
|
| 346 |
+
{`${(2010 + i).toString()} · ${(rand(i, 3) * 90000 + 1000).toFixed(0).padStart(6, '0')}`}
|
| 347 |
+
</div>
|
| 348 |
+
))}
|
| 349 |
+
</div>
|
| 350 |
+
)
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
// ================= 方法 =================
|
| 354 |
+
const LAYERS = [
|
| 355 |
+
{ t: '具体程度', en: 'SPECIFICITY', o: ['模糊判断', '方向明确', '带数字或期限'] },
|
| 356 |
+
{ t: '是否逆共识', en: 'CONSENSUS', o: ['顺共识', '中性', '���共识'] },
|
| 357 |
+
{ t: '赌的是什么', en: 'BET TYPE', o: ['政策 · 城市', '趋势 · 宏观', '时间点 · 幅度'] },
|
| 358 |
+
{ t: '证据强度', en: 'EVIDENCE', o: ['官方统计', '权威报道', '间接推算'] },
|
| 359 |
+
]
|
| 360 |
+
const SOURCES = [
|
| 361 |
+
{ n: '国家统计局', en: 'NBS', d: '房价 · 销售 · CPI · 人口普查' },
|
| 362 |
+
{ n: '中国人民银行', en: 'PBOC', d: 'M2 · 利率 · 首付政策' },
|
| 363 |
+
{ n: '国际清算银行', en: 'BIS', d: '中国住宅价格指数' },
|
| 364 |
+
{ n: '公开报道', en: 'PRESS', d: '政策文件 · 权威媒体' },
|
| 365 |
+
]
|
| 366 |
+
const ID_SORT = [...rows].sort((a, b) => a.id.localeCompare(b.id))
|
| 367 |
+
const FILES = [
|
| 368 |
+
{ en: 'TIANYA · 原帖', t: '天涯原帖', pages: 480 },
|
| 369 |
+
{ en: 'KKNDME · 合集', t: '整理合集', pages: 506 },
|
| 370 |
+
]
|
| 371 |
+
|
| 372 |
+
export function Method() {
|
| 373 |
+
const S = useS()
|
| 374 |
+
const { P, W, M } = S
|
| 375 |
+
const p = useP()
|
| 376 |
+
const vis = useVis()
|
| 377 |
+
// 点阵位置
|
| 378 |
+
const cols = P ? 12 : 16
|
| 379 |
+
const gx = P ? 74 : 54
|
| 380 |
+
const gy = P ? 46 : 52
|
| 381 |
+
const ox = P ? M + 40 : 960
|
| 382 |
+
const oy = P ? 440 : 320
|
| 383 |
+
const scanX = lerp(ox - 60, ox + cols * gx + 60, tw(S.lt(3), 1.2, 3.2, E.inOut))
|
| 384 |
+
const dv = vis(2, 4)
|
| 385 |
+
return (
|
| 386 |
+
<>
|
| 387 |
+
{/* 5–6:两份文件 → Claude Opus 5.5 通读 → 共 986 页 */}
|
| 388 |
+
<Beat k={0} to={2} x={0} y={0} rise={0}>
|
| 389 |
+
{FILES.map((f, fi) =>
|
| 390 |
+
Array.from({ length: 7 }, (_, i) => {
|
| 391 |
+
const q = spr(S.lt(0) - 0.6 - fi * 0.5 - i * 0.05, { k: 9, z: 0.7 })
|
| 392 |
+
const merge = p(1, 0.2, 1.2, E.inOut)
|
| 393 |
+
const c = i - 3
|
| 394 |
+
const base = P ? W / 2 + (fi ? 175 : -175) : fi ? 650 : 360
|
| 395 |
+
const cx = lerp(base, P ? W / 2 : 505, merge * 0.55)
|
| 396 |
+
const cy = P ? 600 : 590
|
| 397 |
+
const pw = P ? 280 : 270
|
| 398 |
+
const ph = P ? 360 : 360
|
| 399 |
+
const top = i === 6
|
| 400 |
+
return (
|
| 401 |
+
<div
|
| 402 |
+
key={`${fi}-${i}`}
|
| 403 |
+
style={{
|
| 404 |
+
position: 'absolute',
|
| 405 |
+
left: cx - pw / 2,
|
| 406 |
+
top: cy - ph / 2,
|
| 407 |
+
width: pw,
|
| 408 |
+
height: ph,
|
| 409 |
+
borderRadius: 10,
|
| 410 |
+
background: `linear-gradient(160deg, rgba(246,240,228,${0.12 + i * 0.008}), rgba(246,240,228,0.04))`,
|
| 411 |
+
border: `1px solid ${top ? hexA(C.gold, 0.5) : 'rgba(243,238,228,0.16)'}`,
|
| 412 |
+
boxShadow: '0 20px 50px rgba(0,0,0,0.5)',
|
| 413 |
+
transform: `translate(${(c * 14 * q).toFixed(1)}px, ${(Math.abs(c) * 6 * q + (1 - clamp(q)) * 120).toFixed(1)}px) rotate(${(c * 2.6 * q + (fi ? 4 : -4) * (1 - merge)).toFixed(2)}deg)`,
|
| 414 |
+
transformOrigin: '50% 120%',
|
| 415 |
+
opacity: clamp(q * 2),
|
| 416 |
+
padding: 26,
|
| 417 |
+
}}
|
| 418 |
+
>
|
| 419 |
+
{top && (
|
| 420 |
+
<>
|
| 421 |
+
<div style={mono(14, C.gold, 700, 3)}>{f.en}</div>
|
| 422 |
+
<div style={{ ...serif(P ? 34 : 30, C.ink, 900), marginTop: 14 }}>{f.t}</div>
|
| 423 |
+
<div style={{ display: 'flex', alignItems: 'baseline', gap: 6, marginTop: 10 }}>
|
| 424 |
+
<div style={txtStyle({ f: 'num', size: P ? 54 : 50, w: 800, color: C.goldHi })}>{f.pages}</div>
|
| 425 |
+
<div style={cn(22, 700, C.mute)}>页</div>
|
| 426 |
+
</div>
|
| 427 |
+
</>
|
| 428 |
+
)}
|
| 429 |
+
{Array.from({ length: top ? 6 : 10 }, (_, j) => (
|
| 430 |
+
<div key={j} style={{ height: 6, borderRadius: 3, marginTop: j === 0 ? 18 : 16, width: `${60 + rand(fi * 97 + i * 13 + j, 2) * 38}%`, background: 'rgba(243,238,228,0.13)' }} />
|
| 431 |
+
))}
|
| 432 |
+
</div>
|
| 433 |
+
)
|
| 434 |
+
}),
|
| 435 |
+
)}
|
| 436 |
+
{/* 阅读扫描光 */}
|
| 437 |
+
{(() => {
|
| 438 |
+
const q = tw(S.lt(0), 2.2, 2.6, E.inOut)
|
| 439 |
+
if (q <= 0 || q >= 1) return null
|
| 440 |
+
const x0 = P ? W / 2 - 350 : 200
|
| 441 |
+
const x1 = P ? W / 2 + 350 : 820
|
| 442 |
+
const x = lerp(x0, x1, q)
|
| 443 |
+
return <div style={{ position: 'absolute', left: x - 2, top: P ? 390 : 380, width: 4, height: P ? 420 : 420, background: `linear-gradient(180deg, transparent, ${CLAWD_ORANGE}, transparent)`, boxShadow: `0 0 30px ${CLAWD_ORANGE}`, opacity: Math.sin(q * Math.PI) }} />
|
| 444 |
+
})()}
|
| 445 |
+
</Beat>
|
| 446 |
+
<Beat k={0} to={2} d={0.2} x={P ? M : 1000} y={P ? 880 : 290} w={P ? W - M * 2 : 800}>
|
| 447 |
+
<Tag text="READ BY" p={p(0, 0.2)} color={CLAWD_ORANGE} />
|
| 448 |
+
<T p={p(0, 0.4)} style={{ display: 'flex', alignItems: 'center', gap: 22, marginTop: 18 }}>
|
| 449 |
+
<Clawd w={P ? 104 : 96} t={S.u} />
|
| 450 |
+
<div style={{ ...txtStyle({ f: 'num', size: P ? 60 : 56, w: 800, color: '#F3A283', ls: -1 }) }}>Claude Opus 5.5</div>
|
| 451 |
+
</T>
|
| 452 |
+
<T p={p(0, 1.2)} style={{ ...cn(P ? 34 : 32, 700, C.ink2), marginTop: 18 }}>
|
| 453 |
+
通读两个文件:天涯原帖 + 整理合集
|
| 454 |
+
</T>
|
| 455 |
+
<div style={{ height: 1, background: C.hair, margin: P ? '34px 0 22px' : '30px 0 18px', opacity: p(1, 0) }} />
|
| 456 |
+
<div style={{ display: 'flex', alignItems: 'flex-end', gap: P ? 30 : 34, flexWrap: 'wrap', opacity: clamp(p(1, 0, 0.5) * 1.5) }}>
|
| 457 |
+
<Big v="986" p={p(1, 0.1, 2)} size={P ? 160 : 170} unit="页" />
|
| 458 |
+
<T p={p(1, 0.9)} style={{ paddingBottom: P ? 30 : 26 }}>
|
| 459 |
+
<div style={mono(P ? 22 : 20, C.dim, 600, 2)}>480 + 506</div>
|
| 460 |
+
<div style={{ ...cn(P ? 26 : 24, 600, C.mute), marginTop: 6 }}>原帖 + 合集</div>
|
| 461 |
+
</T>
|
| 462 |
+
</div>
|
| 463 |
+
<T p={p(1, 2.6)} style={{ display: 'flex', alignItems: 'baseline', gap: 10, marginTop: 8 }}>
|
| 464 |
+
<div style={cn(P ? 34 : 32, 700, C.ink2)}>约</div>
|
| 465 |
+
<div style={{ ...txtStyle({ f: 'num', size: P ? 76 : 76, w: 800 }), ...goldText() }}>54</div>
|
| 466 |
+
<div style={cn(P ? 34 : 32, 700, C.ink2)}>万字 · 逐页通读</div>
|
| 467 |
+
</T>
|
| 468 |
+
</Beat>
|
| 469 |
+
|
| 470 |
+
{/* 7–8:点阵 */}
|
| 471 |
+
{dv > 0.001 && (
|
| 472 |
+
<div style={{ position: 'absolute', inset: 0, opacity: dv }}>
|
| 473 |
+
<svg width={S.W} height={S.H} style={{ position: 'absolute', left: 0, top: 0 }}>
|
| 474 |
+
<defs>
|
| 475 |
+
<linearGradient id="scan" x1="0" y1="0" x2="1" y2="0">
|
| 476 |
+
<stop offset="0" stopColor={C.goldHi} stopOpacity={0} />
|
| 477 |
+
<stop offset="0.85" stopColor={C.goldHi} stopOpacity={0.35} />
|
| 478 |
+
<stop offset="1" stopColor="#FFFFFF" stopOpacity={0.9} />
|
| 479 |
+
</linearGradient>
|
| 480 |
+
</defs>
|
| 481 |
+
{ID_SORT.map((r, i) => {
|
| 482 |
+
const cx = ox + (i % cols) * gx + gx / 2
|
| 483 |
+
const cy = oy + Math.floor(i / cols) * gy + gy / 2
|
| 484 |
+
const q = spr(S.lt(2) - 0.4 - (i % cols) * 0.02 - Math.floor(i / cols) * 0.05, { k: 14, z: 0.55 })
|
| 485 |
+
const scanned = S.lt(3) > 0 && scanX > cx
|
| 486 |
+
const col = scanned ? STATUS_COLOR[r.status] : C.gold
|
| 487 |
+
const flash = scanned ? clamp(1 - (scanX - cx) / 90) : 0
|
| 488 |
+
return (
|
| 489 |
+
<g key={r.id} opacity={clamp(q * 2)}>
|
| 490 |
+
{flash > 0 && <circle cx={cx} cy={cy} r={14 * flash + 7} fill={col} opacity={0.3 * flash} />}
|
| 491 |
+
<circle cx={cx} cy={cy} r={Math.max(0, (P ? 11 : 10) * q)} fill={col} opacity={scanned ? 1 : 0.55} />
|
| 492 |
+
</g>
|
| 493 |
+
)
|
| 494 |
+
})}
|
| 495 |
+
{S.lt(3) > 1.2 && scanX < ox + cols * gx + 50 && <rect x={scanX - 140} y={oy - 20} width={140} height={Math.ceil(123 / cols) * gy + 40} fill="url(#scan)" />}
|
| 496 |
+
{S.lt(3) > 1.2 && scanX < ox + cols * gx + 50 && <rect x={scanX - 1} y={oy - 30} width={2} height={Math.ceil(123 / cols) * gy + 60} fill="#FFFFFF" />}
|
| 497 |
+
</svg>
|
| 498 |
+
<div style={{ position: 'absolute', left: ox, top: oy + Math.ceil(123 / cols) * gy + 22, ...mono(P ? 20 : 17, C.dim, 600, 3), opacity: p(2, 1.6) }}>
|
| 499 |
+
123 PREDICTIONS · 1 DOT = 1 CLAIM
|
| 500 |
+
</div>
|
| 501 |
+
<div style={{ position: 'absolute', left: ox + cols * gx - (P ? 330 : 300), top: oy + Math.ceil(123 / cols) * gy - (P ? 10 : 30) }}>
|
| 502 |
+
<Stamp text="已核对" sub="截至 2026 · 10" p={p(3, 4.6, 0.7, E.lin)} color={C.goldHi} size={P ? 64 : 60} rot={-8} />
|
| 503 |
+
</div>
|
| 504 |
+
</div>
|
| 505 |
+
)}
|
| 506 |
+
<Beat k={2} to={3} x={M} y={P ? 1060 : 330} w={P ? W - M * 2 : 720}>
|
| 507 |
+
<div style={{ display: 'flex', flexDirection: 'column', gap: P ? 26 : 40 }}>
|
| 508 |
+
<div>
|
| 509 |
+
<Tag text="CORE THEORIES" p={p(2, 0.2)} />
|
| 510 |
+
<Big v="43" p={p(2, 0.3, 1.6)} size={P ? 132 : 160} unit="条核心理论" style={{ marginTop: 6 }} />
|
| 511 |
+
</div>
|
| 512 |
+
<div>
|
| 513 |
+
<Tag text="CHECKABLE CALLS" p={p(2, 1.6)} />
|
| 514 |
+
<Big v="123" p={p(2, 1.7, 1.6)} size={P ? 132 : 160} unit="条可核对预测" color={C.goldHi} style={{ marginTop: 6 }} />
|
| 515 |
+
</div>
|
| 516 |
+
</div>
|
| 517 |
+
</Beat>
|
| 518 |
+
<Beat k={3} to={4} x={M} y={P ? 1040 : 300} w={P ? W - M * 2 : 700}>
|
| 519 |
+
<Tag text="CROSS-CHECKED AGAINST" p={p(3, 0.1)} />
|
| 520 |
+
<div style={{ marginTop: 22, display: P ? 'grid' : 'flex', gridTemplateColumns: '1fr 1fr', flexDirection: 'column', gap: P ? 18 : 16 }}>
|
| 521 |
+
{SOURCES.map((s, i) => {
|
| 522 |
+
const q = p(3, 0.4 + i * 0.35)
|
| 523 |
+
return (
|
| 524 |
+
<T key={s.en} p={q}>
|
| 525 |
+
<Card pad={P ? '20px 24px' : '18px 24px'} r={16}>
|
| 526 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
|
| 527 |
+
<Icon kind="ok" size={30} p={p(3, 1.6 + i * 0.6, 0.6)} color={C.green} />
|
| 528 |
+
<div style={{ flex: 1 }}>
|
| 529 |
+
<div style={{ display: 'flex', alignItems: 'baseline', gap: 12 }}>
|
| 530 |
+
<div style={cn(P ? 32 : 30, 800)}>{s.n}</div>
|
| 531 |
+
<div style={mono(16, C.gold, 700)}>{s.en}</div>
|
| 532 |
+
</div>
|
| 533 |
+
<div style={{ ...cn(P ? 22 : 21, 500, C.mute), marginTop: 6 }}>{s.d}</div>
|
| 534 |
+
</div>
|
| 535 |
+
</div>
|
| 536 |
+
</Card>
|
| 537 |
+
</T>
|
| 538 |
+
)
|
| 539 |
+
})}
|
| 540 |
+
</div>
|
| 541 |
+
</Beat>
|
| 542 |
+
|
| 543 |
+
{/* 9:四层标签 */}
|
| 544 |
+
<Beat k={4} x={M} y={P ? 400 : 290} w={W - M * 2}>
|
| 545 |
+
<T p={p(4, 0.1)} style={{ ...serif(P ? 52 : 50), marginBottom: P ? 34 : 30 }}>
|
| 546 |
+
不只判对错,每条再打四层标签
|
| 547 |
+
</T>
|
| 548 |
+
<div style={{ display: 'grid', gridTemplateColumns: P ? '1fr 1fr' : 'repeat(4, 1fr)', gap: P ? 24 : 28 }}>
|
| 549 |
+
{LAYERS.map((l, i) => {
|
| 550 |
+
const q = spr(S.lt(4) - 0.5 - i * 0.55, { k: 10, z: 0.7 })
|
| 551 |
+
return (
|
| 552 |
+
<div key={l.t} style={{ opacity: clamp(q * 2), transform: `translateY(${((1 - clamp(q)) * 80).toFixed(1)}px) rotate(${((1 - clamp(q)) * (i % 2 ? 4 : -4)).toFixed(2)}deg)` }}>
|
| 553 |
+
<Card pad={P ? 30 : 30} style={{ height: P ? 440 : 430 }} tint={i === 0 ? C.gold : undefined}>
|
| 554 |
+
<div style={{ ...txtStyle({ f: 'num', size: 72, w: 800, color: 'transparent', lh: 1 }), WebkitTextStroke: `1.5px ${hexA(C.gold, 0.8)}` }}>{`0${i + 1}`}</div>
|
| 555 |
+
<div style={{ ...serif(P ? 46 : 42), marginTop: 22 }}>{l.t}</div>
|
| 556 |
+
<div style={{ ...mono(16, C.gold, 700, 4), marginTop: 10 }}>{l.en}</div>
|
| 557 |
+
<div style={{ height: 1, background: C.hair, margin: '22px 0' }} />
|
| 558 |
+
{l.o.map((o, j) => (
|
| 559 |
+
<div key={o} style={{ display: 'flex', alignItems: 'center', gap: 12, marginTop: 14, opacity: p(4, 1.2 + i * 0.55 + j * 0.15) }}>
|
| 560 |
+
<div style={{ width: 8, height: 8, borderRadius: 2, background: [C.green, C.amber, C.red][j], transform: 'rotate(45deg)' }} />
|
| 561 |
+
<div style={cn(P ? 27 : 25, 600, C.ink2)}>{o}</div>
|
| 562 |
+
</div>
|
| 563 |
+
))}
|
| 564 |
+
</Card>
|
| 565 |
+
</div>
|
| 566 |
+
)
|
| 567 |
+
})}
|
| 568 |
+
</div>
|
| 569 |
+
</Beat>
|
| 570 |
+
</>
|
| 571 |
+
)
|
| 572 |
+
}
|
| 573 |
+
|
| 574 |
+
// ================= 总成绩 =================
|
| 575 |
+
const ORDER = ['correct', 'wrong', 'disputed', 'pending']
|
| 576 |
+
const grp = (s: string) => (s.startsWith('pending') ? 3 : ORDER.indexOf(s))
|
| 577 |
+
const CL = [
|
| 578 |
+
{ label: '说对', n: all.correct, color: C.green },
|
| 579 |
+
{ label: '说错', n: all.wrong, color: C.red },
|
| 580 |
+
{ label: '对错参半', n: all.disputed, color: C.amber },
|
| 581 |
+
{ label: '未到期', n: 10, color: C.blue },
|
| 582 |
+
]
|
| 583 |
+
const DOTS = (() => {
|
| 584 |
+
const cnt = [0, 0, 0, 0]
|
| 585 |
+
return ID_SORT.map((r, i) => {
|
| 586 |
+
const g = grp(r.status)
|
| 587 |
+
return { i, g, k: cnt[g]++, color: g === 3 ? C.blue : STATUS_COLOR[r.status] }
|
| 588 |
+
})
|
| 589 |
+
})()
|
| 590 |
+
const SUBS = [
|
| 591 |
+
{ parent: '说对', n: all.correct, color: C.green, items: [['E', '精准命中'], ['D', '方向命中'], ['T', '顺势命中']] },
|
| 592 |
+
{ parent: '说错', n: all.wrong, color: C.red, items: [['R', '方向判反'], ['M', '幅度高估'], ['S', '时点过早'], ['A', '绝对化被证伪']] },
|
| 593 |
+
{ parent: '对错参半', n: all.disputed, color: C.amber, items: [['H', '一半对一半错'], ['W', '随时间翻转'], ['V', '表述模糊'], ['C', '口径不足']] },
|
| 594 |
+
]
|
| 595 |
+
const subN = (k: string) => subCounts.find((x) => x.k === k)?.n ?? 0
|
| 596 |
+
/** 子类条形图统一按最大值归一,保证最长的一根恰好满格 */
|
| 597 |
+
const SUB_MAX = Math.max(1, ...SUBS.flatMap((g) => g.items.map(([k]) => subN(k))))
|
| 598 |
+
const topicHit = (ts: string[]) => {
|
| 599 |
+
const r = rateOf(rows.filter((x) => ts.includes(x.topic)))
|
| 600 |
+
return { hit: pct(r.hit), n: r.n }
|
| 601 |
+
}
|
| 602 |
+
const FIELDS = [
|
| 603 |
+
{ no: '04', t: '房价', s: 'BIS 房价指数', ...topicHit(['房价走势']) },
|
| 604 |
+
{ no: '05', t: '城市', s: '23 座城市点名', ...topicHit(['北京与一线', '二三线与城市']) },
|
| 605 |
+
{ no: '06', t: '货币', s: 'M2 · CPI · 汇率', ...topicHit(['通胀与货币', '人民币汇率']) },
|
| 606 |
+
{ no: '07', t: '政策', s: '限购 · 房产税 · 产权', ...topicHit(['调控与房产税']) },
|
| 607 |
+
{ no: '10', t: '盲区', s: '租金 · 人口 · 利率', ...topicHit(['租金与保障房', '社会与人口']) },
|
| 608 |
+
]
|
| 609 |
+
const METHODS = [
|
| 610 |
+
{ l: '只算能分对错的', d: '51 ÷ 81', v: pct(all.hit), hi: true },
|
| 611 |
+
{ l: '存疑全算错', d: '51 ÷ 113', v: pct(all.correct / all.n) },
|
| 612 |
+
{ l: '存疑算半对', d: '(51 + 16) ÷ 113', v: pct(all.partial) },
|
| 613 |
+
{ l: '按难度和证据加权', d: '具体度 × 逆共识 × 证据', v: pct(weighted) },
|
| 614 |
+
]
|
| 615 |
+
|
| 616 |
+
export function Score() {
|
| 617 |
+
const S = useS()
|
| 618 |
+
const { P, W, H, M } = S
|
| 619 |
+
const p = useP()
|
| 620 |
+
const vis = useVis()
|
| 621 |
+
const dv = vis(0, 1)
|
| 622 |
+
// 簇布局
|
| 623 |
+
const cc = 8
|
| 624 |
+
const sp = P ? 34 : 30
|
| 625 |
+
const centers = P
|
| 626 |
+
? [
|
| 627 |
+
[M + 230, 560],
|
| 628 |
+
[M + 690, 560],
|
| 629 |
+
[M + 230, 1080],
|
| 630 |
+
[M + 690, 1080],
|
| 631 |
+
]
|
| 632 |
+
: [
|
| 633 |
+
[M + 205, 470],
|
| 634 |
+
[M + 615, 470],
|
| 635 |
+
[M + 1025, 470],
|
| 636 |
+
[M + 1435, 470],
|
| 637 |
+
]
|
| 638 |
+
return (
|
| 639 |
+
<>
|
| 640 |
+
{/* 9:分簇 */}
|
| 641 |
+
{dv > 0.001 && (
|
| 642 |
+
<div style={{ position: 'absolute', inset: 0, opacity: dv }}>
|
| 643 |
+
<svg width={W} height={H} style={{ position: 'absolute', left: 0, top: 0 }}>
|
| 644 |
+
{DOTS.map((d) => {
|
| 645 |
+
const q = spr(S.lt(0) - 0.2 - rand(d.i, 7) * 0.9, { k: 8, z: 0.75 })
|
| 646 |
+
const [cx, cy] = centers[d.g]
|
| 647 |
+
const tx = cx - ((cc - 1) * sp) / 2 + (d.k % cc) * sp
|
| 648 |
+
const ty = cy + Math.floor(d.k / cc) * sp
|
| 649 |
+
const sx0 = rand(d.i, 1) * W
|
| 650 |
+
const sy0 = rand(d.i, 2) * H
|
| 651 |
+
const x = lerp(sx0, tx, q)
|
| 652 |
+
const y = lerp(sy0, ty, q)
|
| 653 |
+
return <circle key={d.i} cx={x} cy={y} r={P ? 11 : 10} fill={d.color} opacity={clamp(S.lt(0) * 2) * (0.5 + 0.5 * clamp(q))} />
|
| 654 |
+
})}
|
| 655 |
+
</svg>
|
| 656 |
+
{CL.map((c, i) => {
|
| 657 |
+
const [cx, cy] = centers[i]
|
| 658 |
+
const q = p(0, 1.0 + i * 0.9, 1.4)
|
| 659 |
+
return (
|
| 660 |
+
<div key={c.label} style={{ position: 'absolute', left: cx - ((cc - 1) * sp) / 2 - 10, top: cy - (P ? 170 : 175), opacity: clamp(q * 2) }}>
|
| 661 |
+
<Big v={String(c.n)} p={q} size={P ? 100 : 96} color={c.color} />
|
| 662 |
+
<div style={{ ...cn(P ? 30 : 28, 800, C.ink), marginTop: -4 }}>{c.label}</div>
|
| 663 |
+
</div>
|
| 664 |
+
)
|
| 665 |
+
})}
|
| 666 |
+
</div>
|
| 667 |
+
)}
|
| 668 |
+
|
| 669 |
+
{/* 10:63% 环 */}
|
| 670 |
+
<Beat k={1} to={2} x={P ? (W - 560) / 2 : M + 40} y={P ? 400 : 290} w={P ? 560 : 540} h={P ? 560 : 540}>
|
| 671 |
+
<Ring size={P ? 560 : 540} stroke={P ? 34 : 32} segs={[{ v: all.correct, color: C.green }, { v: all.wrong, color: C.red }]} p={p(1, 0.2, 2.2)} />
|
| 672 |
+
<div style={{ position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}>
|
| 673 |
+
<Big v={String(pct(all.hit))} p={p(1, 0.3, 2)} size={P ? 200 : 190} unit="%" />
|
| 674 |
+
<div style={{ ...mono(P ? 20 : 18, C.mute, 600, 4), opacity: p(1, 1.6) }}>HIT RATE</div>
|
| 675 |
+
</div>
|
| 676 |
+
</Beat>
|
| 677 |
+
<Beat k={1} to={2} d={0.6} x={P ? M : 820} y={P ? 1040 : 360} w={P ? W - M * 2 : 960}>
|
| 678 |
+
<Tag text="ONLY RESOLVED CALLS" p={p(1, 0.6)} />
|
| 679 |
+
<T p={p(1, 0.9)} style={{ ...serif(P ? 54 : 58), marginTop: 18 }}>
|
| 680 |
+
只算能分出对错的 81 条
|
| 681 |
+
</T>
|
| 682 |
+
<T p={p(1, 1.8)} style={{ display: 'flex', alignItems: 'center', gap: 18, marginTop: 34, flexWrap: 'wrap' }}>
|
| 683 |
+
<span style={txtStyle({ f: 'num', size: P ? 60 : 64, w: 800, color: C.green })}>51</span>
|
| 684 |
+
<span style={cn(P ? 30 : 28, 600, C.mute)}>说对</span>
|
| 685 |
+
<span style={txtStyle({ f: 'num', size: 54, w: 300, color: C.dim })}>÷</span>
|
| 686 |
+
<span style={txtStyle({ f: 'num', size: P ? 60 : 64, w: 800, color: C.ink })}>81</span>
|
| 687 |
+
<span style={txtStyle({ f: 'num', size: 54, w: 300, color: C.dim })}>=</span>
|
| 688 |
+
<span style={{ ...txtStyle({ f: 'num', size: P ? 60 : 64, w: 800 }), ...goldText() }}>63%</span>
|
| 689 |
+
</T>
|
| 690 |
+
<T p={p(1, 2.8)} style={{ ...cn(P ? 26 : 25, 500, C.dim), marginTop: 22 }}>
|
| 691 |
+
32 条对错参半、10 条未到期,暂不计入
|
| 692 |
+
</T>
|
| 693 |
+
</Beat>
|
| 694 |
+
|
| 695 |
+
{/* 11:四种口径 */}
|
| 696 |
+
<Beat k={2} to={3} x={M} y={P ? 400 : 280} w={W - M * 2}>
|
| 697 |
+
<T p={p(2, 0)} style={{ ...serif(P ? 52 : 50), marginBottom: P ? 40 : 30 }}>
|
| 698 |
+
口径一换,结论就变
|
| 699 |
+
</T>
|
| 700 |
+
{METHODS.map((m, i) => {
|
| 701 |
+
const q = p(2, i === 0 ? 0.3 : [0, 2.2, 4.4, 6.6][i] - 0.2, 1.4)
|
| 702 |
+
const bw = P ? W - M * 2 : 980
|
| 703 |
+
return (
|
| 704 |
+
<div key={m.l} style={{ display: 'flex', flexDirection: P ? 'column' : 'row', alignItems: P ? 'stretch' : 'center', gap: P ? 12 : 34, marginTop: P ? 30 : 22, opacity: clamp(q * 2) * (i === 0 || S.lt(2) < 8.5 ? 1 : 1) }}>
|
| 705 |
+
<div style={{ width: P ? undefined : 420, flex: 'none' }}>
|
| 706 |
+
<div style={cn(P ? 34 : 32, 800, m.hi ? C.goldHi : C.ink)}>{m.l}</div>
|
| 707 |
+
<div style={{ ...mono(P ? 18 : 17, C.dim, 500, 1), marginTop: 6 }}>{m.d}</div>
|
| 708 |
+
</div>
|
| 709 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 24, flex: 1 }}>
|
| 710 |
+
<div style={{ position: 'relative', width: P ? bw - 180 : bw, height: P ? 30 : 34, borderRadius: 8, background: 'rgba(243,238,228,0.06)' }}>
|
| 711 |
+
<div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: `${m.v * E.out(q)}%`, borderRadius: 8, background: m.hi ? `linear-gradient(90deg, ${C.goldDeep}, ${C.goldHi})` : `linear-gradient(90deg, rgba(243,238,228,0.15), rgba(243,238,228,0.65))`, boxShadow: m.hi ? `0 0 30px ${hexA(C.gold, 0.4)}` : undefined }} />
|
| 712 |
+
<div style={{ position: 'absolute', left: '50%', top: -8, bottom: -8, width: 1, background: 'rgba(243,238,228,0.25)' }} />
|
| 713 |
+
</div>
|
| 714 |
+
<Big v={`${m.v}%`} p={q} size={P ? 64 : 60} color={m.hi ? C.goldHi : C.ink} />
|
| 715 |
+
</div>
|
| 716 |
+
</div>
|
| 717 |
+
)
|
| 718 |
+
})}
|
| 719 |
+
<T p={p(2, 8.4)} style={{ ...mono(P ? 18 : 17, C.dim, 500, 2), marginTop: 26, marginLeft: P ? 0 : 454 }}>
|
| 720 |
+
中线 = 50%,抛硬币水平
|
| 721 |
+
</T>
|
| 722 |
+
</Beat>
|
| 723 |
+
|
| 724 |
+
{/* 12:细分 */}
|
| 725 |
+
<Beat k={3} to={4} x={M} y={P ? 400 : 280} w={W - M * 2}>
|
| 726 |
+
<T p={p(3, 0)} style={{ ...serif(P ? 50 : 50), marginBottom: P ? 30 : 30 }}>
|
| 727 |
+
看他在哪里准、在哪里不准
|
| 728 |
+
</T>
|
| 729 |
+
<div style={{ display: 'grid', gridTemplateColumns: P ? '1fr' : '1fr 1fr 1fr', gap: P ? 20 : 28 }}>
|
| 730 |
+
{SUBS.map((g, gi) => (
|
| 731 |
+
<T key={g.parent} p={p(3, 0.4 + gi * 0.4)}>
|
| 732 |
+
<Card tint={g.color} pad={P ? '22px 28px' : 28} style={{ height: P ? undefined : 470 }}>
|
| 733 |
+
<div style={{ display: 'flex', alignItems: 'baseline', gap: 14 }}>
|
| 734 |
+
<Dot color={g.color} size={14} />
|
| 735 |
+
<div style={cn(P ? 34 : 34, 900)}>{g.parent}</div>
|
| 736 |
+
<div style={{ flex: 1 }} />
|
| 737 |
+
<div style={txtStyle({ f: 'num', size: P ? 48 : 54, w: 800, color: g.color })}>{g.n}</div>
|
| 738 |
+
</div>
|
| 739 |
+
<div style={{ display: P ? 'grid' : 'block', gridTemplateColumns: '1fr 1fr', columnGap: 30 }}>
|
| 740 |
+
{g.items.map(([k, l], j) => {
|
| 741 |
+
const n = subN(k)
|
| 742 |
+
const q = p(3, 1.0 + gi * 0.4 + j * 0.18, 1.2)
|
| 743 |
+
const hot = k === 'R'
|
| 744 |
+
return (
|
| 745 |
+
<div key={k} style={{ marginTop: P ? 14 : 26 }}>
|
| 746 |
+
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline' }}>
|
| 747 |
+
<div style={cn(P ? 24 : 25, hot ? 900 : 600, hot ? C.ink : C.ink2)}>{l}</div>
|
| 748 |
+
<div style={txtStyle({ f: 'num', size: P ? 28 : 32, w: 800, color: hot ? C.red : C.ink })}>{Math.round(n * clamp(q * 1.2))}</div>
|
| 749 |
+
</div>
|
| 750 |
+
<div style={{ height: 8, borderRadius: 4, background: 'rgba(243,238,228,0.06)', marginTop: 8 }}>
|
| 751 |
+
<div style={{ height: 8, borderRadius: 4, width: `${(n / SUB_MAX) * 100 * E.out(q)}%`, background: g.color, boxShadow: hot ? `0 0 18px ${C.red}` : undefined, opacity: hot ? 1 : 0.75 }} />
|
| 752 |
+
</div>
|
| 753 |
+
</div>
|
| 754 |
+
)
|
| 755 |
+
})}
|
| 756 |
+
</div>
|
| 757 |
+
</Card>
|
| 758 |
+
</T>
|
| 759 |
+
))}
|
| 760 |
+
</div>
|
| 761 |
+
</Beat>
|
| 762 |
+
|
| 763 |
+
{/* 13:五个战场 */}
|
| 764 |
+
<Beat k={4} x={M} y={P ? 400 : 290} w={W - M * 2}>
|
| 765 |
+
<T p={p(4, 0)} style={{ ...serif(P ? 50 : 50), marginBottom: P ? 30 : 34 }}>
|
| 766 |
+
分五个战场,逐一拆开
|
| 767 |
+
</T>
|
| 768 |
+
<div style={{ display: 'grid', gridTemplateColumns: P ? '1fr' : 'repeat(5, 1fr)', gap: P ? 18 : 26 }}>
|
| 769 |
+
{FIELDS.map((f, i) => {
|
| 770 |
+
const q = spr(S.lt(4) - 0.6 - i * 0.32, { k: 11, z: 0.7 })
|
| 771 |
+
const qa = p(4, 0.9 + i * 0.32, 1.5)
|
| 772 |
+
const col = f.hit >= 70 ? C.green : f.hit >= 50 ? C.amber : C.red
|
| 773 |
+
return (
|
| 774 |
+
<div key={f.no} style={{ opacity: clamp(q * 2), transform: `translate${P ? 'X' : 'Y'}(${((1 - clamp(q)) * 90).toFixed(1)}px)` }}>
|
| 775 |
+
<Card pad={P ? '18px 28px' : 28} style={{ height: P ? 156 : 420, display: 'flex', flexDirection: P ? 'row' : 'column', alignItems: P ? 'center' : 'stretch', gap: P ? 28 : 0 }}>
|
| 776 |
+
<div style={{ ...mono(P ? 22 : 20, C.gold, 700, 3) }}>{f.no}</div>
|
| 777 |
+
<div style={{ marginTop: P ? 0 : 18, width: P ? 250 : undefined }}>
|
| 778 |
+
<div style={serif(P ? 50 : 54)}>{f.t}</div>
|
| 779 |
+
<div style={{ ...cn(P ? 21 : 21, 500, C.mute), marginTop: 8 }}>{f.s}</div>
|
| 780 |
+
</div>
|
| 781 |
+
<div style={{ flex: 1 }} />
|
| 782 |
+
<div style={{ width: P ? 340 : undefined }}>
|
| 783 |
+
<Big v={String(f.hit)} p={qa} size={P ? 72 : 80} unit="%" color={col} unitColor={col} />
|
| 784 |
+
<div style={{ height: 6, borderRadius: 3, background: 'rgba(243,238,228,0.07)', marginTop: 12 }}>
|
| 785 |
+
<div style={{ height: 6, borderRadius: 3, width: `${f.hit * E.out(qa)}%`, background: col, boxShadow: `0 0 16px ${hexA(col, 0.6)}` }} />
|
| 786 |
+
</div>
|
| 787 |
+
<div style={{ ...mono(15, C.dim, 500, 2), marginTop: 10 }}>{`${f.n} CALLS · HIT RATE`}</div>
|
| 788 |
+
</div>
|
| 789 |
+
</Card>
|
| 790 |
+
</div>
|
| 791 |
+
)
|
| 792 |
+
})}
|
| 793 |
+
</div>
|
| 794 |
+
</Beat>
|
| 795 |
+
</>
|
| 796 |
+
)
|
| 797 |
+
}
|
| 798 |
+
|
| 799 |
+
export { byTopic }
|
| 800 |
+
|
| 801 |
+
/** “狂飙”上升图标:柱子逐根长高 + 上扬曲线描出 + 渐变面积 + 箭头与光点 */
|
| 802 |
+
function RiseIcon({ w, h, p }: { w: number; h: number; p: number }) {
|
| 803 |
+
const uid = 'ri' + React.useId().replace(/[^a-zA-Z0-9]/g, '')
|
| 804 |
+
const seg = (a: number, b: number) => E.inOut(clamp((p - a) / (b - a)))
|
| 805 |
+
const bars = [30, 46, 70, 104]
|
| 806 |
+
const line = 'M12 132 C30 128 36 112 50 110 S70 104 80 82 S96 40 108 26'
|
| 807 |
+
const lq = seg(0.25, 0.85)
|
| 808 |
+
const hq = seg(0.8, 1)
|
| 809 |
+
// 箭头沿末段方向(约 -62°)
|
| 810 |
+
const ang = Math.atan2(26 - 40, 108 - 101)
|
| 811 |
+
const wing = (s: number) => `${(108 - 18 * Math.cos(ang + s * 0.5)).toFixed(1)} ${(26 - 18 * Math.sin(ang + s * 0.5)).toFixed(1)}`
|
| 812 |
+
return (
|
| 813 |
+
<svg width={w} height={h} viewBox="0 0 120 160" style={{ display: 'block', overflow: 'visible', marginBottom: 18, opacity: clamp(p * 4) }}>
|
| 814 |
+
<defs>
|
| 815 |
+
<linearGradient id={`${uid}b`} x1="0" y1="0" x2="0" y2="1">
|
| 816 |
+
<stop offset="0" stopColor={C.red} stopOpacity={0.55} />
|
| 817 |
+
<stop offset="1" stopColor={C.red} stopOpacity={0.08} />
|
| 818 |
+
</linearGradient>
|
| 819 |
+
<linearGradient id={`${uid}a`} x1="0" y1="0" x2="0" y2="1">
|
| 820 |
+
<stop offset="0" stopColor={C.red} stopOpacity={0.3} />
|
| 821 |
+
<stop offset="1" stopColor={C.red} stopOpacity={0} />
|
| 822 |
+
</linearGradient>
|
| 823 |
+
</defs>
|
| 824 |
+
<path d="M4 150 L116 150" stroke={C.faint} strokeWidth={2} strokeLinecap="round" />
|
| 825 |
+
{bars.map((bh, i) => {
|
| 826 |
+
const q = E.out(clamp((p - i * 0.07) / 0.35))
|
| 827 |
+
const hh = bh * q
|
| 828 |
+
return <rect key={i} x={10 + i * 27} y={148 - hh} width={16} height={hh} rx={3} fill={`url(#${uid}b)`} />
|
| 829 |
+
})}
|
| 830 |
+
<path d={`${line} L108 148 L12 148 Z`} fill={`url(#${uid}a)`} opacity={seg(0.6, 1)} />
|
| 831 |
+
<path d={line} stroke={hexA(C.red, 0.28)} strokeWidth={15} fill="none" strokeLinecap="round" strokeLinejoin="round" pathLength={1} strokeDasharray={1} strokeDashoffset={1 - lq} />
|
| 832 |
+
<path d={line} stroke={C.red} strokeWidth={7} fill="none" strokeLinecap="round" strokeLinejoin="round" pathLength={1} strokeDasharray={1} strokeDashoffset={1 - lq} />
|
| 833 |
+
{hq > 0.01 && (
|
| 834 |
+
<g opacity={hq}>
|
| 835 |
+
<path d={`M${wing(1)} L108 26 L${wing(-1)}`} stroke={C.red} strokeWidth={7} fill="none" strokeLinecap="round" strokeLinejoin="round" />
|
| 836 |
+
<circle cx={108} cy={26} r={14 * hq} fill={hexA(C.red, 0.2)} />
|
| 837 |
+
</g>
|
| 838 |
+
)}
|
| 839 |
+
</svg>
|
| 840 |
+
)
|
| 841 |
+
}
|
kkndme/frontend/src/rv/scenesB.tsx
ADDED
|
@@ -0,0 +1,963 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
| 4 |
+
import { useS } from './ctx'
|
| 5 |
+
import { Chip, txtStyle, goldText, Icon } from './ui'
|
| 6 |
+
import { Beat, Big, Card, Quote, T, Tag, Ring, cn, mono, serif, useP, useVis, Dot } from './kit'
|
| 7 |
+
import { Grid, Series, SvgDot, linePath, smoothPath, sx, sy, svgText, type Fr } from './charts'
|
| 8 |
+
import { BIS_NOM, BIS_REAL, qYear, M2_IDX, CPI_IDX, HOUSE_IDX, FX, mYear, CITIES } from '../video/series'
|
| 9 |
+
import { byTopic, byType } from '../data/science'
|
| 10 |
+
|
| 11 |
+
const pct = (v: number) => Math.round(v * 100)
|
| 12 |
+
|
| 13 |
+
/** 左文右图(横屏)/ 上图下文(竖屏)的布局 */
|
| 14 |
+
function useLay() {
|
| 15 |
+
const S = useS()
|
| 16 |
+
return S.P
|
| 17 |
+
? { chart: { x: 170, y: 440, w: 800, h: 450 }, panel: { x: S.M, y: 1010, w: S.W - S.M * 2 } }
|
| 18 |
+
: { chart: { x: 900, y: 300, w: 840, h: 500 }, panel: { x: S.M, y: 300, w: 640 } }
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
// ================= 房价 =================
|
| 22 |
+
const NOM: [number, number][] = BIS_NOM.map((v, i) => [qYear(i), v])
|
| 23 |
+
const REAL: [number, number][] = BIS_REAL.map((v, i) => [qYear(i), v])
|
| 24 |
+
const PEAK_I = BIS_NOM.indexOf(Math.max(...BIS_NOM))
|
| 25 |
+
const priceR = byTopic.find((x) => x.k === '房价走势')!.r
|
| 26 |
+
|
| 27 |
+
export function Price() {
|
| 28 |
+
const S = useS()
|
| 29 |
+
const { P, W, H } = S
|
| 30 |
+
const p = useP()
|
| 31 |
+
const vis = useVis()
|
| 32 |
+
const L = useLay()
|
| 33 |
+
const cone = tw(S.lt(1), 0.4, 1.4, E.inOut) * (1 - tw(S.lt(2), -0.4, 1.2, E.inOut))
|
| 34 |
+
const f: Fr = { ...L.chart, x0: 2010, x1: 2026.6, y0: 70, y1: lerp(160, 220, cone) }
|
| 35 |
+
const draw = p(0, 0.8, 3.6, E.soft)
|
| 36 |
+
const realP = p(4, 0.4, 3.2, E.soft)
|
| 37 |
+
const chartA = vis(0) * (1 - 0.6 * p(5, 0, 0.8))
|
| 38 |
+
const peakP = p(3, 0.3, 0.9)
|
| 39 |
+
const dropP = p(3, 1.6, 1.4)
|
| 40 |
+
const yt = cone > 0.3 ? [80, 100, 120, 140, 160, 180, 200] : [80, 100, 120, 140, 160]
|
| 41 |
+
const pk: [number, number] = NOM[PEAK_I]
|
| 42 |
+
const last = NOM[NOM.length - 1]
|
| 43 |
+
const lastR = REAL[REAL.length - 1]
|
| 44 |
+
const fs = P ? 22 : 20
|
| 45 |
+
return (
|
| 46 |
+
<>
|
| 47 |
+
<svg width={W} height={H} style={{ position: 'absolute', left: 0, top: 0, opacity: chartA }}>
|
| 48 |
+
<Grid f={f} yt={yt} xt={[2010, 2014, 2018, 2022, 2026]} p={p(0, 0.2, 1.4)} size={fs} />
|
| 49 |
+
{/* 2010 = 100 基准线 */}
|
| 50 |
+
<line x1={f.x} x2={f.x + f.w} y1={sy(f, 100)} y2={sy(f, 100)} stroke={hexA(C.gold, 0.35)} strokeDasharray="2 6" opacity={p(0, 1.2)} />
|
| 51 |
+
{/* kkndme 预言锥 */}
|
| 52 |
+
{cone > 0.01 && (
|
| 53 |
+
<g opacity={cone}>
|
| 54 |
+
<rect x={sx(f, 2011)} y={f.y} width={sx(f, 2014) - sx(f, 2011)} height={f.h} fill={hexA(C.red, 0.06)} />
|
| 55 |
+
<path d={`M${sx(f, 2011)},${sy(f, 103.5)} L${sx(f, 2013.6)},${sy(f, 155)} L${sx(f, 2013.6)},${sy(f, 207)} Z`} fill={hexA(C.red, 0.18)} stroke={C.red} strokeWidth={2} strokeDasharray="7 6" />
|
| 56 |
+
<text x={sx(f, 2013.6) + 14} y={sy(f, 207) + 8} fill={C.red} style={svgText(fs + 2, 800, 'cn')}>
|
| 57 |
+
+100%
|
| 58 |
+
</text>
|
| 59 |
+
<text x={sx(f, 2013.6) + 14} y={sy(f, 155) + 8} fill={C.red} style={svgText(fs + 2, 800, 'cn')}>
|
| 60 |
+
+50%
|
| 61 |
+
</text>
|
| 62 |
+
<text x={sx(f, 2011)} y={f.y - 14} fill={C.red} style={svgText(fs, 700, 'cn')}>
|
| 63 |
+
KKndme 预言:2–3 年 +50%~100%
|
| 64 |
+
</text>
|
| 65 |
+
</g>
|
| 66 |
+
)}
|
| 67 |
+
<Series id="nom" d={smoothPath(f, NOM)} p={draw} color={C.gold} width={4} area={0.28} baseY={f.y + f.h} clipX={[f.x, f.x + f.w]} />
|
| 68 |
+
{realP > 0 && <Series id="real" d={smoothPath(f, REAL)} p={realP} color={C.sky} width={3.5} />}
|
| 69 |
+
{/* 峰值 */}
|
| 70 |
+
{peakP > 0 && (
|
| 71 |
+
<g>
|
| 72 |
+
<SvgDot id="pk" x={sx(f, pk[0])} y={sy(f, pk[1])} r={8} color={C.goldHi} o={peakP} pulse={(S.t * 0.8) % 1} />
|
| 73 |
+
<text x={sx(f, pk[0])} y={sy(f, pk[1]) - 28} textAnchor="middle" fill={C.goldHi} opacity={peakP} style={svgText(fs, 800, 'mono')}>
|
| 74 |
+
2021Q3 峰值
|
| 75 |
+
</text>
|
| 76 |
+
</g>
|
| 77 |
+
)}
|
| 78 |
+
{dropP > 0 && (
|
| 79 |
+
<g opacity={dropP * (1 - p(4, 0, 0.8) * 0.6)}>
|
| 80 |
+
<line x1={sx(f, pk[0])} x2={sx(f, last[0]) + 30} y1={sy(f, pk[1])} y2={sy(f, pk[1])} stroke={hexA(C.red, 0.7)} strokeDasharray="5 6" />
|
| 81 |
+
<line x1={sx(f, last[0]) + 30} x2={sx(f, last[0]) + 30} y1={sy(f, pk[1])} y2={lerp(sy(f, pk[1]), sy(f, last[1]), E.out(dropP))} stroke={C.red} strokeWidth={3} />
|
| 82 |
+
<text x={sx(f, last[0]) + 18} y={(sy(f, pk[1]) + sy(f, last[1])) / 2 + 10} textAnchor="end" fill={C.red} style={svgText(P ? 34 : 36, 800, 'num')}>
|
| 83 |
+
−21.9%
|
| 84 |
+
</text>
|
| 85 |
+
</g>
|
| 86 |
+
)}
|
| 87 |
+
{draw > 0.98 && (
|
| 88 |
+
<text x={sx(f, last[0]) + 12} y={sy(f, last[1]) + 8} fill={C.gold} opacity={p(0, 4.4)} style={svgText(fs, 800, 'mono')}>
|
| 89 |
+
{last[1].toFixed(0)}
|
| 90 |
+
</text>
|
| 91 |
+
)}
|
| 92 |
+
{realP > 0.98 && (
|
| 93 |
+
<g>
|
| 94 |
+
<SvgDot id="re" x={sx(f, lastR[0])} y={sy(f, lastR[1])} r={7} color={C.sky} o={1} />
|
| 95 |
+
<text x={sx(f, lastR[0]) - 14} y={sy(f, lastR[1]) + 40} textAnchor="end" fill={C.sky} style={svgText(fs + 2, 800, 'cn')}>
|
| 96 |
+
扣除通胀 85.1
|
| 97 |
+
</text>
|
| 98 |
+
</g>
|
| 99 |
+
)}
|
| 100 |
+
<text x={f.x} y={f.y + f.h + (P ? 76 : 70)} fill={C.dim} opacity={p(0, 1.4)} style={svgText(P ? 18 : 16, 500, 'mono')}>
|
| 101 |
+
BIS 中国住宅价格指数 · 2010=100 · 季度 · 2010Q1–2026Q1
|
| 102 |
+
</text>
|
| 103 |
+
</svg>
|
| 104 |
+
|
| 105 |
+
{/* 面板 */}
|
| 106 |
+
<Beat k={0} to={1} {...L.panel}>
|
| 107 |
+
<Tag text="BIS RESIDENTIAL PRICE INDEX" p={p(0, 0.1)} />
|
| 108 |
+
<T p={p(0, 0.4)} style={{ ...serif(P ? 60 : 62), marginTop: 20 }}>
|
| 109 |
+
国际清算银行
|
| 110 |
+
</T>
|
| 111 |
+
<T p={p(0, 0.7)} style={{ ...serif(P ? 44 : 44, C.ink2, 700), marginTop: 10 }}>
|
| 112 |
+
按统计局 70 城房价编制
|
| 113 |
+
</T>
|
| 114 |
+
<T p={p(0, 2.2)} style={{ ...cn(P ? 28 : 26, 500, C.mute), marginTop: 26 }}>
|
| 115 |
+
以 2010 年 = 100,看十五年走势
|
| 116 |
+
</T>
|
| 117 |
+
</Beat>
|
| 118 |
+
<Beat k={1} to={2} {...L.panel}>
|
| 119 |
+
<Quote text="“二三线及以下城市未来 2–3 年内经过 50%–100% 的涨幅”" t={S.lt(1) - 0.2} size={P ? 36 : 34} />
|
| 120 |
+
<T p={p(1, 4.0)} style={{ ...cn(P ? 26 : 24, 500, C.mute), marginTop: P ? 28 : 34 }}>
|
| 121 |
+
实际:2010 → 2013 全国住宅均价
|
| 122 |
+
</T>
|
| 123 |
+
<div style={{ display: 'flex', alignItems: 'baseline', gap: 22, marginTop: 6 }}>
|
| 124 |
+
<Big v="+24%" p={p(1, 4.4, 1.4)} size={P ? 110 : 110} color={C.goldHi} />
|
| 125 |
+
<T p={p(1, 5.2)} style={txtStyle({ f: 'num', size: P ? 28 : 26, w: 600, color: C.mute })}>
|
| 126 |
+
4,725 → 5,850 元/㎡
|
| 127 |
+
</T>
|
| 128 |
+
</div>
|
| 129 |
+
<div style={{ marginTop: 18 }}>
|
| 130 |
+
<Chip kind="no" text="说错 · 幅度高估" p={p(1, 6.2)} size={P ? 26 : 24} />
|
| 131 |
+
</div>
|
| 132 |
+
</Beat>
|
| 133 |
+
<Beat k={2} to={3} {...L.panel}>
|
| 134 |
+
<Quote text="“许多人心怀房价肯定会跌回 2004 年的美好愿望……”" t={S.lt(2) - 0.2} size={P ? 36 : 34} />
|
| 135 |
+
<div style={{ marginTop: P ? 30 : 40 }}>
|
| 136 |
+
{[
|
| 137 |
+
{ l: '2004 年', v: 2608, c: '#7C6E55' },
|
| 138 |
+
{ l: '2025 年', v: 10005, c: C.gold },
|
| 139 |
+
].map((b, i) => {
|
| 140 |
+
const q = p(2, 2.6 + i * 0.8, 1.3)
|
| 141 |
+
return (
|
| 142 |
+
<div key={b.l} style={{ display: 'flex', alignItems: 'center', gap: 18, marginTop: 16, opacity: clamp(q * 2) }}>
|
| 143 |
+
<div style={{ ...cn(P ? 26 : 24, 600, C.mute), width: 100 }}>{b.l}</div>
|
| 144 |
+
<div style={{ height: P ? 28 : 26, width: (P ? 560 : 380) * (b.v / 10005) * E.out(q), borderRadius: 6, background: `linear-gradient(90deg, ${hexA(b.c, 0.4)}, ${b.c})` }} />
|
| 145 |
+
<div style={txtStyle({ f: 'num', size: P ? 32 : 30, w: 800 })}>{fmt(Math.round(b.v * E.out(q)))}</div>
|
| 146 |
+
</div>
|
| 147 |
+
)
|
| 148 |
+
})}
|
| 149 |
+
</div>
|
| 150 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 24, marginTop: 26 }}>
|
| 151 |
+
<Big v="3.8×" p={p(2, 4.4, 1.2)} size={P ? 100 : 96} color={C.goldHi} />
|
| 152 |
+
<Chip kind="ok" text="至今成立" p={p(2, 5.4)} size={P ? 26 : 24} />
|
| 153 |
+
</div>
|
| 154 |
+
</Beat>
|
| 155 |
+
<Beat k={3} to={4} {...L.panel}>
|
| 156 |
+
<Quote text="“除非出现明末的极端事件……等房价大降真的不现实。”" t={S.lt(3) - 0.2} size={P ? 36 : 34} />
|
| 157 |
+
<T p={p(3, 2.4)} style={{ ...cn(P ? 26 : 24, 500, C.mute), marginTop: P ? 28 : 36 }}>
|
| 158 |
+
2021 年三季度见顶后,连跌四年半
|
| 159 |
+
</T>
|
| 160 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 24, marginTop: 6 }}>
|
| 161 |
+
<Big v="−22%" p={p(3, 2.8, 1.4)} size={P ? 120 : 120} color={C.red} />
|
| 162 |
+
<Chip kind="wait" text="未到期 · 还没跌到三成" p={p(3, 4.4)} size={P ? 24 : 22} />
|
| 163 |
+
</div>
|
| 164 |
+
</Beat>
|
| 165 |
+
<Beat k={4} to={5} {...L.panel}>
|
| 166 |
+
<Tag text="REAL TERMS · 扣除通胀" p={p(4, 0.1)} color={C.sky} />
|
| 167 |
+
<Big v="85.1" p={p(4, 0.5, 1.8)} size={P ? 150 : 160} color={'#BFD6F5'} style={{ marginTop: 10 }} />
|
| 168 |
+
<T p={p(4, 1.4)} style={{ ...cn(P ? 32 : 30, 800), marginTop: 4 }}>
|
| 169 |
+
实际房价指数
|
| 170 |
+
</T>
|
| 171 |
+
<T p={p(4, 3.0)} style={{ ...cn(P ? 28 : 26, 500, C.mute), marginTop: 12 }}>
|
| 172 |
+
比 2010 年低 15%;比峰值低 25%
|
| 173 |
+
</T>
|
| 174 |
+
<T p={p(4, 4.4)} style={{ ...serif(P ? 50 : 48, C.goldHi), marginTop: 26 }}>
|
| 175 |
+
房子跑输了物价
|
| 176 |
+
</T>
|
| 177 |
+
</Beat>
|
| 178 |
+
<Beat k={5} {...L.panel} y={P ? 1000 : 290}>
|
| 179 |
+
<Tag text="SCORE · 房价走势" p={p(5, 0.1)} />
|
| 180 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: P ? 50 : 40, marginTop: 24 }}>
|
| 181 |
+
<div style={{ position: 'relative', width: P ? 300 : 280, height: P ? 300 : 280, flex: 'none' }}>
|
| 182 |
+
<Ring size={P ? 300 : 280} stroke={22} segs={[{ v: priceR.correct, color: C.green }, { v: priceR.wrong, color: C.red }, { v: priceR.disputed, color: C.amber }]} p={p(5, 0.3, 1.8)} />
|
| 183 |
+
<div style={{ position: 'absolute', inset: 0, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
| 184 |
+
<Big v={String(pct(priceR.hit))} p={p(5, 0.4, 1.6)} size={100} unit="%" />
|
| 185 |
+
</div>
|
| 186 |
+
</div>
|
| 187 |
+
<div>
|
| 188 |
+
{[
|
| 189 |
+
['说对', priceR.correct, C.green],
|
| 190 |
+
['说错', priceR.wrong, C.red],
|
| 191 |
+
['参半', priceR.disputed, C.amber],
|
| 192 |
+
].map(([l, n, col], i) => (
|
| 193 |
+
<T key={l as string} p={p(5, 1.0 + i * 0.2)} style={{ display: 'flex', alignItems: 'center', gap: 14, marginTop: i ? 14 : 0 }}>
|
| 194 |
+
<Dot color={col as string} />
|
| 195 |
+
<div style={cn(30, 700)}>{`${l} ${n}`}</div>
|
| 196 |
+
</T>
|
| 197 |
+
))}
|
| 198 |
+
</div>
|
| 199 |
+
</div>
|
| 200 |
+
<T p={p(5, 2.4)} style={{ ...serif(P ? 40 : 38, C.goldHi), marginTop: 30 }}>
|
| 201 |
+
方向大体对,幅度和时点频频失手
|
| 202 |
+
</T>
|
| 203 |
+
</Beat>
|
| 204 |
+
</>
|
| 205 |
+
)
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
// ================= 城市 =================
|
| 209 |
+
const HL: Record<number, string[]> = {
|
| 210 |
+
0: [],
|
| 211 |
+
1: ['北京', '上海', '广佛', '深圳'],
|
| 212 |
+
2: ['上海', '合肥'],
|
| 213 |
+
3: ['燕郊', '乳山', '三亚'],
|
| 214 |
+
4: ['重庆', '昆明', '南宁'],
|
| 215 |
+
}
|
| 216 |
+
const cityType = byType.find((x) => x.k === 'city')!.r
|
| 217 |
+
|
| 218 |
+
export function Cities() {
|
| 219 |
+
const S = useS()
|
| 220 |
+
const { P, W, H, M } = S
|
| 221 |
+
const p = useP()
|
| 222 |
+
const vis = useVis()
|
| 223 |
+
const cur = [0, 1, 2, 3, 4, 5].reduce((a, i) => (S.lt(i) >= -0.3 ? i : a), 0)
|
| 224 |
+
const hl = HL[cur] ?? []
|
| 225 |
+
const pj = (lon: number, lat: number) => (P ? { x: 110 + (lon - 98) * 33, y: 420 + (42 - lat) * 23 } : { x: 960 + (lon - 98) * 30, y: 280 + (42 - lat) * 25 })
|
| 226 |
+
const mapA = vis(0) * (1 - 0.75 * p(5, -0.3, 0.8))
|
| 227 |
+
const panel = P ? { x: M, y: 1010, w: W - M * 2 } : { x: M, y: 300, w: 720 }
|
| 228 |
+
const fs = P ? 24 : 22
|
| 229 |
+
return (
|
| 230 |
+
<>
|
| 231 |
+
{/* 星图 */}
|
| 232 |
+
<svg width={W} height={H} style={{ position: 'absolute', left: 0, top: 0, opacity: mapA }}>
|
| 233 |
+
{/* 经纬网 */}
|
| 234 |
+
{Array.from({ length: 6 }, (_, i) => {
|
| 235 |
+
const lon = 100 + i * 5
|
| 236 |
+
const a = pj(lon, 42)
|
| 237 |
+
const b = pj(lon, 17)
|
| 238 |
+
const q = p(0, 0.1 + i * 0.06, 1.4)
|
| 239 |
+
return (
|
| 240 |
+
<g key={'lo' + i} opacity={q}>
|
| 241 |
+
<line x1={a.x} x2={a.x} y1={a.y} y2={lerp(a.y, b.y, q)} stroke="rgba(243,238,228,0.07)" />
|
| 242 |
+
<text x={a.x} y={a.y - 10} textAnchor="middle" fill={C.faint} style={svgText(14, 500, 'mono')}>{`${lon}°E`}</text>
|
| 243 |
+
</g>
|
| 244 |
+
)
|
| 245 |
+
})}
|
| 246 |
+
{Array.from({ length: 6 }, (_, i) => {
|
| 247 |
+
const lat = 20 + i * 4.5
|
| 248 |
+
const a = pj(98, lat)
|
| 249 |
+
const b = pj(125, lat)
|
| 250 |
+
const q = p(0, 0.2 + i * 0.06, 1.4)
|
| 251 |
+
return <line key={'la' + i} x1={a.x} x2={lerp(a.x, b.x, q)} y1={a.y} y2={a.y} stroke="rgba(243,238,228,0.07)" opacity={q} />
|
| 252 |
+
})}
|
| 253 |
+
{/* 城市连线(同色相邻) */}
|
| 254 |
+
{CITIES.map((c, i) => {
|
| 255 |
+
const q = spr(S.lt(0) - 0.8 - i * 0.06, { k: 10, z: 0.55 })
|
| 256 |
+
const { x, y } = pj(c.lon, c.lat)
|
| 257 |
+
const col = STATUS_COLOR[c.st]
|
| 258 |
+
const on = hl.length === 0 || hl.includes(c.name)
|
| 259 |
+
const a = clamp(q * 2) * (on ? 1 : 0.28)
|
| 260 |
+
const lab = c.lab
|
| 261 |
+
const dx = lab === 'l' ? -16 : lab === 'r' ? 16 : 0
|
| 262 |
+
const dy = lab === 't' ? -18 : lab === 'b' ? 30 : 7
|
| 263 |
+
const anchor = lab === 'l' ? 'end' : lab === 'r' ? 'start' : 'middle'
|
| 264 |
+
const big = hl.includes(c.name)
|
| 265 |
+
return (
|
| 266 |
+
<g key={c.name} opacity={a}>
|
| 267 |
+
{big && <circle cx={x} cy={y} r={10 + ((S.t * 0.9 + i * 0.13) % 1) * 26} fill="none" stroke={col} strokeWidth={2} opacity={1 - ((S.t * 0.9 + i * 0.13) % 1)} />}
|
| 268 |
+
<circle cx={x} cy={y} r={big ? 26 : 16} fill={col} opacity={0.18} />
|
| 269 |
+
<circle cx={x} cy={y} r={Math.max(0, (big ? 9 : 7) * clamp(q))} fill={col} stroke="#0A0B0F" strokeWidth={2} />
|
| 270 |
+
<text x={x + dx} y={y + dy} textAnchor={anchor} fill={big ? C.ink : C.mute} style={svgText(big ? fs + 4 : fs - 2, big ? 900 : 600, 'cn')}>
|
| 271 |
+
{c.name}
|
| 272 |
+
</text>
|
| 273 |
+
</g>
|
| 274 |
+
)
|
| 275 |
+
})}
|
| 276 |
+
{/* 图例 */}
|
| 277 |
+
<g opacity={p(0, 2.4)}>
|
| 278 |
+
{[
|
| 279 |
+
['说对', C.green],
|
| 280 |
+
['说错', C.red],
|
| 281 |
+
['存疑', C.amber],
|
| 282 |
+
].map(([l, col], i) => {
|
| 283 |
+
const o = pj(98.5, 18.5)
|
| 284 |
+
return (
|
| 285 |
+
<g key={l}>
|
| 286 |
+
<circle cx={o.x + i * 110 + 8} cy={o.y} r={7} fill={col} />
|
| 287 |
+
<text x={o.x + i * 110 + 24} y={o.y + 7} fill={C.mute} style={svgText(20, 600, 'cn')}>
|
| 288 |
+
{l}
|
| 289 |
+
</text>
|
| 290 |
+
</g>
|
| 291 |
+
)
|
| 292 |
+
})}
|
| 293 |
+
</g>
|
| 294 |
+
</svg>
|
| 295 |
+
|
| 296 |
+
<Beat k={0} to={1} {...panel}>
|
| 297 |
+
<Tag text="CITY CALLS · 城市 / 板块" p={p(0, 0.1)} />
|
| 298 |
+
<T p={p(0, 0.5)} style={{ ...serif(P ? 54 : 56), marginTop: 18 }}>
|
| 299 |
+
他最准的领域之一
|
| 300 |
+
</T>
|
| 301 |
+
<div style={{ marginTop: 10 }}>
|
| 302 |
+
<Big v={String(pct(cityType.hit))} p={p(0, 3.6, 1.8)} size={P ? 170 : 190} unit="%" />
|
| 303 |
+
</div>
|
| 304 |
+
<T p={p(0, 4.8)} style={{ ...cn(P ? 28 : 26, 700), marginTop: 4 }}>
|
| 305 |
+
{`城市分化类判断 · ${cityType.correct} 对 ${cityType.wrong} 错`}
|
| 306 |
+
</T>
|
| 307 |
+
<T p={p(0, 5.6)} style={{ ...cn(P ? 24 : 22, 500, C.dim), marginTop: 12 }}>
|
| 308 |
+
图上 23 座被他点名的城市,按判定结果着色
|
| 309 |
+
</T>
|
| 310 |
+
</Beat>
|
| 311 |
+
<Beat k={1} to={2} {...panel}>
|
| 312 |
+
<Quote text="“一线城市长期跑赢”" t={S.lt(1) - 0.1} size={P ? 40 : 40} />
|
| 313 |
+
<T p={p(1, 1.6)} style={{ ...mono(P ? 18 : 17, C.dim, 500, 2), marginTop: 26 }}>
|
| 314 |
+
新房价格指数 · 2010.12 → 2026.08
|
| 315 |
+
</T>
|
| 316 |
+
{[
|
| 317 |
+
{ l: '北上广深', v: 111, col: C.gold },
|
| 318 |
+
{ l: '其余 66 城', v: 33, col: '#8C7F68' },
|
| 319 |
+
].map((it, i) => {
|
| 320 |
+
const q = p(1, 3.0 + i * 1.6, 1.6)
|
| 321 |
+
return (
|
| 322 |
+
<div key={it.l} style={{ marginTop: 22, opacity: clamp(q * 2) }}>
|
| 323 |
+
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline' }}>
|
| 324 |
+
<div style={serif(P ? 36 : 34, i ? C.ink2 : C.ink)}>{it.l}</div>
|
| 325 |
+
<Big v={`+${it.v}%`} p={q} size={P ? 56 : 54} color={i ? C.mute : C.goldHi} />
|
| 326 |
+
</div>
|
| 327 |
+
<div style={{ height: 14, borderRadius: 7, background: 'rgba(243,238,228,0.06)', marginTop: 10 }}>
|
| 328 |
+
<div style={{ height: 14, borderRadius: 7, width: `${(it.v / 120) * 100 * E.out(q)}%`, background: `linear-gradient(90deg, ${hexA(it.col, 0.35)}, ${it.col})`, boxShadow: i ? undefined : `0 0 24px ${hexA(C.gold, 0.4)}` }} />
|
| 329 |
+
</div>
|
| 330 |
+
</div>
|
| 331 |
+
)
|
| 332 |
+
})}
|
| 333 |
+
<T p={p(1, 7.4)} style={{ ...cn(P ? 24 : 23, 500, C.mute), marginTop: 24 }}>
|
| 334 |
+
从高点回落:一线 −10%,其余 −16%
|
| 335 |
+
</T>
|
| 336 |
+
</Beat>
|
| 337 |
+
<Beat k={2} to={3} {...panel}>
|
| 338 |
+
<Tag text="TOP OF 70 CITIES" p={p(2, 0.1)} />
|
| 339 |
+
{[
|
| 340 |
+
['上海', 154, '70 城第一'],
|
| 341 |
+
['深圳', 112, ''],
|
| 342 |
+
['北京', 93, ''],
|
| 343 |
+
['杭州', 71, ''],
|
| 344 |
+
].map(([l, v, tag], i) => {
|
| 345 |
+
const q = p(2, 0.4 + i * 0.3, 1.4)
|
| 346 |
+
return (
|
| 347 |
+
<div key={l as string} style={{ display: 'flex', alignItems: 'center', gap: 16, marginTop: 16, opacity: clamp(q * 2) }}>
|
| 348 |
+
<div style={{ ...cn(P ? 28 : 26, 800, i === 0 ? C.goldHi : C.ink), width: 70 }}>{l}</div>
|
| 349 |
+
<div style={{ height: 22, width: (P ? 480 : 380) * ((v as number) / 154) * E.out(q), borderRadius: 5, background: i === 0 ? `linear-gradient(90deg, ${C.goldDeep}, ${C.goldHi})` : 'rgba(243,238,228,0.35)' }} />
|
| 350 |
+
<div style={txtStyle({ f: 'num', size: P ? 30 : 28, w: 800, color: i === 0 ? C.goldHi : C.ink })}>{`+${v}%`}</div>
|
| 351 |
+
{tag && <div style={mono(16, C.gold, 700)}>{tag}</div>}
|
| 352 |
+
</div>
|
| 353 |
+
)
|
| 354 |
+
})}
|
| 355 |
+
<T p={p(2, 3.2)} style={{ marginTop: 28 }}>
|
| 356 |
+
<Card tint={C.green} pad={P ? '22px 28px' : '22px 26px'}>
|
| 357 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 18 }}>
|
| 358 |
+
<div style={serif(P ? 44 : 42)}>合肥</div>
|
| 359 |
+
<div style={{ flex: 1 }}>
|
| 360 |
+
<div style={txtStyle({ f: 'num', size: P ? 26 : 24, w: 600, color: C.ink2 })}>6,051 → 18,516 元/㎡</div>
|
| 361 |
+
<div style={{ ...cn(P ? 20 : 19, 500, C.dim), marginTop: 6 }}>2010 → 2020 · “大兴土木的城市房价低不了”</div>
|
| 362 |
+
</div>
|
| 363 |
+
<Big v="+206%" p={p(2, 3.8, 1.3)} size={P ? 54 : 50} color={C.green} />
|
| 364 |
+
</div>
|
| 365 |
+
</Card>
|
| 366 |
+
</T>
|
| 367 |
+
</Beat>
|
| 368 |
+
<Beat k={3} to={4} {...panel}>
|
| 369 |
+
<Tag text="RISK WARNINGS · 说中" p={p(3, 0.1)} color={C.green} />
|
| 370 |
+
{[
|
| 371 |
+
{ l: '燕郊', s: '环京概念盘', a: 34000, b: 12000, pct: '−65%' },
|
| 372 |
+
{ l: '乳山银滩', s: '旅游地产', a: 7500, b: 1655, pct: '−78%' },
|
| 373 |
+
].map((it, i) => {
|
| 374 |
+
const q = p(3, 1.2 + i * 2.2, 2)
|
| 375 |
+
const v = Math.round(lerp(it.a, it.b, E.inOut(q)))
|
| 376 |
+
return (
|
| 377 |
+
<T key={it.l} p={p(3, 0.4 + i * 0.4)} style={{ marginTop: 22 }}>
|
| 378 |
+
<Card pad={P ? '24px 30px' : '24px 28px'}>
|
| 379 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 20 }}>
|
| 380 |
+
<div style={{ flex: 1 }}>
|
| 381 |
+
<div style={serif(P ? 42 : 40)}>{it.l}</div>
|
| 382 |
+
<div style={{ ...cn(20, 500, C.dim), marginTop: 6 }}>{it.s}</div>
|
| 383 |
+
</div>
|
| 384 |
+
<div style={{ textAlign: 'right' }}>
|
| 385 |
+
<div style={{ ...txtStyle({ f: 'num', size: P ? 46 : 44, w: 800, color: q > 0.02 ? C.ink : C.mute }), fontVariantNumeric: 'tabular-nums' }}>{fmt(v)}</div>
|
| 386 |
+
<div style={{ ...mono(16, C.dim, 500), marginTop: 4 }}>{`元/㎡ · 从 ${fmt(it.a)}`}</div>
|
| 387 |
+
</div>
|
| 388 |
+
<div style={{ ...txtStyle({ f: 'num', size: P ? 50 : 48, w: 800, color: C.red }), opacity: clamp(q * 3 - 1.5), width: 150, textAlign: 'right' }}>{it.pct}</div>
|
| 389 |
+
</div>
|
| 390 |
+
</Card>
|
| 391 |
+
</T>
|
| 392 |
+
)
|
| 393 |
+
})}
|
| 394 |
+
</Beat>
|
| 395 |
+
<Beat k={4} to={5} {...panel}>
|
| 396 |
+
<Tag text="MISSES · 押错的牌" p={p(4, 0.1)} color={C.red} />
|
| 397 |
+
<div style={{ display: 'flex', gap: 16, marginTop: 20 }}>
|
| 398 |
+
<Chip kind="no" text="昆明" p={p(4, 0.8)} size={P ? 28 : 26} />
|
| 399 |
+
<Chip kind="no" text="南宁" p={p(4, 1.1)} size={P ? 28 : 26} />
|
| 400 |
+
<Chip kind="no" text="重庆" p={p(4, 4.0)} size={P ? 28 : 26} />
|
| 401 |
+
</div>
|
| 402 |
+
<T p={p(4, 4.0)} style={{ ...cn(P ? 28 : 26, 800), marginTop: 30 }}>
|
| 403 |
+
重庆主城新房 · 元/㎡
|
| 404 |
+
</T>
|
| 405 |
+
{[
|
| 406 |
+
{ l: 'KKndme 目标', v: 9900, ghost: true },
|
| 407 |
+
{ l: '2011 实际', v: 6390 },
|
| 408 |
+
{ l: '2012 实际', v: 6389 },
|
| 409 |
+
].map((b, i) => {
|
| 410 |
+
const q = p(4, 4.4 + i * 0.6, 1.2)
|
| 411 |
+
const bw = (P ? 560 : 420) * (b.v / 9900) * E.out(q)
|
| 412 |
+
return (
|
| 413 |
+
<div key={b.l} style={{ display: 'flex', alignItems: 'center', gap: 16, marginTop: 16, opacity: clamp(q * 2) }}>
|
| 414 |
+
<div style={{ ...cn(P ? 24 : 22, 600, b.ghost ? C.red : C.mute), width: 130 }}>{b.l}</div>
|
| 415 |
+
<div style={{ height: 26, width: bw, borderRadius: 6, border: b.ghost ? `2px dashed ${C.red}` : undefined, background: b.ghost ? hexA(C.red, 0.08) : `linear-gradient(90deg, rgba(243,238,228,0.2), rgba(243,238,228,0.6))` }} />
|
| 416 |
+
<div style={txtStyle({ f: 'num', size: P ? 30 : 28, w: 800, color: b.ghost ? C.red : C.ink })}>{fmt(b.v)}</div>
|
| 417 |
+
</div>
|
| 418 |
+
)
|
| 419 |
+
})}
|
| 420 |
+
</Beat>
|
| 421 |
+
<Beat k={5} x={0} y={P ? 760 : 380} w={W} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }} rise={0}>
|
| 422 |
+
<div style={{ display: 'flex', gap: P ? 26 : 40 }}>
|
| 423 |
+
{['大逻辑', '具体的牌'].map((t, i) => {
|
| 424 |
+
const fl = tw(S.lt(5), 0.3 + i * 1.3, 0.8, E.inOut)
|
| 425 |
+
const sxv = Math.abs(Math.cos(fl * Math.PI))
|
| 426 |
+
const back = fl > 0.5
|
| 427 |
+
const col = i === 0 ? C.green : C.red
|
| 428 |
+
return (
|
| 429 |
+
<div key={t} style={{ width: P ? 300 : 280, height: P ? 400 : 380, transform: `scaleX(${Math.max(0.02, sxv).toFixed(3)})` }}>
|
| 430 |
+
<Card tint={back ? col : C.gold} r={20} pad={0} style={{ width: '100%', height: '100%', display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}>
|
| 431 |
+
{back ? (
|
| 432 |
+
<>
|
| 433 |
+
<Icon kind={i === 0 ? 'ok' : 'no'} size={110} p={1} />
|
| 434 |
+
<div style={{ ...serif(P ? 46 : 44), marginTop: 26 }}>{t}</div>
|
| 435 |
+
<div style={{ ...cn(22, 600, col), marginTop: 12 }}>{i === 0 ? '看懂了' : '常常押错'}</div>
|
| 436 |
+
</>
|
| 437 |
+
) : (
|
| 438 |
+
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
| 439 |
+
<div style={{ ...txtStyle({ f: 'serif', size: P ? 132 : 124, w: 900, lh: 1 }), ...goldText() }}>KK</div>
|
| 440 |
+
<div style={{ ...txtStyle({ f: 'serif', size: P ? 70 : 66, w: 900, lh: 1, ls: 4 }), ...goldText(), marginTop: 10 }}>ndme</div>
|
| 441 |
+
</div>
|
| 442 |
+
)}
|
| 443 |
+
</Card>
|
| 444 |
+
</div>
|
| 445 |
+
)
|
| 446 |
+
})}
|
| 447 |
+
</div>
|
| 448 |
+
</Beat>
|
| 449 |
+
</>
|
| 450 |
+
)
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
// ================= 货币 =================
|
| 454 |
+
const YEARS = Array.from({ length: 16 }, (_, i) => 2010 + i)
|
| 455 |
+
const M2P: [number, number][] = M2_IDX.map((v, i) => [YEARS[i], v])
|
| 456 |
+
const CPIP: [number, number][] = CPI_IDX.map((v, i) => [YEARS[i], v])
|
| 457 |
+
const HOUP: [number, number][] = HOUSE_IDX.map((v, i) => [YEARS[i], v])
|
| 458 |
+
const FXP: [number, number][] = FX.map((v, i) => [mYear(i), v])
|
| 459 |
+
/** 伦敦金年均价(美元/盎司),2010–2024;末点为 2026 年 10 月约 4000 */
|
| 460 |
+
const GOLD: [number, number][] = [
|
| 461 |
+
[2010, 1225],
|
| 462 |
+
[2011, 1572],
|
| 463 |
+
[2012, 1669],
|
| 464 |
+
[2013, 1411],
|
| 465 |
+
[2014, 1266],
|
| 466 |
+
[2015, 1160],
|
| 467 |
+
[2016, 1251],
|
| 468 |
+
[2017, 1257],
|
| 469 |
+
[2018, 1268],
|
| 470 |
+
[2019, 1393],
|
| 471 |
+
[2020, 1770],
|
| 472 |
+
[2021, 1799],
|
| 473 |
+
[2022, 1800],
|
| 474 |
+
[2023, 1943],
|
| 475 |
+
[2024, 2386],
|
| 476 |
+
[2026.8, 4000],
|
| 477 |
+
]
|
| 478 |
+
const FX_MIN_I = FX.indexOf(Math.min(...FX))
|
| 479 |
+
const FX_MAX_I = FX.indexOf(Math.max(...FX))
|
| 480 |
+
|
| 481 |
+
export function Money() {
|
| 482 |
+
const S = useS()
|
| 483 |
+
const { P, W, H, M } = S
|
| 484 |
+
const p = useP()
|
| 485 |
+
const vis = useVis()
|
| 486 |
+
const L = useLay()
|
| 487 |
+
const fs = P ? 22 : 20
|
| 488 |
+
// 图 A:指数
|
| 489 |
+
const aA = vis(1, 4)
|
| 490 |
+
const fA: Fr = { ...L.chart, x0: 2010, x1: 2025.4, y0: 0.6, y1: 5.2 }
|
| 491 |
+
// 图 B:汇率
|
| 492 |
+
const aB = vis(4, 5)
|
| 493 |
+
const fB: Fr = { ...L.chart, x0: 2010, x1: 2026.9, y0: 3.4, y1: 7.6 }
|
| 494 |
+
// 图 C:黄金
|
| 495 |
+
const aC = vis(5)
|
| 496 |
+
const fC: Fr = { ...L.chart, x0: 2010, x1: 2027, y0: 0, y1: 4400 }
|
| 497 |
+
const m2P = p(1, 0.6, 3, E.soft)
|
| 498 |
+
const cpiP = p(2, 0.3, 2.4, E.soft)
|
| 499 |
+
const houP = p(3, 0.4, 2.8, E.soft)
|
| 500 |
+
const kk20 = p(2, 5.0, 1.2)
|
| 501 |
+
// 0:逻辑链
|
| 502 |
+
const nodes = ['货币超发', '高通胀', '房子是避风港']
|
| 503 |
+
return (
|
| 504 |
+
<>
|
| 505 |
+
<Beat k={0} to={1} x={M} y={P ? 400 : 300} w={W - M * 2}>
|
| 506 |
+
<Tag text="KKNDME'S CORE LOGIC" p={p(0, 0.1)} />
|
| 507 |
+
<T p={p(0, 0.3)} style={{ ...serif(P ? 52 : 52), marginTop: 18 }}>
|
| 508 |
+
他的核心逻辑
|
| 509 |
+
</T>
|
| 510 |
+
<div style={{ position: 'relative', display: 'flex', flexDirection: P ? 'column' : 'row', alignItems: P ? 'stretch' : 'center', gap: P ? 70 : 90, marginTop: P ? 50 : 60 }}>
|
| 511 |
+
{nodes.map((n, i) => {
|
| 512 |
+
const q = spr(S.lt(0) - 2.0 - i * 1.4, { k: 10, z: 0.6 })
|
| 513 |
+
const hot = i === 2
|
| 514 |
+
const ar = p(0, 2.6 + i * 1.4, 0.8)
|
| 515 |
+
return (
|
| 516 |
+
<div key={n} style={{ position: 'relative', flex: 1, opacity: clamp(q * 2), transform: `scale(${lerp(0.85, 1, clamp(q)).toFixed(3)})` }}>
|
| 517 |
+
<Card tint={hot ? C.gold : undefined} glow={hot ? C.gold : undefined} pad={P ? '30px 36px' : '40px 36px'} style={{ textAlign: P ? 'left' : 'center' }}>
|
| 518 |
+
<div style={mono(18, C.gold, 700, 3)}>{`STEP 0${i + 1}`}</div>
|
| 519 |
+
<div style={{ ...serif(P ? 52 : 50, hot ? C.goldHi : C.ink), marginTop: 14 }}>{n}</div>
|
| 520 |
+
</Card>
|
| 521 |
+
{i < 2 && ar > 0 && (
|
| 522 |
+
<div style={P ? { position: 'absolute', left: 60, top: '100%', width: 4, height: 70 } : { position: 'absolute', left: '100%', top: '50%', width: 90, height: 4 }}>
|
| 523 |
+
<div style={P ? { position: 'absolute', left: 0, top: 8, width: 3, height: 54 * E.out(ar), background: `linear-gradient(180deg, ${hexA(C.gold, 0.2)}, ${C.gold})` } : { position: 'absolute', left: 8, top: 0, width: 74 * E.out(ar), height: 3, background: `linear-gradient(90deg, ${hexA(C.gold, 0.2)}, ${C.gold})` }} />
|
| 524 |
+
{[0, 1, 2].map((j) => {
|
| 525 |
+
const ph = (S.t * 0.9 + j / 3) % 1
|
| 526 |
+
const off = 8 + ph * (P ? 50 : 70) - 4
|
| 527 |
+
return <div key={j} style={{ position: 'absolute', left: P ? -3 : off, top: P ? off : -3, width: 9, height: 9, borderRadius: '50%', background: C.goldHi, opacity: ar * Math.sin(ph * Math.PI), boxShadow: `0 0 12px ${C.goldHi}` }} />
|
| 528 |
+
})}
|
| 529 |
+
</div>
|
| 530 |
+
)}
|
| 531 |
+
</div>
|
| 532 |
+
)
|
| 533 |
+
})}
|
| 534 |
+
</div>
|
| 535 |
+
</Beat>
|
| 536 |
+
|
| 537 |
+
{/* 图 A */}
|
| 538 |
+
{aA > 0.001 && (
|
| 539 |
+
<svg width={W} height={H} style={{ position: 'absolute', left: 0, top: 0, opacity: aA }}>
|
| 540 |
+
<Grid f={fA} yt={[1, 2, 3, 4, 5]} xt={[2010, 2015, 2020, 2025]} fy={(v) => `${v}×`} p={p(1, 0.1, 1.4)} size={fs} />
|
| 541 |
+
<Series id="m2" d={smoothPath(fA, M2P)} p={m2P} color={C.gold} width={4.5} area={0.25} baseY={fA.y + fA.h} clipX={[fA.x, fA.x + fA.w]} />
|
| 542 |
+
{m2P > 0.98 && (
|
| 543 |
+
<text x={sx(fA, 2025) - 10} y={sy(fA, M2_IDX[15]) - 24} textAnchor="end" fill={C.goldHi} style={svgText(fs + 6, 800, 'num')}>
|
| 544 |
+
M2 4.69×
|
| 545 |
+
</text>
|
| 546 |
+
)}
|
| 547 |
+
{cpiP > 0 && <Series id="cpi" d={smoothPath(fA, CPIP)} p={cpiP} color={C.ink} width={3.5} />}
|
| 548 |
+
{cpiP > 0.98 && (
|
| 549 |
+
<text x={sx(fA, 2025) - 10} y={sy(fA, CPI_IDX[15]) - 18} textAnchor="end" fill={C.ink} style={svgText(fs + 2, 800, 'num')}>
|
| 550 |
+
CPI 1.32×
|
| 551 |
+
</text>
|
| 552 |
+
)}
|
| 553 |
+
{houP > 0 && <Series id="hou" d={smoothPath(fA, HOUP)} p={houP} color={C.sky} width={3.5} />}
|
| 554 |
+
{houP > 0.98 && (
|
| 555 |
+
<text x={sx(fA, 2025) - 10} y={sy(fA, HOUSE_IDX[15]) + 40} textAnchor="end" fill={C.sky} style={svgText(fs + 2, 800, 'cn')}>
|
| 556 |
+
房价 1.16×
|
| 557 |
+
</text>
|
| 558 |
+
)}
|
| 559 |
+
{kk20 > 0 && (
|
| 560 |
+
<g opacity={kk20 * (1 - p(3, 0, 0.6) * 0.7)}>
|
| 561 |
+
<line x1={sx(fA, 2020)} x2={sx(fA, 2020)} y1={sy(fA, 1.2)} y2={lerp(sy(fA, 1.2), fA.y - 40, E.out(kk20))} stroke={C.red} strokeWidth={3} strokeDasharray="8 7" />
|
| 562 |
+
<path d={`M${sx(fA, 2020) - 12},${fA.y - 26} L${sx(fA, 2020)},${fA.y - 44} L${sx(fA, 2020) + 12},${fA.y - 26}`} stroke={C.red} strokeWidth={3} fill="none" />
|
| 563 |
+
<text x={sx(fA, 2020) - 18} y={fA.y + 24} textAnchor="end" fill={C.red} style={svgText(fs + 2, 800, 'cn')}>
|
| 564 |
+
KKndme:十年物价 ×20
|
| 565 |
+
</text>
|
| 566 |
+
<text x={sx(fA, 2020) - 18} y={fA.y + 24 + fs * 1.5} textAnchor="end" fill={C.dim} style={svgText(fs - 3, 500, 'cn')}>
|
| 567 |
+
(这张图要再高 4 倍才画得下)
|
| 568 |
+
</text>
|
| 569 |
+
</g>
|
| 570 |
+
)}
|
| 571 |
+
</svg>
|
| 572 |
+
)}
|
| 573 |
+
<Beat k={1} to={2} {...L.panel}>
|
| 574 |
+
<Tag text="M2 · 广义货币" p={p(1, 0.1)} />
|
| 575 |
+
<Big v="340" p={p(1, 0.6, 2.4)} size={P ? 170 : 180} unit="万亿" style={{ marginTop: 10 }} />
|
| 576 |
+
<T p={p(1, 2.6)} style={{ ...txtStyle({ f: 'num', size: P ? 30 : 28, w: 600, color: C.mute }), marginTop: 6 }}>
|
| 577 |
+
2010:72.6 万亿 → 2025:340.3 万亿
|
| 578 |
+
</T>
|
| 579 |
+
<T p={p(1, 4.6)} style={{ display: 'flex', alignItems: 'center', gap: 20, marginTop: 26 }}>
|
| 580 |
+
<div style={{ ...txtStyle({ f: 'num', size: P ? 80 : 76, w: 800 }), ...goldText() }}>4.7×</div>
|
| 581 |
+
<Chip kind="ok" text="确实超发" p={p(1, 5.2)} size={P ? 26 : 24} />
|
| 582 |
+
</T>
|
| 583 |
+
</Beat>
|
| 584 |
+
<Beat k={2} to={3} {...L.panel}>
|
| 585 |
+
<Tag text="CPI · 物价" p={p(2, 0.1)} color={C.ink} />
|
| 586 |
+
<Big v="+32%" p={p(2, 0.6, 2)} size={P ? 160 : 170} style={{ marginTop: 22 }} />
|
| 587 |
+
<T p={p(2, 2.0)} style={{ ...cn(P ? 28 : 26, 500, C.mute), marginTop: 6 }}>
|
| 588 |
+
2010 → 2025 累计 · 年均约 1.9%
|
| 589 |
+
</T>
|
| 590 |
+
<T p={p(2, 5.0)} style={{ marginTop: 26 }}>
|
| 591 |
+
<Card tint={C.red} pad="20px 26px">
|
| 592 |
+
<div style={cn(P ? 30 : 28, 800)}>KKndme:“十年物价可能再涨 20 倍”</div>
|
| 593 |
+
<div style={{ ...cn(P ? 24 : 22, 600, C.red), marginTop: 8 }}>差了两个数量级</div>
|
| 594 |
+
</Card>
|
| 595 |
+
</T>
|
| 596 |
+
</Beat>
|
| 597 |
+
<Beat k={3} to={4} {...L.panel}>
|
| 598 |
+
<Tag text="THE LINK BROKE" p={p(3, 0.1)} color={C.sky} />
|
| 599 |
+
<T p={p(3, 0.4)} style={{ ...serif(P ? 54 : 56), marginTop: 18 }}>
|
| 600 |
+
钱越来越多,
|
| 601 |
+
</T>
|
| 602 |
+
<T p={p(3, 1.0)} style={{ ...serif(P ? 54 : 56, C.sky), marginTop: 6 }}>
|
| 603 |
+
房价后来却跌了
|
| 604 |
+
</T>
|
| 605 |
+
<T p={p(3, 4.0)} style={{ display: 'flex', alignItems: 'center', gap: 16, marginTop: 30, flexWrap: 'wrap' }}>
|
| 606 |
+
<div style={cn(P ? 30 : 28, 800, C.goldHi)}>“印钞托底房价”</div>
|
| 607 |
+
<Chip kind="no" text="2021 年后失灵" p={p(3, 4.6)} size={P ? 24 : 22} />
|
| 608 |
+
</T>
|
| 609 |
+
<T p={p(3, 1.6)} style={{ display: 'flex', gap: 26, marginTop: 30 }}>
|
| 610 |
+
{[
|
| 611 |
+
['M2', C.gold],
|
| 612 |
+
['CPI', C.ink],
|
| 613 |
+
['房价', C.sky],
|
| 614 |
+
].map(([l, c]) => (
|
| 615 |
+
<div key={l} style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
|
| 616 |
+
<div style={{ width: 26, height: 4, borderRadius: 2, background: c }} />
|
| 617 |
+
<div style={cn(22, 600, C.mute)}>{l}</div>
|
| 618 |
+
</div>
|
| 619 |
+
))}
|
| 620 |
+
</T>
|
| 621 |
+
</Beat>
|
| 622 |
+
|
| 623 |
+
{/* 图 B:汇率 */}
|
| 624 |
+
{aB > 0.001 && (
|
| 625 |
+
<svg width={W} height={H} style={{ position: 'absolute', left: 0, top: 0, opacity: aB }}>
|
| 626 |
+
<Grid f={fB} yt={[4, 5, 6, 7]} xt={[2010, 2014, 2018, 2022, 2026]} fy={(v) => v.toFixed(1)} p={p(4, 0.1, 1.4)} size={fs} />
|
| 627 |
+
<g opacity={p(4, 3.4)}>
|
| 628 |
+
<line x1={fB.x} x2={fB.x + fB.w} y1={sy(fB, 4)} y2={sy(fB, 4)} stroke={C.red} strokeWidth={2.5} strokeDasharray="10 8" />
|
| 629 |
+
<text x={fB.x + 14} y={sy(fB, 4) - 16} fill={C.red} style={svgText(fs + 2, 800, 'cn')}>
|
| 630 |
+
4 : 1 · KKndme:“国家不可能允许”
|
| 631 |
+
</text>
|
| 632 |
+
</g>
|
| 633 |
+
<Series id="fx" d={linePath(fB, FXP)} p={p(4, 0.4, 3.6, E.soft)} color={C.gold} width={3.5} area={0.22} baseY={fB.y + fB.h} clipX={[fB.x, fB.x + fB.w]} />
|
| 634 |
+
{(() => {
|
| 635 |
+
const q1 = p(4, 4.6, 0.8)
|
| 636 |
+
const q2 = p(4, 6.0, 0.8)
|
| 637 |
+
const a = FXP[FX_MIN_I]
|
| 638 |
+
const b = FXP[FX_MAX_I]
|
| 639 |
+
return (
|
| 640 |
+
<>
|
| 641 |
+
<SvgDot id="fxmin" x={sx(fB, a[0])} y={sy(fB, a[1])} r={8} color={C.green} o={q1} />
|
| 642 |
+
<text x={sx(fB, a[0])} y={sy(fB, a[1]) + 44} textAnchor="middle" fill={C.green} opacity={q1} style={svgText(fs + 4, 800, 'num')}>
|
| 643 |
+
{`人民币最强 ${a[1].toFixed(2)}`}
|
| 644 |
+
</text>
|
| 645 |
+
<SvgDot id="fxmax" x={sx(fB, b[0])} y={sy(fB, b[1])} r={8} color={C.ink} o={q2} />
|
| 646 |
+
<text x={sx(fB, b[0])} y={sy(fB, b[1]) - 24} textAnchor="middle" fill={C.ink} opacity={q2} style={svgText(fs + 4, 800, 'num')}>
|
| 647 |
+
{b[1].toFixed(2)}
|
| 648 |
+
</text>
|
| 649 |
+
</>
|
| 650 |
+
)
|
| 651 |
+
})()}
|
| 652 |
+
<text x={fB.x} y={fB.y + fB.h + (P ? 76 : 70)} fill={C.dim} opacity={p(4, 1)} style={svgText(P ? 18 : 16, 500, 'mono')}>
|
| 653 |
+
美元兑人民币 · 月均 · 美联储 H.10 · 数值越低人民币越强
|
| 654 |
+
</text>
|
| 655 |
+
</svg>
|
| 656 |
+
)}
|
| 657 |
+
<Beat k={4} to={5} {...L.panel}>
|
| 658 |
+
<Tag text="RMB / USD" p={p(4, 0.1)} />
|
| 659 |
+
<T p={p(4, 0.3)} style={{ ...serif(P ? 52 : 52), marginTop: 18 }}>
|
| 660 |
+
汇率上他很清醒
|
| 661 |
+
</T>
|
| 662 |
+
<div style={{ marginTop: 26 }}>
|
| 663 |
+
<Quote text="“我不认为人民币能到 4:1,国家也不可能允许 4:1。”" t={S.lt(4) - 1.0} size={P ? 34 : 32} />
|
| 664 |
+
</div>
|
| 665 |
+
<div style={{ marginTop: 26 }}>
|
| 666 |
+
<Chip kind="ok" text="说对 · 最高只到 6.04" p={p(4, 5.4)} size={P ? 26 : 24} />
|
| 667 |
+
</div>
|
| 668 |
+
</Beat>
|
| 669 |
+
|
| 670 |
+
{/* 图 C:黄金 */}
|
| 671 |
+
{aC > 0.001 && (
|
| 672 |
+
<svg width={W} height={H} style={{ position: 'absolute', left: 0, top: 0, opacity: aC }}>
|
| 673 |
+
<Grid f={fC} yt={[1000, 2000, 3000, 4000]} xt={[2010, 2014, 2018, 2022, 2026]} fy={(v) => fmt(v)} p={p(5, 0.1, 1.4)} size={fs} />
|
| 674 |
+
<Series id="gold" d={linePath(fC, GOLD)} p={p(5, 0.4, 5.4, E.soft)} color={C.goldHi} width={4} area={0.3} baseY={fC.y + fC.h} clipX={[fC.x, fC.x + fC.w]} />
|
| 675 |
+
{(() => {
|
| 676 |
+
const q1 = p(5, 2.6, 0.8)
|
| 677 |
+
const q2 = p(5, 6.4, 0.8)
|
| 678 |
+
return (
|
| 679 |
+
<>
|
| 680 |
+
<g opacity={q1}>
|
| 681 |
+
<SvgDot id="g13" x={sx(fC, 2013)} y={sy(fC, 1411)} r={8} color={C.red} o={1} />
|
| 682 |
+
<text x={sx(fC, 2013)} y={sy(fC, 1411) + 46} textAnchor="middle" fill={C.red} style={svgText(fs + 4, 800, 'num')}>
|
| 683 |
+
2013 −28%
|
| 684 |
+
</text>
|
| 685 |
+
</g>
|
| 686 |
+
<g opacity={q2}>
|
| 687 |
+
<SvgDot id="g26" x={sx(fC, 2026.8)} y={sy(fC, 4000)} r={9} color={C.goldHi} o={1} pulse={(S.t * 0.8) % 1} />
|
| 688 |
+
<text x={sx(fC, 2026.8) - 20} y={sy(fC, 4000) - 22} textAnchor="end" fill={C.goldHi} style={svgText(fs + 8, 800, 'num')}>
|
| 689 |
+
≈ $4,000
|
| 690 |
+
</text>
|
| 691 |
+
</g>
|
| 692 |
+
</>
|
| 693 |
+
)
|
| 694 |
+
})()}
|
| 695 |
+
<text x={fC.x} y={fC.y + fC.h + (P ? 76 : 70)} fill={C.dim} opacity={p(5, 1)} style={svgText(P ? 18 : 16, 500, 'mono')}>
|
| 696 |
+
伦敦金 · 美元/盎司 · 年均价,末点为 2026.10
|
| 697 |
+
</text>
|
| 698 |
+
</svg>
|
| 699 |
+
)}
|
| 700 |
+
<Beat k={5} {...L.panel}>
|
| 701 |
+
<Tag text="GOLD" p={p(5, 0.1)} />
|
| 702 |
+
<T p={p(5, 0.3)} style={{ ...serif(P ? 52 : 52), marginTop: 18 }}>
|
| 703 |
+
“黄金风险很大”
|
| 704 |
+
</T>
|
| 705 |
+
<T p={p(5, 2.6)} style={{ display: 'flex', alignItems: 'center', gap: 16, marginTop: 30 }}>
|
| 706 |
+
<Chip kind="ok" text="短期说对" p={p(5, 2.8)} size={P ? 26 : 24} />
|
| 707 |
+
<div style={cn(P ? 26 : 24, 600, C.mute)}>2013 年暴跌 28%</div>
|
| 708 |
+
</T>
|
| 709 |
+
<T p={p(5, 6.0)} style={{ display: 'flex', alignItems: 'center', gap: 16, marginTop: 20 }}>
|
| 710 |
+
<Chip kind="no" text="长期错过" p={p(5, 6.2)} size={P ? 26 : 24} />
|
| 711 |
+
<div style={txtStyle({ f: 'num', size: P ? 30 : 28, w: 700, color: C.goldHi })}>$1,250 → $4,000</div>
|
| 712 |
+
</T>
|
| 713 |
+
</Beat>
|
| 714 |
+
</>
|
| 715 |
+
)
|
| 716 |
+
}
|
| 717 |
+
|
| 718 |
+
// ================= 政策 =================
|
| 719 |
+
const policyR = byTopic.find((x) => x.k === '调控与房产税')!.r
|
| 720 |
+
const EVENTS = [
|
| 721 |
+
{ y: 2011.08, k: 4, l: '沪渝开征房产税' },
|
| 722 |
+
{ y: 2011.5, k: 1, l: '限购扩至 46 城' },
|
| 723 |
+
{ y: 2020.4, k: 3, l: '民法典 · 自动续期' },
|
| 724 |
+
{ y: 2021.8, k: 2, l: '人大授权扩大试点' },
|
| 725 |
+
{ y: 2024.4, k: 5, l: '首付降至 15%' },
|
| 726 |
+
{ y: 2026.2, k: 2, l: '“十五五”未再提' },
|
| 727 |
+
]
|
| 728 |
+
const DOWN: [number, number][] = [
|
| 729 |
+
[2010, 30],
|
| 730 |
+
[2015.2, 30],
|
| 731 |
+
[2015.25, 25],
|
| 732 |
+
[2016.1, 25],
|
| 733 |
+
[2016.15, 20],
|
| 734 |
+
[2024.35, 20],
|
| 735 |
+
[2024.4, 15],
|
| 736 |
+
[2026.8, 15],
|
| 737 |
+
]
|
| 738 |
+
|
| 739 |
+
export function Policy() {
|
| 740 |
+
const S = useS()
|
| 741 |
+
const { P, W, H, M } = S
|
| 742 |
+
const p = useP()
|
| 743 |
+
const vis = useVis()
|
| 744 |
+
const ty = P ? 440 : 300
|
| 745 |
+
const tx0 = M + 20
|
| 746 |
+
const tx1 = W - M - 20
|
| 747 |
+
const X = (yr: number) => lerp(tx0, tx1, (yr - 2010) / 16.8)
|
| 748 |
+
const cur = [0, 1, 2, 3, 4, 5].reduce((a, i) => (S.lt(i) >= 0 ? i : a), 0)
|
| 749 |
+
const top = P ? 560 : 390
|
| 750 |
+
const fs = P ? 22 : 20
|
| 751 |
+
const tA = vis(0, 5)
|
| 752 |
+
return (
|
| 753 |
+
<>
|
| 754 |
+
{/* 时间轴 */}
|
| 755 |
+
<svg width={W} height={H} style={{ position: 'absolute', left: 0, top: 0, opacity: tA }}>
|
| 756 |
+
<line x1={tx0} x2={tx0 + (tx1 - tx0) * p(0, 0.2, 1.6, E.inOut)} y1={ty} y2={ty} stroke="rgba(243,238,228,0.28)" strokeWidth={1.5} />
|
| 757 |
+
{Array.from({ length: 17 }, (_, i) => {
|
| 758 |
+
const y = 2010 + i
|
| 759 |
+
const x = X(y)
|
| 760 |
+
const major = i % 4 === 0
|
| 761 |
+
return (
|
| 762 |
+
<g key={y} opacity={p(0, 0.3 + i * 0.05)}>
|
| 763 |
+
<line x1={x} x2={x} y1={ty - (major ? 8 : 4)} y2={ty + (major ? 8 : 4)} stroke="rgba(243,238,228,0.35)" strokeWidth={1.5} />
|
| 764 |
+
{major && (
|
| 765 |
+
<text x={x} y={ty + 38} textAnchor="middle" fill={C.dim} style={svgText(fs - 2, 500, 'mono')}>
|
| 766 |
+
{y}
|
| 767 |
+
</text>
|
| 768 |
+
)}
|
| 769 |
+
</g>
|
| 770 |
+
)
|
| 771 |
+
})}
|
| 772 |
+
{EVENTS.map((e) => {
|
| 773 |
+
const q = p(e.k, 0.3)
|
| 774 |
+
if (q <= 0) return null
|
| 775 |
+
const on = e.k === cur
|
| 776 |
+
return (
|
| 777 |
+
<g key={e.l} opacity={on ? 1 : 0.4}>
|
| 778 |
+
{on && <circle cx={X(e.y)} cy={ty} r={8 + ((S.t * 0.8) % 1) * 22} fill="none" stroke={C.goldHi} strokeWidth={2} opacity={1 - ((S.t * 0.8) % 1)} />}
|
| 779 |
+
<circle cx={X(e.y)} cy={ty} r={7 * E.back(q)} fill={on ? C.goldHi : C.gold} />
|
| 780 |
+
{on && !P && (
|
| 781 |
+
<text x={X(e.y)} y={ty - 22} textAnchor="middle" fill={C.goldHi} style={svgText(fs, 800, 'cn')}>
|
| 782 |
+
{e.l}
|
| 783 |
+
</text>
|
| 784 |
+
)}
|
| 785 |
+
</g>
|
| 786 |
+
)
|
| 787 |
+
})}
|
| 788 |
+
</svg>
|
| 789 |
+
|
| 790 |
+
{/* 0:命中率 */}
|
| 791 |
+
<Beat k={0} to={1} x={M} y={top} w={W - M * 2} style={{ display: 'flex', flexDirection: P ? 'column' : 'row', alignItems: 'center', gap: P ? 50 : 100 }}>
|
| 792 |
+
<div style={{ position: 'relative', width: P ? 460 : 440, height: P ? 460 : 440, flex: 'none' }}>
|
| 793 |
+
<Ring size={P ? 460 : 440} stroke={30} segs={[{ v: policyR.correct, color: C.green }, { v: policyR.wrong, color: C.red }, { v: policyR.disputed, color: C.amber }]} p={p(0, 0.4, 2.2)} />
|
| 794 |
+
<div style={{ position: 'absolute', inset: 0, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
| 795 |
+
<Big v={String(pct(policyR.hit))} p={p(0, 0.5, 2)} size={P ? 170 : 160} unit="%" />
|
| 796 |
+
</div>
|
| 797 |
+
</div>
|
| 798 |
+
<div style={{ width: P ? '100%' : undefined }}>
|
| 799 |
+
<Tag text="POLICY CALLS · 调控与房产税" p={p(0, 1.4)} />
|
| 800 |
+
<T p={p(0, 1.7)} style={{ ...serif(P ? 60 : 64), marginTop: 18 }}>
|
| 801 |
+
他另一块强项
|
| 802 |
+
</T>
|
| 803 |
+
<div style={{ display: 'flex', gap: 40, marginTop: 30 }}>
|
| 804 |
+
{[
|
| 805 |
+
['说对', policyR.correct, C.green],
|
| 806 |
+
['说错', policyR.wrong, C.red],
|
| 807 |
+
['参半', policyR.disputed, C.amber],
|
| 808 |
+
].map(([l, n, col], i) => (
|
| 809 |
+
<T key={l as string} p={p(0, 2.6 + i * 0.3)} style={{ display: 'flex', alignItems: 'baseline', gap: 10 }}>
|
| 810 |
+
<Dot color={col as string} />
|
| 811 |
+
<div style={txtStyle({ f: 'num', size: 56, w: 800 })}>{n}</div>
|
| 812 |
+
<div style={cn(24, 600, C.mute)}>{l}</div>
|
| 813 |
+
</T>
|
| 814 |
+
))}
|
| 815 |
+
</div>
|
| 816 |
+
</div>
|
| 817 |
+
</Beat>
|
| 818 |
+
|
| 819 |
+
{/* 1:限购 46 城 */}
|
| 820 |
+
<Beat k={1} to={2} x={M} y={top} w={W - M * 2} style={{ display: 'flex', flexDirection: P ? 'column' : 'row', gap: P ? 40 : 90 }}>
|
| 821 |
+
<div style={{ width: P ? '100%' : 640 }}>
|
| 822 |
+
<Quote text="“两年内调控不会放松,更多城市要限购”" t={S.lt(1) - 0.2} size={P ? 40 : 38} />
|
| 823 |
+
<T p={p(1, 3.6)} style={{ display: 'flex', alignItems: 'baseline', gap: 18, marginTop: 34 }}>
|
| 824 |
+
<div style={cn(P ? 30 : 28, 600, C.mute)}>2011 年限购扩大到</div>
|
| 825 |
+
</T>
|
| 826 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 24 }}>
|
| 827 |
+
<Big v="46" p={p(1, 3.8, 1.6)} size={P ? 170 : 170} unit="城" />
|
| 828 |
+
<Chip kind="ok" text="说对" p={p(1, 5.2)} size={P ? 28 : 26} />
|
| 829 |
+
</div>
|
| 830 |
+
</div>
|
| 831 |
+
<div style={{ display: 'grid', gridTemplateColumns: `repeat(${P ? 10 : 8}, 1fr)`, gap: P ? 14 : 16, alignContent: 'start', flex: 1, marginTop: P ? 0 : 20 }}>
|
| 832 |
+
{Array.from({ length: 46 }, (_, i) => {
|
| 833 |
+
const q = p(1, 3.8 + i * 0.035, 0.5)
|
| 834 |
+
return <div key={i} style={{ height: P ? 64 : 62, borderRadius: 8, border: `1px solid ${hexA(C.gold, 0.3 + 0.5 * q)}`, background: hexA(C.gold, 0.05 + 0.3 * q), boxShadow: q > 0.5 ? `0 0 14px ${hexA(C.gold, 0.25)}` : undefined, transform: `scale(${lerp(0.6, 1, E.back(q)).toFixed(3)})`, opacity: 0.3 + 0.7 * q }} />
|
| 835 |
+
})}
|
| 836 |
+
</div>
|
| 837 |
+
</Beat>
|
| 838 |
+
|
| 839 |
+
{/* 2:房产税 */}
|
| 840 |
+
<Beat k={2} to={3} x={M} y={top} w={W - M * 2}>
|
| 841 |
+
<Quote text="“房产税真正实施很难”" t={S.lt(2) - 0.2} size={P ? 42 : 40} />
|
| 842 |
+
<div style={{ display: 'grid', gridTemplateColumns: P ? '1fr' : 'repeat(4, 1fr)', gap: P ? 16 : 24, marginTop: P ? 34 : 40 }}>
|
| 843 |
+
{[
|
| 844 |
+
{ y: '2011', t: '沪渝试点', d: '只有两座城市' },
|
| 845 |
+
{ y: '2021', t: '人大授权扩大试点', d: '方案始终未落地' },
|
| 846 |
+
{ y: '2022', t: '年内不扩围', d: '财政部表态' },
|
| 847 |
+
{ y: '2026', t: '“十五五”规划', d: '房地产税立法不见踪影' },
|
| 848 |
+
].map((e, i) => {
|
| 849 |
+
const q = p(2, 1.6 + i * 1.0)
|
| 850 |
+
return (
|
| 851 |
+
<T key={e.y} p={q}>
|
| 852 |
+
<Card pad={P ? '20px 26px' : 26} tint={i === 3 ? C.gold : undefined} style={{ display: 'flex', flexDirection: P ? 'row' : 'column', alignItems: P ? 'center' : 'stretch', gap: P ? 24 : 0 }}>
|
| 853 |
+
<div style={{ ...txtStyle({ f: 'num', size: P ? 44 : 48, w: 800 }), ...goldText() }}>{e.y}</div>
|
| 854 |
+
<div>
|
| 855 |
+
<div style={{ ...cn(P ? 30 : 30, 800), marginTop: P ? 0 : 14 }}>{e.t}</div>
|
| 856 |
+
<div style={{ ...cn(P ? 22 : 21, 500, C.mute), marginTop: 6 }}>{e.d}</div>
|
| 857 |
+
</div>
|
| 858 |
+
</Card>
|
| 859 |
+
</T>
|
| 860 |
+
)
|
| 861 |
+
})}
|
| 862 |
+
</div>
|
| 863 |
+
<div style={{ marginTop: 28 }}>
|
| 864 |
+
<Chip kind="ok" text="十五年后仍未全面开征 · 说对" p={p(2, 6.4)} size={P ? 26 : 24} />
|
| 865 |
+
</div>
|
| 866 |
+
</Beat>
|
| 867 |
+
|
| 868 |
+
{/* 3:民法典 */}
|
| 869 |
+
<Beat k={3} to={4} x={P ? M : 260} y={top} w={P ? W - M * 2 : W - 520}>
|
| 870 |
+
<Quote text="“70 年住宅产权到期,自动续期”" t={S.lt(3) - 0.2} size={P ? 40 : 40} />
|
| 871 |
+
<T p={p(3, 3.0)} style={{ marginTop: 34 }}>
|
| 872 |
+
<Card tint={C.gold} glow={C.gold} pad={P ? 34 : 40}>
|
| 873 |
+
<div style={{ display: 'flex', alignItems: 'baseline', gap: 20, flexWrap: 'wrap' }}>
|
| 874 |
+
<div style={serif(P ? 44 : 46, C.goldHi)}>《中华人民共和国民法典》</div>
|
| 875 |
+
<div style={txtStyle({ f: 'num', size: P ? 56 : 60, w: 800 })}>第 359 条</div>
|
| 876 |
+
</div>
|
| 877 |
+
<div style={{ ...serif(P ? 38 : 40, C.ink, 700, 1.5), marginTop: 22 }}>
|
| 878 |
+
<span style={{ opacity: 0.85 }}>住宅建设用地使用权期限届满的,</span>
|
| 879 |
+
<span style={{ ...goldText(), fontWeight: 900 }}>自动续期</span>
|
| 880 |
+
<span style={{ opacity: 0.85 }}>。</span>
|
| 881 |
+
</div>
|
| 882 |
+
<div style={{ ...mono(18, C.dim, 500), marginTop: 18 }}>2020.05 通过 · 2021.01.01 施行</div>
|
| 883 |
+
</Card>
|
| 884 |
+
</T>
|
| 885 |
+
<div style={{ marginTop: 24 }}>
|
| 886 |
+
<Chip kind="ok" text="写进法律 · 说对" p={p(3, 5.2)} size={P ? 26 : 24} />
|
| 887 |
+
</div>
|
| 888 |
+
</Beat>
|
| 889 |
+
|
| 890 |
+
{/* 4:翻车 */}
|
| 891 |
+
<Beat k={4} to={5} x={M} y={top} w={W - M * 2}>
|
| 892 |
+
<T p={p(4, 0)} style={{ ...serif(P ? 50 : 50), marginBottom: 30 }}>
|
| 893 |
+
但也有翻车
|
| 894 |
+
</T>
|
| 895 |
+
<div style={{ display: 'grid', gridTemplateColumns: P ? '1fr' : '1fr 1fr', gap: P ? 24 : 34 }}>
|
| 896 |
+
{[
|
| 897 |
+
{ q: '“房产税两年内一定不征”', a: '5', u: '个月后', d: '2011 年 1 月,沪渝开征', st: 1.2 },
|
| 898 |
+
{ q: '“限购不会长期”', a: '14', u: '年', d: '2010 年起,一限就是十四年', st: 5.0 },
|
| 899 |
+
].map((c, i) => (
|
| 900 |
+
<T key={c.q} p={p(4, c.st - 0.8)}>
|
| 901 |
+
<Card tint={C.red} pad={P ? 30 : 34}>
|
| 902 |
+
<div style={serif(P ? 36 : 36, C.ink, 800)}>{c.q}</div>
|
| 903 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 20, marginTop: 22 }}>
|
| 904 |
+
<Big v={c.a} p={p(4, c.st, 1.4)} size={P ? 110 : 120} unit={c.u} color={C.red} unitColor={C.red} />
|
| 905 |
+
<div style={{ flex: 1 }} />
|
| 906 |
+
<Chip kind="no" p={p(4, c.st + 0.8)} size={24} />
|
| 907 |
+
</div>
|
| 908 |
+
<div style={{ ...cn(P ? 24 : 23, 500, C.mute), marginTop: 8 }}>{c.d}</div>
|
| 909 |
+
</Card>
|
| 910 |
+
</T>
|
| 911 |
+
))}
|
| 912 |
+
</div>
|
| 913 |
+
</Beat>
|
| 914 |
+
|
| 915 |
+
{/* 5:首付 */}
|
| 916 |
+
{(() => {
|
| 917 |
+
const a = vis(5)
|
| 918 |
+
if (a <= 0.001) return null
|
| 919 |
+
const f: Fr = P ? { x: 170, y: 520, w: 800, h: 420, x0: 2010, x1: 2026.8, y0: 0, y1: 45 } : { x: 900, y: 330, w: 840, h: 460, x0: 2010, x1: 2026.8, y0: 0, y1: 45 }
|
| 920 |
+
const q = p(5, 0.4, 3.4, E.soft)
|
| 921 |
+
return (
|
| 922 |
+
<>
|
| 923 |
+
<svg width={W} height={H} style={{ position: 'absolute', left: 0, top: 0, opacity: a }}>
|
| 924 |
+
<Grid f={f} yt={[0, 10, 20, 30, 40]} xt={[2010, 2014, 2018, 2022, 2026]} fy={(v) => `${v}%`} p={p(5, 0.1, 1.4)} size={fs} />
|
| 925 |
+
<g opacity={p(5, 0.6)}>
|
| 926 |
+
<line x1={f.x} x2={f.x + f.w} y1={sy(f, 40)} y2={sy(f, 40)} stroke={C.red} strokeWidth={2.5} strokeDasharray="10 8" />
|
| 927 |
+
<text x={f.x + 12} y={sy(f, 40) - 14} fill={C.red} style={svgText(fs + 2, 800, 'cn')}>
|
| 928 |
+
KKndme:首套首付要提到 40%
|
| 929 |
+
</text>
|
| 930 |
+
</g>
|
| 931 |
+
<Series id="down" d={linePath(f, DOWN)} p={q} color={C.gold} width={4} area={0.22} baseY={f.y + f.h} clipX={[f.x, f.x + f.w]} />
|
| 932 |
+
{q > 0.98 && (
|
| 933 |
+
<g>
|
| 934 |
+
<SvgDot id="d15" x={sx(f, 2024.4)} y={sy(f, 15)} r={9} color={C.goldHi} o={1} pulse={(S.t * 0.8) % 1} />
|
| 935 |
+
<text x={sx(f, 2024.4)} y={sy(f, 15) - 26} textAnchor="middle" fill={C.goldHi} style={svgText(fs + 6, 800, 'num')}>
|
| 936 |
+
15%
|
| 937 |
+
</text>
|
| 938 |
+
</g>
|
| 939 |
+
)}
|
| 940 |
+
<text x={f.x} y={f.y + f.h + (P ? 76 : 70)} fill={C.dim} opacity={p(5, 1)} style={svgText(P ? 18 : 16, 500, 'mono')}>
|
| 941 |
+
首套房最低首付比例 · 非限购城市 · 中国人民银行
|
| 942 |
+
</text>
|
| 943 |
+
</svg>
|
| 944 |
+
<Beat k={5} x={M} y={P ? 1060 : 330} w={P ? W - M * 2 : 640}>
|
| 945 |
+
<Tag text="DOWN PAYMENT" p={p(5, 0.1)} />
|
| 946 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 30, marginTop: 14 }}>
|
| 947 |
+
<Big v="15%" p={p(5, 3.4, 1.4)} size={P ? 160 : 170} color={C.goldHi} />
|
| 948 |
+
<Chip kind="no" text="说反了" p={p(5, 4.4)} size={P ? 26 : 24} />
|
| 949 |
+
</div>
|
| 950 |
+
<T p={p(5, 4.2)} style={{ ...cn(P ? 30 : 28, 700), marginTop: 8 }}>
|
| 951 |
+
1998 年以来最低
|
| 952 |
+
</T>
|
| 953 |
+
<T p={p(5, 4.8)} style={{ ...cn(P ? 24 : 23, 500, C.mute), marginTop: 12 }}>
|
| 954 |
+
30% → 25% → 20% → 15%,一路下调
|
| 955 |
+
</T>
|
| 956 |
+
</Beat>
|
| 957 |
+
</>
|
| 958 |
+
)
|
| 959 |
+
})()}
|
| 960 |
+
</>
|
| 961 |
+
)
|
| 962 |
+
}
|
| 963 |
+
|
kkndme/frontend/src/rv/scenesC.tsx
ADDED
|
@@ -0,0 +1,974 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// 三把尺子 · 自信校准 · 盲区 · 未到期 · 结语
|
| 2 |
+
import React from 'react'
|
| 3 |
+
import { C, E, clamp, hexA, lerp, spr, tw, rand, STATUS_COLOR } from './theme'
|
| 4 |
+
import { useS } from './ctx'
|
| 5 |
+
import { Chip, Icon, txtStyle, goldText, shineStyle, Chars } from './ui'
|
| 6 |
+
import { Beat, Big, Card, Quote, Stamp, T, Tag, Ring, cn, mono, serif, useP, useVis, Dot } from './kit'
|
| 7 |
+
import { Grid, Series, SvgDot, linePath, smoothPath, sx, sy, svgText, type Fr } from './charts'
|
| 8 |
+
import { rows, bySpec, byBold, byType, byTopic, brier, BRIER } from '../data/science'
|
| 9 |
+
import { CtaCard } from './brand'
|
| 10 |
+
import { CTA_AT, CTA_IN, wordAt } from '../video/script'
|
| 11 |
+
|
| 12 |
+
const pct = (v: number) => Math.round(v * 100)
|
| 13 |
+
const hitColor = (h: number) => (h >= 0.6 ? C.green : h >= 0.5 ? C.amber : C.red)
|
| 14 |
+
|
| 15 |
+
// ================= 三把尺子 =================
|
| 16 |
+
const RULERS = [
|
| 17 |
+
{ no: '01', name: '具体程度', items: bySpec.map((x) => ({ l: x.label, h: x.r.hit })) },
|
| 18 |
+
{ no: '02', name: '是否逆共识', items: byBold.map((x) => ({ l: x.label, h: x.r.hit })) },
|
| 19 |
+
{ no: '03', name: '赌的是什么', items: byType.map((x) => ({ l: x.label, h: x.r.hit })) },
|
| 20 |
+
]
|
| 21 |
+
|
| 22 |
+
function Ruler({ x, y, w, items, p, k, hlLow, fs }: { x: number; y: number; w: number; items: { l: string; h: number }[]; p: number; k: number; hlLow?: boolean; fs: number }) {
|
| 23 |
+
const S = useS()
|
| 24 |
+
const X = (v: number) => x + v * w
|
| 25 |
+
const sorted = [...items].sort((a, b) => a.h - b.h)
|
| 26 |
+
return (
|
| 27 |
+
<g>
|
| 28 |
+
{/* 刻度 */}
|
| 29 |
+
<line x1={x} x2={x + w * E.out(p)} y1={y} y2={y} stroke="rgba(243,238,228,0.45)" strokeWidth={2} />
|
| 30 |
+
{Array.from({ length: 21 }, (_, i) => {
|
| 31 |
+
const q = clamp(p * 2.2 - i * 0.04)
|
| 32 |
+
const major = i % 2 === 0
|
| 33 |
+
return (
|
| 34 |
+
<g key={i} opacity={q}>
|
| 35 |
+
<line x1={X(i / 20)} x2={X(i / 20)} y1={y - (major ? 12 : 6)} y2={y} stroke="rgba(243,238,228,0.4)" strokeWidth={1.4} />
|
| 36 |
+
{i % 5 === 0 && (
|
| 37 |
+
<text x={X(i / 20)} y={y + 24} textAnchor="middle" fill={C.dim} style={svgText(14, 500, 'mono')}>
|
| 38 |
+
{`${i * 5}%`}
|
| 39 |
+
</text>
|
| 40 |
+
)}
|
| 41 |
+
</g>
|
| 42 |
+
)
|
| 43 |
+
})}
|
| 44 |
+
{/* 抛硬币 50% */}
|
| 45 |
+
<g opacity={tw(S.lt(2), 0.4, 0.8) * p}>
|
| 46 |
+
<line x1={X(0.5)} x2={X(0.5)} y1={y - 70} y2={y + 70} stroke={hexA(C.ink, 0.35)} strokeWidth={1.5} strokeDasharray="4 6" />
|
| 47 |
+
</g>
|
| 48 |
+
{sorted.map((it, i) => {
|
| 49 |
+
const q = tw(S.lt(k), 1.0 + i * 0.55, 1.2, E.out3)
|
| 50 |
+
if (q <= 0) return null
|
| 51 |
+
const up = i % 2 === 0
|
| 52 |
+
const vx = X(it.h * q)
|
| 53 |
+
const col = hitColor(it.h)
|
| 54 |
+
const len = 58 * E.out(clamp(q * 1.5))
|
| 55 |
+
const low = hlLow && it.h < 0.5
|
| 56 |
+
return (
|
| 57 |
+
<g key={it.l}>
|
| 58 |
+
<line x1={vx} x2={vx} y1={y} y2={up ? y - len : y + len} stroke={col} strokeWidth={2} />
|
| 59 |
+
<circle cx={vx} cy={y} r={9} fill={col} stroke="#0A0B0F" strokeWidth={2.5} />
|
| 60 |
+
{low && <circle cx={vx} cy={y} r={14 + ((S.t * 0.9) % 1) * 20} fill="none" stroke={col} strokeWidth={2} opacity={1 - ((S.t * 0.9) % 1)} />}
|
| 61 |
+
<text x={vx} y={up ? y - len - fs * 1.85 : y + len + fs * 1.05} textAnchor="middle" fill={C.ink2} opacity={clamp(q * 2)} style={svgText(fs - 2, 600, 'cn')}>
|
| 62 |
+
{it.l}
|
| 63 |
+
</text>
|
| 64 |
+
<text x={vx} y={up ? y - len - 8 : y + len + fs * 2.6} textAnchor="middle" fill={C.ink} opacity={clamp(q * 2)} style={svgText(fs + 4, 800, 'num')}>
|
| 65 |
+
{`${Math.round(it.h * 100 * q)}%`}
|
| 66 |
+
</text>
|
| 67 |
+
</g>
|
| 68 |
+
)
|
| 69 |
+
})}
|
| 70 |
+
</g>
|
| 71 |
+
)
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
export function Rulers() {
|
| 75 |
+
const S = useS()
|
| 76 |
+
const { P, W, H, M } = S
|
| 77 |
+
const p = useP()
|
| 78 |
+
const vis = useVis()
|
| 79 |
+
const fs = P ? 24 : 22
|
| 80 |
+
const rx = P ? M + 30 : 560
|
| 81 |
+
const rw = P ? W - M * 2 - 60 : W - M - 600
|
| 82 |
+
const ys = P ? [640, 960, 1280] : [360, 575, 790]
|
| 83 |
+
const cur = [1, 2, 3].reduce((a, i) => (S.lt(i) >= 0 ? i : a), 0)
|
| 84 |
+
const allA = vis(1, 4)
|
| 85 |
+
return (
|
| 86 |
+
<>
|
| 87 |
+
<Beat k={0} to={1} x={0} y={P ? 640 : 330} w={W} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
| 88 |
+
<T p={p(0, 0.1)} style={{ ...serif(P ? 64 : 76), textAlign: 'center' }}>
|
| 89 |
+
同一个人,
|
| 90 |
+
</T>
|
| 91 |
+
<T p={p(0, 0.7)} style={{ ...serif(P ? 64 : 76), textAlign: 'center', marginTop: 8 }}>
|
| 92 |
+
<span>为什么</span>
|
| 93 |
+
<span style={{ color: C.green }}>有时神准</span>
|
| 94 |
+
<span>,</span>
|
| 95 |
+
<span style={{ color: C.red }}>有时离谱</span>
|
| 96 |
+
</T>
|
| 97 |
+
<div style={{ display: 'flex', gap: P ? 24 : 40, marginTop: P ? 70 : 64 }}>
|
| 98 |
+
{RULERS.map((r, i) => (
|
| 99 |
+
<T key={r.no} p={p(0, 2.4 + i * 0.3)}>
|
| 100 |
+
<Card pad={P ? '22px 26px' : '24px 34px'} style={{ textAlign: 'center' }}>
|
| 101 |
+
<div style={mono(16, C.gold, 700, 3)}>{`RULER ${r.no}`}</div>
|
| 102 |
+
<div style={{ ...cn(P ? 30 : 32, 800), marginTop: 10 }}>{r.name}</div>
|
| 103 |
+
</Card>
|
| 104 |
+
</T>
|
| 105 |
+
))}
|
| 106 |
+
</div>
|
| 107 |
+
</Beat>
|
| 108 |
+
|
| 109 |
+
{allA > 0.001 && (
|
| 110 |
+
<>
|
| 111 |
+
{RULERS.map((r, i) => {
|
| 112 |
+
const a = vis(i + 1, 4)
|
| 113 |
+
if (a <= 0.001) return null
|
| 114 |
+
const dim = cur === i + 1 ? 1 : 0.38
|
| 115 |
+
return (
|
| 116 |
+
<div key={r.no} style={{ position: 'absolute', left: P ? M : M, top: P ? ys[i] - 200 : ys[i] - 30, width: P ? W - M * 2 : 380, opacity: a * dim }}>
|
| 117 |
+
<div style={mono(16, C.gold, 700, 3)}>{`RULER ${r.no}`}</div>
|
| 118 |
+
<div style={{ ...serif(P ? 44 : 44), marginTop: 6 }}>{r.name}</div>
|
| 119 |
+
</div>
|
| 120 |
+
)
|
| 121 |
+
})}
|
| 122 |
+
<svg width={W} height={H} style={{ position: 'absolute', left: 0, top: 0 }}>
|
| 123 |
+
{RULERS.map((r, i) => {
|
| 124 |
+
const a = vis(i + 1, 4)
|
| 125 |
+
if (a <= 0.001) return null
|
| 126 |
+
const dim = cur === i + 1 ? 1 : 0.38
|
| 127 |
+
return (
|
| 128 |
+
<g key={r.no} opacity={a * dim}>
|
| 129 |
+
<Ruler x={rx} y={ys[i]} w={rw} items={r.items} p={p(i + 1, 0.1, 1.2)} k={i + 1} hlLow={i !== 1} fs={fs} />
|
| 130 |
+
</g>
|
| 131 |
+
)
|
| 132 |
+
})}
|
| 133 |
+
<text x={rx + rw * 0.5} y={ys[1] + 104} textAnchor="middle" fill={C.mute} opacity={tw(S.lt(2), 0.6, 0.8) * (cur === 2 ? 1 : 0.4) * vis(2, 4)} style={svgText(fs - 4, 600, 'cn')}>
|
| 134 |
+
抛硬币 50%
|
| 135 |
+
</text>
|
| 136 |
+
</svg>
|
| 137 |
+
</>
|
| 138 |
+
)}
|
| 139 |
+
|
| 140 |
+
<Beat k={4} x={M} y={P ? 520 : 300} w={W - M * 2}>
|
| 141 |
+
<T p={p(4, 0.1)} style={{ ...serif(P ? 56 : 60), textAlign: 'center' }}>
|
| 142 |
+
结论很清晰
|
| 143 |
+
</T>
|
| 144 |
+
<div style={{ display: 'grid', gridTemplateColumns: P ? '1fr' : '1fr 1fr', gap: P ? 30 : 40, marginTop: P ? 50 : 50 }}>
|
| 145 |
+
{[
|
| 146 |
+
{ k: 'ok' as const, h: '他擅长', a: '讲逻辑', b: '判方向', col: C.green, n: '政策 79% · 城市 78%' },
|
| 147 |
+
{ k: 'no' as const, h: '他不擅长', a: '报数字', b: '掐时间', col: C.red, n: '幅度 30% · 时间点 40%' },
|
| 148 |
+
].map((c, i) => (
|
| 149 |
+
<T key={c.h} p={p(4, 0.8 + i * 1.6)}>
|
| 150 |
+
<Card tint={c.col} glow={c.col} pad={P ? 36 : 44}>
|
| 151 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 18 }}>
|
| 152 |
+
<Icon kind={c.k} size={P ? 56 : 60} p={p(4, 1.0 + i * 1.6)} />
|
| 153 |
+
<div style={cn(P ? 34 : 34, 800, c.col)}>{c.h}</div>
|
| 154 |
+
</div>
|
| 155 |
+
<div style={{ display: 'flex', gap: 30, marginTop: 22 }}>
|
| 156 |
+
<div style={serif(P ? 76 : 84)}>{c.a}</div>
|
| 157 |
+
<div style={serif(P ? 76 : 84)}>{c.b}</div>
|
| 158 |
+
</div>
|
| 159 |
+
<div style={{ ...mono(P ? 20 : 19, C.mute, 600, 1), marginTop: 18 }}>{c.n}</div>
|
| 160 |
+
</Card>
|
| 161 |
+
</T>
|
| 162 |
+
))}
|
| 163 |
+
</div>
|
| 164 |
+
</Beat>
|
| 165 |
+
</>
|
| 166 |
+
)
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
// ================= 自信校准 =================
|
| 170 |
+
const ABS_N = rows.filter((r) => /一定|肯定|不可能|绝对|必然|永远/.test(r.quote)).length
|
| 171 |
+
const WORDS = ['一定', '肯定', '不可能', '必然', '绝对', '永远']
|
| 172 |
+
const CURVE: [number, number][] = Array.from({ length: 51 }, (_, i) => [0.5 + i * 0.01, brier(0.5 + i * 0.01)])
|
| 173 |
+
const BEST = CURVE.reduce((a, b) => (b[1] < a[1] ? b : a))
|
| 174 |
+
|
| 175 |
+
export function Brier() {
|
| 176 |
+
const S = useS()
|
| 177 |
+
const { P, W, H, M } = S
|
| 178 |
+
const p = useP()
|
| 179 |
+
const vis = useVis()
|
| 180 |
+
const fs = P ? 22 : 20
|
| 181 |
+
const cx = W / 2
|
| 182 |
+
const cy = P ? 860 : 560
|
| 183 |
+
return (
|
| 184 |
+
<>
|
| 185 |
+
{/* 0:绝对化用词 */}
|
| 186 |
+
<Beat k={0} to={1} x={0} y={0} w={W} h={H} rise={0}>
|
| 187 |
+
{WORDS.map((wd, i) => {
|
| 188 |
+
const ang = (i / WORDS.length) * Math.PI * 2 - Math.PI / 2 + S.t * 0.08
|
| 189 |
+
const R = P ? 380 : 400
|
| 190 |
+
const ry = P ? 1 : 0.62
|
| 191 |
+
const q = spr(S.lt(0) - 0.6 - i * 0.18, { k: 9, z: 0.5 })
|
| 192 |
+
const x = cx + Math.cos(ang) * R * lerp(1.6, 1, clamp(q))
|
| 193 |
+
const y = cy + Math.sin(ang) * R * ry * lerp(1.6, 1, clamp(q))
|
| 194 |
+
return (
|
| 195 |
+
<div key={wd} style={{ position: 'absolute', left: x, top: y, transform: 'translate(-50%,-50%)', opacity: clamp(q) * (0.55 + 0.45 * Math.sin(S.t * 1.4 + i)), ...serif(P ? 52 : 56, i % 2 ? C.ink2 : C.goldHi), filter: `blur(${((1 - clamp(q)) * 10).toFixed(1)}px)` }}>
|
| 196 |
+
{`“${wd}”`}
|
| 197 |
+
</div>
|
| 198 |
+
)
|
| 199 |
+
})}
|
| 200 |
+
<div style={{ position: 'absolute', left: 0, top: cy - (P ? 150 : 140), width: W, display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
| 201 |
+
<Big v={String(ABS_N)} p={p(0, 1.2, 1.6)} size={P ? 200 : 210} unit="条" />
|
| 202 |
+
<T p={p(0, 2.4)} style={{ ...cn(P ? 28 : 28, 700, C.ink2), marginTop: 6, textAlign: 'center' }}>
|
| 203 |
+
{`123 条预测里,原话带着绝对化字眼`}
|
| 204 |
+
</T>
|
| 205 |
+
</div>
|
| 206 |
+
</Beat>
|
| 207 |
+
|
| 208 |
+
{/* 1:公式 */}
|
| 209 |
+
<Beat k={1} to={2} x={M} y={P ? 470 : 300} w={W - M * 2} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
| 210 |
+
<Tag text="BRIER SCORE · 布里尔分数" p={p(1, 0.1)} />
|
| 211 |
+
<T p={p(1, 0.4)} style={{ ...serif(P ? 54 : 60), marginTop: 20 }}>
|
| 212 |
+
衡量“自信度准不准”
|
| 213 |
+
</T>
|
| 214 |
+
<T p={p(1, 1.6)} style={{ marginTop: P ? 50 : 44 }}>
|
| 215 |
+
<Card tint={C.gold} glow={C.gold} pad={P ? '34px 30px' : '34px 56px'}>
|
| 216 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: P ? 14 : 22, ...txtStyle({ f: 'serif', size: P ? 46 : 58, w: 900 }) }}>
|
| 217 |
+
<span style={{ color: C.dim }}>(</span>
|
| 218 |
+
<span>说出的把握</span>
|
| 219 |
+
<span style={{ color: C.gold }}>−</span>
|
| 220 |
+
<span>实际结果</span>
|
| 221 |
+
<span style={{ color: C.dim }}>)²</span>
|
| 222 |
+
</div>
|
| 223 |
+
<div style={{ ...cn(P ? 24 : 24, 500, C.mute), marginTop: 16, textAlign: 'center' }}>对每条预测求平均 · 说对记 1,说错记 0,参半记 0.5</div>
|
| 224 |
+
</Card>
|
| 225 |
+
</T>
|
| 226 |
+
{/* 刻度:0 全知 → 0.25 五五开 */}
|
| 227 |
+
<div style={{ position: 'relative', width: P ? 860 : 1100, height: 120, marginTop: P ? 70 : 54 }}>
|
| 228 |
+
{(() => {
|
| 229 |
+
const q = p(1, 4.0, 1.4)
|
| 230 |
+
const w = P ? 860 : 1100
|
| 231 |
+
return (
|
| 232 |
+
<>
|
| 233 |
+
<div style={{ position: 'absolute', left: 0, top: 40, width: w * E.out(q), height: 10, borderRadius: 5, background: `linear-gradient(90deg, ${C.green}, ${C.amber} 50%, ${C.red})`, opacity: 0.85 }} />
|
| 234 |
+
{[
|
| 235 |
+
{ v: 0, l: '0 · 全知全能' },
|
| 236 |
+
{ v: 0.5, l: '0.25 · 五五开' },
|
| 237 |
+
{ v: 1, l: '0.5 · 全靠反着猜' },
|
| 238 |
+
].map((m, i) => (
|
| 239 |
+
<div key={m.l} style={{ position: 'absolute', left: m.v * w, top: 66, transform: `translateX(${i === 0 ? 0 : i === 2 ? -100 : -50}%)`, opacity: p(1, 4.4 + i * 0.4), ...mono(P ? 18 : 18, C.ink2, 600, 1), whiteSpace: 'nowrap' }}>
|
| 240 |
+
{m.l}
|
| 241 |
+
</div>
|
| 242 |
+
))}
|
| 243 |
+
<div style={{ position: 'absolute', left: 0, top: 0, opacity: p(1, 5.0), ...cn(22, 800, C.green) }}>← 越低越好</div>
|
| 244 |
+
</>
|
| 245 |
+
)
|
| 246 |
+
})()}
|
| 247 |
+
</div>
|
| 248 |
+
</Beat>
|
| 249 |
+
|
| 250 |
+
{/* 2:比较 */}
|
| 251 |
+
<Beat k={2} to={3} x={M} y={P ? 480 : 310} w={W - M * 2}>
|
| 252 |
+
<Tag text="IF EVERY CALL WERE SAID WITH…" p={p(2, 0.1)} />
|
| 253 |
+
{(() => {
|
| 254 |
+
const bw = P ? 640 : 1120
|
| 255 |
+
const sc = 0.3
|
| 256 |
+
const items = [
|
| 257 |
+
{ l: 'KKndme · 九成把握', v: BRIER.kk90, col: C.red, d: 0.8 },
|
| 258 |
+
{ l: 'KKndme · 八成把握', v: BRIER.kk80, col: C.red, d: 2.8 },
|
| 259 |
+
{ l: '每句都说“五五开”', v: BRIER.coin, col: C.gray, d: 5.0 },
|
| 260 |
+
]
|
| 261 |
+
const lineP = p(2, 5.0)
|
| 262 |
+
return (
|
| 263 |
+
<div style={{ position: 'relative', marginTop: 30 }}>
|
| 264 |
+
{items.map((it, i) => {
|
| 265 |
+
const q = p(2, it.d, 1.4, E.out3)
|
| 266 |
+
return (
|
| 267 |
+
<div key={it.l} style={{ marginTop: i ? (P ? 40 : 34) : 0, opacity: clamp(q * 2) }}>
|
| 268 |
+
<div style={cn(P ? 30 : 28, 700, i === 2 ? C.mute : C.ink)}>{it.l}</div>
|
| 269 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 20, marginTop: 12 }}>
|
| 270 |
+
<div style={{ height: P ? 46 : 44, width: (bw * it.v * E.out(q)) / sc, borderRadius: 8, background: i === 2 ? 'linear-gradient(90deg, rgba(142,147,156,0.3), rgba(142,147,156,0.8))' : `linear-gradient(90deg, ${hexA(it.col, 0.3)}, ${it.col})`, boxShadow: i === 2 ? undefined : `0 0 30px ${hexA(it.col, 0.3)}` }} />
|
| 271 |
+
<div style={txtStyle({ f: 'num', size: P ? 50 : 50, w: 800, color: i === 2 ? C.ink2 : C.ink })}>{(it.v * clamp(q)).toFixed(3)}</div>
|
| 272 |
+
</div>
|
| 273 |
+
</div>
|
| 274 |
+
)
|
| 275 |
+
})}
|
| 276 |
+
{lineP > 0 && (
|
| 277 |
+
<div style={{ position: 'absolute', left: (bw * BRIER.coin) / sc, top: -10, bottom: -10, width: 2, borderLeft: `2px dashed ${hexA(C.ink, 0.5)}`, opacity: lineP }} />
|
| 278 |
+
)}
|
| 279 |
+
<T p={p(2, 6.6)} style={{ marginTop: P ? 50 : 34 }}>
|
| 280 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 18 }}>
|
| 281 |
+
<Chip kind="no" text="都比“五五开”还差" p={p(2, 6.8)} size={P ? 26 : 24} />
|
| 282 |
+
<div style={cn(P ? 24 : 22, 500, C.dim)}>分数越低越好</div>
|
| 283 |
+
</div>
|
| 284 |
+
</T>
|
| 285 |
+
</div>
|
| 286 |
+
)
|
| 287 |
+
})()}
|
| 288 |
+
</Beat>
|
| 289 |
+
|
| 290 |
+
{/* 3:校准曲线 */}
|
| 291 |
+
{(() => {
|
| 292 |
+
const a = vis(3)
|
| 293 |
+
if (a <= 0.001) return null
|
| 294 |
+
const f: Fr = P ? { x: 170, y: 480, w: 800, h: 480, x0: 0.5, x1: 1, y0: 0.15, y1: 0.3 } : { x: 900, y: 320, w: 840, h: 480, x0: 0.5, x1: 1, y0: 0.15, y1: 0.3 }
|
| 295 |
+
const q = p(3, 0.3, 2.4, E.inOut)
|
| 296 |
+
const bq = p(3, 2.6, 0.8)
|
| 297 |
+
return (
|
| 298 |
+
<>
|
| 299 |
+
<svg width={W} height={H} style={{ position: 'absolute', left: 0, top: 0, opacity: a }}>
|
| 300 |
+
<Grid f={f} yt={[0.15, 0.2, 0.25, 0.3]} xt={[0.5, 0.6, 0.7, 0.8, 0.9, 1]} fy={(v) => v.toFixed(2)} fx={(v) => `${Math.round(v * 100)}%`} p={p(3, 0.1, 1.2)} size={fs} />
|
| 301 |
+
<Series id="cv" d={smoothPath(f, CURVE)} p={q} color={C.ink} width={3.5} area={0.14} baseY={f.y + f.h} clipX={[f.x, f.x + f.w]} />
|
| 302 |
+
{[0.8, 0.9].map((v, i) => {
|
| 303 |
+
const o = p(3, 1.2 + i * 0.4, 0.6)
|
| 304 |
+
return (
|
| 305 |
+
<g key={v} opacity={o}>
|
| 306 |
+
<SvgDot id={'k' + v} x={sx(f, v)} y={sy(f, brier(v))} r={8} color={C.red} o={1} />
|
| 307 |
+
<text x={sx(f, v) - 16} y={sy(f, brier(v)) + 6} textAnchor="end" fill={C.red} style={svgText(fs, 800, 'cn')}>
|
| 308 |
+
{`KKndme ${Math.round(v * 100)}%`}
|
| 309 |
+
</text>
|
| 310 |
+
</g>
|
| 311 |
+
)
|
| 312 |
+
})}
|
| 313 |
+
<g opacity={bq}>
|
| 314 |
+
<line x1={sx(f, BEST[0])} x2={sx(f, BEST[0])} y1={f.y + f.h} y2={sy(f, BEST[1])} stroke={C.green} strokeWidth={2} strokeDasharray="5 6" />
|
| 315 |
+
<SvgDot id="best" x={sx(f, BEST[0])} y={sy(f, BEST[1])} r={10} color={C.green} o={1} pulse={(S.t * 0.8) % 1} />
|
| 316 |
+
<text x={sx(f, BEST[0]) + 20} y={sy(f, BEST[1]) - 22} fill={C.green} style={svgText(fs + 6, 800, 'cn')}>
|
| 317 |
+
{`六成把握 · ${BEST[1].toFixed(3)} 最佳`}
|
| 318 |
+
</text>
|
| 319 |
+
</g>
|
| 320 |
+
<text x={f.x + f.w} y={f.y + f.h + (P ? 76 : 70)} textAnchor="end" fill={C.mute} opacity={p(3, 0.6)} style={svgText(fs - 2, 600, 'cn')}>
|
| 321 |
+
说出的把握 →
|
| 322 |
+
</text>
|
| 323 |
+
<text x={f.x} y={f.y - 20} fill={C.mute} opacity={p(3, 0.6)} style={svgText(fs - 2, 600, 'cn')}>
|
| 324 |
+
布里尔分数(越低越好)
|
| 325 |
+
</text>
|
| 326 |
+
</svg>
|
| 327 |
+
<Beat k={3} x={M} y={P ? 1090 : 330} w={P ? W - M * 2 : 640}>
|
| 328 |
+
<Tag text="CALIBRATION" p={p(3, 0.1)} />
|
| 329 |
+
<T p={p(3, 3.4)} style={{ ...serif(P ? 50 : 52), marginTop: 22 }}>
|
| 330 |
+
神贴最大的问题,
|
| 331 |
+
</T>
|
| 332 |
+
<T p={p(3, 4.2)} style={{ ...serif(P ? 50 : 52), marginTop: 8 }}>
|
| 333 |
+
<span>不是看错,而是</span>
|
| 334 |
+
<span style={{ ...goldText(), fontWeight: 900 }}>太笃定</span>
|
| 335 |
+
</T>
|
| 336 |
+
</Beat>
|
| 337 |
+
</>
|
| 338 |
+
)
|
| 339 |
+
})()}
|
| 340 |
+
</>
|
| 341 |
+
)
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
// ================= 盲区 =================
|
| 345 |
+
const RENT = rows.filter((r) => r.topic === '租金与保障房')
|
| 346 |
+
const BENCH: [number, number][] = [
|
| 347 |
+
[2010.0, 5.94],
|
| 348 |
+
[2010.95, 5.94],
|
| 349 |
+
[2011.0, 6.4],
|
| 350 |
+
[2011.5, 6.4],
|
| 351 |
+
[2011.55, 7.05],
|
| 352 |
+
[2012.5, 7.05],
|
| 353 |
+
[2012.55, 6.55],
|
| 354 |
+
[2014.85, 6.55],
|
| 355 |
+
[2014.9, 6.15],
|
| 356 |
+
[2015.75, 6.15],
|
| 357 |
+
[2015.8, 4.9],
|
| 358 |
+
[2019.6, 4.9],
|
| 359 |
+
]
|
| 360 |
+
const LPR: [number, number][] = [
|
| 361 |
+
[2019.65, 4.85],
|
| 362 |
+
[2020.3, 4.85],
|
| 363 |
+
[2020.32, 4.65],
|
| 364 |
+
[2022.05, 4.65],
|
| 365 |
+
[2022.07, 4.6],
|
| 366 |
+
[2022.4, 4.6],
|
| 367 |
+
[2022.42, 4.45],
|
| 368 |
+
[2022.65, 4.45],
|
| 369 |
+
[2022.67, 4.3],
|
| 370 |
+
[2023.45, 4.3],
|
| 371 |
+
[2023.47, 4.2],
|
| 372 |
+
[2024.15, 4.2],
|
| 373 |
+
[2024.17, 3.95],
|
| 374 |
+
[2024.55, 3.95],
|
| 375 |
+
[2024.57, 3.85],
|
| 376 |
+
[2024.8, 3.85],
|
| 377 |
+
[2024.82, 3.6],
|
| 378 |
+
[2025.4, 3.6],
|
| 379 |
+
[2025.42, 3.5],
|
| 380 |
+
[2026.8, 3.5],
|
| 381 |
+
]
|
| 382 |
+
|
| 383 |
+
export function Blind() {
|
| 384 |
+
const S = useS()
|
| 385 |
+
const { P, W, H, M } = S
|
| 386 |
+
const p = useP()
|
| 387 |
+
const vis = useVis()
|
| 388 |
+
const fs = P ? 22 : 20
|
| 389 |
+
return (
|
| 390 |
+
<>
|
| 391 |
+
{/* 0 */}
|
| 392 |
+
<Beat k={0} to={1} x={M} y={P ? 520 : 320} w={W - M * 2} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
| 393 |
+
<Tag text="BLIND SPOTS" p={p(0, 0.1)} color={C.red} />
|
| 394 |
+
<T p={p(0, 0.3)} style={{ ...serif(P ? 64 : 72), marginTop: 22 }}>
|
| 395 |
+
他的盲区
|
| 396 |
+
</T>
|
| 397 |
+
<div style={{ display: 'flex', flexDirection: P ? 'column' : 'row', gap: P ? 24 : 40, marginTop: P ? 50 : 56, width: P ? '100%' : undefined }}>
|
| 398 |
+
{['租金', '人口', '利率'].map((t, i) => {
|
| 399 |
+
const q = spr(S.lt(0) - 1.6 - i * 0.45, { k: 9, z: 0.55 })
|
| 400 |
+
return (
|
| 401 |
+
<div key={t} style={{ opacity: clamp(q * 2), transform: `translateY(${((1 - clamp(q)) * 40).toFixed(1)}px)` }}>
|
| 402 |
+
<Card tint={C.red} pad={P ? '28px 40px' : '40px 64px'} style={{ textAlign: 'center' }}>
|
| 403 |
+
<div style={mono(16, C.red, 700, 3)}>{`0${i + 1}`}</div>
|
| 404 |
+
<div style={{ ...serif(P ? 64 : 72), marginTop: 8 }}>{t}</div>
|
| 405 |
+
</Card>
|
| 406 |
+
</div>
|
| 407 |
+
)
|
| 408 |
+
})}
|
| 409 |
+
</div>
|
| 410 |
+
</Beat>
|
| 411 |
+
|
| 412 |
+
{/* 1:租金 */}
|
| 413 |
+
<Beat k={1} to={2} x={M} y={P ? 440 : 300} w={W - M * 2} style={{ display: 'flex', flexDirection: P ? 'column' : 'row', gap: P ? 50 : 90 }}>
|
| 414 |
+
<div style={{ width: P ? '100%' : 760 }}>
|
| 415 |
+
<Quote text="“房租收入下降基本是做梦才会出现的事情”" t={S.lt(1) - 0.2} size={P ? 40 : 40} />
|
| 416 |
+
<T p={p(1, 3.2)} style={{ ...cn(P ? 28 : 26, 600, C.mute), marginTop: 30 }}>
|
| 417 |
+
现实:2022 年起,全国住宅租金连年下跌
|
| 418 |
+
</T>
|
| 419 |
+
<div style={{ display: 'flex', alignItems: 'baseline', gap: 16, marginTop: 10 }}>
|
| 420 |
+
<Big v="0" p={p(1, 4.4, 1)} size={P ? 180 : 190} color={C.red} />
|
| 421 |
+
<div style={serif(P ? 60 : 64, C.mute)}>/ 5</div>
|
| 422 |
+
<div style={{ ...cn(P ? 28 : 26, 700), marginLeft: 12 }}>租金类预测 说中</div>
|
| 423 |
+
</div>
|
| 424 |
+
</div>
|
| 425 |
+
<div style={{ flex: 1, display: 'flex', flexDirection: 'column', gap: 14, marginTop: P ? 0 : 10 }}>
|
| 426 |
+
{RENT.map((r, i) => {
|
| 427 |
+
const q = p(1, 4.6 + i * 0.25)
|
| 428 |
+
const st = r.status
|
| 429 |
+
return (
|
| 430 |
+
<T key={r.id} p={q}>
|
| 431 |
+
<Card pad="16px 22px" tint={STATUS_COLOR[st]}>
|
| 432 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
|
| 433 |
+
<Icon kind={st === 'wrong' ? 'no' : 'mid'} size={30} p={q} />
|
| 434 |
+
<div style={{ ...cn(P ? 23 : 21, 600, C.ink2), flex: 1, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>{r.quote.replace(/^“/, '').slice(0, P ? 22 : 24) + '…'}</div>
|
| 435 |
+
</div>
|
| 436 |
+
</Card>
|
| 437 |
+
</T>
|
| 438 |
+
)
|
| 439 |
+
})}
|
| 440 |
+
</div>
|
| 441 |
+
</Beat>
|
| 442 |
+
|
| 443 |
+
{/* 2:人口 */}
|
| 444 |
+
<Beat k={2} to={3} x={M} y={P ? 420 : 290} w={W - M * 2} style={{ display: 'flex', flexDirection: P ? 'column' : 'row', gap: P ? 40 : 90, alignItems: P ? 'stretch' : 'center' }}>
|
| 445 |
+
<div style={{ width: P ? '100%' : 620 }}>
|
| 446 |
+
<Quote text="“三四线城市人口还会缓慢增长”" t={S.lt(2) - 0.2} size={P ? 40 : 40} />
|
| 447 |
+
<T p={p(2, 2.4)} style={{ ...mono(18, C.dim, 600, 2), marginTop: 30 }}>
|
| 448 |
+
第七次全国人口普查 · 2020 vs 2010
|
| 449 |
+
</T>
|
| 450 |
+
<div style={{ display: 'flex', alignItems: 'baseline', gap: 14, marginTop: 6 }}>
|
| 451 |
+
<Big v="149" p={p(2, 2.8, 1.6)} size={P ? 150 : 150} color={C.red} />
|
| 452 |
+
<div style={cn(P ? 30 : 28, 700, C.mute)}>/ 337 城人口减少</div>
|
| 453 |
+
</div>
|
| 454 |
+
<T p={p(2, 6.2)} style={{ display: 'flex', alignItems: 'baseline', gap: 16, marginTop: 10 }}>
|
| 455 |
+
<div style={cn(P ? 28 : 28, 700)}>东北十年</div>
|
| 456 |
+
<div style={txtStyle({ f: 'num', size: P ? 64 : 64, w: 800, color: C.red })}>−1,101 万</div>
|
| 457 |
+
</T>
|
| 458 |
+
</div>
|
| 459 |
+
{/* 337 格 */}
|
| 460 |
+
<div style={{ display: 'grid', gridTemplateColumns: `repeat(${P ? 24 : 20}, 1fr)`, gap: P ? 8 : 9, flex: 1 }}>
|
| 461 |
+
{Array.from({ length: 337 }, (_, i) => {
|
| 462 |
+
const shrink = rand(i, 7) < 149 / 337
|
| 463 |
+
const q = p(2, 2.6 + rand(i, 3) * 2.2, 0.5)
|
| 464 |
+
const s = P ? 30 : 30
|
| 465 |
+
return <div key={i} style={{ height: s, borderRadius: 5, background: shrink ? hexA(C.red, 0.15 + 0.7 * q) : `rgba(243,238,228,${(0.06 + 0.06 * q).toFixed(3)})`, boxShadow: shrink && q > 0.7 ? `0 0 10px ${hexA(C.red, 0.35)}` : undefined }} />
|
| 466 |
+
})}
|
| 467 |
+
</div>
|
| 468 |
+
</Beat>
|
| 469 |
+
|
| 470 |
+
{/* 3:利率 */}
|
| 471 |
+
{(() => {
|
| 472 |
+
const a = vis(3, 4)
|
| 473 |
+
if (a <= 0.001) return null
|
| 474 |
+
const f: Fr = P ? { x: 170, y: 470, w: 800, h: 460, x0: 2010, x1: 2026.8, y0: 2.5, y1: 7.5 } : { x: 900, y: 310, w: 840, h: 480, x0: 2010, x1: 2026.8, y0: 2.5, y1: 7.5 }
|
| 475 |
+
return (
|
| 476 |
+
<>
|
| 477 |
+
<svg width={W} height={H} style={{ position: 'absolute', left: 0, top: 0, opacity: a }}>
|
| 478 |
+
<Grid f={f} yt={[3, 4, 5, 6, 7]} xt={[2010, 2014, 2018, 2022, 2026]} fy={(v) => `${v}%`} p={p(3, 0.1, 1.2)} size={fs} />
|
| 479 |
+
<Series id="bench" d={linePath(f, BENCH)} p={p(3, 0.4, 2.2, E.soft)} color={C.gold} width={3.5} />
|
| 480 |
+
<Series id="lpr" d={linePath(f, LPR)} p={p(3, 2.4, 2.4, E.soft)} color={C.goldHi} width={3.5} area={0.22} baseY={f.y + f.h} clipX={[sx(f, 2019.65), f.x + f.w]} />
|
| 481 |
+
<g opacity={p(3, 1.4)}>
|
| 482 |
+
<SvgDot id="r705" x={sx(f, 2012)} y={sy(f, 7.05)} r={8} color={C.red} o={1} />
|
| 483 |
+
<text x={sx(f, 2012)} y={sy(f, 7.05) - 20} textAnchor="middle" fill={C.ink} style={svgText(fs + 4, 800, 'num')}>
|
| 484 |
+
7.05%
|
| 485 |
+
</text>
|
| 486 |
+
</g>
|
| 487 |
+
<g opacity={p(3, 4.4)}>
|
| 488 |
+
<SvgDot id="r35" x={sx(f, 2026.8)} y={sy(f, 3.5)} r={8} color={C.goldHi} o={1} />
|
| 489 |
+
<text x={sx(f, 2026.8) - 10} y={sy(f, 3.5) - 22} textAnchor="end" fill={C.ink} style={svgText(fs + 2, 800, 'num')}>
|
| 490 |
+
LPR 3.5%
|
| 491 |
+
</text>
|
| 492 |
+
<line x1={sx(f, 2024)} x2={f.x + f.w} y1={sy(f, 3.1)} y2={sy(f, 3.1)} stroke={C.green} strokeWidth={2.5} strokeDasharray="6 6" />
|
| 493 |
+
<text x={sx(f, 2024) - 10} y={sy(f, 3.1) + 8} textAnchor="end" fill={C.green} style={svgText(fs, 800, 'cn')}>
|
| 494 |
+
首套实际 ≈3.1%
|
| 495 |
+
</text>
|
| 496 |
+
</g>
|
| 497 |
+
<text x={f.x} y={f.y + f.h + (P ? 76 : 70)} fill={C.dim} opacity={p(3, 1)} style={svgText(P ? 18 : 16, 500, 'mono')}>
|
| 498 |
+
5 年以上贷款利率:2019 年前为基准利率,之后为 5 年期 LPR
|
| 499 |
+
</text>
|
| 500 |
+
</svg>
|
| 501 |
+
<Beat k={3} to={4} x={M} y={P ? 1060 : 320} w={P ? W - M * 2 : 640}>
|
| 502 |
+
<Tag text="MORTGAGE RATES" p={p(3, 0.1)} />
|
| 503 |
+
<T p={p(3, 0.3)} style={{ ...serif(P ? 52 : 52), marginTop: 18 }}>
|
| 504 |
+
利率一路走低
|
| 505 |
+
</T>
|
| 506 |
+
<T p={p(3, 1.6)} style={{ display: 'flex', alignItems: 'baseline', gap: 16, marginTop: 20 }}>
|
| 507 |
+
<div style={txtStyle({ f: 'num', size: P ? 64 : 64, w: 800 })}>6%+</div>
|
| 508 |
+
<div style={serif(46, C.gold)}>→</div>
|
| 509 |
+
<div style={{ ...txtStyle({ f: 'num', size: P ? 64 : 64, w: 800 }), ...goldText() }}>3% 出头</div>
|
| 510 |
+
</T>
|
| 511 |
+
<T p={p(3, 5.6)} style={{ ...cn(P ? 28 : 28, 700, C.ink2), marginTop: 22 }}>
|
| 512 |
+
首付降到 15%,房价却还在跌
|
| 513 |
+
</T>
|
| 514 |
+
</Beat>
|
| 515 |
+
</>
|
| 516 |
+
)
|
| 517 |
+
})()}
|
| 518 |
+
|
| 519 |
+
{/* 4:前提支柱 */}
|
| 520 |
+
<Beat k={4} x={M} y={P ? 440 : 290} w={W - M * 2} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
| 521 |
+
{(() => {
|
| 522 |
+
const crack = p(4, 3.4, 1.2, E.in)
|
| 523 |
+
const pw = P ? 300 : 300
|
| 524 |
+
const ph = P ? 360 : 300
|
| 525 |
+
const shake = crack > 0 && crack < 1 ? Math.sin(S.t * 60) * 3 * (1 - crack) : 0
|
| 526 |
+
return (
|
| 527 |
+
<>
|
| 528 |
+
{/* 屋顶 */}
|
| 529 |
+
<T p={p(4, 0.2)}>
|
| 530 |
+
<div style={{ width: P ? 760 : 820, transform: `translateY(${(crack * 34).toFixed(1)}px) rotate(${(crack * -3.5).toFixed(2)}deg)` }}>
|
| 531 |
+
<Card tint={C.gold} glow={C.gold} pad="26px 30px" style={{ textAlign: 'center' }}>
|
| 532 |
+
<div style={serif(P ? 46 : 48, C.goldHi)}>KKndme 的世界观</div>
|
| 533 |
+
<div style={{ ...cn(22, 600, C.mute), marginTop: 22 }}>房价只涨不跌 · 房子是唯一的避风港</div>
|
| 534 |
+
</Card>
|
| 535 |
+
</div>
|
| 536 |
+
</T>
|
| 537 |
+
<div style={{ display: 'flex', gap: P ? 120 : 200, marginTop: 18 }}>
|
| 538 |
+
{['人口红利', '货币扩张'].map((t, i) => {
|
| 539 |
+
const q = p(4, 0.8 + i * 0.4)
|
| 540 |
+
const c2 = clamp(crack * 1.2 - i * 0.2)
|
| 541 |
+
return (
|
| 542 |
+
<div key={t} style={{ position: 'relative', width: pw, height: ph, opacity: q, transform: `translateX(${shake.toFixed(1)}px)` }}>
|
| 543 |
+
<div style={{ position: 'absolute', left: pw / 2 - 50, top: 0, width: 100, height: ph, borderRadius: 10, background: `linear-gradient(90deg, rgba(243,238,228,0.08), rgba(243,238,228,0.22) 50%, rgba(243,238,228,0.08))`, border: '1px solid rgba(243,238,228,0.2)' }} />
|
| 544 |
+
{/* 裂纹 */}
|
| 545 |
+
{c2 > 0 && (
|
| 546 |
+
<svg width={pw} height={ph} style={{ position: 'absolute', left: 0, top: 0 }}>
|
| 547 |
+
<path d={`M${pw / 2 - 20},${ph * 0.15} L${pw / 2 + 12},${ph * 0.34} L${pw / 2 - 14},${ph * 0.5} L${pw / 2 + 18},${ph * 0.68} L${pw / 2 - 8},${ph * 0.86}`} stroke={C.red} strokeWidth={3} fill="none" strokeDasharray={`${ph * c2} ${ph}`} style={{ filter: `drop-shadow(0 0 6px ${C.red})` }} />
|
| 548 |
+
</svg>
|
| 549 |
+
)}
|
| 550 |
+
<div style={{ position: 'absolute', left: 0, width: pw, top: ph + 16, textAlign: 'center', ...serif(P ? 40 : 40, c2 > 0.5 ? C.red : C.ink) }}>{t}</div>
|
| 551 |
+
<div style={{ position: 'absolute', left: 0, width: pw, top: ph + 70, textAlign: 'center', ...cn(22, 600, C.mute), opacity: c2 }}>{i === 0 ? '→ 人口减少' : '→ 物价低迷'}</div>
|
| 552 |
+
</div>
|
| 553 |
+
)
|
| 554 |
+
})}
|
| 555 |
+
</div>
|
| 556 |
+
</>
|
| 557 |
+
)
|
| 558 |
+
})()}
|
| 559 |
+
</Beat>
|
| 560 |
+
</>
|
| 561 |
+
)
|
| 562 |
+
}
|
| 563 |
+
|
| 564 |
+
// ================= 未到期 =================
|
| 565 |
+
const PEND = [
|
| 566 |
+
{
|
| 567 |
+
grp: 'lean' as const,
|
| 568 |
+
h: '正在偏向他',
|
| 569 |
+
col: C.blue,
|
| 570 |
+
items: [
|
| 571 |
+
{ t: '人民币不会自由兑换', e: '资本项目约 60% 子项可兑换' },
|
| 572 |
+
{ t: '体制外养老是大问题', e: '2025 年起渐进式延迟退休' },
|
| 573 |
+
{ t: '百年政治判断', e: '期限 2110 年,至今一致' },
|
| 574 |
+
],
|
| 575 |
+
},
|
| 576 |
+
{
|
| 577 |
+
grp: 'against' as const,
|
| 578 |
+
h: '正在偏离他',
|
| 579 |
+
col: C.purple,
|
| 580 |
+
items: [
|
| 581 |
+
{ t: '北京核心区超过香港', e: '北京二手均价 3.65 万,较高点 −40%' },
|
| 582 |
+
{ t: '房产税将来一定会出', e: '“十五五”规划纲要未再提' },
|
| 583 |
+
],
|
| 584 |
+
},
|
| 585 |
+
{
|
| 586 |
+
grp: 'wait' as const,
|
| 587 |
+
h: '还看不清',
|
| 588 |
+
col: C.gray,
|
| 589 |
+
items: [
|
| 590 |
+
{ t: '房价不会大跌 30%–50%', e: '较 2021 高点跌约 22%,未到 30%' },
|
| 591 |
+
{ t: '20 年内楼市不崩盘', e: '期限到 2030 年' },
|
| 592 |
+
{ t: '不会重演日本', e: '跌 22%,日本当年跌约 67%' },
|
| 593 |
+
{ t: '城中村一定会消失', e: '35 城仍约 170 万套待改造' },
|
| 594 |
+
{ t: '房产税推高房租', e: '前提未触发,无法检验' },
|
| 595 |
+
],
|
| 596 |
+
},
|
| 597 |
+
]
|
| 598 |
+
|
| 599 |
+
export function Pending() {
|
| 600 |
+
const S = useS()
|
| 601 |
+
const { P, W, M } = S
|
| 602 |
+
const p = useP()
|
| 603 |
+
const focus = S.lt(2) >= -0.2 ? 1 : S.lt(1) >= -0.2 ? 0 : -1
|
| 604 |
+
const colW = P ? W - M * 2 : 520
|
| 605 |
+
return (
|
| 606 |
+
<>
|
| 607 |
+
{PEND.map((gp, gi) => {
|
| 608 |
+
const x = P ? M : M + gi * 560
|
| 609 |
+
const y0 = P ? [420, 790, 1160][gi] : 300
|
| 610 |
+
const dimT = focus < 0 || focus === gi ? 1 : 0.3
|
| 611 |
+
const a = p(0, 0.4 + gi * 0.6, 0.8)
|
| 612 |
+
const hl = focus === gi
|
| 613 |
+
return (
|
| 614 |
+
<div key={gi} style={{ position: 'absolute', left: x, top: y0, width: colW, opacity: a * (0.3 + 0.7 * dimT), transform: `translateY(${((1 - a) * 30).toFixed(1)}px) scale(${hl ? 1.02 : 1})`, transformOrigin: 'left top', filter: dimT < 1 ? 'blur(1.5px)' : undefined }}>
|
| 615 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
|
| 616 |
+
<Chip kind={gp.grp} p={a} size={22} />
|
| 617 |
+
<div style={serif(P ? 38 : 36)}>{gp.h}</div>
|
| 618 |
+
<div style={{ flex: 1 }} />
|
| 619 |
+
<Big v={String(gp.items.length)} p={p(0, 0.6 + gi * 0.6, 1.2)} size={P ? 56 : 64} color={gp.col} unit="条" unitColor={gp.col} />
|
| 620 |
+
</div>
|
| 621 |
+
<div style={{ height: 2, marginTop: 8, width: `${(E.out(a) * 100).toFixed(1)}%`, background: `linear-gradient(90deg, ${gp.col}, ${hexA(gp.col, 0.1)})` }} />
|
| 622 |
+
<div style={{ display: 'flex', flexDirection: 'column', gap: P ? 8 : 10, marginTop: P ? 12 : 16 }}>
|
| 623 |
+
{gp.items.map((it, k) => {
|
| 624 |
+
const q = p(0, 2.4 + gi * 0.5 + k * 0.2)
|
| 625 |
+
return (
|
| 626 |
+
<T key={it.t} p={q} dy={12}>
|
| 627 |
+
<Card tint={hl ? gp.col : undefined} glow={hl ? gp.col : undefined} pad={P ? '14px 22px' : '12px 22px'} r={16}>
|
| 628 |
+
{P ? (
|
| 629 |
+
<div style={{ display: 'flex', alignItems: 'baseline', gap: 16 }}>
|
| 630 |
+
<div style={serif(30)}>{it.t}</div>
|
| 631 |
+
<div style={{ flex: 1 }} />
|
| 632 |
+
<div style={cn(21, 500, C.mute)}>{it.e}</div>
|
| 633 |
+
</div>
|
| 634 |
+
) : (
|
| 635 |
+
<>
|
| 636 |
+
<div style={serif(30)}>{it.t}</div>
|
| 637 |
+
<div style={{ ...cn(21, 500, C.mute), marginTop: 4 }}>{it.e}</div>
|
| 638 |
+
</>
|
| 639 |
+
)}
|
| 640 |
+
</Card>
|
| 641 |
+
</T>
|
| 642 |
+
)
|
| 643 |
+
})}
|
| 644 |
+
</div>
|
| 645 |
+
</div>
|
| 646 |
+
)
|
| 647 |
+
})}
|
| 648 |
+
{!P && (
|
| 649 |
+
<div style={{ position: 'absolute', left: 0, width: W, top: 990, textAlign: 'center', opacity: p(0, 4.4) * (focus < 0 ? 1 : 0.5), ...cn(22, 500, C.dim) }}>这 10 条还没到期,不计入命中率</div>
|
| 650 |
+
)}
|
| 651 |
+
</>
|
| 652 |
+
)
|
| 653 |
+
}
|
| 654 |
+
|
| 655 |
+
// ================= 结语 =================
|
| 656 |
+
const SCAT = [
|
| 657 |
+
...byType.map((x) => {
|
| 658 |
+
const rs = rows.filter((r) => r.a.type === x.k && !r.status.startsWith('pending'))
|
| 659 |
+
return { l: x.label, sp: rs.reduce((a, r) => a + r.a.spec, 0) / rs.length, hit: x.r.hit, n: x.r.n }
|
| 660 |
+
}),
|
| 661 |
+
(() => {
|
| 662 |
+
const rs = rows.filter((r) => r.topic === '租金与保障房' && !r.status.startsWith('pending'))
|
| 663 |
+
const r = byTopic.find((x) => x.k === '租金与保障房')!.r
|
| 664 |
+
return { l: '租金', sp: rs.reduce((a, x) => a + x.a.spec, 0) / rs.length, hit: r.hit, n: r.n }
|
| 665 |
+
})(),
|
| 666 |
+
]
|
| 667 |
+
const BARCODE = [...rows].sort((a, b) => a.id.localeCompare(b.id))
|
| 668 |
+
const LOGIC = [
|
| 669 |
+
{ t: '土地财政', d: '地方财政离不开卖地' },
|
| 670 |
+
{ t: '货币超发', d: 'M2 十五年涨到 4.7 倍' },
|
| 671 |
+
{ t: '城市分化', d: '人往大城市走,强者恒强' },
|
| 672 |
+
]
|
| 673 |
+
const VISION = (['policy', 'city'] as const).map((k) => {
|
| 674 |
+
const x = byType.find((b) => b.k === k)!
|
| 675 |
+
return { l: k === 'policy' ? '政策走向' : '城市分化', hit: x.r.hit, pct: Math.round(x.r.hit * 100), c: x.r.correct, w: x.r.wrong }
|
| 676 |
+
})
|
| 677 |
+
|
| 678 |
+
export function Outro() {
|
| 679 |
+
const S = useS()
|
| 680 |
+
const { P, W, H, M } = S
|
| 681 |
+
const p = useP()
|
| 682 |
+
const vis = useVis()
|
| 683 |
+
/** 第 k 句中某个词开始朗读的大致秒数(按字数比例估算) */
|
| 684 |
+
const fr = (k: number, w: string) => wordAt(S.sc.lines[k]?.text ?? '', w) * S.ld(k)
|
| 685 |
+
const fs = P ? 24 : 22
|
| 686 |
+
return (
|
| 687 |
+
<>
|
| 688 |
+
{/* 0:问题 */}
|
| 689 |
+
<Beat k={0} to={1} x={0} y={P ? 760 : 380} w={W} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
| 690 |
+
<Tag text="15 YEARS · 123 PREDICTIONS" p={p(0, 0.1)} size={20} />
|
| 691 |
+
<Chars text="十五年对账," t={S.lt(0) - 0.2} st={0.07} d={0.7} dy={0.4} blur={14} style={{ ...txtStyle({ f: 'serif', size: P ? 88 : 100, w: 900 }), marginTop: 30 }} />
|
| 692 |
+
<Chars text="这个神贴留给我们什么?" t={S.lt(0) - 0.6} st={0.07} d={0.7} dy={0.4} blur={14} style={{ ...txtStyle({ f: 'serif', size: P ? 70 : 80, w: 900, color: C.goldHi }), marginTop: 16 }} />
|
| 693 |
+
</Beat>
|
| 694 |
+
|
| 695 |
+
{/* 1:四象限散点 */}
|
| 696 |
+
{(() => {
|
| 697 |
+
const a = vis(1, 2)
|
| 698 |
+
if (a <= 0.001) return null
|
| 699 |
+
const f: Fr = P ? { x: 170, y: 470, w: 800, h: 820, x0: 1.3, x1: 3.15, y0: 0, y1: 1 } : { x: 330, y: 300, w: 1300, h: 540, x0: 1.3, x1: 3.15, y0: 0, y1: 1 }
|
| 700 |
+
const q0 = p(1, 0.1, 0.9)
|
| 701 |
+
const mx = sx(f, 2.2)
|
| 702 |
+
const my = sy(f, 0.5)
|
| 703 |
+
const n = SCAT.length
|
| 704 |
+
const mxv = SCAT.reduce((s, v) => s + v.sp, 0) / n
|
| 705 |
+
const myv = SCAT.reduce((s, v) => s + v.hit, 0) / n
|
| 706 |
+
const b = SCAT.reduce((s, v) => s + (v.sp - mxv) * (v.hit - myv), 0) / SCAT.reduce((s, v) => s + (v.sp - mxv) ** 2, 0)
|
| 707 |
+
const fit = (x: number) => clamp(myv + b * (x - mxv))
|
| 708 |
+
const tp = p(1, 4.6, 1.6, E.inOut)
|
| 709 |
+
return (
|
| 710 |
+
<svg width={W} height={H} style={{ position: 'absolute', left: 0, top: 0, opacity: a }}>
|
| 711 |
+
<g opacity={q0}>
|
| 712 |
+
<rect x={f.x} y={f.y} width={(mx - f.x) * E.out(q0)} height={my - f.y} fill={hexA(C.green, 0.07)} />
|
| 713 |
+
<rect x={mx} y={my} width={(f.x + f.w - mx) * E.out(q0)} height={f.y + f.h - my} fill={hexA(C.red, 0.07)} />
|
| 714 |
+
<line x1={mx} x2={mx} y1={f.y} y2={f.y + f.h} stroke="rgba(243,238,228,0.2)" strokeDasharray="4 6" />
|
| 715 |
+
<line x1={f.x} x2={f.x + f.w} y1={my} y2={my} stroke="rgba(243,238,228,0.2)" strokeDasharray="4 6" />
|
| 716 |
+
<line x1={f.x} x2={f.x + f.w} y1={f.y + f.h} y2={f.y + f.h} stroke="rgba(243,238,228,0.35)" />
|
| 717 |
+
<line x1={f.x} x2={f.x} y1={f.y} y2={f.y + f.h} stroke="rgba(243,238,228,0.35)" />
|
| 718 |
+
{[0, 0.5, 1].map((v) => (
|
| 719 |
+
<text key={v} x={f.x - 14} y={sy(f, v) + 7} textAnchor="end" fill={C.dim} style={svgText(fs - 4, 500, 'mono')}>
|
| 720 |
+
{`${v * 100}%`}
|
| 721 |
+
</text>
|
| 722 |
+
))}
|
| 723 |
+
<text x={f.x} y={f.y - 20} fill={C.mute} style={svgText(fs - 2, 700, 'cn')}>
|
| 724 |
+
命中率 ↑
|
| 725 |
+
</text>
|
| 726 |
+
<text x={f.x + f.w} y={f.y + f.h + 40} textAnchor="end" fill={C.mute} style={svgText(fs - 2, 700, 'cn')}>
|
| 727 |
+
说得越具体 →
|
| 728 |
+
</text>
|
| 729 |
+
<text x={f.x + 20} y={f.y + 40} fill={C.green} style={svgText(fs, 800, 'cn')}>
|
| 730 |
+
逻辑与方向 · 看得准
|
| 731 |
+
</text>
|
| 732 |
+
<text x={f.x + f.w - 20} y={f.y + f.h - 22} textAnchor="end" fill={C.red} style={svgText(fs, 800, 'cn')}>
|
| 733 |
+
数字与时点 · 屡屡失手
|
| 734 |
+
</text>
|
| 735 |
+
</g>
|
| 736 |
+
{tp > 0 && <line x1={sx(f, 1.35)} y1={sy(f, fit(1.35))} x2={sx(f, lerp(1.35, 3.1, tp))} y2={sy(f, fit(lerp(1.35, 3.1, tp)))} stroke={C.gold} strokeWidth={2.5} strokeDasharray="10 8" opacity={0.85} />}
|
| 737 |
+
{SCAT.map((s, i) => {
|
| 738 |
+
const good = s.hit >= 0.6
|
| 739 |
+
const q = spr(S.lt(1) - (good ? 1.0 + i * 0.3 : 3.4 + i * 0.25), { k: 10, z: 0.5 })
|
| 740 |
+
if (q <= 0.001) return null
|
| 741 |
+
const x = sx(f, s.sp)
|
| 742 |
+
const y = sy(f, s.hit)
|
| 743 |
+
const r = (12 + Math.sqrt(s.n) * 5) * Math.max(0, q)
|
| 744 |
+
const col = hitColor(s.hit)
|
| 745 |
+
const lr = s.l === '租金' || s.l === '涨跌幅度' || s.l === '时间点'
|
| 746 |
+
return (
|
| 747 |
+
<g key={s.l}>
|
| 748 |
+
<circle cx={x} cy={y} r={r} fill={hexA(col, 0.22)} stroke={col} strokeWidth={2.5} />
|
| 749 |
+
<text x={lr ? x - r - 12 : x + r + 12} y={y + 9} textAnchor={lr ? 'end' : 'start'} fill={C.ink} opacity={clamp(q)} style={svgText(fs + 2, 700, 'cn')}>
|
| 750 |
+
{`${s.l} ${pct(s.hit)}%`}
|
| 751 |
+
</text>
|
| 752 |
+
</g>
|
| 753 |
+
)
|
| 754 |
+
})}
|
| 755 |
+
</svg>
|
| 756 |
+
)
|
| 757 |
+
})()}
|
| 758 |
+
|
| 759 |
+
{/* 2:金句 */}
|
| 760 |
+
<Beat k={2} to={3} x={0} y={P ? 720 : 360} w={W} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
| 761 |
+
<Chars text="看对方向容易," t={S.lt(2) - 0.1} st={0.08} d={0.8} dy={0.4} blur={16} style={txtStyle({ f: 'serif', size: P ? 100 : 120, w: 900 })} />
|
| 762 |
+
<div style={{ marginTop: P ? 24 : 20, ...txtStyle({ f: 'serif', size: P ? 100 : 120, w: 900 }), ...shineStyle(tw(S.lt(2), 2.0, 1.6) * 1.6 - 0.3), opacity: p(2, 1.0, 0.9), transform: `translateY(${((1 - p(2, 1.0, 0.9)) * 30).toFixed(1)}px)`, filter: `blur(${((1 - p(2, 1.0, 0.9)) * 14).toFixed(1)}px)` }}>算准时间很难。</div>
|
| 763 |
+
<div style={{ width: 160 * p(2, 1.8, 0.8), height: 2, background: C.gold, marginTop: 40 }} />
|
| 764 |
+
</Beat>
|
| 765 |
+
|
| 766 |
+
{/* 3:预言 = 逻辑 × 前提 */}
|
| 767 |
+
<Beat k={3} to={4} x={0} y={P ? 560 : 300} w={W} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
| 768 |
+
<div style={{ display: 'flex', gap: P ? 18 : 40, alignItems: 'center', flexWrap: 'wrap', justifyContent: 'center' }}>
|
| 769 |
+
{['预言', '=', '逻辑', '×', '前提'].map((s, i) => {
|
| 770 |
+
const q = spr(S.lt(3) - 0.2 - i * 0.22, { k: 10, z: 0.6 })
|
| 771 |
+
const strike = p(3, 3.4, 0.5)
|
| 772 |
+
return (
|
| 773 |
+
<div key={i} style={{ position: 'relative', opacity: clamp(q * 2), transform: `translateY(${((1 - clamp(q)) * 40).toFixed(1)}px)`, ...txtStyle({ f: 'serif', size: P ? 96 : 120, w: 900, color: i === 4 ? C.goldHi : i % 2 ? C.gold : C.ink }) }}>
|
| 774 |
+
{s}
|
| 775 |
+
{i === 4 && strike > 0 && <div style={{ position: 'absolute', left: -8, top: '52%', height: 8, width: `calc(${(strike * 100).toFixed(1)}% + 16px)`, background: C.red, borderRadius: 4, boxShadow: `0 0 16px ${hexA(C.red, 0.6)}` }} />}
|
| 776 |
+
</div>
|
| 777 |
+
)
|
| 778 |
+
})}
|
| 779 |
+
</div>
|
| 780 |
+
<div style={{ display: 'flex', flexDirection: P ? 'column' : 'row', gap: P ? 16 : 28, marginTop: P ? 50 : 50, alignItems: 'center' }}>
|
| 781 |
+
{['人口红利 → 人口减少', '货币扩张 → 低通胀', '高利率 → 降息周期'].map((s, i) => (
|
| 782 |
+
<T key={s} p={p(3, 1.6 + i * 0.35)}>
|
| 783 |
+
<Card pad="14px 26px" r={14}>
|
| 784 |
+
<div style={cn(P ? 28 : 26, 700, C.ink2)}>{s}</div>
|
| 785 |
+
</Card>
|
| 786 |
+
</T>
|
| 787 |
+
))}
|
| 788 |
+
</div>
|
| 789 |
+
<T p={p(3, 4.4)} style={{ ...serif(P ? 42 : 46, C.mute), marginTop: P ? 50 : 50, textAlign: 'center' }}>
|
| 790 |
+
前提变了,再神的帖子,也会过期
|
| 791 |
+
</T>
|
| 792 |
+
<div style={{ position: 'absolute', left: P ? W / 2 + 120 : W / 2 + 360, top: P ? -70 : -40 }}>
|
| 793 |
+
<Stamp text="EXPIRED" sub="已过期" p={p(3, 5.2, 0.5)} size={P ? 70 : 84} />
|
| 794 |
+
</div>
|
| 795 |
+
</Beat>
|
| 796 |
+
|
| 797 |
+
{/* 4:能力 —— 2010 年就讲清的逻辑 */}
|
| 798 |
+
<Beat k={4} to={5} x={P ? M : 0} y={P ? 470 : 250} w={P ? W - M * 2 : W} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
| 799 |
+
<Tag text="ABILITY · 能力" p={p(4, 0.1)} size={20} />
|
| 800 |
+
<T p={p(4, 0.9)} style={{ ...serif(P ? 64 : 72), marginTop: 26, textAlign: 'center' }}>
|
| 801 |
+
<span style={{ ...goldText(), fontWeight: 900 }}>2010</span> 年,房价还在狂飙
|
| 802 |
+
</T>
|
| 803 |
+
<T p={p(4, fr(4, '他就把') - 0.2)} style={{ ...cn(P ? 34 : 34, 600, C.mute), marginTop: 14, textAlign: 'center' }}>
|
| 804 |
+
他就把底层逻辑讲得清清楚楚
|
| 805 |
+
</T>
|
| 806 |
+
<div style={{ display: 'flex', flexDirection: P ? 'column' : 'row', gap: P ? 22 : 34, marginTop: P ? 56 : 54 }}>
|
| 807 |
+
{LOGIC.map((l, i) => {
|
| 808 |
+
const q = spr(S.lt(4) - fr(4, l.t) + 0.15, { k: 10, z: 0.6 })
|
| 809 |
+
return (
|
| 810 |
+
<div key={l.t} style={{ opacity: clamp(q * 2), transform: `translateY(${((1 - clamp(q)) * 50).toFixed(1)}px) scale(${lerp(0.9, 1, clamp(q)).toFixed(3)})` }}>
|
| 811 |
+
<Card pad={P ? '26px 34px' : '30px 34px'} r={20} tint={C.gold} style={{ width: P ? W - M * 2 : 430 }}>
|
| 812 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 18 }}>
|
| 813 |
+
<div style={{ ...txtStyle({ f: 'num', size: 54, w: 800, color: 'transparent', lh: 1 }), WebkitTextStroke: `1.5px ${hexA(C.gold, 0.85)}` }}>{`0${i + 1}`}</div>
|
| 814 |
+
<div>
|
| 815 |
+
<div style={serif(P ? 46 : 44)}>{l.t}</div>
|
| 816 |
+
<div style={{ ...cn(P ? 24 : 22, 600, C.mute), marginTop: 8 }}>{l.d}</div>
|
| 817 |
+
</div>
|
| 818 |
+
</div>
|
| 819 |
+
</Card>
|
| 820 |
+
</div>
|
| 821 |
+
)
|
| 822 |
+
})}
|
| 823 |
+
</div>
|
| 824 |
+
</Beat>
|
| 825 |
+
|
| 826 |
+
{/* 5:眼光 —— 政策与城市近八成 */}
|
| 827 |
+
<Beat k={5} to={6} x={0} y={P ? 470 : 250} w={W} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
| 828 |
+
<Tag text="VISION · 眼光" p={p(5, 0.1)} size={20} />
|
| 829 |
+
<div style={{ display: 'flex', gap: P ? 70 : 140, marginTop: P ? 60 : 50 }}>
|
| 830 |
+
{VISION.map((v, i) => {
|
| 831 |
+
const q = p(5, 0.3 + i * 0.5, 1.8)
|
| 832 |
+
const sz = P ? 330 : 320
|
| 833 |
+
return (
|
| 834 |
+
<div key={v.l} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', opacity: clamp(q * 3) }}>
|
| 835 |
+
<div style={{ position: 'relative', width: sz, height: sz }}>
|
| 836 |
+
<Ring size={sz} stroke={P ? 22 : 22} segs={[{ v: v.hit, color: C.green }, { v: 1 - v.hit, color: 'rgba(0,0,0,0)' }]} p={q} />
|
| 837 |
+
<div style={{ position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}>
|
| 838 |
+
<Big v={String(v.pct)} p={q} size={P ? 120 : 116} unit="%" unitColor={C.green} />
|
| 839 |
+
</div>
|
| 840 |
+
</div>
|
| 841 |
+
<div style={{ ...serif(P ? 44 : 42), marginTop: 26 }}>{v.l}</div>
|
| 842 |
+
<div style={{ ...mono(P ? 20 : 18, C.dim, 600, 2), marginTop: 10 }}>{`${v.c} / ${v.c + v.w} 可判定`}</div>
|
| 843 |
+
</div>
|
| 844 |
+
)
|
| 845 |
+
})}
|
| 846 |
+
</div>
|
| 847 |
+
<T p={p(5, fr(5, '这份眼光') - 0.1)} style={{ ...serif(P ? 52 : 54, C.goldHi), marginTop: P ? 70 : 50, textAlign: 'center' }}>
|
| 848 |
+
这份眼光,放在当年凤毛麟角
|
| 849 |
+
</T>
|
| 850 |
+
</Beat>
|
| 851 |
+
|
| 852 |
+
{/* 6:格局 —— 制度 · 人口 · 财富 */}
|
| 853 |
+
<Beat k={6} to={7} x={0} y={P ? 430 : 230} w={W} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
| 854 |
+
<Tag text="PERSPECTIVE · 格局" p={p(6, 0.1)} size={20} />
|
| 855 |
+
<T p={p(6, fr(6, '不是一套房') - 0.1)} style={{ position: 'relative', marginTop: P ? 40 : 34 }}>
|
| 856 |
+
<div style={cn(P ? 36 : 36, 700, C.mute)}>一套房的涨跌</div>
|
| 857 |
+
<div style={{ position: 'absolute', left: -10, top: '52%', height: 4, width: `calc(${(p(6, fr(6, '而是') - 0.2, 0.5) * 100).toFixed(1)}% + 20px)`, background: C.red, borderRadius: 2 }} />
|
| 858 |
+
</T>
|
| 859 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: P ? 26 : 44, marginTop: P ? 46 : 40 }}>
|
| 860 |
+
{['制度', '人口', '财富'].map((w, i) => {
|
| 861 |
+
const q = spr(S.lt(6) - fr(6, w) + 0.1, { k: 11, z: 0.55 })
|
| 862 |
+
return (
|
| 863 |
+
<React.Fragment key={w}>
|
| 864 |
+
{i > 0 && <div style={{ ...txtStyle({ f: 'serif', size: P ? 60 : 72, w: 900, color: C.gold }), opacity: clamp(q * 2) }}>·</div>}
|
| 865 |
+
<div style={{ ...txtStyle({ f: 'serif', size: P ? 120 : 140, w: 900 }), opacity: clamp(q * 2), transform: `translateY(${((1 - clamp(q)) * 60).toFixed(1)}px)` }}>{w}</div>
|
| 866 |
+
</React.Fragment>
|
| 867 |
+
)
|
| 868 |
+
})}
|
| 869 |
+
</div>
|
| 870 |
+
<T p={p(6, fr(6, '的流向') - 0.1)} style={{ ...mono(P ? 22 : 22, C.gold, 700, 6), marginTop: 16 }}>
|
| 871 |
+
{'—— 的流向 ——'}
|
| 872 |
+
</T>
|
| 873 |
+
<T p={p(6, fr(6, '教会') - 0.1)} style={{ ...cn(P ? 34 : 34, 600, C.ink2), marginTop: P ? 46 : 36, textAlign: 'center' }}>
|
| 874 |
+
教会了一代人,用经济学的眼光看房子
|
| 875 |
+
</T>
|
| 876 |
+
{(() => {
|
| 877 |
+
const t0 = fr(6, '这份功力') - 0.1
|
| 878 |
+
const q = p(6, t0, 1.0)
|
| 879 |
+
return (
|
| 880 |
+
<div style={{ marginTop: P ? 56 : 40, display: 'flex', flexDirection: 'column', alignItems: 'center', opacity: clamp(q * 1.5), transform: `scale(${lerp(1.15, 1, E.out(q)).toFixed(3)})`, filter: q < 0.95 ? `blur(${((1 - q) * 12).toFixed(1)}px)` : undefined }}>
|
| 881 |
+
<div style={{ ...txtStyle({ f: 'serif', size: P ? 84 : 92, w: 900 }), ...shineStyle(tw(S.lt(6), t0 + 0.5, 1.6) * 1.6 - 0.3) }}>致敬 KKndme</div>
|
| 882 |
+
<div style={{ display: 'flex', gap: 18, marginTop: 22 }}>
|
| 883 |
+
{['能力', '眼光', '格局'].map((w, i) => (
|
| 884 |
+
<div key={w} style={{ opacity: p(6, t0 + 0.4 + i * 0.25), padding: '8px 22px', borderRadius: 999, border: `1.5px solid ${hexA(C.gold, 0.6)}`, ...cn(P ? 26 : 24, 700, C.goldHi) }}>
|
| 885 |
+
{w}
|
| 886 |
+
</div>
|
| 887 |
+
))}
|
| 888 |
+
</div>
|
| 889 |
+
</div>
|
| 890 |
+
)
|
| 891 |
+
})()}
|
| 892 |
+
</Beat>
|
| 893 |
+
|
| 894 |
+
{/* 7:条码 → 关注 / 点赞 / 评论 */}
|
| 895 |
+
{(() => {
|
| 896 |
+
const a = vis(7)
|
| 897 |
+
if (a <= 0.001) return null
|
| 898 |
+
const dl = S.ld(7)
|
| 899 |
+
const cIn = dl * CTA_IN
|
| 900 |
+
const out = tw(S.lt(7), cIn - 0.5, 0.7, E.in)
|
| 901 |
+
const n = BARCODE.length
|
| 902 |
+
const bx0 = P ? M : 240
|
| 903 |
+
const bx1 = P ? W - M : W - 240
|
| 904 |
+
const bw = (bx1 - bx0) / n
|
| 905 |
+
const by = P ? 780 : 330
|
| 906 |
+
const bh = P ? 240 : 170
|
| 907 |
+
return (
|
| 908 |
+
<>
|
| 909 |
+
<div style={{ position: 'absolute', left: 0, top: 0, width: W, height: H, opacity: a * (1 - out), transform: `translateY(${(-out * 60).toFixed(1)}px)`, filter: out > 0.02 ? `blur(${(out * 14).toFixed(1)}px)` : undefined }}>
|
| 910 |
+
{BARCODE.map((r, i) => {
|
| 911 |
+
const q = tw(S.lt(7), 0.2 + (i / n) * 1.6, 0.5)
|
| 912 |
+
if (q <= 0) return null
|
| 913 |
+
const col = STATUS_COLOR[r.status] ?? C.gray
|
| 914 |
+
const h = bh * (0.55 + 0.45 * rand(i, 11)) * E.out(q)
|
| 915 |
+
return <div key={r.id} style={{ position: 'absolute', left: bx0 + i * bw, top: by + bh - h, width: Math.max(2, bw - 3), height: h, background: col, opacity: 0.88, borderRadius: 2 }} />
|
| 916 |
+
})}
|
| 917 |
+
<div style={{ position: 'absolute', left: bx0, top: by + bh + 14, width: bx1 - bx0, display: 'flex', justifyContent: 'space-between', opacity: p(7, 1.8), ...mono(16, C.dim, 600, 2) }}>
|
| 918 |
+
<span>A01</span>
|
| 919 |
+
<span>{`${n} PREDICTIONS · SORTED BY ID`}</span>
|
| 920 |
+
<span>{BARCODE[n - 1].id}</span>
|
| 921 |
+
</div>
|
| 922 |
+
<div style={{ position: 'absolute', left: 0, width: W, top: by + bh + (P ? 110 : 64), display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
| 923 |
+
<T p={p(7, 1.4)} style={{ ...serif(P ? 56 : 60), textAlign: 'center' }}>
|
| 924 |
+
<span style={{ ...goldText(), fontWeight: 900 }}>123</span>
|
| 925 |
+
<span> 条完整核对</span>
|
| 926 |
+
</T>
|
| 927 |
+
<T p={p(7, 2.0)} style={{ ...cn(P ? 28 : 28, 600, C.mute), marginTop: 14, textAlign: 'center' }}>
|
| 928 |
+
每条都附原话和出处
|
| 929 |
+
</T>
|
| 930 |
+
{(() => {
|
| 931 |
+
const at = fr(7, '相关文件')
|
| 932 |
+
const q0 = p(7, at - 0.2, 0.6)
|
| 933 |
+
if (q0 <= 0) return null
|
| 934 |
+
return (
|
| 935 |
+
<div style={{ marginTop: P ? 40 : 30, display: 'flex', flexDirection: 'column', alignItems: 'center', opacity: clamp(q0 * 1.4) }}>
|
| 936 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 12, ...cn(P ? 32 : 30, 800, C.goldHi) }}>
|
| 937 |
+
<svg width={30} height={30} viewBox="0 0 30 30">
|
| 938 |
+
<path d="M19 8 L10 17 a3.5 3.5 0 0 0 5 5 L24 13 a6 6 0 0 0 -8.5 -8.5 L6 14 a8.5 8.5 0 0 0 12 12 L24 20" stroke={C.goldHi} strokeWidth={2.6} fill="none" strokeLinecap="round" />
|
| 939 |
+
</svg>
|
| 940 |
+
相关文件,全部放在评论区
|
| 941 |
+
</div>
|
| 942 |
+
<div style={{ display: 'flex', gap: P ? 12 : 16, marginTop: 18, flexWrap: 'wrap', justifyContent: 'center', maxWidth: W - M * 2 }}>
|
| 943 |
+
{['天涯原帖 · 480 页', '整理合集 · 506 页', '理论框架 · 43 条', '123 条核对 + AI 推演'].map((f, i) => {
|
| 944 |
+
const q = p(7, at + 0.3 + i * 0.25, 0.5)
|
| 945 |
+
return (
|
| 946 |
+
<div key={f} style={{ opacity: clamp(q * 1.5), transform: `translateY(${((1 - q) * 16).toFixed(1)}px)`, display: 'flex', alignItems: 'center', gap: 10, padding: P ? '10px 20px' : '10px 22px', borderRadius: 12, border: `1px solid ${hexA(C.gold, 0.45)}`, background: hexA(C.gold, 0.08), ...cn(P ? 24 : 24, 700, C.ink) }}>
|
| 947 |
+
<svg width={22} height={26} viewBox="0 0 22 26">
|
| 948 |
+
<path d="M2 2 H14 L20 8 V24 H2 Z M14 2 V8 H20" stroke={C.gold} strokeWidth={2} fill="none" strokeLinejoin="round" />
|
| 949 |
+
</svg>
|
| 950 |
+
{f}
|
| 951 |
+
</div>
|
| 952 |
+
)
|
| 953 |
+
})}
|
| 954 |
+
</div>
|
| 955 |
+
</div>
|
| 956 |
+
)
|
| 957 |
+
})()}
|
| 958 |
+
</div>
|
| 959 |
+
</div>
|
| 960 |
+
{S.lt(7) > cIn - 0.2 && (
|
| 961 |
+
<div style={{ position: 'absolute', left: 0, top: P ? 500 : 150, width: W, opacity: a }}>
|
| 962 |
+
<CtaCard W={W} P={P} u={S.lt(7) - cIn} at={CTA_AT.map((f) => dl * (f - CTA_IN)) as [number, number, number]} />
|
| 963 |
+
<T p={p(7, dl * 0.88)} style={{ display: 'flex', justifyContent: 'center', marginTop: P ? 70 : 44 }}>
|
| 964 |
+
<div style={{ ...txtStyle({ f: 'serif', size: P ? 68 : 60, w: 900 }), ...shineStyle(tw(S.lt(7), dl * 0.9, 1.6) * 1.6 - 0.3) }}>我们下期见</div>
|
| 965 |
+
</T>
|
| 966 |
+
</div>
|
| 967 |
+
)}
|
| 968 |
+
</>
|
| 969 |
+
)
|
| 970 |
+
})()}
|
| 971 |
+
</>
|
| 972 |
+
)
|
| 973 |
+
}
|
| 974 |
+
|
kkndme/frontend/src/rv/scenesD.tsx
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// 理论框架的重要性 · AI 按理论框架推演未来房价(不构成投资建议)
|
| 2 |
+
import React from 'react'
|
| 3 |
+
import { C, E, clamp, hexA, lerp, tw } from './theme'
|
| 4 |
+
import { useS } from './ctx'
|
| 5 |
+
import { txtStyle, goldText, shineStyle } from './ui'
|
| 6 |
+
import { Beat, Big, Card, Stamp, T, Tag, cn, mono, serif, useP, useVis } from './kit'
|
| 7 |
+
import { Clawd } from './brand'
|
| 8 |
+
import { theories } from '../data/theories'
|
| 9 |
+
import { byType } from '../data/science'
|
| 10 |
+
import { wordAt } from '../video/script'
|
| 11 |
+
|
| 12 |
+
const GROUPS = (() => {
|
| 13 |
+
const m = new Map<string, number>()
|
| 14 |
+
theories.forEach((t) => m.set(t.group, (m.get(t.group) ?? 0) + 1))
|
| 15 |
+
return [...m.entries()].sort((a, b) => b[1] - a[1])
|
| 16 |
+
})()
|
| 17 |
+
const CITY_HIT = Math.round((byType.find((b) => b.k === 'city')?.r.hit ?? 0) * 100)
|
| 18 |
+
|
| 19 |
+
const QUESTIONS = [
|
| 20 |
+
{ q: '谁在定价', w: '谁在定价', basis: '房价由“精英的平均收入”决定' },
|
| 21 |
+
{ q: '钱从哪里来', w: '钱从哪里来', basis: '土地财政 · 货币蓄水池' },
|
| 22 |
+
{ q: '人往哪里去', w: '人往哪里去', basis: '好位置稀缺 · 资金流向京沪与省会' },
|
| 23 |
+
]
|
| 24 |
+
|
| 25 |
+
const OUTLOOK = [
|
| 26 |
+
{ no: '01', t: '分化继续', basis: '资金流向 · 好位置稀缺', d: '核心城市的核心地段,最抗跌', col: C.green, kind: 'split' as const },
|
| 27 |
+
{ no: '02', t: '普涨难再', basis: '外来人口决定房价和租金', d: '人口不再流入的城市,长期承压', col: C.red, kind: 'down' as const },
|
| 28 |
+
{ no: '03', t: '崩盘也难', basis: '土地财政 · 政府不会让房地产崩盘', d: '更可能是长时间的横盘消化', col: C.amber, kind: 'flat' as const },
|
| 29 |
+
]
|
| 30 |
+
|
| 31 |
+
const AMBER = C.amber
|
| 32 |
+
|
| 33 |
+
/** 趋势图标:网格 + 分段描线 + 末端光点;分化 = 一条主干在分叉点裂成一升一降 */
|
| 34 |
+
function TrendIcon({ kind, size, col, p }: { kind: 'split' | 'down' | 'flat'; size: number; col: string; p: number }) {
|
| 35 |
+
const uid = 'ti' + React.useId().replace(/[^a-zA-Z0-9]/g, '')
|
| 36 |
+
const sw = 6.5
|
| 37 |
+
const seg = (a: number, b: number) => E.inOut(clamp((p - a) / (b - a)))
|
| 38 |
+
const draw = (q: number) => ({ pathLength: 1, strokeDasharray: 1, strokeDashoffset: 1 - q })
|
| 39 |
+
const dot = (x: number, y: number, c: string, q: number) =>
|
| 40 |
+
q > 0.01 && (
|
| 41 |
+
<g opacity={clamp(q * 1.4)}>
|
| 42 |
+
<circle cx={x} cy={y} r={10 * q} fill={hexA(c, 0.22)} />
|
| 43 |
+
<circle cx={x} cy={y} r={4.6} fill={c} stroke={C.bg} strokeWidth={1.6} />
|
| 44 |
+
</g>
|
| 45 |
+
)
|
| 46 |
+
const grid = (
|
| 47 |
+
<g opacity={0.5 * clamp(p * 3)}>
|
| 48 |
+
{[22, 50, 78].map((y) => (
|
| 49 |
+
<path key={y} d={`M6 ${y} L94 ${y}`} stroke={C.faint} strokeWidth={1.2} strokeDasharray="3 5" />
|
| 50 |
+
))}
|
| 51 |
+
</g>
|
| 52 |
+
)
|
| 53 |
+
if (kind === 'split') {
|
| 54 |
+
const a = seg(0, 0.38)
|
| 55 |
+
const b = seg(0.32, 1)
|
| 56 |
+
const up = 'M44 58 C58 55 68 40 88 18'
|
| 57 |
+
const dn = 'M44 58 C58 61 70 72 88 84'
|
| 58 |
+
return (
|
| 59 |
+
<svg width={size} height={size} viewBox="0 0 100 100" style={{ display: 'block', overflow: 'visible' }}>
|
| 60 |
+
<defs>
|
| 61 |
+
<linearGradient id={`${uid}w`} x1="0" y1="0" x2="0" y2="1">
|
| 62 |
+
<stop offset="0" stopColor={C.green} stopOpacity={0.32} />
|
| 63 |
+
<stop offset="0.5" stopColor={C.green} stopOpacity={0.04} />
|
| 64 |
+
<stop offset="0.5" stopColor={C.red} stopOpacity={0.04} />
|
| 65 |
+
<stop offset="1" stopColor={C.red} stopOpacity={0.28} />
|
| 66 |
+
</linearGradient>
|
| 67 |
+
</defs>
|
| 68 |
+
{grid}
|
| 69 |
+
{/* 两条分支之间的“剪刀差” */}
|
| 70 |
+
<path d={`${up} L88 84 C70 72 58 61 44 58 Z`} fill={`url(#${uid}w)`} opacity={b} />
|
| 71 |
+
{/* 主干 */}
|
| 72 |
+
<path d="M8 60 C18 57 26 62 34 58 S40 58 44 58" stroke={C.ink2} strokeWidth={sw} fill="none" strokeLinecap="round" {...draw(a)} />
|
| 73 |
+
{/* 下行分支(其他城市) */}
|
| 74 |
+
<path d={dn} stroke={hexA(C.red, 0.9)} strokeWidth={sw} fill="none" strokeLinecap="round" {...draw(b)} />
|
| 75 |
+
{/* 上行分支(核心城市)+ 柔光 */}
|
| 76 |
+
<path d={up} stroke={hexA(C.green, 0.25)} strokeWidth={sw + 7} fill="none" strokeLinecap="round" {...draw(b)} />
|
| 77 |
+
<path d={up} stroke={C.green} strokeWidth={sw} fill="none" strokeLinecap="round" {...draw(b)} />
|
| 78 |
+
{/* 分叉点 */}
|
| 79 |
+
{a > 0.95 && <circle cx={44} cy={58} r={5.2} fill={C.bg} stroke={C.ink} strokeWidth={2.4} opacity={clamp((a - 0.95) * 20)} />}
|
| 80 |
+
{dot(88, 18, C.green, seg(0.86, 1))}
|
| 81 |
+
{dot(88, 84, C.red, seg(0.86, 1))}
|
| 82 |
+
</svg>
|
| 83 |
+
)
|
| 84 |
+
}
|
| 85 |
+
const q = seg(0, 1)
|
| 86 |
+
const line = kind === 'down' ? 'M8 24 C24 26 30 40 42 42 S60 50 68 62 S82 78 90 80' : 'M8 46 C18 36 26 60 38 54 S54 46 64 54 S80 56 90 52'
|
| 87 |
+
const end: [number, number] = kind === 'down' ? [90, 80] : [90, 52]
|
| 88 |
+
return (
|
| 89 |
+
<svg width={size} height={size} viewBox="0 0 100 100" style={{ display: 'block', overflow: 'visible' }}>
|
| 90 |
+
<defs>
|
| 91 |
+
<linearGradient id={`${uid}a`} x1="0" y1="0" x2="0" y2="1">
|
| 92 |
+
<stop offset="0" stopColor={col} stopOpacity={0.26} />
|
| 93 |
+
<stop offset="1" stopColor={col} stopOpacity={0} />
|
| 94 |
+
</linearGradient>
|
| 95 |
+
</defs>
|
| 96 |
+
{grid}
|
| 97 |
+
{kind === 'flat' && <path d="M6 53 L94 53" stroke={hexA(col, 0.5)} strokeWidth={2} strokeDasharray="5 5" opacity={clamp(p * 2)} />}
|
| 98 |
+
<path d={`${line} L90 94 L8 94 Z`} fill={`url(#${uid}a)`} opacity={seg(0.5, 1)} />
|
| 99 |
+
<path d={line} stroke={hexA(col, 0.25)} strokeWidth={sw + 7} fill="none" strokeLinecap="round" strokeLinejoin="round" {...draw(q)} />
|
| 100 |
+
<path d={line} stroke={col} strokeWidth={sw} fill="none" strokeLinecap="round" strokeLinejoin="round" {...draw(q)} />
|
| 101 |
+
{dot(end[0], end[1], col, seg(0.86, 1))}
|
| 102 |
+
</svg>
|
| 103 |
+
)
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
/** AI 推演角标:从第 2 句起常驻,直到本章结束 */
|
| 107 |
+
function AiBadge() {
|
| 108 |
+
const S = useS()
|
| 109 |
+
const vis = useVis()
|
| 110 |
+
const a = vis(2, undefined, 0.2)
|
| 111 |
+
if (a <= 0.001) return null
|
| 112 |
+
const { P, W, M } = S
|
| 113 |
+
return (
|
| 114 |
+
<div style={{ position: 'absolute', right: M - 20, top: P ? 228 : 132, opacity: a, display: 'flex', alignItems: 'center', gap: 12, padding: P ? '10px 20px' : '10px 22px', borderRadius: 999, border: `1.5px solid ${hexA(AMBER, 0.7)}`, background: 'rgba(20,14,6,0.72)', maxWidth: W - M * 2 }}>
|
| 115 |
+
<Clawd w={P ? 40 : 44} t={S.t} />
|
| 116 |
+
<div style={txtStyle({ f: 'cn', size: P ? 22 : 22, w: 800, color: C.ink })}>AI 推演</div>
|
| 117 |
+
<div style={{ width: 1, height: 22, background: hexA(AMBER, 0.6) }} />
|
| 118 |
+
<div style={txtStyle({ f: 'cn', size: P ? 22 : 22, w: 800, color: AMBER })}>不构成投资建议</div>
|
| 119 |
+
</div>
|
| 120 |
+
)
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
export function Outlook() {
|
| 124 |
+
const S = useS()
|
| 125 |
+
const { P, W, M } = S
|
| 126 |
+
const p = useP()
|
| 127 |
+
const fr = (k: number, w: string) => wordAt(S.sc.lines[k]?.text ?? '', w) * S.ld(k)
|
| 128 |
+
const cw = W - M * 2
|
| 129 |
+
// 3–5:三条推演卡,当前句高亮
|
| 130 |
+
const cur = S.lt(5) >= -0.2 ? 2 : S.lt(4) >= -0.2 ? 1 : 0
|
| 131 |
+
return (
|
| 132 |
+
<>
|
| 133 |
+
<AiBadge />
|
| 134 |
+
|
| 135 |
+
{/* 0:43 条核心理论 · 八大板块 */}
|
| 136 |
+
<Beat k={0} to={1} x={M} y={P ? 330 : 300} w={P ? cw : 640}>
|
| 137 |
+
<Tag text="THE FRAMEWORK" p={p(0, 0.2)} />
|
| 138 |
+
<T p={p(0, 0.4)} style={{ ...cn(P ? 34 : 32, 600, C.mute), marginTop: 22 }}>
|
| 139 |
+
他留下的真正资产
|
| 140 |
+
</T>
|
| 141 |
+
<div style={{ marginTop: 10 }}>
|
| 142 |
+
<Big v={String(theories.length)} p={p(0, fr(0, '43'), 1.4)} size={P ? 200 : 210} unit="条核心理论" color={C.ink} />
|
| 143 |
+
</div>
|
| 144 |
+
<T p={p(0, fr(0, '八大'))} style={{ ...serif(P ? 60 : 58), marginTop: 10 }}>
|
| 145 |
+
归成 <span style={goldText()}>八大板块</span>
|
| 146 |
+
</T>
|
| 147 |
+
</Beat>
|
| 148 |
+
<Beat k={0} to={1} x={P ? M : 860} y={P ? 840 : 290} w={P ? cw : W - 860 - M}>
|
| 149 |
+
<div style={{ display: 'grid', gridTemplateColumns: P ? 'repeat(2, 1fr)' : 'repeat(4, 1fr)', gap: P ? 18 : 18 }}>
|
| 150 |
+
{GROUPS.map(([g, n], i) => {
|
| 151 |
+
const q = tw(S.lt(0), fr(0, '八大') - 0.6 + i * 0.12, 0.6)
|
| 152 |
+
return (
|
| 153 |
+
<div key={g} style={{ opacity: clamp(q * 1.4), transform: `translateY(${((1 - E.out(q)) * 24).toFixed(1)}px)` }}>
|
| 154 |
+
<Card pad={P ? '20px 24px' : '20px 22px'} r={16} tint={i < 2 ? C.gold : undefined}>
|
| 155 |
+
<div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', gap: 8 }}>
|
| 156 |
+
<div style={cn(P ? 28 : 26, 800)}>{g}</div>
|
| 157 |
+
<div style={txtStyle({ f: 'num', size: P ? 40 : 38, w: 800, color: C.goldHi })}>{n}</div>
|
| 158 |
+
</div>
|
| 159 |
+
<div style={{ height: 6, borderRadius: 3, background: C.hair, marginTop: 14, overflow: 'hidden' }}>
|
| 160 |
+
<div style={{ width: `${((n / GROUPS[0][1]) * 100 * E.out(q)).toFixed(1)}%`, height: '100%', background: `linear-gradient(90deg, ${C.goldDeep}, ${C.goldHi})` }} />
|
| 161 |
+
</div>
|
| 162 |
+
</Card>
|
| 163 |
+
</div>
|
| 164 |
+
)
|
| 165 |
+
})}
|
| 166 |
+
</div>
|
| 167 |
+
</Beat>
|
| 168 |
+
|
| 169 |
+
{/* 1:三个根本问题 */}
|
| 170 |
+
<Beat k={1} to={2} x={0} y={P ? 300 : 250} w={W} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }} rise={0}>
|
| 171 |
+
<Tag text="WHY IT MATTERS" p={p(1, 0.2)} />
|
| 172 |
+
<T p={p(1, 0.5)} style={{ ...serif(P ? 54 : 52), marginTop: 20, textAlign: 'center' }}>
|
| 173 |
+
房价背后的三个根本问题
|
| 174 |
+
</T>
|
| 175 |
+
<div style={{ display: 'flex', flexDirection: P ? 'column' : 'row', gap: P ? 22 : 30, marginTop: P ? 46 : 46 }}>
|
| 176 |
+
{QUESTIONS.map((it, i) => {
|
| 177 |
+
const q = tw(S.lt(1), fr(1, it.w) - 0.2, 0.7)
|
| 178 |
+
return (
|
| 179 |
+
<div key={it.q} style={{ width: P ? cw : 500, opacity: clamp(q * 1.4), transform: `translateY(${((1 - E.out(q)) * 30).toFixed(1)}px)` }}>
|
| 180 |
+
<Card pad={P ? '26px 34px' : '32px 34px'} tint={C.gold} glow={q > 0.5 ? C.gold : undefined}>
|
| 181 |
+
<div style={mono(P ? 20 : 18, C.gold, 700, 3)}>{`Q${i + 1}`}</div>
|
| 182 |
+
<div style={{ ...serif(P ? 60 : 62), marginTop: 8 }}>{it.q}?</div>
|
| 183 |
+
<div style={{ ...cn(P ? 26 : 24, 500, C.mute), marginTop: 12 }}>{it.basis}</div>
|
| 184 |
+
</Card>
|
| 185 |
+
</div>
|
| 186 |
+
)
|
| 187 |
+
})}
|
| 188 |
+
</div>
|
| 189 |
+
<T p={p(1, fr(1, '十五年后'))} style={{ marginTop: P ? 46 : 44, display: 'flex', alignItems: 'baseline', gap: 16, justifyContent: 'center' }}>
|
| 190 |
+
<div style={cn(P ? 32 : 30, 700, C.ink)}>十五年后,城市分化类判断命中</div>
|
| 191 |
+
<div style={{ ...txtStyle({ f: 'num', size: P ? 64 : 60, w: 800, color: C.green }) }}>{`${CITY_HIT}%`}</div>
|
| 192 |
+
</T>
|
| 193 |
+
</Beat>
|
| 194 |
+
|
| 195 |
+
{/* 2:AI 推演声明 */}
|
| 196 |
+
<Beat k={2} to={3} x={0} y={P ? 420 : 250} w={W} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }} rise={0}>
|
| 197 |
+
<Tag text="AI OUTLOOK · BASED ON KKNDME'S FRAMEWORK" p={p(2, 0.2)} color={AMBER} />
|
| 198 |
+
<T p={p(2, 0.5)} style={{ ...serif(P ? 76 : 80), marginTop: 26, textAlign: 'center' }}>
|
| 199 |
+
未来房价,<span style={goldText()}>会怎么走?</span>
|
| 200 |
+
</T>
|
| 201 |
+
<div style={{ marginTop: P ? 56 : 46, opacity: clamp(p(2, fr(2, '以下'), 0.7) * 1.4), transform: `scale(${lerp(0.94, 1, p(2, fr(2, '以下'), 0.7)).toFixed(3)})` }}>
|
| 202 |
+
<div style={{ display: 'flex', flexDirection: P ? 'column' : 'row', alignItems: 'center', gap: P ? 24 : 40, padding: P ? '36px 44px' : '34px 52px', borderRadius: 28, border: `2px solid ${hexA(AMBER, 0.75)}`, background: 'linear-gradient(155deg, rgba(224,168,74,0.16), rgba(217,119,87,0.08))', maxWidth: cw }}>
|
| 203 |
+
<Clawd w={P ? 170 : 170} t={S.t} />
|
| 204 |
+
<div style={{ textAlign: P ? 'center' : 'left' }}>
|
| 205 |
+
<div style={cn(P ? 40 : 40, 800, C.ink)}>
|
| 206 |
+
以下由 <span style={{ color: '#F3A283' }}>AI</span> 引用 KKndme 理论框架推演
|
| 207 |
+
</div>
|
| 208 |
+
<div style={{ ...cn(P ? 26 : 26, 500, C.mute), marginTop: 12 }}>仅代表对其理论框架的推演,不代表任何机构观点</div>
|
| 209 |
+
<div style={{ display: 'flex', justifyContent: P ? 'center' : 'flex-start', marginTop: 22 }}>
|
| 210 |
+
<Stamp text="不构成投资建议" p={p(2, fr(2, '不构成') - 0.1, 0.6, E.lin)} size={P ? 52 : 50} rot={-3} color={AMBER} />
|
| 211 |
+
</div>
|
| 212 |
+
</div>
|
| 213 |
+
</div>
|
| 214 |
+
</div>
|
| 215 |
+
</Beat>
|
| 216 |
+
|
| 217 |
+
{/* 3–5:三条推演 */}
|
| 218 |
+
<Beat k={3} to={6} x={M} y={P ? 340 : 270} w={cw}>
|
| 219 |
+
<div style={{ display: 'flex', flexDirection: P ? 'column' : 'row', gap: P ? 24 : 30 }}>
|
| 220 |
+
{OUTLOOK.map((o, i) => {
|
| 221 |
+
const q = p(3 + i, 0.1, 0.8)
|
| 222 |
+
const hl = cur === i
|
| 223 |
+
if (q <= 0.001) return <div key={o.no} style={{ width: P ? cw : (cw - 60) / 3, height: P ? 300 : 520 }} />
|
| 224 |
+
return (
|
| 225 |
+
<div key={o.no} style={{ width: P ? cw : (cw - 60) / 3, opacity: clamp(q * 1.4) * (hl ? 1 : 0.5), transform: `translateY(${((1 - q) * 30).toFixed(1)}px) scale(${hl ? 1.02 : 1})`, transformOrigin: 'center top', filter: hl ? undefined : 'saturate(0.6)' }}>
|
| 226 |
+
<Card pad={P ? '28px 34px' : '34px 34px'} tint={hl ? o.col : undefined} glow={hl ? o.col : undefined} style={{ height: P ? 300 : 520, display: 'flex', flexDirection: P ? 'row' : 'column', gap: P ? 30 : 0, alignItems: P ? 'center' : undefined }}>
|
| 227 |
+
<div style={{ flex: 'none' }}>
|
| 228 |
+
<div style={mono(P ? 22 : 22, o.col, 700, 3)}>{o.no}</div>
|
| 229 |
+
<div style={{ marginTop: 14 }}>
|
| 230 |
+
<TrendIcon kind={o.kind} size={P ? 150 : 150} col={o.col} p={p(3 + i, 0.4, 1.2)} />
|
| 231 |
+
</div>
|
| 232 |
+
</div>
|
| 233 |
+
<div>
|
| 234 |
+
<div style={{ ...serif(P ? 62 : 64), marginTop: P ? 0 : 26 }}>{o.t}</div>
|
| 235 |
+
<div style={{ display: 'inline-block', marginTop: 16, padding: '6px 14px', borderRadius: 10, background: hexA(o.col, 0.14), border: `1px solid ${hexA(o.col, 0.45)}`, ...cn(P ? 22 : 21, 700, C.ink2) }}>依据:{o.basis}</div>
|
| 236 |
+
<div style={{ ...cn(P ? 30 : 30, 600, C.ink), marginTop: 18 }}>{o.d}</div>
|
| 237 |
+
</div>
|
| 238 |
+
</Card>
|
| 239 |
+
</div>
|
| 240 |
+
)
|
| 241 |
+
})}
|
| 242 |
+
</div>
|
| 243 |
+
</Beat>
|
| 244 |
+
|
| 245 |
+
{/* 6:货币蓄水池逻辑打折扣 */}
|
| 246 |
+
<Beat k={6} to={7} x={0} y={P ? 380 : 270} w={W} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }} rise={0}>
|
| 247 |
+
<Tag text="CAVEAT · 需要注意" p={p(6, 0.2)} color={C.red} />
|
| 248 |
+
<div style={{ position: 'relative', marginTop: 30 }}>
|
| 249 |
+
<T p={p(6, 0.4)} style={{ ...serif(P ? 74 : 84), textAlign: 'center' }}>
|
| 250 |
+
“货币蓄水池”
|
| 251 |
+
</T>
|
| 252 |
+
{(() => {
|
| 253 |
+
const q = p(6, fr(6, '打了折扣'), 0.6)
|
| 254 |
+
return q > 0 ? <div style={{ position: 'absolute', left: -20, right: -20, top: '52%', height: 6, background: C.red, boxShadow: `0 0 22px ${C.red}`, transform: `rotate(-3deg) scaleX(${q.toFixed(3)})`, transformOrigin: 'left center' }} /> : null
|
| 255 |
+
})()}
|
| 256 |
+
</div>
|
| 257 |
+
<T p={p(6, fr(6, '打了折扣') + 0.3)} style={{ ...cn(P ? 34 : 34, 700, C.red), marginTop: 18 }}>
|
| 258 |
+
逻辑已经打了折扣
|
| 259 |
+
</T>
|
| 260 |
+
<div style={{ display: 'flex', flexDirection: P ? 'column' : 'row', gap: P ? 24 : 40, marginTop: P ? 56 : 50, alignItems: 'center' }}>
|
| 261 |
+
{[
|
| 262 |
+
{ l: 'M2 · 2010→2025', v: '×4.7', col: C.goldHi, at: fr(6, '钱越来越多') },
|
| 263 |
+
{ l: '房价 · 2021Q3 见顶后', v: '−22%', col: C.red, at: fr(6, '房价却') },
|
| 264 |
+
].map((it, i) => (
|
| 265 |
+
<React.Fragment key={it.l}>
|
| 266 |
+
{i === 1 && <div style={{ ...serif(P ? 60 : 64, C.dim), opacity: p(6, it.at - 0.3) }}>≠</div>}
|
| 267 |
+
<T p={p(6, it.at - 0.2)}>
|
| 268 |
+
<Card pad={P ? '24px 40px' : '26px 44px'} tint={it.col}>
|
| 269 |
+
<div style={mono(P ? 20 : 18, C.mute, 600, 2)}>{it.l}</div>
|
| 270 |
+
<div style={{ ...txtStyle({ f: 'num', size: P ? 96 : 96, w: 800, color: it.col, ls: -2 }), marginTop: 6 }}>{it.v}</div>
|
| 271 |
+
</Card>
|
| 272 |
+
</T>
|
| 273 |
+
</React.Fragment>
|
| 274 |
+
))}
|
| 275 |
+
</div>
|
| 276 |
+
</Beat>
|
| 277 |
+
|
| 278 |
+
{/* 7:结论 + 再次声明 */}
|
| 279 |
+
<Beat k={7} x={0} y={P ? 400 : 260} w={W} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }} rise={0}>
|
| 280 |
+
<T p={p(7, 0.2)} style={{ ...cn(P ? 38 : 36, 600, C.mute) }}>未来买房,买的不是</T>
|
| 281 |
+
<div style={{ position: 'relative', marginTop: 18 }}>
|
| 282 |
+
<T p={p(7, 0.6)} style={{ ...serif(P ? 84 : 92, C.ink2) }}>
|
| 283 |
+
“中国房价”
|
| 284 |
+
</T>
|
| 285 |
+
{(() => {
|
| 286 |
+
const q = p(7, fr(7, '而是') - 0.3, 0.5)
|
| 287 |
+
return q > 0 ? <div style={{ position: 'absolute', left: -16, right: -16, top: '52%', height: 5, background: C.red, transform: `scaleX(${q.toFixed(3)})`, transformOrigin: 'left center' }} /> : null
|
| 288 |
+
})()}
|
| 289 |
+
</div>
|
| 290 |
+
<T p={p(7, fr(7, '而是'))} style={{ marginTop: P ? 34 : 26, textAlign: 'center' }}>
|
| 291 |
+
<div style={cn(P ? 38 : 36, 600, C.mute)}>而是</div>
|
| 292 |
+
<div style={{ ...txtStyle({ f: 'serif', size: P ? 100 : 108, w: 900, lh: 1.15 }), ...shineStyle(tw(S.lt(7), fr(7, '而是') + 0.4, 1.6) * 1.6 - 0.3), marginTop: 10 }}>具体的城市和地段</div>
|
| 293 |
+
</T>
|
| 294 |
+
<div style={{ marginTop: P ? 70 : 50, opacity: clamp(p(7, fr(7, '再强调'), 0.6) * 1.4) }}>
|
| 295 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 18, padding: P ? '22px 32px' : '20px 36px', borderRadius: 20, border: `2px solid ${hexA(AMBER, 0.8)}`, background: hexA(AMBER, 0.1), maxWidth: cw }}>
|
| 296 |
+
<svg width={44} height={44} viewBox="0 0 44 44" style={{ flex: 'none' }}>
|
| 297 |
+
<path d="M22 4 L41 38 L3 38 Z" fill="none" stroke={AMBER} strokeWidth={3.5} strokeLinejoin="round" />
|
| 298 |
+
<path d="M22 16 L22 27" stroke={AMBER} strokeWidth={4} strokeLinecap="round" />
|
| 299 |
+
<circle cx={22} cy={32.5} r={2.4} fill={AMBER} />
|
| 300 |
+
</svg>
|
| 301 |
+
<div style={{ ...cn(P ? 28 : 30, 700, C.ink), whiteSpace: P ? 'normal' : 'nowrap' }}>
|
| 302 |
+
AI 基于 KKndme 理论框架的推演,<span style={{ color: AMBER }}>不构成任何投资建议</span>
|
| 303 |
+
</div>
|
| 304 |
+
</div>
|
| 305 |
+
</div>
|
| 306 |
+
</Beat>
|
| 307 |
+
</>
|
| 308 |
+
)
|
| 309 |
+
}
|
| 310 |
+
|
kkndme/frontend/src/rv/theme.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Remotion 版视频:配色、字体、缓动
|
| 2 |
+
export const C = {
|
| 3 |
+
bg: '#060709',
|
| 4 |
+
bg2: '#0B0D12',
|
| 5 |
+
ink: '#F3EEE4',
|
| 6 |
+
ink2: 'rgba(243,238,228,0.78)',
|
| 7 |
+
mute: 'rgba(243,238,228,0.56)',
|
| 8 |
+
dim: 'rgba(243,238,228,0.34)',
|
| 9 |
+
faint: 'rgba(243,238,228,0.14)',
|
| 10 |
+
hair: 'rgba(243,238,228,0.08)',
|
| 11 |
+
gold: '#D8B26E',
|
| 12 |
+
goldHi: '#F4DDA8',
|
| 13 |
+
goldDeep: '#9C7A3C',
|
| 14 |
+
green: '#4CC38A',
|
| 15 |
+
red: '#EA6A5F',
|
| 16 |
+
amber: '#E0A84A',
|
| 17 |
+
blue: '#6E9BF5',
|
| 18 |
+
sky: '#8FB8EA',
|
| 19 |
+
purple: '#B08AE6',
|
| 20 |
+
gray: '#8E939C',
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
export const STATUS_COLOR: Record<string, string> = {
|
| 24 |
+
correct: C.green,
|
| 25 |
+
wrong: C.red,
|
| 26 |
+
disputed: C.amber,
|
| 27 |
+
pending_lean: C.blue,
|
| 28 |
+
pending_against: C.purple,
|
| 29 |
+
pending_neutral: C.gray,
|
| 30 |
+
pending: C.blue,
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
export const F = {
|
| 34 |
+
serif: '"KKSerif", "Noto Serif SC", "Songti SC", serif',
|
| 35 |
+
sans: '"Inter", "KKSans", "Noto Sans SC", "PingFang SC", sans-serif',
|
| 36 |
+
cn: '"KKSans", "Noto Sans SC", "PingFang SC", sans-serif',
|
| 37 |
+
mono: '"JBMono", "KKSans", monospace',
|
| 38 |
+
num: '"Inter", "KKSans", sans-serif',
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
export const clamp = (v: number, a = 0, b = 1) => Math.min(b, Math.max(a, v))
|
| 42 |
+
export const lerp = (a: number, b: number, p: number) => a + (b - a) * p
|
| 43 |
+
export const prog = (t: number, s: number, d: number) => clamp((t - s) / Math.max(1e-6, d))
|
| 44 |
+
|
| 45 |
+
const bez = (x1: number, y1: number, x2: number, y2: number) => {
|
| 46 |
+
// 牛顿迭代求解三次贝塞尔
|
| 47 |
+
const cx = 3 * x1
|
| 48 |
+
const bx = 3 * (x2 - x1) - cx
|
| 49 |
+
const ax = 1 - cx - bx
|
| 50 |
+
const cy = 3 * y1
|
| 51 |
+
const by = 3 * (y2 - y1) - cy
|
| 52 |
+
const ay = 1 - cy - by
|
| 53 |
+
const sx = (t: number) => ((ax * t + bx) * t + cx) * t
|
| 54 |
+
const sy = (t: number) => ((ay * t + by) * t + cy) * t
|
| 55 |
+
const dx = (t: number) => (3 * ax * t + 2 * bx) * t + cx
|
| 56 |
+
return (x: number) => {
|
| 57 |
+
if (x <= 0) return 0
|
| 58 |
+
if (x >= 1) return 1
|
| 59 |
+
let t = x
|
| 60 |
+
for (let i = 0; i < 8; i++) {
|
| 61 |
+
const e = sx(t) - x
|
| 62 |
+
const d = dx(t)
|
| 63 |
+
if (Math.abs(e) < 1e-5 || Math.abs(d) < 1e-6) break
|
| 64 |
+
t -= e / d
|
| 65 |
+
}
|
| 66 |
+
return sy(clamp(t))
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/** 缓动曲线 */
|
| 71 |
+
export const E = {
|
| 72 |
+
out: bez(0.16, 1, 0.3, 1), // expo-out:干脆利落
|
| 73 |
+
out3: (p: number) => 1 - Math.pow(1 - clamp(p), 3),
|
| 74 |
+
inOut: bez(0.65, 0, 0.35, 1),
|
| 75 |
+
soft: bez(0.4, 0, 0.2, 1),
|
| 76 |
+
in: bez(0.7, 0, 0.84, 0),
|
| 77 |
+
back: bez(0.34, 1.56, 0.64, 1),
|
| 78 |
+
lin: (p: number) => clamp(p),
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/** 时间 t 在 [s, s+d] 内的缓动进度 */
|
| 82 |
+
export const tw = (t: number, s: number, d: number, e: (p: number) => number = E.out) => e(prog(t, s, d))
|
| 83 |
+
|
| 84 |
+
/** 解析弹簧(与帧率无关):t 秒后的位置,0→1 */
|
| 85 |
+
export function spr(t: number, o: { k?: number; z?: number } = {}) {
|
| 86 |
+
if (t <= 0) return 0
|
| 87 |
+
const w = o.k ?? 12 // 固有角频率
|
| 88 |
+
const z = o.z ?? 0.62 // 阻尼比
|
| 89 |
+
if (z >= 1) return 1 - Math.exp(-w * t) * (1 + w * t)
|
| 90 |
+
const wd = w * Math.sqrt(1 - z * z)
|
| 91 |
+
return 1 - Math.exp(-z * w * t) * (Math.cos(wd * t) + ((z * w) / wd) * Math.sin(wd * t))
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
export function hexA(hex: string, a: number) {
|
| 95 |
+
if (hex.startsWith('rgba')) return hex
|
| 96 |
+
const h = hex.replace('#', '')
|
| 97 |
+
const n = parseInt(h.length === 3 ? h.split('').map((x) => x + x).join('') : h, 16)
|
| 98 |
+
return `rgba(${(n >> 16) & 255},${(n >> 8) & 255},${n & 255},${a})`
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
/** 确定性伪随机 */
|
| 102 |
+
export function rand(i: number, s = 0) {
|
| 103 |
+
const x = Math.sin(i * 127.1 + s * 311.7) * 43758.5453
|
| 104 |
+
return x - Math.floor(x)
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
export const fmt = (v: number, dec = 0) => v.toLocaleString('en-US', { minimumFractionDigits: dec, maximumFractionDigits: dec })
|
kkndme/frontend/src/rv/ui.tsx
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react'
|
| 2 |
+
import { C, E, F, clamp, hexA, lerp, tw } from './theme'
|
| 3 |
+
|
| 4 |
+
type CSS = React.CSSProperties
|
| 5 |
+
|
| 6 |
+
// ---------- 定位与文字 ----------
|
| 7 |
+
export function Abs({ x = 0, y = 0, w, h, ax = 0, ay = 0, style, children, o = 1 }: { x?: number; y?: number; w?: number; h?: number; ax?: number; ay?: number; style?: CSS; children?: React.ReactNode; o?: number }) {
|
| 8 |
+
if (o <= 0.001) return null
|
| 9 |
+
const tf = [ax || ay ? `translate(${-ax * 100}%, ${-ay * 100}%)` : '', style?.transform ?? ''].join(' ').trim()
|
| 10 |
+
return (
|
| 11 |
+
<div
|
| 12 |
+
style={{
|
| 13 |
+
position: 'absolute',
|
| 14 |
+
left: x,
|
| 15 |
+
top: y,
|
| 16 |
+
width: w,
|
| 17 |
+
height: h,
|
| 18 |
+
...style,
|
| 19 |
+
opacity: o < 1 ? o * (typeof style?.opacity === 'number' ? style.opacity : 1) : style?.opacity,
|
| 20 |
+
transform: tf || undefined,
|
| 21 |
+
}}
|
| 22 |
+
>
|
| 23 |
+
{children}
|
| 24 |
+
</div>
|
| 25 |
+
)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
export interface TxtProps {
|
| 29 |
+
f?: keyof typeof F
|
| 30 |
+
size: number
|
| 31 |
+
w?: number
|
| 32 |
+
color?: string
|
| 33 |
+
ls?: number
|
| 34 |
+
lh?: number
|
| 35 |
+
align?: 'left' | 'center' | 'right'
|
| 36 |
+
style?: CSS
|
| 37 |
+
children?: React.ReactNode
|
| 38 |
+
nowrap?: boolean
|
| 39 |
+
}
|
| 40 |
+
export function txtStyle({ f = 'sans', size, w = 700, color = C.ink, ls, lh = 1.15, align, nowrap = true }: Omit<TxtProps, 'children' | 'style'>): CSS {
|
| 41 |
+
return {
|
| 42 |
+
fontFamily: F[f],
|
| 43 |
+
fontSize: size,
|
| 44 |
+
fontWeight: w,
|
| 45 |
+
color,
|
| 46 |
+
letterSpacing: ls !== undefined ? ls : undefined,
|
| 47 |
+
lineHeight: lh,
|
| 48 |
+
textAlign: align,
|
| 49 |
+
whiteSpace: nowrap ? 'nowrap' : 'normal',
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
export function Txt(p: TxtProps) {
|
| 53 |
+
return <div style={{ ...txtStyle(p), ...p.style }}>{p.children}</div>
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/** 遮罩上滑显现 */
|
| 57 |
+
export function Reveal({ p, children, style, dir = 1 }: { p: number; children: React.ReactNode; style?: CSS; dir?: number }) {
|
| 58 |
+
if (p <= 0.001) return <div style={{ ...style, visibility: 'hidden' }}>{children}</div>
|
| 59 |
+
const q = E.out(p)
|
| 60 |
+
return (
|
| 61 |
+
<div style={{ overflow: 'hidden', paddingBottom: '0.12em', marginBottom: '-0.12em', ...style }}>
|
| 62 |
+
<div style={{ transform: `translateY(${(1 - q) * 108 * dir}%)`, opacity: clamp(p * 3) }}>{children}</div>
|
| 63 |
+
</div>
|
| 64 |
+
)
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/** 模糊淡入 */
|
| 68 |
+
export function BlurIn({ p, children, dy = 26, blur = 14, scale = 0, style, dx = 0 }: { p: number; children: React.ReactNode; dy?: number; blur?: number; scale?: number; style?: CSS; dx?: number }) {
|
| 69 |
+
if (p <= 0.001) return null
|
| 70 |
+
const q = clamp(p)
|
| 71 |
+
const b = (1 - q) * blur
|
| 72 |
+
return (
|
| 73 |
+
<div
|
| 74 |
+
style={{
|
| 75 |
+
opacity: clamp(q * 1.4),
|
| 76 |
+
transform: `translate(${(1 - q) * dx}px, ${(1 - q) * dy}px)${scale ? ` scale(${1 + (1 - q) * scale})` : ''}`,
|
| 77 |
+
filter: b > 0.3 ? `blur(${b.toFixed(1)}px)` : undefined,
|
| 78 |
+
...style,
|
| 79 |
+
}}
|
| 80 |
+
>
|
| 81 |
+
{children}
|
| 82 |
+
</div>
|
| 83 |
+
)
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/** 逐字出现:t = 距开始秒数 */
|
| 87 |
+
export function Chars({
|
| 88 |
+
text,
|
| 89 |
+
t,
|
| 90 |
+
st = 0.045,
|
| 91 |
+
d = 0.7,
|
| 92 |
+
dy = 0.5,
|
| 93 |
+
blur = 10,
|
| 94 |
+
style,
|
| 95 |
+
charStyle,
|
| 96 |
+
colorAt,
|
| 97 |
+
}: {
|
| 98 |
+
text: string
|
| 99 |
+
t: number
|
| 100 |
+
st?: number
|
| 101 |
+
d?: number
|
| 102 |
+
dy?: number
|
| 103 |
+
blur?: number
|
| 104 |
+
style?: CSS
|
| 105 |
+
charStyle?: (i: number, p: number) => CSS | undefined
|
| 106 |
+
colorAt?: (i: number) => string | undefined
|
| 107 |
+
}) {
|
| 108 |
+
const chars = Array.from(text)
|
| 109 |
+
return (
|
| 110 |
+
<div style={{ display: 'flex', whiteSpace: 'pre', ...style }}>
|
| 111 |
+
{chars.map((ch, i) => {
|
| 112 |
+
const p = tw(t, i * st, d, E.out)
|
| 113 |
+
const b = (1 - p) * blur
|
| 114 |
+
return (
|
| 115 |
+
<span
|
| 116 |
+
key={i}
|
| 117 |
+
style={{
|
| 118 |
+
display: 'inline-block',
|
| 119 |
+
opacity: p <= 0.001 ? 0 : clamp(p * 1.6),
|
| 120 |
+
transform: `translateY(${((1 - p) * dy).toFixed(3)}em)`,
|
| 121 |
+
filter: b > 0.3 && p > 0.001 ? `blur(${b.toFixed(1)}px)` : undefined,
|
| 122 |
+
color: colorAt?.(i),
|
| 123 |
+
...charStyle?.(i, p),
|
| 124 |
+
}}
|
| 125 |
+
>
|
| 126 |
+
{ch}
|
| 127 |
+
</span>
|
| 128 |
+
)
|
| 129 |
+
})}
|
| 130 |
+
</div>
|
| 131 |
+
)
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
/** 老虎机数字滚动。p: 0→1 */
|
| 135 |
+
export function Roll({ value, p, style, spins = 2, color }: { value: string; p: number; style?: CSS; spins?: number; color?: string }) {
|
| 136 |
+
const chars = Array.from(value)
|
| 137 |
+
const digitIdx = chars.map((c, i) => (/\d/.test(c) ? chars.slice(i + 1).filter((x) => /\d/.test(x)).length : -1))
|
| 138 |
+
return (
|
| 139 |
+
<div style={{ display: 'flex', whiteSpace: 'pre', color, ...style }}>
|
| 140 |
+
{chars.map((ch, i) => {
|
| 141 |
+
if (!/\d/.test(ch)) {
|
| 142 |
+
return (
|
| 143 |
+
<span key={i} style={{ display: 'inline-block', opacity: clamp(p * 3) }}>
|
| 144 |
+
{ch}
|
| 145 |
+
</span>
|
| 146 |
+
)
|
| 147 |
+
}
|
| 148 |
+
const k = digitIdx[i]
|
| 149 |
+
const target = Number(ch)
|
| 150 |
+
const total = (spins + Math.min(k, 3)) * 10 + target
|
| 151 |
+
const pk = E.out(clamp(p * (1 + k * 0.12) - k * 0.02))
|
| 152 |
+
const pk2 = E.out(clamp((p - 0.02) * (1 + k * 0.12) - k * 0.02))
|
| 153 |
+
const pos = total * pk
|
| 154 |
+
const vel = Math.abs(pos - total * pk2)
|
| 155 |
+
const base = Math.floor(pos)
|
| 156 |
+
const fr = pos - base
|
| 157 |
+
const blur = Math.min(6, vel * 4)
|
| 158 |
+
return (
|
| 159 |
+
<span key={i} style={{ display: 'inline-block', position: 'relative', overflow: 'hidden', height: '1.08em', lineHeight: '1.08em', verticalAlign: 'top' }}>
|
| 160 |
+
<span style={{ visibility: 'hidden' }}>0</span>
|
| 161 |
+
<span style={{ position: 'absolute', left: 0, right: 0, top: 0, textAlign: 'center', transform: `translateY(${(-fr * 100).toFixed(2)}%)`, filter: blur > 0.4 ? `blur(${blur.toFixed(1)}px)` : undefined, opacity: p <= 0 ? 0 : 1 }}>
|
| 162 |
+
{base % 10}
|
| 163 |
+
</span>
|
| 164 |
+
{fr > 0.001 && (
|
| 165 |
+
<span style={{ position: 'absolute', left: 0, right: 0, top: 0, textAlign: 'center', transform: `translateY(${((1 - fr) * 100).toFixed(2)}%)`, filter: blur > 0.4 ? `blur(${blur.toFixed(1)}px)` : undefined }}>
|
| 166 |
+
{(base + 1) % 10}
|
| 167 |
+
</span>
|
| 168 |
+
)}
|
| 169 |
+
</span>
|
| 170 |
+
)
|
| 171 |
+
})}
|
| 172 |
+
</div>
|
| 173 |
+
)
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
/** 数值插值显示 */
|
| 177 |
+
export const countTo = (v: number, p: number, dec = 0) => (v * clamp(p)).toLocaleString('en-US', { minimumFractionDigits: dec, maximumFractionDigits: dec })
|
| 178 |
+
|
| 179 |
+
// ---------- 容器 ----------
|
| 180 |
+
export function Glass({ x, y, w, h, r = 22, tint, children, style, o = 1, glow }: { x: number; y: number; w: number; h?: number; r?: number; tint?: string; children?: React.ReactNode; style?: CSS; o?: number; glow?: string }) {
|
| 181 |
+
if (o <= 0.001) return null
|
| 182 |
+
return (
|
| 183 |
+
<div
|
| 184 |
+
style={{
|
| 185 |
+
position: 'absolute',
|
| 186 |
+
left: x,
|
| 187 |
+
top: y,
|
| 188 |
+
width: w,
|
| 189 |
+
height: h,
|
| 190 |
+
borderRadius: r,
|
| 191 |
+
background: `linear-gradient(155deg, ${tint ? hexA(tint, 0.16) : 'rgba(255,255,255,0.075)'} 0%, rgba(255,255,255,0.025) 55%, rgba(255,255,255,0.015) 100%)`,
|
| 192 |
+
border: `1px solid ${tint ? hexA(tint, 0.42) : 'rgba(243,238,228,0.13)'}`,
|
| 193 |
+
boxShadow: glow ? `0 0 60px ${hexA(glow, 0.22)}, 0 30px 70px rgba(0,0,0,0.5)` : '0 30px 70px rgba(0,0,0,0.5)',
|
| 194 |
+
opacity: o < 1 ? o : undefined,
|
| 195 |
+
...style,
|
| 196 |
+
}}
|
| 197 |
+
>
|
| 198 |
+
<div style={{ position: 'absolute', left: r, right: r, top: 0, height: 1, background: `linear-gradient(90deg, transparent, ${tint ? hexA(tint, 0.8) : 'rgba(255,255,255,0.35)'}, transparent)` }} />
|
| 199 |
+
{children}
|
| 200 |
+
</div>
|
| 201 |
+
)
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
/** 小标题:金色短线 + 等宽字母 */
|
| 205 |
+
export function Kicker({ text, p = 1, color = C.gold, size = 20, style }: { text: string; p?: number; color?: string; size?: number; style?: CSS }) {
|
| 206 |
+
if (p <= 0.001) return null
|
| 207 |
+
return (
|
| 208 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: 14, opacity: clamp(p * 1.5), ...style }}>
|
| 209 |
+
<div style={{ width: 36 * E.out(p), height: 2, background: color }} />
|
| 210 |
+
<div style={{ ...txtStyle({ f: 'mono', size, w: 700, color, ls: lerp(10, 3, E.out(p)) }) }}>{text}</div>
|
| 211 |
+
</div>
|
| 212 |
+
)
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
export type ChipKind = 'ok' | 'no' | 'mid' | 'lean' | 'against' | 'wait'
|
| 216 |
+
const CHIP: Record<ChipKind, { c: string; label: string }> = {
|
| 217 |
+
ok: { c: C.green, label: '说对' },
|
| 218 |
+
no: { c: C.red, label: '说错' },
|
| 219 |
+
mid: { c: C.amber, label: '存疑' },
|
| 220 |
+
lean: { c: C.blue, label: '偏向' },
|
| 221 |
+
against: { c: C.purple, label: '偏离' },
|
| 222 |
+
wait: { c: C.gray, label: '待定' },
|
| 223 |
+
}
|
| 224 |
+
export function Icon({ kind, size = 22, color, p = 1 }: { kind: ChipKind; size?: number; color?: string; p?: number }) {
|
| 225 |
+
const col = color ?? CHIP[kind].c
|
| 226 |
+
const L = 30
|
| 227 |
+
const d =
|
| 228 |
+
kind === 'ok'
|
| 229 |
+
? 'M6 16 L13 23 L26 9'
|
| 230 |
+
: kind === 'no'
|
| 231 |
+
? 'M8 8 L24 24 M24 8 L8 24'
|
| 232 |
+
: kind === 'mid'
|
| 233 |
+
? 'M7 16 L25 16'
|
| 234 |
+
: kind === 'lean'
|
| 235 |
+
? 'M7 22 L16 10 L25 22'
|
| 236 |
+
: kind === 'against'
|
| 237 |
+
? 'M7 10 L16 22 L25 10'
|
| 238 |
+
: 'M16 7 L16 16 L22 20'
|
| 239 |
+
return (
|
| 240 |
+
<svg width={size} height={size} viewBox="0 0 32 32" style={{ display: 'block', overflow: 'visible' }}>
|
| 241 |
+
{kind === 'wait' && <circle cx="16" cy="16" r="11" fill="none" stroke={col} strokeWidth="3" opacity={0.6} />}
|
| 242 |
+
<path d={d} fill="none" stroke={col} strokeWidth="4" strokeLinecap="round" strokeLinejoin="round" strokeDasharray={L * 1.4} strokeDashoffset={L * 1.4 * (1 - E.out(p))} />
|
| 243 |
+
</svg>
|
| 244 |
+
)
|
| 245 |
+
}
|
| 246 |
+
export function Chip({ kind, text, p = 1, size = 24, style }: { kind: ChipKind; text?: string; p?: number; size?: number; style?: CSS }) {
|
| 247 |
+
if (p <= 0.001) return null
|
| 248 |
+
const c = CHIP[kind].c
|
| 249 |
+
const q = E.back(clamp(p * 1.2))
|
| 250 |
+
return (
|
| 251 |
+
<div
|
| 252 |
+
style={{
|
| 253 |
+
display: 'inline-flex',
|
| 254 |
+
alignItems: 'center',
|
| 255 |
+
gap: size * 0.38,
|
| 256 |
+
padding: `${size * 0.34}px ${size * 0.7}px ${size * 0.34}px ${size * 0.5}px`,
|
| 257 |
+
borderRadius: 999,
|
| 258 |
+
background: `linear-gradient(90deg, ${hexA(c, 0.22)}, ${hexA(c, 0.08)})`,
|
| 259 |
+
border: `1.5px solid ${hexA(c, 0.65)}`,
|
| 260 |
+
boxShadow: `0 0 28px ${hexA(c, 0.25)}`,
|
| 261 |
+
opacity: clamp(p * 2),
|
| 262 |
+
transform: `scale(${lerp(0.7, 1, q)})`,
|
| 263 |
+
transformOrigin: 'left center',
|
| 264 |
+
whiteSpace: 'nowrap',
|
| 265 |
+
...style,
|
| 266 |
+
}}
|
| 267 |
+
>
|
| 268 |
+
<Icon kind={kind} size={size * 1.05} p={clamp(p * 1.5 - 0.3)} />
|
| 269 |
+
<span style={txtStyle({ f: 'sans', size, w: 800, color: C.ink })}>{text ?? CHIP[kind].label}</span>
|
| 270 |
+
</div>
|
| 271 |
+
)
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
/** 水平分隔线(从左展开) */
|
| 275 |
+
export function HLine({ x, y, w, p, color = C.gold, h = 2, o = 1, style }: { x: number; y: number; w: number; p: number; color?: string; h?: number; o?: number; style?: CSS }) {
|
| 276 |
+
if (p <= 0.001) return null
|
| 277 |
+
return <div style={{ position: 'absolute', left: x, top: y, width: w * E.out(p), height: h, background: color, opacity: o, ...style }} />
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
/** 高亮光扫文字(背景裁切到文字) */
|
| 281 |
+
export function shineStyle(sweep: number, base: string = C.goldHi, hi = '#FFFFFF'): CSS {
|
| 282 |
+
const s = sweep * 140 - 20
|
| 283 |
+
return {
|
| 284 |
+
backgroundImage: `linear-gradient(100deg, ${base} ${s - 18}%, ${hi} ${s}%, ${base} ${s + 18}%)`,
|
| 285 |
+
backgroundClip: 'text',
|
| 286 |
+
WebkitBackgroundClip: 'text',
|
| 287 |
+
color: 'transparent',
|
| 288 |
+
WebkitTextFillColor: 'transparent',
|
| 289 |
+
}
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
export function goldText(angle = 180): CSS {
|
| 293 |
+
return {
|
| 294 |
+
backgroundImage: `linear-gradient(${angle}deg, #FFF1CF 0%, ${C.goldHi} 35%, ${C.gold} 70%, #A88346 100%)`,
|
| 295 |
+
backgroundClip: 'text',
|
| 296 |
+
WebkitBackgroundClip: 'text',
|
| 297 |
+
color: 'transparent',
|
| 298 |
+
WebkitTextFillColor: 'transparent',
|
| 299 |
+
}
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
/** 光晕点 */
|
| 303 |
+
export function GlowDot({ x, y, r = 8, color = C.goldHi, o = 1, halo = 3 }: { x: number; y: number; r?: number; color?: string; o?: number; halo?: number }) {
|
| 304 |
+
if (o <= 0.001) return null
|
| 305 |
+
return (
|
| 306 |
+
<>
|
| 307 |
+
<div style={{ position: 'absolute', left: x - r * halo, top: y - r * halo, width: r * halo * 2, height: r * halo * 2, borderRadius: '50%', background: color, opacity: 0.28 * o, filter: `blur(${r * 1.2}px)` }} />
|
| 308 |
+
<div style={{ position: 'absolute', left: x - r, top: y - r, width: r * 2, height: r * 2, borderRadius: '50%', background: color, opacity: o, boxShadow: `0 0 ${r * 2}px ${color}` }} />
|
| 309 |
+
</>
|
| 310 |
+
)
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
/** 横条 */
|
| 314 |
+
export function HBar({ x, y, w, h, frac, p, color, track = true, r }: { x: number; y: number; w: number; h: number; frac: number; p: number; color: string; track?: boolean; r?: number }) {
|
| 315 |
+
const q = E.out(clamp(p))
|
| 316 |
+
const rr = r ?? Math.min(h / 2, 8)
|
| 317 |
+
return (
|
| 318 |
+
<>
|
| 319 |
+
{track && <div style={{ position: 'absolute', left: x, top: y, width: w, height: h, borderRadius: rr, background: 'rgba(243,238,228,0.06)', opacity: clamp(p * 3) }} />}
|
| 320 |
+
{q > 0.001 && (
|
| 321 |
+
<div
|
| 322 |
+
style={{
|
| 323 |
+
position: 'absolute',
|
| 324 |
+
left: x,
|
| 325 |
+
top: y,
|
| 326 |
+
width: Math.max(h * 0.2, w * frac * q),
|
| 327 |
+
height: h,
|
| 328 |
+
borderRadius: rr,
|
| 329 |
+
background: `linear-gradient(90deg, ${hexA(color, 0.35)}, ${color})`,
|
| 330 |
+
boxShadow: `0 0 24px ${hexA(color, 0.35)}`,
|
| 331 |
+
}}
|
| 332 |
+
/>
|
| 333 |
+
)}
|
| 334 |
+
</>
|
| 335 |
+
)
|
| 336 |
+
}
|
kkndme/frontend/src/video/audio.ts
ADDED
|
@@ -0,0 +1,1911 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Timeline, TScene } from './timeline'
|
| 2 |
+
import { VO_LINES, CTA_AT, CTA_IN, wordAt } from './script'
|
| 3 |
+
|
| 4 |
+
export const SR = 48000
|
| 5 |
+
|
| 6 |
+
export interface Stems {
|
| 7 |
+
/** 旁白 + 音效 */
|
| 8 |
+
main: AudioBuffer
|
| 9 |
+
/** 背景音乐(已含人声闪避) */
|
| 10 |
+
music: AudioBuffer
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
export async function loadVoice(base: string, onProgress?: (p: number) => void) {
|
| 14 |
+
const ctx = new OfflineAudioContext(1, 1, SR)
|
| 15 |
+
let done = 0
|
| 16 |
+
const bufs = await Promise.all(
|
| 17 |
+
VO_LINES.map(async (_, i) => {
|
| 18 |
+
const url = `${base}vo/vo${String(i).padStart(2, '0')}.mp3?v=20261031xf2`
|
| 19 |
+
const res = await fetch(url)
|
| 20 |
+
if (!res.ok) throw new Error(`旁白加载失败:${url}`)
|
| 21 |
+
const ab = await res.arrayBuffer()
|
| 22 |
+
const buf = await ctx.decodeAudioData(ab)
|
| 23 |
+
done++
|
| 24 |
+
onProgress?.(done / VO_LINES.length)
|
| 25 |
+
return buf
|
| 26 |
+
}),
|
| 27 |
+
)
|
| 28 |
+
return { bufs, durs: bufs.map((b) => b.duration) }
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
// ---------- 分段渲染引擎 ----------
|
| 32 |
+
// 把整条时间线切成短段分别离线渲染再叠加:每段只包含自己的发声节点,速度快很多。
|
| 33 |
+
|
| 34 |
+
interface Bus {
|
| 35 |
+
ctx: OfflineAudioContext
|
| 36 |
+
out: AudioNode
|
| 37 |
+
verb: AudioNode
|
| 38 |
+
delay: AudioNode
|
| 39 |
+
noise: AudioBuffer
|
| 40 |
+
}
|
| 41 |
+
interface Ev {
|
| 42 |
+
t: number
|
| 43 |
+
/** 发声长度(秒),超过分段尾长时自动加长该段,避免长句被截断 */
|
| 44 |
+
len?: number
|
| 45 |
+
fn: (b: Bus, at: number) => void
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
const mtof = (m: number) => 440 * Math.pow(2, (m - 69) / 12)
|
| 49 |
+
|
| 50 |
+
function lcg(seed: number) {
|
| 51 |
+
let s = seed >>> 0
|
| 52 |
+
return () => {
|
| 53 |
+
s = (s * 1664525 + 1013904223) >>> 0
|
| 54 |
+
return s / 4294967296
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
const NOISE = (() => {
|
| 58 |
+
const r = lcg(12345)
|
| 59 |
+
const d = new Float32Array(SR * 2)
|
| 60 |
+
for (let i = 0; i < d.length; i++) d[i] = r() * 2 - 1
|
| 61 |
+
return d
|
| 62 |
+
})()
|
| 63 |
+
function toBuffer(ctx: BaseAudioContext, chans: Float32Array[]) {
|
| 64 |
+
const b = ctx.createBuffer(chans.length, chans[0].length, SR)
|
| 65 |
+
chans.forEach((d, i) => b.copyToChannel(d as Float32Array<ArrayBuffer>, i))
|
| 66 |
+
return b
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/** 算法混响(Freeverb)+ 反馈延迟,有状态处理器:可以一段一段地连续处理 */
|
| 70 |
+
type FxOpts = { verbGain: number; room?: number; delayTime?: number; delayFb?: number; delayGain?: number }
|
| 71 |
+
function makeFx(opts: FxOpts) {
|
| 72 |
+
const sc = SR / 44100
|
| 73 |
+
const room = opts.room ?? 0.84
|
| 74 |
+
const damp = 0.22
|
| 75 |
+
const combL = [1116, 1188, 1277, 1356, 1422, 1491, 1557, 1617].map((x) => new Float32Array(Math.round(x * sc)))
|
| 76 |
+
const combR = [1116, 1188, 1277, 1356, 1422, 1491, 1557, 1617].map((x) => new Float32Array(Math.round((x + 23) * sc)))
|
| 77 |
+
const apL = [556, 441, 341, 225].map((x) => new Float32Array(Math.round(x * sc)))
|
| 78 |
+
const apR = [556, 441, 341, 225].map((x) => new Float32Array(Math.round((x + 23) * sc)))
|
| 79 |
+
const ciL = new Int32Array(8)
|
| 80 |
+
const ciR = new Int32Array(8)
|
| 81 |
+
const cfL = new Float32Array(8)
|
| 82 |
+
const cfR = new Float32Array(8)
|
| 83 |
+
const aiL = new Int32Array(4)
|
| 84 |
+
const aiR = new Int32Array(4)
|
| 85 |
+
const dlen = opts.delayTime ? Math.round(opts.delayTime * SR) : 0
|
| 86 |
+
const dbuf = new Float32Array(Math.max(1, dlen))
|
| 87 |
+
let di = 0
|
| 88 |
+
let dlp = 0
|
| 89 |
+
const dfb = opts.delayFb ?? 0.35
|
| 90 |
+
const dg = opts.delayGain ?? 0.45
|
| 91 |
+
const dk = 1 - Math.exp((-2 * Math.PI * 2600) / SR)
|
| 92 |
+
const wet = opts.verbGain * 3
|
| 93 |
+
/** 就地处理 bus 的前 n 个采样 */
|
| 94 |
+
return async (bus: Float32Array[], n: number) => {
|
| 95 |
+
const outL = bus[0]
|
| 96 |
+
const outR = bus[1]
|
| 97 |
+
const vin = bus[2]
|
| 98 |
+
const din = bus[3]
|
| 99 |
+
const chunk = SR
|
| 100 |
+
for (let s0 = 0; s0 < n; s0 += chunk) {
|
| 101 |
+
const e = Math.min(n, s0 + chunk)
|
| 102 |
+
for (let i = s0; i < e; i++) {
|
| 103 |
+
let x = vin[i]
|
| 104 |
+
if (dlen) {
|
| 105 |
+
const y = dbuf[di]
|
| 106 |
+
dlp += (y - dlp) * dk
|
| 107 |
+
dbuf[di] = din[i] + dlp * dfb
|
| 108 |
+
di = di + 1 >= dlen ? 0 : di + 1
|
| 109 |
+
const d = dlp * dg
|
| 110 |
+
outL[i] += d
|
| 111 |
+
outR[i] += d
|
| 112 |
+
x += d
|
| 113 |
+
}
|
| 114 |
+
x *= 0.015
|
| 115 |
+
let l = 0
|
| 116 |
+
let r = 0
|
| 117 |
+
for (let k = 0; k < 8; k++) {
|
| 118 |
+
const bl = combL[k]
|
| 119 |
+
const jl = ciL[k]
|
| 120 |
+
const yl = bl[jl]
|
| 121 |
+
cfL[k] = yl * (1 - damp) + cfL[k] * damp
|
| 122 |
+
bl[jl] = x + cfL[k] * room
|
| 123 |
+
ciL[k] = jl + 1 >= bl.length ? 0 : jl + 1
|
| 124 |
+
l += yl
|
| 125 |
+
const br = combR[k]
|
| 126 |
+
const jr = ciR[k]
|
| 127 |
+
const yr = br[jr]
|
| 128 |
+
cfR[k] = yr * (1 - damp) + cfR[k] * damp
|
| 129 |
+
br[jr] = x + cfR[k] * room
|
| 130 |
+
ciR[k] = jr + 1 >= br.length ? 0 : jr + 1
|
| 131 |
+
r += yr
|
| 132 |
+
}
|
| 133 |
+
for (let k = 0; k < 4; k++) {
|
| 134 |
+
const bl = apL[k]
|
| 135 |
+
const jl = aiL[k]
|
| 136 |
+
const vl = bl[jl]
|
| 137 |
+
bl[jl] = l + vl * 0.5
|
| 138 |
+
l = vl - l
|
| 139 |
+
aiL[k] = jl + 1 >= bl.length ? 0 : jl + 1
|
| 140 |
+
const br = apR[k]
|
| 141 |
+
const jr = aiR[k]
|
| 142 |
+
const vr = br[jr]
|
| 143 |
+
br[jr] = r + vr * 0.5
|
| 144 |
+
r = vr - r
|
| 145 |
+
aiR[k] = jr + 1 >= br.length ? 0 : jr + 1
|
| 146 |
+
}
|
| 147 |
+
outL[i] += l * wet
|
| 148 |
+
outR[i] += r * wet
|
| 149 |
+
}
|
| 150 |
+
await new Promise((res) => setTimeout(res, 0))
|
| 151 |
+
}
|
| 152 |
+
}
|
| 153 |
+
}
|
| 154 |
+
async function fxPass(bus: Float32Array[], opts: FxOpts) {
|
| 155 |
+
await makeFx(opts)(bus, bus[0].length)
|
| 156 |
+
return [bus[0], bus[1]]
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
/** 渲染单个分段(相对时间 0 起),返回 4 路 AudioBuffer */
|
| 160 |
+
async function renderSegment(list: Ev[], s0: number, len: number) {
|
| 161 |
+
const ctx = new OfflineAudioContext(4, len, SR)
|
| 162 |
+
ctx.destination.channelInterpretation = 'discrete'
|
| 163 |
+
const merger = ctx.createChannelMerger(4)
|
| 164 |
+
merger.connect(ctx.destination)
|
| 165 |
+
const dry = ctx.createGain()
|
| 166 |
+
dry.channelCount = 2
|
| 167 |
+
dry.channelCountMode = 'explicit'
|
| 168 |
+
const split = ctx.createChannelSplitter(2)
|
| 169 |
+
dry.connect(split)
|
| 170 |
+
split.connect(merger, 0, 0)
|
| 171 |
+
split.connect(merger, 1, 1)
|
| 172 |
+
const verb = ctx.createGain()
|
| 173 |
+
verb.connect(merger, 0, 2)
|
| 174 |
+
const delay = ctx.createGain()
|
| 175 |
+
delay.connect(merger, 0, 3)
|
| 176 |
+
const b: Bus = { ctx, out: dry, verb, delay, noise: toBuffer(ctx, [NOISE]) }
|
| 177 |
+
list.forEach((e) => e.fn(b, Math.max(0, e.t - s0)))
|
| 178 |
+
return ctx.startRendering()
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
/**
|
| 182 |
+
* 流式渲染:按 48 秒窗口逐段合成 → 效果器 → 包络 → 写成 16-bit PCM。
|
| 183 |
+
* 内存只占一个窗口 + 最终 PCM,避免长视频一次性申请几百 MB 浮点数组。
|
| 184 |
+
*/
|
| 185 |
+
async function renderEventsStream(
|
| 186 |
+
dur: number,
|
| 187 |
+
events: Ev[],
|
| 188 |
+
opts: FxOpts & { seg: number; tail: number },
|
| 189 |
+
post: ((chans: Float32Array[], n: number, offset: number) => void) | null,
|
| 190 |
+
ceiling: number,
|
| 191 |
+
onSeg?: () => void,
|
| 192 |
+
peaks?: { blk: number; out?: Float32Array },
|
| 193 |
+
): Promise<Blob> {
|
| 194 |
+
const total = Math.ceil(dur * SR)
|
| 195 |
+
const W = 48 * SR
|
| 196 |
+
// 尾长至少覆盖最长的单个发声(如长旁白)+ 混响余量
|
| 197 |
+
const tail = Math.max(opts.tail, ...events.map((e) => (e.len ?? 0) + 3))
|
| 198 |
+
const span = W + Math.ceil((opts.seg + tail + 1) * SR)
|
| 199 |
+
const bus = [0, 1, 2, 3].map(() => new Float32Array(span))
|
| 200 |
+
const fx = makeFx(opts)
|
| 201 |
+
const pcm = new Int16Array(total * 2)
|
| 202 |
+
// 先按 0.5 倍写入留出 6dB 余量,最后统一归一化
|
| 203 |
+
let peak = 0
|
| 204 |
+
const pk = peaks ? new Float32Array(Math.ceil(total / peaks.blk) + 2) : null
|
| 205 |
+
for (let w0 = 0; w0 < total; w0 += W) {
|
| 206 |
+
const t0 = w0 / SR
|
| 207 |
+
const segs: number[] = []
|
| 208 |
+
for (let s0 = Math.ceil(t0 / opts.seg - 1e-9) * opts.seg; s0 < t0 + W / SR && s0 < dur; s0 += opts.seg) segs.push(s0)
|
| 209 |
+
let k = 0
|
| 210 |
+
const worker = async () => {
|
| 211 |
+
while (k < segs.length) {
|
| 212 |
+
const s0 = segs[k++]
|
| 213 |
+
const list = events.filter((e) => e.t >= s0 && e.t < s0 + opts.seg)
|
| 214 |
+
if (!list.length) continue
|
| 215 |
+
const off = Math.floor(s0 * SR) - w0
|
| 216 |
+
const need = Math.max(opts.seg + opts.tail, ...list.map((e) => e.t - s0 + (e.len ?? 0) + 3))
|
| 217 |
+
const len = Math.min(total - Math.floor(s0 * SR), Math.ceil(need * SR), span - off)
|
| 218 |
+
if (len <= 0) continue
|
| 219 |
+
const buf = await renderSegment(list, s0, len)
|
| 220 |
+
for (let ch = 0; ch < 4; ch++) {
|
| 221 |
+
const src = buf.getChannelData(ch)
|
| 222 |
+
const dst = bus[ch]
|
| 223 |
+
for (let i = 0; i < src.length; i++) dst[off + i] += src[i]
|
| 224 |
+
}
|
| 225 |
+
onSeg?.()
|
| 226 |
+
}
|
| 227 |
+
}
|
| 228 |
+
await Promise.all([worker(), worker(), worker(), worker()])
|
| 229 |
+
const n = Math.min(W, total - w0)
|
| 230 |
+
await fx(bus, n)
|
| 231 |
+
post?.(bus, n, w0)
|
| 232 |
+
const L = bus[0]
|
| 233 |
+
const R = bus[1]
|
| 234 |
+
for (let i = 0, j = w0 * 2; i < n; i++, j += 2) {
|
| 235 |
+
const l = L[i]
|
| 236 |
+
const r = R[i]
|
| 237 |
+
const a = l < 0 ? -l : l
|
| 238 |
+
const b = r < 0 ? -r : r
|
| 239 |
+
if (a > peak) peak = a
|
| 240 |
+
if (b > peak) peak = b
|
| 241 |
+
if (pk) {
|
| 242 |
+
const bi = ((w0 + i) / peaks!.blk) | 0
|
| 243 |
+
const ab = a > b ? a : b
|
| 244 |
+
if (ab > pk[bi]) pk[bi] = ab
|
| 245 |
+
}
|
| 246 |
+
const ls = l * 0.5
|
| 247 |
+
const rs = r * 0.5
|
| 248 |
+
pcm[j] = (ls > 1 ? 1 : ls < -1 ? -1 : ls) * 32767
|
| 249 |
+
pcm[j + 1] = (rs > 1 ? 1 : rs < -1 ? -1 : rs) * 32767
|
| 250 |
+
}
|
| 251 |
+
// 窗口滑动:把超出部分(混响尾巴)搬到开头
|
| 252 |
+
for (const c of bus) {
|
| 253 |
+
c.copyWithin(0, W)
|
| 254 |
+
c.fill(0, span - W)
|
| 255 |
+
}
|
| 256 |
+
}
|
| 257 |
+
const gain = 2 * (peak > ceiling ? ceiling / peak : 1)
|
| 258 |
+
if (pk && peaks) {
|
| 259 |
+
for (let i = 0; i < pk.length; i++) pk[i] *= gain * 0.5
|
| 260 |
+
peaks.out = pk
|
| 261 |
+
}
|
| 262 |
+
for (let i = 0; i < pcm.length; i++) {
|
| 263 |
+
const v = pcm[i] * gain
|
| 264 |
+
pcm[i] = v > 32767 ? 32767 : v < -32768 ? -32768 : v
|
| 265 |
+
}
|
| 266 |
+
return pcmToWav(pcm, 2)
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
function pcmToWav(pcm: Int16Array, ch: number): Blob {
|
| 270 |
+
const bytes = pcm.length * 2
|
| 271 |
+
const head = new ArrayBuffer(44)
|
| 272 |
+
const v = new DataView(head)
|
| 273 |
+
const w = (o: number, s: string) => {
|
| 274 |
+
for (let i = 0; i < s.length; i++) v.setUint8(o + i, s.charCodeAt(i))
|
| 275 |
+
}
|
| 276 |
+
w(0, 'RIFF')
|
| 277 |
+
v.setUint32(4, 36 + bytes, true)
|
| 278 |
+
w(8, 'WAVE')
|
| 279 |
+
w(12, 'fmt ')
|
| 280 |
+
v.setUint32(16, 16, true)
|
| 281 |
+
v.setUint16(20, 1, true)
|
| 282 |
+
v.setUint16(22, ch, true)
|
| 283 |
+
v.setUint32(24, SR, true)
|
| 284 |
+
v.setUint32(28, SR * ch * 2, true)
|
| 285 |
+
v.setUint16(32, ch * 2, true)
|
| 286 |
+
v.setUint16(34, 16, true)
|
| 287 |
+
w(36, 'data')
|
| 288 |
+
v.setUint32(40, bytes, true)
|
| 289 |
+
return new Blob([head, pcm as Int16Array<ArrayBuffer>], { type: 'audio/wav' })
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
function env(g: GainNode, t: number, peak: number, a: number, d: number) {
|
| 293 |
+
g.gain.setValueAtTime(0.0001, t)
|
| 294 |
+
g.gain.linearRampToValueAtTime(peak, t + a)
|
| 295 |
+
g.gain.exponentialRampToValueAtTime(0.0001, t + a + d)
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
// ---------- 音乐 ----------
|
| 299 |
+
// D 小调 lo-fi 爵士嘻哈:暖垫音 + FM 电钢琴 + 拨弦旋律 + 次低音 + 摇摆鼓组。
|
| 300 |
+
// 每一章从标题卡的冲击点起拍,按整小节微调速度(±3%),章末一小节刹车 + 属和弦,正好落进下一章。
|
| 301 |
+
const BAR = (60 / 84) * 4
|
| 302 |
+
type Chord = { v: number[]; b: number }
|
| 303 |
+
const CH: Record<string, Chord> = {
|
| 304 |
+
Dm9: { v: [53, 57, 60, 64], b: 38 },
|
| 305 |
+
Bbmaj9: { v: [50, 53, 57, 60], b: 34 },
|
| 306 |
+
Fmaj9: { v: [52, 55, 57, 60], b: 41 },
|
| 307 |
+
C69: { v: [52, 55, 57, 62], b: 36 },
|
| 308 |
+
Gm9: { v: [53, 57, 58, 62], b: 31 },
|
| 309 |
+
A7sus: { v: [55, 57, 62, 64], b: 33 },
|
| 310 |
+
A7b9: { v: [55, 58, 61, 64], b: 33 },
|
| 311 |
+
Dmadd9: { v: [53, 57, 62, 64], b: 38 },
|
| 312 |
+
Bbmaj7s11: { v: [50, 53, 57, 64], b: 34 },
|
| 313 |
+
Gm6: { v: [52, 55, 58, 62], b: 31 },
|
| 314 |
+
Am7: { v: [55, 57, 60, 64], b: 33 },
|
| 315 |
+
CE: { v: [55, 60, 62, 67], b: 40 },
|
| 316 |
+
Fmaj9hi: { v: [57, 60, 64, 67], b: 41 },
|
| 317 |
+
}
|
| 318 |
+
type BarDef = [string, number][]
|
| 319 |
+
type Prog = { bars: BarDef[]; mel: [number, number][][] }
|
| 320 |
+
const PROGS: Record<string, Prog> = {
|
| 321 |
+
story: {
|
| 322 |
+
bars: [[['Dm9', 0]], [['Bbmaj9', 0]], [['Fmaj9', 0]], [['C69', 0]]],
|
| 323 |
+
mel: [
|
| 324 |
+
[[0, 69], [1, 72], [1.5, 74], [3, 72]],
|
| 325 |
+
[[0, 74], [1, 72], [2, 69], [3.5, 65]],
|
| 326 |
+
[[0, 69], [1.5, 72], [2, 77], [3, 76]],
|
| 327 |
+
[[0, 74], [1, 72], [2, 67], [2.5, 69]],
|
| 328 |
+
],
|
| 329 |
+
},
|
| 330 |
+
drive: {
|
| 331 |
+
bars: [[['Dm9', 0]], [['Bbmaj9', 0]], [['Gm9', 0]], [['A7sus', 0], ['A7b9', 2]]],
|
| 332 |
+
mel: [
|
| 333 |
+
[[0, 74], [0.5, 76], [1, 77], [2, 76], [3, 72]],
|
| 334 |
+
[[0, 74], [1, 77], [2, 81], [3, 77]],
|
| 335 |
+
[[0, 79], [1, 77], [1.5, 74], [3, 70]],
|
| 336 |
+
[[0, 76], [1, 74], [2, 73], [3, 76]],
|
| 337 |
+
],
|
| 338 |
+
},
|
| 339 |
+
think: {
|
| 340 |
+
bars: [[['Gm9', 0]], [['Dm9', 0]], [['Bbmaj9', 0]], [['A7sus', 0]]],
|
| 341 |
+
mel: [
|
| 342 |
+
[[0, 70], [1, 74], [2, 77], [3.5, 74]],
|
| 343 |
+
[[0, 76], [1, 74], [2, 69], [3, 72]],
|
| 344 |
+
[[0, 74], [1.5, 77], [2, 72], [3, 69]],
|
| 345 |
+
[[0, 74], [2, 76], [3, 69]],
|
| 346 |
+
],
|
| 347 |
+
},
|
| 348 |
+
dark: {
|
| 349 |
+
bars: [[['Dmadd9', 0]], [['Bbmaj7s11', 0]], [['Gm6', 0]], [['A7b9', 0]]],
|
| 350 |
+
mel: [
|
| 351 |
+
[[0, 69], [1.5, 74], [2, 76]],
|
| 352 |
+
[[0, 74], [2, 69], [3, 76]],
|
| 353 |
+
[[0, 70], [1.5, 67], [2, 64]],
|
| 354 |
+
[[0, 73], [1, 70], [2, 69]],
|
| 355 |
+
],
|
| 356 |
+
},
|
| 357 |
+
hope: {
|
| 358 |
+
bars: [[['Bbmaj9', 0]], [['C69', 0]], [['Am7', 0]], [['Dm9', 0]]],
|
| 359 |
+
mel: [
|
| 360 |
+
[[0, 77], [1, 81], [1.5, 79], [2, 77], [3, 74]],
|
| 361 |
+
[[0, 76], [1, 79], [2, 81], [3, 79]],
|
| 362 |
+
[[0, 76], [1, 72], [2, 74], [3, 76]],
|
| 363 |
+
[[0, 77], [1, 76], [2, 74], [3.5, 69]],
|
| 364 |
+
],
|
| 365 |
+
},
|
| 366 |
+
warm: {
|
| 367 |
+
bars: [[['Fmaj9', 0]], [['CE', 0]], [['Dm9', 0]], [['Bbmaj9', 0]]],
|
| 368 |
+
mel: [
|
| 369 |
+
[[0, 72], [1, 76], [2, 79], [3, 81]],
|
| 370 |
+
[[0, 79], [1, 76], [2, 74], [3, 72]],
|
| 371 |
+
[[0, 77], [1, 76], [2, 74], [3, 69]],
|
| 372 |
+
[[0, 74], [1, 72], [2, 69], [3, 65]],
|
| 373 |
+
],
|
| 374 |
+
},
|
| 375 |
+
}
|
| 376 |
+
const TURN: BarDef = [['A7sus', 0], ['A7b9', 2]]
|
| 377 |
+
const TURN_MEL = PROGS.drive.mel[3]
|
| 378 |
+
/** 每章编曲:和声进行(按 4 小节乐句轮换)+ 每个乐句的层级(0 只有垫音 … 3 全编制) */
|
| 379 |
+
const PLAN: Record<string, { p: string[]; lv: number[]; dark?: boolean; clock?: boolean; air?: boolean }> = {
|
| 380 |
+
intro: { p: ['story'], lv: [0, 1, 1, 2, 2, 2, 2] },
|
| 381 |
+
method: { p: ['drive', 'story'], lv: [1, 2, 2, 2] },
|
| 382 |
+
score: { p: ['story', 'drive'], lv: [2, 2, 3, 2] },
|
| 383 |
+
price: { p: ['drive', 'story'], lv: [2, 3, 2, 3, 2, 3] },
|
| 384 |
+
cities: { p: ['story', 'drive'], lv: [2, 3, 3, 2, 3, 3] },
|
| 385 |
+
money: { p: ['drive', 'story'], lv: [2, 2, 3, 3, 2, 3] },
|
| 386 |
+
policy: { p: ['story', 'drive'], lv: [2, 3, 2, 3, 3] },
|
| 387 |
+
rulers: { p: ['think'], lv: [1, 2, 2, 2] },
|
| 388 |
+
brier: { p: ['think', 'drive'], lv: [2, 2, 2] },
|
| 389 |
+
blind: { p: ['dark'], lv: [1], dark: true },
|
| 390 |
+
pending: { p: ['dark'], lv: [1], dark: true, clock: true },
|
| 391 |
+
outlook: { p: ['hope', 'story'], lv: [1, 1, 2, 2, 3, 2, 2, 2], air: true },
|
| 392 |
+
outro: { p: ['warm'], lv: [2, 2, 2, 1, 1, 0, 0] },
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
/** 是否正在说话(m = 前后余量,秒) */
|
| 396 |
+
function speechTest(tl: Timeline) {
|
| 397 |
+
const L = tl.lines
|
| 398 |
+
return (t: number, m = 0.12) => {
|
| 399 |
+
let lo = 0
|
| 400 |
+
let hi = L.length - 1
|
| 401 |
+
while (lo < hi) {
|
| 402 |
+
const mid = (lo + hi + 1) >> 1
|
| 403 |
+
if (L[mid].start - m <= t) lo = mid
|
| 404 |
+
else hi = mid - 1
|
| 405 |
+
}
|
| 406 |
+
const l = L[lo]
|
| 407 |
+
return t >= l.start - m && t <= l.end + m * 0.5
|
| 408 |
+
}
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
// —— 乐器 ——
|
| 412 |
+
function pad({ ctx, out, verb }: Bus, at: number, notes: number[], len: number, lvl: number, cut: number) {
|
| 413 |
+
const lp = ctx.createBiquadFilter()
|
| 414 |
+
lp.type = 'lowpass'
|
| 415 |
+
lp.Q.value = 0.5
|
| 416 |
+
lp.frequency.setValueAtTime(cut * 0.6, at)
|
| 417 |
+
lp.frequency.linearRampToValueAtTime(cut, at + len * 0.5)
|
| 418 |
+
lp.frequency.linearRampToValueAtTime(cut * 0.7, at + len + 0.9)
|
| 419 |
+
const g = ctx.createGain()
|
| 420 |
+
g.gain.setValueAtTime(0.0001, at)
|
| 421 |
+
g.gain.linearRampToValueAtTime(lvl, at + Math.min(0.7, len * 0.5))
|
| 422 |
+
g.gain.setValueAtTime(lvl, at + len - 0.05)
|
| 423 |
+
g.gain.linearRampToValueAtTime(0.0001, at + len + 0.9)
|
| 424 |
+
lp.connect(g)
|
| 425 |
+
g.connect(out)
|
| 426 |
+
g.connect(verb)
|
| 427 |
+
notes.forEach((m, i) =>
|
| 428 |
+
[-7, 7].forEach((det, j) => {
|
| 429 |
+
const o = ctx.createOscillator()
|
| 430 |
+
o.type = 'sawtooth'
|
| 431 |
+
o.frequency.value = mtof(m)
|
| 432 |
+
o.detune.value = det + (i - 1.5) * 1.5
|
| 433 |
+
const p = ctx.createStereoPanner()
|
| 434 |
+
p.pan.value = j ? 0.45 : -0.45
|
| 435 |
+
o.connect(p).connect(lp)
|
| 436 |
+
o.start(at)
|
| 437 |
+
o.stop(at + len + 1)
|
| 438 |
+
}),
|
| 439 |
+
)
|
| 440 |
+
}
|
| 441 |
+
/** 高处的空气感垫音(展望章) */
|
| 442 |
+
function air({ ctx, out, verb }: Bus, at: number, notes: number[], len: number, lvl: number) {
|
| 443 |
+
const g = ctx.createGain()
|
| 444 |
+
g.gain.setValueAtTime(0.0001, at)
|
| 445 |
+
g.gain.linearRampToValueAtTime(lvl, at + Math.min(1.2, len * 0.5))
|
| 446 |
+
g.gain.setValueAtTime(lvl, at + len - 0.1)
|
| 447 |
+
g.gain.linearRampToValueAtTime(0.0001, at + len + 1.2)
|
| 448 |
+
g.connect(out)
|
| 449 |
+
g.connect(verb)
|
| 450 |
+
notes.forEach((m, i) => {
|
| 451 |
+
const o = ctx.createOscillator()
|
| 452 |
+
o.frequency.value = mtof(m)
|
| 453 |
+
o.detune.value = i ? 4 : -4
|
| 454 |
+
o.connect(g)
|
| 455 |
+
o.start(at)
|
| 456 |
+
o.stop(at + len + 1.3)
|
| 457 |
+
})
|
| 458 |
+
}
|
| 459 |
+
/** FM 电钢琴(带自动声像颤音) */
|
| 460 |
+
function rhodes({ ctx, out, verb, delay }: Bus, at: number, notes: number[], len: number, vel: number, roll = 0.012) {
|
| 461 |
+
const bus = ctx.createGain()
|
| 462 |
+
bus.gain.value = vel
|
| 463 |
+
const lp = ctx.createBiquadFilter()
|
| 464 |
+
lp.type = 'lowpass'
|
| 465 |
+
lp.frequency.value = 2400
|
| 466 |
+
const pan = ctx.createStereoPanner()
|
| 467 |
+
const lfo = ctx.createOscillator()
|
| 468 |
+
lfo.frequency.value = 3.4
|
| 469 |
+
const lg = ctx.createGain()
|
| 470 |
+
lg.gain.value = 0.3
|
| 471 |
+
lfo.connect(lg).connect(pan.pan)
|
| 472 |
+
lfo.start(at)
|
| 473 |
+
lfo.stop(at + len + 1.2)
|
| 474 |
+
bus.connect(lp).connect(pan)
|
| 475 |
+
pan.connect(out)
|
| 476 |
+
pan.connect(verb)
|
| 477 |
+
const ds = ctx.createGain()
|
| 478 |
+
ds.gain.value = 0.18
|
| 479 |
+
pan.connect(ds).connect(delay)
|
| 480 |
+
notes.forEach((m, i) => {
|
| 481 |
+
const t = at + i * roll
|
| 482 |
+
const f = mtof(m)
|
| 483 |
+
const c = ctx.createOscillator()
|
| 484 |
+
c.frequency.value = f
|
| 485 |
+
const mod = ctx.createOscillator()
|
| 486 |
+
mod.frequency.value = f
|
| 487 |
+
const mi = ctx.createGain()
|
| 488 |
+
mi.gain.setValueAtTime(f * 1.5, t)
|
| 489 |
+
mi.gain.setTargetAtTime(f * 0.22, t, 0.22)
|
| 490 |
+
mod.connect(mi).connect(c.frequency)
|
| 491 |
+
const g = ctx.createGain()
|
| 492 |
+
g.gain.setValueAtTime(0.0001, t)
|
| 493 |
+
g.gain.linearRampToValueAtTime(0.085, t + 0.004)
|
| 494 |
+
g.gain.setTargetAtTime(0.034, t + 0.004, 0.45)
|
| 495 |
+
g.gain.setTargetAtTime(0.0001, t + len, 0.16)
|
| 496 |
+
c.connect(g).connect(bus)
|
| 497 |
+
const tn = ctx.createOscillator()
|
| 498 |
+
tn.frequency.value = f * 7
|
| 499 |
+
const tg = ctx.createGain()
|
| 500 |
+
env(tg, t, 0.01, 0.002, 0.07)
|
| 501 |
+
tn.connect(tg).connect(bus)
|
| 502 |
+
c.start(t)
|
| 503 |
+
mod.start(t)
|
| 504 |
+
tn.start(t)
|
| 505 |
+
c.stop(t + len + 1)
|
| 506 |
+
mod.stop(t + len + 1)
|
| 507 |
+
tn.stop(t + 0.1)
|
| 508 |
+
})
|
| 509 |
+
}
|
| 510 |
+
function bassNote({ ctx, out }: Bus, at: number, m: number, len: number, vel: number) {
|
| 511 |
+
const f = mtof(m)
|
| 512 |
+
const o = ctx.createOscillator()
|
| 513 |
+
o.frequency.value = f
|
| 514 |
+
const o2 = ctx.createOscillator()
|
| 515 |
+
o2.type = 'triangle'
|
| 516 |
+
o2.frequency.value = f * 2
|
| 517 |
+
const g2 = ctx.createGain()
|
| 518 |
+
g2.gain.value = 0.2
|
| 519 |
+
const lp = ctx.createBiquadFilter()
|
| 520 |
+
lp.type = 'lowpass'
|
| 521 |
+
lp.frequency.value = 480
|
| 522 |
+
const g = ctx.createGain()
|
| 523 |
+
g.gain.setValueAtTime(0.0001, at)
|
| 524 |
+
g.gain.linearRampToValueAtTime(0.24 * vel, at + 0.012)
|
| 525 |
+
g.gain.setTargetAtTime(0.16 * vel, at + 0.012, 0.3)
|
| 526 |
+
g.gain.setTargetAtTime(0.0001, at + len, 0.06)
|
| 527 |
+
o.connect(g)
|
| 528 |
+
o2.connect(g2).connect(lp).connect(g)
|
| 529 |
+
g.connect(out)
|
| 530 |
+
o.start(at)
|
| 531 |
+
o2.start(at)
|
| 532 |
+
o.stop(at + len + 0.5)
|
| 533 |
+
o2.stop(at + len + 0.5)
|
| 534 |
+
}
|
| 535 |
+
function kick({ ctx, out, noise }: Bus, at: number, vel: number, muff = false) {
|
| 536 |
+
const o = ctx.createOscillator()
|
| 537 |
+
o.frequency.setValueAtTime(muff ? 90 : 118, at)
|
| 538 |
+
o.frequency.exponentialRampToValueAtTime(muff ? 42 : 46, at + 0.11)
|
| 539 |
+
const g = ctx.createGain()
|
| 540 |
+
g.gain.setValueAtTime(0.0001, at)
|
| 541 |
+
g.gain.linearRampToValueAtTime(0.5 * vel, at + 0.003)
|
| 542 |
+
g.gain.setTargetAtTime(0.0001, at + 0.02, muff ? 0.14 : 0.1)
|
| 543 |
+
o.connect(g).connect(out)
|
| 544 |
+
o.start(at)
|
| 545 |
+
o.stop(at + 0.6)
|
| 546 |
+
if (muff) return
|
| 547 |
+
const s = ctx.createBufferSource()
|
| 548 |
+
s.buffer = noise
|
| 549 |
+
const hp = ctx.createBiquadFilter()
|
| 550 |
+
hp.type = 'bandpass'
|
| 551 |
+
hp.frequency.value = 2200
|
| 552 |
+
const ng = ctx.createGain()
|
| 553 |
+
env(ng, at, 0.05 * vel, 0.0008, 0.012)
|
| 554 |
+
s.connect(hp).connect(ng).connect(out)
|
| 555 |
+
s.start(at, 0.37)
|
| 556 |
+
s.stop(at + 0.03)
|
| 557 |
+
}
|
| 558 |
+
function snare({ ctx, out, verb, noise }: Bus, at: number, vel: number, clap = false) {
|
| 559 |
+
const s = ctx.createBufferSource()
|
| 560 |
+
s.buffer = noise
|
| 561 |
+
const bp = ctx.createBiquadFilter()
|
| 562 |
+
bp.type = 'bandpass'
|
| 563 |
+
bp.frequency.value = 1900
|
| 564 |
+
bp.Q.value = 0.7
|
| 565 |
+
const lp = ctx.createBiquadFilter()
|
| 566 |
+
lp.type = 'lowpass'
|
| 567 |
+
lp.frequency.value = 6500
|
| 568 |
+
const g = ctx.createGain()
|
| 569 |
+
env(g, at, 0.15 * vel, 0.0015, 0.15)
|
| 570 |
+
s.connect(bp).connect(lp).connect(g)
|
| 571 |
+
g.connect(out)
|
| 572 |
+
const sv = ctx.createGain()
|
| 573 |
+
sv.gain.value = 0.5
|
| 574 |
+
g.connect(sv).connect(verb)
|
| 575 |
+
s.start(at, (at * 7.3) % 1.5)
|
| 576 |
+
s.stop(at + 0.25)
|
| 577 |
+
const o = ctx.createOscillator()
|
| 578 |
+
o.type = 'triangle'
|
| 579 |
+
o.frequency.setValueAtTime(205, at)
|
| 580 |
+
o.frequency.exponentialRampToValueAtTime(165, at + 0.05)
|
| 581 |
+
const og = ctx.createGain()
|
| 582 |
+
env(og, at, 0.09 * vel, 0.001, 0.08)
|
| 583 |
+
o.connect(og).connect(out)
|
| 584 |
+
o.start(at)
|
| 585 |
+
o.stop(at + 0.12)
|
| 586 |
+
if (!clap) return
|
| 587 |
+
;[0, 0.011, 0.023].forEach((d, k) => {
|
| 588 |
+
const c = ctx.createBufferSource()
|
| 589 |
+
c.buffer = noise
|
| 590 |
+
const cb = ctx.createBiquadFilter()
|
| 591 |
+
cb.type = 'bandpass'
|
| 592 |
+
cb.frequency.value = 1250
|
| 593 |
+
cb.Q.value = 1.1
|
| 594 |
+
const cg = ctx.createGain()
|
| 595 |
+
env(cg, at + d, 0.07 * vel, 0.001, k === 2 ? 0.13 : 0.012)
|
| 596 |
+
c.connect(cb).connect(cg)
|
| 597 |
+
cg.connect(out)
|
| 598 |
+
cg.connect(verb)
|
| 599 |
+
c.start(at + d, 0.6 + k * 0.1)
|
| 600 |
+
c.stop(at + d + 0.18)
|
| 601 |
+
})
|
| 602 |
+
}
|
| 603 |
+
function rim({ ctx, out, noise }: Bus, at: number, vel: number) {
|
| 604 |
+
const o = ctx.createOscillator()
|
| 605 |
+
o.type = 'triangle'
|
| 606 |
+
o.frequency.value = 1650
|
| 607 |
+
const g = ctx.createGain()
|
| 608 |
+
env(g, at, 0.035 * vel, 0.0008, 0.022)
|
| 609 |
+
o.connect(g).connect(out)
|
| 610 |
+
o.start(at)
|
| 611 |
+
o.stop(at + 0.05)
|
| 612 |
+
const o2 = ctx.createOscillator()
|
| 613 |
+
o2.frequency.value = 430
|
| 614 |
+
const g2 = ctx.createGain()
|
| 615 |
+
env(g2, at, 0.04 * vel, 0.001, 0.035)
|
| 616 |
+
o2.connect(g2).connect(out)
|
| 617 |
+
o2.start(at)
|
| 618 |
+
o2.stop(at + 0.06)
|
| 619 |
+
const s = ctx.createBufferSource()
|
| 620 |
+
s.buffer = noise
|
| 621 |
+
const bp = ctx.createBiquadFilter()
|
| 622 |
+
bp.type = 'bandpass'
|
| 623 |
+
bp.frequency.value = 3200
|
| 624 |
+
bp.Q.value = 2
|
| 625 |
+
const ng = ctx.createGain()
|
| 626 |
+
env(ng, at, 0.05 * vel, 0.0005, 0.012)
|
| 627 |
+
s.connect(bp).connect(ng).connect(out)
|
| 628 |
+
s.start(at, 0.9)
|
| 629 |
+
s.stop(at + 0.03)
|
| 630 |
+
}
|
| 631 |
+
function hat({ ctx, out, noise }: Bus, at: number, vel: number, open = false) {
|
| 632 |
+
const s = ctx.createBufferSource()
|
| 633 |
+
s.buffer = noise
|
| 634 |
+
const hp = ctx.createBiquadFilter()
|
| 635 |
+
hp.type = 'highpass'
|
| 636 |
+
hp.frequency.value = 7200
|
| 637 |
+
const lp = ctx.createBiquadFilter()
|
| 638 |
+
lp.type = 'lowpass'
|
| 639 |
+
lp.frequency.value = 11500
|
| 640 |
+
const g = ctx.createGain()
|
| 641 |
+
env(g, at, (open ? 0.03 : 0.04) * vel, 0.001, open ? 0.26 : 0.032)
|
| 642 |
+
const p = ctx.createStereoPanner()
|
| 643 |
+
p.pan.value = 0.28
|
| 644 |
+
s.connect(hp).connect(lp).connect(g).connect(p).connect(out)
|
| 645 |
+
s.start(at, (at * 3.1) % 1.5)
|
| 646 |
+
s.stop(at + (open ? 0.4 : 0.08))
|
| 647 |
+
}
|
| 648 |
+
function shaker({ ctx, out, noise }: Bus, at: number, vel: number) {
|
| 649 |
+
const s = ctx.createBufferSource()
|
| 650 |
+
s.buffer = noise
|
| 651 |
+
const bp = ctx.createBiquadFilter()
|
| 652 |
+
bp.type = 'bandpass'
|
| 653 |
+
bp.frequency.value = 5600
|
| 654 |
+
bp.Q.value = 1.2
|
| 655 |
+
const g = ctx.createGain()
|
| 656 |
+
g.gain.setValueAtTime(0.0001, at)
|
| 657 |
+
g.gain.linearRampToValueAtTime(0.035 * vel, at + 0.012)
|
| 658 |
+
g.gain.exponentialRampToValueAtTime(0.0001, at + 0.07)
|
| 659 |
+
const p = ctx.createStereoPanner()
|
| 660 |
+
p.pan.value = -0.3
|
| 661 |
+
s.connect(bp).connect(g).connect(p).connect(out)
|
| 662 |
+
s.start(at, (at * 5.7) % 1.5)
|
| 663 |
+
s.stop(at + 0.09)
|
| 664 |
+
}
|
| 665 |
+
function clock({ ctx, out }: Bus, at: number, hi: boolean) {
|
| 666 |
+
const o = ctx.createOscillator()
|
| 667 |
+
o.type = 'triangle'
|
| 668 |
+
o.frequency.value = hi ? 1480 : 1250
|
| 669 |
+
const g = ctx.createGain()
|
| 670 |
+
env(g, at, 0.028, 0.0008, 0.03)
|
| 671 |
+
o.connect(g).connect(out)
|
| 672 |
+
o.start(at)
|
| 673 |
+
o.stop(at + 0.05)
|
| 674 |
+
}
|
| 675 |
+
function crash({ ctx, out, verb, noise }: Bus, at: number, vel: number) {
|
| 676 |
+
const s = ctx.createBufferSource()
|
| 677 |
+
s.buffer = noise
|
| 678 |
+
s.loop = true
|
| 679 |
+
const hp = ctx.createBiquadFilter()
|
| 680 |
+
hp.type = 'highpass'
|
| 681 |
+
hp.frequency.value = 4200
|
| 682 |
+
const lp = ctx.createBiquadFilter()
|
| 683 |
+
lp.type = 'lowpass'
|
| 684 |
+
lp.frequency.setValueAtTime(10000, at)
|
| 685 |
+
lp.frequency.exponentialRampToValueAtTime(5000, at + 1.8)
|
| 686 |
+
const g = ctx.createGain()
|
| 687 |
+
g.gain.setValueAtTime(0.0001, at)
|
| 688 |
+
g.gain.linearRampToValueAtTime(0.035 * vel, at + 0.004)
|
| 689 |
+
g.gain.setTargetAtTime(0.0001, at + 0.01, 0.55)
|
| 690 |
+
s.connect(hp).connect(lp).connect(g)
|
| 691 |
+
g.connect(out)
|
| 692 |
+
g.connect(verb)
|
| 693 |
+
s.start(at, 0.2)
|
| 694 |
+
s.stop(at + 2.6)
|
| 695 |
+
}
|
| 696 |
+
/** 反向镲:章末刹车后吸进下一章 */
|
| 697 |
+
function revCym({ ctx, out, verb, noise }: Bus, at: number, len: number, vel: number) {
|
| 698 |
+
const s = ctx.createBufferSource()
|
| 699 |
+
s.buffer = noise
|
| 700 |
+
s.loop = true
|
| 701 |
+
const hp = ctx.createBiquadFilter()
|
| 702 |
+
hp.type = 'highpass'
|
| 703 |
+
hp.frequency.setValueAtTime(6000, at)
|
| 704 |
+
hp.frequency.exponentialRampToValueAtTime(2500, at + len)
|
| 705 |
+
const g = ctx.createGain()
|
| 706 |
+
g.gain.setValueAtTime(0.0001, at)
|
| 707 |
+
g.gain.exponentialRampToValueAtTime(0.03 * vel, at + len - 0.03)
|
| 708 |
+
g.gain.linearRampToValueAtTime(0.0001, at + len)
|
| 709 |
+
s.connect(hp).connect(g)
|
| 710 |
+
g.connect(out)
|
| 711 |
+
g.connect(verb)
|
| 712 |
+
s.start(at, 0.5)
|
| 713 |
+
s.stop(at + len + 0.02)
|
| 714 |
+
}
|
| 715 |
+
|
| 716 |
+
// 拨弦(Karplus-Strong),每个音高只合成一次
|
| 717 |
+
const KS = new Map<number, { buf: AudioBuffer; rate: number }>()
|
| 718 |
+
function ksBuf(m: number) {
|
| 719 |
+
const hit = KS.get(m)
|
| 720 |
+
if (hit) return hit
|
| 721 |
+
const f = mtof(m)
|
| 722 |
+
const N = Math.max(2, Math.floor(SR / f - 0.5))
|
| 723 |
+
const len = Math.floor(SR * 2.4)
|
| 724 |
+
const d = new Float32Array(len)
|
| 725 |
+
const r = lcg(m * 977 + 13)
|
| 726 |
+
const line = new Float32Array(N)
|
| 727 |
+
let lp = 0
|
| 728 |
+
for (let i = 0; i < N; i++) {
|
| 729 |
+
lp += (r() * 2 - 1 - lp) * 0.5
|
| 730 |
+
line[i] = lp
|
| 731 |
+
}
|
| 732 |
+
const decay = Math.pow(0.06, 1 / f)
|
| 733 |
+
let idx = 0
|
| 734 |
+
for (let i = 0; i < len; i++) {
|
| 735 |
+
const nx = idx + 1 >= N ? 0 : idx + 1
|
| 736 |
+
d[i] = line[idx]
|
| 737 |
+
line[idx] = decay * 0.5 * (line[idx] + line[nx])
|
| 738 |
+
idx = nx
|
| 739 |
+
}
|
| 740 |
+
const buf = new AudioBuffer({ length: len, sampleRate: SR, numberOfChannels: 1 })
|
| 741 |
+
buf.copyToChannel(d, 0)
|
| 742 |
+
const e = { buf, rate: f / (SR / (N + 0.5)) }
|
| 743 |
+
KS.set(m, e)
|
| 744 |
+
return e
|
| 745 |
+
}
|
| 746 |
+
function pluck({ ctx, out, verb, delay }: Bus, at: number, m: number, vel: number, pan = 0.2, send = 0.5) {
|
| 747 |
+
const e = ksBuf(m)
|
| 748 |
+
const s = ctx.createBufferSource()
|
| 749 |
+
s.buffer = e.buf
|
| 750 |
+
s.playbackRate.value = e.rate
|
| 751 |
+
const lp = ctx.createBiquadFilter()
|
| 752 |
+
lp.type = 'lowpass'
|
| 753 |
+
lp.frequency.value = 3400
|
| 754 |
+
const g = ctx.createGain()
|
| 755 |
+
g.gain.value = 0.3 * vel
|
| 756 |
+
const p = ctx.createStereoPanner()
|
| 757 |
+
p.pan.value = pan
|
| 758 |
+
s.connect(lp).connect(g).connect(p)
|
| 759 |
+
p.connect(out)
|
| 760 |
+
p.connect(verb)
|
| 761 |
+
const ds = ctx.createGain()
|
| 762 |
+
ds.gain.value = send
|
| 763 |
+
p.connect(ds).connect(delay)
|
| 764 |
+
s.start(at)
|
| 765 |
+
s.stop(at + 2.4)
|
| 766 |
+
}
|
| 767 |
+
function musicEvents(tl: Timeline): Ev[] {
|
| 768 |
+
const evs: Ev[] = []
|
| 769 |
+
const rnd = lcg(2010)
|
| 770 |
+
// 每个事件在创建时就抽好随机数,渲染顺序不影响结果
|
| 771 |
+
let cur = 0.5
|
| 772 |
+
const at = (t: number, fn: (b: Bus, a: number) => void) => {
|
| 773 |
+
const r = rnd()
|
| 774 |
+
evs.push({
|
| 775 |
+
t: Math.max(0, t),
|
| 776 |
+
fn: (b, a) => {
|
| 777 |
+
cur = r
|
| 778 |
+
fn(b, a)
|
| 779 |
+
},
|
| 780 |
+
})
|
| 781 |
+
}
|
| 782 |
+
const hv = (v: number) => v * (0.88 + cur * 0.24)
|
| 783 |
+
const talking = speechTest(tl)
|
| 784 |
+
const sc = tl.scenes
|
| 785 |
+
const g0 = (k: number) => (k === 0 ? Math.max(0.8, sc[0].lines[0].start - 1.2) : sc[k].start + 0.25)
|
| 786 |
+
const last = sc[sc.length - 1]
|
| 787 |
+
const endAll = last.lines[last.lines.length - 1].end + 0.4
|
| 788 |
+
|
| 789 |
+
// 封面:属和弦从无声里升起,落到序章第一拍
|
| 790 |
+
const s0 = g0(0)
|
| 791 |
+
at(0.02, (b, a) => pad(b, a, CH.A7sus.v, s0 - 0.1, 0.03, 700))
|
| 792 |
+
at(s0 - 1.0, (b, a) => revCym(b, a, 1.0, 0.7))
|
| 793 |
+
|
| 794 |
+
sc.forEach((s, k) => {
|
| 795 |
+
const plan = PLAN[s.key] ?? PLAN.method
|
| 796 |
+
const start = g0(k)
|
| 797 |
+
const end = k < sc.length - 1 ? g0(k + 1) : endAll
|
| 798 |
+
const nb = Math.max(1, Math.round((end - start) / BAR))
|
| 799 |
+
const bl = (end - start) / nb
|
| 800 |
+
const st = bl / 16
|
| 801 |
+
const isOutro = k === sc.length - 1
|
| 802 |
+
if (k > 0) at(start, (b, a) => crash(b, a, plan.dark ? 0.5 : 0.9))
|
| 803 |
+
for (let j = 0; j < nb; j++) {
|
| 804 |
+
const t0 = start + j * bl
|
| 805 |
+
const ph = Math.floor(j / 4)
|
| 806 |
+
const lv = plan.lv[Math.min(ph, plan.lv.length - 1)]
|
| 807 |
+
const prog = PROGS[plan.p[ph % plan.p.length]]
|
| 808 |
+
const brk = !isOutro && j === nb - 1
|
| 809 |
+
const fin = isOutro && j === nb - 1
|
| 810 |
+
const bar: BarDef = brk ? TURN : fin ? PROGS.warm.bars[3] : prog.bars[j % 4]
|
| 811 |
+
const mel = brk ? TURN_MEL : fin ? PROGS.warm.mel[3] : prog.mel[j % 4]
|
| 812 |
+
const S = (n: number) => t0 + n * st + (n % 2 ? st * 0.28 : 0) + (rnd() - 0.5) * 0.006
|
| 813 |
+
const chordAt = (n: number) => {
|
| 814 |
+
let c = bar[0][0]
|
| 815 |
+
for (const [name, beat] of bar) if (n >= beat * 4) c = name
|
| 816 |
+
return CH[c]
|
| 817 |
+
}
|
| 818 |
+
|
| 819 |
+
// 垫音 + 电钢琴
|
| 820 |
+
bar.forEach(([name, beat], ci) => {
|
| 821 |
+
const cs = t0 + beat * 4 * st
|
| 822 |
+
const nextBeat = ci < bar.length - 1 ? bar[ci + 1][1] : 4
|
| 823 |
+
const len = (nextBeat - beat) * 4 * st
|
| 824 |
+
const c = CH[name]
|
| 825 |
+
const padLvl = plan.dark ? 0.045 : [0.05, 0.042, 0.03, 0.027][lv]
|
| 826 |
+
const cut = plan.dark ? 650 : [800, 1000, 1300, 1650][lv]
|
| 827 |
+
at(cs, (b, a) => pad(b, a, c.v, len, padLvl, cut))
|
| 828 |
+
if (plan.air) at(cs, (b, a) => air(b, a, [c.v[2] + 24, c.v[3] + 24], len, lv >= 2 ? 0.007 : 0.009))
|
| 829 |
+
})
|
| 830 |
+
const comp: [number, number, number][] =
|
| 831 |
+
bar.length > 1
|
| 832 |
+
? [
|
| 833 |
+
[0, 8, 0.75],
|
| 834 |
+
[8, 8, 0.7],
|
| 835 |
+
]
|
| 836 |
+
: plan.dark
|
| 837 |
+
? [[0, 16, 0.6]]
|
| 838 |
+
: lv === 0
|
| 839 |
+
? [[0, 16, 0.75]]
|
| 840 |
+
: lv === 1
|
| 841 |
+
? [
|
| 842 |
+
[0, 10, 0.75],
|
| 843 |
+
[10, 6, 0.5],
|
| 844 |
+
]
|
| 845 |
+
: lv === 2
|
| 846 |
+
? [
|
| 847 |
+
[0, 7, 0.8],
|
| 848 |
+
[10, 6, 0.55],
|
| 849 |
+
]
|
| 850 |
+
: [
|
| 851 |
+
[0, 7, 0.85],
|
| 852 |
+
[10, 4, 0.6],
|
| 853 |
+
[14, 2, 0.45],
|
| 854 |
+
]
|
| 855 |
+
comp.forEach(([n, ln, v]) => {
|
| 856 |
+
const c = chordAt(n)
|
| 857 |
+
const r = lv === 0 || plan.dark ? 0.035 : 0.012
|
| 858 |
+
at(S(n), (b, a) => rhodes(b, a, c.v, ln * st, hv(v), r))
|
| 859 |
+
})
|
| 860 |
+
|
| 861 |
+
// 低音
|
| 862 |
+
const bp: [number, number, number][] = plan.dark
|
| 863 |
+
? [[0, 16, 0]]
|
| 864 |
+
: lv === 0
|
| 865 |
+
? []
|
| 866 |
+
: lv === 1
|
| 867 |
+
? [[0, 14, 0]]
|
| 868 |
+
: [
|
| 869 |
+
[0, 6, 0],
|
| 870 |
+
[7, 2, 12],
|
| 871 |
+
[10, 4, 0],
|
| 872 |
+
[14, 2, 7],
|
| 873 |
+
]
|
| 874 |
+
bp.forEach(([n, ln, iv]) => {
|
| 875 |
+
if (brk && n >= 12) return
|
| 876 |
+
const c = chordAt(n)
|
| 877 |
+
at(S(n), (b, a) => bassNote(b, a, c.b + iv, ln * st - 0.02, hv(iv ? 0.75 : 1) * (plan.dark ? 0.8 : 1)))
|
| 878 |
+
})
|
| 879 |
+
|
| 880 |
+
// 鼓
|
| 881 |
+
const stop = brk ? 8 : 16
|
| 882 |
+
if (plan.dark) {
|
| 883 |
+
at(S(0), (b, a) => kick(b, a, 0.75, true))
|
| 884 |
+
at(S(3), (b, a) => kick(b, a, 0.5, true))
|
| 885 |
+
if (plan.clock) for (let n = 0; n < stop; n += 4) at(S(n), (b, a) => clock(b, a, n % 8 === 0))
|
| 886 |
+
} else if (lv >= 1) {
|
| 887 |
+
for (let n = 0; n < stop; n++) {
|
| 888 |
+
const t = S(n)
|
| 889 |
+
if (lv === 1) {
|
| 890 |
+
if (n === 0) at(t, (b, a) => kick(b, a, 0.7))
|
| 891 |
+
if (n === 10) at(t, (b, a) => kick(b, a, 0.45))
|
| 892 |
+
if (n === 12) at(t, (b, a) => rim(b, a, hv(0.6)))
|
| 893 |
+
at(t, (b, a) => shaker(b, a, hv(n % 2 ? 0.3 : 0.55)))
|
| 894 |
+
continue
|
| 895 |
+
}
|
| 896 |
+
const kv = n === 0 ? 0.95 : n === 7 ? 0.55 : n === 10 ? 0.8 : lv >= 3 && n === 15 && j % 2 ? 0.4 : 0
|
| 897 |
+
if (kv) at(t, (b, a) => kick(b, a, hv(kv)))
|
| 898 |
+
if (n === 4 || n === 12) at(t, (b, a) => snare(b, a, hv(0.85), lv >= 3))
|
| 899 |
+
if (lv >= 3 && n === 9) at(t, (b, a) => snare(b, a, 0.15))
|
| 900 |
+
const open = lv >= 3 && n === 14
|
| 901 |
+
if (n % 2 === 0) at(t, (b, a) => hat(b, a, hv(open ? 0.8 : n % 4 === 0 ? 0.7 : 0.5), open))
|
| 902 |
+
else if (lv >= 3 || n === 15) at(t, (b, a) => hat(b, a, hv(0.26)))
|
| 903 |
+
}
|
| 904 |
+
}
|
| 905 |
+
if (brk) at(t0 + 8 * st, (b, a) => revCym(b, a, 8 * st, plan.dark ? 0.5 : 0.85))
|
| 906 |
+
|
| 907 |
+
// 旋律:只在旁白的停顿里应答
|
| 908 |
+
mel.forEach(([beat, m]) => {
|
| 909 |
+
const t = t0 + beat * 4 * st
|
| 910 |
+
if (talking(t, 0.15)) return
|
| 911 |
+
at(t, (b, a) => pluck(b, a, m, hv(plan.dark ? 0.7 : 0.85)))
|
| 912 |
+
})
|
| 913 |
+
// 全编制时的轻声琶音
|
| 914 |
+
if (lv >= 3)
|
| 915 |
+
for (let n = 0; n < stop; n += 2) {
|
| 916 |
+
const c = chordAt(n)
|
| 917 |
+
const m = c.v[[0, 1, 2, 3, 2, 1, 3, 2][n / 2]] + 12
|
| 918 |
+
at(S(n), (b, a) => pluck(b, a, m, hv(0.22), -0.3, 0.35))
|
| 919 |
+
}
|
| 920 |
+
}
|
| 921 |
+
})
|
| 922 |
+
|
| 923 |
+
// 终止和弦:Fmaj9 慢慢散开
|
| 924 |
+
at(endAll, (b, a) => {
|
| 925 |
+
pad(b, a, CH.Fmaj9hi.v, 5.5, 0.045, 900)
|
| 926 |
+
rhodes(b, a, CH.Fmaj9hi.v, 5, 0.75, 0.06)
|
| 927 |
+
bassNote(b, a, 41, 4.5, 0.8)
|
| 928 |
+
})
|
| 929 |
+
at(endAll + 0.3, (b, a) => pluck(b, a, 81, 0.8))
|
| 930 |
+
at(endAll + 0.9, (b, a) => pluck(b, a, 76, 0.6, -0.2))
|
| 931 |
+
at(endAll + 1.6, (b, a) => pluck(b, a, 72, 0.5))
|
| 932 |
+
return evs
|
| 933 |
+
}
|
| 934 |
+
|
| 935 |
+
// ---------- 旁白 + 音效 ----------
|
| 936 |
+
/** 音效整体电平(相对人声) */
|
| 937 |
+
const SFX_GAIN = 1.8
|
| 938 |
+
/** D 小调五声音阶:所有“啵”声都落在调内,和配乐不打架 */
|
| 939 |
+
const PENTA = [62, 65, 67, 69, 72]
|
| 940 |
+
function pent(f: number) {
|
| 941 |
+
const m = 69 + 12 * Math.log2(f / 440)
|
| 942 |
+
let best = m
|
| 943 |
+
let bd = 99
|
| 944 |
+
for (let o = -2; o <= 3; o++)
|
| 945 |
+
for (const p of PENTA) {
|
| 946 |
+
const c = p + 12 * o
|
| 947 |
+
const d = Math.abs(c - m)
|
| 948 |
+
if (d < bd) {
|
| 949 |
+
bd = d
|
| 950 |
+
best = c
|
| 951 |
+
}
|
| 952 |
+
}
|
| 953 |
+
return mtof(best)
|
| 954 |
+
}
|
| 955 |
+
/** 粉红噪声(1/f):比白噪声柔和,做气流、纸张、低频尾音 */
|
| 956 |
+
const PINK = (() => {
|
| 957 |
+
const r = lcg(777)
|
| 958 |
+
const d = new Float32Array(SR * 3)
|
| 959 |
+
let b0 = 0
|
| 960 |
+
let b1 = 0
|
| 961 |
+
let b2 = 0
|
| 962 |
+
let b3 = 0
|
| 963 |
+
let b4 = 0
|
| 964 |
+
let b5 = 0
|
| 965 |
+
let b6 = 0
|
| 966 |
+
for (let i = 0; i < d.length; i++) {
|
| 967 |
+
const w = r() * 2 - 1
|
| 968 |
+
b0 = 0.99886 * b0 + w * 0.0555179
|
| 969 |
+
b1 = 0.99332 * b1 + w * 0.0750759
|
| 970 |
+
b2 = 0.969 * b2 + w * 0.153852
|
| 971 |
+
b3 = 0.8665 * b3 + w * 0.3104856
|
| 972 |
+
b4 = 0.55 * b4 + w * 0.5329522
|
| 973 |
+
b5 = -0.7616 * b5 - w * 0.016898
|
| 974 |
+
d[i] = (b0 + b1 + b2 + b3 + b4 + b5 + b6 + w * 0.5362) * 0.16
|
| 975 |
+
b6 = w * 0.115926
|
| 976 |
+
}
|
| 977 |
+
return d
|
| 978 |
+
})()
|
| 979 |
+
const pinkCache = new WeakMap<BaseAudioContext, AudioBuffer>()
|
| 980 |
+
function pinkOf(ctx: OfflineAudioContext) {
|
| 981 |
+
let b = pinkCache.get(ctx)
|
| 982 |
+
if (!b) {
|
| 983 |
+
b = toBuffer(ctx, [PINK])
|
| 984 |
+
pinkCache.set(ctx, b)
|
| 985 |
+
}
|
| 986 |
+
return b
|
| 987 |
+
}
|
| 988 |
+
/** 模态合成的基本单元:一个自然衰减的正弦分音(dec = 衰减到 -60dB 的时间;bend = 起音时略高、迅速回落) */
|
| 989 |
+
function partial(ctx: OfflineAudioContext, dest: AudioNode, a: number, f: number, amp: number, dec: number, att = 0.0015, bend = 0) {
|
| 990 |
+
if (f > SR * 0.45 || amp <= 0) return
|
| 991 |
+
const o = ctx.createOscillator()
|
| 992 |
+
if (bend) {
|
| 993 |
+
o.frequency.setValueAtTime(f * (1 + bend), a)
|
| 994 |
+
o.frequency.exponentialRampToValueAtTime(f, a + Math.min(0.06, dec * 0.35))
|
| 995 |
+
} else o.frequency.value = f
|
| 996 |
+
const g = ctx.createGain()
|
| 997 |
+
g.gain.setValueAtTime(0, a)
|
| 998 |
+
g.gain.linearRampToValueAtTime(amp, a + att)
|
| 999 |
+
g.gain.setTargetAtTime(0, a + att, dec / 6.9)
|
| 1000 |
+
o.connect(g).connect(dest)
|
| 1001 |
+
o.start(a)
|
| 1002 |
+
o.stop(a + att + dec + 0.05)
|
| 1003 |
+
}
|
| 1004 |
+
/** 噪声瞬态:击打的“触点”、纸张、摩擦(滤波噪声 + 指数衰减,可带滤波扫频) */
|
| 1005 |
+
function burst(
|
| 1006 |
+
ctx: OfflineAudioContext,
|
| 1007 |
+
buf: AudioBuffer,
|
| 1008 |
+
dest: AudioNode,
|
| 1009 |
+
a: number,
|
| 1010 |
+
amp: number,
|
| 1011 |
+
type: BiquadFilterType,
|
| 1012 |
+
fc: number,
|
| 1013 |
+
q: number,
|
| 1014 |
+
dec: number,
|
| 1015 |
+
off = 0,
|
| 1016 |
+
fc2 = 0,
|
| 1017 |
+
) {
|
| 1018 |
+
const s = ctx.createBufferSource()
|
| 1019 |
+
s.buffer = buf
|
| 1020 |
+
const f = ctx.createBiquadFilter()
|
| 1021 |
+
f.type = type
|
| 1022 |
+
f.Q.value = q
|
| 1023 |
+
f.frequency.setValueAtTime(fc, a)
|
| 1024 |
+
if (fc2) f.frequency.exponentialRampToValueAtTime(fc2, a + dec)
|
| 1025 |
+
const g = ctx.createGain()
|
| 1026 |
+
g.gain.setValueAtTime(0, a)
|
| 1027 |
+
g.gain.linearRampToValueAtTime(amp, a + 0.0008)
|
| 1028 |
+
g.gain.setTargetAtTime(0, a + 0.0008, dec / 6.9)
|
| 1029 |
+
s.connect(f).connect(g).connect(dest)
|
| 1030 |
+
const room = Math.max(0.01, buf.duration - dec - 0.2)
|
| 1031 |
+
s.start(a, Math.abs(off) % room)
|
| 1032 |
+
s.stop(a + dec + 0.08)
|
| 1033 |
+
}
|
| 1034 |
+
/** 钢片琴(celesta):近谐波分音 + 轻微拍频 + 琴槌触点,干净、甜,和配乐同调 */
|
| 1035 |
+
const CELESTA: [number, number, number][] = [
|
| 1036 |
+
[1, 1, 1],
|
| 1037 |
+
[2.0, 0.38, 0.55],
|
| 1038 |
+
[3.0, 0.09, 0.3],
|
| 1039 |
+
[4.17, 0.08, 0.2],
|
| 1040 |
+
[5.43, 0.04, 0.13],
|
| 1041 |
+
[6.8, 0.018, 0.08],
|
| 1042 |
+
]
|
| 1043 |
+
function bell({ ctx, out, verb, noise }: Bus, a: number, f: number, amp: number, dec: number, wet = 0.5) {
|
| 1044 |
+
const sum = ctx.createGain()
|
| 1045 |
+
const dry = ctx.createGain()
|
| 1046 |
+
dry.gain.value = 1 - wet * 0.4
|
| 1047 |
+
const wg = ctx.createGain()
|
| 1048 |
+
wg.gain.value = wet
|
| 1049 |
+
sum.connect(dry).connect(out)
|
| 1050 |
+
sum.connect(wg).connect(verb)
|
| 1051 |
+
CELESTA.forEach(([r, pa, pd], k) => partial(ctx, sum, a, f * r * (1 + k * 0.0006), amp * 0.62 * pa, dec * pd, 0.0012))
|
| 1052 |
+
partial(ctx, sum, a, f + 0.9, amp * 0.16, dec * 0.85, 0.0012)
|
| 1053 |
+
burst(ctx, noise, sum, a, amp * 0.22, 'bandpass', Math.min(9500, f * 3.2), 1.1, 0.006, f * 0.0013)
|
| 1054 |
+
}
|
| 1055 |
+
/** 马林巴 / 木质音条:分音比 1 : 3.99 : 10.65,软槌触点 */
|
| 1056 |
+
const MARIMBA: [number, number, number][] = [
|
| 1057 |
+
[1, 1, 1],
|
| 1058 |
+
[3.99, 0.26, 0.3],
|
| 1059 |
+
[10.65, 0.06, 0.1],
|
| 1060 |
+
]
|
| 1061 |
+
function wood({ ctx, out, verb, noise }: Bus, a: number, f: number, amp: number, dec: number, mallet = 2400, wet = 0.18) {
|
| 1062 |
+
const sum = ctx.createGain()
|
| 1063 |
+
sum.connect(out)
|
| 1064 |
+
const wg = ctx.createGain()
|
| 1065 |
+
wg.gain.value = wet
|
| 1066 |
+
sum.connect(wg).connect(verb)
|
| 1067 |
+
MARIMBA.forEach(([r, pa, pd]) => partial(ctx, sum, a, f * r, amp * pa, dec * pd, 0.0012, r === 1 ? 0.012 : 0))
|
| 1068 |
+
burst(ctx, noise, sum, a, amp * 0.32, 'lowpass', mallet, 0.7, 0.012, f * 0.0071)
|
| 1069 |
+
}
|
| 1070 |
+
function sfxEvents(tl: Timeline, vo: AudioBuffer[]): Ev[] {
|
| 1071 |
+
const evs: Ev[] = []
|
| 1072 |
+
// 旁白走单独的第 4 路(干声、单声道),后面单独压缩再和音效合并
|
| 1073 |
+
tl.lines.forEach((l) =>
|
| 1074 |
+
evs.push({
|
| 1075 |
+
t: l.start,
|
| 1076 |
+
len: vo[l.i].duration,
|
| 1077 |
+
fn: ({ ctx, delay }, a) => {
|
| 1078 |
+
const s = ctx.createBufferSource()
|
| 1079 |
+
s.buffer = vo[l.i]
|
| 1080 |
+
const hp = ctx.createBiquadFilter()
|
| 1081 |
+
hp.type = 'highpass'
|
| 1082 |
+
hp.frequency.value = 85
|
| 1083 |
+
hp.Q.value = 0.7
|
| 1084 |
+
const mud = ctx.createBiquadFilter()
|
| 1085 |
+
mud.type = 'peaking'
|
| 1086 |
+
mud.frequency.value = 300
|
| 1087 |
+
mud.Q.value = 1
|
| 1088 |
+
mud.gain.value = -2
|
| 1089 |
+
const pres = ctx.createBiquadFilter()
|
| 1090 |
+
pres.type = 'peaking'
|
| 1091 |
+
pres.frequency.value = 3200
|
| 1092 |
+
pres.Q.value = 0.8
|
| 1093 |
+
pres.gain.value = 2
|
| 1094 |
+
const airy = ctx.createBiquadFilter()
|
| 1095 |
+
airy.type = 'highshelf'
|
| 1096 |
+
airy.frequency.value = 9000
|
| 1097 |
+
airy.gain.value = 1.5
|
| 1098 |
+
s.connect(hp).connect(mud).connect(pres).connect(airy).connect(delay)
|
| 1099 |
+
s.start(a)
|
| 1100 |
+
},
|
| 1101 |
+
}),
|
| 1102 |
+
)
|
| 1103 |
+
const at = (t: number, fn: (b: Bus, at: number) => void) =>
|
| 1104 |
+
evs.push({
|
| 1105 |
+
t: Math.max(0, t),
|
| 1106 |
+
fn: (b, a) => {
|
| 1107 |
+
const o = b.ctx.createGain()
|
| 1108 |
+
o.gain.value = SFX_GAIN
|
| 1109 |
+
o.connect(b.out)
|
| 1110 |
+
const v = b.ctx.createGain()
|
| 1111 |
+
v.gain.value = SFX_GAIN
|
| 1112 |
+
v.connect(b.verb)
|
| 1113 |
+
fn({ ...b, out: o, verb: v }, a)
|
| 1114 |
+
},
|
| 1115 |
+
})
|
| 1116 |
+
const rnd = lcg(42)
|
| 1117 |
+
|
| 1118 |
+
/** 平滑的单峰包络曲线(峰值在 pk 处),给气流 / 上升音用 */
|
| 1119 |
+
const swell = (n: number, pk: number, amp: number, fall = 1.6) => {
|
| 1120 |
+
const c = new Float32Array(n)
|
| 1121 |
+
for (let i = 0; i < n; i++) {
|
| 1122 |
+
const x = i / (n - 1)
|
| 1123 |
+
const y = x < pk ? Math.pow(Math.sin((Math.PI / 2) * (x / pk)), 2) : Math.pow(Math.cos((Math.PI / 2) * ((x - pk) / (1 - pk))), fall)
|
| 1124 |
+
c[i] = Math.max(0, y) * amp
|
| 1125 |
+
}
|
| 1126 |
+
c[n - 1] = 0
|
| 1127 |
+
return c
|
| 1128 |
+
}
|
| 1129 |
+
|
| 1130 |
+
/** 气流:粉噪“身体” + 高频“空气”,滤波跟着音量走(像物体掠过时的多普勒),左右移动 */
|
| 1131 |
+
const whoosh = (t: number, len = 0.9, amp = 0.16, up = true) =>
|
| 1132 |
+
at(t, ({ ctx, out, verb, noise }, a) => {
|
| 1133 |
+
const pb = pinkOf(ctx)
|
| 1134 |
+
const g = ctx.createGain()
|
| 1135 |
+
g.gain.setValueAtTime(0, a)
|
| 1136 |
+
g.gain.setValueCurveAtTime(swell(96, up ? 0.62 : 0.3, amp * 1.25), a, len)
|
| 1137 |
+
const s = ctx.createBufferSource()
|
| 1138 |
+
s.buffer = pb
|
| 1139 |
+
s.loop = true
|
| 1140 |
+
const bp = ctx.createBiquadFilter()
|
| 1141 |
+
bp.type = 'bandpass'
|
| 1142 |
+
bp.Q.value = 0.85
|
| 1143 |
+
const lo = up ? 260 : 2400
|
| 1144 |
+
const pk = up ? 2200 : 1100
|
| 1145 |
+
const en = up ? 900 : 300
|
| 1146 |
+
const tp = a + len * (up ? 0.62 : 0.3)
|
| 1147 |
+
bp.frequency.setValueAtTime(lo, a)
|
| 1148 |
+
bp.frequency.exponentialRampToValueAtTime(pk, tp)
|
| 1149 |
+
bp.frequency.exponentialRampToValueAtTime(en, a + len)
|
| 1150 |
+
s.connect(bp).connect(g)
|
| 1151 |
+
// 空气层:白噪声高通,只在峰值附近露出来
|
| 1152 |
+
const s2 = ctx.createBufferSource()
|
| 1153 |
+
s2.buffer = noise
|
| 1154 |
+
s2.loop = true
|
| 1155 |
+
const hp = ctx.createBiquadFilter()
|
| 1156 |
+
hp.type = 'bandpass'
|
| 1157 |
+
hp.Q.value = 1.4
|
| 1158 |
+
hp.frequency.setValueAtTime(up ? 2500 : 7000, a)
|
| 1159 |
+
hp.frequency.exponentialRampToValueAtTime(up ? 7500 : 3200, tp)
|
| 1160 |
+
hp.frequency.exponentialRampToValueAtTime(up ? 4200 : 2000, a + len)
|
| 1161 |
+
const ag = ctx.createGain()
|
| 1162 |
+
ag.gain.value = 0.16
|
| 1163 |
+
s2.connect(hp).connect(ag).connect(g)
|
| 1164 |
+
const pan = ctx.createStereoPanner()
|
| 1165 |
+
pan.pan.setValueAtTime(up ? -0.75 : 0.65, a)
|
| 1166 |
+
pan.pan.linearRampToValueAtTime(up ? 0.75 : -0.65, a + len)
|
| 1167 |
+
g.connect(pan)
|
| 1168 |
+
pan.connect(out)
|
| 1169 |
+
const vs = ctx.createGain()
|
| 1170 |
+
vs.gain.value = 0.45
|
| 1171 |
+
pan.connect(vs).connect(verb)
|
| 1172 |
+
s.start(a, (t * 1.37) % 1.8)
|
| 1173 |
+
s.stop(a + len + 0.05)
|
| 1174 |
+
s2.start(a, (t * 0.73) % 0.9)
|
| 1175 |
+
s2.stop(a + len + 0.05)
|
| 1176 |
+
})
|
| 1177 |
+
/** 冲击:超低频下潜 + 鼓头冲击 + 触点 + 粉噪轰鸣 + D 调低音尾,像电影预告里的“咚——” */
|
| 1178 |
+
const impact = (t: number, amp = 0.7) =>
|
| 1179 |
+
at(t, ({ ctx, out, verb, noise }, a) => {
|
| 1180 |
+
const k = amp * 0.34
|
| 1181 |
+
const pb = pinkOf(ctx)
|
| 1182 |
+
// 1 超低频下潜
|
| 1183 |
+
const o = ctx.createOscillator()
|
| 1184 |
+
o.frequency.setValueAtTime(64, a)
|
| 1185 |
+
o.frequency.exponentialRampToValueAtTime(37, a + 0.4)
|
| 1186 |
+
const g = ctx.createGain()
|
| 1187 |
+
g.gain.setValueAtTime(0, a)
|
| 1188 |
+
g.gain.linearRampToValueAtTime(k, a + 0.006)
|
| 1189 |
+
g.gain.setTargetAtTime(0, a + 0.03, 0.42)
|
| 1190 |
+
o.connect(g).connect(out)
|
| 1191 |
+
o.start(a)
|
| 1192 |
+
o.stop(a + 2.6)
|
| 1193 |
+
// 2 鼓头冲击
|
| 1194 |
+
const kk = ctx.createOscillator()
|
| 1195 |
+
kk.frequency.setValueAtTime(165, a)
|
| 1196 |
+
kk.frequency.exponentialRampToValueAtTime(52, a + 0.05)
|
| 1197 |
+
const kg = ctx.createGain()
|
| 1198 |
+
kg.gain.setValueAtTime(0, a)
|
| 1199 |
+
kg.gain.linearRampToValueAtTime(k * 0.75, a + 0.002)
|
| 1200 |
+
kg.gain.setTargetAtTime(0, a + 0.004, 0.045)
|
| 1201 |
+
kk.connect(kg).connect(out)
|
| 1202 |
+
kk.start(a)
|
| 1203 |
+
kk.stop(a + 0.4)
|
| 1204 |
+
// 3 触点
|
| 1205 |
+
burst(ctx, noise, out, a, k * 0.42, 'bandpass', 3400, 0.8, 0.014, t * 1.9)
|
| 1206 |
+
// 4 粉噪轰鸣(大部分进混响,形成空间)
|
| 1207 |
+
const body = ctx.createGain()
|
| 1208 |
+
body.connect(out)
|
| 1209 |
+
const bv = ctx.createGain()
|
| 1210 |
+
bv.gain.value = 0.9
|
| 1211 |
+
body.connect(bv).connect(verb)
|
| 1212 |
+
burst(ctx, pb, body, a, k * 1.1, 'lowpass', 1600, 0.6, 0.9, t * 2.3, 110)
|
| 1213 |
+
// 5 调在 D 上的低音尾(D2 + A2),融进配乐
|
| 1214 |
+
const tl2 = ctx.createBiquadFilter()
|
| 1215 |
+
tl2.type = 'lowpass'
|
| 1216 |
+
tl2.frequency.value = 520
|
| 1217 |
+
const tg = ctx.createGain()
|
| 1218 |
+
tg.gain.setValueAtTime(0, a)
|
| 1219 |
+
tg.gain.linearRampToValueAtTime(k * 0.2, a + 0.03)
|
| 1220 |
+
tg.gain.setTargetAtTime(0, a + 0.1, 0.6)
|
| 1221 |
+
tl2.connect(tg)
|
| 1222 |
+
tg.connect(out)
|
| 1223 |
+
tg.connect(verb)
|
| 1224 |
+
;[38, 45, 50].forEach((m, i) => {
|
| 1225 |
+
const x = ctx.createOscillator()
|
| 1226 |
+
x.type = 'triangle'
|
| 1227 |
+
x.frequency.value = mtof(m)
|
| 1228 |
+
x.detune.value = i === 1 ? 4 : -3
|
| 1229 |
+
const xg = ctx.createGain()
|
| 1230 |
+
xg.gain.value = [1, 0.5, 0.3][i]
|
| 1231 |
+
x.connect(xg).connect(tl2)
|
| 1232 |
+
x.start(a)
|
| 1233 |
+
x.stop(a + 3)
|
| 1234 |
+
})
|
| 1235 |
+
})
|
| 1236 |
+
/** 上升:反向镲片 + 粉噪扫频 + 越来越快的颤音和弦,最后一刻收住,落进下一个冲击 */
|
| 1237 |
+
const riser = (end: number, len = 1.8, amp = 0.12) =>
|
| 1238 |
+
at(end - len, ({ ctx, out, verb, noise }, a) => {
|
| 1239 |
+
const e = a + len
|
| 1240 |
+
const curve = (p: number, v: number) => {
|
| 1241 |
+
const n = 64
|
| 1242 |
+
const c = new Float32Array(n)
|
| 1243 |
+
for (let i = 0; i < n; i++) c[i] = Math.pow(i / (n - 1), p) * v
|
| 1244 |
+
return c
|
| 1245 |
+
}
|
| 1246 |
+
// 反向镲片
|
| 1247 |
+
const s = ctx.createBufferSource()
|
| 1248 |
+
s.buffer = noise
|
| 1249 |
+
s.loop = true
|
| 1250 |
+
const hp = ctx.createBiquadFilter()
|
| 1251 |
+
hp.type = 'highpass'
|
| 1252 |
+
hp.frequency.setValueAtTime(3500, a)
|
| 1253 |
+
hp.frequency.exponentialRampToValueAtTime(1800, e)
|
| 1254 |
+
const cg = ctx.createGain()
|
| 1255 |
+
cg.gain.setValueAtTime(0, a)
|
| 1256 |
+
cg.gain.setValueCurveAtTime(curve(3.2, amp * 0.55), a, len - 0.02)
|
| 1257 |
+
cg.gain.linearRampToValueAtTime(0, e)
|
| 1258 |
+
s.connect(hp).connect(cg)
|
| 1259 |
+
cg.connect(out)
|
| 1260 |
+
cg.connect(verb)
|
| 1261 |
+
s.start(a, (end * 1.3) % 1.5)
|
| 1262 |
+
s.stop(e + 0.02)
|
| 1263 |
+
// 粉噪扫频
|
| 1264 |
+
const s2 = ctx.createBufferSource()
|
| 1265 |
+
s2.buffer = pinkOf(ctx)
|
| 1266 |
+
s2.loop = true
|
| 1267 |
+
const bp = ctx.createBiquadFilter()
|
| 1268 |
+
bp.type = 'bandpass'
|
| 1269 |
+
bp.Q.value = 2.2
|
| 1270 |
+
bp.frequency.setValueAtTime(380, a)
|
| 1271 |
+
bp.frequency.exponentialRampToValueAtTime(5200, e)
|
| 1272 |
+
const g = ctx.createGain()
|
| 1273 |
+
g.gain.setValueAtTime(0, a)
|
| 1274 |
+
g.gain.setValueCurveAtTime(curve(2, amp * 1.1), a, len - 0.02)
|
| 1275 |
+
g.gain.linearRampToValueAtTime(0, e)
|
| 1276 |
+
s2.connect(bp).connect(g)
|
| 1277 |
+
g.connect(out)
|
| 1278 |
+
g.connect(verb)
|
| 1279 |
+
s2.start(a, (end * 0.7) % 2)
|
| 1280 |
+
s2.stop(e + 0.02)
|
| 1281 |
+
// 颤音和弦:D + A 八度滑升
|
| 1282 |
+
const lp = ctx.createBiquadFilter()
|
| 1283 |
+
lp.type = 'lowpass'
|
| 1284 |
+
lp.frequency.setValueAtTime(900, a)
|
| 1285 |
+
lp.frequency.exponentialRampToValueAtTime(3600, e)
|
| 1286 |
+
const trem = ctx.createGain()
|
| 1287 |
+
trem.gain.value = 0.55
|
| 1288 |
+
const lfo = ctx.createOscillator()
|
| 1289 |
+
lfo.frequency.setValueAtTime(4, a)
|
| 1290 |
+
lfo.frequency.exponentialRampToValueAtTime(18, e)
|
| 1291 |
+
const lg = ctx.createGain()
|
| 1292 |
+
lg.gain.value = 0.45
|
| 1293 |
+
lfo.connect(lg).connect(trem.gain)
|
| 1294 |
+
const og = ctx.createGain()
|
| 1295 |
+
og.gain.setValueAtTime(0, a)
|
| 1296 |
+
og.gain.setValueCurveAtTime(curve(2.4, amp * 0.32), a, len - 0.02)
|
| 1297 |
+
og.gain.linearRampToValueAtTime(0, e)
|
| 1298 |
+
;[62, 69, 74].forEach((m, i) => {
|
| 1299 |
+
const o = ctx.createOscillator()
|
| 1300 |
+
o.type = i === 2 ? 'sine' : 'triangle'
|
| 1301 |
+
o.frequency.setValueAtTime(mtof(m), a)
|
| 1302 |
+
o.frequency.exponentialRampToValueAtTime(mtof(m + 12), e)
|
| 1303 |
+
o.detune.value = [-7, 6, 0][i]
|
| 1304 |
+
o.connect(lp)
|
| 1305 |
+
o.start(a)
|
| 1306 |
+
o.stop(e + 0.02)
|
| 1307 |
+
})
|
| 1308 |
+
lp.connect(trem).connect(og)
|
| 1309 |
+
og.connect(out)
|
| 1310 |
+
og.connect(verb)
|
| 1311 |
+
lfo.start(a)
|
| 1312 |
+
lfo.stop(e + 0.02)
|
| 1313 |
+
})
|
| 1314 |
+
/** 计数“嗒”:柔和的木质轻点(无高频噪声触点,间隔过密时自动跳过,避免连成噼里啪啦) */
|
| 1315 |
+
let lastTick = -9
|
| 1316 |
+
const tick = (t: number, f = 2400, amp = 0.05) => {
|
| 1317 |
+
if (Math.abs(t - lastTick) < 0.11) return
|
| 1318 |
+
lastTick = t
|
| 1319 |
+
const pan = (rnd() - 0.5) * 0.35
|
| 1320 |
+
const jit = 0.94 + rnd() * 0.12
|
| 1321 |
+
at(t, ({ ctx, out }, a) => {
|
| 1322 |
+
const p = ctx.createStereoPanner()
|
| 1323 |
+
p.pan.value = pan
|
| 1324 |
+
p.connect(out)
|
| 1325 |
+
const ff = Math.min(1500, f * 0.55) * jit
|
| 1326 |
+
partial(ctx, p, a, ff, amp * 0.5, 0.045, 0.003)
|
| 1327 |
+
partial(ctx, p, a, ff * 1.5, amp * 0.14, 0.025, 0.003)
|
| 1328 |
+
})
|
| 1329 |
+
}
|
| 1330 |
+
const ticks = (t: number, len: number, n: number, f = 2200, amp = 0.04) => {
|
| 1331 |
+
for (let k = 0; k < n; k++) tick(t + (1 - Math.pow(1 - k / n, 1 / 3)) * len, f + (k % 2) * 160, amp)
|
| 1332 |
+
}
|
| 1333 |
+
/** 打字机 / 机械键盘:键帽触点 + 键帽本体 + 底壳“哒” + 回弹,每一下都略有不同 */
|
| 1334 |
+
let lastType = -9
|
| 1335 |
+
const type = (t: number) => {
|
| 1336 |
+
if (Math.abs(t - lastType) < 0.13) return
|
| 1337 |
+
lastType = t
|
| 1338 |
+
const f = 1400 + rnd() * 900
|
| 1339 |
+
const fc = 2600 + rnd() * 1800
|
| 1340 |
+
const off = rnd() * 1.5
|
| 1341 |
+
const v = 0.8 + rnd() * 0.4
|
| 1342 |
+
const pan = (rnd() - 0.5) * 0.5
|
| 1343 |
+
const up = 0.045 + rnd() * 0.025
|
| 1344 |
+
const th = 170 + rnd() * 60
|
| 1345 |
+
at(t, ({ ctx, out, noise }, a) => {
|
| 1346 |
+
const p = ctx.createStereoPanner()
|
| 1347 |
+
p.pan.value = pan
|
| 1348 |
+
p.connect(out)
|
| 1349 |
+
burst(ctx, noise, p, a, 0.035 * v, 'bandpass', fc * 0.7, 1.3, 0.007, off)
|
| 1350 |
+
partial(ctx, p, a, f, 0.045 * v, 0.024, 0.0005)
|
| 1351 |
+
partial(ctx, p, a, f * 2.31, 0.022 * v, 0.014, 0.0005)
|
| 1352 |
+
partial(ctx, p, a + 0.002, th, 0.07 * v, 0.045, 0.002, 0.2)
|
| 1353 |
+
burst(ctx, pinkOf(ctx), p, a + 0.002, 0.1 * v, 'lowpass', 1100, 0.7, 0.035, off + 0.4)
|
| 1354 |
+
burst(ctx, noise, p, a + up, 0.012 * v, 'bandpass', fc * 0.6, 1.5, 0.006, off + 0.8)
|
| 1355 |
+
})
|
| 1356 |
+
}
|
| 1357 |
+
/** 单个钢片琴音(D6) */
|
| 1358 |
+
const ding = (t: number, amp = 0.12) => at(t, (b, a) => bell(b, a, mtof(86), amp * 0.85, 1.8))
|
| 1359 |
+
/** 卡片落桌:粉噪“啪” + 桌面低频 + 纸边轻擦 */
|
| 1360 |
+
const thud = (t: number, amp = 0.4) =>
|
| 1361 |
+
at(t, (b, a) => {
|
| 1362 |
+
const { ctx, out, verb, noise } = b
|
| 1363 |
+
const sum = ctx.createGain()
|
| 1364 |
+
sum.connect(out)
|
| 1365 |
+
const vs = ctx.createGain()
|
| 1366 |
+
vs.gain.value = 0.16
|
| 1367 |
+
sum.connect(vs).connect(verb)
|
| 1368 |
+
partial(ctx, sum, a, 88, amp * 0.6, 0.2, 0.002, 0.3)
|
| 1369 |
+
partial(ctx, sum, a, 176, amp * 0.18, 0.08, 0.002)
|
| 1370 |
+
burst(ctx, pinkOf(ctx), sum, a, amp * 0.85, 'lowpass', 1500, 0.6, 0.08, t * 3.1, 320)
|
| 1371 |
+
burst(ctx, noise, sum, a, amp * 0.16, 'bandpass', 2400, 1.0, 0.016, t * 5.3)
|
| 1372 |
+
burst(ctx, noise, sum, a + 0.012, amp * 0.05, 'highpass', 6000, 0.7, 0.05, t * 2.9)
|
| 1373 |
+
})
|
| 1374 |
+
/** 木质音条“叮”,音高量化到 D 小调五声音阶:连续出现时就是一段小旋律 */
|
| 1375 |
+
let lastPop = -9
|
| 1376 |
+
const pop = (t: number, f = 900, amp = 0.06) => {
|
| 1377 |
+
if (Math.abs(t - lastPop) < 0.14) return
|
| 1378 |
+
lastPop = t
|
| 1379 |
+
const fq = pent(f)
|
| 1380 |
+
const pan = (rnd() - 0.5) * 0.6
|
| 1381 |
+
at(t, (b, a) => {
|
| 1382 |
+
const { ctx, out, verb, noise } = b
|
| 1383 |
+
const p = ctx.createStereoPanner()
|
| 1384 |
+
p.pan.value = pan
|
| 1385 |
+
p.connect(out)
|
| 1386 |
+
const sum = ctx.createGain()
|
| 1387 |
+
sum.connect(p)
|
| 1388 |
+
const vs = ctx.createGain()
|
| 1389 |
+
vs.gain.value = 0.26
|
| 1390 |
+
sum.connect(vs).connect(verb)
|
| 1391 |
+
partial(ctx, sum, a, fq, amp * 0.9, 0.34, 0.0015, 0.008)
|
| 1392 |
+
partial(ctx, sum, a, fq * 2, amp * 0.1, 0.16, 0.0015)
|
| 1393 |
+
partial(ctx, sum, a, fq * 3.99, amp * 0.2, 0.08, 0.0012)
|
| 1394 |
+
burst(ctx, noise, sum, a, amp * 0.12, 'lowpass', 2200, 0.7, 0.009, t * 5.1)
|
| 1395 |
+
})
|
| 1396 |
+
}
|
| 1397 |
+
/** 泛音:钢片琴琶音 D5-A5-D6-A6 + 一缕高频闪光 */
|
| 1398 |
+
const shimmer = (t: number, amp = 0.05) =>
|
| 1399 |
+
at(t, (b, a) => {
|
| 1400 |
+
;[74, 81, 86, 93].forEach((m, k) => bell(b, a + k * 0.065, mtof(m), amp * (0.95 - k * 0.14), 2.4, 0.8))
|
| 1401 |
+
const { ctx, verb, noise } = b
|
| 1402 |
+
const g = ctx.createGain()
|
| 1403 |
+
g.connect(verb)
|
| 1404 |
+
burst(ctx, noise, g, a + 0.05, amp * 0.35, 'highpass', 7500, 0.7, 0.9, t * 1.1)
|
| 1405 |
+
})
|
| 1406 |
+
|
| 1407 |
+
const S = (k: string) => tl.scenes.find((s) => s.key === k)!
|
| 1408 |
+
const Ls = (k: string, i: number) => S(k).lines[i].start
|
| 1409 |
+
const Le = (k: string, i: number) => S(k).lines[i].end
|
| 1410 |
+
|
| 1411 |
+
// 章节标题卡:转场气流 + 低频冲击 + 泛音
|
| 1412 |
+
tl.scenes.forEach((s) => {
|
| 1413 |
+
if (s.idx === 0) return
|
| 1414 |
+
whoosh(s.start - 0.05, 0.95, 0.14)
|
| 1415 |
+
impact(s.start + 0.25, 0.4)
|
| 1416 |
+
shimmer(s.start + 0.35, 0.03)
|
| 1417 |
+
whoosh(s.start + 1.75, 0.8, 0.05, false)
|
| 1418 |
+
})
|
| 1419 |
+
const L = (k: string, i: number) => S(k).lines[i].start
|
| 1420 |
+
const roll = (t: number, d: number, n = 12) => ticks(t, d, n, 2000, 0.03)
|
| 1421 |
+
/** 说中:钢片琴上行四度 + 木质低音垫底 */
|
| 1422 |
+
const ok = (t: number) =>
|
| 1423 |
+
at(t, (b, a) => {
|
| 1424 |
+
bell(b, a, mtof(81), 0.06, 1.2, 0.55)
|
| 1425 |
+
bell(b, a + 0.085, mtof(86), 0.07, 1.8, 0.6)
|
| 1426 |
+
wood(b, a, mtof(62), 0.05, 0.45, 1800, 0.2)
|
| 1427 |
+
})
|
| 1428 |
+
const ring = (t: number) => {
|
| 1429 |
+
whoosh(t, 1.8, 0.05)
|
| 1430 |
+
ticks(t + 0.1, 1.8, 18, 1900, 0.03)
|
| 1431 |
+
}
|
| 1432 |
+
/** 没说中:两声下行的闷木(A3 → F3)+ 低音“咚” */
|
| 1433 |
+
const no = (t: number) =>
|
| 1434 |
+
at(t, (b, a) => {
|
| 1435 |
+
wood(b, a, mtof(57), 0.26, 0.26, 1100, 0.12)
|
| 1436 |
+
wood(b, a + 0.14, mtof(53), 0.24, 0.34, 900, 0.12)
|
| 1437 |
+
partial(b.ctx, b.out, a + 0.14, mtof(41), 0.12, 0.28, 0.003)
|
| 1438 |
+
})
|
| 1439 |
+
|
| 1440 |
+
// 01 序章
|
| 1441 |
+
impact(L('intro', 0) - 1.2, 0.45)
|
| 1442 |
+
shimmer(L('intro', 0) - 1.1, 0.03)
|
| 1443 |
+
roll(L('intro', 0) + 0.3, 1.6, 16)
|
| 1444 |
+
riser(L('intro', 0) + 1.0, 1.2, 0.05)
|
| 1445 |
+
{
|
| 1446 |
+
const d0 = Le('intro', 0) - L('intro', 0)
|
| 1447 |
+
const w0 = (w: string) => L('intro', 0) + wordAt(VO_LINES[S('intro').lines[0].i].text, w) * d0
|
| 1448 |
+
whoosh(w0('4月') - 0.1, 0.6, 0.06)
|
| 1449 |
+
thud(w0('4月') + 0.3, 0.3)
|
| 1450 |
+
whoosh(w0('北京') - 0.1, 0.6, 0.06)
|
| 1451 |
+
thud(w0('北京') + 0.3, 0.3)
|
| 1452 |
+
pop(w0('人人') + 0.1, 900, 0.07)
|
| 1453 |
+
}
|
| 1454 |
+
{
|
| 1455 |
+
const l1 = S('intro').lines[1]
|
| 1456 |
+
const w1 = (w: string) => l1.start + wordAt(l1.text, w) * (l1.end - l1.start)
|
| 1457 |
+
shimmer(w1('KK') - 0.2, 0.04)
|
| 1458 |
+
for (let k = 0; k < 34; k++) type(L('intro', 1) + 2.2 + (k / 34) * 2.6)
|
| 1459 |
+
;['土地', '货币', '制度', '人性'].forEach((w, i) => pop(w1(w), 700 + i * 80, 0.06))
|
| 1460 |
+
}
|
| 1461 |
+
{
|
| 1462 |
+
const l2 = S('intro').lines[2]
|
| 1463 |
+
const w2 = (w: string) => l2.start + wordAt(l2.text, w) * (l2.end - l2.start)
|
| 1464 |
+
roll(w2('整整') - 0.3, 1.2, 12)
|
| 1465 |
+
roll(w2('一千') - 0.2, 1.4, 14)
|
| 1466 |
+
;['追更', '抄笔记', '整理成册'].forEach((w, i) => pop(w2(w), 800 + i * 70, 0.05))
|
| 1467 |
+
impact(w2('尊称') + 0.55, 0.55)
|
| 1468 |
+
shimmer(w2('尊称') + 0.7, 0.05)
|
| 1469 |
+
}
|
| 1470 |
+
pop(L('intro', 3) + 0.3, 700, 0.06)
|
| 1471 |
+
pop(L('intro', 3) + 0.9, 800, 0.06)
|
| 1472 |
+
pop(L('intro', 3) + 3.0, 900, 0.07)
|
| 1473 |
+
roll(L('intro', 3) + 3.2, 1.6, 16)
|
| 1474 |
+
shimmer(L('intro', 4) + 0.4, 0.04)
|
| 1475 |
+
riser(L('intro', 4) + 2.3 + 1.2, 1.2, 0.07)
|
| 1476 |
+
impact(L('intro', 4) + 3.5, 0.6)
|
| 1477 |
+
for (let k = 0; k < 16; k++) pop(L('intro', 5) + 0.2 + k * 0.12, 600 + k * 40, 0.035)
|
| 1478 |
+
whoosh(L('intro', 5) + 3.0, 1.6, 0.08, false)
|
| 1479 |
+
thud(L('intro', 5) + 4.6, 0.35)
|
| 1480 |
+
riser(L('intro', 6) - 0.6 + 1.0, 1.0, 0.08)
|
| 1481 |
+
impact(L('intro', 6) + 0.4, 0.75)
|
| 1482 |
+
shimmer(L('intro', 6) + 2.2, 0.04)
|
| 1483 |
+
|
| 1484 |
+
// 02 方法
|
| 1485 |
+
for (let k = 0; k < 2; k++) whoosh(L('method', 0) + 1.2 + k * 0.8, 0.5, 0.05)
|
| 1486 |
+
pop(L('method', 0) + 0.4, 900, 0.06)
|
| 1487 |
+
for (let k = 0; k < 14; k++) pop(L('method', 0) + 1.6 + k * 0.06, 700 + k * 30, 0.03)
|
| 1488 |
+
roll(L('method', 1) + 0.3, 1.8, 16)
|
| 1489 |
+
for (let k = 0; k < 12; k++) tick(L('method', 1) + 0.2 + k * 0.07, 2600, 0.025)
|
| 1490 |
+
shimmer(L('method', 1) + 2.6, 0.04)
|
| 1491 |
+
roll(L('method', 2) + 0.6, 1.4)
|
| 1492 |
+
roll(L('method', 2) + 2.0, 1.4)
|
| 1493 |
+
for (let k = 0; k < 123; k += 4) pop(L('method', 2) + 2.2 + k * 0.012, 800 + (k % 7) * 70, 0.028)
|
| 1494 |
+
whoosh(L('method', 3) + 0.4, 3.4, 0.05)
|
| 1495 |
+
for (let k = 0; k < 30; k++) tick(L('method', 3) + 0.5 + (k / 30) * 3.3, 3000 + (k % 3) * 200, 0.022)
|
| 1496 |
+
impact(L('method', 3) + 4.5, 0.55)
|
| 1497 |
+
for (let k = 0; k < 4; k++) whoosh(L('method', 4) + 1.0 + k * 1.6, 0.5, 0.05)
|
| 1498 |
+
|
| 1499 |
+
// 03 总成绩
|
| 1500 |
+
for (let k = 0; k < 4; k++) {
|
| 1501 |
+
whoosh(L('score', 0) + 0.3 + k * 0.9, 0.6, 0.05)
|
| 1502 |
+
roll(L('score', 0) + 0.4 + k * 0.9, 1.3, 10)
|
| 1503 |
+
}
|
| 1504 |
+
riser(L('score', 1) - 0.4 + 1.0, 1.0, 0.06)
|
| 1505 |
+
roll(L('score', 1) + 0.8, 2.0, 18)
|
| 1506 |
+
ok(L('score', 1) + 2.8)
|
| 1507 |
+
;[2.2, 4.4, 6.4].forEach((d) => roll(L('score', 2) + d, 1.2, 10))
|
| 1508 |
+
for (let k = 0; k < 4; k++) pop(L('score', 3) + 0.3 + k * 0.6, 700 + k * 80, 0.05)
|
| 1509 |
+
thud(L('score', 3) + 4.5, 0.3)
|
| 1510 |
+
for (let k = 0; k < 5; k++) whoosh(L('score', 4) + 0.6 + k * 0.5, 0.5, 0.05)
|
| 1511 |
+
|
| 1512 |
+
// 04 房价
|
| 1513 |
+
whoosh(L('price', 0) + 0.8, 5.0, 0.04)
|
| 1514 |
+
for (let k = 0; k < 3; k++) pop(L('price', 0) + 2.6 + k * 0.6, 900, 0.05)
|
| 1515 |
+
riser(L('price', 1) + 0.4 + 1.6, 1.6, 0.06)
|
| 1516 |
+
roll(L('price', 1) + 4.6, 1.2)
|
| 1517 |
+
no(L('price', 1) + 6.6)
|
| 1518 |
+
pop(L('price', 2) + 2.6, 700, 0.06)
|
| 1519 |
+
pop(L('price', 2) + 3.4, 900, 0.06)
|
| 1520 |
+
roll(L('price', 2) + 4.4, 1.2)
|
| 1521 |
+
ok(L('price', 2) + 5.6)
|
| 1522 |
+
impact(L('price', 3) + 0.4, 0.4)
|
| 1523 |
+
whoosh(L('price', 3) + 1.6, 2.0, 0.08, false)
|
| 1524 |
+
roll(L('price', 3) + 2.6, 1.2)
|
| 1525 |
+
thud(L('price', 3) + 3.6, 0.38)
|
| 1526 |
+
whoosh(L('price', 4) + 0.3, 2.6, 0.05, false)
|
| 1527 |
+
roll(L('price', 4) + 0.6, 1.6, 14)
|
| 1528 |
+
ring(L('price', 5) + 0.3)
|
| 1529 |
+
|
| 1530 |
+
// 05 城市
|
| 1531 |
+
for (let k = 0; k < 23; k++) pop(L('cities', 0) + 0.6 + k * 0.12, 700 + (k % 6) * 90, 0.035)
|
| 1532 |
+
roll(L('cities', 0) + 3.8, 1.6, 16)
|
| 1533 |
+
shimmer(L('cities', 0) + 5.4, 0.04)
|
| 1534 |
+
pop(L('cities', 1) + 2.6, 800, 0.06)
|
| 1535 |
+
roll(L('cities', 1) + 2.6, 1.3)
|
| 1536 |
+
pop(L('cities', 1) + 4.2, 600, 0.06)
|
| 1537 |
+
roll(L('cities', 1) + 4.2, 1.3)
|
| 1538 |
+
ok(L('cities', 1) + 7.6)
|
| 1539 |
+
for (let k = 0; k < 4; k++) pop(L('cities', 2) + 0.4 + k * 0.25, 900 - k * 60, 0.05)
|
| 1540 |
+
whoosh(L('cities', 2) + 3.4, 0.7, 0.06)
|
| 1541 |
+
roll(L('cities', 2) + 3.6, 1.2)
|
| 1542 |
+
whoosh(L('cities', 3) + 1.8, 1.4, 0.06, false)
|
| 1543 |
+
whoosh(L('cities', 3) + 4.0, 1.4, 0.06, false)
|
| 1544 |
+
ok(L('cities', 3) + 6.2)
|
| 1545 |
+
for (let k = 0; k < 2; k++) no(L('cities', 4) + 0.8 + k * 1.0)
|
| 1546 |
+
for (let k = 0; k < 3; k++) pop(L('cities', 4) + 4.6 + k * 0.8, 700, 0.05)
|
| 1547 |
+
thud(L('cities', 4) + 6.2, 0.3)
|
| 1548 |
+
shimmer(L('cities', 5) + 0.2, 0.04)
|
| 1549 |
+
|
| 1550 |
+
// 06 货币
|
| 1551 |
+
for (let k = 0; k < 3; k++) pop(L('money', 0) + 1.2 + k * 1.0, 700 + k * 120, 0.06)
|
| 1552 |
+
whoosh(L('money', 1) + 0.4, 3.2, 0.05)
|
| 1553 |
+
ok(L('money', 1) + 3.8)
|
| 1554 |
+
whoosh(L('money', 2) + 0.3, 2.4, 0.04)
|
| 1555 |
+
riser(L('money', 2) + 4.2 + 1.4, 1.4, 0.08)
|
| 1556 |
+
no(L('money', 2) + 4.0)
|
| 1557 |
+
impact(L('money', 2) + 5.6, 0.35)
|
| 1558 |
+
whoosh(L('money', 3) + 0.6, 2.8, 0.05, false)
|
| 1559 |
+
no(L('money', 3) + 2.2)
|
| 1560 |
+
whoosh(L('money', 4) + 0.1, 0.9, 0.08)
|
| 1561 |
+
thud(L('money', 4) + 1.4, 0.25)
|
| 1562 |
+
pop(L('money', 4) + 4.0, 900, 0.06)
|
| 1563 |
+
pop(L('money', 4) + 5.6, 700, 0.06)
|
| 1564 |
+
ok(L('money', 4) + 6.6)
|
| 1565 |
+
;[0.8, 1.6, 3.4, 6.0].forEach((d, k) => pop(L('money', 5) + d, 600 + k * 120, 0.06))
|
| 1566 |
+
thud(L('money', 5) + 3.4, 0.25)
|
| 1567 |
+
shimmer(L('money', 5) + 6.2, 0.04)
|
| 1568 |
+
|
| 1569 |
+
// 07 政策
|
| 1570 |
+
ring(L('policy', 0) + 0.4)
|
| 1571 |
+
for (let k = 0; k < 3; k++) pop(L('policy', 0) + 2.6 + k * 0.3, 800, 0.05)
|
| 1572 |
+
for (let k = 0; k < 3; k++) pop(L('policy', 1) + 1.0 + k * 0.9, 700 + k * 150, 0.06)
|
| 1573 |
+
roll(L('policy', 1) + 3.4, 1.6, 16)
|
| 1574 |
+
ok(L('policy', 1) + 5.6)
|
| 1575 |
+
ok(L('policy', 1) + 6.0)
|
| 1576 |
+
for (let k = 0; k < 4; k++) whoosh(L('policy', 2) + 2.0 + k * 0.9, 0.5, 0.05)
|
| 1577 |
+
ok(L('policy', 2) + 6.4)
|
| 1578 |
+
whoosh(L('policy', 3) + 0.2, 1.0, 0.07)
|
| 1579 |
+
impact(L('policy', 3) + 2.2, 0.4)
|
| 1580 |
+
ok(L('policy', 3) + 5.2)
|
| 1581 |
+
whoosh(L('policy', 4) + 1.4, 1.4, 0.05)
|
| 1582 |
+
no(L('policy', 4) + 3.6)
|
| 1583 |
+
whoosh(L('policy', 4) + 5.4, 1.6, 0.05)
|
| 1584 |
+
roll(L('policy', 4) + 5.4, 1.6, 14)
|
| 1585 |
+
no(L('policy', 4) + 6.8)
|
| 1586 |
+
whoosh(L('policy', 5) + 0.4, 1.0, 0.05)
|
| 1587 |
+
whoosh(L('policy', 5) + 1.4, 3.0, 0.04, false)
|
| 1588 |
+
pop(L('policy', 5) + 4.2, 600, 0.07)
|
| 1589 |
+
no(L('policy', 5) + 5.4)
|
| 1590 |
+
|
| 1591 |
+
// 08 三把尺子
|
| 1592 |
+
for (let k = 0; k < 3; k++) whoosh(L('rulers', 0) + 0.6 + k * 0.5, 0.6, 0.06)
|
| 1593 |
+
;[1, 2, 3].forEach((k) => {
|
| 1594 |
+
const ds = k === 3 ? [1.0, 1.4, 2.2, 2.6, 4.2, 5.6] : [1.6, 3.4, 5.4]
|
| 1595 |
+
ds.forEach((d, j) => {
|
| 1596 |
+
pop(L('rulers', k) + d, 600 + j * 90, 0.05)
|
| 1597 |
+
roll(L('rulers', k) + d, 1.0, 8)
|
| 1598 |
+
})
|
| 1599 |
+
thud(L('rulers', k) + ds[ds.length - 1] + 0.4, 0.22)
|
| 1600 |
+
})
|
| 1601 |
+
ok(L('rulers', 4) + 0.3)
|
| 1602 |
+
no(L('rulers', 4) + 2.7)
|
| 1603 |
+
|
| 1604 |
+
// 09 自信校准
|
| 1605 |
+
for (let k = 0; k < 6; k++) pop(L('brier', 0) + 0.3 + k * 0.22, 1000 - k * 60, 0.04)
|
| 1606 |
+
roll(L('brier', 0) + 0.8, 1.4, 14)
|
| 1607 |
+
for (let k = 0; k < 14; k++) type(L('brier', 1) + 0.4 + k * 0.11)
|
| 1608 |
+
ding(L('brier', 1) + 3.0, 0.06)
|
| 1609 |
+
thud(L('brier', 1) + 4.0, 0.25)
|
| 1610 |
+
whoosh(L('brier', 2) + 0.2, 2.2, 0.05)
|
| 1611 |
+
no(L('brier', 2) + 2.4)
|
| 1612 |
+
pop(L('brier', 2) + 4.6, 700, 0.07)
|
| 1613 |
+
pop(L('brier', 2) + 6.6, 900, 0.07)
|
| 1614 |
+
riser(L('brier', 3) - 0.6 + 1.0, 1.0, 0.07)
|
| 1615 |
+
ok(L('brier', 3) + 0.4)
|
| 1616 |
+
impact(L('brier', 3) + 4.6, 0.45)
|
| 1617 |
+
|
| 1618 |
+
// 10 盲区
|
| 1619 |
+
for (let k = 0; k < 3; k++) whoosh(L('blind', 0) + 0.8 + k * 0.6, 0.6, 0.06)
|
| 1620 |
+
for (let k = 0; k < 3; k++) thud(L('blind', 1) + 3.6 + k * 0.5, 0.2)
|
| 1621 |
+
no(L('blind', 1) + 5.4)
|
| 1622 |
+
for (let k = 0; k < 40; k++) tick(L('blind', 2) + 0.3 + k * 0.035, 2800, 0.018)
|
| 1623 |
+
whoosh(L('blind', 2) + 4.0, 2.2, 0.05, false)
|
| 1624 |
+
roll(L('blind', 2) + 4.0, 1.6, 14)
|
| 1625 |
+
thud(L('blind', 2) + 7.6, 0.3)
|
| 1626 |
+
;[0.6, 3.6, 5.6].forEach((d) => {
|
| 1627 |
+
whoosh(L('blind', 3) + d, 0.6, 0.06)
|
| 1628 |
+
roll(L('blind', 3) + d + 0.5, 1.2, 10)
|
| 1629 |
+
})
|
| 1630 |
+
thud(L('blind', 3) + 5.9, 0.3)
|
| 1631 |
+
whoosh(L('blind', 4) + 1.4, 1.0, 0.05, false)
|
| 1632 |
+
riser(L('blind', 4) + 2.2 + 1.0, 1.0, 0.06)
|
| 1633 |
+
impact(L('blind', 4) + 3.2, 0.6)
|
| 1634 |
+
thud(L('blind', 4) + 4.0, 0.4)
|
| 1635 |
+
|
| 1636 |
+
// 11 未到期
|
| 1637 |
+
for (let k = 0; k < 3; k++) whoosh(L('pending', 0) + 0.6 + k * 0.7, 0.5, 0.05)
|
| 1638 |
+
for (let k = 0; k < 10; k++) pop(L('pending', 0) + 2.6 + k * 0.2, 800 + k * 40, 0.04)
|
| 1639 |
+
ding(L('pending', 1) + 0.2, 0.06)
|
| 1640 |
+
thud(L('pending', 2) + 0.2, 0.25)
|
| 1641 |
+
|
| 1642 |
+
// 12 理论与展望
|
| 1643 |
+
{
|
| 1644 |
+
const ow = (k: number, w: string) => {
|
| 1645 |
+
const l = S('outlook').lines[k]
|
| 1646 |
+
return l.start + wordAt(l.text, w) * (l.end - l.start)
|
| 1647 |
+
}
|
| 1648 |
+
roll(ow(0, '43'), 1.4, 14)
|
| 1649 |
+
for (let k = 0; k < 8; k++) pop(ow(0, '八大') - 0.6 + k * 0.12, 650 + k * 50, 0.035)
|
| 1650 |
+
;['谁在定价', '钱从哪里来', '人往哪里去'].forEach((w, i) => {
|
| 1651 |
+
whoosh(ow(1, w) - 0.2, 0.5, 0.05)
|
| 1652 |
+
pop(ow(1, w) + 0.1, 760 + i * 90, 0.06)
|
| 1653 |
+
})
|
| 1654 |
+
ding(ow(1, '十五年后') + 0.2, 0.05)
|
| 1655 |
+
shimmer(L('outlook', 2) + 0.3, 0.04)
|
| 1656 |
+
riser(ow(2, '以下') - 1.0, 1.0, 0.05)
|
| 1657 |
+
impact(ow(2, '不构成') + 0.1, 0.45)
|
| 1658 |
+
for (let k = 3; k <= 5; k++) {
|
| 1659 |
+
whoosh(L('outlook', k) - 0.1, 0.6, 0.06)
|
| 1660 |
+
pop(L('outlook', k) + 0.3, 700 + k * 40, 0.06)
|
| 1661 |
+
}
|
| 1662 |
+
thud(ow(6, '打了折扣') + 0.1, 0.35)
|
| 1663 |
+
pop(ow(6, '钱越来越多'), 900, 0.05)
|
| 1664 |
+
thud(ow(6, '房价却') + 0.1, 0.28)
|
| 1665 |
+
whoosh(ow(7, '而是') - 0.3, 0.6, 0.05, false)
|
| 1666 |
+
shimmer(ow(7, '而是') + 0.4, 0.05)
|
| 1667 |
+
ding(ow(7, '再强调') + 0.1, 0.05)
|
| 1668 |
+
}
|
| 1669 |
+
|
| 1670 |
+
// 13 结论
|
| 1671 |
+
shimmer(L('outro', 0) + 0.2, 0.04)
|
| 1672 |
+
for (let k = 0; k < 7; k++) pop(L('outro', 1) + (k < 3 ? 1.0 + k * 0.3 : 3.6 + k * 0.25), 600 + k * 60, 0.06)
|
| 1673 |
+
whoosh(L('outro', 1) + 4.6, 1.6, 0.05)
|
| 1674 |
+
riser(L('outro', 2) - 0.8 + 0.9, 0.9, 0.07)
|
| 1675 |
+
impact(L('outro', 2) + 0.15, 0.6)
|
| 1676 |
+
shimmer(L('outro', 2) + 1.2, 0.05)
|
| 1677 |
+
for (let k = 0; k < 5; k++) pop(L('outro', 3) + 0.2 + k * 0.25, 700, 0.05)
|
| 1678 |
+
whoosh(L('outro', 3) + 3.6, 0.6, 0.08, false)
|
| 1679 |
+
thud(L('outro', 3) + 3.7, 0.38)
|
| 1680 |
+
// 致敬
|
| 1681 |
+
shimmer(L('outro', 4) + 0.2, 0.05)
|
| 1682 |
+
for (let k = 0; k < 3; k++) pop(L('outro', 4) + 3.0 + k * 1.1, 700 + k * 90, 0.06)
|
| 1683 |
+
riser(L('outro', 5) - 0.6, 0.8, 0.06)
|
| 1684 |
+
roll(L('outro', 5) + 0.4, 1.6, 14)
|
| 1685 |
+
ding(L('outro', 5) + 2.2, 0.06)
|
| 1686 |
+
whoosh(L('outro', 6) + 0.2, 1.2, 0.05)
|
| 1687 |
+
for (let k = 0; k < 3; k++) pop(L('outro', 6) + 2.6 + k * 0.5, 650 + k * 80, 0.06)
|
| 1688 |
+
impact(L('outro', 6) + Math.max(4, Le('outro', 6) - L('outro', 6) - 2.4), 0.5)
|
| 1689 |
+
shimmer(L('outro', 6) + Math.max(4.2, Le('outro', 6) - L('outro', 6) - 2.2), 0.05)
|
| 1690 |
+
// 收尾:条码 + 关注 / 点赞 / 评论
|
| 1691 |
+
const dl = Le('outro', 7) - L('outro', 7)
|
| 1692 |
+
for (let k = 0; k < 123; k += 3) tick(L('outro', 7) + 0.2 + (k / 123) * 1.6, 2400 + (k % 5) * 150, 0.02)
|
| 1693 |
+
whoosh(L('outro', 7) + dl * CTA_IN - 0.3, 1.0, 0.05)
|
| 1694 |
+
for (const f of CTA_AT) pop(L('outro', 7) + dl * f + 0.05, 1000, 0.08)
|
| 1695 |
+
ding(L('outro', 7) + dl * CTA_AT[1] + 0.15, 0.06)
|
| 1696 |
+
shimmer(Le('outro', 7) + 0.3, 0.05)
|
| 1697 |
+
return evs
|
| 1698 |
+
}
|
| 1699 |
+
|
| 1700 |
+
// ---------- 母带处理 ----------
|
| 1701 |
+
/** 人声压缩参数(阈值 dBFS / 压缩比 / 补偿增益) */
|
| 1702 |
+
const VOICE = { thr: -24, ratio: 3, knee: 8, makeup: 5.0 }
|
| 1703 |
+
/** 成片峰值上限 ≈ -2.2 dBFS:主轨限幅时把同一时刻的配乐峰值也算进去(主轨 + 配乐 ≤ 上限),
|
| 1704 |
+
* 这样配乐可以更响,叠加、再经 AAC 编码后真峰值仍 ≤ -1 dBTP */
|
| 1705 |
+
const MIX_CEIL = 0.78
|
| 1706 |
+
/** 配乐峰值包络的分块大小(样本) */
|
| 1707 |
+
const PK_BLK = 64
|
| 1708 |
+
/** 背景音乐整体电平 / 说话时压低到的比例 */
|
| 1709 |
+
const MUSIC_GAIN = 0.62
|
| 1710 |
+
const MUSIC_DUCK = 0.6
|
| 1711 |
+
|
| 1712 |
+
/** 配乐峰值 → 慢包络:滑动最大值(±45ms)后再做 0.3s 释放平滑,并按 0.7 计入(两轨峰值很少同时到顶) */
|
| 1713 |
+
function smoothPeaks(pk: Float32Array) {
|
| 1714 |
+
const n = pk.length
|
| 1715 |
+
const H = Math.ceil((0.045 * SR) / PK_BLK)
|
| 1716 |
+
const mx = new Float32Array(n)
|
| 1717 |
+
const dq = new Int32Array(n)
|
| 1718 |
+
let qh = 0
|
| 1719 |
+
let qt = 0
|
| 1720 |
+
for (let i = 0; i < n + H; i++) {
|
| 1721 |
+
if (i < n) {
|
| 1722 |
+
while (qt > qh && pk[dq[qt - 1]] <= pk[i]) qt--
|
| 1723 |
+
dq[qt++] = i
|
| 1724 |
+
}
|
| 1725 |
+
const c = i - H
|
| 1726 |
+
if (c < 0) continue
|
| 1727 |
+
while (dq[qh] < c - H) qh++
|
| 1728 |
+
mx[c] = pk[dq[qh]]
|
| 1729 |
+
}
|
| 1730 |
+
const kr = 1 - Math.exp(-PK_BLK / (0.3 * SR))
|
| 1731 |
+
let e = 0
|
| 1732 |
+
for (let i = 0; i < n; i++) {
|
| 1733 |
+
e = mx[i] > e ? mx[i] : e + (mx[i] - e) * kr
|
| 1734 |
+
mx[i] = e * 0.7
|
| 1735 |
+
}
|
| 1736 |
+
return mx
|
| 1737 |
+
}
|
| 1738 |
+
|
| 1739 |
+
/**
|
| 1740 |
+
* 主轨后处理(有状态,可分段调用):
|
| 1741 |
+
* 第 4 路人声 → 软拐点压缩 + 补偿 → 与音效相加 → 前瞻限幅(2.5ms,最小值+滑动平均,不削波)
|
| 1742 |
+
*/
|
| 1743 |
+
function mainMaster(musPk?: Float32Array) {
|
| 1744 |
+
const aA = 1 - Math.exp(-1 / (0.001 * SR))
|
| 1745 |
+
const aR = 1 - Math.exp(-1 / (0.09 * SR))
|
| 1746 |
+
const gA = 1 - Math.exp(-1 / (0.002 * SR))
|
| 1747 |
+
const gR = 1 - Math.exp(-1 / (0.12 * SR))
|
| 1748 |
+
let e = 0
|
| 1749 |
+
let vg = 1
|
| 1750 |
+
// 人声压缩也带 5ms 前瞻:检测用当前样本,增益作用在延迟后的样本上
|
| 1751 |
+
const VLA = Math.round(0.005 * SR)
|
| 1752 |
+
const vd = new Float32Array(VLA)
|
| 1753 |
+
let vi = 0
|
| 1754 |
+
const { thr, ratio, knee, makeup } = VOICE
|
| 1755 |
+
const slope = 1 / ratio - 1
|
| 1756 |
+
const LA = Math.round(0.004 * SR)
|
| 1757 |
+
const relK = 1 - Math.exp(-1 / (0.15 * SR))
|
| 1758 |
+
// 配乐峰值转成慢包络(约 90ms 保持 + 平滑),限幅阈值只随配乐响度缓慢变化,
|
| 1759 |
+
// 不再跟着低音波形抖动(否则人声会被低音调制,听起来像电流声)
|
| 1760 |
+
const musEnv = musPk ? smoothPeaks(musPk) : null
|
| 1761 |
+
// 延迟线 + 单调队列(前瞻最小值)+ 滑动平均
|
| 1762 |
+
const dl = new Float32Array(LA + 1)
|
| 1763 |
+
const dr = new Float32Array(LA + 1)
|
| 1764 |
+
const req = new Float32Array(LA + 1)
|
| 1765 |
+
const dq = new Int32Array(LA + 2)
|
| 1766 |
+
let qh = 0
|
| 1767 |
+
let qt = 0
|
| 1768 |
+
const box = new Float32Array(LA)
|
| 1769 |
+
let boxSum = LA
|
| 1770 |
+
box.fill(1)
|
| 1771 |
+
let bi = 0
|
| 1772 |
+
let rel = 1
|
| 1773 |
+
let n0 = 0
|
| 1774 |
+
let maxGR = 0
|
| 1775 |
+
let maxAt = 0
|
| 1776 |
+
let gr2 = 0
|
| 1777 |
+
let target = 1
|
| 1778 |
+
return Object.assign(
|
| 1779 |
+
(chans: Float32Array[], n: number) => {
|
| 1780 |
+
const L = chans[0]
|
| 1781 |
+
const R = chans[1]
|
| 1782 |
+
const V = chans[3]
|
| 1783 |
+
for (let i = 0; i < n; i++) {
|
| 1784 |
+
// 人声压缩
|
| 1785 |
+
const v = V[i]
|
| 1786 |
+
const av = v < 0 ? -v : v
|
| 1787 |
+
e += (av - e) * (av > e ? aA : aR)
|
| 1788 |
+
if ((i & 7) === 0) {
|
| 1789 |
+
const lvl = 20 * Math.log10(e + 1e-9)
|
| 1790 |
+
const over = lvl - thr
|
| 1791 |
+
const gr = over <= -knee / 2 ? 0 : over < knee / 2 ? (slope * (over + knee / 2) ** 2) / (2 * knee) : slope * over
|
| 1792 |
+
target = Math.pow(10, gr / 20) * makeup
|
| 1793 |
+
}
|
| 1794 |
+
vg += (target - vg) * (target < vg ? gA : gR)
|
| 1795 |
+
const vdel = vd[vi]
|
| 1796 |
+
vd[vi] = v
|
| 1797 |
+
vi = vi + 1 >= VLA ? 0 : vi + 1
|
| 1798 |
+
const xl = L[i] + vdel * vg
|
| 1799 |
+
const xr = R[i] + vdel * vg
|
| 1800 |
+
// 限幅
|
| 1801 |
+
const pk = Math.max(xl < 0 ? -xl : xl, xr < 0 ? -xr : xr)
|
| 1802 |
+
// 这个样本 LA 之后才输出,和那一刻的配乐相加
|
| 1803 |
+
const mj = musEnv ? ((n0 + LA) / PK_BLK) | 0 : 0
|
| 1804 |
+
const mp = musEnv && mj < musEnv.length ? musEnv[mj] : 0
|
| 1805 |
+
const lim = MIX_CEIL - mp > 0.45 ? MIX_CEIL - mp : 0.45
|
| 1806 |
+
const rq = pk > lim ? lim / pk : 1
|
| 1807 |
+
const w = n0 % (LA + 1)
|
| 1808 |
+
dl[w] = xl
|
| 1809 |
+
dr[w] = xr
|
| 1810 |
+
req[w] = rq
|
| 1811 |
+
while (qt > qh && req[dq[(qt - 1) % (LA + 2)] % (LA + 1)] >= rq) qt--
|
| 1812 |
+
dq[qt % (LA + 2)] = n0
|
| 1813 |
+
qt++
|
| 1814 |
+
while (dq[qh % (LA + 2)] <= n0 - LA - 1) qh++
|
| 1815 |
+
const h = req[dq[qh % (LA + 2)] % (LA + 1)]
|
| 1816 |
+
rel = h < rel ? h : rel + (1 - rel) * relK
|
| 1817 |
+
boxSum += rel - box[bi]
|
| 1818 |
+
box[bi] = rel
|
| 1819 |
+
bi = bi + 1 >= LA ? 0 : bi + 1
|
| 1820 |
+
const g = boxSum / LA
|
| 1821 |
+
if (1 - g > maxGR) {
|
| 1822 |
+
maxGR = 1 - g
|
| 1823 |
+
maxAt = n0 / SR
|
| 1824 |
+
}
|
| 1825 |
+
if (g < 0.794) gr2++
|
| 1826 |
+
const o = (n0 + 1) % (LA + 1)
|
| 1827 |
+
L[i] = dl[o] * g
|
| 1828 |
+
R[i] = dr[o] * g
|
| 1829 |
+
n0++
|
| 1830 |
+
}
|
| 1831 |
+
},
|
| 1832 |
+
{ stats: () => ({ maxGRdB: -20 * Math.log10(1 - maxGR), maxAt, over2dB: gr2 / SR }) },
|
| 1833 |
+
)
|
| 1834 |
+
}
|
| 1835 |
+
|
| 1836 |
+
/** 背景音乐:只在长停顿(≥1.1 秒)和标题卡时抬起来,句间短停顿保持压低,避免忽大忽小 */
|
| 1837 |
+
function musicEnvelope(tl: Timeline) {
|
| 1838 |
+
const dur = tl.duration
|
| 1839 |
+
const blocks: [number, number][] = []
|
| 1840 |
+
for (const l of tl.lines) {
|
| 1841 |
+
const b = blocks[blocks.length - 1]
|
| 1842 |
+
if (b && l.start - b[1] < 1.1) b[1] = l.end
|
| 1843 |
+
else blocks.push([l.start, l.end])
|
| 1844 |
+
}
|
| 1845 |
+
let bi = 0
|
| 1846 |
+
const target = (t: number) => {
|
| 1847 |
+
while (bi < blocks.length - 1 && t > blocks[bi][1] + 0.15) bi++
|
| 1848 |
+
const b = blocks[bi]
|
| 1849 |
+
const talking = t >= b[0] - 0.25 && t <= b[1] + 0.15
|
| 1850 |
+
const fade = t > dur - 4 ? Math.max(0, (dur - t) / 4) : 1
|
| 1851 |
+
const fadeIn = Math.min(1, t / 0.8)
|
| 1852 |
+
return (talking ? MUSIC_DUCK : 1) * fade * fadeIn * MUSIC_GAIN
|
| 1853 |
+
}
|
| 1854 |
+
const block = 128
|
| 1855 |
+
const dt = block / SR
|
| 1856 |
+
const ka = 1 - Math.exp(-dt / 0.12)
|
| 1857 |
+
const kr = 1 - Math.exp(-dt / 0.7)
|
| 1858 |
+
let g = target(0)
|
| 1859 |
+
return (chans: Float32Array[], n: number, offset: number) => {
|
| 1860 |
+
for (let i = 0; i < n; i += block) {
|
| 1861 |
+
const tg = target((offset + i) / SR)
|
| 1862 |
+
g += (tg - g) * (tg < g ? ka : kr)
|
| 1863 |
+
const end = Math.min(n, i + block)
|
| 1864 |
+
for (let c = 0; c < 2; c++) {
|
| 1865 |
+
const d = chans[c]
|
| 1866 |
+
for (let j = i; j < end; j++) d[j] *= g
|
| 1867 |
+
}
|
| 1868 |
+
}
|
| 1869 |
+
}
|
| 1870 |
+
}
|
| 1871 |
+
|
| 1872 |
+
/** Remotion 版:流式渲染两条音轨(旁白+音效 / 背景音乐),直接输出 WAV */
|
| 1873 |
+
export async function buildStemWavs(tl: Timeline, vo: AudioBuffer[], onProgress?: (p: number) => void): Promise<{ main: Blob; music: Blob }> {
|
| 1874 |
+
const segs = Math.ceil(tl.duration / 8) + Math.ceil(tl.duration / 6)
|
| 1875 |
+
let done = 0
|
| 1876 |
+
const tick = () => onProgress?.(Math.min(1, ++done / segs))
|
| 1877 |
+
// 先渲染配乐并记下它的峰值包络,主轨限幅时把配乐一起算进去
|
| 1878 |
+
const pk: { blk: number; out?: Float32Array } = { blk: PK_BLK }
|
| 1879 |
+
const music = await renderEventsStream(
|
| 1880 |
+
tl.duration,
|
| 1881 |
+
musicEvents(tl),
|
| 1882 |
+
{ seg: 6, tail: 5, room: 0.88, verbGain: 0.4, delayTime: (60 / 84) * 0.75, delayFb: 0.34, delayGain: 0.4 },
|
| 1883 |
+
musicEnvelope(tl),
|
| 1884 |
+
0.9,
|
| 1885 |
+
tick,
|
| 1886 |
+
pk,
|
| 1887 |
+
)
|
| 1888 |
+
const master = mainMaster(pk.out)
|
| 1889 |
+
const main = await renderEventsStream(tl.duration, sfxEvents(tl, vo), { seg: 8, tail: 11.5, room: 0.84, verbGain: 0.3 }, master, 1, tick)
|
| 1890 |
+
;(globalThis as { __kkMaster?: unknown }).__kkMaster = master.stats()
|
| 1891 |
+
return { main, music }
|
| 1892 |
+
}
|
| 1893 |
+
|
| 1894 |
+
/** 混合成导出用的平面数组 */
|
| 1895 |
+
export function mixdown(stems: Stems, withMusic: boolean, musicGain = 1): Float32Array[] {
|
| 1896 |
+
const len = stems.main.length
|
| 1897 |
+
const outs: Float32Array[] = []
|
| 1898 |
+
for (let ch = 0; ch < 2; ch++) {
|
| 1899 |
+
const m = stems.main.getChannelData(ch)
|
| 1900 |
+
const o = new Float32Array(len)
|
| 1901 |
+
if (withMusic) {
|
| 1902 |
+
const mu = stems.music.getChannelData(ch)
|
| 1903 |
+
for (let i = 0; i < len; i++) {
|
| 1904 |
+
const v = m[i] + mu[i] * musicGain
|
| 1905 |
+
o[i] = v > 1 ? 1 : v < -1 ? -1 : v
|
| 1906 |
+
}
|
| 1907 |
+
} else o.set(m)
|
| 1908 |
+
outs.push(o)
|
| 1909 |
+
}
|
| 1910 |
+
return outs
|
| 1911 |
+
}
|
kkndme/frontend/src/video/clawd.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Claude 吉祥物(像素小螃蟹 Clawd)的几何数据:视频(SVG)与封面(Canvas)共用
|
| 2 |
+
export const CLAWD_ORANGE = '#D97757'
|
| 3 |
+
export const CLAWD_W = 16
|
| 4 |
+
export const CLAWD_H = 8.8
|
| 5 |
+
|
| 6 |
+
export interface Px {
|
| 7 |
+
x: number
|
| 8 |
+
y: number
|
| 9 |
+
w: number
|
| 10 |
+
h: number
|
| 11 |
+
c: string
|
| 12 |
+
/** 部位:用于做动画 */
|
| 13 |
+
part: 'body' | 'arm' | 'eye' | 'leg' | 'hi'
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
const O = CLAWD_ORANGE
|
| 17 |
+
const DARK = '#1B1410'
|
| 18 |
+
export const CLAWD_PX: Px[] = [
|
| 19 |
+
{ x: 2, y: 0, w: 12, h: 6.2, c: O, part: 'body' },
|
| 20 |
+
{ x: 2, y: 0, w: 12, h: 0.7, c: '#E8946F', part: 'hi' },
|
| 21 |
+
{ x: 0, y: 2.2, w: 2.2, h: 2.2, c: O, part: 'arm' },
|
| 22 |
+
{ x: 13.8, y: 2.2, w: 2.2, h: 2.2, c: O, part: 'arm' },
|
| 23 |
+
{ x: 4.6, y: 1.7, w: 1.3, h: 2.3, c: DARK, part: 'eye' },
|
| 24 |
+
{ x: 10.1, y: 1.7, w: 1.3, h: 2.3, c: DARK, part: 'eye' },
|
| 25 |
+
{ x: 3.1, y: 6, w: 1.4, h: 2.8, c: O, part: 'leg' },
|
| 26 |
+
{ x: 5.5, y: 6, w: 1.4, h: 2.8, c: O, part: 'leg' },
|
| 27 |
+
{ x: 9.1, y: 6, w: 1.4, h: 2.8, c: O, part: 'leg' },
|
| 28 |
+
{ x: 11.5, y: 6, w: 1.4, h: 2.8, c: O, part: 'leg' },
|
| 29 |
+
]
|
| 30 |
+
|
| 31 |
+
/** 主持人照片里“托举的手掌”位置(占图片宽高的比例),吉祥物站在这里 */
|
| 32 |
+
export const HOST_IMG = { w: 783, h: 1044, palmX: 0.5, palmY: 0.708, mascotW: 0.25 }
|
| 33 |
+
|
| 34 |
+
/** Claude 星芒标志(8 道光) */
|
| 35 |
+
export function burstPath(cx: number, cy: number, r: number) {
|
| 36 |
+
const pts: string[] = []
|
| 37 |
+
for (let i = 0; i < 8; i++) {
|
| 38 |
+
const a = (i / 8) * Math.PI * 2 - Math.PI / 2
|
| 39 |
+
const b = a + Math.PI / 8
|
| 40 |
+
pts.push(`${(cx + Math.cos(a) * r).toFixed(2)},${(cy + Math.sin(a) * r).toFixed(2)}`)
|
| 41 |
+
pts.push(`${(cx + Math.cos(b) * r * 0.32).toFixed(2)},${(cy + Math.sin(b) * r * 0.32).toFixed(2)}`)
|
| 42 |
+
}
|
| 43 |
+
return `M${pts.join('L')}Z`
|
| 44 |
+
}
|
kkndme/frontend/src/video/covers.ts
ADDED
|
@@ -0,0 +1,468 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { C, STATUS_COLOR, T, background, finish, hexA, rr, dot, line, checkMark, crossMark, measure, setFont, type Ctx } from './draw'
|
| 2 |
+
import { rows, all, weighted } from '../data/science'
|
| 3 |
+
import { CLAWD_PX, CLAWD_W, CLAWD_H, CLAWD_ORANGE, HOST_IMG, burstPath } from './clawd'
|
| 4 |
+
|
| 5 |
+
export type Ratio = '16:9' | '4:3' | '3:4'
|
| 6 |
+
export const RATIO_SIZE: Record<Ratio, [number, number]> = { '16:9': [1920, 1080], '4:3': [1440, 1080], '3:4': [1080, 1440] }
|
| 7 |
+
|
| 8 |
+
export interface CoverDef {
|
| 9 |
+
id: string
|
| 10 |
+
name: string
|
| 11 |
+
draw: (c: Ctx, W: number, H: number) => void
|
| 12 |
+
/** 绘制前需要准备的资源(例如图片) */
|
| 13 |
+
prepare?: () => Promise<void>
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
const ORDER = ['correct', 'wrong', 'disputed', 'pending_lean', 'pending_against', 'pending_neutral']
|
| 17 |
+
const sorted = [...rows].sort((a, b) => ORDER.indexOf(a.status) - ORDER.indexOf(b.status))
|
| 18 |
+
|
| 19 |
+
function brand(c: Ctx, W: number, H: number, s: number) {
|
| 20 |
+
const m = 70 * s
|
| 21 |
+
c.fillStyle = C.gold
|
| 22 |
+
c.fillRect(m, m - 6 * s, 8 * s, 30 * s)
|
| 23 |
+
T(c, 'kkndme 神贴 · 十五年对账', m + 24 * s, m + 20 * s, { size: 28 * s, w: 700, color: C.ink, ls: 4 * s, a: 0.9 })
|
| 24 |
+
T(c, '2010 → 2026', W - m, m + 20 * s, { size: 26 * s, w: 700, color: C.mute, align: 'right', ls: 3 * s })
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
function frame(c: Ctx, W: number, H: number, accent = C.gold) {
|
| 28 |
+
background(c, W, H, 12, accent, 1)
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function fitSize(c: Ctx, s: string, maxW: number, size: number, w = 900, f: 'serif' | 'sans' = 'serif') {
|
| 32 |
+
const m = measure(c, s, size, w, f)
|
| 33 |
+
return m > maxW ? (size * maxW) / m : size
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/** 成绩单:63% 划掉 → 55 分 */
|
| 37 |
+
const scoreCard: CoverDef = {
|
| 38 |
+
id: 'score',
|
| 39 |
+
name: '成绩单',
|
| 40 |
+
draw(c, W, H) {
|
| 41 |
+
frame(c, W, H)
|
| 42 |
+
const s = Math.min(W, H) / 1080
|
| 43 |
+
const wide = W / H > 1.5
|
| 44 |
+
const port = H > W
|
| 45 |
+
brand(c, W, H, s)
|
| 46 |
+
const x = wide ? W * 0.07 : W * 0.08
|
| 47 |
+
// 标题
|
| 48 |
+
const t1 = '房地产圣经'
|
| 49 |
+
const t2 = '到底说对了多少?'
|
| 50 |
+
const ty = port ? H * 0.2 : H * 0.3
|
| 51 |
+
const ts = fitSize(c, t2, wide ? W * 0.5 : W * 0.84, (port ? 120 : 112) * s)
|
| 52 |
+
T(c, t1, x, ty, { size: ts * 0.62, w: 900, f: 'serif', color: C.goldHi, ls: 6 * s })
|
| 53 |
+
T(c, t2, x, ty + ts * 1.15, { size: ts, w: 900, f: 'serif' })
|
| 54 |
+
// 分数
|
| 55 |
+
const cx = wide ? W * 0.77 : W * 0.5
|
| 56 |
+
const cy = wide ? H * 0.52 : port ? H * 0.6 : H * 0.66
|
| 57 |
+
const raw = `${Math.round(all.hit * 100)}%`
|
| 58 |
+
const fin = `${Math.round(weighted * 100)}`
|
| 59 |
+
const rs = (wide ? 150 : port ? 150 : 120) * s
|
| 60 |
+
const rx = wide ? cx : cx - 220 * s
|
| 61 |
+
const ry = wide ? cy - 170 * s : cy
|
| 62 |
+
T(c, raw, rx, ry, { size: rs, w: 900, f: 'serif', color: C.mute, align: 'center' })
|
| 63 |
+
const rw = measure(c, raw, rs, 900, 'serif')
|
| 64 |
+
line(c, rx - rw / 2 - 10 * s, ry - rs * 0.25, rx + rw / 2 + 10 * s, ry - rs * 0.42, C.red, 9 * s)
|
| 65 |
+
T(c, '原始命中率', rx, ry + 50 * s, { size: 26 * s, w: 500, color: C.dim, align: 'center' })
|
| 66 |
+
const fx = wide ? cx : cx + 200 * s
|
| 67 |
+
const fy = wide ? cy + 230 * s : cy + 20 * s
|
| 68 |
+
const fs = (wide ? 260 : port ? 250 : 220) * s
|
| 69 |
+
const grd = c.createLinearGradient(0, fy - fs, 0, fy)
|
| 70 |
+
grd.addColorStop(0, C.goldHi)
|
| 71 |
+
grd.addColorStop(1, C.gold)
|
| 72 |
+
T(c, fin, fx, fy, { size: fs, w: 900, f: 'serif', color: grd as unknown as string, align: 'center' })
|
| 73 |
+
T(c, '分', fx + measure(c, fin, fs, 900, 'serif') / 2 + 40 * s, fy - 10 * s, { size: 60 * s, w: 900, f: 'serif', color: C.gold, align: 'center' })
|
| 74 |
+
T(c, '难度加权后的真实得分', fx, fy + 56 * s, { size: 28 * s, w: 700, color: C.ink, align: 'center' })
|
| 75 |
+
// 底部
|
| 76 |
+
const by = H - 90 * s
|
| 77 |
+
T(c, `123 条预测 · 逐条核对 · 截至 2026.10`, x, by, { size: 30 * s, w: 500, color: C.mute, ls: 2 * s })
|
| 78 |
+
finish(c, W, H, 3)
|
| 79 |
+
},
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/** 点阵:123 个点 */
|
| 83 |
+
const dotsCard: CoverDef = {
|
| 84 |
+
id: 'dots',
|
| 85 |
+
name: '123 点阵',
|
| 86 |
+
draw(c, W, H) {
|
| 87 |
+
frame(c, W, H)
|
| 88 |
+
const s = Math.min(W, H) / 1080
|
| 89 |
+
const port = H > W
|
| 90 |
+
brand(c, W, H, s)
|
| 91 |
+
const cols = port ? 12 : W / H > 1.5 ? 21 : 16
|
| 92 |
+
const gw = W * (port ? 0.8 : 0.84)
|
| 93 |
+
const sp = gw / cols
|
| 94 |
+
const rowsN = Math.ceil(sorted.length / cols)
|
| 95 |
+
const x0 = W / 2 - ((cols - 1) * sp) / 2
|
| 96 |
+
const gy = port ? H * 0.5 : H * 0.58
|
| 97 |
+
const y0 = gy - ((rowsN - 1) * sp) / 2
|
| 98 |
+
sorted.forEach((r, i) => {
|
| 99 |
+
dot(c, x0 + (i % cols) * sp, y0 + Math.floor(i / cols) * sp, sp * 0.3, STATUS_COLOR[r.status])
|
| 100 |
+
})
|
| 101 |
+
const ty = port ? H * 0.17 : H * 0.2
|
| 102 |
+
const head = 'kkndme 的 123 条预测'
|
| 103 |
+
const hs = fitSize(c, head, W * 0.84, (port ? 110 : 100) * s)
|
| 104 |
+
T(c, head, W / 2, ty, { size: hs, w: 900, f: 'serif', align: 'center' })
|
| 105 |
+
// 图例 + 数字
|
| 106 |
+
const items = [
|
| 107 |
+
{ l: '说对', n: all.correct, col: C.green },
|
| 108 |
+
{ l: '说错', n: all.wrong, col: C.red },
|
| 109 |
+
{ l: '存疑', n: all.disputed, col: C.amber },
|
| 110 |
+
{ l: '未到期', n: 10, col: C.blue },
|
| 111 |
+
]
|
| 112 |
+
const ly = y0 + (rowsN - 1) * sp + (port ? 170 : 120) * s
|
| 113 |
+
const lw = (port ? 240 : W / H > 1.5 ? 300 : 280) * s
|
| 114 |
+
items.forEach((it, k) => {
|
| 115 |
+
const lx = W / 2 + (k - 1.5) * lw
|
| 116 |
+
T(c, `${it.n}`, lx, ly, { size: 76 * s, w: 900, f: 'serif', color: it.col, align: 'center' })
|
| 117 |
+
T(c, it.l, lx, ly + 44 * s, { size: 28 * s, w: 700, color: C.ink, align: 'center' })
|
| 118 |
+
})
|
| 119 |
+
finish(c, W, H, 5)
|
| 120 |
+
},
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
/** 金句 */
|
| 124 |
+
const quoteCard: CoverDef = {
|
| 125 |
+
id: 'quote',
|
| 126 |
+
name: '金句',
|
| 127 |
+
draw(c, W, H) {
|
| 128 |
+
frame(c, W, H)
|
| 129 |
+
const s = Math.min(W, H) / 1080
|
| 130 |
+
const port = H > W
|
| 131 |
+
brand(c, W, H, s)
|
| 132 |
+
const g = c.createRadialGradient(W / 2, H * 0.46, 0, W / 2, H * 0.46, Math.max(W, H) * 0.5)
|
| 133 |
+
g.addColorStop(0, 'rgba(216,178,110,0.16)')
|
| 134 |
+
g.addColorStop(1, 'rgba(216,178,110,0)')
|
| 135 |
+
c.fillStyle = g
|
| 136 |
+
c.fillRect(0, 0, W, H)
|
| 137 |
+
const l1 = '看对方向容易,'
|
| 138 |
+
const l2 = '算准时间很难。'
|
| 139 |
+
const size = fitSize(c, l1, W * 0.82, (port ? 150 : 150) * s)
|
| 140 |
+
const cy = H * (port ? 0.44 : 0.46)
|
| 141 |
+
T(c, '“', W / 2 - measure(c, l1, size, 900, 'serif') / 2 - 10 * s, cy - size * 0.95, { size: size * 1.2, w: 900, f: 'serif', color: C.gold, a: 0.6 })
|
| 142 |
+
T(c, l1, W / 2, cy, { size, w: 900, f: 'serif', align: 'center' })
|
| 143 |
+
T(c, l2, W / 2, cy + size * 1.3, { size, w: 900, f: 'serif', color: C.goldHi, align: 'center' })
|
| 144 |
+
line(c, W / 2 - 160 * s, cy + size * 1.95, W / 2 + 160 * s, cy + size * 1.95, C.gold, 2 * s)
|
| 145 |
+
T(c, '天涯 kkndme 神贴 · 15 年后逐条对账', W / 2, cy + size * 1.95 + 80 * s, { size: 40 * s, w: 700, align: 'center', color: C.ink, ls: 4 * s })
|
| 146 |
+
T(c, `说对 ${all.correct} · 说错 ${all.wrong} · 存疑 ${all.disputed} · 未到期 10`, W / 2, cy + size * 1.95 + 140 * s, { size: 30 * s, w: 500, align: 'center', color: C.mute })
|
| 147 |
+
finish(c, W, H, 7)
|
| 148 |
+
},
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
/** 他说 vs 现实 */
|
| 152 |
+
const versusCard: CoverDef = {
|
| 153 |
+
id: 'versus',
|
| 154 |
+
name: '他说 vs 现实',
|
| 155 |
+
draw(c, W, H) {
|
| 156 |
+
frame(c, W, H)
|
| 157 |
+
const s = Math.min(W, H) / 1080
|
| 158 |
+
const port = H > W
|
| 159 |
+
const wide = W / H > 1.5
|
| 160 |
+
brand(c, W, H, s)
|
| 161 |
+
const head = '他说的,成真了吗?'
|
| 162 |
+
const hs = fitSize(c, head, W * 0.86, (port ? 110 : 96) * s)
|
| 163 |
+
T(c, head, W / 2, H * (port ? 0.16 : 0.2), { size: hs, w: 900, f: 'serif', align: 'center' })
|
| 164 |
+
const items = [
|
| 165 |
+
{ said: '房价跌不回 2004 年', real: '2025 年均价仍是 3.8 倍', ok: true },
|
| 166 |
+
{ said: '人民币到不了 4 : 1', real: '最高只到 6.04', ok: true },
|
| 167 |
+
{ said: '房租会暴涨', real: '50 城租金连跌三年', ok: false },
|
| 168 |
+
{ said: '物价再涨 20 倍', real: '十年只涨 28%', ok: false },
|
| 169 |
+
]
|
| 170 |
+
const cw = W * (wide ? 0.4 : port ? 0.84 : 0.42)
|
| 171 |
+
const ch = (port ? 210 : wide ? 230 : 250) * s
|
| 172 |
+
const gap = 28 * s
|
| 173 |
+
const colsN = port ? 1 : 2
|
| 174 |
+
const totalW = colsN * cw + (colsN - 1) * gap
|
| 175 |
+
const x0 = W / 2 - totalW / 2
|
| 176 |
+
const y0 = H * (port ? 0.24 : 0.3)
|
| 177 |
+
items.forEach((it, k) => {
|
| 178 |
+
const col = port ? 0 : k % 2
|
| 179 |
+
const row = port ? k : Math.floor(k / 2)
|
| 180 |
+
const x = x0 + col * (cw + gap)
|
| 181 |
+
const y = y0 + row * (ch + gap)
|
| 182 |
+
const color = it.ok ? C.green : C.red
|
| 183 |
+
rr(c, x, y, cw, ch, 20 * s)
|
| 184 |
+
c.fillStyle = hexA(color, 0.08)
|
| 185 |
+
c.fill()
|
| 186 |
+
c.strokeStyle = hexA(color, 0.55)
|
| 187 |
+
c.lineWidth = 2 * s
|
| 188 |
+
c.stroke()
|
| 189 |
+
const ix = x + 64 * s
|
| 190 |
+
const iy = y + ch / 2
|
| 191 |
+
if (it.ok) checkMark(c, ix, iy, 34 * s, color, 1, 7 * s)
|
| 192 |
+
else crossMark(c, ix, iy, 34 * s, color, 1, 7 * s)
|
| 193 |
+
const tx = x + 120 * s
|
| 194 |
+
const maxW = cw - 150 * s
|
| 195 |
+
T(c, '他说', tx, y + ch * 0.3, { size: 24 * s, w: 500, color: C.mute })
|
| 196 |
+
T(c, it.said, tx, y + ch * 0.53, { size: fitSize(c, it.said, maxW, 46 * s, 900), w: 900, f: 'serif' })
|
| 197 |
+
T(c, `现实:${it.real}`, tx, y + ch * 0.82, { size: fitSize(c, `现实:${it.real}`, maxW, 30 * s, 700, 'sans'), w: 700, color })
|
| 198 |
+
})
|
| 199 |
+
const by = H - (port ? 110 : 80) * s
|
| 200 |
+
T(c, `123 条预测 · 说对 ${all.correct} · 说错 ${all.wrong}`, W / 2, by, { size: 30 * s, w: 500, color: C.mute, align: 'center' })
|
| 201 |
+
finish(c, W, H, 9)
|
| 202 |
+
},
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
/** 年份大字 */
|
| 206 |
+
const yearCard: CoverDef = {
|
| 207 |
+
id: 'year',
|
| 208 |
+
name: '十五年',
|
| 209 |
+
draw(c, W, H) {
|
| 210 |
+
frame(c, W, H)
|
| 211 |
+
const s = Math.min(W, H) / 1080
|
| 212 |
+
const port = H > W
|
| 213 |
+
brand(c, W, H, s)
|
| 214 |
+
const ys = (port ? 300 : 280) * s
|
| 215 |
+
const cy = H * (port ? 0.42 : 0.5)
|
| 216 |
+
const grd = c.createLinearGradient(0, cy - ys, 0, cy)
|
| 217 |
+
grd.addColorStop(0, C.goldHi)
|
| 218 |
+
grd.addColorStop(1, hexA(C.gold, 0.6))
|
| 219 |
+
if (port) {
|
| 220 |
+
T(c, '2010', W / 2, cy - ys * 0.55, { size: ys, w: 900, f: 'serif', color: C.mute, align: 'center' })
|
| 221 |
+
T(c, '2026', W / 2, cy + ys * 0.55, { size: ys, w: 900, f: 'serif', color: grd as unknown as string, align: 'center' })
|
| 222 |
+
} else {
|
| 223 |
+
T(c, '2010', W * 0.28, cy, { size: ys, w: 900, f: 'serif', color: C.mute, align: 'center' })
|
| 224 |
+
T(c, '2026', W * 0.72, cy, { size: ys, w: 900, f: 'serif', color: grd as unknown as string, align: 'center' })
|
| 225 |
+
line(c, W * 0.47, cy - ys * 0.33, W * 0.53, cy - ys * 0.33, C.gold, 4 * s)
|
| 226 |
+
}
|
| 227 |
+
const t = 'kkndme 神贴,十五年后对账'
|
| 228 |
+
const ts = fitSize(c, t, W * 0.84, 92 * s)
|
| 229 |
+
const ty = port ? H * 0.78 : H * 0.78
|
| 230 |
+
T(c, t, W / 2, ty, { size: ts, w: 900, f: 'serif', align: 'center' })
|
| 231 |
+
T(c, '123 条预测 · 6 种算法 · 一份不吹不黑的成绩单', W / 2, ty + 70 * s, { size: fitSize(c, '123 条预测 · 6 种算法 · 一份不吹不黑的成绩单', W * 0.84, 32 * s, 500, 'sans'), w: 500, align: 'center', color: C.mute })
|
| 232 |
+
finish(c, W, H, 11)
|
| 233 |
+
},
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
// ---------- 主持人露脸封面:手托 Claude 吉祥物 Opus 5.5 ----------
|
| 237 |
+
let hostImg: HTMLImageElement | null = null
|
| 238 |
+
function loadImg(src: string) {
|
| 239 |
+
return new Promise<HTMLImageElement>((res, rej) => {
|
| 240 |
+
const im = new Image()
|
| 241 |
+
im.onload = () => res(im)
|
| 242 |
+
im.onerror = () => rej(new Error('图片加载失败'))
|
| 243 |
+
im.src = src
|
| 244 |
+
})
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
function drawClawd(c: Ctx, x: number, y: number, w: number) {
|
| 248 |
+
const u = w / CLAWD_W
|
| 249 |
+
for (const p of CLAWD_PX) {
|
| 250 |
+
c.fillStyle = p.c
|
| 251 |
+
c.fillRect(Math.round(x + p.x * u), Math.round(y + p.y * u), Math.ceil(p.w * u), Math.ceil(p.h * u))
|
| 252 |
+
}
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
function nameTag(c: Ctx, cx: number, bottom: number, size: number) {
|
| 256 |
+
setFont(c, size, 800)
|
| 257 |
+
const tw = c.measureText('Opus 5.5').width
|
| 258 |
+
const bs = size * 0.9
|
| 259 |
+
const padL = size * 0.42
|
| 260 |
+
const padR = size * 0.55
|
| 261 |
+
const gap = size * 0.3
|
| 262 |
+
const w = padL + bs + gap + tw + padR
|
| 263 |
+
const h = size * 1.55
|
| 264 |
+
const tri = size * 0.42
|
| 265 |
+
const x = cx - w / 2
|
| 266 |
+
const y = bottom - tri - h
|
| 267 |
+
c.save()
|
| 268 |
+
c.shadowColor = hexA(CLAWD_ORANGE, 0.5)
|
| 269 |
+
c.shadowBlur = size
|
| 270 |
+
rr(c, x, y, w, h, h / 2)
|
| 271 |
+
c.fillStyle = '#141110'
|
| 272 |
+
c.fill()
|
| 273 |
+
c.restore()
|
| 274 |
+
rr(c, x, y, w, h, h / 2)
|
| 275 |
+
c.lineWidth = Math.max(2, size * 0.08)
|
| 276 |
+
c.strokeStyle = CLAWD_ORANGE
|
| 277 |
+
c.stroke()
|
| 278 |
+
c.beginPath()
|
| 279 |
+
c.moveTo(cx - tri * 0.9, y + h - 1)
|
| 280 |
+
c.lineTo(cx, y + h + tri)
|
| 281 |
+
c.lineTo(cx + tri * 0.9, y + h - 1)
|
| 282 |
+
c.closePath()
|
| 283 |
+
c.fillStyle = CLAWD_ORANGE
|
| 284 |
+
c.fill()
|
| 285 |
+
c.save()
|
| 286 |
+
c.translate(x + padL, y + (h - bs) / 2)
|
| 287 |
+
c.scale(bs / 20, bs / 20)
|
| 288 |
+
c.fillStyle = CLAWD_ORANGE
|
| 289 |
+
c.fill(new Path2D(burstPath(10, 10, 10)))
|
| 290 |
+
c.restore()
|
| 291 |
+
T(c, 'Opus 5.5', x + padL + bs + gap, y + h / 2, { size, w: 800, color: '#FFF6EE', base: 'middle', align: 'left' })
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
function hostWithMascot(c: Ctx, x: number, y: number, h: number) {
|
| 295 |
+
if (!hostImg) return
|
| 296 |
+
const w = (h * HOST_IMG.w) / HOST_IMG.h
|
| 297 |
+
const mw = w * HOST_IMG.mascotW
|
| 298 |
+
const mh = (mw * CLAWD_H) / CLAWD_W
|
| 299 |
+
const px = x + w * HOST_IMG.palmX
|
| 300 |
+
const py = y + h * HOST_IMG.palmY
|
| 301 |
+
const g = c.createRadialGradient(px, py - mh, 0, px, py - mh, mw * 1.3)
|
| 302 |
+
g.addColorStop(0, hexA(CLAWD_ORANGE, 0.3))
|
| 303 |
+
g.addColorStop(1, hexA(CLAWD_ORANGE, 0))
|
| 304 |
+
c.fillStyle = g
|
| 305 |
+
c.fillRect(px - mw * 1.4, py - mh - mw * 1.4, mw * 2.8, mw * 2.8)
|
| 306 |
+
c.drawImage(hostImg, x, y, w, h)
|
| 307 |
+
c.save()
|
| 308 |
+
c.filter = 'blur(4px)'
|
| 309 |
+
c.fillStyle = 'rgba(40,20,10,0.35)'
|
| 310 |
+
c.beginPath()
|
| 311 |
+
c.ellipse(px, py + mh * 0.01, mw * 0.42, mh * 0.08, 0, 0, Math.PI * 2)
|
| 312 |
+
c.fill()
|
| 313 |
+
c.restore()
|
| 314 |
+
drawClawd(c, px - mw / 2, py - mh + mh * 0.02, mw)
|
| 315 |
+
nameTag(c, px, py - mh - mw * 0.06, mw * 0.15)
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
function goldFill(c: Ctx, s: string, x: number, y: number, size: number, align: CanvasTextAlign = 'left') {
|
| 319 |
+
const g = c.createLinearGradient(0, y - size, 0, y)
|
| 320 |
+
g.addColorStop(0, '#FFF1CF')
|
| 321 |
+
g.addColorStop(0.4, C.goldHi)
|
| 322 |
+
g.addColorStop(0.75, C.gold)
|
| 323 |
+
g.addColorStop(1, '#A88346')
|
| 324 |
+
T(c, s, x, y, { size, w: 900, f: 'serif', color: g, align })
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
const hostCard: CoverDef = {
|
| 328 |
+
id: 'host',
|
| 329 |
+
name: '露脸封面',
|
| 330 |
+
async prepare() {
|
| 331 |
+
if (!hostImg) hostImg = await loadImg(`${import.meta.env.BASE_URL}brand/host.png`)
|
| 332 |
+
},
|
| 333 |
+
draw(c, W, H) {
|
| 334 |
+
frame(c, W, H)
|
| 335 |
+
const port = H > W
|
| 336 |
+
const wide = W / H > 1.5
|
| 337 |
+
const s = Math.min(W, H) / 1080
|
| 338 |
+
// 人像后的暖光
|
| 339 |
+
const hx = port ? W / 2 : W * (wide ? 0.78 : 0.75)
|
| 340 |
+
const g = c.createRadialGradient(hx, H * 0.6, 0, hx, H * 0.6, Math.max(W, H) * 0.5)
|
| 341 |
+
g.addColorStop(0, hexA(C.gold, 0.2))
|
| 342 |
+
g.addColorStop(1, hexA(C.gold, 0))
|
| 343 |
+
c.fillStyle = g
|
| 344 |
+
c.fillRect(0, 0, W, H)
|
| 345 |
+
c.strokeStyle = hexA(C.gold, 0.22)
|
| 346 |
+
c.lineWidth = 1.5
|
| 347 |
+
rr(c, 34 * s, 34 * s, W - 68 * s, H - 68 * s, 18 * s)
|
| 348 |
+
c.stroke()
|
| 349 |
+
// 人像
|
| 350 |
+
const hostH = port ? H * 0.55 : wide ? H * 0.963 : H * 0.86
|
| 351 |
+
const hostW = (hostH * HOST_IMG.w) / HOST_IMG.h
|
| 352 |
+
const hostX = port ? (W - hostW) / 2 : W - hostW - (wide ? 30 : 0) * s
|
| 353 |
+
const hostY = H - hostH + 20 * s
|
| 354 |
+
hostWithMascot(c, hostX, hostY, hostH)
|
| 355 |
+
// 文字
|
| 356 |
+
const L = port ? W / 2 : (wide ? 130 : 84) * s
|
| 357 |
+
const maxW = port ? W * 0.86 : hostX - L - 20 * s
|
| 358 |
+
const lab = '天涯神贴 · 房地产圣经 · 十五年对账'
|
| 359 |
+
c.fillStyle = C.gold
|
| 360 |
+
const bx = port ? W / 2 - measure(c, lab, 30 * s, 700) / 2 - 24 * s : L
|
| 361 |
+
c.fillRect(bx, 104 * s, 8 * s, 32 * s)
|
| 362 |
+
T(c, lab, bx + 24 * s, 130 * s, { size: 30 * s, w: 700, color: 'rgba(243,238,228,0.82)', ls: 4 * s })
|
| 363 |
+
// KKndme + “KK大神”印章
|
| 364 |
+
let k1 = (port ? 176 : 206) * s
|
| 365 |
+
const stampF = (port ? 56 : 62) * s
|
| 366 |
+
const gapK = (port ? 26 : 34) * s
|
| 367 |
+
const stampW = measure(c, 'KK大神', stampF, 900, 'serif') + 44 * s
|
| 368 |
+
const kkW = () => measure(c, 'KK', k1, 900, 'serif') + measure(c, 'ndme', k1 * 0.75, 900, 'serif')
|
| 369 |
+
const fit = maxW / (kkW() + gapK + stampW)
|
| 370 |
+
if (fit < 1) k1 *= fit
|
| 371 |
+
const sc = Math.min(1, fit)
|
| 372 |
+
const rowW = kkW() + (gapK + stampW) * sc
|
| 373 |
+
const kx = port ? W / 2 - rowW / 2 : L
|
| 374 |
+
const ky = (port ? 300 : 365) * s
|
| 375 |
+
c.save()
|
| 376 |
+
c.shadowColor = hexA(C.gold, 0.4)
|
| 377 |
+
c.shadowBlur = 30 * s
|
| 378 |
+
const kg = c.createLinearGradient(0, ky - k1, 0, ky)
|
| 379 |
+
kg.addColorStop(0, '#FFF6DC')
|
| 380 |
+
kg.addColorStop(0.5, C.goldHi)
|
| 381 |
+
kg.addColorStop(1, C.gold)
|
| 382 |
+
T(c, 'KK', kx, ky, { size: k1, w: 900, f: 'serif', color: kg })
|
| 383 |
+
c.restore()
|
| 384 |
+
goldFill(c, 'ndme', kx + measure(c, 'KK', k1, 900, 'serif'), ky, k1 * 0.75)
|
| 385 |
+
{
|
| 386 |
+
const sw = stampW * sc
|
| 387 |
+
const sh = (stampF + 50 * s) * sc
|
| 388 |
+
const sx = kx + kkW() + gapK * sc + sw / 2
|
| 389 |
+
const sy = ky - k1 * 0.36
|
| 390 |
+
c.save()
|
| 391 |
+
c.translate(sx, sy)
|
| 392 |
+
c.rotate((-8 * Math.PI) / 180)
|
| 393 |
+
c.shadowColor = hexA(C.red, 0.5)
|
| 394 |
+
c.shadowBlur = 30 * s
|
| 395 |
+
rr(c, -sw / 2, -sh / 2, sw, sh, 14 * s * sc)
|
| 396 |
+
c.fillStyle = hexA(C.red, 0.1)
|
| 397 |
+
c.fill()
|
| 398 |
+
c.lineWidth = 5 * s * sc
|
| 399 |
+
c.strokeStyle = C.red
|
| 400 |
+
c.stroke()
|
| 401 |
+
c.restore()
|
| 402 |
+
c.save()
|
| 403 |
+
c.translate(sx, sy)
|
| 404 |
+
c.rotate((-8 * Math.PI) / 180)
|
| 405 |
+
T(c, 'KK大神', 0, stampF * 0.18 * sc, { size: stampF * sc, w: 900, f: 'serif', color: C.red, align: 'center', ls: 4 * s * sc })
|
| 406 |
+
T(c, '天涯 · 2010', 0, stampF * 0.18 * sc + 30 * s * sc, { size: 15 * s * sc, w: 700, color: C.red, align: 'center', ls: 3 * s * sc })
|
| 407 |
+
c.restore()
|
| 408 |
+
}
|
| 409 |
+
const t2a = '神贴到底'
|
| 410 |
+
const t2b = '说对了多少?'
|
| 411 |
+
const ts = fitSize(c, t2a + t2b, maxW, (port ? 80 : 90) * s)
|
| 412 |
+
const ty = ky + (port ? 100 : 130) * s
|
| 413 |
+
const tw2 = measure(c, t2a + t2b, ts, 900, 'serif')
|
| 414 |
+
const tx0 = port ? W / 2 - tw2 / 2 : L
|
| 415 |
+
T(c, t2a, tx0, ty, { size: ts, w: 900, f: 'serif' })
|
| 416 |
+
goldFill(c, t2b, tx0 + measure(c, t2a, ts, 900, 'serif'), ty, ts)
|
| 417 |
+
// 数字
|
| 418 |
+
const stats: [string, string, string][] = [
|
| 419 |
+
[String(rows.length), '条预测', C.ink],
|
| 420 |
+
[String(all.correct), '条说对', C.green],
|
| 421 |
+
[String(all.wrong), '条说错', C.red],
|
| 422 |
+
]
|
| 423 |
+
const ns = (port ? 72 : wide ? 92 : 72) * s
|
| 424 |
+
const ls = (port ? 28 : wide ? 30 : 26) * s
|
| 425 |
+
const gap = (port ? 44 : wide ? 60 : 40) * s
|
| 426 |
+
const widths = stats.map(([v, l]) => measure(c, v, ns, 800) + 8 * s + measure(c, l, ls, 700))
|
| 427 |
+
const tot = widths.reduce((a, b) => a + b, 0) + gap * 2
|
| 428 |
+
let sx0 = port ? W / 2 - tot / 2 : L
|
| 429 |
+
const sy0 = ty + (port ? 96 : 140) * s
|
| 430 |
+
stats.forEach(([v, l, col], i) => {
|
| 431 |
+
T(c, v, sx0, sy0, { size: ns, w: 800, color: col })
|
| 432 |
+
T(c, l, sx0 + measure(c, v, ns, 800) + 8 * s, sy0, { size: ls, w: 700, color: C.mute })
|
| 433 |
+
sx0 += widths[i] + gap
|
| 434 |
+
})
|
| 435 |
+
// Claude 卡片
|
| 436 |
+
const l1a = '我用 '
|
| 437 |
+
const l1b = 'Claude Opus 5.5'
|
| 438 |
+
const l1c = ' 通读'
|
| 439 |
+
const l2 = '2 份文件 · 986 页 · 约 54 万字'
|
| 440 |
+
const f1 = (port ? 30 : wide ? 36 : 30) * s
|
| 441 |
+
const f2 = (port ? 24 : wide ? 28 : 24) * s
|
| 442 |
+
const iw = (port ? 70 : wide ? 92 : 76) * s
|
| 443 |
+
const w1 = measure(c, l1a + l1b + l1c, f1, 800)
|
| 444 |
+
const w2 = measure(c, l2, f2, 600)
|
| 445 |
+
const pad = (port ? 26 : 32) * s
|
| 446 |
+
const cw = pad * 2 + iw + 22 * s + Math.max(w1, w2)
|
| 447 |
+
const chh = (port ? 100 : wide ? 128 : 110) * s
|
| 448 |
+
const cx = port ? W / 2 - cw / 2 : L
|
| 449 |
+
const cy = sy0 + (port ? 36 : 70) * s
|
| 450 |
+
rr(c, cx, cy, cw, chh, 22 * s)
|
| 451 |
+
const cg = c.createLinearGradient(cx, cy, cx + cw, cy + chh)
|
| 452 |
+
cg.addColorStop(0, 'rgba(217,119,87,0.18)')
|
| 453 |
+
cg.addColorStop(1, 'rgba(255,255,255,0.03)')
|
| 454 |
+
c.fillStyle = cg
|
| 455 |
+
c.fill()
|
| 456 |
+
c.lineWidth = 1.5 * s
|
| 457 |
+
c.strokeStyle = hexA(CLAWD_ORANGE, 0.55)
|
| 458 |
+
c.stroke()
|
| 459 |
+
drawClawd(c, cx + pad, cy + (chh - (iw * CLAWD_H) / CLAWD_W) / 2, iw)
|
| 460 |
+
const tx = cx + pad + iw + 22 * s
|
| 461 |
+
T(c, l1a, tx, cy + chh * 0.45, { size: f1, w: 800 })
|
| 462 |
+
T(c, l1b, tx + measure(c, l1a, f1, 800), cy + chh * 0.45, { size: f1, w: 800, color: '#F3A283' })
|
| 463 |
+
T(c, l1c, tx + measure(c, l1a + l1b, f1, 800), cy + chh * 0.45, { size: f1, w: 800 })
|
| 464 |
+
T(c, l2, tx, cy + chh * 0.8, { size: f2, w: 600, color: 'rgba(243,238,228,0.82)' })
|
| 465 |
+
},
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
export const COVERS: Cover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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// 画布绘制工具:调色板、缓动、文字、背景质感
|
| 2 |
+
export const SERIF = '"KKSerif", "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif'
|
| 3 |
+
export const SANS = '"KKSans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif'
|
| 4 |
+
|
| 5 |
+
export const C = {
|
| 6 |
+
bg: '#07080C',
|
| 7 |
+
ink: '#F3EEE4',
|
| 8 |
+
mute: 'rgba(243,238,228,0.58)',
|
| 9 |
+
dim: 'rgba(243,238,228,0.32)',
|
| 10 |
+
faint: 'rgba(243,238,228,0.12)',
|
| 11 |
+
hair: 'rgba(243,238,228,0.07)',
|
| 12 |
+
gold: '#D8B26E',
|
| 13 |
+
goldHi: '#F4DDA8',
|
| 14 |
+
green: '#4CC38A',
|
| 15 |
+
red: '#EA6A5F',
|
| 16 |
+
amber: '#D9A441',
|
| 17 |
+
blue: '#6E9BF5',
|
| 18 |
+
purple: '#B08AE6',
|
| 19 |
+
gray: '#8E939C',
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
export const STATUS_COLOR: Record<string, string> = {
|
| 23 |
+
correct: C.green,
|
| 24 |
+
wrong: C.red,
|
| 25 |
+
disputed: C.amber,
|
| 26 |
+
pending_lean: C.blue,
|
| 27 |
+
pending_against: C.purple,
|
| 28 |
+
pending_neutral: C.gray,
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
export const clamp = (v: number, a = 0, b = 1) => Math.min(b, Math.max(a, v))
|
| 32 |
+
export const lerp = (a: number, b: number, p: number) => a + (b - a) * p
|
| 33 |
+
export const prog = (t: number, s: number, d: number) => clamp((t - s) / d)
|
| 34 |
+
export const eo = (p: number) => 1 - Math.pow(1 - clamp(p), 3)
|
| 35 |
+
export const eo5 = (p: number) => 1 - Math.pow(1 - clamp(p), 5)
|
| 36 |
+
export const eio = (p: number) => {
|
| 37 |
+
p = clamp(p)
|
| 38 |
+
return p < 0.5 ? 4 * p * p * p : 1 - Math.pow(-2 * p + 2, 3) / 2
|
| 39 |
+
}
|
| 40 |
+
export const eback = (p: number) => {
|
| 41 |
+
p = clamp(p)
|
| 42 |
+
const c1 = 1.70158
|
| 43 |
+
const c3 = c1 + 1
|
| 44 |
+
return 1 + c3 * Math.pow(p - 1, 3) + c1 * Math.pow(p - 1, 2)
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
export function hexA(hex: string, a: number) {
|
| 48 |
+
const h = hex.replace('#', '')
|
| 49 |
+
const r = parseInt(h.slice(0, 2), 16)
|
| 50 |
+
const g = parseInt(h.slice(2, 4), 16)
|
| 51 |
+
const b = parseInt(h.slice(4, 6), 16)
|
| 52 |
+
return `rgba(${r},${g},${b},${a})`
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
export type Ctx = CanvasRenderingContext2D
|
| 56 |
+
|
| 57 |
+
export interface TO {
|
| 58 |
+
size: number
|
| 59 |
+
w?: number
|
| 60 |
+
f?: 'serif' | 'sans'
|
| 61 |
+
color?: string | CanvasGradient
|
| 62 |
+
align?: CanvasTextAlign
|
| 63 |
+
base?: CanvasTextBaseline
|
| 64 |
+
a?: number
|
| 65 |
+
ls?: number
|
| 66 |
+
/** 入场进度 0–1:淡入 + 上浮 */
|
| 67 |
+
p?: number
|
| 68 |
+
shadow?: number
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
export function setFont(c: Ctx, size: number, w = 700, f: 'serif' | 'sans' = 'sans') {
|
| 72 |
+
c.font = `${w} ${size}px ${f === 'serif' ? SERIF : SANS}`
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
export function T(c: Ctx, s: string, x: number, y: number, o: TO) {
|
| 76 |
+
const p = o.p ?? 1
|
| 77 |
+
if (p <= 0.001) return
|
| 78 |
+
c.save()
|
| 79 |
+
c.globalAlpha *= (o.a ?? 1) * clamp(p * 1.25)
|
| 80 |
+
setFont(c, o.size, o.w ?? 700, o.f ?? 'sans')
|
| 81 |
+
c.fillStyle = o.color ?? C.ink
|
| 82 |
+
c.textAlign = o.align ?? 'left'
|
| 83 |
+
c.textBaseline = o.base ?? 'alphabetic'
|
| 84 |
+
if (o.ls) (c as unknown as { letterSpacing: string }).letterSpacing = `${o.ls}px`
|
| 85 |
+
if (o.shadow) {
|
| 86 |
+
c.shadowColor = 'rgba(0,0,0,0.65)'
|
| 87 |
+
c.shadowBlur = o.shadow
|
| 88 |
+
}
|
| 89 |
+
let dx = 0
|
| 90 |
+
if (o.ls && (o.align === 'center' || o.align === undefined)) dx = o.align === 'center' ? o.ls / 2 : 0
|
| 91 |
+
c.fillText(s, x + dx, y + (1 - eo(p)) * o.size * 0.38)
|
| 92 |
+
c.restore()
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
export function measure(c: Ctx, s: string, size: number, w = 700, f: 'serif' | 'sans' = 'sans') {
|
| 96 |
+
c.save()
|
| 97 |
+
setFont(c, size, w, f)
|
| 98 |
+
const m = c.measureText(s).width
|
| 99 |
+
c.restore()
|
| 100 |
+
return m
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
/** 按宽度断行(中文逐字,英文按词) */
|
| 104 |
+
export function wrap(c: Ctx, s: string, maxW: number, size: number, w = 500, f: 'serif' | 'sans' = 'sans') {
|
| 105 |
+
c.save()
|
| 106 |
+
setFont(c, size, w, f)
|
| 107 |
+
const out: string[] = []
|
| 108 |
+
let cur = ''
|
| 109 |
+
const tokens = s.match(/[A-Za-z0-9.%:+\-×]+|./gu) ?? []
|
| 110 |
+
for (const tk of tokens) {
|
| 111 |
+
const next = cur + tk
|
| 112 |
+
if (c.measureText(next).width > maxW && cur) {
|
| 113 |
+
// 避免标点落在行首
|
| 114 |
+
if (/^[,。、;:!?”)]/.test(tk)) {
|
| 115 |
+
cur = next
|
| 116 |
+
continue
|
| 117 |
+
}
|
| 118 |
+
out.push(cur)
|
| 119 |
+
cur = tk.trimStart()
|
| 120 |
+
} else cur = next
|
| 121 |
+
}
|
| 122 |
+
if (cur) out.push(cur)
|
| 123 |
+
c.restore()
|
| 124 |
+
// 平衡两行长度
|
| 125 |
+
if (out.length === 2) {
|
| 126 |
+
const all = out.join('')
|
| 127 |
+
const half = Math.ceil(all.length / 2)
|
| 128 |
+
const a = all.slice(0, half)
|
| 129 |
+
const b = all.slice(half)
|
| 130 |
+
if (measure(c, a, size, w, f) <= maxW && !/^[,。、;:!?”)]/.test(b)) return [a, b]
|
| 131 |
+
}
|
| 132 |
+
return out
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
export function rr(c: Ctx, x: number, y: number, w: number, h: number, r: number) {
|
| 136 |
+
const rad = Math.min(r, w / 2, h / 2)
|
| 137 |
+
c.beginPath()
|
| 138 |
+
c.moveTo(x + rad, y)
|
| 139 |
+
c.arcTo(x + w, y, x + w, y + h, rad)
|
| 140 |
+
c.arcTo(x + w, y + h, x, y + h, rad)
|
| 141 |
+
c.arcTo(x, y + h, x, y, rad)
|
| 142 |
+
c.arcTo(x, y, x + w, y, rad)
|
| 143 |
+
c.closePath()
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
export function dot(c: Ctx, x: number, y: number, r: number, color: string, a = 1) {
|
| 147 |
+
if (a <= 0.001 || r <= 0) return
|
| 148 |
+
const prev = c.globalAlpha
|
| 149 |
+
c.globalAlpha = prev * a
|
| 150 |
+
c.fillStyle = color
|
| 151 |
+
c.beginPath()
|
| 152 |
+
c.arc(x, y, r, 0, Math.PI * 2)
|
| 153 |
+
c.fill()
|
| 154 |
+
c.globalAlpha = prev
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
export function line(c: Ctx, x1: number, y1: number, x2: number, y2: number, color: string, w = 2, a = 1, dash?: number[]) {
|
| 158 |
+
c.save()
|
| 159 |
+
c.globalAlpha *= a
|
| 160 |
+
c.strokeStyle = color
|
| 161 |
+
c.lineWidth = w
|
| 162 |
+
c.lineCap = 'round'
|
| 163 |
+
if (dash) c.setLineDash(dash)
|
| 164 |
+
c.beginPath()
|
| 165 |
+
c.moveTo(x1, y1)
|
| 166 |
+
c.lineTo(x2, y2)
|
| 167 |
+
c.stroke()
|
| 168 |
+
c.restore()
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
export function checkMark(c: Ctx, x: number, y: number, s: number, color: string, p: number, w = 6) {
|
| 172 |
+
if (p <= 0) return
|
| 173 |
+
const pts = [
|
| 174 |
+
[x - s * 0.5, y],
|
| 175 |
+
[x - s * 0.12, y + s * 0.38],
|
| 176 |
+
[x + s * 0.55, y - s * 0.42],
|
| 177 |
+
]
|
| 178 |
+
const l1 = Math.hypot(pts[1][0] - pts[0][0], pts[1][1] - pts[0][1])
|
| 179 |
+
const l2 = Math.hypot(pts[2][0] - pts[1][0], pts[2][1] - pts[1][1])
|
| 180 |
+
const L = (l1 + l2) * clamp(p)
|
| 181 |
+
c.save()
|
| 182 |
+
c.strokeStyle = color
|
| 183 |
+
c.lineWidth = w
|
| 184 |
+
c.lineCap = 'round'
|
| 185 |
+
c.lineJoin = 'round'
|
| 186 |
+
c.beginPath()
|
| 187 |
+
c.moveTo(pts[0][0], pts[0][1])
|
| 188 |
+
if (L <= l1) c.lineTo(lerp(pts[0][0], pts[1][0], L / l1), lerp(pts[0][1], pts[1][1], L / l1))
|
| 189 |
+
else {
|
| 190 |
+
c.lineTo(pts[1][0], pts[1][1])
|
| 191 |
+
const q = (L - l1) / l2
|
| 192 |
+
c.lineTo(lerp(pts[1][0], pts[2][0], q), lerp(pts[1][1], pts[2][1], q))
|
| 193 |
+
}
|
| 194 |
+
c.stroke()
|
| 195 |
+
c.restore()
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
export function crossMark(c: Ctx, x: number, y: number, s: number, color: string, p: number, w = 6) {
|
| 199 |
+
const p1 = clamp(p * 2)
|
| 200 |
+
const p2 = clamp(p * 2 - 1)
|
| 201 |
+
const h = s * 0.45
|
| 202 |
+
if (p1 > 0) line(c, x - h, y - h, lerp(x - h, x + h, p1), lerp(y - h, y + h, p1), color, w)
|
| 203 |
+
if (p2 > 0) line(c, x + h, y - h, lerp(x + h, x - h, p2), lerp(y - h, y + h, p2), color, w)
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
// ---------- 质感层 ----------
|
| 207 |
+
let noiseCanvas: HTMLCanvasElement | null = null
|
| 208 |
+
function getNoise() {
|
| 209 |
+
if (noiseCanvas) return noiseCanvas
|
| 210 |
+
const n = document.createElement('canvas')
|
| 211 |
+
n.width = n.height = 256
|
| 212 |
+
const x = n.getContext('2d')!
|
| 213 |
+
const img = x.createImageData(256, 256)
|
| 214 |
+
let seed = 1234567
|
| 215 |
+
for (let i = 0; i < img.data.length; i += 4) {
|
| 216 |
+
seed = (seed * 1103515245 + 12345) & 0x7fffffff
|
| 217 |
+
const v = (seed >> 16) & 255
|
| 218 |
+
img.data[i] = img.data[i + 1] = img.data[i + 2] = v
|
| 219 |
+
img.data[i + 3] = 255
|
| 220 |
+
}
|
| 221 |
+
x.putImageData(img, 0, 0)
|
| 222 |
+
noiseCanvas = n
|
| 223 |
+
return n
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
export function background(c: Ctx, W: number, H: number, t: number, accent: string, accentA: number) {
|
| 227 |
+
c.fillStyle = C.bg
|
| 228 |
+
c.fillRect(0, 0, W, H)
|
| 229 |
+
const M = Math.max(W, H)
|
| 230 |
+
const glow = (x: number, y: number, r: number, col: string, a: number) => {
|
| 231 |
+
const g = c.createRadialGradient(x, y, 0, x, y, r)
|
| 232 |
+
g.addColorStop(0, hexA(col, a))
|
| 233 |
+
g.addColorStop(1, hexA(col, 0))
|
| 234 |
+
c.fillStyle = g
|
| 235 |
+
c.fillRect(0, 0, W, H)
|
| 236 |
+
}
|
| 237 |
+
glow(W * (0.18 + 0.05 * Math.sin(t * 0.07)), H * (0.22 + 0.04 * Math.cos(t * 0.05)), M * 0.62, C.gold, 0.085)
|
| 238 |
+
glow(W * (0.86 + 0.04 * Math.cos(t * 0.06)), H * (0.84 + 0.03 * Math.sin(t * 0.08)), M * 0.55, '#3A5BA8', 0.08)
|
| 239 |
+
if (accentA > 0.01) glow(W * 0.5, H * 0.5, M * 0.6, accent, 0.07 * accentA)
|
| 240 |
+
// 账本细线
|
| 241 |
+
c.save()
|
| 242 |
+
c.strokeStyle = C.hair
|
| 243 |
+
c.lineWidth = 1
|
| 244 |
+
const step = 72
|
| 245 |
+
const off = (t * 6) % step
|
| 246 |
+
c.globalAlpha = 0.55
|
| 247 |
+
for (let y = -step + off; y < H; y += step) {
|
| 248 |
+
c.beginPath()
|
| 249 |
+
c.moveTo(0, y)
|
| 250 |
+
c.lineTo(W, y)
|
| 251 |
+
c.stroke()
|
| 252 |
+
}
|
| 253 |
+
c.restore()
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
export function finish(c: Ctx, W: number, H: number, frame: number) {
|
| 257 |
+
// 暗角
|
| 258 |
+
const g = c.createRadialGradient(W / 2, H / 2, Math.min(W, H) * 0.35, W / 2, H / 2, Math.max(W, H) * 0.78)
|
| 259 |
+
g.addColorStop(0, 'rgba(0,0,0,0)')
|
| 260 |
+
g.addColorStop(1, 'rgba(0,0,0,0.62)')
|
| 261 |
+
c.fillStyle = g
|
| 262 |
+
c.fillRect(0, 0, W, H)
|
| 263 |
+
// 胶片颗粒
|
| 264 |
+
const n = getNoise()
|
| 265 |
+
c.save()
|
| 266 |
+
c.globalAlpha = 0.045
|
| 267 |
+
c.globalCompositeOperation = 'screen'
|
| 268 |
+
const ox = (frame * 73) % 256
|
| 269 |
+
const oy = (frame * 151) % 256
|
| 270 |
+
for (let x = -ox; x < W; x += 256) for (let y = -oy; y < H; y += 256) c.drawImage(n, x, y)
|
| 271 |
+
c.restore()
|
| 272 |
+
}
|
kkndme/frontend/src/video/export.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { ArrayBufferTarget, Muxer } from 'mp4-muxer'
|
| 2 |
+
import { drawFrame } from './render'
|
| 3 |
+
import type { Timeline } from './timeline'
|
| 4 |
+
import { mixdown, SR, type Stems } from './audio'
|
| 5 |
+
|
| 6 |
+
export type Res = '2k' | '1080' | '720'
|
| 7 |
+
export type Orient = 'landscape' | 'portrait'
|
| 8 |
+
export interface ExportOpts {
|
| 9 |
+
res: Res
|
| 10 |
+
fps: 24 | 30 | 60
|
| 11 |
+
music: boolean
|
| 12 |
+
orient: Orient
|
| 13 |
+
subtitles: boolean
|
| 14 |
+
}
|
| 15 |
+
export interface ExportProgress {
|
| 16 |
+
phase: 'video' | 'audio' | 'finalize'
|
| 17 |
+
p: number
|
| 18 |
+
eta?: number
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
const SIZE: Record<Res, [number, number]> = { '2k': [2560, 1440], '1080': [1920, 1080], '720': [1280, 720] }
|
| 22 |
+
const BITRATE: Record<Res, number> = { '2k': 12_000_000, '1080': 7_000_000, '720': 4_000_000 }
|
| 23 |
+
const AVC = ['avc1.640034', 'avc1.640033', 'avc1.64002A', 'avc1.640028', 'avc1.4D4033', 'avc1.42E034', 'avc1.42001f']
|
| 24 |
+
|
| 25 |
+
export function exportSupported() {
|
| 26 |
+
return typeof window !== 'undefined' && 'VideoEncoder' in window && 'AudioEncoder' in window && 'VideoFrame' in window
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
export function dims(o: Pick<ExportOpts, 'res' | 'orient'>) {
|
| 30 |
+
const [w, h] = SIZE[o.res]
|
| 31 |
+
return o.orient === 'portrait' ? [h, w] : [w, h]
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
async function pickVideoConfig(width: number, height: number, fps: number, bitrate: number) {
|
| 35 |
+
for (const codec of AVC) {
|
| 36 |
+
const cfg: VideoEncoderConfig = {
|
| 37 |
+
codec,
|
| 38 |
+
width,
|
| 39 |
+
height,
|
| 40 |
+
bitrate,
|
| 41 |
+
framerate: fps,
|
| 42 |
+
bitrateMode: 'variable',
|
| 43 |
+
latencyMode: 'quality',
|
| 44 |
+
avc: { format: 'avc' },
|
| 45 |
+
}
|
| 46 |
+
try {
|
| 47 |
+
const r = await VideoEncoder.isConfigSupported(cfg)
|
| 48 |
+
if (r.supported) return cfg
|
| 49 |
+
} catch {
|
| 50 |
+
/* 尝试下一个 */
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
return null
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
async function pickAudioConfig() {
|
| 57 |
+
const opts: [string, 'aac' | 'opus'][] = [
|
| 58 |
+
['mp4a.40.2', 'aac'],
|
| 59 |
+
['opus', 'opus'],
|
| 60 |
+
]
|
| 61 |
+
for (const [codec, kind] of opts) {
|
| 62 |
+
const cfg: AudioEncoderConfig = { codec, sampleRate: SR, numberOfChannels: 2, bitrate: 192_000 }
|
| 63 |
+
try {
|
| 64 |
+
const r = await AudioEncoder.isConfigSupported(cfg)
|
| 65 |
+
if (r.supported) return { cfg, kind }
|
| 66 |
+
} catch {
|
| 67 |
+
/* 尝试下一个 */
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
return null
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
export async function exportMp4(
|
| 74 |
+
tl: Timeline,
|
| 75 |
+
stems: Stems,
|
| 76 |
+
o: ExportOpts,
|
| 77 |
+
onProgress: (p: ExportProgress) => void,
|
| 78 |
+
signal: AbortSignal,
|
| 79 |
+
): Promise<Blob> {
|
| 80 |
+
const [width, height] = dims(o)
|
| 81 |
+
const fpsK = o.fps === 60 ? 1.4 : o.fps === 24 ? 0.9 : 1
|
| 82 |
+
const vcfg = await pickVideoConfig(width, height, o.fps, Math.round(BITRATE[o.res] * fpsK))
|
| 83 |
+
if (!vcfg) throw new Error(`当前浏览器不支持以 ${width}×${height} / ${o.fps} 帧编码 H.264,请尝试降低分辨率或帧率。`)
|
| 84 |
+
const acfg = await pickAudioConfig()
|
| 85 |
+
if (!acfg) throw new Error('当前浏览器不支持音频编码(AAC / Opus)。')
|
| 86 |
+
|
| 87 |
+
const target = new ArrayBufferTarget()
|
| 88 |
+
const muxer = new Muxer({
|
| 89 |
+
target,
|
| 90 |
+
video: { codec: 'avc', width, height, frameRate: o.fps },
|
| 91 |
+
audio: { codec: acfg.kind, numberOfChannels: 2, sampleRate: SR },
|
| 92 |
+
fastStart: 'in-memory',
|
| 93 |
+
firstTimestampBehavior: 'offset',
|
| 94 |
+
})
|
| 95 |
+
|
| 96 |
+
let failure: unknown = null
|
| 97 |
+
const venc = new VideoEncoder({
|
| 98 |
+
output: (chunk, meta) => muxer.addVideoChunk(chunk, meta),
|
| 99 |
+
error: (e) => (failure = e),
|
| 100 |
+
})
|
| 101 |
+
venc.configure(vcfg)
|
| 102 |
+
const aenc = new AudioEncoder({
|
| 103 |
+
output: (chunk, meta) => muxer.addAudioChunk(chunk, meta),
|
| 104 |
+
error: (e) => (failure = e),
|
| 105 |
+
})
|
| 106 |
+
aenc.configure(acfg.cfg)
|
| 107 |
+
|
| 108 |
+
// 先编码音频(很快)
|
| 109 |
+
onProgress({ phase: 'audio', p: 0 })
|
| 110 |
+
const pcm = mixdown(stems, o.music)
|
| 111 |
+
const total = Math.min(pcm[0].length, Math.ceil(tl.duration * SR))
|
| 112 |
+
const block = 4800
|
| 113 |
+
for (let i = 0; i < total; i += block) {
|
| 114 |
+
const n = Math.min(block, total - i)
|
| 115 |
+
const data = new Float32Array(n * 2)
|
| 116 |
+
data.set(pcm[0].subarray(i, i + n), 0)
|
| 117 |
+
data.set(pcm[1].subarray(i, i + n), n)
|
| 118 |
+
const ad = new AudioData({ format: 'f32-planar', sampleRate: SR, numberOfFrames: n, numberOfChannels: 2, timestamp: Math.round((i / SR) * 1e6), data })
|
| 119 |
+
aenc.encode(ad)
|
| 120 |
+
ad.close()
|
| 121 |
+
}
|
| 122 |
+
await aenc.flush()
|
| 123 |
+
|
| 124 |
+
// 逐帧渲染视频
|
| 125 |
+
const canvas = document.createElement('canvas')
|
| 126 |
+
canvas.width = width
|
| 127 |
+
canvas.height = height
|
| 128 |
+
const ctx = canvas.getContext('2d', { alpha: false })!
|
| 129 |
+
const frames = Math.ceil(tl.duration * o.fps)
|
| 130 |
+
const frameDur = 1e6 / o.fps
|
| 131 |
+
const t0 = performance.now()
|
| 132 |
+
for (let f = 0; f < frames; f++) {
|
| 133 |
+
if (signal.aborted) {
|
| 134 |
+
venc.close()
|
| 135 |
+
aenc.close()
|
| 136 |
+
throw new DOMException('已取消', 'AbortError')
|
| 137 |
+
}
|
| 138 |
+
if (failure) throw failure
|
| 139 |
+
const t = f / o.fps
|
| 140 |
+
drawFrame(ctx, width, height, t, tl, f, { subtitles: o.subtitles })
|
| 141 |
+
const vf = new VideoFrame(canvas, { timestamp: Math.round(f * frameDur), duration: Math.round(frameDur) })
|
| 142 |
+
venc.encode(vf, { keyFrame: f % (o.fps * 2) === 0 })
|
| 143 |
+
vf.close()
|
| 144 |
+
while (venc.encodeQueueSize > 6) await new Promise((r) => setTimeout(r, 1))
|
| 145 |
+
if (f % 8 === 0) {
|
| 146 |
+
const el = (performance.now() - t0) / 1000
|
| 147 |
+
const p = (f + 1) / frames
|
| 148 |
+
onProgress({ phase: 'video', p, eta: (el / p) * (1 - p) })
|
| 149 |
+
await new Promise((r) => setTimeout(r, 0))
|
| 150 |
+
}
|
| 151 |
+
}
|
| 152 |
+
onProgress({ phase: 'finalize', p: 1 })
|
| 153 |
+
await venc.flush()
|
| 154 |
+
if (failure) throw failure
|
| 155 |
+
muxer.finalize()
|
| 156 |
+
venc.close()
|
| 157 |
+
aenc.close()
|
| 158 |
+
return new Blob([target.buffer], { type: 'video/mp4' })
|
| 159 |
+
}
|
kkndme/frontend/src/video/fonts.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
let loading: Promise<void> | null = null
|
| 2 |
+
|
| 3 |
+
/** 加载视频 / 封面专用字体(只在浏览器中调用) */
|
| 4 |
+
export function loadVideoFonts(): Promise<void> {
|
| 5 |
+
if (loading) return loading
|
| 6 |
+
const base = import.meta.env.BASE_URL
|
| 7 |
+
const list: [string, string, string][] = [
|
| 8 |
+
['KKSerif', '900', 'kkserif-900'],
|
| 9 |
+
['KKSerif', '700', 'kkserif-700'],
|
| 10 |
+
['KKSans', '400', 'kksans-400'],
|
| 11 |
+
['KKSans', '500', 'kksans-400'],
|
| 12 |
+
['KKSans', '700', 'kksans-700'],
|
| 13 |
+
]
|
| 14 |
+
loading = Promise.all(
|
| 15 |
+
list.map(async ([family, weight, file]) => {
|
| 16 |
+
try {
|
| 17 |
+
const f = new FontFace(family, `url(${base}fonts/${file}.woff2)`, { weight })
|
| 18 |
+
await f.load()
|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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// 视频特效与图表组件库:遮罩揭示、滚动数字、玻璃面板、发光折线、引线标注、粒子光斑……
|
| 2 |
+
import { C, T, clamp, lerp, prog, eo, eo5, eio, eback, hexA, rr, dot, line, measure, setFont, checkMark, crossMark, type Ctx, type TO } from './draw'
|
| 3 |
+
import type { TScene, TLine } from './timeline'
|
| 4 |
+
|
| 5 |
+
export interface G {
|
| 6 |
+
c: Ctx
|
| 7 |
+
W: number
|
| 8 |
+
H: number
|
| 9 |
+
P: boolean
|
| 10 |
+
t: number
|
| 11 |
+
s: TScene
|
| 12 |
+
/** 场景内时间 */
|
| 13 |
+
u: number
|
| 14 |
+
L: (k: number) => TLine
|
| 15 |
+
lt: (k: number) => number
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
/** 第 k 句开始后淡入;第 to 句开始时淡出 */
|
| 19 |
+
export function vis(g: G, k: number, to?: number, d = 0.6) {
|
| 20 |
+
const i = eo(prog(g.lt(k), 0, d))
|
| 21 |
+
const o = to === undefined ? 1 : 1 - eo(prog(g.lt(to), -0.2, 0.5))
|
| 22 |
+
return Math.min(i, o)
|
| 23 |
+
}
|
| 24 |
+
export const pin = (g: G, k: number, delay = 0, d = 0.7) => eo(prog(g.lt(k), delay, d))
|
| 25 |
+
export const pinR = (g: G, k: number, delay = 0, d = 0.7) => prog(g.lt(k), delay, d)
|
| 26 |
+
|
| 27 |
+
/** 版面:左右边距、内容区上下界 */
|
| 28 |
+
export function lay(g: G) {
|
| 29 |
+
return {
|
| 30 |
+
M: g.P ? 80 : 140,
|
| 31 |
+
top: g.P ? 390 : 262,
|
| 32 |
+
bot: g.P ? 1520 : 900,
|
| 33 |
+
cx: g.W / 2,
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
export function withA(c: Ctx, a: number, fn: () => void) {
|
| 38 |
+
if (a <= 0.002) return
|
| 39 |
+
c.save()
|
| 40 |
+
c.globalAlpha *= a
|
| 41 |
+
fn()
|
| 42 |
+
c.restore()
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
// ---------- 文字特效 ----------
|
| 46 |
+
/** 遮罩揭示:文字从一条看不见的缝里升起 */
|
| 47 |
+
export function maskText(c: Ctx, s: string, x: number, y: number, o: TO, p: number) {
|
| 48 |
+
if (p <= 0.001) return
|
| 49 |
+
const w = measure(c, s, o.size, o.w ?? 700, o.f ?? 'sans') + (o.ls ?? 0) * s.length
|
| 50 |
+
const al = o.align ?? 'left'
|
| 51 |
+
const x0 = al === 'center' ? x - w / 2 : al === 'right' ? x - w : x
|
| 52 |
+
c.save()
|
| 53 |
+
c.beginPath()
|
| 54 |
+
c.rect(x0 - 40, y - o.size * 1.12, w + 80, o.size * 1.5)
|
| 55 |
+
c.clip()
|
| 56 |
+
T(c, s, x, y + (1 - eo5(p)) * o.size * 1.25, { ...o, p: 1, a: (o.a ?? 1) * clamp(p * 2.2) })
|
| 57 |
+
c.restore()
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
const prefixCache = new Map<string, number[]>()
|
| 61 |
+
function prefixWidths(c: Ctx, s: string, size: number, w: number, f: 'serif' | 'sans') {
|
| 62 |
+
const key = `${s}|${size}|${w}|${f}`
|
| 63 |
+
let v = prefixCache.get(key)
|
| 64 |
+
if (v) return v
|
| 65 |
+
c.save()
|
| 66 |
+
setFont(c, size, w, f)
|
| 67 |
+
const chars = Array.from(s)
|
| 68 |
+
v = [0]
|
| 69 |
+
let acc = ''
|
| 70 |
+
for (const ch of chars) {
|
| 71 |
+
acc += ch
|
| 72 |
+
v.push(c.measureText(acc).width)
|
| 73 |
+
}
|
| 74 |
+
c.restore()
|
| 75 |
+
prefixCache.set(key, v)
|
| 76 |
+
return v
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/** 逐字入场:每个字依次浮起、带一点模糊感(用透明度 + 位移模拟) */
|
| 80 |
+
export function charText(c: Ctx, s: string, x: number, y: number, o: TO, p: number, st = 0.06) {
|
| 81 |
+
if (p <= 0.001) return
|
| 82 |
+
const chars = Array.from(s)
|
| 83 |
+
const pw = prefixWidths(c, s, o.size, o.w ?? 700, o.f ?? 'sans')
|
| 84 |
+
const total = pw[pw.length - 1]
|
| 85 |
+
const al = o.align ?? 'left'
|
| 86 |
+
const x0 = al === 'center' ? x - total / 2 : al === 'right' ? x - total : x
|
| 87 |
+
const span = 1 + st * chars.length
|
| 88 |
+
chars.forEach((ch, i) => {
|
| 89 |
+
const q = clamp(p * span - i * st)
|
| 90 |
+
if (q <= 0) return
|
| 91 |
+
T(c, ch, x0 + pw[i], y + (1 - eo(q)) * o.size * 0.42, { ...o, align: 'left', p: 1, a: (o.a ?? 1) * clamp(q * 1.6) })
|
| 92 |
+
})
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
/** 金属光泽:横向渐变 + 一道移动的高光 */
|
| 96 |
+
export function shine(c: Ctx, x: number, w: number, sweep: number, base = C.goldHi, hi = '#FFFFFF') {
|
| 97 |
+
const g = c.createLinearGradient(x, 0, x + w, 0)
|
| 98 |
+
const s = clamp(sweep, -0.3, 1.3)
|
| 99 |
+
const stops: [number, string][] = [
|
| 100 |
+
[0, base],
|
| 101 |
+
[s - 0.14, base],
|
| 102 |
+
[s, hi],
|
| 103 |
+
[s + 0.14, base],
|
| 104 |
+
[1, base],
|
| 105 |
+
]
|
| 106 |
+
stops
|
| 107 |
+
.filter(([o]) => o >= 0 && o <= 1)
|
| 108 |
+
.sort((a, b) => a[0] - b[0])
|
| 109 |
+
.forEach(([o, col]) => g.addColorStop(o, col))
|
| 110 |
+
return g
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
export function shineText(c: Ctx, s: string, x: number, y: number, o: TO, sweep: number, base = C.goldHi) {
|
| 114 |
+
const w = measure(c, s, o.size, o.w ?? 700, o.f ?? 'sans')
|
| 115 |
+
const al = o.align ?? 'left'
|
| 116 |
+
const x0 = al === 'center' ? x - w / 2 : al === 'right' ? x - w : x
|
| 117 |
+
T(c, s, x, y, { ...o, color: shine(c, x0, w, sweep, base) })
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
/** 滚动数字:每一位像机械计数器一样滚到目标值 */
|
| 121 |
+
export function roll(c: Ctx, s: string, x: number, y: number, o: TO, p: number, colorFn?: (x0: number, w: number) => string | CanvasGradient) {
|
| 122 |
+
if (p <= 0.001) return 0
|
| 123 |
+
const size = o.size
|
| 124 |
+
const wt = o.w ?? 900
|
| 125 |
+
const f = o.f ?? 'serif'
|
| 126 |
+
const chars = Array.from(s)
|
| 127 |
+
const pw = prefixWidths(c, s, size, wt, f)
|
| 128 |
+
const total = pw[pw.length - 1]
|
| 129 |
+
const al = o.align ?? 'left'
|
| 130 |
+
const x0 = al === 'center' ? x - total / 2 : al === 'right' ? x - total : x
|
| 131 |
+
const lh = size * 1.06
|
| 132 |
+
const col = colorFn ? colorFn(x0, total) : (o.color ?? C.ink)
|
| 133 |
+
const n = chars.length
|
| 134 |
+
c.save()
|
| 135 |
+
c.globalAlpha *= (o.a ?? 1) * clamp(p * 3)
|
| 136 |
+
setFont(c, size, wt, f)
|
| 137 |
+
c.textAlign = 'center'
|
| 138 |
+
c.textBaseline = 'alphabetic'
|
| 139 |
+
c.fillStyle = col
|
| 140 |
+
if (o.shadow) {
|
| 141 |
+
c.shadowColor = 'rgba(0,0,0,0.6)'
|
| 142 |
+
c.shadowBlur = o.shadow
|
| 143 |
+
}
|
| 144 |
+
chars.forEach((ch, i) => {
|
| 145 |
+
const cw = pw[i + 1] - pw[i]
|
| 146 |
+
const cxm = x0 + pw[i] + cw / 2
|
| 147 |
+
const d = ch.charCodeAt(0) - 48
|
| 148 |
+
if (d >= 0 && d <= 9) {
|
| 149 |
+
const q = eo5(clamp(p * 1.25 - (n - 1 - i) * 0.045))
|
| 150 |
+
const target = d + 10 * (1 + ((n - i) % 3))
|
| 151 |
+
const cur = target * q
|
| 152 |
+
const j = Math.floor(cur)
|
| 153 |
+
const fr = cur - j
|
| 154 |
+
c.save()
|
| 155 |
+
c.beginPath()
|
| 156 |
+
c.rect(cxm - cw / 2 - 4, y - size * 0.98, cw + 8, size * 1.24)
|
| 157 |
+
c.clip()
|
| 158 |
+
c.fillText(String(j % 10), cxm, y - fr * lh)
|
| 159 |
+
if (fr > 0.001) c.fillText(String((j + 1) % 10), cxm, y + (1 - fr) * lh)
|
| 160 |
+
c.restore()
|
| 161 |
+
} else {
|
| 162 |
+
c.save()
|
| 163 |
+
c.globalAlpha *= clamp(p * 1.6)
|
| 164 |
+
c.fillText(ch, cxm, y)
|
| 165 |
+
c.restore()
|
| 166 |
+
}
|
| 167 |
+
})
|
| 168 |
+
c.restore()
|
| 169 |
+
return total
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
/** 数值计数(带格式) */
|
| 173 |
+
export function countTo(v: number, p: number, dec = 0) {
|
| 174 |
+
const x = v * eo5(p)
|
| 175 |
+
return x.toFixed(dec)
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
/** 字距展开的英文小标 */
|
| 179 |
+
export function kicker(c: Ctx, s: string, x: number, y: number, color: string, a: number, size = 22, align: CanvasTextAlign = 'left') {
|
| 180 |
+
T(c, s, x, y, { size, w: 700, color, a, ls: size * 0.32, align })
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
// ---------- 面板与形状 ----------
|
| 184 |
+
export function glass(c: Ctx, x: number, y: number, w: number, h: number, r: number, a = 1, tint?: string) {
|
| 185 |
+
if (a <= 0.002) return
|
| 186 |
+
c.save()
|
| 187 |
+
c.globalAlpha *= a
|
| 188 |
+
rr(c, x, y, w, h, r)
|
| 189 |
+
const g = c.createLinearGradient(x, y, x, y + h)
|
| 190 |
+
g.addColorStop(0, tint ? hexA(tint, 0.1) : 'rgba(255,255,255,0.06)')
|
| 191 |
+
g.addColorStop(1, tint ? hexA(tint, 0.025) : 'rgba(255,255,255,0.015)')
|
| 192 |
+
c.fillStyle = g
|
| 193 |
+
c.fill()
|
| 194 |
+
c.strokeStyle = tint ? hexA(tint, 0.32) : 'rgba(243,238,228,0.12)'
|
| 195 |
+
c.lineWidth = 1.5
|
| 196 |
+
c.stroke()
|
| 197 |
+
// 顶部高光
|
| 198 |
+
const hl = c.createLinearGradient(x, 0, x + w, 0)
|
| 199 |
+
hl.addColorStop(0, 'rgba(255,255,255,0)')
|
| 200 |
+
hl.addColorStop(0.5, 'rgba(255,255,255,0.22)')
|
| 201 |
+
hl.addColorStop(1, 'rgba(255,255,255,0)')
|
| 202 |
+
c.strokeStyle = hl
|
| 203 |
+
c.lineWidth = 1.5
|
| 204 |
+
c.beginPath()
|
| 205 |
+
c.moveTo(x + r, y + 0.75)
|
| 206 |
+
c.lineTo(x + w - r, y + 0.75)
|
| 207 |
+
c.stroke()
|
| 208 |
+
c.restore()
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
/** 面板入场:轻微上浮 + 3D 透视倾斜回正 */
|
| 212 |
+
export function card3d(c: Ctx, cx: number, cy: number, p: number, fn: () => void, tilt = 0.12) {
|
| 213 |
+
if (p <= 0.002) return
|
| 214 |
+
const q = eo5(p)
|
| 215 |
+
c.save()
|
| 216 |
+
c.globalAlpha *= clamp(p * 1.8)
|
| 217 |
+
c.translate(cx, cy + (1 - q) * 60)
|
| 218 |
+
const sy = lerp(1 - tilt, 1, q)
|
| 219 |
+
c.transform(1, 0, lerp(-tilt, 0, q) * 0.5, sy, 0, 0)
|
| 220 |
+
c.translate(-cx, -cy)
|
| 221 |
+
fn()
|
| 222 |
+
c.restore()
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
/** 判定胶囊:✓ / ✕ / ≈ */
|
| 226 |
+
export function chip(c: Ctx, label: string, x: number, y: number, kind: 'ok' | 'no' | 'mid' | 'lean' | 'against' | 'wait', p: number, size = 26, align: 'left' | 'right' | 'center' = 'left') {
|
| 227 |
+
if (p <= 0.001) return 0
|
| 228 |
+
const color = { ok: C.green, no: C.red, mid: C.amber, lean: C.blue, against: C.purple, wait: C.gray }[kind]
|
| 229 |
+
const tw = measure(c, label, size, 700)
|
| 230 |
+
const h = size + 26
|
| 231 |
+
const w = tw + h + 26
|
| 232 |
+
const x0 = align === 'left' ? x : align === 'right' ? x - w : x - w / 2
|
| 233 |
+
c.save()
|
| 234 |
+
c.globalAlpha *= clamp(p * 1.6)
|
| 235 |
+
const sc = lerp(1.3, 1, eback(p))
|
| 236 |
+
c.translate(x0 + w / 2, y)
|
| 237 |
+
c.scale(sc, sc)
|
| 238 |
+
c.translate(-w / 2, 0)
|
| 239 |
+
rr(c, 0, -h / 2, w, h, h / 2)
|
| 240 |
+
c.fillStyle = hexA(color, 0.13)
|
| 241 |
+
c.fill()
|
| 242 |
+
c.strokeStyle = hexA(color, 0.65)
|
| 243 |
+
c.lineWidth = 2
|
| 244 |
+
c.stroke()
|
| 245 |
+
const ix = h / 2 + 4
|
| 246 |
+
dot(c, ix, 0, h * 0.32, color, 0.95)
|
| 247 |
+
const s = h * 0.34
|
| 248 |
+
if (kind === 'ok') checkMark(c, ix, 1, s, C.bg, clamp(p * 1.4 - 0.2), 3.5)
|
| 249 |
+
else if (kind === 'no') crossMark(c, ix, 0, s * 0.95, C.bg, clamp(p * 1.4 - 0.2), 3.5)
|
| 250 |
+
else line(c, ix - s * 0.4, 0, ix + s * 0.4, 0, C.bg, 3.5, clamp(p * 2 - 0.4))
|
| 251 |
+
T(c, label, h + 10, size * 0.36, { size, w: 700, color: C.ink })
|
| 252 |
+
c.restore()
|
| 253 |
+
return w
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
/** 环形进度(分段) */
|
| 257 |
+
export function ring(c: Ctx, cx: number, cy: number, r: number, w: number, segs: { v: number; color: string }[], p: number, gap = 0.018) {
|
| 258 |
+
const total = segs.reduce((a, b) => a + b.v, 0)
|
| 259 |
+
c.save()
|
| 260 |
+
c.lineCap = 'butt'
|
| 261 |
+
c.strokeStyle = 'rgba(243,238,228,0.07)'
|
| 262 |
+
c.lineWidth = w
|
| 263 |
+
c.beginPath()
|
| 264 |
+
c.arc(cx, cy, r, 0, Math.PI * 2)
|
| 265 |
+
c.stroke()
|
| 266 |
+
let a0 = -Math.PI / 2
|
| 267 |
+
const sweep = Math.PI * 2 * eio(p)
|
| 268 |
+
const end = -Math.PI / 2 + sweep
|
| 269 |
+
segs.forEach((sg) => {
|
| 270 |
+
const a1 = a0 + (sg.v / total) * Math.PI * 2
|
| 271 |
+
const s0 = a0 + gap
|
| 272 |
+
const s1 = Math.min(a1 - gap, end)
|
| 273 |
+
if (s1 > s0) {
|
| 274 |
+
c.strokeStyle = sg.color
|
| 275 |
+
c.shadowColor = hexA(sg.color, 0.6)
|
| 276 |
+
c.shadowBlur = 18
|
| 277 |
+
c.beginPath()
|
| 278 |
+
c.arc(cx, cy, r, s0, s1)
|
| 279 |
+
c.stroke()
|
| 280 |
+
}
|
| 281 |
+
a0 = a1
|
| 282 |
+
})
|
| 283 |
+
c.restore()
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
/** 扩散光圈 */
|
| 287 |
+
export function pulse(c: Ctx, x: number, y: number, r: number, t: number, color: string, a = 1, period = 1.6) {
|
| 288 |
+
for (let k = 0; k < 2; k++) {
|
| 289 |
+
const q = ((t / period + k / 2) % 1 + 1) % 1
|
| 290 |
+
c.save()
|
| 291 |
+
c.globalAlpha *= a * (1 - q) * 0.7
|
| 292 |
+
c.strokeStyle = color
|
| 293 |
+
c.lineWidth = 2
|
| 294 |
+
c.beginPath()
|
| 295 |
+
c.arc(x, y, r + q * r * 2.4, 0, Math.PI * 2)
|
| 296 |
+
c.stroke()
|
| 297 |
+
c.restore()
|
| 298 |
+
}
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
/** 发光点 */
|
| 302 |
+
export function glowDot(c: Ctx, x: number, y: number, r: number, color: string, a = 1) {
|
| 303 |
+
if (a <= 0.002) return
|
| 304 |
+
c.save()
|
| 305 |
+
c.globalAlpha *= a
|
| 306 |
+
const g = c.createRadialGradient(x, y, 0, x, y, r * 4)
|
| 307 |
+
g.addColorStop(0, hexA(color, 0.55))
|
| 308 |
+
g.addColorStop(1, hexA(color, 0))
|
| 309 |
+
c.fillStyle = g
|
| 310 |
+
c.fillRect(x - r * 4, y - r * 4, r * 8, r * 8)
|
| 311 |
+
c.restore()
|
| 312 |
+
dot(c, x, y, r, color, a)
|
| 313 |
+
dot(c, x, y, r * 0.45, '#FFFFFF', a * 0.85)
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
/** 斜向扫光带 */
|
| 317 |
+
export function sweepBand(c: Ctx, x: number, y: number, w: number, h: number, p: number, color = C.goldHi, a = 0.22) {
|
| 318 |
+
if (p <= 0 || p >= 1) return
|
| 319 |
+
const bx = lerp(x - w * 0.3, x + w * 1.3, eio(p))
|
| 320 |
+
c.save()
|
| 321 |
+
c.beginPath()
|
| 322 |
+
c.rect(x, y, w, h)
|
| 323 |
+
c.clip()
|
| 324 |
+
c.globalCompositeOperation = 'lighter'
|
| 325 |
+
c.translate(bx, y + h / 2)
|
| 326 |
+
c.transform(1, 0, -0.35, 1, 0, 0)
|
| 327 |
+
const g = c.createLinearGradient(-120, 0, 120, 0)
|
| 328 |
+
g.addColorStop(0, hexA(color, 0))
|
| 329 |
+
g.addColorStop(0.5, hexA(color, a * Math.sin(p * Math.PI)))
|
| 330 |
+
g.addColorStop(1, hexA(color, 0))
|
| 331 |
+
c.fillStyle = g
|
| 332 |
+
c.fillRect(-120, -h / 2, 240, h)
|
| 333 |
+
c.restore()
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
/** 横向数据条(带轨道) */
|
| 337 |
+
export function hbar(c: Ctx, x: number, y: number, w: number, h: number, frac: number, color: string, p: number, track = true) {
|
| 338 |
+
if (track) {
|
| 339 |
+
c.save()
|
| 340 |
+
rr(c, x, y, w, h, h / 2)
|
| 341 |
+
c.fillStyle = 'rgba(243,238,228,0.06)'
|
| 342 |
+
c.fill()
|
| 343 |
+
c.restore()
|
| 344 |
+
}
|
| 345 |
+
const bw = Math.max(0, w * frac * eo5(p))
|
| 346 |
+
if (bw < 1) return x
|
| 347 |
+
c.save()
|
| 348 |
+
rr(c, x, y, Math.max(bw, h), h, h / 2)
|
| 349 |
+
const g = c.createLinearGradient(x, 0, x + bw, 0)
|
| 350 |
+
g.addColorStop(0, hexA(color, 0.55))
|
| 351 |
+
g.addColorStop(1, color)
|
| 352 |
+
c.fillStyle = g
|
| 353 |
+
c.shadowColor = hexA(color, 0.5)
|
| 354 |
+
c.shadowBlur = 16
|
| 355 |
+
c.fill()
|
| 356 |
+
c.restore()
|
| 357 |
+
return x + bw
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
/** 竖向柱 */
|
| 361 |
+
export function vbar(c: Ctx, x: number, base: number, w: number, h: number, color: string, p: number, glow = true) {
|
| 362 |
+
const bh = h * eo5(p)
|
| 363 |
+
if (bh < 0.5) return base
|
| 364 |
+
c.save()
|
| 365 |
+
rr(c, x, base - bh, w, bh, Math.min(6, w / 2))
|
| 366 |
+
const g = c.createLinearGradient(0, base - bh, 0, base)
|
| 367 |
+
g.addColorStop(0, color)
|
| 368 |
+
g.addColorStop(1, hexA(color, 0.25))
|
| 369 |
+
c.fillStyle = g
|
| 370 |
+
if (glow) {
|
| 371 |
+
c.shadowColor = hexA(color, 0.45)
|
| 372 |
+
c.shadowBlur = 14
|
| 373 |
+
}
|
| 374 |
+
c.fill()
|
| 375 |
+
c.restore()
|
| 376 |
+
return base - bh
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
// ---------- 折线图 ----------
|
| 380 |
+
export interface Chart {
|
| 381 |
+
x: number
|
| 382 |
+
y: number
|
| 383 |
+
w: number
|
| 384 |
+
h: number
|
| 385 |
+
x0: number
|
| 386 |
+
x1: number
|
| 387 |
+
y0: number
|
| 388 |
+
y1: number
|
| 389 |
+
}
|
| 390 |
+
export const sx = (ch: Chart, v: number) => ch.x + ((v - ch.x0) / (ch.x1 - ch.x0)) * ch.w
|
| 391 |
+
export const sy = (ch: Chart, v: number) => ch.y + ch.h - ((v - ch.y0) / (ch.y1 - ch.y0)) * ch.h
|
| 392 |
+
|
| 393 |
+
export function grid(c: Ctx, ch: Chart, yt: number[], xt: number[], fy: (v: number) => string, fx: (v: number) => string, a: number, P: boolean) {
|
| 394 |
+
if (a <= 0.002) return
|
| 395 |
+
c.save()
|
| 396 |
+
c.globalAlpha *= a
|
| 397 |
+
const fs = P ? 24 : 20
|
| 398 |
+
yt.forEach((v, i) => {
|
| 399 |
+
const y = sy(ch, v)
|
| 400 |
+
const p = clamp(a * 1.5 - i * 0.05)
|
| 401 |
+
line(c, ch.x, y, ch.x + ch.w * eio(p), y, 'rgba(243,238,228,0.09)', 1.2, 1, [3, 7])
|
| 402 |
+
T(c, fy(v), ch.x - 16, y + fs * 0.36, { size: fs, w: 500, color: C.dim, align: 'right' })
|
| 403 |
+
})
|
| 404 |
+
line(c, ch.x, ch.y + ch.h, ch.x + ch.w, ch.y + ch.h, 'rgba(243,238,228,0.22)', 1.5)
|
| 405 |
+
xt.forEach((v) => {
|
| 406 |
+
const x = sx(ch, v)
|
| 407 |
+
line(c, x, ch.y + ch.h, x, ch.y + ch.h + 8, 'rgba(243,238,228,0.3)', 1.5)
|
| 408 |
+
T(c, fx(v), x, ch.y + ch.h + 12 + fs, { size: fs, w: 500, color: C.dim, align: 'center' })
|
| 409 |
+
})
|
| 410 |
+
c.restore()
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
export interface SeriesOpts {
|
| 414 |
+
w?: number
|
| 415 |
+
area?: number
|
| 416 |
+
head?: boolean
|
| 417 |
+
dash?: number[]
|
| 418 |
+
glow?: number
|
| 419 |
+
t?: number
|
| 420 |
+
/** 从第几个点开始画 */
|
| 421 |
+
from?: number
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
/** 发光折线:p 为绘制进度(按 x 方向),返回笔头坐标 */
|
| 425 |
+
export function series(c: Ctx, ch: Chart, pts: [number, number][], p: number, color: string, o: SeriesOpts = {}) {
|
| 426 |
+
if (p <= 0.001 || pts.length < 2) return null
|
| 427 |
+
const from = o.from ?? 0
|
| 428 |
+
const xa = pts[from][0]
|
| 429 |
+
const xb = pts[pts.length - 1][0]
|
| 430 |
+
const xp = lerp(xa, xb, clamp(p))
|
| 431 |
+
const path: [number, number][] = []
|
| 432 |
+
for (let i = from; i < pts.length; i++) {
|
| 433 |
+
const [x, y] = pts[i]
|
| 434 |
+
if (x <= xp) path.push([sx(ch, x), sy(ch, y)])
|
| 435 |
+
else {
|
| 436 |
+
const [px, py] = pts[i - 1]
|
| 437 |
+
const q = (xp - px) / (x - px)
|
| 438 |
+
path.push([sx(ch, xp), sy(ch, lerp(py, y, q))])
|
| 439 |
+
break
|
| 440 |
+
}
|
| 441 |
+
}
|
| 442 |
+
if (path.length < 2) return null
|
| 443 |
+
c.save()
|
| 444 |
+
if (o.area) {
|
| 445 |
+
const g = c.createLinearGradient(0, ch.y, 0, ch.y + ch.h)
|
| 446 |
+
g.addColorStop(0, hexA(color, o.area))
|
| 447 |
+
g.addColorStop(1, hexA(color, 0))
|
| 448 |
+
c.beginPath()
|
| 449 |
+
c.moveTo(path[0][0], ch.y + ch.h)
|
| 450 |
+
path.forEach(([x, y]) => c.lineTo(x, y))
|
| 451 |
+
c.lineTo(path[path.length - 1][0], ch.y + ch.h)
|
| 452 |
+
c.closePath()
|
| 453 |
+
c.fillStyle = g
|
| 454 |
+
c.fill()
|
| 455 |
+
}
|
| 456 |
+
c.beginPath()
|
| 457 |
+
path.forEach(([x, y], i) => (i ? c.lineTo(x, y) : c.moveTo(x, y)))
|
| 458 |
+
c.strokeStyle = color
|
| 459 |
+
c.lineWidth = o.w ?? 4
|
| 460 |
+
c.lineJoin = 'round'
|
| 461 |
+
c.lineCap = 'round'
|
| 462 |
+
if (o.dash) c.setLineDash(o.dash)
|
| 463 |
+
if (o.glow !== 0) {
|
| 464 |
+
c.shadowColor = hexA(color, 0.7)
|
| 465 |
+
c.shadowBlur = o.glow ?? 16
|
| 466 |
+
}
|
| 467 |
+
c.stroke()
|
| 468 |
+
c.restore()
|
| 469 |
+
const head = path[path.length - 1]
|
| 470 |
+
if (o.head !== false && p < 0.999) glowDot(c, head[0], head[1], (o.w ?? 4) * 1.6, color)
|
| 471 |
+
return head
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
/** 某个 x 值对应的点(线性插值) */
|
| 475 |
+
export function at(pts: [number, number][], x: number) {
|
| 476 |
+
for (let i = 1; i < pts.length; i++) {
|
| 477 |
+
if (pts[i][0] >= x) {
|
| 478 |
+
const [x0, y0] = pts[i - 1]
|
| 479 |
+
const [x1, y1] = pts[i]
|
| 480 |
+
return lerp(y0, y1, (x - x0) / (x1 - x0))
|
| 481 |
+
}
|
| 482 |
+
}
|
| 483 |
+
return pts[pts.length - 1][1]
|
| 484 |
+
}
|
| 485 |
+
|
| 486 |
+
/** 引线标注:点 → 折线 → 文字块 */
|
| 487 |
+
export function annot(
|
| 488 |
+
c: Ctx,
|
| 489 |
+
px: number,
|
| 490 |
+
py: number,
|
| 491 |
+
lx: number,
|
| 492 |
+
ly: number,
|
| 493 |
+
rows: { s: string; size: number; color?: string; w?: number; f?: 'serif' | 'sans' }[],
|
| 494 |
+
color: string,
|
| 495 |
+
p: number,
|
| 496 |
+
align: 'left' | 'right' = 'left',
|
| 497 |
+
) {
|
| 498 |
+
if (p <= 0.001) return
|
| 499 |
+
const q1 = eio(clamp(p * 2))
|
| 500 |
+
const q2 = clamp(p * 2 - 0.6)
|
| 501 |
+
glowDot(c, px, py, 7, color, clamp(p * 4))
|
| 502 |
+
c.save()
|
| 503 |
+
c.strokeStyle = hexA(color, 0.8)
|
| 504 |
+
c.lineWidth = 2
|
| 505 |
+
c.beginPath()
|
| 506 |
+
c.moveTo(px, py)
|
| 507 |
+
const mx = lx
|
| 508 |
+
const segA = Math.hypot(mx - px, ly - py)
|
| 509 |
+
const tx = lerp(px, mx, q1)
|
| 510 |
+
const ty = lerp(py, ly, q1)
|
| 511 |
+
if (segA > 0) c.lineTo(tx, ty)
|
| 512 |
+
c.stroke()
|
| 513 |
+
c.restore()
|
| 514 |
+
if (q2 <= 0) return
|
| 515 |
+
const dir = align === 'left' ? 1 : -1
|
| 516 |
+
line(c, lx, ly, lx + dir * 36 * eo(q2), ly, color, 2)
|
| 517 |
+
let y = ly - (rows.reduce((a, r) => a + r.size * 1.3, 0) - rows[0].size * 1.3) / 2 + rows[0].size * 0.36
|
| 518 |
+
rows.forEach((r, i) => {
|
| 519 |
+
T(c, r.s, lx + dir * 50, y, { size: r.size, w: r.w ?? 700, f: r.f, color: r.color ?? C.ink, align, p: clamp(q2 * 1.4 - i * 0.15) })
|
| 520 |
+
y += r.size * 1.3 + (i === 0 ? 2 : 0)
|
| 521 |
+
})
|
| 522 |
+
}
|
| 523 |
+
|
| 524 |
+
// ---------- 粒子光斑 ----------
|
| 525 |
+
const sprites = new Map<string, HTMLCanvasElement>()
|
| 526 |
+
function sprite(color: string) {
|
| 527 |
+
let s = sprites.get(color)
|
| 528 |
+
if (s) return s
|
| 529 |
+
s = document.createElement('canvas')
|
| 530 |
+
s.width = s.height = 128
|
| 531 |
+
const x = s.getContext('2d')!
|
| 532 |
+
const g = x.createRadialGradient(64, 64, 0, 64, 64, 64)
|
| 533 |
+
g.addColorStop(0, hexA(color, 1))
|
| 534 |
+
g.addColorStop(0.35, hexA(color, 0.5))
|
| 535 |
+
g.addColorStop(1, hexA(color, 0))
|
| 536 |
+
x.fillStyle = g
|
| 537 |
+
x.fillRect(0, 0, 128, 128)
|
| 538 |
+
sprites.set(color, s)
|
| 539 |
+
return s
|
| 540 |
+
}
|
| 541 |
+
const PARTS = Array.from({ length: 34 }, (_, i) => {
|
| 542 |
+
const r = (n: number) => {
|
| 543 |
+
const v = Math.sin(i * 127.1 + n * 311.7) * 43758.5453
|
| 544 |
+
return v - Math.floor(v)
|
| 545 |
+
}
|
| 546 |
+
return { x: r(1), y: r(2), s: 0.3 + r(3) * 0.7, sp: 0.004 + r(4) * 0.012, ph: r(5) * 6.28, gold: r(6) > 0.35, a: 0.25 + r(7) * 0.75 }
|
| 547 |
+
})
|
| 548 |
+
|
| 549 |
+
export function bokeh(c: Ctx, W: number, H: number, t: number, a = 1, tint?: string) {
|
| 550 |
+
if (a <= 0.002) return
|
| 551 |
+
const sg = sprite(C.gold)
|
| 552 |
+
const sb = sprite(tint ?? '#5B7FD0')
|
| 553 |
+
c.save()
|
| 554 |
+
c.globalCompositeOperation = 'lighter'
|
| 555 |
+
PARTS.forEach((p) => {
|
| 556 |
+
const y = ((p.y - t * p.sp) % 1 + 1) % 1
|
| 557 |
+
const x = p.x + Math.sin(t * 0.2 + p.ph) * 0.02
|
| 558 |
+
const r = (8 + p.s * 46) * (Math.max(W, H) / 1920)
|
| 559 |
+
const tw = 0.6 + 0.4 * Math.sin(t * 0.9 + p.ph * 3)
|
| 560 |
+
c.globalAlpha = a * p.a * tw * 0.16
|
| 561 |
+
c.drawImage(p.gold ? sg : sb, x * W - r, y * H - r, r * 2, r * 2)
|
| 562 |
+
})
|
| 563 |
+
c.restore()
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { C, T, background, finish, clamp, lerp, prog, eo, eo5, eio, hexA, dot, line, wrap, measure, setFont, SERIF, type Ctx } from './draw'
|
| 2 |
+
import { sceneAt, SCENE_INFO, CARD, type Timeline, type TScene } from './timeline'
|
| 3 |
+
import type { SceneKey } from './script'
|
| 4 |
+
import { type G, bokeh, maskText, shine } from './kit'
|
| 5 |
+
import { intro, method, score } from './scenes1'
|
| 6 |
+
import { price, cities, money } from './scenes2'
|
| 7 |
+
import { policy, rulers, brier, blind, pending, outro } from './scenes3'
|
| 8 |
+
|
| 9 |
+
const SCENES: Partial<Record<SceneKey, (g: G) => void>> = { intro, method, score, price, cities, money, policy, rulers, brier, blind, pending, outro }
|
| 10 |
+
const ACCENT: Partial<Record<SceneKey, string>> = {
|
| 11 |
+
score: C.gold,
|
| 12 |
+
cities: C.green,
|
| 13 |
+
policy: C.gold,
|
| 14 |
+
brier: C.amber,
|
| 15 |
+
blind: C.red,
|
| 16 |
+
pending: C.blue,
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
// ---------- 主入口 ----------
|
| 20 |
+
export interface RenderOpts {
|
| 21 |
+
subtitles?: boolean
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
export function drawFrame(c: Ctx, pxW: number, pxH: number, t: number, tl: Timeline, frame = Math.round(t * 30), opts: RenderOpts = {}) {
|
| 25 |
+
const P = pxH > pxW
|
| 26 |
+
const W = P ? 1080 : 1920
|
| 27 |
+
const H = P ? 1920 : 1080
|
| 28 |
+
c.setTransform(pxW / W, 0, 0, pxH / H, 0, 0)
|
| 29 |
+
c.globalAlpha = 1
|
| 30 |
+
c.globalCompositeOperation = 'source-over'
|
| 31 |
+
const s = sceneAt(tl, t)
|
| 32 |
+
const u = t - s.start
|
| 33 |
+
const accentA = ACCENT[s.key] ? Math.min(eo(prog(t, s.start, 1.2)), 1 - prog(t, s.end - 0.8, 0.8)) : 0
|
| 34 |
+
background(c, W, H, t, ACCENT[s.key] ?? C.gold, accentA)
|
| 35 |
+
const cardA = s.idx > 0 ? Math.sin(clamp(u / CARD) * Math.PI) : 0
|
| 36 |
+
bokeh(c, W, H, t, 0.8 + cardA * 0.6, ACCENT[s.key] === C.red ? '#8A3A3A' : undefined)
|
| 37 |
+
const g: G = {
|
| 38 |
+
c,
|
| 39 |
+
W,
|
| 40 |
+
H,
|
| 41 |
+
P,
|
| 42 |
+
t,
|
| 43 |
+
s,
|
| 44 |
+
u,
|
| 45 |
+
L: (k) => s.lines[Math.min(k, s.lines.length - 1)],
|
| 46 |
+
lt: (k) => (k < s.lines.length ? t - s.lines[k].start : -99),
|
| 47 |
+
}
|
| 48 |
+
// 场景淡入淡出 + 镜头运动
|
| 49 |
+
const fin = eo(prog(t, s.start + 0.05, 0.5))
|
| 50 |
+
const fout = prog(t, s.end - 0.5, 0.5)
|
| 51 |
+
const sa = Math.min(fin, 1 - fout)
|
| 52 |
+
if (sa > 0.002) {
|
| 53 |
+
c.save()
|
| 54 |
+
c.globalAlpha *= sa
|
| 55 |
+
const z = (1 + Math.min(u, 40) * 0.001) * (1 - 0.03 * eio(fout))
|
| 56 |
+
c.translate(W / 2, H / 2)
|
| 57 |
+
c.scale(z, z)
|
| 58 |
+
c.translate(-W / 2, -H / 2)
|
| 59 |
+
SCENES[s.key]?.(g)
|
| 60 |
+
c.restore()
|
| 61 |
+
if (s.idx > 0) {
|
| 62 |
+
c.save()
|
| 63 |
+
c.globalAlpha *= sa
|
| 64 |
+
chapter(g)
|
| 65 |
+
c.restore()
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
// 转场光线
|
| 69 |
+
const tr = prog(t, s.start, 1.0)
|
| 70 |
+
if (s.idx > 0 && tr > 0 && tr < 1) {
|
| 71 |
+
const x = lerp(-300, W + 300, eio(tr))
|
| 72 |
+
const grd = c.createLinearGradient(x - 360, 0, x + 60, 0)
|
| 73 |
+
grd.addColorStop(0, 'rgba(244,221,168,0)')
|
| 74 |
+
grd.addColorStop(1, 'rgba(244,221,168,0.14)')
|
| 75 |
+
c.save()
|
| 76 |
+
c.globalCompositeOperation = 'lighter'
|
| 77 |
+
c.fillStyle = grd
|
| 78 |
+
c.fillRect(x - 360, 0, 420, H)
|
| 79 |
+
c.restore()
|
| 80 |
+
line(c, x + 60, 0, x + 60, H, C.goldHi, 2, 0.55 * Math.sin(tr * Math.PI))
|
| 81 |
+
}
|
| 82 |
+
chrome(c, W, H, P, t, tl, s)
|
| 83 |
+
if (opts.subtitles !== false) subtitle(c, W, H, P, t, tl)
|
| 84 |
+
// 颗粒每秒刷新 12 次:保留胶片质感,同时让导出文件更小
|
| 85 |
+
finish(c, W, H, Math.floor(t * 12) + frame * 0)
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
// ---------- 章节标题卡 → 常驻页眉 ----------
|
| 89 |
+
function chapter(g: G) {
|
| 90 |
+
const { c, W, H, P, u, s } = g
|
| 91 |
+
const info = SCENE_INFO[s.key]
|
| 92 |
+
const cx = W / 2
|
| 93 |
+
const cy = P ? H * 0.46 : H * 0.5
|
| 94 |
+
const M = P ? 80 : 140
|
| 95 |
+
const m = eio(prog(u, 1.75, 0.8)) // 0 = 标题卡,1 = 页眉
|
| 96 |
+
const cardOut = 1 - eo(prog(u, 1.6, 0.6))
|
| 97 |
+
// 巨型描边编号
|
| 98 |
+
if (cardOut > 0.002) {
|
| 99 |
+
const p = eo(prog(u, 0.1, 1.2))
|
| 100 |
+
const fs = P ? 460 : 520
|
| 101 |
+
c.save()
|
| 102 |
+
c.globalAlpha *= cardOut * clamp(p * 2)
|
| 103 |
+
c.translate(cx, cy + (P ? 20 : 30))
|
| 104 |
+
const sc = 1.08 - 0.08 * eo5(p) + (1 - cardOut) * 0.06
|
| 105 |
+
c.scale(sc, sc)
|
| 106 |
+
setFont(c, fs, 900, 'serif')
|
| 107 |
+
c.textAlign = 'center'
|
| 108 |
+
c.textBaseline = 'middle'
|
| 109 |
+
const len = 2600
|
| 110 |
+
c.setLineDash([len * p, len])
|
| 111 |
+
c.lineWidth = 2
|
| 112 |
+
c.strokeStyle = hexA(C.gold, 0.5)
|
| 113 |
+
c.strokeText(info.no, 0, 0)
|
| 114 |
+
c.setLineDash([])
|
| 115 |
+
c.fillStyle = hexA(C.gold, 0.06 * p)
|
| 116 |
+
c.fillText(info.no, 0, 0)
|
| 117 |
+
c.restore()
|
| 118 |
+
// 英文章节名
|
| 119 |
+
T(c, `CHAPTER ${info.no} · ${info.en}`, cx, cy - (P ? 120 : 110), { size: P ? 24 : 22, w: 700, color: C.gold, align: 'center', ls: 6, a: cardOut, p: eo(prog(u, 0.35, 0.7)) })
|
| 120 |
+
const lw = (P ? 200 : 260) * eio(prog(u, 0.7, 0.8))
|
| 121 |
+
line(c, cx - lw, cy + (P ? 110 : 110), cx + lw, cy + (P ? 110 : 110), C.gold, 2, cardOut)
|
| 122 |
+
}
|
| 123 |
+
// 标题:从居中大字移动到左上页眉
|
| 124 |
+
const big = P ? 150 : 150
|
| 125 |
+
const small = P ? 60 : 56
|
| 126 |
+
const fs = lerp(big, small, m)
|
| 127 |
+
const w = measure(c, info.title, fs, 900, 'serif')
|
| 128 |
+
const tx = lerp(cx - w / 2, M, m)
|
| 129 |
+
const ty = lerp(cy + big * 0.36, P ? 300 : 200, m)
|
| 130 |
+
const tp = prog(u, 0.45, 0.9)
|
| 131 |
+
if (m <= 0) {
|
| 132 |
+
maskText(c, info.title, tx, ty, { size: fs, w: 900, f: 'serif', color: shine(c, tx, w, prog(u, 1.0, 1.0) * 1.6 - 0.3, C.ink) }, tp)
|
| 133 |
+
} else {
|
| 134 |
+
T(c, info.title, tx, ty, { size: fs, w: 900, f: 'serif', color: C.ink })
|
| 135 |
+
}
|
| 136 |
+
// 页眉小标
|
| 137 |
+
const ha = clamp((m - 0.75) / 0.25)
|
| 138 |
+
if (ha > 0) {
|
| 139 |
+
T(c, `CHAPTER ${info.no}`, M, P ? 240 : 140, { size: P ? 22 : 20, w: 700, color: C.gold, ls: 6, a: ha })
|
| 140 |
+
const lw = 48 * ha
|
| 141 |
+
line(c, M + w + 28, ty - small * 0.34, M + w + 28 + lw, ty - small * 0.34, C.gold, 2, ha)
|
| 142 |
+
T(c, info.en, M + w + 28 + 66, ty - small * 0.34 + 7, { size: P ? 18 : 18, w: 700, color: C.dim, ls: 4, a: ha })
|
| 143 |
+
}
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
// ---------- 顶栏 / 进度 ----------
|
| 147 |
+
function chrome(c: Ctx, W: number, H: number, P: boolean, t: number, tl: Timeline, s: TScene) {
|
| 148 |
+
const a = Math.min(1, prog(t, 1.0, 1.0)) * (1 - prog(t, tl.duration - 1.2, 1.0))
|
| 149 |
+
if (a <= 0) return
|
| 150 |
+
c.save()
|
| 151 |
+
c.globalAlpha = a
|
| 152 |
+
const m = P ? 80 : 90
|
| 153 |
+
const top = P ? 150 : 76
|
| 154 |
+
c.fillStyle = C.gold
|
| 155 |
+
c.fillRect(m, top - 22, 8, 26)
|
| 156 |
+
T(c, 'kkndme 神贴 · 十五年对账', m + 22, top, { size: P ? 28 : 24, w: 700, color: C.ink, ls: 4, a: 0.85 })
|
| 157 |
+
const info = SCENE_INFO[s.key]
|
| 158 |
+
T(c, `${info.no} / 12 ${info.title}`, W - m, top, { size: P ? 26 : 22, w: 700, color: C.mute, align: 'right', ls: 3 })
|
| 159 |
+
// 进度
|
| 160 |
+
const y = H - (P ? 120 : 34)
|
| 161 |
+
line(c, m, y, W - m, y, C.hair, 2)
|
| 162 |
+
line(c, m, y, m + (W - 2 * m) * (t / tl.duration), y, C.gold, 2, 0.8)
|
| 163 |
+
tl.scenes.forEach((sc) => {
|
| 164 |
+
const x = m + (W - 2 * m) * (sc.start / tl.duration)
|
| 165 |
+
dot(c, x, y, sc.key === s.key ? 4.5 : 3, t >= sc.start ? C.gold : C.dim, 0.9)
|
| 166 |
+
})
|
| 167 |
+
c.restore()
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
// ---------- 字幕 ----------
|
| 171 |
+
function subtitle(c: Ctx, W: number, H: number, P: boolean, t: number, tl: Timeline) {
|
| 172 |
+
const ln = tl.lines.find((l) => t >= l.start - 0.1 && t < l.end + 0.3)
|
| 173 |
+
if (!ln) return
|
| 174 |
+
const a = Math.min(prog(t, ln.start - 0.1, 0.18), 1 - prog(t, ln.end + 0.12, 0.18))
|
| 175 |
+
const size = P ? 44 : 38
|
| 176 |
+
const maxW = P ? W - 160 : W - 400
|
| 177 |
+
const ls = wrap(c, ln.text, maxW, size, 500)
|
| 178 |
+
const lh = size * (P ? 1.42 : 1.36)
|
| 179 |
+
// 竖屏:首行固定、向下换行(不压住画面主体);横屏:最多两行,贴底
|
| 180 |
+
const y0 = P ? H - 330 : ls.length > 1 ? H - 92 - lh / 2 : H - 92
|
| 181 |
+
const base = y0 + (ls.length - 1) * lh
|
| 182 |
+
c.save()
|
| 183 |
+
c.globalAlpha = a
|
| 184 |
+
const grd = c.createLinearGradient(0, y0 - lh * 1.6, 0, base + lh)
|
| 185 |
+
grd.addColorStop(0, 'rgba(7,8,12,0)')
|
| 186 |
+
grd.addColorStop(1, 'rgba(7,8,12,0.6)')
|
| 187 |
+
c.fillStyle = grd
|
| 188 |
+
c.fillRect(0, y0 - lh * 1.6, W, base + lh - (y0 - lh * 1.6))
|
| 189 |
+
ls.forEach((s, k) => T(c, s, W / 2, y0 + k * lh, { size, w: 500, align: 'center', color: C.ink, shadow: 14 }))
|
| 190 |
+
c.restore()
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
export { SERIF }
|
kkndme/frontend/src/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 11 |
+
shineText,
|
| 12 |
+
roll,
|
| 13 |
+
kicker,
|
| 14 |
+
glass,
|
| 15 |
+
card3d,
|
| 16 |
+
chip,
|
| 17 |
+
ring,
|
| 18 |
+
glowDot,
|
| 19 |
+
sweepBand,
|
| 20 |
+
hbar,
|
| 21 |
+
vbar,
|
| 22 |
+
pulse,
|
| 23 |
+
shine,
|
| 24 |
+
C,
|
| 25 |
+
T,
|
| 26 |
+
clamp,
|
| 27 |
+
lerp,
|
| 28 |
+
prog,
|
| 29 |
+
eo,
|
| 30 |
+
eo5,
|
| 31 |
+
eio,
|
| 32 |
+
eback,
|
| 33 |
+
hexA,
|
| 34 |
+
rr,
|
| 35 |
+
dot,
|
| 36 |
+
line,
|
| 37 |
+
measure,
|
| 38 |
+
} from './kit'
|
| 39 |
+
import { STATUS_COLOR, wrap } from './draw'
|
| 40 |
+
import { SALES } from './series'
|
| 41 |
+
import { rows, all, strict, weighted, subCounts } from '../data/science'
|
| 42 |
+
|
| 43 |
+
const seed = (i: number, n: number) => {
|
| 44 |
+
const v = Math.sin(i * 91.7 + n * 47.3) * 24634.6345
|
| 45 |
+
return v - Math.floor(v)
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
// ============ 序章 ============
|
| 49 |
+
export function intro(g: G) {
|
| 50 |
+
const { c, W, H, P } = g
|
| 51 |
+
const { M } = lay(g)
|
| 52 |
+
|
| 53 |
+
// —— 0:2010 年 8 月 · 帖子
|
| 54 |
+
withA(c, vis(g, 0, 1), () => {
|
| 55 |
+
const x = P ? 80 : 180
|
| 56 |
+
const yk = P ? 500 : 380
|
| 57 |
+
kicker(c, 'TIANYA · 天涯社区 · 房产观澜', x, yk, C.gold, pin(g, 0, 0.1), P ? 24 : 22)
|
| 58 |
+
const yr = P ? 700 : 590
|
| 59 |
+
const size = P ? 210 : 220
|
| 60 |
+
const w = roll(c, '2010', x - 6, yr, { size, w: 900, f: 'serif' }, pinR(g, 0, 0.2, 1.8), (x0, ww) => shine(c, x0, ww, prog(g.lt(0), 2.2, 1.6) * 1.6 - 0.3, C.ink))
|
| 61 |
+
T(c, '.08', x - 6 + w + 10, yr, { size: size * 0.46, w: 900, f: 'serif', color: C.gold, p: pin(g, 0, 1.2) })
|
| 62 |
+
T(c, '一个网名叫 kkndme 的人,开始谈房价', x, yr + (P ? 80 : 74), { size: P ? 34 : 30, w: 500, color: C.mute, p: pin(g, 0, 1.6) })
|
| 63 |
+
// 帖子卡片
|
| 64 |
+
const cx = P ? 80 : 1000
|
| 65 |
+
const cy = P ? 900 : 300
|
| 66 |
+
const cw = P ? 920 : 760
|
| 67 |
+
const chh = P ? 520 : 470
|
| 68 |
+
card3d(c, cx + cw / 2, cy + chh / 2, pin(g, 0, 0.6, 1.1), () => {
|
| 69 |
+
glass(c, cx, cy, cw, chh, 26)
|
| 70 |
+
dot(c, cx + 64, cy + 70, 30, hexA(C.gold, 0.2))
|
| 71 |
+
c.save()
|
| 72 |
+
c.strokeStyle = hexA(C.gold, 0.7)
|
| 73 |
+
c.lineWidth = 2
|
| 74 |
+
c.beginPath()
|
| 75 |
+
c.arc(cx + 64, cy + 70, 30, 0, Math.PI * 2)
|
| 76 |
+
c.stroke()
|
| 77 |
+
c.restore()
|
| 78 |
+
T(c, 'K', cx + 64, cy + 82, { size: 32, w: 900, f: 'serif', color: C.goldHi, align: 'center' })
|
| 79 |
+
T(c, 'kkndme', cx + 112, cy + 64, { size: 32, w: 700 })
|
| 80 |
+
T(c, '楼主 · 2010 年 8 月', cx + 112, cy + 98, { size: 22, w: 500, color: C.dim })
|
| 81 |
+
chip(c, '原帖节选', cx + cw - 36, cy + 72, 'wait', pin(g, 0, 1.2), 20, 'right')
|
| 82 |
+
line(c, cx + 34, cy + 138, cx + cw - 34, cy + 138, C.faint, 1.5)
|
| 83 |
+
const quote = '“未来10年还得涨……涨价幅度可能比之前更猛。”'
|
| 84 |
+
const qs = P ? 54 : 50
|
| 85 |
+
const ls = wrap(c, quote, cw - 90, qs, 900, 'serif')
|
| 86 |
+
const tp = prog(g.lt(0), 1.0, 3.4)
|
| 87 |
+
let n = Math.floor(Array.from(quote).length * tp)
|
| 88 |
+
ls.forEach((s, k) => {
|
| 89 |
+
const ch = Array.from(s)
|
| 90 |
+
const show = ch.slice(0, Math.max(0, n)).join('')
|
| 91 |
+
n -= ch.length
|
| 92 |
+
if (show) T(c, show, cx + 46, cy + 230 + k * qs * 1.45, { size: qs, w: 900, f: 'serif' })
|
| 93 |
+
if (n < 0 && n > -ch.length - 1 && tp < 1 && Math.floor(g.t * 2.5) % 2 === 0) {
|
| 94 |
+
const wv = measure(c, show, qs, 900, 'serif')
|
| 95 |
+
c.fillStyle = C.gold
|
| 96 |
+
c.fillRect(cx + 50 + wv, cy + 230 + k * qs * 1.45 - qs * 0.82, 4, qs)
|
| 97 |
+
}
|
| 98 |
+
})
|
| 99 |
+
T(c, '—— 帖子后来被网友整理成 500 多页的合集', cx + 46, cy + chh - 44, { size: P ? 26 : 22, w: 500, color: C.dim, p: pin(g, 0, 4.6) })
|
| 100 |
+
})
|
| 101 |
+
})
|
| 102 |
+
|
| 103 |
+
// —— 1:均价十年近翻倍
|
| 104 |
+
withA(c, vis(g, 1, 2), () => {
|
| 105 |
+
const x = P ? 80 : 180
|
| 106 |
+
kicker(c, '全国商品房平均售价 · 元/㎡', x, P ? 500 : 380, C.gold, pin(g, 1, 0), P ? 24 : 22)
|
| 107 |
+
const big = P ? 200 : 200
|
| 108 |
+
const yb = P ? 700 : 590
|
| 109 |
+
roll(c, '9860', x - 4, yb, { size: big, w: 900, f: 'serif' }, pinR(g, 1, 3.2, 1.6), (x0, ww) => shine(c, x0, ww, prog(g.lt(1), 4.6, 1.4) * 1.6 - 0.3))
|
| 110 |
+
T(c, '2020 年 · 比 2010 年的 5032 元高出 96%', x, yb + (P ? 76 : 70), { size: P ? 32 : 30, w: 500, color: C.mute, p: pin(g, 1, 4.0) })
|
| 111 |
+
chip(c, '十年近乎翻倍', x, yb + (P ? 150 : 140), 'mid', pin(g, 1, 4.6), P ? 26 : 24)
|
| 112 |
+
// 三根柱
|
| 113 |
+
const data = [
|
| 114 |
+
{ y: '2000', v: 2112 },
|
| 115 |
+
{ y: '2010', v: 5032, tag: 'kkndme 发帖' },
|
| 116 |
+
{ y: '2020', v: 9860 },
|
| 117 |
+
]
|
| 118 |
+
const base = P ? 1450 : 840
|
| 119 |
+
const maxH = P ? 480 : 470
|
| 120 |
+
const bw = P ? 170 : 130
|
| 121 |
+
const x0 = P ? 160 : 1060
|
| 122 |
+
const gap = P ? 290 : 230
|
| 123 |
+
line(c, x0 - 40, base, x0 + gap * 2 + bw + 40, base, 'rgba(243,238,228,0.25)', 1.5)
|
| 124 |
+
data.forEach((d, i) => {
|
| 125 |
+
const bx = x0 + i * gap
|
| 126 |
+
const p = pinR(g, 1, i === 0 ? 0.3 : i === 1 ? 0.9 : 3.0, 1.1)
|
| 127 |
+
const top = vbar(c, bx, base, bw, (d.v / 10000) * maxH, i === 2 ? C.gold : i === 1 ? '#B89A62' : '#6D6250', p)
|
| 128 |
+
roll(c, d.v.toLocaleString('en-US'), bx + bw / 2, top - 18, { size: P ? 40 : 36, w: 700, f: 'sans', align: 'center', color: i === 2 ? C.goldHi : C.ink }, p)
|
| 129 |
+
T(c, d.y, bx + bw / 2, base + 44, { size: P ? 30 : 26, w: 700, color: C.mute, align: 'center', p })
|
| 130 |
+
if (d.tag) {
|
| 131 |
+
T(c, d.tag, bx + bw / 2, top - 70, { size: P ? 24 : 22, w: 700, color: C.gold, align: 'center', p: pin(g, 1, 1.6) })
|
| 132 |
+
}
|
| 133 |
+
})
|
| 134 |
+
})
|
| 135 |
+
|
| 136 |
+
// —— 2:房地产圣经 → 2021 反转
|
| 137 |
+
withA(c, vis(g, 2, 3), () => {
|
| 138 |
+
const cy = H * (P ? 0.42 : 0.46)
|
| 139 |
+
const flip = eo(prog(g.lt(2), 3.5, 0.8))
|
| 140 |
+
kicker(c, '被无数人奉为', W / 2, cy - (P ? 190 : 180), C.mute, pin(g, 2, 0.2), P ? 26 : 24, 'center')
|
| 141 |
+
const size = P ? 168 : 190
|
| 142 |
+
c.save()
|
| 143 |
+
c.globalAlpha *= 1 - flip * 0.6
|
| 144 |
+
charText(c, '“房地产圣经”', W / 2, cy, { size, w: 900, f: 'serif', align: 'center', color: shine(c, W / 2 - size * 3, size * 6, prog(g.lt(2), 1.3, 1.4) * 1.6 - 0.3) }, pinR(g, 2, 0.3, 1.2), 0.08)
|
| 145 |
+
c.restore()
|
| 146 |
+
if (flip > 0) {
|
| 147 |
+
const lw = (P ? 900 : 1150) * eio(flip)
|
| 148 |
+
line(c, W / 2 - lw / 2, cy - size * 0.32, W / 2 + lw / 2, cy - size * 0.32, C.red, 6)
|
| 149 |
+
const yy = cy + (P ? 190 : 170)
|
| 150 |
+
T(c, '2021 年之后,剧情反转', W / 2, yy, { size: P ? 56 : 54, w: 900, f: 'serif', align: 'center', color: C.red, p: flip })
|
| 151 |
+
glowDot(c, W / 2, yy + 60, 6, C.red, flip * (0.6 + 0.4 * Math.sin(g.t * 6)))
|
| 152 |
+
}
|
| 153 |
+
})
|
| 154 |
+
|
| 155 |
+
// —— 3:销售面积腰斩
|
| 156 |
+
withA(c, vis(g, 3, 4), () => {
|
| 157 |
+
const x = P ? 80 : 200
|
| 158 |
+
kicker(c, '全国商品房销售面积 · 亿平方米', x, P ? 470 : 330, C.gold, pin(g, 3, 0), P ? 24 : 22)
|
| 159 |
+
const base = P ? 1400 : 840
|
| 160 |
+
const maxH = P ? 640 : 440
|
| 161 |
+
const x0 = P ? 110 : 220
|
| 162 |
+
const span = P ? 860 : 1480
|
| 163 |
+
const n = SALES.length
|
| 164 |
+
const step = span / n
|
| 165 |
+
const bw = step * 0.62
|
| 166 |
+
line(c, x0 - 10, base, x0 + span, base, 'rgba(243,238,228,0.25)', 1.5)
|
| 167 |
+
const fall = prog(g.lt(3), 3.0, 1.8)
|
| 168 |
+
SALES.forEach((v, i) => {
|
| 169 |
+
const bx = x0 + i * step
|
| 170 |
+
const after = i > 11
|
| 171 |
+
const p = after ? clamp(fall * n * 0.25 - (i - 12) * 0.8) : pinR(g, 3, 0.2 + i * 0.12, 0.8)
|
| 172 |
+
const col = after ? C.red : i === 11 ? C.goldHi : '#A98B57'
|
| 173 |
+
const top = vbar(c, bx, base, bw, (v / 20) * maxH, col, p, i === 11 || i === 15)
|
| 174 |
+
if ([0, 3, 6, 9, 11, 15].includes(i)) T(c, String(2010 + i), bx + bw / 2, base + (P ? 40 : 36), { size: P ? 24 : 22, w: 500, color: C.dim, align: 'center', p })
|
| 175 |
+
if (i === 11) {
|
| 176 |
+
T(c, '17.94', bx + bw / 2, top - 22, { size: P ? 40 : 38, w: 900, f: 'serif', color: C.goldHi, align: 'center', p })
|
| 177 |
+
T(c, '2021 峰值', bx + bw / 2, top - (P ? 72 : 68), { size: P ? 24 : 22, w: 700, color: C.gold, align: 'center', p: pin(g, 3, 1.8) })
|
| 178 |
+
}
|
| 179 |
+
if (i === 15) T(c, '8.81', bx + bw / 2, top - 22, { size: P ? 40 : 38, w: 900, f: 'serif', color: C.red, align: 'center', p })
|
| 180 |
+
})
|
| 181 |
+
// 跌幅括号
|
| 182 |
+
const pk = x0 + 11 * step + bw / 2
|
| 183 |
+
const ed = x0 + 15 * step + bw / 2
|
| 184 |
+
const bp = eo(prog(g.lt(3), 4.6, 0.8))
|
| 185 |
+
if (bp > 0) {
|
| 186 |
+
const yb = base - (17.94 / 20) * maxH - (P ? 130 : 120)
|
| 187 |
+
line(c, pk, yb, lerp(pk, ed, bp), yb, C.red, 2.5, 1, [6, 6])
|
| 188 |
+
T(c, '−51%', (pk + ed) / 2, yb - 18, { size: P ? 58 : 60, w: 900, f: 'serif', color: C.red, align: 'center', p: bp })
|
| 189 |
+
}
|
| 190 |
+
})
|
| 191 |
+
|
| 192 |
+
// —— 4:片名
|
| 193 |
+
withA(c, vis(g, 4), () => {
|
| 194 |
+
const cy = H * (P ? 0.4 : 0.44)
|
| 195 |
+
kicker(c, 'KKNDME · 2010 — 2026 · A FIFTEEN-YEAR AUDIT', W / 2, cy - (P ? 250 : 210), C.gold, pin(g, 4, 0.2), P ? 22 : 22, 'center')
|
| 196 |
+
const size = P ? 150 : 128
|
| 197 |
+
if (P) {
|
| 198 |
+
maskText(c, '神贴十五年', W / 2, cy, { size, w: 900, f: 'serif', align: 'center' }, pinR(g, 4, 0.4, 1.0))
|
| 199 |
+
maskText(c, '一笔一笔对账', W / 2, cy + size * 1.2, { size: size * 0.72, w: 900, f: 'serif', align: 'center', color: shine(c, 140, 800, prog(g.lt(4), 2.2, 1.6) * 1.6 - 0.3) }, pinR(g, 4, 0.9, 1.0))
|
| 200 |
+
} else {
|
| 201 |
+
maskText(c, '神贴十五年,一笔一笔对账', W / 2, cy, { size, w: 900, f: 'serif', align: 'center', color: shine(c, 0, W, prog(g.lt(4), 2.2, 1.6) * 1.6 - 0.3, C.ink, C.goldHi) }, pinR(g, 4, 0.4, 1.1))
|
| 202 |
+
}
|
| 203 |
+
const ly = cy + (P ? size * 1.2 + 90 : 90)
|
| 204 |
+
const lw = (P ? 760 : 1100) * eio(prog(g.lt(4), 1.0, 1.4))
|
| 205 |
+
line(c, W / 2 - lw / 2, ly, W / 2 + lw / 2, ly, C.gold, 1.5, 0.8)
|
| 206 |
+
const pills = ['986 页原文', '123 条预测', '核对至 2026.10']
|
| 207 |
+
const pw = P ? 290 : 300
|
| 208 |
+
pills.forEach((s, i) => {
|
| 209 |
+
const px = W / 2 + (i - 1) * (pw + 30)
|
| 210 |
+
const p = pin(g, 4, 1.6 + i * 0.2)
|
| 211 |
+
withA(c, p, () => {
|
| 212 |
+
glass(c, px - pw / 2, ly + 50, pw, 76, 38)
|
| 213 |
+
T(c, s, px, ly + 99, { size: P ? 30 : 28, w: 700, align: 'center', color: i === 1 ? C.goldHi : C.ink })
|
| 214 |
+
})
|
| 215 |
+
})
|
| 216 |
+
})
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
// ============ 方法 ============
|
| 220 |
+
const DOTS = rows.map((r, i) => ({ i, status: r.status, color: STATUS_COLOR[r.status] }))
|
| 221 |
+
const ORDER = ['correct', 'wrong', 'disputed', 'pending_lean', 'pending_against', 'pending_neutral']
|
| 222 |
+
|
| 223 |
+
function gridPos(g: G, i: number) {
|
| 224 |
+
const cols = g.P ? 12 : 16
|
| 225 |
+
const sp = g.P ? 70 : 50
|
| 226 |
+
const rowsN = Math.ceil(DOTS.length / cols)
|
| 227 |
+
const x0 = g.P ? g.W / 2 - ((cols - 1) * sp) / 2 : 1340 - ((cols - 1) * sp) / 2
|
| 228 |
+
const y0 = (g.P ? 1160 : 590) - ((rowsN - 1) * sp) / 2
|
| 229 |
+
return { x: x0 + (i % cols) * sp, y: y0 + Math.floor(i / cols) * sp, r: g.P ? 16 : 12 }
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
const LAYERS = [
|
| 233 |
+
{ t: '具体程度', en: 'SPECIFICITY', o: '模糊判断 · 方向明确 · 带数字或期限' },
|
| 234 |
+
{ t: '共识程度', en: 'CONSENSUS', o: '顺共识 · 中性 · 逆共识' },
|
| 235 |
+
{ t: '预测类型', en: 'TYPE', o: '政策 · 城市 · 趋势 · 宏观 · 时间点 · 幅度' },
|
| 236 |
+
{ t: '证据强度', en: 'EVIDENCE', o: '官方数据 · 权威报道 · 间接推算' },
|
| 237 |
+
]
|
| 238 |
+
|
| 239 |
+
export function method(g: G) {
|
| 240 |
+
const { c, W, H, P } = g
|
| 241 |
+
const { M } = lay(g)
|
| 242 |
+
// —— 0:986 页
|
| 243 |
+
withA(c, vis(g, 0, 1), () => {
|
| 244 |
+
const bx = P ? 540 : 640
|
| 245 |
+
const by = P ? 1040 : 760
|
| 246 |
+
const n = 26
|
| 247 |
+
for (let k = 0; k < n; k++) {
|
| 248 |
+
const p = pinR(g, 0, 0.2 + k * 0.07, 0.6)
|
| 249 |
+
if (p <= 0) continue
|
| 250 |
+
const y = by - k * (P ? 15 : 14) - (1 - eback(p)) * 90
|
| 251 |
+
const w = P ? 520 : 460
|
| 252 |
+
const h = P ? 70 : 62
|
| 253 |
+
const col = k < 12 ? 'rgba(243,238,228,' : 'rgba(216,178,110,'
|
| 254 |
+
c.save()
|
| 255 |
+
c.globalAlpha *= clamp(p * 2)
|
| 256 |
+
c.beginPath()
|
| 257 |
+
c.moveTo(bx - w / 2, y)
|
| 258 |
+
c.lineTo(bx - w / 2 + 70, y - h)
|
| 259 |
+
c.lineTo(bx + w / 2 + 70, y - h)
|
| 260 |
+
c.lineTo(bx + w / 2, y)
|
| 261 |
+
c.closePath()
|
| 262 |
+
c.fillStyle = col + (k === n - 1 ? '0.16)' : '0.05)')
|
| 263 |
+
c.fill()
|
| 264 |
+
c.strokeStyle = col + '0.45)'
|
| 265 |
+
c.lineWidth = 1.2
|
| 266 |
+
c.stroke()
|
| 267 |
+
c.restore()
|
| 268 |
+
}
|
| 269 |
+
// 顶页文字
|
| 270 |
+
withA(c, pin(g, 0, 2.2), () => {
|
| 271 |
+
const y = by - (n - 1) * (P ? 15 : 14)
|
| 272 |
+
T(c, '天涯 kkndme 神贴', bx + 35, y - (P ? 28 : 24), { size: P ? 26 : 22, w: 700, color: C.ink, align: 'center' })
|
| 273 |
+
})
|
| 274 |
+
const x = P ? 80 : 1080
|
| 275 |
+
const yk = P ? 1170 : 400
|
| 276 |
+
kicker(c, 'SOURCE · 通读原文', x, yk, C.gold, pin(g, 0, 0.2), P ? 24 : 22)
|
| 277 |
+
const w = roll(c, '986', x - 6, yk + (P ? 200 : 210), { size: P ? 200 : 220, w: 900, f: 'serif' }, pinR(g, 0, 0.3, 1.8), (x0, ww) => shine(c, x0, ww, prog(g.lt(0), 2.4, 1.4) * 1.6 - 0.3))
|
| 278 |
+
T(c, '页', x + w + 6, yk + (P ? 200 : 210), { size: P ? 64 : 70, w: 900, f: 'serif', color: C.gold, p: pin(g, 0, 1.4) })
|
| 279 |
+
const ry = yk + (P ? 280 : 300)
|
| 280 |
+
;[
|
| 281 |
+
['天涯原帖(含网友回复)', '480 页'],
|
| 282 |
+
['kk 发言整理合集', '506 页'],
|
| 283 |
+
].forEach(([a, b], i) => {
|
| 284 |
+
const p = pin(g, 0, 2.0 + i * 0.3)
|
| 285 |
+
T(c, a, x, ry + i * (P ? 56 : 54), { size: P ? 32 : 30, w: 500, color: C.mute, p })
|
| 286 |
+
T(c, b, x + (P ? 600 : 560), ry + i * (P ? 56 : 54), { size: P ? 32 : 30, w: 700, color: C.ink, align: 'right', p })
|
| 287 |
+
})
|
| 288 |
+
})
|
| 289 |
+
|
| 290 |
+
// —— 1–2:43 理论 / 123 预测点阵 + 扫描核对
|
| 291 |
+
const aGrid = vis(g, 1, 3)
|
| 292 |
+
withA(c, aGrid, () => {
|
| 293 |
+
const scan = prog(g.lt(2), 0.4, 3.4)
|
| 294 |
+
const gp0 = gridPos(g, 0)
|
| 295 |
+
const gpN = gridPos(g, DOTS.length - 1)
|
| 296 |
+
const sy = lerp(gp0.y - 40, gpN.y + 40, eio(scan))
|
| 297 |
+
DOTS.forEach((d, i) => {
|
| 298 |
+
const gp = gridPos(g, i)
|
| 299 |
+
const p = pinR(g, 1, 2.2 + i * 0.012, 0.5)
|
| 300 |
+
if (p <= 0) return
|
| 301 |
+
const scanned = scan > 0 && gp.y < sy
|
| 302 |
+
const col = scanned ? d.color : C.gold
|
| 303 |
+
const r = gp.r * lerp(0.2, 1, eback(p))
|
| 304 |
+
dot(c, gp.x, gp.y, r, col, scanned ? 0.95 : 0.35 + 0.25 * p)
|
| 305 |
+
if (!scanned) {
|
| 306 |
+
c.save()
|
| 307 |
+
c.strokeStyle = hexA(C.gold, 0.5)
|
| 308 |
+
c.lineWidth = 1.5
|
| 309 |
+
c.beginPath()
|
| 310 |
+
c.arc(gp.x, gp.y, r, 0, Math.PI * 2)
|
| 311 |
+
c.stroke()
|
| 312 |
+
c.restore()
|
| 313 |
+
}
|
| 314 |
+
})
|
| 315 |
+
if (scan > 0 && scan < 1) {
|
| 316 |
+
const x0 = gp0.x - 40
|
| 317 |
+
const x1 = gridPos(g, (P ? 12 : 16) - 1).x + 40
|
| 318 |
+
const grd = c.createLinearGradient(0, sy - 60, 0, sy)
|
| 319 |
+
grd.addColorStop(0, hexA(C.goldHi, 0))
|
| 320 |
+
grd.addColorStop(1, hexA(C.goldHi, 0.16))
|
| 321 |
+
c.fillStyle = grd
|
| 322 |
+
c.fillRect(x0, sy - 60, x1 - x0, 60)
|
| 323 |
+
line(c, x0, sy, x1, sy, C.goldHi, 2, 0.9)
|
| 324 |
+
}
|
| 325 |
+
})
|
| 326 |
+
withA(c, vis(g, 1, 2), () => {
|
| 327 |
+
const blocks = [
|
| 328 |
+
{ n: '43', l: '条核心理论', s: '房价、货币、城市、调控的底层逻辑' },
|
| 329 |
+
{ n: '123', l: '条可核对预测', s: '有明确对象、可以拿事实检验' },
|
| 330 |
+
]
|
| 331 |
+
blocks.forEach((b, i) => {
|
| 332 |
+
const x = P ? 80 : 180
|
| 333 |
+
const y = P ? 680 + i * 330 : 470 + i * 270
|
| 334 |
+
const p = pinR(g, 1, i === 0 ? 0.6 : 2.0, 1.4)
|
| 335 |
+
const w = roll(c, b.n, x - 4, y, { size: P ? 170 : 180, w: 900, f: 'serif', color: i ? C.goldHi : C.ink }, p)
|
| 336 |
+
T(c, b.l, x + w + 14, y, { size: P ? 40 : 44, w: 900, f: 'serif', color: i ? C.gold : C.ink, p: eo(p) })
|
| 337 |
+
T(c, b.s, x, y + (P ? 64 : 62), { size: P ? 26 : 26, w: 500, color: C.dim, p: eo(prog(p, 0.4, 0.6)) })
|
| 338 |
+
})
|
| 339 |
+
})
|
| 340 |
+
withA(c, vis(g, 2, 3), () => {
|
| 341 |
+
const x = P ? 80 : 180
|
| 342 |
+
const y0 = P ? 470 : 360
|
| 343 |
+
kicker(c, 'VERIFY · 逐条对照', x, y0, C.gold, pin(g, 2, 0), P ? 24 : 22)
|
| 344 |
+
const src = ['国家统计局', '中国人民银行', '国际清算银行 BIS', '美联储 FRED', '政府文件 · 法院公告', '权威媒体报道']
|
| 345 |
+
src.forEach((s, i) => {
|
| 346 |
+
const cols = P ? 3 : 1
|
| 347 |
+
const sx0 = x + (i % cols) * (P ? 310 : 0)
|
| 348 |
+
const sy0 = y0 + (P ? 60 : 70) + Math.floor(i / cols) * (P ? 84 : 76)
|
| 349 |
+
const p = pin(g, 2, 0.5 + i * 0.25, 0.6)
|
| 350 |
+
withA(c, p, () => {
|
| 351 |
+
const wv = P ? 290 : measure(c, s, 30, 700) + 64
|
| 352 |
+
glass(c, sx0, sy0 - 4 + (1 - p) * 20, wv, 60, 30)
|
| 353 |
+
dot(c, sx0 + 28, sy0 + 26 + (1 - p) * 20, 6, C.gold)
|
| 354 |
+
T(c, s, sx0 + 46, sy0 + 37 + (1 - p) * 20, { size: P ? 26 : 30, w: 700 })
|
| 355 |
+
})
|
| 356 |
+
})
|
| 357 |
+
// 截止印章
|
| 358 |
+
const sp = pin(g, 2, 4.4, 0.6)
|
| 359 |
+
if (sp > 0) {
|
| 360 |
+
const stx = P ? 760 : 720
|
| 361 |
+
const sty = P ? 410 : 840
|
| 362 |
+
c.save()
|
| 363 |
+
c.globalAlpha *= clamp(sp * 1.5)
|
| 364 |
+
c.translate(stx, sty)
|
| 365 |
+
c.rotate(-0.08)
|
| 366 |
+
c.scale(lerp(1.6, 1, eback(sp)), lerp(1.6, 1, eback(sp)))
|
| 367 |
+
const sw = P ? 260 : 280
|
| 368 |
+
rr(c, -sw / 2, -44, sw, 88, 10)
|
| 369 |
+
c.strokeStyle = hexA(C.red, 0.85)
|
| 370 |
+
c.lineWidth = 3
|
| 371 |
+
c.stroke()
|
| 372 |
+
rr(c, -sw / 2 + 7, -37, sw - 14, 74, 6)
|
| 373 |
+
c.lineWidth = 1.2
|
| 374 |
+
c.stroke()
|
| 375 |
+
T(c, '核对截至', 0, -6, { size: 20, w: 700, color: C.red, align: 'center', ls: 6 })
|
| 376 |
+
T(c, '2026 · 10', 0, 30, { size: 34, w: 900, f: 'serif', color: C.red, align: 'center' })
|
| 377 |
+
c.restore()
|
| 378 |
+
}
|
| 379 |
+
})
|
| 380 |
+
|
| 381 |
+
// —— 3:四层标签
|
| 382 |
+
withA(c, vis(g, 3), () => {
|
| 383 |
+
const x = P ? 80 : 180
|
| 384 |
+
kicker(c, 'CODING · 四层标签', x, P ? 470 : 330, C.gold, pin(g, 3, 0), P ? 24 : 22)
|
| 385 |
+
LAYERS.forEach((L, i) => {
|
| 386 |
+
const p = pinR(g, 3, [1.4, 3.0, 4.6, 6.0][i] - 0.4, 0.8)
|
| 387 |
+
if (p <= 0) return
|
| 388 |
+
const q = eback(p)
|
| 389 |
+
const h = P ? 210 : 108
|
| 390 |
+
const y = P ? 540 + i * 235 : 380 + i * 128
|
| 391 |
+
const sk = P ? 0 : 40
|
| 392 |
+
const w = P ? 920 : 1560
|
| 393 |
+
const xx = x + (1 - q) * 80
|
| 394 |
+
c.save()
|
| 395 |
+
c.globalAlpha *= clamp(p * 2)
|
| 396 |
+
c.beginPath()
|
| 397 |
+
c.moveTo(xx + sk, y)
|
| 398 |
+
c.lineTo(xx + w, y)
|
| 399 |
+
c.lineTo(xx + w - sk, y + h)
|
| 400 |
+
c.lineTo(xx, y + h)
|
| 401 |
+
c.closePath()
|
| 402 |
+
const gr = c.createLinearGradient(xx, 0, xx + w, 0)
|
| 403 |
+
gr.addColorStop(0, hexA(C.gold, 0.16 - i * 0.025))
|
| 404 |
+
gr.addColorStop(1, 'rgba(255,255,255,0.02)')
|
| 405 |
+
c.fillStyle = gr
|
| 406 |
+
c.fill()
|
| 407 |
+
c.strokeStyle = hexA(C.gold, 0.4)
|
| 408 |
+
c.lineWidth = 1.5
|
| 409 |
+
c.stroke()
|
| 410 |
+
T(c, `0${i + 1}`, xx + sk + 34, y + (P ? 74 : 70), { size: P ? 54 : 50, w: 900, f: 'serif', color: C.gold })
|
| 411 |
+
T(c, L.t, xx + sk + (P ? 130 : 140), y + (P ? 72 : 68), { size: P ? 46 : 42, w: 900, f: 'serif' })
|
| 412 |
+
kicker(c, L.en, xx + sk + (P ? 132 : 340), P ? y + 112 : y + 64, C.dim, 1, P ? 18 : 18)
|
| 413 |
+
T(c, L.o, P ? xx + 34 : xx + w - sk - 40, y + (P ? 170 : 68), { size: P ? 30 : 30, w: 500, color: C.mute, align: P ? 'left' : 'right' })
|
| 414 |
+
c.restore()
|
| 415 |
+
})
|
| 416 |
+
})
|
| 417 |
+
}
|
| 418 |
+
|
| 419 |
+
// ============ 总成绩 ============
|
| 420 |
+
const byStatus = [...DOTS].sort((a, b) => ORDER.indexOf(a.status) - ORDER.indexOf(b.status) || a.i - b.i)
|
| 421 |
+
const clusterOf = (s: string) => (s.startsWith('pending') ? 3 : ORDER.indexOf(s))
|
| 422 |
+
const CL = [
|
| 423 |
+
{ label: '说对', n: all.correct, color: C.green },
|
| 424 |
+
{ label: '说错', n: all.wrong, color: C.red },
|
| 425 |
+
{ label: '对错参半', n: all.disputed, color: C.amber },
|
| 426 |
+
{ label: '未到期', n: 10, color: C.blue },
|
| 427 |
+
]
|
| 428 |
+
function clusterPos(g: G, d: (typeof DOTS)[number]) {
|
| 429 |
+
const k = clusterOf(d.status)
|
| 430 |
+
const members = byStatus.filter((x) => clusterOf(x.status) === k)
|
| 431 |
+
const j = members.indexOf(d)
|
| 432 |
+
const cols = g.P ? 7 : 8
|
| 433 |
+
const sp = g.P ? 36 : 36
|
| 434 |
+
const cc = g.P ? { x: g.W * (k % 2 ? 0.73 : 0.27), y: k < 2 ? 760 : 1260 } : { x: 300 + k * 440, y: 610 }
|
| 435 |
+
return { x: cc.x - ((cols - 1) * sp) / 2 + (j % cols) * sp, y: cc.y + Math.floor(j / cols) * sp, r: g.P ? 12 : 12, k, cc }
|
| 436 |
+
}
|
| 437 |
+
|
| 438 |
+
const SUBS = [
|
| 439 |
+
{ parent: '说对', n: all.correct, color: C.green, items: [['E', '精准命中'], ['D', '方向命中'], ['T', '顺势命中']] },
|
| 440 |
+
{ parent: '说错', n: all.wrong, color: C.red, items: [['R', '方向判反'], ['M', '幅度高估'], ['S', '时点过早'], ['A', '绝对化被证伪']] },
|
| 441 |
+
{ parent: '对错参半', n: all.disputed, color: C.amber, items: [['H', '一半对一半错'], ['W', '随时间翻转'], ['V', '表述模糊'], ['C', '口径不足']] },
|
| 442 |
+
]
|
| 443 |
+
const subN = (k: string) => subCounts.find((x) => x.k === k)?.n ?? 0
|
| 444 |
+
|
| 445 |
+
const topicStat = (topics: string[]) => {
|
| 446 |
+
const rs = rows.filter((r) => topics.includes(r.topic))
|
| 447 |
+
const k = (s: string) => rs.filter((r) => (s === 'pending' ? r.status.startsWith('pending') : r.status === s)).length
|
| 448 |
+
return { n: rs.length, c: k('correct'), w: k('wrong'), d: k('disputed'), p: k('pending') }
|
| 449 |
+
}
|
| 450 |
+
const FIELDS = [
|
| 451 |
+
{ no: '04', t: '房价', s: 'BIS 房价指数', st: topicStat(['房价走势']) },
|
| 452 |
+
{ no: '05', t: '城市', s: '23 座城市点名', st: topicStat(['北京与一线', '二三线与城市']) },
|
| 453 |
+
{ no: '06', t: '货币', s: 'M2 · CPI · 汇率', st: topicStat(['通胀与货币', '人民币汇率']) },
|
| 454 |
+
{ no: '07', t: '政策', s: '限购 · 房产税 · 产权', st: topicStat(['调控与房产税']) },
|
| 455 |
+
{ no: '10', t: '盲区', s: '租金 · 人口 · 利率', st: topicStat(['租金与保障房', '社会与人口']) },
|
| 456 |
+
]
|
| 457 |
+
|
| 458 |
+
export function score(g: G) {
|
| 459 |
+
const { c, W, H, P } = g
|
| 460 |
+
const { M } = lay(g)
|
| 461 |
+
// —— 0:聚类
|
| 462 |
+
withA(c, vis(g, 0, 1), () => {
|
| 463 |
+
DOTS.forEach((d) => {
|
| 464 |
+
const cp = clusterPos(g, d)
|
| 465 |
+
const delay = 0.3 + cp.k * 0.9 + seed(d.i, 3) * 0.5
|
| 466 |
+
const p = eo5(pinR(g, 0, delay, 1.1))
|
| 467 |
+
if (p <= 0) return
|
| 468 |
+
const sx0 = W * seed(d.i, 1)
|
| 469 |
+
const sy0 = H * (0.25 + 0.5 * seed(d.i, 2))
|
| 470 |
+
dot(c, lerp(sx0, cp.x, p), lerp(sy0, cp.y, p), cp.r * lerp(0.4, 1, p), d.color, clamp(p * 2))
|
| 471 |
+
})
|
| 472 |
+
CL.forEach((cl, k) => {
|
| 473 |
+
const cc = P ? { x: W * (k % 2 ? 0.73 : 0.27), y: k < 2 ? 760 : 1260 } : { x: 300 + k * 440, y: 610 }
|
| 474 |
+
const p = pinR(g, 0, 0.4 + k * 0.9, 1.3)
|
| 475 |
+
roll(c, String(cl.n), cc.x, cc.y - (P ? 60 : 70), { size: P ? 120 : 130, w: 900, f: 'serif', align: 'center', color: cl.color }, p)
|
| 476 |
+
T(c, cl.label, cc.x, cc.y - (P ? 200 : 220), { size: P ? 36 : 34, w: 700, align: 'center', color: C.ink, p: eo(p) })
|
| 477 |
+
})
|
| 478 |
+
T(c, '123 条预测 · 按判定结果归类', W / 2, P ? 520 : 340, { size: P ? 30 : 28, w: 500, color: C.mute, align: 'center', p: pin(g, 0, 0.1), ls: 4 })
|
| 479 |
+
})
|
| 480 |
+
|
| 481 |
+
// —— 1:63% 环
|
| 482 |
+
withA(c, vis(g, 1, 2), () => {
|
| 483 |
+
const cx = P ? 540 : 640
|
| 484 |
+
const cy = P ? 820 : 590
|
| 485 |
+
const r = P ? 250 : 230
|
| 486 |
+
const p = pinR(g, 1, 0.3, 2.2)
|
| 487 |
+
ring(c, cx, cy, r, P ? 38 : 34, [
|
| 488 |
+
{ v: all.correct, color: C.green },
|
| 489 |
+
{ v: all.wrong, color: C.red },
|
| 490 |
+
], p)
|
| 491 |
+
const w = roll(c, '63', cx - 30, cy + 54, { size: P ? 170 : 160, w: 900, f: 'serif', align: 'center' }, prog(g.lt(1), 0.8, 2), (x0, ww) => shine(c, x0, ww, prog(g.lt(1), 2.6, 1.2) * 1.6 - 0.3, C.ink))
|
| 492 |
+
T(c, '%', cx - 30 + w / 2 + 6, cy + 54, { size: P ? 80 : 74, w: 900, f: 'serif', color: C.gold, p: pin(g, 1, 1.6) })
|
| 493 |
+
T(c, '命中率', cx, cy - (P ? 110 : 100), { size: P ? 30 : 28, w: 700, color: C.mute, align: 'center', p: pin(g, 1, 0.6), ls: 6 })
|
| 494 |
+
const tx = P ? 80 : 1060
|
| 495 |
+
const ty = P ? 1200 : 430
|
| 496 |
+
kicker(c, 'HIT RATE · 只算能分对错的', tx, ty, C.gold, pin(g, 1, 0.4), P ? 24 : 22)
|
| 497 |
+
T(c, '51 ÷ (51 + 30) = 63%', tx, ty + (P ? 90 : 90), { size: P ? 58 : 60, w: 900, f: 'serif', p: pin(g, 1, 1.0) })
|
| 498 |
+
;[
|
| 499 |
+
['说对', '51 条', C.green],
|
| 500 |
+
['说错', '30 条', C.red],
|
| 501 |
+
['不计入:对错参半 32 · 未到期 10', '', C.dim],
|
| 502 |
+
].forEach(([a, b, col], i) => {
|
| 503 |
+
const p2 = pin(g, 1, 1.6 + i * 0.25)
|
| 504 |
+
const yy = ty + (P ? 170 : 180) + i * (P ? 60 : 62)
|
| 505 |
+
dot(c, tx + 10, yy - 10, 8, col, p2)
|
| 506 |
+
T(c, a, tx + 34, yy, { size: P ? 32 : 30, w: i === 2 ? 500 : 700, color: i === 2 ? C.dim : C.ink, p: p2 })
|
| 507 |
+
if (b) T(c, b, tx + (P ? 400 : 420), yy, { size: P ? 32 : 30, w: 700, color: col, align: 'right', p: p2 })
|
| 508 |
+
})
|
| 509 |
+
})
|
| 510 |
+
|
| 511 |
+
// —— 2:四种口径
|
| 512 |
+
withA(c, vis(g, 2, 3), () => {
|
| 513 |
+
const items = [
|
| 514 |
+
{ l: '只算能分对错的', s: '51 ÷ 81', v: all.hit, d: 0.2, col: C.gold },
|
| 515 |
+
{ l: '存疑全算错', s: '51 ÷ 113', v: strict, d: 2.2, col: C.red },
|
| 516 |
+
{ l: '存疑算半对', s: '(51 + 16) ÷ 113', v: all.partial, d: 4.4, col: C.amber },
|
| 517 |
+
{ l: '按难度和证据加权', s: '越具体、越逆共识权重越高', v: weighted, d: 6.4, col: C.blue },
|
| 518 |
+
]
|
| 519 |
+
kicker(c, 'FOUR WAYS TO SCORE · 换个口径,换个结论', P ? 80 : 180, P ? 470 : 330, C.gold, pin(g, 2, 0), P ? 24 : 22)
|
| 520 |
+
const bx = P ? 80 : 640
|
| 521 |
+
const bw = P ? 760 : 900
|
| 522 |
+
items.forEach((it, i) => {
|
| 523 |
+
const y = P ? 600 + i * 230 : 420 + i * 125
|
| 524 |
+
const p = pinR(g, 2, it.d, 1.2)
|
| 525 |
+
withA(c, eo(p), () => {
|
| 526 |
+
T(c, it.l, P ? 80 : 180, P ? y : y + 10, { size: P ? 40 : 36, w: 900, f: 'serif' })
|
| 527 |
+
T(c, it.s, P ? 80 : 180, P ? y + 46 : y + 50, { size: P ? 24 : 22, w: 500, color: C.dim })
|
| 528 |
+
const by = P ? y + 80 : y - 12
|
| 529 |
+
const end = hbar(c, bx, by, bw, P ? 30 : 28, it.v, it.col, p)
|
| 530 |
+
roll(c, (it.v * 100).toFixed(1), end + 22, by + (P ? 28 : 26), { size: P ? 44 : 44, w: 900, f: 'serif', color: C.ink }, p)
|
| 531 |
+
})
|
| 532 |
+
})
|
| 533 |
+
// 50% 参考线
|
| 534 |
+
const rx = bx + bw * 0.5
|
| 535 |
+
const top = P ? 660 : 380
|
| 536 |
+
const bot = P ? 1410 : 820
|
| 537 |
+
const lp = pin(g, 2, 0.8)
|
| 538 |
+
line(c, rx, top, rx, lerp(top, bot, lp), C.ink, 1.5, 0.35, [5, 7])
|
| 539 |
+
T(c, '抛硬币 50%', rx, top - 14, { size: P ? 22 : 20, w: 700, color: C.dim, align: 'center', p: lp })
|
| 540 |
+
})
|
| 541 |
+
|
| 542 |
+
// —— 3:判定细分
|
| 543 |
+
withA(c, vis(g, 3, 4), () => {
|
| 544 |
+
const x = P ? 80 : 180
|
| 545 |
+
kicker(c, 'WHY · 对在哪、错在哪', x, P ? 470 : 330, C.gold, pin(g, 3, 0), P ? 24 : 22)
|
| 546 |
+
const bx = P ? 80 : 480
|
| 547 |
+
const bw = P ? 920 : 1260
|
| 548 |
+
SUBS.forEach((sb, r) => {
|
| 549 |
+
const y = P ? 580 + r * 300 : 420 + r * 165
|
| 550 |
+
const p = pinR(g, 3, 0.3 + r * 0.6, 1.2)
|
| 551 |
+
withA(c, eo(p), () => {
|
| 552 |
+
T(c, sb.parent, x, P ? y : y + 14, { size: P ? 40 : 38, w: 900, f: 'serif', color: sb.color })
|
| 553 |
+
T(c, `${sb.n} 条`, P ? x + 1000 - 80 : x + 270, P ? y : y + 14, { size: P ? 34 : 30, w: 700, color: C.mute, align: 'right' })
|
| 554 |
+
const by = P ? y + 30 : y - 14
|
| 555 |
+
const bh = P ? 40 : 38
|
| 556 |
+
let cx0 = bx
|
| 557 |
+
const shades = [1, 0.66, 0.44, 0.28]
|
| 558 |
+
sb.items.forEach(([k], i) => {
|
| 559 |
+
const n = subN(k)
|
| 560 |
+
const sw = (n / sb.n) * bw * eo5(clamp(p * 1.3 - i * 0.1))
|
| 561 |
+
if (sw > 3) {
|
| 562 |
+
c.save()
|
| 563 |
+
rr(c, cx0, by, sw - 3, bh, 6)
|
| 564 |
+
c.fillStyle = hexA(sb.color, shades[i])
|
| 565 |
+
c.fill()
|
| 566 |
+
c.restore()
|
| 567 |
+
if (i === 0) T(c, String(n), cx0 + 18, by + bh * 0.72, { size: P ? 28 : 26, w: 900, color: C.bg })
|
| 568 |
+
}
|
| 569 |
+
cx0 += (n / sb.n) * bw
|
| 570 |
+
})
|
| 571 |
+
// 图例
|
| 572 |
+
let lx = bx
|
| 573 |
+
const ly = by + bh + (P ? 46 : 40)
|
| 574 |
+
sb.items.forEach(([k, l], i) => {
|
| 575 |
+
const s = `${l} ${subN(k)}`
|
| 576 |
+
const fs = P ? 26 : 24
|
| 577 |
+
dot(c, lx + 8, ly - fs * 0.34, 7, hexA(sb.color, shades[i]))
|
| 578 |
+
T(c, s, lx + 22, ly, { size: fs, w: i === 0 ? 700 : 500, color: i === 0 ? C.ink : C.mute })
|
| 579 |
+
lx += measure(c, s, fs, 700) + (P ? 46 : 60)
|
| 580 |
+
})
|
| 581 |
+
})
|
| 582 |
+
})
|
| 583 |
+
// 洞察
|
| 584 |
+
const ip = pin(g, 3, 3.6)
|
| 585 |
+
withA(c, ip, () => {
|
| 586 |
+
const y = P ? 1490 : 884
|
| 587 |
+
T(c, '说错的 30 条里,20 条是方向判反——不是差一点,是看反了', P ? 80 : 180, y, { size: P ? 30 : 30, w: 700, color: C.goldHi })
|
| 588 |
+
})
|
| 589 |
+
})
|
| 590 |
+
|
| 591 |
+
// —— 4:五个战场
|
| 592 |
+
withA(c, vis(g, 4), () => {
|
| 593 |
+
kicker(c, 'FIVE BATTLEFIELDS · 五个战场', P ? 80 : 135, P ? 450 : 330, C.gold, pin(g, 4, 0), P ? 24 : 22)
|
| 594 |
+
FIELDS.forEach((f, i) => {
|
| 595 |
+
const p = pinR(g, 4, 0.6 + i * 0.5, 0.9)
|
| 596 |
+
const cw = P ? 920 : 306
|
| 597 |
+
const chh = P ? 184 : 440
|
| 598 |
+
const x = P ? 80 : 135 + i * 336
|
| 599 |
+
const y = P ? 496 + i * 204 : 390
|
| 600 |
+
card3d(c, x + cw / 2, y + chh / 2, p, () => {
|
| 601 |
+
glass(c, x, y, cw, chh, 22)
|
| 602 |
+
if (P) {
|
| 603 |
+
T(c, f.no, x + 36, y + 80, { size: 52, w: 900, f: 'serif', color: C.gold })
|
| 604 |
+
T(c, f.t, x + 140, y + 80, { size: 54, w: 900, f: 'serif' })
|
| 605 |
+
T(c, f.s, x + 140, y + 130, { size: 26, w: 500, color: C.dim })
|
| 606 |
+
T(c, `${f.st.n} 条`, x + cw - 36, y + 80, { size: 40, w: 900, f: 'serif', align: 'right', color: C.goldHi })
|
| 607 |
+
} else {
|
| 608 |
+
T(c, f.no, x + 32, y + 72, { size: 40, w: 900, f: 'serif', color: C.gold })
|
| 609 |
+
T(c, f.t, x + 32, y + 170, { size: 72, w: 900, f: 'serif' })
|
| 610 |
+
T(c, f.s, x + 32, y + 216, { size: 22, w: 500, color: C.dim })
|
| 611 |
+
T(c, String(f.st.n), x + 32, y + 330, { size: 70, w: 900, f: 'serif', color: C.goldHi })
|
| 612 |
+
T(c, '条预测', x + 32 + measure(c, String(f.st.n), 70, 900, 'serif') + 10, y + 330, { size: 26, w: 700, color: C.mute })
|
| 613 |
+
}
|
| 614 |
+
// 构成条
|
| 615 |
+
const bx = P ? x + 36 : x + 32
|
| 616 |
+
const bw = P ? cw - 72 : cw - 64
|
| 617 |
+
const by = P ? y + 156 : y + 372
|
| 618 |
+
let xx = bx
|
| 619 |
+
;[
|
| 620 |
+
[f.st.c, C.green],
|
| 621 |
+
[f.st.w, C.red],
|
| 622 |
+
[f.st.d, C.amber],
|
| 623 |
+
[f.st.p, C.blue],
|
| 624 |
+
].forEach(([n, col]) => {
|
| 625 |
+
const w = ((n as number) / f.st.n) * bw * eo(clamp(p * 1.4 - 0.3))
|
| 626 |
+
if (w > 2) {
|
| 627 |
+
c.save()
|
| 628 |
+
rr(c, xx, by, w - 2, P ? 14 : 12, 4)
|
| 629 |
+
c.fillStyle = col as string
|
| 630 |
+
c.fill()
|
| 631 |
+
c.restore()
|
| 632 |
+
}
|
| 633 |
+
xx += w
|
| 634 |
+
})
|
| 635 |
+
})
|
| 636 |
+
})
|
| 637 |
+
if (!P) {
|
| 638 |
+
const lp = pin(g, 4, 3.4)
|
| 639 |
+
;[
|
| 640 |
+
['说对', C.green],
|
| 641 |
+
['说错', C.red],
|
| 642 |
+
['参半', C.amber],
|
| 643 |
+
['未到期', C.blue],
|
| 644 |
+
].forEach(([l, col], i) => {
|
| 645 |
+
dot(c, 140 + i * 150, 872, 7, col, lp)
|
| 646 |
+
T(c, l, 156 + i * 150, 880, { size: 22, w: 500, color: C.mute, p: lp })
|
| 647 |
+
})
|
| 648 |
+
}
|
| 649 |
+
})
|
| 650 |
+
}
|
kkndme/frontend/src/video/scenes2.ts
ADDED
|
@@ -0,0 +1,593 @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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// 房价 · 城市 · 货币
|
| 2 |
+
import {
|
| 3 |
+
type G,
|
| 4 |
+
type Chart,
|
| 5 |
+
vis,
|
| 6 |
+
pin,
|
| 7 |
+
pinR,
|
| 8 |
+
withA,
|
| 9 |
+
maskText,
|
| 10 |
+
charText,
|
| 11 |
+
roll,
|
| 12 |
+
kicker,
|
| 13 |
+
glass,
|
| 14 |
+
card3d,
|
| 15 |
+
chip,
|
| 16 |
+
ring,
|
| 17 |
+
glowDot,
|
| 18 |
+
hbar,
|
| 19 |
+
vbar,
|
| 20 |
+
pulse,
|
| 21 |
+
shine,
|
| 22 |
+
grid,
|
| 23 |
+
series,
|
| 24 |
+
annot,
|
| 25 |
+
at,
|
| 26 |
+
sx,
|
| 27 |
+
sy,
|
| 28 |
+
C,
|
| 29 |
+
T,
|
| 30 |
+
clamp,
|
| 31 |
+
lerp,
|
| 32 |
+
prog,
|
| 33 |
+
eo,
|
| 34 |
+
eo5,
|
| 35 |
+
eio,
|
| 36 |
+
hexA,
|
| 37 |
+
rr,
|
| 38 |
+
dot,
|
| 39 |
+
line,
|
| 40 |
+
measure,
|
| 41 |
+
checkMark,
|
| 42 |
+
crossMark,
|
| 43 |
+
} from './kit'
|
| 44 |
+
import { STATUS_COLOR, wrap } from './draw'
|
| 45 |
+
import { BIS_NOM, BIS_REAL, qYear, FX, mYear, M2_IDX, CPI_IDX, HOUSE_IDX, CITIES } from './series'
|
| 46 |
+
import { byType, byTopic } from '../data/science'
|
| 47 |
+
|
| 48 |
+
const NOM: [number, number][] = BIS_NOM.map((v, i) => [qYear(i), v])
|
| 49 |
+
const REAL: [number, number][] = BIS_REAL.map((v, i) => [qYear(i), v])
|
| 50 |
+
const PEAK_I = BIS_NOM.indexOf(Math.max(...BIS_NOM))
|
| 51 |
+
|
| 52 |
+
/** 右侧(横屏)/ 下方(竖屏)信息面板 */
|
| 53 |
+
function panel(g: G) {
|
| 54 |
+
return g.P ? { x: 80, y: 1090, w: 920, h: 420 } : { x: 1320, y: 290, w: 460, h: 560 }
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
function quote(g: G, s: string, x: number, y: number, w: number, p: number, size?: number) {
|
| 58 |
+
const fs = size ?? (g.P ? 40 : 36)
|
| 59 |
+
T(g.c, 'kkndme 当年说', x, y, { size: g.P ? 24 : 22, w: 700, color: C.dim, ls: 4, p })
|
| 60 |
+
const ls = wrap(g.c, s, w, fs, 900, 'serif')
|
| 61 |
+
ls.forEach((l, k) => T(g.c, l, x, y + 20 + fs * 1.3 * (k + 1), { size: fs, w: 900, f: 'serif', p: clamp(p * 1.3 - k * 0.15) }))
|
| 62 |
+
return y + 20 + fs * 1.3 * ls.length
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
// ============ 房价 ============
|
| 66 |
+
export function price(g: G) {
|
| 67 |
+
const { c, P } = g
|
| 68 |
+
const ch: Chart = P ? { x: 150, y: 430, w: 850, h: 560, x0: 2010, x1: 2026.6, y0: 70, y1: 170 } : { x: 210, y: 290, w: 1020, h: 540, x0: 2010, x1: 2026.6, y0: 70, y1: 170 }
|
| 69 |
+
const fs = P ? 24 : 20
|
| 70 |
+
// —— 图表常驻
|
| 71 |
+
grid(c, ch, [80, 100, 120, 140, 160], [2010, 2014, 2018, 2022, 2026], (v) => String(v), (v) => String(v), pin(g, 0, 0.2, 1), P)
|
| 72 |
+
withA(c, pin(g, 0, 0.3), () => {
|
| 73 |
+
kicker(c, 'BIS 中国住宅价格指数 · 2010 = 100', ch.x, ch.y - (P ? 34 : 30), C.gold, 1, P ? 22 : 20)
|
| 74 |
+
})
|
| 75 |
+
const drawP = eio(prog(g.lt(0), 0.8, 5.2))
|
| 76 |
+
// 预言锥
|
| 77 |
+
const coneA = vis(g, 1, 3)
|
| 78 |
+
withA(c, coneA, () => {
|
| 79 |
+
const p = eo(prog(g.lt(1), 0.4, 1.6))
|
| 80 |
+
const x0 = 2010.875
|
| 81 |
+
const y0v = 101.86
|
| 82 |
+
const x1 = lerp(x0, 2013.875, p)
|
| 83 |
+
c.save()
|
| 84 |
+
c.beginPath()
|
| 85 |
+
c.rect(ch.x, ch.y, ch.w, ch.h)
|
| 86 |
+
c.clip()
|
| 87 |
+
c.beginPath()
|
| 88 |
+
c.moveTo(sx(ch, x0), sy(ch, y0v))
|
| 89 |
+
c.lineTo(sx(ch, x1), sy(ch, lerp(y0v, y0v * 2, p)))
|
| 90 |
+
c.lineTo(sx(ch, x1), sy(ch, lerp(y0v, y0v * 1.5, p)))
|
| 91 |
+
c.closePath()
|
| 92 |
+
const gr = c.createLinearGradient(0, sy(ch, 200), 0, sy(ch, 100))
|
| 93 |
+
gr.addColorStop(0, hexA(C.red, 0.32))
|
| 94 |
+
gr.addColorStop(1, hexA(C.red, 0.05))
|
| 95 |
+
c.fillStyle = gr
|
| 96 |
+
c.fill()
|
| 97 |
+
c.restore()
|
| 98 |
+
line(c, sx(ch, x0), sy(ch, y0v), sx(ch, x1), Math.max(ch.y, sy(ch, lerp(y0v, y0v * 1.5, p))), C.red, 2, 0.9, [6, 6])
|
| 99 |
+
T(c, 'kkndme 预言:3 年 +50%~100%', sx(ch, 2011.0), ch.y + 34, { size: P ? 26 : 24, w: 700, color: C.red, p: pin(g, 1, 1.2) })
|
| 100 |
+
// 实际
|
| 101 |
+
const ap = pin(g, 1, 5.0, 1)
|
| 102 |
+
annot(c, sx(ch, 2013.875), sy(ch, 113.06), sx(ch, 2015.2), sy(ch, 150), [
|
| 103 |
+
{ s: '2013 年底:实际 +11%', size: P ? 28 : 26, color: C.ink },
|
| 104 |
+
{ s: '(BIS 指数口径)', size: P ? 22 : 20, color: C.dim, w: 500 },
|
| 105 |
+
], C.ink, ap)
|
| 106 |
+
})
|
| 107 |
+
// 名义线
|
| 108 |
+
const redFrom = eo(prog(g.lt(3), 1.6, 2.0))
|
| 109 |
+
series(c, ch, NOM, drawP, C.gold, { w: P ? 5 : 4.5, area: 0.2, t: g.t })
|
| 110 |
+
if (redFrom > 0) series(c, ch, NOM.slice(PEAK_I), redFrom, C.red, { w: P ? 5.5 : 5, area: 0.18, glow: 22 })
|
| 111 |
+
if (drawP > 0.98 && redFrom <= 0) withA(c, pin(g, 0, 6.0), () => T(c, '名义', sx(ch, 2026.2), sy(ch, 113.98) - 20, { size: fs, w: 700, color: C.gold, align: 'center' }))
|
| 112 |
+
// 峰值
|
| 113 |
+
withA(c, vis(g, 3), () => {
|
| 114 |
+
const px = sx(ch, NOM[PEAK_I][0])
|
| 115 |
+
const py = sy(ch, NOM[PEAK_I][1])
|
| 116 |
+
const p = pin(g, 3, 0.4, 1)
|
| 117 |
+
pulse(c, px, py, 10, g.t, C.red, p)
|
| 118 |
+
annot(c, px, py, px - (P ? 140 : 150), sy(ch, 162), [
|
| 119 |
+
{ s: '2021Q3 见顶 145.9', size: P ? 28 : 26, color: C.ink },
|
| 120 |
+
], C.red, p, 'right')
|
| 121 |
+
const bp = eo(prog(g.lt(3), 3.6, 0.8))
|
| 122 |
+
if (bp > 0) {
|
| 123 |
+
const ex = sx(ch, NOM[NOM.length - 1][0]) + (P ? 26 : 30)
|
| 124 |
+
const y1 = sy(ch, NOM[PEAK_I][1])
|
| 125 |
+
const y2 = sy(ch, NOM[NOM.length - 1][1])
|
| 126 |
+
line(c, ex, y1, ex, lerp(y1, y2, bp), C.red, 2.5)
|
| 127 |
+
line(c, ex - 8, y1, ex + 8, y1, C.red, 2.5, bp)
|
| 128 |
+
line(c, ex - 8, y2, ex + 8, y2, C.red, 2.5, bp)
|
| 129 |
+
T(c, '−21.9%', ex - 14, (y1 + y2) / 2 + 12, { size: P ? 40 : 40, w: 900, f: 'serif', color: C.red, align: 'right', p: bp })
|
| 130 |
+
}
|
| 131 |
+
})
|
| 132 |
+
// 实际线
|
| 133 |
+
withA(c, vis(g, 4), () => {
|
| 134 |
+
const p = eio(prog(g.lt(4), 0.3, 2.6))
|
| 135 |
+
line(c, ch.x, sy(ch, 100), ch.x + ch.w * eo(prog(g.lt(4), 0, 1)), sy(ch, 100), C.ink, 1.5, 0.45, [4, 6])
|
| 136 |
+
series(c, ch, REAL, p, '#9FC3F0', { w: P ? 4 : 3.5, area: 0.08, glow: 12 })
|
| 137 |
+
withA(c, pin(g, 4, 2.6), () => {
|
| 138 |
+
const ex = sx(ch, REAL[REAL.length - 1][0])
|
| 139 |
+
const ey = sy(ch, REAL[REAL.length - 1][1])
|
| 140 |
+
glowDot(c, ex, ey, 6, '#9FC3F0')
|
| 141 |
+
T(c, '扣除通胀 85.1', ex - 14, ey + 40, { size: P ? 26 : 24, w: 700, color: '#9FC3F0', align: 'right' })
|
| 142 |
+
})
|
| 143 |
+
})
|
| 144 |
+
|
| 145 |
+
// —— 面板
|
| 146 |
+
const pn = panel(g)
|
| 147 |
+
const px = pn.x
|
| 148 |
+
const py = pn.y
|
| 149 |
+
// 0:读图
|
| 150 |
+
withA(c, vis(g, 0, 1), () => {
|
| 151 |
+
kicker(c, 'HOW TO READ', px, py + 30, C.gold, pin(g, 0, 1), 20)
|
| 152 |
+
T(c, '国际清算银行按统计局', px, py + (P ? 90 : 100), { size: P ? 34 : 32, w: 900, f: 'serif', p: pin(g, 0, 1.3) })
|
| 153 |
+
T(c, '70 城房价编制的指数', px, py + (P ? 140 : 150), { size: P ? 34 : 32, w: 900, f: 'serif', p: pin(g, 0, 1.5) })
|
| 154 |
+
const rowsI = [
|
| 155 |
+
['2010 年', '100'],
|
| 156 |
+
['2021Q3 峰值', '145.9'],
|
| 157 |
+
['2026Q1 最新', '114.0'],
|
| 158 |
+
]
|
| 159 |
+
rowsI.forEach(([a, b], i) => {
|
| 160 |
+
const y = py + (P ? 220 : 240) + i * (P ? 60 : 64)
|
| 161 |
+
const p = pin(g, 0, 2.6 + i * 0.6)
|
| 162 |
+
line(c, px, y + 18, px + (P ? 600 : pn.w), y + 18, C.faint, 1, p)
|
| 163 |
+
T(c, a, px, y, { size: P ? 28 : 26, w: 500, color: C.mute, p })
|
| 164 |
+
T(c, b, px + (P ? 600 : pn.w), y, { size: P ? 34 : 32, w: 900, f: 'serif', align: 'right', color: i === 1 ? C.goldHi : C.ink, p })
|
| 165 |
+
})
|
| 166 |
+
})
|
| 167 |
+
// 1:幅度高估
|
| 168 |
+
withA(c, vis(g, 1, 2), () => {
|
| 169 |
+
const y = quote(g, '“二三线及以下城市未来 2–3 年内经过 50%–100% 的涨幅”', px, py + 30, pn.w, pin(g, 1, 0.2))
|
| 170 |
+
T(c, '实际 2010→2013 全国住宅均价', px, y + 60, { size: P ? 26 : 24, w: 500, color: C.mute, p: pin(g, 1, 4.4) })
|
| 171 |
+
const w = roll(c, '+24', px, y + (P ? 150 : 160), { size: P ? 96 : 100, w: 900, f: 'serif', color: C.ink }, pinR(g, 1, 4.6, 1.2))
|
| 172 |
+
T(c, '%', px + w + 4, y + (P ? 150 : 160), { size: P ? 50 : 50, w: 900, f: 'serif', color: C.gold, p: pin(g, 1, 5.2) })
|
| 173 |
+
T(c, '4725 → 5850 元/㎡', px + w + 70, y + (P ? 150 : 160), { size: P ? 28 : 24, w: 700, color: C.mute, p: pin(g, 1, 5.6) })
|
| 174 |
+
chip(c, '说错 · 幅度高估', px, y + (P ? 230 : 240), 'no', pin(g, 1, 6.6), P ? 26 : 24)
|
| 175 |
+
})
|
| 176 |
+
// 2:不会跌回 2004
|
| 177 |
+
withA(c, vis(g, 2, 3), () => {
|
| 178 |
+
const y = quote(g, '“许多人心怀房价肯定会跌回 2004 年的美好愿望……”', px, py + 30, pn.w, pin(g, 2, 0.2))
|
| 179 |
+
const bars = [
|
| 180 |
+
{ l: '2004 年', v: 2608 },
|
| 181 |
+
{ l: '2025 年', v: 10005 },
|
| 182 |
+
]
|
| 183 |
+
const bw = P ? 600 : pn.w - 120
|
| 184 |
+
bars.forEach((b, i) => {
|
| 185 |
+
const by = y + (P ? 60 : 70) + i * (P ? 80 : 90)
|
| 186 |
+
const p = pinR(g, 2, 2.6 + i * 0.8, 1.2)
|
| 187 |
+
T(c, b.l, px, by + 2, { size: P ? 26 : 24, w: 500, color: C.mute, p: eo(p) })
|
| 188 |
+
const end = hbar(c, px + (P ? 130 : 110), by - 22, bw * (P ? 1 : 0.86), P ? 26 : 24, b.v / 10005, i ? C.gold : '#7C6E55', p)
|
| 189 |
+
T(c, b.v.toLocaleString('en-US'), end + 14, by + 2, { size: P ? 28 : 26, w: 900, f: 'serif', p: eo(p) })
|
| 190 |
+
})
|
| 191 |
+
const yy = y + (P ? 260 : 290)
|
| 192 |
+
roll(c, '3.8', px, yy, { size: P ? 80 : 80, w: 900, f: 'serif', color: C.goldHi }, pinR(g, 2, 4.4, 1.2))
|
| 193 |
+
T(c, '倍 · 住宅均价 元/㎡', px + (P ? 140 : 140), yy, { size: P ? 28 : 24, w: 700, color: C.mute, p: pin(g, 2, 5) })
|
| 194 |
+
if (!P) chip(c, '至今成立', px, yy + 70, 'ok', pin(g, 2, 5.6), 24)
|
| 195 |
+
else chip(c, '至今成立', px + 640, yy - 20, 'ok', pin(g, 2, 5.6), 26)
|
| 196 |
+
})
|
| 197 |
+
// 3:不会大跌
|
| 198 |
+
withA(c, vis(g, 3, 4), () => {
|
| 199 |
+
const y = quote(g, '“除非出现明末的极端事件……等房价大降真的不现实。”', px, py + 30, pn.w, pin(g, 3, 0.2))
|
| 200 |
+
T(c, '已从高点下跌', px, y + 60, { size: P ? 26 : 24, w: 500, color: C.mute, p: pin(g, 3, 2.4) })
|
| 201 |
+
const w = roll(c, '22', px, y + (P ? 150 : 160), { size: P ? 96 : 100, w: 900, f: 'serif', color: C.red }, pinR(g, 3, 2.6, 1.2))
|
| 202 |
+
T(c, '%', px + w + 4, y + (P ? 150 : 160), { size: 50, w: 900, f: 'serif', color: C.red, p: pin(g, 3, 3.2) })
|
| 203 |
+
T(c, '标普 2026.10 测算', px + w + 70, y + (P ? 150 : 160), { size: P ? 26 : 22, w: 500, color: C.dim, p: pin(g, 3, 3.6) })
|
| 204 |
+
chip(c, '未到期 · 还没跌到三成', px, y + (P ? 230 : 240), 'wait', pin(g, 3, 4.4), P ? 26 : 24)
|
| 205 |
+
})
|
| 206 |
+
// 4:实际房价
|
| 207 |
+
withA(c, vis(g, 4, 5), () => {
|
| 208 |
+
kicker(c, 'REAL TERMS · 扣除通胀', px, py + 30, C.gold, pin(g, 4, 0.2), 20)
|
| 209 |
+
const w = roll(c, '85.1', px, py + (P ? 150 : 170), { size: P ? 120 : 130, w: 900, f: 'serif', color: '#BFD6F5' }, pinR(g, 4, 0.6, 1.6))
|
| 210 |
+
T(c, '实际房价指数', px, py + (P ? 210 : 230), { size: P ? 30 : 28, w: 700, p: pin(g, 4, 1.4) })
|
| 211 |
+
T(c, '比 2010 年低 15%;比峰值低 25%', px, py + (P ? 262 : 286), { size: P ? 28 : 26, w: 500, color: C.mute, p: pin(g, 4, 3.0) })
|
| 212 |
+
T(c, '房子跑输了物价', px, py + (P ? 330 : 370), { size: P ? 44 : 42, w: 900, f: 'serif', color: C.goldHi, p: pin(g, 4, 4.4) })
|
| 213 |
+
})
|
| 214 |
+
// 5:成绩
|
| 215 |
+
withA(c, vis(g, 5), () => {
|
| 216 |
+
const st = byTopic.find((x) => x.k === '房价走势')!.r
|
| 217 |
+
kicker(c, 'SCORE · 房价走势类', px, py + 30, C.gold, pin(g, 5, 0.1), 20)
|
| 218 |
+
const rcx = px + (P ? 150 : 120)
|
| 219 |
+
const rcy = py + (P ? 220 : 210)
|
| 220 |
+
const p = pinR(g, 5, 0.3, 1.8)
|
| 221 |
+
ring(c, rcx, rcy, P ? 120 : 100, P ? 22 : 20, [
|
| 222 |
+
{ v: st.correct, color: C.green },
|
| 223 |
+
{ v: st.wrong, color: C.red },
|
| 224 |
+
{ v: st.disputed, color: C.amber },
|
| 225 |
+
], p)
|
| 226 |
+
roll(c, '38', rcx - 10, rcy + 24, { size: P ? 80 : 70, w: 900, f: 'serif', align: 'center' }, p)
|
| 227 |
+
T(c, '%', rcx + (P ? 52 : 44), rcy + 24, { size: P ? 36 : 32, w: 900, f: 'serif', color: C.gold, p: eo(p) })
|
| 228 |
+
const tx = px + (P ? 330 : 0)
|
| 229 |
+
const ty = P ? py + 150 : py + 380
|
| 230 |
+
;[
|
| 231 |
+
['说对', st.correct, C.green],
|
| 232 |
+
['说错', st.wrong, C.red],
|
| 233 |
+
['参半', st.disputed, C.amber],
|
| 234 |
+
].forEach(([l, n, col], i) => {
|
| 235 |
+
const q = pin(g, 5, 1.0 + i * 0.2)
|
| 236 |
+
const xx = P ? tx : tx + i * 150
|
| 237 |
+
const yy = P ? ty + i * 56 : ty
|
| 238 |
+
dot(c, xx + 8, yy - 9, 7, col as string, q)
|
| 239 |
+
T(c, `${l} ${n}`, xx + 24, yy, { size: P ? 30 : 26, w: 700, p: q })
|
| 240 |
+
})
|
| 241 |
+
T(c, '方向大体对,幅度和时点频频失手', P ? tx : px, P ? ty + 200 : ty + 70, { size: P ? 30 : 26, w: 700, color: C.goldHi, p: pin(g, 5, 2.4) })
|
| 242 |
+
})
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
// ============ 城市 ============
|
| 246 |
+
function proj(g: G, lon: number, lat: number) {
|
| 247 |
+
return g.P ? { x: 140 + (lon - 98) * 31, y: 440 + (42 - lat) * 25 } : { x: 180 + (lon - 98) * 30, y: 280 + (42 - lat) * 25 }
|
| 248 |
+
}
|
| 249 |
+
const HL: Record<number, string[]> = {
|
| 250 |
+
1: ['北京', '上海', '广佛', '深圳'],
|
| 251 |
+
2: ['上海', '合肥'],
|
| 252 |
+
3: ['燕郊', '乳山', '三亚'],
|
| 253 |
+
4: ['重庆', '昆明', '南宁'],
|
| 254 |
+
}
|
| 255 |
+
const cityType = byType.find((x) => x.k === 'city')!.r
|
| 256 |
+
|
| 257 |
+
export function cities(g: G) {
|
| 258 |
+
const { c, P } = g
|
| 259 |
+
const k = [0, 1, 2, 3, 4, 5].reduce((a, i) => (g.lt(i) >= -0.2 ? i : a), 0)
|
| 260 |
+
const hl = HL[k]
|
| 261 |
+
// 经纬网
|
| 262 |
+
withA(c, pin(g, 0, 0, 1.2), () => {
|
| 263 |
+
for (let lon = 100; lon <= 125; lon += 5) {
|
| 264 |
+
const a = proj(g, lon, 41)
|
| 265 |
+
const b = proj(g, lon, 17.5)
|
| 266 |
+
line(c, a.x, a.y, b.x, b.y, 'rgba(243,238,228,0.07)', 1, 1, [2, 6])
|
| 267 |
+
T(c, `${lon}°E`, a.x, a.y - 10, { size: P ? 18 : 16, w: 500, color: C.dim, align: 'center', a: 0.7 })
|
| 268 |
+
}
|
| 269 |
+
for (let lat = 20; lat <= 40; lat += 5) {
|
| 270 |
+
const a = proj(g, 99, lat)
|
| 271 |
+
const b = proj(g, 125, lat)
|
| 272 |
+
line(c, a.x, a.y, b.x, b.y, 'rgba(243,238,228,0.07)', 1, 1, [2, 6])
|
| 273 |
+
T(c, `${lat}°N`, P ? b.x + 8 : a.x - 8, a.y + 6, { size: P ? 18 : 16, w: 500, color: C.dim, align: P ? 'left' : 'right', a: 0.7 })
|
| 274 |
+
}
|
| 275 |
+
})
|
| 276 |
+
const sorted = [...CITIES].sort((a, b) => a.lon - b.lon)
|
| 277 |
+
sorted.forEach((ct, i) => {
|
| 278 |
+
const p = pinR(g, 0, 0.6 + i * 0.12, 0.7)
|
| 279 |
+
if (p <= 0) return
|
| 280 |
+
const { x, y } = proj(g, ct.lon, ct.lat)
|
| 281 |
+
const col = STATUS_COLOR[ct.st]
|
| 282 |
+
const on = !hl || hl.includes(ct.name)
|
| 283 |
+
const a = on ? 1 : 0.28
|
| 284 |
+
withA(c, a, () => {
|
| 285 |
+
if (hl && on) pulse(c, x, y, 9, g.t, col, 0.9)
|
| 286 |
+
glowDot(c, x, y, (P ? 9 : 8) * lerp(0.3, 1, eo5(p)), col, clamp(p * 2))
|
| 287 |
+
const fs = P ? 24 : 22
|
| 288 |
+
const off = 16
|
| 289 |
+
const lx = ct.lab === 'l' ? x - off : ct.lab === 'r' ? x + off : x
|
| 290 |
+
const ly = ct.lab === 't' ? y - off : ct.lab === 'b' ? y + off + fs * 0.8 : y + fs * 0.36
|
| 291 |
+
T(c, ct.name, lx, ly, { size: fs, w: on && hl ? 900 : 700, color: on && hl ? C.ink : C.mute, align: ct.lab === 'l' ? 'right' : ct.lab === 'r' ? 'left' : 'center', p })
|
| 292 |
+
})
|
| 293 |
+
})
|
| 294 |
+
// 图例
|
| 295 |
+
withA(c, pin(g, 0, 3.6), () => {
|
| 296 |
+
const lx = P ? 140 : 180
|
| 297 |
+
const ly = P ? 1060 : 890
|
| 298 |
+
;[
|
| 299 |
+
['看对', C.green],
|
| 300 |
+
['看错', C.red],
|
| 301 |
+
['参半', C.amber],
|
| 302 |
+
].forEach(([l, col], i) => {
|
| 303 |
+
dot(c, lx + i * 130 + 8, ly - 8, 7, col)
|
| 304 |
+
T(c, l, lx + i * 130 + 24, ly, { size: P ? 24 : 22, w: 500, color: C.mute })
|
| 305 |
+
})
|
| 306 |
+
})
|
| 307 |
+
|
| 308 |
+
const pn = P ? { x: 80, y: 1120, w: 920 } : { x: 1080, y: 300, w: 700 }
|
| 309 |
+
const { x: px, y: py, w: pw } = pn
|
| 310 |
+
// 0
|
| 311 |
+
withA(c, vis(g, 0, 1), () => {
|
| 312 |
+
kicker(c, 'MOST ACCURATE · 他最准的领域之一', px, py + 20, C.gold, pin(g, 0, 0.3), 20)
|
| 313 |
+
const w = roll(c, String(Math.round(cityType.hit * 100)), px, py + (P ? 160 : 200), { size: P ? 150 : 180, w: 900, f: 'serif', color: C.ink }, pinR(g, 0, 3.8, 1.6), (x0, ww) => shine(c, x0, ww, prog(g.lt(0), 5.4, 1.2) * 1.6 - 0.3, C.ink))
|
| 314 |
+
T(c, '%', px + w + 6, py + (P ? 160 : 200), { size: P ? 70 : 80, w: 900, f: 'serif', color: C.gold, p: pin(g, 0, 4.4) })
|
| 315 |
+
T(c, `城市 / 板块类判断命中率 · ${cityType.correct} 对 ${cityType.wrong} 错`, px, py + (P ? 230 : 270), { size: P ? 28 : 28, w: 700, p: pin(g, 0, 4.8) })
|
| 316 |
+
T(c, '图上 23 座被他点名的城市,按判定结果着色', px, py + (P ? 280 : 330), { size: P ? 26 : 24, w: 500, color: C.dim, p: pin(g, 0, 5.4) })
|
| 317 |
+
})
|
| 318 |
+
// 1:一线 vs 其余
|
| 319 |
+
withA(c, vis(g, 1, 2), () => {
|
| 320 |
+
kicker(c, '70 城新房价格 · 2010.12 → 2026.08 累计', px, py + 20, C.gold, pin(g, 1, 0.3), 20)
|
| 321 |
+
const items = [
|
| 322 |
+
{ l: '北上广深', v: 111, col: C.gold },
|
| 323 |
+
{ l: '其余 66 城', v: 33, col: '#8C7F68' },
|
| 324 |
+
]
|
| 325 |
+
items.forEach((it, i) => {
|
| 326 |
+
const y = py + (P ? 100 : 120) + i * (P ? 110 : 130)
|
| 327 |
+
const p = pinR(g, 1, 2.6 + i * 1.6, 1.3)
|
| 328 |
+
T(c, it.l, px, y, { size: P ? 32 : 32, w: 900, f: 'serif', p: eo(p) })
|
| 329 |
+
const end = hbar(c, px, y + 22, (P ? 700 : 520) * (it.v / 111), P ? 34 : 34, 1, it.col, p, false)
|
| 330 |
+
roll(c, `+${it.v}%`, end + 18, y + 54, { size: P ? 46 : 46, w: 900, f: 'serif', color: i ? C.mute : C.goldHi }, p)
|
| 331 |
+
})
|
| 332 |
+
T(c, '从高点回落:一线 −10%,其余 −16%', px, py + (P ? 320 : 420), { size: P ? 28 : 26, w: 500, color: C.mute, p: pin(g, 1, 7.2) })
|
| 333 |
+
chip(c, '一线长期跑赢', px, py + (P ? 365 : 490), 'ok', pin(g, 1, 7.6), P ? 26 : 24)
|
| 334 |
+
})
|
| 335 |
+
// 2:上海 + 合肥
|
| 336 |
+
withA(c, vis(g, 2, 3), () => {
|
| 337 |
+
kicker(c, '累计涨幅排行 · 2010.12 → 2026.08', px, py + 20, C.gold, pin(g, 2, 0.2), 20)
|
| 338 |
+
const items = [
|
| 339 |
+
['上海', 154, '70 城第一'],
|
| 340 |
+
['深圳', 112, ''],
|
| 341 |
+
['北京', 93, ''],
|
| 342 |
+
['杭州', 71, ''],
|
| 343 |
+
] as const
|
| 344 |
+
items.forEach(([l, v, tag], i) => {
|
| 345 |
+
const y = py + (P ? 74 : 90) + i * (P ? 52 : 62)
|
| 346 |
+
const p = pinR(g, 2, 0.4 + i * 0.25, 1)
|
| 347 |
+
T(c, l, px, y + 20, { size: P ? 28 : 28, w: 700, p: eo(p), color: i === 0 ? C.goldHi : C.ink })
|
| 348 |
+
const end = hbar(c, px + 90, y, (P ? 560 : 420) * (v / 154), 24, 1, i === 0 ? C.gold : '#8C7F68', p, false)
|
| 349 |
+
T(c, `+${v}% ${tag}`, end + 14, y + 21, { size: P ? 26 : 24, w: 700, color: i === 0 ? C.goldHi : C.mute, p: eo(p) })
|
| 350 |
+
})
|
| 351 |
+
const cy0 = py + (P ? 310 : 380)
|
| 352 |
+
withA(c, pin(g, 2, 3.4), () => {
|
| 353 |
+
glass(c, px, cy0 - 50, pw, P ? 110 : 140, 18, 1, C.green)
|
| 354 |
+
T(c, '合肥', px + 28, cy0 + (P ? 20 : 10), { size: P ? 40 : 40, w: 900, f: 'serif', color: C.ink })
|
| 355 |
+
T(c, '6051 → 18516 元/㎡', px + (P ? 140 : 140), cy0 + (P ? 20 : 10), { size: P ? 30 : 28, w: 700, color: C.mute })
|
| 356 |
+
roll(c, '+206%', px + pw - 28, cy0 + (P ? 22 : 12), { size: P ? 48 : 48, w: 900, f: 'serif', color: C.green, align: 'right' }, pinR(g, 2, 3.6, 1.2))
|
| 357 |
+
if (!P) T(c, '2010 → 2020 · “大兴土木的城市房价低不了”', px + 28, cy0 + 58, { size: 22, w: 500, color: C.dim })
|
| 358 |
+
})
|
| 359 |
+
})
|
| 360 |
+
// 3:风险区
|
| 361 |
+
withA(c, vis(g, 3, 4), () => {
|
| 362 |
+
kicker(c, 'WARNINGS · 他提示过的风险', px, py + 20, C.gold, pin(g, 3, 0.2), 20)
|
| 363 |
+
const items = [
|
| 364 |
+
{ l: '燕郊', a: '3.4 万', b: '1.2 万', pct: '−65%', from: 34000, to: 12000 },
|
| 365 |
+
{ l: '乳山银滩', a: '7500', b: '1655', pct: '−78%', from: 7500, to: 1655 },
|
| 366 |
+
]
|
| 367 |
+
items.forEach((it, i) => {
|
| 368 |
+
const y = py + (P ? 90 : 110) + i * (P ? 130 : 160)
|
| 369 |
+
const p = pinR(g, 3, 1.8 + i * 2.2, 1.4)
|
| 370 |
+
withA(c, eo(p), () => {
|
| 371 |
+
T(c, it.l, px, y, { size: P ? 34 : 34, w: 900, f: 'serif' })
|
| 372 |
+
T(c, `${it.a} → ${it.b} 元/㎡`, px, y + (P ? 44 : 46), { size: P ? 26 : 24, w: 500, color: C.mute })
|
| 373 |
+
const bw = P ? 420 : 300
|
| 374 |
+
const bx = px + (P ? 440 : 340)
|
| 375 |
+
hbar(c, bx, y - 26, bw, 22, 1, '#5C5446', 1, false)
|
| 376 |
+
hbar(c, bx, y - 26, bw, 22, it.to / it.from, C.red, p, false)
|
| 377 |
+
T(c, it.pct, bx + bw, y + 40, { size: P ? 44 : 44, w: 900, f: 'serif', color: C.red, align: 'right' })
|
| 378 |
+
})
|
| 379 |
+
})
|
| 380 |
+
chip(c, '风险提示全部应验', px, py + (P ? 380 : 450), 'ok', pin(g, 3, 6.2), P ? 26 : 24)
|
| 381 |
+
})
|
| 382 |
+
// 4:押错的牌
|
| 383 |
+
withA(c, vis(g, 4, 5), () => {
|
| 384 |
+
kicker(c, 'MISSES · 他看好的城市', px, py + 20, C.gold, pin(g, 4, 0.2), 20)
|
| 385 |
+
// 重庆:目标 vs 实际
|
| 386 |
+
const y = py + (P ? 80 : 100)
|
| 387 |
+
T(c, '重庆主城新房 元/㎡', px, y, { size: P ? 28 : 28, w: 700, p: pin(g, 4, 4.0) })
|
| 388 |
+
const bars = [
|
| 389 |
+
{ l: 'kkndme 目标', v: 9900, ghost: true },
|
| 390 |
+
{ l: '2011 实际', v: 6390 },
|
| 391 |
+
{ l: '2012 实际', v: 6389 },
|
| 392 |
+
]
|
| 393 |
+
const bw = P ? 640 : 430
|
| 394 |
+
bars.forEach((b, i) => {
|
| 395 |
+
const yy = y + 30 + i * (P ? 50 : 56)
|
| 396 |
+
const p = pinR(g, 4, 4.6 + i * 0.8, 1)
|
| 397 |
+
T(c, b.l, px, yy + 22, { size: P ? 24 : 22, w: 500, color: C.mute, p: eo(p) })
|
| 398 |
+
if (b.ghost) {
|
| 399 |
+
withA(c, eo(p), () => {
|
| 400 |
+
rr(c, px + 130, yy, bw * eo5(p), 28, 8)
|
| 401 |
+
c.save()
|
| 402 |
+
c.setLineDash([6, 6])
|
| 403 |
+
c.strokeStyle = hexA(C.gold, 0.8)
|
| 404 |
+
c.lineWidth = 2
|
| 405 |
+
c.stroke()
|
| 406 |
+
c.restore()
|
| 407 |
+
})
|
| 408 |
+
T(c, '9900', px + 130 + bw + 14, yy + 24, { size: 28, w: 900, f: 'serif', color: C.gold, p: eo(p) })
|
| 409 |
+
} else {
|
| 410 |
+
const end = hbar(c, px + 130, yy, bw * (b.v / 9900), 28, 1, C.red, p, false)
|
| 411 |
+
T(c, String(b.v), end + 14, yy + 24, { size: 28, w: 900, f: 'serif', p: eo(p) })
|
| 412 |
+
}
|
| 413 |
+
})
|
| 414 |
+
const y2 = y + (P ? 230 : 250)
|
| 415 |
+
;[
|
| 416 |
+
['昆明', '2020 峰值约 1.5 万 → 2026.09 二手 9978'],
|
| 417 |
+
['南宁', '2025 GDP 6212 亿,仍落后昆明 8637 亿'],
|
| 418 |
+
].forEach(([a, b], i) => {
|
| 419 |
+
const yy = y2 + i * (P ? 56 : 60)
|
| 420 |
+
const p = pin(g, 4, 0.8 + i * 1.0)
|
| 421 |
+
crossMark(c, px + 12, yy - 9, 18, C.red, p, 3.5)
|
| 422 |
+
T(c, a, px + 36, yy, { size: P ? 30 : 28, w: 900, f: 'serif', p })
|
| 423 |
+
T(c, b, px + 110, yy, { size: P ? 24 : 22, w: 500, color: C.mute, p })
|
| 424 |
+
})
|
| 425 |
+
})
|
| 426 |
+
// 5:金句
|
| 427 |
+
withA(c, vis(g, 5), () => {
|
| 428 |
+
const y = py + (P ? 130 : 220)
|
| 429 |
+
maskText(c, '看懂了大逻辑,', px, y, { size: P ? 64 : 60, w: 900, f: 'serif' }, pinR(g, 5, 0.1, 0.9))
|
| 430 |
+
maskText(c, '却常押错具体的牌。', px, y + (P ? 90 : 86), { size: P ? 64 : 60, w: 900, f: 'serif', color: C.goldHi }, pinR(g, 5, 0.8, 0.9))
|
| 431 |
+
const lw = (P ? 600 : 520) * eio(prog(g.lt(5), 1.4, 1))
|
| 432 |
+
line(c, px, y + (P ? 140 : 130), px + lw, y + (P ? 140 : 130), C.gold, 2)
|
| 433 |
+
})
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
// ============ 货币 ============
|
| 437 |
+
const YEARS = Array.from({ length: 16 }, (_, i) => 2010 + i)
|
| 438 |
+
const M2P: [number, number][] = M2_IDX.map((v, i) => [YEARS[i], v])
|
| 439 |
+
const CPIP: [number, number][] = CPI_IDX.map((v, i) => [YEARS[i], v])
|
| 440 |
+
const HOUP: [number, number][] = HOUSE_IDX.map((v, i) => [YEARS[i], v])
|
| 441 |
+
const FXP: [number, number][] = FX.map((v, i) => [mYear(i), v])
|
| 442 |
+
const HOUSE_C = '#8FB8EA'
|
| 443 |
+
|
| 444 |
+
export function money(g: G) {
|
| 445 |
+
const { c, P } = g
|
| 446 |
+
const chA: Chart = P ? { x: 150, y: 450, w: 820, h: 520, x0: 2010, x1: 2025.4, y0: 0, y1: 5 } : { x: 210, y: 300, w: 900, h: 520, x0: 2010, x1: 2025.4, y0: 0, y1: 5 }
|
| 447 |
+
const chB: Chart = P ? { x: 150, y: 450, w: 820, h: 520, x0: 2010, x1: 2026.9, y0: 3.5, y1: 7.6 } : { x: 210, y: 300, w: 900, h: 520, x0: 2010, x1: 2026.9, y0: 3.5, y1: 7.6 }
|
| 448 |
+
const aA = Math.min(pin(g, 1, 0, 0.8), 1 - eo(prog(g.lt(4), -0.2, 0.6)))
|
| 449 |
+
const aB = eo(prog(g.lt(4), 0.1, 0.8))
|
| 450 |
+
const fs = P ? 26 : 24
|
| 451 |
+
// 图 A:指数线
|
| 452 |
+
withA(c, aA, () => {
|
| 453 |
+
grid(c, chA, [1, 2, 3, 4, 5], [2010, 2015, 2020, 2025], (v) => `${v}×`, String, 1, P)
|
| 454 |
+
kicker(c, '以 2010 年为 1 · 年度', chA.x, chA.y - (P ? 34 : 30), C.gold, 1, P ? 22 : 20)
|
| 455 |
+
const pM = eio(prog(g.lt(1), 0.4, 3.2))
|
| 456 |
+
series(c, chA, M2P, pM, C.gold, { w: P ? 5 : 4.5, area: 0.16 })
|
| 457 |
+
if (pM > 0.98)
|
| 458 |
+
withA(c, pin(g, 1, 3.6), () => {
|
| 459 |
+
T(c, 'M2 4.69×', sx(chA, 2025) - 10, sy(chA, M2_IDX[15]) - 22, { size: fs + 4, w: 900, color: C.goldHi, align: 'right' })
|
| 460 |
+
T(c, '72.6 → 340.3 万亿元', sx(chA, 2025) - 10, sy(chA, M2_IDX[15]) + 40, { size: fs - 2, w: 500, color: C.mute, align: 'right' })
|
| 461 |
+
})
|
| 462 |
+
const pC = eio(prog(g.lt(2), 0.3, 2.4))
|
| 463 |
+
series(c, chA, CPIP, pC, C.ink, { w: P ? 4 : 3.5, glow: 8 })
|
| 464 |
+
if (pC > 0.98) withA(c, pin(g, 2, 2.8), () => T(c, 'CPI 1.32×', P ? sx(chA, 2025) - 10 : sx(chA, 2025) + 12, sy(chA, CPI_IDX[15]) + (P ? 40 : -16), { size: fs, w: 900, color: C.ink, align: P ? 'right' : 'left' }))
|
| 465 |
+
// 20 倍幽灵线
|
| 466 |
+
const gp = eo(prog(g.lt(2), 4.4, 1.2))
|
| 467 |
+
if (gp > 0) {
|
| 468 |
+
const gx = sx(chA, 2020)
|
| 469 |
+
const y0 = sy(chA, 1)
|
| 470 |
+
const y1 = lerp(y0, chA.y - (P ? 40 : 20), gp)
|
| 471 |
+
line(c, gx, y0, gx, y1, C.red, 2.5, 1, [7, 6])
|
| 472 |
+
c.save()
|
| 473 |
+
c.fillStyle = C.red
|
| 474 |
+
c.beginPath()
|
| 475 |
+
c.moveTo(gx, y1 - 14)
|
| 476 |
+
c.lineTo(gx - 9, y1 + 2)
|
| 477 |
+
c.lineTo(gx + 9, y1 + 2)
|
| 478 |
+
c.closePath()
|
| 479 |
+
c.fill()
|
| 480 |
+
c.restore()
|
| 481 |
+
T(c, 'kkndme:十年物价 ×20', gx - 16, chA.y + 30, { size: fs, w: 900, color: C.red, align: 'right', p: gp })
|
| 482 |
+
T(c, '(这张图要再高 4 倍才画得下)', gx - 16, chA.y + 30 + fs * 1.4, { size: fs - 4, w: 500, color: C.dim, align: 'right', p: gp })
|
| 483 |
+
}
|
| 484 |
+
const pH = eio(prog(g.lt(3), 0.6, 2.8))
|
| 485 |
+
series(c, chA, HOUP, pH, HOUSE_C, { w: P ? 5 : 4.5, glow: 14 })
|
| 486 |
+
if (pH > 0.7)
|
| 487 |
+
annot(c, sx(chA, 2021), sy(chA, HOUSE_IDX[11]), sx(chA, 2017), sy(chA, 2.6), [
|
| 488 |
+
{ s: '2021 年后:钱还在涨,房价掉头', size: fs, color: C.ink },
|
| 489 |
+
{ s: '房价指数 1.45× → 1.19×', size: fs - 4, color: C.mute, w: 500 },
|
| 490 |
+
], HOUSE_C, prog(g.lt(3), 2.6, 1.4), 'right')
|
| 491 |
+
})
|
| 492 |
+
// 图 B:汇率
|
| 493 |
+
withA(c, aB, () => {
|
| 494 |
+
grid(c, chB, [4, 5, 6, 7], [2010, 2014, 2018, 2022, 2026], (v) => v.toFixed(1), String, 1, P)
|
| 495 |
+
kicker(c, '美元兑人民币 · 月均价', chB.x, chB.y - (P ? 34 : 30), C.gold, 1, P ? 22 : 20)
|
| 496 |
+
const lp = eo(prog(g.lt(4), 1.4, 1.0))
|
| 497 |
+
line(c, chB.x, sy(chB, 4), chB.x + chB.w * lp, sy(chB, 4), C.red, 2.5, 1, [8, 7])
|
| 498 |
+
T(c, '4 : 1 kkndme:“国家不可能允许”', chB.x + 16, sy(chB, 4) - 16, { size: fs, w: 900, color: C.red, p: lp })
|
| 499 |
+
const p = eio(prog(g.lt(4), 0.6, 3.0))
|
| 500 |
+
series(c, chB, FXP, p, C.gold, { w: P ? 4 : 3.5, area: 0.12 })
|
| 501 |
+
const minI = FX.indexOf(Math.min(...FX))
|
| 502 |
+
const maxI = FX.indexOf(Math.max(...FX))
|
| 503 |
+
annot(c, sx(chB, FXP[minI][0]), sy(chB, FX[minI]), sx(chB, P ? 2010.6 : 2014.6), sy(chB, P ? 7.3 : 5.2), [
|
| 504 |
+
{ s: '2014.01 6.04', size: fs + 2, color: C.ink },
|
| 505 |
+
{ s: '人民币最强点(盘中)', size: fs - 4, color: C.mute, w: 500 },
|
| 506 |
+
], C.gold, prog(g.lt(4), 4.0, 1.2))
|
| 507 |
+
annot(c, sx(chB, FXP[maxI][0]), sy(chB, FX[maxI]), sx(chB, 2021.4), sy(chB, 5.4), [
|
| 508 |
+
{ s: '2023.10 7.31', size: fs + 2, color: C.ink },
|
| 509 |
+
{ s: '后来又贬回来', size: fs - 4, color: C.mute, w: 500 },
|
| 510 |
+
], C.gold, prog(g.lt(4), 5.6, 1.2), 'right')
|
| 511 |
+
})
|
| 512 |
+
|
| 513 |
+
const pn = P ? { x: 80, y: 1100, w: 920 } : { x: 1250, y: 300, w: 530 }
|
| 514 |
+
const { x: px, y: py, w: pw } = pn
|
| 515 |
+
// 逻辑链
|
| 516 |
+
const chainA = Math.min(pin(g, 0, 0.2), 1 - eo(prog(g.lt(4), -0.2, 0.5)))
|
| 517 |
+
withA(c, chainA, () => {
|
| 518 |
+
kicker(c, 'kkndme 的核心逻辑', px, py + 20, C.gold, 1, 20)
|
| 519 |
+
const nodes = ['货币���发', '高通胀', '房价托底']
|
| 520 |
+
const res = [pin(g, 1, 3.8), pin(g, 2, 4.0), pin(g, 3, 2.2)]
|
| 521 |
+
const kinds = ['ok', 'no', 'no'] as const
|
| 522 |
+
nodes.forEach((n, i) => {
|
| 523 |
+
const p = pin(g, 0, 1.2 + i * 1.0)
|
| 524 |
+
const nx = P ? px + i * 320 : px
|
| 525 |
+
const ny = P ? py + 110 : py + 110 + i * 150
|
| 526 |
+
const nw = P ? 280 : 340
|
| 527 |
+
withA(c, p, () => {
|
| 528 |
+
glass(c, nx, ny - 50, nw, 90, 20, 1, res[i] > 0.5 ? (kinds[i] === 'ok' ? C.green : C.red) : undefined)
|
| 529 |
+
T(c, n, nx + 28, ny + 10, { size: P ? 36 : 36, w: 900, f: 'serif' })
|
| 530 |
+
if (res[i] > 0) {
|
| 531 |
+
const ix = nx + nw - 44
|
| 532 |
+
dot(c, ix, ny - 5, 20, kinds[i] === 'ok' ? C.green : C.red, res[i])
|
| 533 |
+
if (kinds[i] === 'ok') checkMark(c, ix, ny - 4, 18, C.bg, res[i], 4)
|
| 534 |
+
else crossMark(c, ix, ny - 5, 18, C.bg, res[i], 4)
|
| 535 |
+
}
|
| 536 |
+
if (i < 2) {
|
| 537 |
+
const broken = res[i + 1] > 0.5
|
| 538 |
+
const ax = P ? nx + nw + 6 : nx + 40
|
| 539 |
+
const ay = P ? ny - 5 : ny + 44
|
| 540 |
+
const bx = P ? nx + 314 : nx + 40
|
| 541 |
+
const by = P ? ny - 5 : ny + 106
|
| 542 |
+
line(c, ax, ay, bx, by, broken ? C.red : C.gold, 2.5, pin(g, 0, 1.8 + i * 1.0), broken ? [5, 6] : undefined)
|
| 543 |
+
}
|
| 544 |
+
})
|
| 545 |
+
})
|
| 546 |
+
withA(c, pin(g, 3, 4.6), () => {
|
| 547 |
+
T(c, '印钞托底房价 → 2021 年后失灵', px, P ? py + 260 : py + 500, { size: P ? 30 : 28, w: 700, color: C.goldHi })
|
| 548 |
+
})
|
| 549 |
+
withA(c, pin(g, 2, 2.0) * (1 - pin(g, 3, 4.2)), () => {
|
| 550 |
+
T(c, 'CPI 2012—2025 年均仅约 1.6%', px, P ? py + 260 : py + 500, { size: P ? 28 : 26, w: 500, color: C.mute })
|
| 551 |
+
})
|
| 552 |
+
})
|
| 553 |
+
// 汇率面板
|
| 554 |
+
withA(c, vis(g, 4, 5), () => {
|
| 555 |
+
const y = quote(g, '“我不认为人民币能到 4:1,国家也不可能允许 4:1。”', px, py + 20, pw, pin(g, 4, 0.4))
|
| 556 |
+
const rowsF = [
|
| 557 |
+
['2010.09 发帖时', '≈ 6.7'],
|
| 558 |
+
['最高(2014.01 盘中)', '6.04'],
|
| 559 |
+
['2026.10', '6.67'],
|
| 560 |
+
]
|
| 561 |
+
rowsF.forEach(([a, b], i) => {
|
| 562 |
+
const yy = y + (P ? 56 : 64) + i * (P ? 50 : 56)
|
| 563 |
+
const p = pin(g, 4, 2.4 + i * 0.4)
|
| 564 |
+
T(c, a, px, yy, { size: P ? 26 : 24, w: 500, color: C.mute, p })
|
| 565 |
+
T(c, b, px + (P ? 600 : pw), yy, { size: P ? 32 : 30, w: 900, f: 'serif', align: 'right', p })
|
| 566 |
+
})
|
| 567 |
+
chip(c, '说对 · 适度升值、到不了 4:1', px, y + (P ? 230 : 260), 'ok', pin(g, 4, 6.6), P ? 26 : 22)
|
| 568 |
+
})
|
| 569 |
+
// 黄金
|
| 570 |
+
withA(c, vis(g, 5), () => {
|
| 571 |
+
kicker(c, 'GOLD · 美元/盎司', px, py + 20, C.gold, pin(g, 5, 0.2), 20)
|
| 572 |
+
const ms = [
|
| 573 |
+
{ d: '2010.09', v: 1250, l: '发帖时' },
|
| 574 |
+
{ d: '2011', v: 1920, l: '高点' },
|
| 575 |
+
{ d: '2015 底', v: 1050, l: '2013 年暴跌 28%' },
|
| 576 |
+
{ d: '2026.10', v: 4024, l: '十五年 3.2 倍' },
|
| 577 |
+
]
|
| 578 |
+
const base = py + (P ? 330 : 470)
|
| 579 |
+
const maxH = P ? 240 : 330
|
| 580 |
+
const step = P ? 220 : 130
|
| 581 |
+
const bw = P ? 110 : 76
|
| 582 |
+
line(c, px, base, px + step * 3 + bw + 10, base, 'rgba(243,238,228,0.25)', 1.5)
|
| 583 |
+
ms.forEach((m, i) => {
|
| 584 |
+
const bx = px + i * step
|
| 585 |
+
const p = pinR(g, 5, [0.8, 1.6, 3.4, 6.0][i], 1)
|
| 586 |
+
const col = i === 3 ? C.goldHi : i === 2 ? C.red : '#9C8458'
|
| 587 |
+
const top = vbar(c, bx, base, bw, (m.v / 4024) * maxH, col, p)
|
| 588 |
+
T(c, m.v.toLocaleString('en-US'), bx + bw / 2, top - 14, { size: P ? 30 : 26, w: 900, f: 'serif', align: 'center', p: eo(p) })
|
| 589 |
+
T(c, m.d, bx + bw / 2, base + 32, { size: P ? 22 : 20, w: 700, color: C.mute, align: 'center', p: eo(p) })
|
| 590 |
+
})
|
| 591 |
+
T(c, '短期说对(2013 暴跌 28%),长期错过 3 倍涨幅', px, base + (P ? 72 : 90), { size: P ? 26 : 22, w: 700, color: C.goldHi, p: pin(g, 5, 7.0) })
|
| 592 |
+
})
|
| 593 |
+
}
|
kkndme/frontend/src/video/scenes3.ts
ADDED
|
@@ -0,0 +1,976 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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+
pulse,
|
| 21 |
+
shine,
|
| 22 |
+
shineText,
|
| 23 |
+
sweepBand,
|
| 24 |
+
grid,
|
| 25 |
+
series,
|
| 26 |
+
annot,
|
| 27 |
+
sx,
|
| 28 |
+
sy,
|
| 29 |
+
C,
|
| 30 |
+
T,
|
| 31 |
+
clamp,
|
| 32 |
+
lerp,
|
| 33 |
+
prog,
|
| 34 |
+
eo,
|
| 35 |
+
eo5,
|
| 36 |
+
eio,
|
| 37 |
+
eback,
|
| 38 |
+
hexA,
|
| 39 |
+
rr,
|
| 40 |
+
dot,
|
| 41 |
+
line,
|
| 42 |
+
measure,
|
| 43 |
+
checkMark,
|
| 44 |
+
crossMark,
|
| 45 |
+
} from './kit'
|
| 46 |
+
import { STATUS_COLOR, wrap } from './draw'
|
| 47 |
+
import { rows, bySpec, byBold, byType, byTopic, brier as brierFn, BRIER, all } from '../data/science'
|
| 48 |
+
|
| 49 |
+
const seed = (i: number, n: number) => {
|
| 50 |
+
const v = Math.sin(i * 73.3 + n * 19.7) * 35711.913
|
| 51 |
+
return v - Math.floor(v)
|
| 52 |
+
}
|
| 53 |
+
const pct = (v: number) => Math.round(v * 100)
|
| 54 |
+
|
| 55 |
+
function quoteBlock(g: G, s: string, x: number, y: number, w: number, p: number, size?: number, label = 'kkndme 原话') {
|
| 56 |
+
const fs = size ?? (g.P ? 36 : 32)
|
| 57 |
+
T(g.c, label, x, y, { size: g.P ? 22 : 20, w: 700, color: C.dim, ls: 4, p })
|
| 58 |
+
const ls = wrap(g.c, s, w, fs, 900, 'serif')
|
| 59 |
+
ls.forEach((l, k) => T(g.c, l, x, y + 14 + fs * 1.32 * (k + 1), { size: fs, w: 900, f: 'serif', p: clamp(p * 1.3 - k * 0.15) }))
|
| 60 |
+
return y + 14 + fs * 1.32 * ls.length
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
function mark(c: G['c'], x: number, y: number, ok: boolean, p: number, r = 20) {
|
| 64 |
+
if (p <= 0) return
|
| 65 |
+
dot(c, x, y, r, ok ? C.green : C.red, p)
|
| 66 |
+
if (ok) checkMark(c, x, y + 1, r * 0.9, C.bg, p, r * 0.2)
|
| 67 |
+
else crossMark(c, x, y, r * 0.85, C.bg, p, r * 0.2)
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
// ============ 政策 ============
|
| 71 |
+
const policyR = byTopic.find((x) => x.k === '调控与房产税')!.r
|
| 72 |
+
|
| 73 |
+
export function policy(g: G) {
|
| 74 |
+
const { c, P } = g
|
| 75 |
+
const M = P ? 80 : 140
|
| 76 |
+
// —— 顶部时间轴(常驻)
|
| 77 |
+
const ty = P ? 470 : 316
|
| 78 |
+
const tx0 = P ? 110 : 200
|
| 79 |
+
const tx1 = P ? 970 : 1720
|
| 80 |
+
const X = (yr: number) => lerp(tx0, tx1, (yr - 2010) / 16.8)
|
| 81 |
+
const ta = pin(g, 0, 0.2, 1)
|
| 82 |
+
withA(c, ta, () => {
|
| 83 |
+
line(c, tx0, ty, tx0 + (tx1 - tx0) * eio(prog(g.lt(0), 0.2, 1.6)), ty, 'rgba(243,238,228,0.28)', 1.5)
|
| 84 |
+
for (let y = 2010; y <= 2026; y++) {
|
| 85 |
+
const x = X(y)
|
| 86 |
+
const major = y % 4 === 2 || y === 2010 || y === 2026
|
| 87 |
+
line(c, x, ty - (major ? 8 : 4), x, ty + (major ? 8 : 4), 'rgba(243,238,228,0.35)', 1.5)
|
| 88 |
+
if (y === 2010 || y === 2014 || y === 2018 || y === 2022 || y === 2026) T(c, String(y), x, ty + (P ? 40 : 36), { size: P ? 22 : 18, w: 500, color: C.dim, align: 'center' })
|
| 89 |
+
}
|
| 90 |
+
})
|
| 91 |
+
const marks: { y: number; k: number; col: string }[] = [
|
| 92 |
+
{ y: 2010.6, k: 4, col: C.gold },
|
| 93 |
+
{ y: 2011.08, k: 2, col: C.gold },
|
| 94 |
+
{ y: 2011.9, k: 1, col: C.green },
|
| 95 |
+
{ y: 2020.4, k: 3, col: C.green },
|
| 96 |
+
{ y: 2021.8, k: 2, col: C.gold },
|
| 97 |
+
{ y: 2022.2, k: 2, col: C.gold },
|
| 98 |
+
{ y: 2024.4, k: 5, col: C.red },
|
| 99 |
+
{ y: 2026.3, k: 2, col: C.gold },
|
| 100 |
+
]
|
| 101 |
+
const cur = [0, 1, 2, 3, 4, 5].reduce((a, i) => (g.lt(i) >= 0 ? i : a), 0)
|
| 102 |
+
marks.forEach((m) => {
|
| 103 |
+
const p = pin(g, m.k, 0.3)
|
| 104 |
+
if (p <= 0) return
|
| 105 |
+
const on = m.k === cur
|
| 106 |
+
withA(c, on ? 1 : 0.45, () => {
|
| 107 |
+
if (on) pulse(c, X(m.y), ty, 7, g.t, m.col, 0.8)
|
| 108 |
+
glowDot(c, X(m.y), ty, 7 * eback(p), m.col)
|
| 109 |
+
})
|
| 110 |
+
})
|
| 111 |
+
|
| 112 |
+
const top = P ? 580 : 400
|
| 113 |
+
// 0:命中率
|
| 114 |
+
withA(c, vis(g, 0, 1), () => {
|
| 115 |
+
const rcx = P ? 540 : 520
|
| 116 |
+
const rcy = P ? 860 : 640
|
| 117 |
+
const R = P ? 230 : 190
|
| 118 |
+
const p = pinR(g, 0, 0.4, 2.2)
|
| 119 |
+
ring(c, rcx, rcy, R, P ? 30 : 26, [
|
| 120 |
+
{ v: policyR.correct, color: C.green },
|
| 121 |
+
{ v: policyR.wrong, color: C.red },
|
| 122 |
+
{ v: policyR.disputed, color: C.amber },
|
| 123 |
+
], p)
|
| 124 |
+
const w = roll(c, '83', rcx - 18, rcy + 40, { size: P ? 150 : 130, w: 900, f: 'serif', align: 'center' }, p, (x0, ww) => shine(c, x0, ww, prog(g.lt(0), 3, 1.2) * 1.6 - 0.3, C.ink))
|
| 125 |
+
T(c, '%', rcx - 18 + w / 2 + 6, rcy + 40, { size: P ? 60 : 54, w: 900, f: 'serif', color: C.gold, p: eo(p) })
|
| 126 |
+
const lx = P ? M : 900
|
| 127 |
+
const ly = P ? 1220 : 470
|
| 128 |
+
kicker(c, 'POLICY CALLS · 调控与房产税', lx, ly, C.gold, pin(g, 0, 1.4), 20)
|
| 129 |
+
T(c, '他另一块强项', lx, ly + (P ? 80 : 84), { size: P ? 56 : 60, w: 900, f: 'serif', p: pin(g, 0, 1.7) })
|
| 130 |
+
;[
|
| 131 |
+
['说对', policyR.correct, C.green],
|
| 132 |
+
['说错', policyR.wrong, C.red],
|
| 133 |
+
['参半', policyR.disputed, C.amber],
|
| 134 |
+
].forEach(([l, n, col], i) => {
|
| 135 |
+
const q = pin(g, 0, 2.6 + i * 0.3)
|
| 136 |
+
const xx = lx + i * (P ? 200 : 190)
|
| 137 |
+
const yy = ly + (P ? 160 : 180)
|
| 138 |
+
dot(c, xx + 9, yy - 12, 8, col as string, q)
|
| 139 |
+
T(c, String(n), xx + 28, yy, { size: P ? 52 : 52, w: 900, f: 'serif', p: q })
|
| 140 |
+
T(c, l as string, xx + 28 + measure(c, String(n), 52, 900, 'serif') + 10, yy, { size: P ? 26 : 24, w: 500, color: C.mute, p: q })
|
| 141 |
+
})
|
| 142 |
+
if (!P) T(c, '读懂政策的动机,比读懂市场容易', lx, ly + 270, { size: 28, w: 500, color: C.dim, p: pin(g, 0, 4) })
|
| 143 |
+
})
|
| 144 |
+
// 1:限购扩围
|
| 145 |
+
withA(c, vis(g, 1, 2), () => {
|
| 146 |
+
const x = M + (P ? 0 : 60)
|
| 147 |
+
const y = quoteBlock(g, '“两年内调控都不会放松。”', x, top + 20, P ? 900 : 700, pin(g, 1, 0.2), P ? 44 : 44)
|
| 148 |
+
T(c, '实施限购的城市', x, y + (P ? 80 : 70), { size: P ? 28 : 26, w: 500, color: C.mute, p: pin(g, 1, 3.2) })
|
| 149 |
+
const w = roll(c, '46', x, y + (P ? 230 : 230), { size: P ? 180 : 180, w: 900, f: 'serif', color: C.ink }, pinR(g, 1, 3.4, 1.6))
|
| 150 |
+
T(c, '城', x + w + 10, y + (P ? 230 : 230), { size: 60, w: 900, f: 'serif', color: C.gold, p: pin(g, 1, 4.2) })
|
| 151 |
+
T(c, '2011 年底', x + w + 90, y + (P ? 230 : 230), { size: P ? 28 : 26, w: 500, color: C.dim, p: pin(g, 1, 4.6) })
|
| 152 |
+
// 右:从 1 城到 46 城
|
| 153 |
+
const bx = P ? M + 40 : 1100
|
| 154 |
+
const base = P ? 1450 : 830
|
| 155 |
+
const bars = [
|
| 156 |
+
{ l: '2010.04', s: '北京率先', v: 1 },
|
| 157 |
+
{ l: '2010 年底', s: '一线及热点', v: 16 },
|
| 158 |
+
{ l: '2011 年底', s: '扩大到', v: 46 },
|
| 159 |
+
]
|
| 160 |
+
const H = P ? 300 : 380
|
| 161 |
+
bars.forEach((b, i) => {
|
| 162 |
+
const p = pinR(g, 1, 1.0 + i * 0.9, 1)
|
| 163 |
+
const xx = bx + i * (P ? 300 : 210)
|
| 164 |
+
const top2 = vbar(c, xx, base, P ? 120 : 110, Math.max(8, (b.v / 46) * H), i === 2 ? C.gold : '#8C7F68', p)
|
| 165 |
+
T(c, `${b.v} 城`, xx + (P ? 60 : 55), top2 - 16, { size: P ? 34 : 32, w: 900, f: 'serif', align: 'center', p: eo(p) })
|
| 166 |
+
T(c, b.l, xx + (P ? 60 : 55), base + 34, { size: P ? 22 : 20, w: 700, color: C.mute, align: 'center', p: eo(p) })
|
| 167 |
+
})
|
| 168 |
+
if (!P) T(c, '数量为约数,口径以政策公开报道为准', 1100, 890, { size: 18, w: 500, color: C.dim, p: pin(g, 1, 3) })
|
| 169 |
+
chip(c, '调控不放松', P ? M : x, P ? y + 320 : y + 320, 'ok', pin(g, 1, 5.6), P ? 26 : 24)
|
| 170 |
+
chip(c, '限购扩围', P ? M + 240 : x + 230, P ? y + 320 : y + 320, 'ok', pin(g, 1, 6.0), P ? 26 : 24)
|
| 171 |
+
})
|
| 172 |
+
// 2:房产税难产
|
| 173 |
+
withA(c, vis(g, 2, 3), () => {
|
| 174 |
+
const x = M + (P ? 0 : 60)
|
| 175 |
+
quoteBlock(g, '“房产税的推出就没那么容易了。”', x, top + 20, P ? 900 : 1400, pin(g, 2, 0.2), P ? 44 : 44)
|
| 176 |
+
const ms = [
|
| 177 |
+
{ d: '2011.01', t: '沪渝试点', s: '仅两城、仅增量为主' },
|
| 178 |
+
{ d: '2021.10', t: '人大授权扩大试点', s: '试点办法始终未出' },
|
| 179 |
+
{ d: '2022.03', t: '年内不扩大试点', s: '财政部明确暂缓' },
|
| 180 |
+
{ d: '2026', t: '“十五五”未再提', s: '立法计划里也没有' },
|
| 181 |
+
]
|
| 182 |
+
const y0 = P ? top + 230 : top + 220
|
| 183 |
+
ms.forEach((m, i) => {
|
| 184 |
+
const p = pin(g, 2, 2.0 + i * 0.9)
|
| 185 |
+
const cw = P ? 920 : 370
|
| 186 |
+
const ch = P ? 140 : 230
|
| 187 |
+
const cx = P ? M : x + i * 400
|
| 188 |
+
const cy = P ? y0 + i * 160 : y0
|
| 189 |
+
withA(c, p, () => {
|
| 190 |
+
c.save()
|
| 191 |
+
c.translate(0, (1 - p) * 30)
|
| 192 |
+
glass(c, cx, cy, cw, ch, 20, 1, i === 3 ? C.gold : undefined)
|
| 193 |
+
T(c, m.d, cx + 28, cy + (P ? 50 : 56), { size: P ? 26 : 24, w: 900, color: C.gold })
|
| 194 |
+
T(c, m.t, cx + 28, cy + (P ? 100 : 120), { size: P ? 36 : 34, w: 900, f: 'serif' })
|
| 195 |
+
T(c, m.s, P ? cx + cw - 28 : cx + 28, cy + (P ? 100 : 176), { size: P ? 24 : 22, w: 500, color: C.mute, align: P ? 'right' : 'left' })
|
| 196 |
+
c.restore()
|
| 197 |
+
})
|
| 198 |
+
if (!P && i < 3) line(c, cx + cw + 4, y0 + ch / 2, cx + 396, y0 + ch / 2, C.gold, 2, pin(g, 2, 2.5 + i * 0.9))
|
| 199 |
+
})
|
| 200 |
+
chip(c, '真正实施很难 · 说对', P ? M : x, P ? y0 + 690 : y0 + 330, 'ok', pin(g, 2, 6.4), P ? 26 : 24)
|
| 201 |
+
})
|
| 202 |
+
// 3:民法典
|
| 203 |
+
withA(c, vis(g, 3, 4), () => {
|
| 204 |
+
const cw = P ? 920 : 1100
|
| 205 |
+
const chh = P ? 620 : 440
|
| 206 |
+
const cx = P ? M : 410
|
| 207 |
+
const cy = P ? 640 : 410
|
| 208 |
+
card3d(c, cx + cw / 2, cy + chh / 2, pin(g, 3, 0.2, 1.1), () => {
|
| 209 |
+
glass(c, cx, cy, cw, chh, 26, 1, C.gold)
|
| 210 |
+
line(c, cx + 50, cy + 80, cx + cw - 50, cy + 80, hexA(C.gold, 0.5), 1.5)
|
| 211 |
+
T(c, '中华人民共和国民法典', cx + cw / 2, cy + 58, { size: P ? 26 : 24, w: 700, color: C.gold, align: 'center', ls: 6 })
|
| 212 |
+
T(c, '第 三 百 五 十 九 条', cx + cw / 2, cy + (P ? 170 : 160), { size: P ? 50 : 46, w: 900, f: 'serif', align: 'center' })
|
| 213 |
+
const s1 = '住宅建设用地使用权期间届满的,'
|
| 214 |
+
const s2 = '自动续期。'
|
| 215 |
+
maskText(c, s1, cx + cw / 2, cy + (P ? 290 : 260), { size: P ? 46 : 46, w: 900, f: 'serif', align: 'center' }, pinR(g, 3, 1.4, 1))
|
| 216 |
+
const p2 = pinR(g, 3, 2.2, 1)
|
| 217 |
+
maskText(c, s2, cx + cw / 2, cy + (P ? 380 : 340), { size: P ? 70 : 64, w: 900, f: 'serif', align: 'center', color: C.goldHi }, p2)
|
| 218 |
+
const uw = measure(c, s2, P ? 70 : 64, 900, 'serif')
|
| 219 |
+
line(c, cx + cw / 2 - uw / 2, cy + (P ? 400 : 358), cx + cw / 2 - uw / 2 + uw * eio(prog(g.lt(3), 3, 0.8)), cy + (P ? 400 : 358), C.gold, 3)
|
| 220 |
+
T(c, '2020 年 5 月通过 · 2021 年 1 月 1 日施行', cx + cw / 2, cy + chh - (P ? 70 : 40), { size: P ? 24 : 22, w: 500, color: C.mute, align: 'center', p: pin(g, 3, 4) })
|
| 221 |
+
})
|
| 222 |
+
T(c, 'kkndme:“70 年产权到期会自动续期”', P ? M : 410, P ? 1340 : 900, { size: P ? 30 : 26, w: 700, color: C.mute, p: pin(g, 3, 4.6) })
|
| 223 |
+
chip(c, '写进法律 · 说对', P ? M : 1510, P ? 1410 : 880, P ? 'ok' : 'ok', pin(g, 3, 5.2), P ? 26 : 24, P ? 'left' : 'right')
|
| 224 |
+
})
|
| 225 |
+
// 4:两次翻车
|
| 226 |
+
withA(c, vis(g, 4, 5), () => {
|
| 227 |
+
const cw = P ? 920 : 760
|
| 228 |
+
const chh = P ? 430 : 470
|
| 229 |
+
const L = [
|
| 230 |
+
{ q: '“近两年一定不会征收房产税”', x: M, y: P ? 600 : 400 },
|
| 231 |
+
{ q: '“限购不会是长期政策”', x: P ? M : 1020, y: P ? 1070 : 400 },
|
| 232 |
+
]
|
| 233 |
+
L.forEach((b, i) => {
|
| 234 |
+
const p = pin(g, 4, i ? 4.6 : 0.4, 0.8)
|
| 235 |
+
withA(c, p, () => {
|
| 236 |
+
glass(c, b.x, b.y, cw, chh, 24, 1, C.red)
|
| 237 |
+
T(c, b.q, b.x + 36, b.y + 76, { size: P ? 38 : 36, w: 900, f: 'serif' })
|
| 238 |
+
mark(c, b.x + cw - 52, b.y + 64, false, pin(g, 4, i ? 6.8 : 3.6), 22)
|
| 239 |
+
})
|
| 240 |
+
const ax0 = b.x + 60
|
| 241 |
+
const ax1 = b.x + cw - 60
|
| 242 |
+
const ay = b.y + (P ? 270 : 290)
|
| 243 |
+
if (i === 0) {
|
| 244 |
+
// 2010.08 → 2011.01.28
|
| 245 |
+
const p1 = eo(prog(g.lt(4), 1.4, 1.4))
|
| 246 |
+
withA(c, p, () => {
|
| 247 |
+
line(c, ax0, ay, ax1, ay, 'rgba(243,238,228,0.2)', 2)
|
| 248 |
+
T(c, '2010.08 发帖', ax0, ay + 44, { size: P ? 24 : 22, w: 700, color: C.mute })
|
| 249 |
+
T(c, '2012.08 “两年”期限', ax1, ay + 44, { size: P ? 24 : 22, w: 700, color: C.dim, align: 'right' })
|
| 250 |
+
line(c, ax1, ay - 10, ax1, ay + 10, C.dim, 2)
|
| 251 |
+
})
|
| 252 |
+
const xx = lerp(ax0, lerp(ax0, ax1, 5 / 24), p1)
|
| 253 |
+
if (p1 > 0) {
|
| 254 |
+
line(c, ax0, ay, xx, ay, C.red, 6)
|
| 255 |
+
glowDot(c, xx, ay, 8, C.red)
|
| 256 |
+
T(c, '5 个月', (ax0 + xx) / 2 + 40, ay - 40, { size: P ? 60 : 56, w: 900, f: 'serif', color: C.red, align: 'left', p: p1 })
|
| 257 |
+
T(c, '2011.01.28 沪渝开征', xx, ay - (P ? 110 : 110), { size: P ? 24 : 22, w: 700, color: C.ink, align: 'left', p: pin(g, 4, 2.6) })
|
| 258 |
+
}
|
| 259 |
+
} else {
|
| 260 |
+
const p1 = eo(prog(g.lt(4), 5.4, 1.6))
|
| 261 |
+
withA(c, p, () => {
|
| 262 |
+
line(c, ax0, ay, ax1, ay, 'rgba(243,238,228,0.2)', 2)
|
| 263 |
+
T(c, '2010', ax0, ay + 44, { size: P ? 24 : 22, w: 700, color: C.mute })
|
| 264 |
+
T(c, '2024', ax1, ay + 44, { size: P ? 24 : 22, w: 700, color: C.mute, align: 'right' })
|
| 265 |
+
})
|
| 266 |
+
if (p1 > 0) {
|
| 267 |
+
const xx = lerp(ax0, ax1, p1)
|
| 268 |
+
hbar(c, ax0, ay - 12, ax1 - ax0, 24, 1, C.red, p1, false)
|
| 269 |
+
glowDot(c, xx, ay, 8, C.red)
|
| 270 |
+
roll(c, '14', ax0, ay - 50, { size: P ? 60 : 56, w: 900, f: 'serif', color: C.red }, p1)
|
| 271 |
+
T(c, '年', ax0 + measure(c, '14', P ? 60 : 56, 900, 'serif') + 8, ay - 50, { size: P ? 34 : 30, w: 900, f: 'serif', color: C.red, p: p1 })
|
| 272 |
+
T(c, '多数城市到 2024 年后才陆续放开', ax0, ay + (P ? 100 : 110), { size: P ? 24 : 22, w: 500, color: C.dim, p: pin(g, 4, 7) })
|
| 273 |
+
}
|
| 274 |
+
}
|
| 275 |
+
})
|
| 276 |
+
})
|
| 277 |
+
// 5:首付
|
| 278 |
+
withA(c, vis(g, 5), () => {
|
| 279 |
+
const ch: Chart = P ? { x: 170, y: 640, w: 800, h: 560, x0: 2010, x1: 2026, y0: 0, y1: 45 } : { x: 260, y: 420, w: 1000, h: 400, x0: 2010, x1: 2026, y0: 0, y1: 45 }
|
| 280 |
+
grid(c, ch, [0, 15, 30, 45], [2010, 2014, 2018, 2022, 2026], (v) => `${v}%`, String, pin(g, 5, 0.1), P)
|
| 281 |
+
kicker(c, '首套房最低首付比例', ch.x, ch.y - 30, C.gold, pin(g, 5, 0.1), 20)
|
| 282 |
+
const kp = eo(prog(g.lt(5), 0.4, 1))
|
| 283 |
+
line(c, ch.x, sy(ch, 40), ch.x + ch.w * kp, sy(ch, 40), C.red, 2.5, 1, [8, 7])
|
| 284 |
+
T(c, 'kkndme:“理想状况应该是 40%”', ch.x + 16, sy(ch, 40) - 16, { size: P ? 26 : 24, w: 900, color: C.red, p: kp })
|
| 285 |
+
const steps: [number, number][] = [
|
| 286 |
+
[2010, 30],
|
| 287 |
+
[2015.7, 30],
|
| 288 |
+
[2015.7, 25],
|
| 289 |
+
[2016.1, 25],
|
| 290 |
+
[2016.1, 20],
|
| 291 |
+
[2023.6, 20],
|
| 292 |
+
[2024.4, 20],
|
| 293 |
+
[2024.4, 15],
|
| 294 |
+
[2026, 15],
|
| 295 |
+
]
|
| 296 |
+
series(c, ch, steps, eio(prog(g.lt(5), 1.4, 3.0)), C.gold, { w: P ? 5 : 4.5, area: 0.18 })
|
| 297 |
+
const lab = (yr: number, v: number, s: string, d: number) => T(c, s, sx(ch, yr) + 10, sy(ch, v) - 16, { size: P ? 22 : 20, w: 700, color: C.mute, p: pin(g, 5, d) })
|
| 298 |
+
lab(2010.2, 30, '30%', 1.6)
|
| 299 |
+
lab(2016.1, 20, '20% · 非限购城市', 2.6)
|
| 300 |
+
T(c, '15%', sx(ch, 2024.4) + 10, sy(ch, 15) - 18, { size: P ? 44 : 44, w: 900, f: 'serif', color: C.goldHi, p: pin(g, 5, 4.2) })
|
| 301 |
+
const rx = P ? M : 1360
|
| 302 |
+
const ry = P ? 1320 : 470
|
| 303 |
+
withA(c, pin(g, 5, 4.6), () => {
|
| 304 |
+
T(c, '2024.05', rx, ry, { size: P ? 26 : 24, w: 900, color: C.gold })
|
| 305 |
+
T(c, '首付降至 15%', rx, ry + (P ? 56 : 60), { size: P ? 44 : 44, w: 900, f: 'serif' })
|
| 306 |
+
T(c, '1998 年房改以来最低', rx, ry + (P ? 106 : 112), { size: P ? 26 : 24, w: 500, color: C.mute })
|
| 307 |
+
})
|
| 308 |
+
chip(c, '方向判反', rx, ry + (P ? 170 : 190), 'no', pin(g, 5, 5.4), P ? 26 : 24)
|
| 309 |
+
})
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
// ============ 三把尺子 ============
|
| 313 |
+
const RULERS = [
|
| 314 |
+
{ t: '具体程度', s: '说得越具体,越容易被证伪', data: bySpec.map((x) => ({ l: x.label, r: x.r })) },
|
| 315 |
+
{ t: '是否逆共识', s: '和大众唱反调,难度更高', data: byBold.map((x) => ({ l: x.label, r: x.r })) },
|
| 316 |
+
{
|
| 317 |
+
t: '赌的是什么',
|
| 318 |
+
s: '同样是预测,难度天差地别',
|
| 319 |
+
data: [...byType].sort((a, b) => b.r.hit - a.r.hit).map((x) => ({ l: x.label, r: x.r })),
|
| 320 |
+
},
|
| 321 |
+
]
|
| 322 |
+
export function rulers(g: G) {
|
| 323 |
+
const { c, P } = g
|
| 324 |
+
const M = P ? 80 : 140
|
| 325 |
+
// 0:三把尺子
|
| 326 |
+
withA(c, vis(g, 0, 1), () => {
|
| 327 |
+
RULERS.forEach((r, i) => {
|
| 328 |
+
const p = pin(g, 0, 0.6 + i * 0.5, 0.9)
|
| 329 |
+
const w = P ? 920 : 500
|
| 330 |
+
const h = P ? 300 : 440
|
| 331 |
+
const x = P ? M : M + i * 560
|
| 332 |
+
const y = P ? 450 + i * 340 : 360
|
| 333 |
+
withA(c, p, () => {
|
| 334 |
+
c.save()
|
| 335 |
+
c.translate(0, (1 - p) * 60)
|
| 336 |
+
glass(c, x, y, w, h, 26)
|
| 337 |
+
T(c, `0${i + 1}`, x + 40, y + (P ? 110 : 130), { size: P ? 90 : 110, w: 900, f: 'serif', color: hexA(C.gold, 0.9) })
|
| 338 |
+
T(c, r.t, x + (P ? 220 : 40), y + (P ? 100 : 240), { size: P ? 50 : 52, w: 900, f: 'serif' })
|
| 339 |
+
T(c, r.s, x + (P ? 220 : 40), y + (P ? 160 : 300), { size: P ? 26 : 24, w: 500, color: C.mute })
|
| 340 |
+
// 刻度
|
| 341 |
+
const ry = y + h - (P ? 70 : 70)
|
| 342 |
+
const n = 24
|
| 343 |
+
for (let k = 0; k <= n; k++) {
|
| 344 |
+
const xx = x + 40 + ((w - 80) * k) / n
|
| 345 |
+
const q = clamp(p * 1.6 - k / n / 1.5)
|
| 346 |
+
line(c, xx, ry, xx, ry - (k % 4 === 0 ? 26 : 12) * q, hexA(C.gold, 0.6), 2)
|
| 347 |
+
}
|
| 348 |
+
line(c, x + 40, ry, x + w - 40, ry, hexA(C.gold, 0.6), 2)
|
| 349 |
+
c.restore()
|
| 350 |
+
})
|
| 351 |
+
})
|
| 352 |
+
})
|
| 353 |
+
// 1–3:柱状图
|
| 354 |
+
;[0, 1, 2].forEach((ri) => {
|
| 355 |
+
const k = ri + 1
|
| 356 |
+
const a = vis(g, k, k + 1 <= 3 ? k + 1 : 4)
|
| 357 |
+
withA(c, a, () => {
|
| 358 |
+
const R = RULERS[ri]
|
| 359 |
+
const n = R.data.length
|
| 360 |
+
const ch = P ? { x: M + 40, y: 520, w: 840, h: 520 } : { x: 220, y: 330, w: 1060, h: 470 }
|
| 361 |
+
const yOf = (v: number) => ch.y + ch.h - v * ch.h
|
| 362 |
+
kicker(c, `RULER 0${k} · ${R.t}`, ch.x, ch.y - 20, C.gold, 1, 20)
|
| 363 |
+
// 网格 + 50% 线
|
| 364 |
+
;[0, 0.25, 0.5, 0.75, 1].forEach((v) => {
|
| 365 |
+
if (v === 0.5) return
|
| 366 |
+
line(c, ch.x, yOf(v), ch.x + ch.w, yOf(v), 'rgba(243,238,228,0.08)', 1, 1, [3, 7])
|
| 367 |
+
T(c, `${v * 100}%`, ch.x - 14, yOf(v) + 7, { size: P ? 22 : 18, w: 500, color: C.dim, align: 'right' })
|
| 368 |
+
})
|
| 369 |
+
const lp = eo(prog(g.lt(k), 0.2, 0.8))
|
| 370 |
+
line(c, ch.x, yOf(0.5), ch.x + ch.w * lp, yOf(0.5), C.ink, 2, 0.6, [8, 8])
|
| 371 |
+
T(c, '50%', ch.x - 14, yOf(0.5) + 7, { size: P ? 22 : 18, w: 700, color: C.ink, align: 'right', p: lp })
|
| 372 |
+
T(c, '抛硬币', ch.x - 14, yOf(0.5) + (P ? 36 : 32), { size: P ? 20 : 18, w: 700, color: C.mute, align: 'right', p: lp })
|
| 373 |
+
line(c, ch.x, ch.y + ch.h, ch.x + ch.w, ch.y + ch.h, 'rgba(243,238,228,0.3)', 1.5)
|
| 374 |
+
const slot = ch.w / n
|
| 375 |
+
const bw = Math.min(P ? 110 : 150, slot * 0.56)
|
| 376 |
+
const delays = ri === 2 ? [1.0, 1.4, 2.2, 2.6, 4.2, 5.6] : [1.6, 3.4, 5.4]
|
| 377 |
+
R.data.forEach((d, i) => {
|
| 378 |
+
const p = pinR(g, k, delays[i] ?? 1 + i * 0.6, 1.1)
|
| 379 |
+
const bx = ch.x + slot * i + (slot - bw) / 2
|
| 380 |
+
const hit = d.r.hit
|
| 381 |
+
const col = hit >= 0.6 ? C.gold : hit >= 0.5 ? '#9C8C6C' : '#6E6354'
|
| 382 |
+
const top = vbar(c, bx, ch.y + ch.h, bw, hit * ch.h, col, p)
|
| 383 |
+
const fs = P ? (n > 3 ? 40 : 56) : n > 3 ? 46 : 64
|
| 384 |
+
const wv = roll(c, String(pct(hit)), bx + bw / 2 - fs * 0.18, top - 22, { size: fs, w: 900, f: 'serif', align: 'center', color: hit < 0.5 ? C.red : C.ink }, p)
|
| 385 |
+
T(c, '%', bx + bw / 2 - fs * 0.18 + wv / 2 + 4, top - 22, { size: fs * 0.45, w: 900, f: 'serif', color: C.gold, p: eo(p) })
|
| 386 |
+
const lfs = P ? (n > 3 ? 22 : 28) : n > 3 ? 24 : 28
|
| 387 |
+
T(c, d.l, bx + bw / 2, ch.y + ch.h + lfs + 14, { size: lfs, w: 700, align: 'center', p: eo(p) })
|
| 388 |
+
T(c, `${d.r.correct} 对 ${d.r.wrong} 错`, bx + bw / 2, ch.y + ch.h + lfs * 2 + 24, { size: lfs - 6, w: 500, color: C.dim, align: 'center', p: eo(p) })
|
| 389 |
+
})
|
| 390 |
+
// 侧注
|
| 391 |
+
const nx = P ? M : 1380
|
| 392 |
+
const ny = P ? 1250 : 420
|
| 393 |
+
const notes = [
|
| 394 |
+
['越具体越不准', '带数字或期限的预测,', '命中率掉了 26 个百分点'],
|
| 395 |
+
['越逆共识越难', '逆共识说的 41 条,', '16 对 17 错,还不如抛硬币'],
|
| 396 |
+
['方向 > 时点 > 幅度', '“会不会”他很准;', '“何时”“多少”他很差'],
|
| 397 |
+
][ri]
|
| 398 |
+
withA(c, pin(g, k, ri === 2 ? 6.4 : 6.2), () => {
|
| 399 |
+
line(c, nx, ny, nx + 60, ny, C.gold, 3)
|
| 400 |
+
T(c, notes[0], nx, ny + (P ? 66 : 70), { size: P ? 46 : 44, w: 900, f: 'serif', color: C.goldHi })
|
| 401 |
+
T(c, notes[1], nx, ny + (P ? 120 : 130), { size: P ? 28 : 26, w: 500, color: C.mute })
|
| 402 |
+
T(c, notes[2], nx, ny + (P ? 160 : 170), { size: P ? 28 : 26, w: 500, color: C.mute })
|
| 403 |
+
})
|
| 404 |
+
})
|
| 405 |
+
})
|
| 406 |
+
// 4:擅长 vs 不擅长
|
| 407 |
+
withA(c, vis(g, 4), () => {
|
| 408 |
+
const cols = [
|
| 409 |
+
{ h: '擅长', items: ['讲逻辑', '判方向', '读政策', '看城市分化'], ok: true },
|
| 410 |
+
{ h: '不擅长', items: ['报数字', '掐时间', '估幅度', '看租金'], ok: false },
|
| 411 |
+
]
|
| 412 |
+
cols.forEach((cl, i) => {
|
| 413 |
+
const w = P ? 920 : 760
|
| 414 |
+
const h = P ? 480 : 500
|
| 415 |
+
const x = P ? M : M + 60 + i * 820
|
| 416 |
+
const y = P ? 460 + i * 540 : 360
|
| 417 |
+
const p = pin(g, 4, 0.2 + i * 2.4, 0.9)
|
| 418 |
+
withA(c, p, () => {
|
| 419 |
+
glass(c, x, y, w, h, 26, 1, cl.ok ? C.green : C.red)
|
| 420 |
+
T(c, cl.h, x + 44, y + 96, { size: P ? 60 : 60, w: 900, f: 'serif', color: cl.ok ? C.ink : C.ink })
|
| 421 |
+
mark(c, x + w - 70, y + 76, cl.ok, p, 26)
|
| 422 |
+
cl.items.forEach((s, k) => {
|
| 423 |
+
const q = pin(g, 4, 0.8 + i * 2.4 + k * 0.3)
|
| 424 |
+
const yy = y + (P ? 190 : 200) + k * (P ? 72 : 76)
|
| 425 |
+
dot(c, x + 54, yy - 12, 6, cl.ok ? C.green : C.red, q)
|
| 426 |
+
T(c, s, x + 80, yy, { size: P ? 38 : 38, w: 700, p: q })
|
| 427 |
+
})
|
| 428 |
+
})
|
| 429 |
+
})
|
| 430 |
+
})
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
// ============ 自信校准 ============
|
| 434 |
+
const ABS_N = rows.filter((r) => /一定|肯定|不可能|绝对|必然|永远/.test(r.quote)).length
|
| 435 |
+
const CURVE: [number, number][] = Array.from({ length: 51 }, (_, i) => {
|
| 436 |
+
const p = 0.5 + i * 0.01
|
| 437 |
+
return [p, brierFn(p)]
|
| 438 |
+
})
|
| 439 |
+
export function brierScene(g: G) {
|
| 440 |
+
const { c, P } = g
|
| 441 |
+
const M = P ? 80 : 140
|
| 442 |
+
// 0:太自信了吗
|
| 443 |
+
withA(c, vis(g, 0, 1), () => {
|
| 444 |
+
const words = ['一定', '肯定', '不可能', '必然', '绝对', '永远']
|
| 445 |
+
words.forEach((wd, i) => {
|
| 446 |
+
const p = pin(g, 0, 0.3 + i * 0.22, 0.9)
|
| 447 |
+
const ang = (i / words.length) * Math.PI * 2 + 0.4
|
| 448 |
+
const rx = P ? 330 : 520
|
| 449 |
+
const ry = P ? 300 : 220
|
| 450 |
+
const cx = P ? 540 : 960
|
| 451 |
+
const cy = P ? 900 : 590
|
| 452 |
+
const x = cx + Math.cos(ang + g.u * 0.08) * rx
|
| 453 |
+
const y = cy + Math.sin(ang + g.u * 0.08) * ry
|
| 454 |
+
T(c, `“${wd}”`, x, y, { size: P ? 44 : 46, w: 900, f: 'serif', color: hexA(C.gold, 0.55 + 0.45 * seed(i, 2)), align: 'center', p })
|
| 455 |
+
})
|
| 456 |
+
const cx = P ? 540 : 960
|
| 457 |
+
const cy = P ? 900 : 590
|
| 458 |
+
const w = roll(c, String(ABS_N), cx - 30, cy + 40, { size: P ? 180 : 180, w: 900, f: 'serif', align: 'center' }, pinR(g, 0, 0.8, 1.4), (x0, ww) => shine(c, x0, ww, prog(g.lt(0), 2.4, 1.2) * 1.6 - 0.3, C.ink))
|
| 459 |
+
T(c, '条', cx - 30 + w / 2 + 10, cy + 40, { size: 56, w: 900, f: 'serif', color: C.gold, p: pin(g, 0, 1.6) })
|
| 460 |
+
T(c, `123 条预测里,原话带着“一定 / 不可能”的绝对口吻`, cx, cy + (P ? 120 : 110), { size: P ? 28 : 28, w: 500, color: C.mute, align: 'center', p: pin(g, 0, 2.0) })
|
| 461 |
+
})
|
| 462 |
+
// 1:公式
|
| 463 |
+
withA(c, vis(g, 1, 2), () => {
|
| 464 |
+
const cx = P ? 540 : 960
|
| 465 |
+
kicker(c, 'BRIER SCORE · 布里尔分数', cx, P ? 520 : 380, C.gold, pin(g, 1, 0.1), 22, 'center')
|
| 466 |
+
const f = '( 说出的把握 − 实际结果 )²'
|
| 467 |
+
charText(c, f, cx - measure(c, f, P ? 56 : 72, 900, 'serif') / 2, P ? 650 : 520, { size: P ? 56 : 72, w: 900, f: 'serif' }, pinR(g, 1, 0.4, 1.6), 0.05)
|
| 468 |
+
T(c, '每条取平均 · 越低越好', cx, P ? 720 : 590, { size: P ? 28 : 28, w: 500, color: C.mute, align: 'center', p: pin(g, 1, 1.8) })
|
| 469 |
+
// 示例
|
| 470 |
+
const ex = [
|
| 471 |
+
{ s: '说九成会涨,结果涨了', v: '0.01', col: C.green },
|
| 472 |
+
{ s: '说九成会涨,结果跌了', v: '0.81', col: C.red },
|
| 473 |
+
]
|
| 474 |
+
ex.forEach((e, i) => {
|
| 475 |
+
const p = pin(g, 1, 3.0 + i * 1.0)
|
| 476 |
+
const w = P ? 920 : 640
|
| 477 |
+
const x = P ? M : cx - 660 + i * 680
|
| 478 |
+
const y = P ? 820 + i * 200 : 680
|
| 479 |
+
withA(c, p, () => {
|
| 480 |
+
glass(c, x, y, w, 160, 20, 1, e.col)
|
| 481 |
+
T(c, e.s, x + 34, y + 66, { size: P ? 30 : 28, w: 700 })
|
| 482 |
+
T(c, i === 0 ? '(0.9 − 1)²' : '(0.9 − 0)²', x + 34, y + 120, { size: P ? 26 : 24, w: 500, color: C.mute })
|
| 483 |
+
T(c, e.v, x + w - 34, y + 110, { size: P ? 66 : 66, w: 900, f: 'serif', align: 'right', color: e.col })
|
| 484 |
+
})
|
| 485 |
+
})
|
| 486 |
+
T(c, '0 分 = 全知全能;存疑按“结果 0.5”计', cx, P ? 1290 : 900, { size: P ? 24 : 22, w: 500, color: C.dim, align: 'center', p: pin(g, 1, 5.2) })
|
| 487 |
+
})
|
| 488 |
+
// 2–3:校准曲线
|
| 489 |
+
withA(c, Math.min(vis(g, 2), 1), () => {
|
| 490 |
+
const ch: Chart = P ? { x: 170, y: 520, w: 800, h: 560, x0: 0.5, x1: 1.0, y0: 0.15, y1: 0.35 } : { x: 230, y: 330, w: 960, h: 480, x0: 0.5, x1: 1.0, y0: 0.15, y1: 0.35 }
|
| 491 |
+
grid(c, ch, [0.15, 0.2, 0.25, 0.3, 0.35], [0.5, 0.6, 0.7, 0.8, 0.9, 1.0], (v) => v.toFixed(2), (v) => `${Math.round(v * 100)}%`, 1, P)
|
| 492 |
+
kicker(c, '纵轴:布里尔分数(越低越好) · 横轴:每句话都按这个把握说', ch.x, ch.y - 24, C.gold, 1, P ? 18 : 20)
|
| 493 |
+
series(c, ch, CURVE, eio(prog(g.lt(2), 0.2, 2.2)), C.ink, { w: 3, glow: 8, head: false })
|
| 494 |
+
const pts = [
|
| 495 |
+
{ p: 0.5, v: BRIER.coin, l: '五五开', col: C.gray, d: 6.6, side: 'r' },
|
| 496 |
+
{ p: 0.8, v: BRIER.kk80, l: 'kkndme@八成', col: C.amber, d: 4.6, side: 'l' },
|
| 497 |
+
{ p: 0.9, v: BRIER.kk90, l: 'kkndme@九成', col: C.red, d: 2.4, side: 'l' },
|
| 498 |
+
]
|
| 499 |
+
pts.forEach((q) => {
|
| 500 |
+
const p = pin(g, 2, q.d, 0.8)
|
| 501 |
+
if (p <= 0) return
|
| 502 |
+
const x = sx(ch, q.p)
|
| 503 |
+
const y = sy(ch, q.v)
|
| 504 |
+
glowDot(c, x, y, 11 * eback(p), q.col)
|
| 505 |
+
const lx = q.side === 'l' ? x - 24 : x + 24
|
| 506 |
+
T(c, q.l, lx, y - 26, { size: P ? 26 : 24, w: 700, color: C.mute, align: q.side === 'l' ? 'right' : 'left', p })
|
| 507 |
+
roll(c, q.v.toFixed(3), lx, y + 16, { size: P ? 40 : 40, w: 900, f: 'serif', align: q.side === 'l' ? 'right' : 'left', color: C.ink }, p)
|
| 508 |
+
})
|
| 509 |
+
// 最佳点
|
| 510 |
+
const bp = pin(g, 3, 0.4, 0.9)
|
| 511 |
+
if (bp > 0) {
|
| 512 |
+
const x = sx(ch, all.partial)
|
| 513 |
+
const y = sy(ch, BRIER.calibrated)
|
| 514 |
+
line(c, x, y, x, ch.y + ch.h, C.green, 2, bp, [4, 6])
|
| 515 |
+
pulse(c, x, y, 12, g.t, C.green, bp)
|
| 516 |
+
glowDot(c, x, y, 12, C.green, bp)
|
| 517 |
+
T(c, '说成六成:最佳', x + 26, y + 60, { size: P ? 28 : 28, w: 900, color: C.green, p: bp })
|
| 518 |
+
roll(c, BRIER.calibrated.toFixed(3), x + 26, y + 110, { size: P ? 44 : 44, w: 900, f: 'serif', color: C.ink }, pinR(g, 3, 0.6, 1))
|
| 519 |
+
}
|
| 520 |
+
// 侧注
|
| 521 |
+
const nx = P ? 80 : 1300
|
| 522 |
+
const ny = P ? 1250 : 420
|
| 523 |
+
withA(c, vis(g, 2, 3), () => {
|
| 524 |
+
T(c, '把握越足,', nx, ny + 50, { size: P ? 46 : 44, w: 900, f: 'serif', p: pin(g, 2, 7.6) })
|
| 525 |
+
T(c, '分数反而越差', nx, ny + 110, { size: P ? 46 : 44, w: 900, f: 'serif', color: C.red, p: pin(g, 2, 7.9) })
|
| 526 |
+
T(c, '他的真实命中率只够撑起六成把握', nx, ny + (P ? 170 : 176), { size: P ? 26 : 24, w: 500, color: C.mute, p: pin(g, 2, 8.4) })
|
| 527 |
+
})
|
| 528 |
+
withA(c, vis(g, 3), () => {
|
| 529 |
+
maskText(c, '最大的问题,', nx, ny + 50, { size: P ? 50 : 48, w: 900, f: 'serif' }, pinR(g, 3, 3.2, 0.9))
|
| 530 |
+
maskText(c, '不是看错,', nx, ny + 120, { size: P ? 50 : 48, w: 900, f: 'serif' }, pinR(g, 3, 3.8, 0.9))
|
| 531 |
+
maskText(c, '而是太笃定。', nx, ny + 190, { size: P ? 50 : 48, w: 900, f: 'serif', color: C.goldHi }, pinR(g, 3, 4.6, 0.9))
|
| 532 |
+
})
|
| 533 |
+
})
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
// ============ 盲区 ============
|
| 537 |
+
const RANK: number[] = (() => {
|
| 538 |
+
const idx = Array.from({ length: 337 }, (_, i) => i).sort((a, b) => seed(a, 7) - seed(b, 7))
|
| 539 |
+
const r: number[] = []
|
| 540 |
+
idx.forEach((v, k) => (r[v] = k))
|
| 541 |
+
return r
|
| 542 |
+
})()
|
| 543 |
+
export function blind(g: G) {
|
| 544 |
+
const { c, P } = g
|
| 545 |
+
const M = P ? 80 : 140
|
| 546 |
+
// 0:三张卡
|
| 547 |
+
withA(c, vis(g, 0, 1), () => {
|
| 548 |
+
const cards = [
|
| 549 |
+
{ t: '租金', e: 'RENT', s: '“房租下降是做梦”' },
|
| 550 |
+
{ t: '人口', e: 'POPULATION', s: '“三四线人口还会增长”' },
|
| 551 |
+
{ t: '利率', e: 'INTEREST RATE', s: '没想到会一路走低' },
|
| 552 |
+
]
|
| 553 |
+
cards.forEach((cd, i) => {
|
| 554 |
+
const p = pin(g, 0, 0.8 + i * 0.6, 0.9)
|
| 555 |
+
const w = P ? 920 : 500
|
| 556 |
+
const h = P ? 310 : 460
|
| 557 |
+
const x = P ? M : M + i * 560
|
| 558 |
+
const y = P ? 450 + i * 350 : 360
|
| 559 |
+
card3d(c, x + w / 2, y + h / 2, p, () => {
|
| 560 |
+
glass(c, x, y, w, h, 26, 1, C.red)
|
| 561 |
+
T(c, cd.e, x + 40, y + 60, { size: 20, w: 700, color: C.red, ls: 5 })
|
| 562 |
+
T(c, cd.t, x + 40, y + (P ? 170 : 220), { size: P ? 96 : 110, w: 900, f: 'serif' })
|
| 563 |
+
T(c, cd.s, x + 40, y + h - 50, { size: P ? 28 : 26, w: 500, color: C.mute })
|
| 564 |
+
})
|
| 565 |
+
})
|
| 566 |
+
})
|
| 567 |
+
// 1:租金
|
| 568 |
+
withA(c, vis(g, 1, 2), () => {
|
| 569 |
+
const x = M + (P ? 0 : 40)
|
| 570 |
+
const y = quoteBlock(g, '“房租收入下降基本是做梦才会出现的事情。”', x, P ? 450 : 330, P ? 900 : 760, pin(g, 1, 0.2), P ? 42 : 40)
|
| 571 |
+
const ch = P ? { x: M + 60, y: y + 120, w: 800, h: 360 } : { x: x + 40, y: y + 100, w: 700, h: 300 }
|
| 572 |
+
const zero = ch.y + 40
|
| 573 |
+
line(c, ch.x - 20, zero, ch.x + ch.w, zero, 'rgba(243,238,228,0.4)', 1.5)
|
| 574 |
+
T(c, '0', ch.x - 30, zero + 7, { size: 20, w: 500, color: C.dim, align: 'right', p: pin(g, 1, 2) })
|
| 575 |
+
const bars = [
|
| 576 |
+
{ l: '2024 全年', v: 3.25 },
|
| 577 |
+
{ l: '2025.12', v: 3.62 },
|
| 578 |
+
{ l: '2026.03', v: 3.65 },
|
| 579 |
+
]
|
| 580 |
+
const scale = (ch.h - 80) / 4
|
| 581 |
+
bars.forEach((b, i) => {
|
| 582 |
+
const p = pinR(g, 1, 3.6 + i * 0.5, 1)
|
| 583 |
+
const bx = ch.x + i * (ch.w / 3) + 30
|
| 584 |
+
const bw = ch.w / 3 - 80
|
| 585 |
+
const hgt = b.v * scale * eo5(p)
|
| 586 |
+
if (p > 0) {
|
| 587 |
+
c.save()
|
| 588 |
+
c.globalAlpha *= clamp(p * 3)
|
| 589 |
+
const gr = c.createLinearGradient(0, zero, 0, zero + hgt)
|
| 590 |
+
gr.addColorStop(0, hexA(C.red, 0.5))
|
| 591 |
+
gr.addColorStop(1, C.red)
|
| 592 |
+
c.fillStyle = gr
|
| 593 |
+
rr(c, bx, zero + 2, bw, Math.max(2, hgt), 6)
|
| 594 |
+
c.fill()
|
| 595 |
+
c.restore()
|
| 596 |
+
}
|
| 597 |
+
T(c, `−${b.v.toFixed(2)}%`, bx + bw / 2, zero + hgt + 44, { size: P ? 36 : 34, w: 900, f: 'serif', align: 'center', color: C.red, p: eo(p) })
|
| 598 |
+
T(c, b.l, bx + bw / 2, zero - 16, { size: P ? 22 : 20, w: 700, color: C.mute, align: 'center', p: eo(p) })
|
| 599 |
+
})
|
| 600 |
+
T(c, '全国住宅租金同比', ch.x - 20, ch.y + ch.h + 30, { size: P ? 22 : 20, w: 500, color: C.dim, p: pin(g, 1, 4) })
|
| 601 |
+
// 右:0/4
|
| 602 |
+
const rx = P ? M : 1240
|
| 603 |
+
const ry = P ? 1360 : 420
|
| 604 |
+
withA(c, pin(g, 1, 5.4), () => {
|
| 605 |
+
T(c, '租金类预测', rx, ry, { size: P ? 28 : 28, w: 700, color: C.mute })
|
| 606 |
+
const w = roll(c, '0', rx, ry + (P ? 130 : 160), { size: P ? 130 : 160, w: 900, f: 'serif', color: C.red }, pinR(g, 1, 5.6, 1))
|
| 607 |
+
T(c, '/ 4 说中', rx + w + 16, ry + (P ? 130 : 160), { size: P ? 50 : 56, w: 900, f: 'serif', color: C.ink })
|
| 608 |
+
if (!P) T(c, '另有 1 条存疑', rx, ry + 230, { size: 24, w: 500, color: C.dim })
|
| 609 |
+
})
|
| 610 |
+
})
|
| 611 |
+
// 2:人口
|
| 612 |
+
withA(c, vis(g, 2, 3), () => {
|
| 613 |
+
const cols = P ? 24 : 32
|
| 614 |
+
const gap = P ? 33 : 27
|
| 615 |
+
const ox = P ? M + 30 : M + 40
|
| 616 |
+
const oy = P ? 470 : 340
|
| 617 |
+
const pr = prog(g.lt(2), 4.0, 2.2)
|
| 618 |
+
for (let i = 0; i < 337; i++) {
|
| 619 |
+
const cx = ox + (i % cols) * gap
|
| 620 |
+
const cy = oy + Math.floor(i / cols) * gap
|
| 621 |
+
const ap = pinR(g, 2, 0.3 + (i / 337) * 1.4, 0.5)
|
| 622 |
+
if (ap <= 0) continue
|
| 623 |
+
const rk = RANK[i]
|
| 624 |
+
const col = rk < 149 && rk / 149 < pr ? C.red : 'rgba(243,238,228,0.42)'
|
| 625 |
+
dot(c, cx, cy, P ? 9 : 8, col, eo(ap))
|
| 626 |
+
}
|
| 627 |
+
const rx = P ? M : 1100
|
| 628 |
+
const ry = P ? 1050 : 400
|
| 629 |
+
withA(c, pin(g, 2, 2.6), () => {
|
| 630 |
+
T(c, '七普 · 337 个地级及以上城市', rx, ry, { size: P ? 26 : 24, w: 700, color: C.mute })
|
| 631 |
+
const w = roll(c, '149', rx, ry + (P ? 130 : 140), { size: P ? 130 : 140, w: 900, f: 'serif', color: C.red }, pinR(g, 2, 4.0, 1.6))
|
| 632 |
+
T(c, '个人口减少', rx + w + 16, ry + (P ? 130 : 140), { size: P ? 40 : 40, w: 900, f: 'serif', p: pin(g, 2, 4.6) })
|
| 633 |
+
})
|
| 634 |
+
withA(c, pin(g, 2, 7.4), () => {
|
| 635 |
+
const yy = ry + (P ? 230 : 260)
|
| 636 |
+
line(c, rx, yy - 50, rx + 60, yy - 50, C.red, 3)
|
| 637 |
+
T(c, '东北三省十年', rx, yy, { size: P ? 28 : 28, w: 700, color: C.mute })
|
| 638 |
+
const w = roll(c, '−1101', rx, yy + (P ? 90 : 100), { size: P ? 90 : 96, w: 900, f: 'serif', color: C.ink }, pinR(g, 2, 7.6, 1.4))
|
| 639 |
+
T(c, '万人', rx + w + 12, yy + (P ? 90 : 100), { size: P ? 40 : 40, w: 900, f: 'serif', color: C.gold })
|
| 640 |
+
})
|
| 641 |
+
})
|
| 642 |
+
// 3:利率
|
| 643 |
+
withA(c, vis(g, 3, 4), () => {
|
| 644 |
+
const tiles = [
|
| 645 |
+
{ k: '首套房贷利率', a: '6%+', b: '3.06%', s: '2010s 高位 → 2025 均值', col: C.blue, d: 0.6 },
|
| 646 |
+
{ k: '首套最低首付', a: '30%', b: '15%', s: '2010 → 2024.05', col: C.blue, d: 3.6 },
|
| 647 |
+
{ k: '全国房价', a: '高点', b: '−22%', s: '2021 → 2026', col: C.red, d: 5.6 },
|
| 648 |
+
]
|
| 649 |
+
tiles.forEach((tl, i) => {
|
| 650 |
+
const w = P ? 920 : 500
|
| 651 |
+
const h = P ? 290 : 400
|
| 652 |
+
const x = P ? M : M + i * 560
|
| 653 |
+
const y = P ? 450 + i * 330 : 380
|
| 654 |
+
const p = pin(g, 3, tl.d, 0.9)
|
| 655 |
+
withA(c, p, () => {
|
| 656 |
+
c.save()
|
| 657 |
+
c.translate(0, (1 - p) * 40)
|
| 658 |
+
glass(c, x, y, w, h, 26, 1, tl.col)
|
| 659 |
+
T(c, tl.k, x + 40, y + 64, { size: P ? 28 : 28, w: 700, color: C.mute })
|
| 660 |
+
T(c, tl.a, x + 40, y + (P ? 170 : 200), { size: P ? 56 : 56, w: 900, f: 'serif', color: C.dim })
|
| 661 |
+
const aw = measure(c, tl.a, P ? 56 : 56, 900, 'serif')
|
| 662 |
+
line(c, x + 40 + aw + 20, y + (P ? 152 : 182), x + 40 + aw + 70, y + (P ? 152 : 182), C.ink, 2.5, eo(prog(g.lt(3), tl.d + 0.4, 0.5)))
|
| 663 |
+
roll(c, tl.b, x + 40 + aw + 96, y + (P ? 176 : 206), { size: P ? 84 : 84, w: 900, f: 'serif', color: i === 2 ? C.red : C.ink }, pinR(g, 3, tl.d + 0.5, 1.2))
|
| 664 |
+
T(c, tl.s, x + 40, y + h - 46, { size: P ? 24 : 22, w: 500, color: C.dim })
|
| 665 |
+
c.restore()
|
| 666 |
+
})
|
| 667 |
+
})
|
| 668 |
+
T(c, '钱变便宜了,门槛变低了,房价却还在跌', P ? M : 960, P ? 1460 : 880, { size: P ? 34 : 36, w: 900, f: 'serif', color: C.goldHi, align: P ? 'left' : 'center', p: pin(g, 3, 7.4) })
|
| 669 |
+
})
|
| 670 |
+
// 4:前提崩塌
|
| 671 |
+
withA(c, vis(g, 4), () => {
|
| 672 |
+
const cx = P ? 540 : 960
|
| 673 |
+
const base = P ? 1300 : 860
|
| 674 |
+
const pw = P ? 200 : 220
|
| 675 |
+
const ph = P ? 420 : 340
|
| 676 |
+
const gapX = P ? 400 : 560
|
| 677 |
+
const crack = eo(prog(g.lt(4), 3.2, 1.0))
|
| 678 |
+
const tilt = eio(prog(g.lt(4), 4.0, 1.6)) * 0.07
|
| 679 |
+
const labels = ['人口红利', '货币扩张']
|
| 680 |
+
labels.forEach((l, i) => {
|
| 681 |
+
const x = cx + (i ? gapX / 2 : -gapX / 2) - pw / 2
|
| 682 |
+
const p = pin(g, 4, 0.4 + i * 0.5, 0.9)
|
| 683 |
+
const sink = i === 0 ? tilt * 900 : tilt * 300
|
| 684 |
+
withA(c, p, () => {
|
| 685 |
+
c.save()
|
| 686 |
+
c.translate(0, sink)
|
| 687 |
+
const gr = c.createLinearGradient(x, 0, x + pw, 0)
|
| 688 |
+
gr.addColorStop(0, 'rgba(216,178,110,0.16)')
|
| 689 |
+
gr.addColorStop(0.5, 'rgba(216,178,110,0.32)')
|
| 690 |
+
gr.addColorStop(1, 'rgba(216,178,110,0.12)')
|
| 691 |
+
c.fillStyle = gr
|
| 692 |
+
c.fillRect(x, base - ph, pw, ph - sink)
|
| 693 |
+
c.strokeStyle = hexA(C.gold, 0.6)
|
| 694 |
+
c.lineWidth = 2
|
| 695 |
+
c.strokeRect(x, base - ph, pw, ph - sink)
|
| 696 |
+
for (let k = 1; k < 5; k++) line(c, x + (pw * k) / 5, base - ph + 20, x + (pw * k) / 5, base - sink - 20, hexA(C.gold, 0.18), 1.5)
|
| 697 |
+
T(c, l, x + pw / 2, base - ph / 2 + 10, { size: P ? 40 : 40, w: 900, f: 'serif', align: 'center' })
|
| 698 |
+
// 裂缝
|
| 699 |
+
if (crack > 0) {
|
| 700 |
+
c.save()
|
| 701 |
+
c.strokeStyle = C.red
|
| 702 |
+
c.lineWidth = 3
|
| 703 |
+
c.shadowColor = C.red
|
| 704 |
+
c.shadowBlur = 12
|
| 705 |
+
c.beginPath()
|
| 706 |
+
const pts = [
|
| 707 |
+
[0.3, 0],
|
| 708 |
+
[0.55, 0.18],
|
| 709 |
+
[0.4, 0.35],
|
| 710 |
+
[0.65, 0.55],
|
| 711 |
+
[0.45, 0.75],
|
| 712 |
+
[0.6, 1],
|
| 713 |
+
]
|
| 714 |
+
const n = Math.max(2, Math.ceil(pts.length * crack))
|
| 715 |
+
pts.slice(0, n).forEach(([a, b], j) => {
|
| 716 |
+
const px = x + pw * a + (i ? 10 : 0)
|
| 717 |
+
const py = base - ph + (ph - sink) * b * crack
|
| 718 |
+
if (j) c.lineTo(px, py)
|
| 719 |
+
else c.moveTo(px, py)
|
| 720 |
+
})
|
| 721 |
+
c.stroke()
|
| 722 |
+
c.restore()
|
| 723 |
+
}
|
| 724 |
+
c.restore()
|
| 725 |
+
})
|
| 726 |
+
})
|
| 727 |
+
// 横梁
|
| 728 |
+
const sp = pin(g, 4, 1.4, 1)
|
| 729 |
+
withA(c, sp, () => {
|
| 730 |
+
const bw = gapX + pw + 120
|
| 731 |
+
const bh = P ? 120 : 110
|
| 732 |
+
c.save()
|
| 733 |
+
c.translate(cx, base - ph - bh / 2 + tilt * 600)
|
| 734 |
+
c.rotate(-tilt)
|
| 735 |
+
c.translate(0, (1 - sp) * -60)
|
| 736 |
+
glass(c, -bw / 2, -bh / 2, bw, bh, 18, 1, C.gold)
|
| 737 |
+
T(c, 'kkndme 的世界观', 0, 14, { size: P ? 46 : 46, w: 900, f: 'serif', align: 'center', color: C.goldHi })
|
| 738 |
+
c.restore()
|
| 739 |
+
})
|
| 740 |
+
withA(c, pin(g, 4, 5.2), () => {
|
| 741 |
+
T(c, '前提一旦松动,最笃定的判断也会失效', cx, P ? 600 : 330, { size: P ? 36 : 40, w: 900, f: 'serif', align: 'center' })
|
| 742 |
+
})
|
| 743 |
+
})
|
| 744 |
+
}
|
| 745 |
+
|
| 746 |
+
// ============ 未到期 ============
|
| 747 |
+
const PEND = [
|
| 748 |
+
{
|
| 749 |
+
grp: 'lean' as const,
|
| 750 |
+
h: '正在偏向他',
|
| 751 |
+
col: C.blue,
|
| 752 |
+
items: [
|
| 753 |
+
{ t: '人民币不会自由兑换', e: '资本项目约 60% 子项可兑换' },
|
| 754 |
+
{ t: '体制外养老是大问题', e: '2025 年起渐进式延迟退休' },
|
| 755 |
+
{ t: '百年政治判断', e: '期限 2110 年,至今一致' },
|
| 756 |
+
],
|
| 757 |
+
},
|
| 758 |
+
{
|
| 759 |
+
grp: 'against' as const,
|
| 760 |
+
h: '正在偏离他',
|
| 761 |
+
col: C.purple,
|
| 762 |
+
items: [
|
| 763 |
+
{ t: '北京核心区超过香港', e: '北京二手均价 3.65 万,较高点 −40%' },
|
| 764 |
+
{ t: '房产税将来一定会出', e: '“十五五”规划纲要未再提' },
|
| 765 |
+
],
|
| 766 |
+
},
|
| 767 |
+
{
|
| 768 |
+
grp: 'wait' as const,
|
| 769 |
+
h: '还看不清',
|
| 770 |
+
col: C.gray,
|
| 771 |
+
items: [
|
| 772 |
+
{ t: '房价不会大跌 30%–50%', e: '较 2021 高点跌约 22%,未到 30%' },
|
| 773 |
+
{ t: '20 年内楼市不崩盘', e: '期限到 2030 年' },
|
| 774 |
+
{ t: '不会重演日本', e: '跌 22%,日本当年跌约 67%' },
|
| 775 |
+
{ t: '城中村一定会消失', e: '35 城仍约 170 万套待改造' },
|
| 776 |
+
{ t: '房产税推高房租', e: '前提未触发,无法检验' },
|
| 777 |
+
],
|
| 778 |
+
},
|
| 779 |
+
]
|
| 780 |
+
export function pending(g: G) {
|
| 781 |
+
const { c, P } = g
|
| 782 |
+
const M = P ? 80 : 140
|
| 783 |
+
const focus = g.lt(2) >= 0 ? 1 : g.lt(1) >= 0 ? 0 : -1
|
| 784 |
+
PEND.forEach((gp, gi) => {
|
| 785 |
+
const colW = P ? 920 : 520
|
| 786 |
+
const x = P ? M : M + gi * 560
|
| 787 |
+
const y0 = P ? [450, 820, 1190][gi] : 330
|
| 788 |
+
const a = pin(g, 0, 0.6 + gi * 0.7, 0.8)
|
| 789 |
+
const dim = focus < 0 || focus === gi ? 1 : 0.32
|
| 790 |
+
withA(c, a * dim, () => {
|
| 791 |
+
// 标题
|
| 792 |
+
dot(c, x + 12, y0 - 10, 10, gp.col)
|
| 793 |
+
T(c, gp.h, x + 34, y0, { size: P ? 34 : 34, w: 900, f: 'serif' })
|
| 794 |
+
roll(c, String(gp.items.length), x + colW, y0 + 6, { size: P ? 56 : 60, w: 900, f: 'serif', align: 'right', color: gp.col }, pinR(g, 0, 0.8 + gi * 0.7, 1))
|
| 795 |
+
line(c, x, y0 + 26, x + colW, y0 + 26, hexA(gp.col, 0.6), 2, eo(prog(g.lt(0), 0.8 + gi * 0.7, 0.8)))
|
| 796 |
+
gp.items.forEach((it, k) => {
|
| 797 |
+
const ch = P ? 74 : 96
|
| 798 |
+
const cy = y0 + 46 + k * (ch + (P ? 8 : 12))
|
| 799 |
+
const q = pin(g, 0, 2.6 + gi * 0.6 + k * 0.2)
|
| 800 |
+
withA(c, q, () => {
|
| 801 |
+
const hl = focus === gi
|
| 802 |
+
glass(c, x, cy, colW, ch, 16, 1, hl ? gp.col : undefined)
|
| 803 |
+
if (P) {
|
| 804 |
+
T(c, it.t, x + 24, cy + 46, { size: 30, w: 900, f: 'serif' })
|
| 805 |
+
T(c, it.e, x + colW - 24, cy + 46, { size: 22, w: 500, color: C.mute, align: 'right' })
|
| 806 |
+
} else {
|
| 807 |
+
T(c, it.t, x + 26, cy + 42, { size: 30, w: 900, f: 'serif' })
|
| 808 |
+
T(c, it.e, x + 26, cy + 78, { size: 21, w: 500, color: C.mute })
|
| 809 |
+
}
|
| 810 |
+
})
|
| 811 |
+
})
|
| 812 |
+
})
|
| 813 |
+
})
|
| 814 |
+
if (!P) {
|
| 815 |
+
withA(c, pin(g, 0, 4.4), () => {
|
| 816 |
+
T(c, '这 10 条没有到期,不计入命中率', 960, 985, { size: 24, w: 500, color: C.dim, align: 'center' })
|
| 817 |
+
})
|
| 818 |
+
}
|
| 819 |
+
}
|
| 820 |
+
|
| 821 |
+
// ============ 结论 ============
|
| 822 |
+
const SCAT = [
|
| 823 |
+
...byType.map((x) => {
|
| 824 |
+
const rs = rows.filter((r) => r.a.type === x.k && !r.status.startsWith('pending'))
|
| 825 |
+
return { l: x.label, sp: rs.reduce((a, r) => a + r.a.spec, 0) / rs.length, hit: x.r.hit, n: x.r.n }
|
| 826 |
+
}),
|
| 827 |
+
(() => {
|
| 828 |
+
const rs = rows.filter((r) => r.topic === '租金与保障房' && !r.status.startsWith('pending'))
|
| 829 |
+
const r = byTopic.find((x) => x.k === '租金与保障房')!.r
|
| 830 |
+
return { l: '租金', sp: rs.reduce((a, x) => a + x.a.spec, 0) / rs.length, hit: r.hit, n: r.n }
|
| 831 |
+
})(),
|
| 832 |
+
]
|
| 833 |
+
const BARCODE = [...rows].sort((a, b) => a.id.localeCompare(b.id))
|
| 834 |
+
|
| 835 |
+
export function outro(g: G) {
|
| 836 |
+
const { c, P } = g
|
| 837 |
+
const M = P ? 80 : 140
|
| 838 |
+
const cx = g.W / 2
|
| 839 |
+
// 0:问题
|
| 840 |
+
withA(c, vis(g, 0, 1), () => {
|
| 841 |
+
const y = P ? 900 : 560
|
| 842 |
+
kicker(c, '15 YEARS · 123 PREDICTIONS', cx, y - (P ? 140 : 130), C.gold, pin(g, 0, 0.2), 22, 'center')
|
| 843 |
+
maskText(c, '十五年对账,', cx, y, { size: P ? 88 : 96, w: 900, f: 'serif', align: 'center' }, pinR(g, 0, 0.3, 0.9))
|
| 844 |
+
maskText(c, '这个神贴留给我们什么?', cx, y + (P ? 120 : 124), { size: P ? 72 : 80, w: 900, f: 'serif', align: 'center', color: C.goldHi }, pinR(g, 0, 1.0, 0.9))
|
| 845 |
+
})
|
| 846 |
+
// 1:散点 · 四象限
|
| 847 |
+
withA(c, vis(g, 1, 2), () => {
|
| 848 |
+
const ch: Chart = P ? { x: 170, y: 470, w: 800, h: 760, x0: 1.3, x1: 3.15, y0: 0, y1: 1 } : { x: 300, y: 300, w: 1320, h: 520, x0: 1.3, x1: 3.15, y0: 0, y1: 1 }
|
| 849 |
+
const a0 = pin(g, 1, 0.1, 0.8)
|
| 850 |
+
withA(c, a0, () => {
|
| 851 |
+
// 象限底色
|
| 852 |
+
const mx = sx(ch, 2.2)
|
| 853 |
+
const my = sy(ch, 0.5)
|
| 854 |
+
c.save()
|
| 855 |
+
c.fillStyle = hexA(C.green, 0.06)
|
| 856 |
+
c.fillRect(ch.x, ch.y, mx - ch.x, my - ch.y)
|
| 857 |
+
c.fillStyle = hexA(C.red, 0.06)
|
| 858 |
+
c.fillRect(mx, my, ch.x + ch.w - mx, ch.y + ch.h - my)
|
| 859 |
+
c.restore()
|
| 860 |
+
line(c, mx, ch.y, mx, ch.y + ch.h, 'rgba(243,238,228,0.2)', 1.5, 1, [4, 6])
|
| 861 |
+
line(c, ch.x, my, ch.x + ch.w, my, 'rgba(243,238,228,0.2)', 1.5, 1, [4, 6])
|
| 862 |
+
line(c, ch.x, ch.y + ch.h, ch.x + ch.w, ch.y + ch.h, 'rgba(243,238,228,0.3)', 1.5)
|
| 863 |
+
line(c, ch.x, ch.y, ch.x, ch.y + ch.h, 'rgba(243,238,228,0.3)', 1.5)
|
| 864 |
+
;[0, 0.5, 1].forEach((v) => T(c, `${v * 100}%`, ch.x - 14, sy(ch, v) + 7, { size: P ? 22 : 18, w: 500, color: C.dim, align: 'right' }))
|
| 865 |
+
T(c, '命中率', ch.x, ch.y - 20, { size: P ? 22 : 20, w: 700, color: C.mute })
|
| 866 |
+
T(c, '说得越具体 →', ch.x + ch.w, ch.y + ch.h + 36, { size: P ? 22 : 20, w: 700, color: C.mute, align: 'right' })
|
| 867 |
+
T(c, '笼统但准', ch.x + 20, ch.y + 36, { size: P ? 24 : 22, w: 700, color: C.green })
|
| 868 |
+
T(c, '具体却错', ch.x + ch.w - 20, ch.y + ch.h - 20, { size: P ? 24 : 22, w: 700, color: C.red, align: 'right' })
|
| 869 |
+
})
|
| 870 |
+
// 趋势线(最小二乘)
|
| 871 |
+
const n = SCAT.length
|
| 872 |
+
const mxv = SCAT.reduce((a, s) => a + s.sp, 0) / n
|
| 873 |
+
const myv = SCAT.reduce((a, s) => a + s.hit, 0) / n
|
| 874 |
+
const b = SCAT.reduce((a, s) => a + (s.sp - mxv) * (s.hit - myv), 0) / SCAT.reduce((a, s) => a + (s.sp - mxv) ** 2, 0)
|
| 875 |
+
const f = (x: number) => myv + b * (x - mxv)
|
| 876 |
+
const tp = eio(prog(g.lt(1), 4.6, 1.6))
|
| 877 |
+
if (tp > 0) {
|
| 878 |
+
const xa = 1.35
|
| 879 |
+
const xb = lerp(xa, 3.1, tp)
|
| 880 |
+
line(c, sx(ch, xa), sy(ch, clamp(f(xa))), sx(ch, xb), sy(ch, clamp(f(xb))), C.gold, 2.5, 0.8, [10, 8])
|
| 881 |
+
}
|
| 882 |
+
SCAT.forEach((s, i) => {
|
| 883 |
+
const good = s.hit >= 0.6
|
| 884 |
+
const p = pin(g, 1, good ? 1.0 + i * 0.3 : 3.6 + i * 0.25, 0.8)
|
| 885 |
+
if (p <= 0) return
|
| 886 |
+
const x = sx(ch, s.sp)
|
| 887 |
+
const y = sy(ch, s.hit)
|
| 888 |
+
const r = (P ? 12 : 12) + Math.sqrt(s.n) * (P ? 5 : 5)
|
| 889 |
+
const col = good ? C.green : s.hit >= 0.5 ? C.amber : C.red
|
| 890 |
+
c.save()
|
| 891 |
+
c.globalAlpha *= p
|
| 892 |
+
c.beginPath()
|
| 893 |
+
c.arc(x, y, r * eback(p), 0, Math.PI * 2)
|
| 894 |
+
c.fillStyle = hexA(col, 0.22)
|
| 895 |
+
c.fill()
|
| 896 |
+
c.strokeStyle = col
|
| 897 |
+
c.lineWidth = 2.5
|
| 898 |
+
c.stroke()
|
| 899 |
+
c.restore()
|
| 900 |
+
const lr = s.l === '租金' || s.l === '涨跌幅度' || s.l === '时间点'
|
| 901 |
+
T(c, `${s.l} ${pct(s.hit)}%`, lr ? x - r - 12 : x + r + 12, y + 9, { size: P ? 26 : 26, w: 700, align: lr ? 'right' : 'left', p })
|
| 902 |
+
})
|
| 903 |
+
})
|
| 904 |
+
// 2:金句
|
| 905 |
+
withA(c, vis(g, 2, 3), () => {
|
| 906 |
+
const y = P ? 900 : 560
|
| 907 |
+
const s1 = '看对方向容易,'
|
| 908 |
+
const s2 = '算准时间很难。'
|
| 909 |
+
maskText(c, s1, cx, y, { size: P ? 96 : 110, w: 900, f: 'serif', align: 'center' }, pinR(g, 2, 0.1, 0.9))
|
| 910 |
+
const p2 = pinR(g, 2, 1.1, 0.9)
|
| 911 |
+
if (p2 > 0) {
|
| 912 |
+
const fs = P ? 96 : 110
|
| 913 |
+
const w = measure(c, s2, fs, 900, 'serif')
|
| 914 |
+
maskText(c, s2, cx, y + (P ? 140 : 150), { size: fs, w: 900, f: 'serif', align: 'center', color: shine(c, cx - w / 2, w, prog(g.lt(2), 2.0, 1.4) * 1.6 - 0.3, C.goldHi) }, p2)
|
| 915 |
+
}
|
| 916 |
+
line(c, cx - 60 * eo(prog(g.lt(2), 1.6, 0.8)), y + (P ? 220 : 230), cx + 60 * eo(prog(g.lt(2), 1.6, 0.8)), y + (P ? 220 : 230), C.gold, 2)
|
| 917 |
+
})
|
| 918 |
+
// 3:预言 = 逻辑 × 前提
|
| 919 |
+
withA(c, vis(g, 3, 4), () => {
|
| 920 |
+
const y = P ? 880 : 560
|
| 921 |
+
const fs = P ? 96 : 120
|
| 922 |
+
const parts = ['预言', '=', '逻辑', '×', '前提']
|
| 923 |
+
const ws = parts.map((s) => measure(c, s, fs, 900, 'serif'))
|
| 924 |
+
const gap = P ? 30 : 46
|
| 925 |
+
const total = ws.reduce((a, b) => a + b, 0) + gap * (parts.length - 1)
|
| 926 |
+
let x = cx - total / 2
|
| 927 |
+
const pos: number[] = []
|
| 928 |
+
parts.forEach((s, i) => {
|
| 929 |
+
pos.push(x)
|
| 930 |
+
const p = pinR(g, 3, 0.2 + i * 0.25, 0.8)
|
| 931 |
+
maskText(c, s, x, y, { size: fs, w: 900, f: 'serif', color: i === 4 ? C.goldHi : i % 2 ? C.gold : C.ink }, p)
|
| 932 |
+
x += ws[i] + gap
|
| 933 |
+
})
|
| 934 |
+
const sp = eo(prog(g.lt(3), 3.6, 0.6))
|
| 935 |
+
if (sp > 0) {
|
| 936 |
+
const x4 = pos[4]
|
| 937 |
+
line(c, x4 - 10, y - fs * 0.32, x4 - 10 + (ws[4] + 20) * sp, y - fs * 0.32, C.red, 7)
|
| 938 |
+
}
|
| 939 |
+
T(c, '前提变了,再神的帖子,也会过期', cx, y + (P ? 150 : 150), { size: P ? 40 : 44, w: 900, f: 'serif', align: 'center', color: C.mute, p: pin(g, 3, 4.4) })
|
| 940 |
+
const chips = ['人口红利 → 人口减少', '货币扩张 → 低通胀', '高利率 → 降息']
|
| 941 |
+
chips.forEach((s, i) => {
|
| 942 |
+
const p = pin(g, 3, 1.6 + i * 0.35)
|
| 943 |
+
const xx = P ? cx : cx + (i - 1) * 440
|
| 944 |
+
const yy = P ? y - 300 + i * 0 : y - 240
|
| 945 |
+
if (P) T(c, s, cx, y + 260 + i * 60, { size: 30, w: 700, color: C.dim, align: 'center', p })
|
| 946 |
+
else T(c, s, xx, yy, { size: 28, w: 700, color: C.dim, align: 'center', p })
|
| 947 |
+
})
|
| 948 |
+
})
|
| 949 |
+
// 4:条码 + 下期见
|
| 950 |
+
withA(c, vis(g, 4), () => {
|
| 951 |
+
const n = BARCODE.length
|
| 952 |
+
const bx0 = P ? 80 : 240
|
| 953 |
+
const bx1 = P ? 1000 : 1680
|
| 954 |
+
const bw = (bx1 - bx0) / n
|
| 955 |
+
const by = P ? 820 : 440
|
| 956 |
+
const bh = P ? 220 : 200
|
| 957 |
+
BARCODE.forEach((r, i) => {
|
| 958 |
+
const p = pinR(g, 4, 0.2 + (i / n) * 1.6, 0.5)
|
| 959 |
+
if (p <= 0) return
|
| 960 |
+
const col = STATUS_COLOR[r.status] ?? C.gray
|
| 961 |
+
const h = bh * (0.55 + 0.45 * seed(i, 3)) * eo5(p)
|
| 962 |
+
c.save()
|
| 963 |
+
c.globalAlpha *= clamp(p * 2)
|
| 964 |
+
c.fillStyle = col
|
| 965 |
+
c.fillRect(bx0 + i * bw + bw * 0.15, by + bh - h, bw * 0.7, h)
|
| 966 |
+
c.restore()
|
| 967 |
+
})
|
| 968 |
+
sweepBand(c, bx0, by - 10, bx1 - bx0, bh + 20, prog(g.lt(4), 2.0, 1.4))
|
| 969 |
+
T(c, '123 条完整核对 · 每条附原话与出处', cx, by + bh + (P ? 80 : 70), { size: P ? 32 : 32, w: 700, align: 'center', color: C.mute, p: pin(g, 4, 1.4) })
|
| 970 |
+
T(c, '我们下期见', cx, by + bh + (P ? 220 : 200), { size: P ? 80 : 84, w: 900, f: 'serif', align: 'center', p: pin(g, 4, 3.4, 1.0) })
|
| 971 |
+
const lw = eo(prog(g.lt(4), 3.9, 0.8)) * 90
|
| 972 |
+
line(c, cx - lw, by + bh + (P ? 260 : 238), cx + lw, by + bh + (P ? 260 : 238), C.gold, 2)
|
| 973 |
+
})
|
| 974 |
+
}
|
| 975 |
+
|
| 976 |
+
export { brierScene as brier }
|
kkndme/frontend/src/video/script.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// 旁白脚本:text 为字幕;say 为配音朗读用(可选);音频文件 public/vo/voNN.mp3 由同序号生成
|
| 2 |
+
export type SceneKey =
|
| 3 |
+
| 'intro'
|
| 4 |
+
| 'method'
|
| 5 |
+
| 'score'
|
| 6 |
+
| 'price'
|
| 7 |
+
| 'cities'
|
| 8 |
+
| 'money'
|
| 9 |
+
| 'policy'
|
| 10 |
+
| 'rulers'
|
| 11 |
+
| 'brier'
|
| 12 |
+
| 'blind'
|
| 13 |
+
| 'pending'
|
| 14 |
+
| 'outlook'
|
| 15 |
+
| 'outro'
|
| 16 |
+
export interface VoLine {
|
| 17 |
+
scene: SceneKey
|
| 18 |
+
text: string
|
| 19 |
+
say?: string
|
| 20 |
+
}
|
| 21 |
+
export const VO_LINES: VoLine[] = [
|
| 22 |
+
// 00 序章
|
| 23 |
+
{ scene: 'intro', text: '2010年,中国楼市正在狂飙。4月“新国十条”出台,北京率先限购,人人都在问:房价,到底会不会跌?', say: '2010年,中国楼市正在狂飙。4月,新国十条出台,北京率先限购。人人都在问:房价,到底会不会跌?' },
|
| 24 |
+
{ scene: 'intro', text: '就在这时,天涯论坛上,一个叫 KKndme 的网友开帖聊房子。他不晒房、不喊涨,而是从土地、货币,一路讲到制度和人性。', say: '就在这时,天涯论坛上,一个叫 K K need me 的网友,开帖聊房子。他不晒房,不喊涨,而是从土地、货币,一路讲到制度和人性。' },
|
| 25 |
+
{ scene: 'intro', text: '从2010年8月写到2011年7月,整整11个月,一千多层楼。网友追更、抄笔记、整理成册,尊称他“KK大神”。', say: '从2010年8月,写到2011年7月,整整11个月,一千多层楼。网友追更、抄笔记、整理成册,尊称他:K K大神。' },
|
| 26 |
+
{ scene: 'intro', text: '那一年,全国商品房均价每平方米5032元;十年后,是9860元。' },
|
| 27 |
+
{ scene: 'intro', text: '这个帖子被无数人奉为“房地产圣经”。可2021年之后,剧情突然反转。' },
|
| 28 |
+
{ scene: 'intro', text: '全国商品房销售面积,从17.9亿平方米,一路掉到8.8亿,少了一半。' },
|
| 29 |
+
{ scene: 'intro', text: '神贴到底神不神?今天不吹不黑,用数据把这十五年的账,一笔一笔对清楚。' },
|
| 30 |
+
// 07 方法
|
| 31 |
+
{ scene: 'method', text: '我用 Claude Opus 5.5,通读了两个文件:天涯原帖和整理合集。', say: '我用 Claude Opus 五点五,通读了两个文件:天涯原帖,和整理合集。' },
|
| 32 |
+
{ scene: 'method', text: '两个文件共986页:原帖480页、合集506页,约54万字。', say: '两个文件,一共986页:原帖480页,合集506页,约54万字。' },
|
| 33 |
+
{ scene: 'method', text: '从中提炼出43条核心理论,和123条能够核对的具体预测。' },
|
| 34 |
+
{ scene: 'method', text: '每一条都对照统计局、央行、国际清算银行的数据和公开报道,核对到2026年10月。' },
|
| 35 |
+
{ scene: 'method', text: '而且不只判对错,每条还要打四层标签:说得多具体、是否逆共识、赌的是什么、证据有多硬。' },
|
| 36 |
+
// 12 总成绩
|
| 37 |
+
{ scene: 'score', text: '先看总账:说对51条,说错30条,对错参半32条,还有10条没到期。' },
|
| 38 |
+
{ scene: 'score', text: '只算能分出对错的81条,命中率是63%。' },
|
| 39 |
+
{ scene: 'score', text: '但口径一换,结论就变:存疑全算错,只剩45%;存疑算半对,59%;按难度和证据加权,55%。' },
|
| 40 |
+
{ scene: 'score', text: '所以单看一个命中率没有意义。真正有价值的,是看他在哪里准、在哪里不准。' },
|
| 41 |
+
{ scene: 'score', text: '接下来,我们分五个战场逐一拆开:房价、城市、货币、政策,还有他看漏的地方。' },
|
| 42 |
+
// 17 房价
|
| 43 |
+
{ scene: 'price', text: '第一个战场,房价本身。这条线,是国际清算银行根据统计局70城数据编制的中国房价指数。' },
|
| 44 |
+
{ scene: 'price', text: '2011年,KKndme说二三线城市两三年内要涨50%到100%。实际三年,全国住宅均价只涨了约24%。', say: '2011年,K K大神说,二三线城市两三年内要涨50%到100%。实际三年,全国住宅均价只涨了约24%。' },
|
| 45 |
+
{ scene: 'price', text: '他坚信房价不会跌回2004年。这条至今成立:2025年住宅均价约1万元,是2004年的3.8倍。' },
|
| 46 |
+
{ scene: 'price', text: '但他也说房价不会大跌三到五成。2021年三季度见顶后,指数连跌四年半,名义跌了约22%,还没到三成,这条暂无定论。' },
|
| 47 |
+
{ scene: 'price', text: '扣掉通胀更明显:实际房价指数跌到85,比2010年还低了15%。' },
|
| 48 |
+
{ scene: 'price', text: '这一战场的成绩:方向大体对,幅度和时间点频频失手,命中率只有38%。' },
|
| 49 |
+
// 23 城市
|
| 50 |
+
{ scene: 'cities', text: '第二个战场,城市。这是他看得最准的领域之一:城市分化类的判断,命中率78%。' },
|
| 51 |
+
{ scene: 'cities', text: '他说一线城市长期跑赢。2010年底到2026年8月,北上广深新房平均涨了111%,其余66城只涨了33%。2026年3月起,一线二手房价格又连续7个月环比上涨。' },
|
| 52 |
+
{ scene: 'cities', text: '上海涨了154%,70城第一。他点名“房价低不了”的合肥,十年涨了两倍。' },
|
| 53 |
+
{ scene: 'cities', text: '他提醒环京概念盘和旅游地产风险大:燕郊从3.4万跌到1.2万,乳山银滩跌了近八成。' },
|
| 54 |
+
{ scene: 'cities', text: '可他看好的昆明、南宁都让人失望。他说重庆6000元的房子很快到9900,两年后仍是6389。', say: '可他看好的昆明、南宁都让人失望。他说重庆六千元的房子很快到九千九百,两年后仍是六千三百八十九。' },
|
| 55 |
+
{ scene: 'cities', text: '看懂了大逻辑,却常常押错具体的牌。' },
|
| 56 |
+
// 29 货币
|
| 57 |
+
{ scene: 'money', text: '第三个战场,钱。KKndme的核心逻辑是:货币超发,必然高通胀,房子是普通人唯一的避风港。', say: '第三个战场,钱。K K大神的核心逻辑是:货币超发,必然高通胀,房子是普通人唯一的避风港。' },
|
| 58 |
+
{ scene: 'money', text: '货币确实超发了:M2从2010年的72.6万亿,涨到2025年的340万亿,是原来的4.7倍。', say: '货币确实超发了:M二从2010年的72.6万亿,涨到2025年的340万亿,是原来的4.7倍。' },
|
| 59 |
+
{ scene: 'money', text: '可物价没有跟上:同期CPI累计只涨了32%。他说十年物价可能再涨20倍,差了两个数量级。' },
|
| 60 |
+
{ scene: 'money', text: '更反直觉的是,钱越来越多,房价后来却跌了。“印钞托底房价”的逻辑,在2021年后失灵。' },
|
| 61 |
+
{ scene: 'money', text: '汇率上他很清醒:人民币只会适度升值,到不了4比1。实际最高6.04,后来贬到7.3,如今又回到6.7左右。' },
|
| 62 |
+
{ scene: 'money', text: '黄金他说风险很大,短期确实如此,2013年暴跌28%。但十五年后,金价从1250涨到了4000美元。' },
|
| 63 |
+
// 35 政策
|
| 64 |
+
{ scene: 'policy', text: '第四个战场,政策。这是他另一块强项:调控与房产税的判断,命中率83%。' },
|
| 65 |
+
{ scene: 'policy', text: '他说两年内调控不会放松、更多城市要限购。2011年,限购扩大到46个城市。' },
|
| 66 |
+
{ scene: 'policy', text: '他说房产税真正实施很难。十五年过去,只有沪渝试点;“十五五”规划里,房地产税立法已不见踪影。' },
|
| 67 |
+
{ scene: 'policy', text: '他说70年住宅产权到期自动续期。2020年,《民法典》第359条把它写进了法律。' },
|
| 68 |
+
{ scene: 'policy', text: '但也有翻车:他说房产税两年内一定不征,5个月后沪渝就开征了;说限购不会长期,结果一限就是十四年。' },
|
| 69 |
+
{ scene: 'policy', text: '他说首套首付要提到40%,实际一路降到15%,是1998年以来最低。' },
|
| 70 |
+
// 41 三把尺子
|
| 71 |
+
{ scene: 'rulers', text: '为什么同一个人,有时神准,有时离谱?我们用三把尺子来量。' },
|
| 72 |
+
{ scene: 'rulers', text: '第一把,具体程度。模糊判断命中71%,方向明确69%,一旦带上数字或期限,只剩45%。' },
|
| 73 |
+
{ scene: 'rulers', text: '第二把,是否逆共识。顺着共识说的命中80%,逆着大众说的只有48%,还不如抛硬币。' },
|
| 74 |
+
{ scene: 'rulers', text: '第三把,赌的是什么。政策和城市分化接近八成;时间点只有40%,涨跌幅度只有30%。' },
|
| 75 |
+
{ scene: 'rulers', text: '结论很清晰:他擅长讲逻辑、判方向,不擅长报数字、掐时间。' },
|
| 76 |
+
// 46 布里尔
|
| 77 |
+
{ scene: 'brier', text: '还有一个问题:他说话的语气,是不是太自信了?' },
|
| 78 |
+
{ scene: 'brier', text: '我们用布里尔分数来衡量“自信度准不准”:分数越低越好,0分代表全知全能。' },
|
| 79 |
+
{ scene: 'brier', text: '如果每句话都按九成把握来算,KKndme得分0.265;按八成算,0.213。都比每句只说“五五开”的0.179还差。', say: '如果每句话都按九成把握来算,K K大神得分0.265;按八成算,0.213。都比每句只说“五五开”的0.179还差。' },
|
| 80 |
+
{ scene: 'brier', text: '如果他把把握说成六成,分数反而最好。神贴最大的问题,不是看错,而是太笃定。' },
|
| 81 |
+
// 50 盲区
|
| 82 |
+
{ scene: 'blind', text: '最后一个战场,是他的盲区:租金、人口和利率。' },
|
| 83 |
+
{ scene: 'blind', text: '他断言“房租下降基本是做梦”。结果2022年起租金连年下跌,租金类预测一条都没说中。' },
|
| 84 |
+
{ scene: 'blind', text: '他认为三四线城市人口还会缓慢增长。七普显示,337个城市里有149个人口减少,东北十年少了1101万人。' },
|
| 85 |
+
{ scene: 'blind', text: '他也没料到利率会一路走低:房贷利率从6%以上降到3%出头,首付降到15%,房价却还在跌。' },
|
| 86 |
+
{ scene: 'blind', text: '他的世界观建立在人口红利和货币扩张上。前提一旦松动,最笃定的判断也会失效。' },
|
| 87 |
+
// 55 未到期
|
| 88 |
+
{ scene: 'pending', text: '还有10条预测没到期:3条正在偏向他,2条正在偏离,5条还看不清。' },
|
| 89 |
+
{ scene: 'pending', text: '偏向他的:人民币至今没有自由兑换;体制外打工者的养老,压力越来越大。' },
|
| 90 |
+
{ scene: 'pending', text: '偏离他的:北京核心区房价超过香港,越来越远;房产税“将来一定会出”,也越来越看不到。' },
|
| 91 |
+
// 58 理论框架与展望
|
| 92 |
+
{ scene: 'outlook', text: '对完账,再看��留下的真正资产:一套看房价的理论框架。43条核心理论,归成八大板块。' },
|
| 93 |
+
{ scene: 'outlook', text: '它的重要性在于,回答了房价背后的三个根本问题:谁在定价、钱从哪里来、人往哪里去。十五年后,用它解释城市分化,依然好用。' },
|
| 94 |
+
{ scene: 'outlook', text: '那么,按照 KKndme 的理论框架,未来房价会怎么走?以下是AI引用他的理论框架做的推演,不构成投资建议。', say: '那么,按照K K大神的理论框架,未来房价会怎么走?以下,是AI引用他的理论框架做的推演,不构成投资建议。' },
|
| 95 |
+
{ scene: 'outlook', text: '第一,分化继续。按他的“资金流向”理论:全国富人买京沪,全省富人买省会。核心城市的核心地段,最抗跌。' },
|
| 96 |
+
{ scene: 'outlook', text: '第二,普涨难再。他说房价和租金由外来人口决定。如今人口见顶,人口不再流入的城市,房价会长期承压。' },
|
| 97 |
+
{ scene: 'outlook', text: '第三,崩盘也难。按“土地财政”和“政府不会让房地产崩盘”的逻辑,政策会持续托底,更可能是长时间的横盘消化。' },
|
| 98 |
+
{ scene: 'outlook', text: '但要注意,他最核心的“货币蓄水池”逻辑已经打了折扣:钱越来越多,房价却没有跟着涨。' },
|
| 99 |
+
{ scene: 'outlook', text: '所以,未来买房,买的不是“中国房价”,而是具体的城市和地段。再强调一次:这是AI基于理论框架的推演,不构成任何投资建议。' },
|
| 100 |
+
// 66 结论
|
| 101 |
+
{ scene: 'outro', text: '十五年对账,这个神贴留给我们什么?' },
|
| 102 |
+
{ scene: 'outro', text: '把他的判断放进四个象限:政策和城市分化,他看得很准;数字、时间点和租金,他屡屡失手。' },
|
| 103 |
+
{ scene: 'outro', text: '看对方向容易,算准时间很难。' },
|
| 104 |
+
{ scene: 'outro', text: '任何预言都建立在当时的前提上。前提变了,再神的帖子,也会过期。' },
|
| 105 |
+
{ scene: 'outro', text: '但对账不是为了挑刺。2010年房价还在狂飙,他就把土地财政、货币超发、城市分化这套逻辑,讲得清清楚楚。' },
|
| 106 |
+
{ scene: 'outro', text: '政策走向和城市分化,他判断对了近八成。这份眼光,放在当年凤毛麟角。' },
|
| 107 |
+
{ scene: 'outro', text: '更难得的是格局:他看的不是一套房的涨跌,而是制度、人口和财富的流向,教会了一代人用经济学的眼光看房子。这份功力,值得致敬:KKndme。', say: '更难得的是格局:他看的不是一套房的涨跌,而是制度、人口和财富的流向,教会了一代人用经济学的眼光看房子。这份功力,值得致敬:K K need me。' },
|
| 108 |
+
{ scene: 'outro', text: '123条完整核对,每条都附原话和出处,相关文件全部放在评论区。觉得有收获,记得关注、点赞,在评论区聊聊你的看法。我们下期见。' },
|
| 109 |
+
]
|
| 110 |
+
|
| 111 |
+
/** 估算某个词在一句旁白中开始朗读的位置(占整句时长的比例):标点处有停顿、数字读得更长 */
|
| 112 |
+
export function wordAt(text: string, w: string) {
|
| 113 |
+
const wt = (c: string) => (/[,。、:;?!]/.test(c) ? 1.5 : /\d/.test(c) ? 1.4 : 1)
|
| 114 |
+
const i = text.indexOf(w)
|
| 115 |
+
if (i < 0) return 0
|
| 116 |
+
const tot = [...text].reduce((a, c) => a + wt(c), 0)
|
| 117 |
+
return [...text.slice(0, i)].reduce((a, c) => a + wt(c), 0) / tot
|
| 118 |
+
}
|
| 119 |
+
/** 片尾最后一句中“关注 / 点赞 / 评论”出现的位置,用于按钮动效与音效对齐 */
|
| 120 |
+
const LAST = VO_LINES[VO_LINES.length - 1].text
|
| 121 |
+
export const CTA_AT: [number, number, number] = [wordAt(LAST, '关注'), wordAt(LAST, '点赞'), wordAt(LAST, '评论')]
|
| 122 |
+
/** 片尾关注卡出现的位置 */
|
| 123 |
+
export const CTA_IN = wordAt(LAST, '觉得')
|
kkndme/frontend/src/video/series.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// 视频图表用的真实数据序列(来源见注释)
|
| 2 |
+
|
| 3 |
+
/** BIS 中国住宅价格指数(2010=100),季度,2010Q1–2026Q1。来源:BIS / FRED QCNN628BIS、QCNR628BIS */
|
| 4 |
+
export const BIS_NOM = [97.76,100.01,100.38,101.86,103.51,104.28,104.48,104.20,103.66,103.11,103.26,103.66,105.59,108.56,111.01,113.06,114.29,114.34,111.72,109.16,107.82,107.59,108.24,108.84,111.53,113.83,116.42,119.20,120.62,122.99,124.38,125.15,125.88,127.70,131.57,134.16,135.44,137.15,138.50,139.23,139.49,140.26,141.57,142.45,143.72,145.40,145.91,144.75,143.50,142.23,141.13,139.38,138.69,138.43,136.64,134.20,131.53,128.21,124.93,122.70,121.64,120.00,118.03,115.66,113.98]
|
| 5 |
+
export const BIS_REAL = [98.47,100.88,100.69,99.96,99.13,99.32,98.45,97.69,95.62,95.50,95.54,95.31,95.18,98.28,100.00,101.01,100.76,101.25,98.56,95.95,93.77,93.82,93.83,94.26,94.91,97.16,99.11,100.94,101.19,103.50,104.28,104.23,103.56,105.81,108.07,109.44,109.46,110.55,110.35,108.75,107.16,109.94,110.31,111.21,110.55,112.63,112.99,111.09,109.33,107.83,106.45,105.04,104.34,104.85,103.13,101.48,98.96,96.85,93.82,92.60,91.61,90.68,88.85,86.79,85.13]
|
| 6 |
+
export const BIS_START = 2010
|
| 7 |
+
/** 季度序号 → 年份(小数) */
|
| 8 |
+
export const qYear = (i: number) => BIS_START + i / 4 + 0.125
|
| 9 |
+
|
| 10 |
+
/** 美元兑人民币月均价,2010-01 至 2026-09。来源:美联储 H.10 / FRED EXCHUS */
|
| 11 |
+
export const FX = [6.827,6.829,6.826,6.826,6.827,6.818,6.776,6.787,6.740,6.668,6.654,6.650,6.596,6.576,6.564,6.527,6.496,6.475,6.457,6.404,6.388,6.371,6.356,6.348,6.317,6.300,6.312,6.304,6.324,6.363,6.372,6.359,6.320,6.263,6.234,6.233,6.221,6.232,6.215,6.186,6.142,6.134,6.134,6.121,6.120,6.103,6.093,6.074,6.051,6.082,6.173,6.225,6.238,6.231,6.198,6.154,6.138,6.125,6.125,6.189,6.218,6.252,6.239,6.201,6.204,6.205,6.208,6.338,6.368,6.351,6.364,6.449,6.573,6.550,6.503,6.475,6.526,6.589,6.677,6.647,6.670,6.730,6.840,6.920,6.891,6.869,6.894,6.888,6.884,6.807,6.769,6.667,6.569,6.625,6.620,6.593,6.423,6.318,6.317,6.297,6.370,6.465,6.716,6.845,6.855,6.919,6.937,6.884,6.786,6.737,6.712,6.716,6.852,6.898,6.878,7.063,7.114,7.096,7.020,7.014,6.918,6.997,7.021,7.071,7.102,7.082,7.004,6.927,6.811,6.725,6.603,6.539,6.467,6.460,6.511,6.519,6.432,6.425,6.476,6.477,6.456,6.417,6.389,6.369,6.356,6.344,6.345,6.431,6.699,6.695,6.735,6.801,7.019,7.190,7.181,6.972,6.790,6.838,6.891,6.888,6.985,7.161,7.186,7.249,7.298,7.307,7.223,7.140,7.171,7.194,7.202,7.237,7.233,7.255,7.261,7.147,7.076,7.088,7.206,7.281,7.296,7.273,7.249,7.297,7.217,7.180,7.174,7.173,7.123,7.120,7.107,7.043,6.969,6.906,6.892,6.837,6.800,6.776,6.776,6.736,6.708]
|
| 12 |
+
export const mYear = (i: number) => 2010 + i / 12 + 1 / 24
|
| 13 |
+
|
| 14 |
+
/** 年末 M2(万亿元),2010–2025。来源:中国人民银行 */
|
| 15 |
+
export const M2 = [72.58, 85.16, 97.42, 110.65, 122.84, 139.23, 155.01, 167.68, 182.67, 198.65, 218.68, 238.29, 266.43, 292.27, 313.53, 340.29]
|
| 16 |
+
/** CPI 年度涨幅(%),2010–2025。来源:国家统计局 */
|
| 17 |
+
export const CPI_RATE = [3.3, 5.4, 2.6, 2.6, 2.0, 1.4, 2.0, 1.6, 2.1, 2.9, 2.5, 0.9, 2.0, 0.2, 0.2, 0.0]
|
| 18 |
+
/** 全国商品房销售面积(亿平方米),2010–2025。来源:国家统计局 */
|
| 19 |
+
export const SALES = [10.43, 10.99, 11.13, 13.06, 12.06, 12.85, 15.73, 16.94, 17.17, 17.16, 17.61, 17.94, 13.58, 11.17, 9.74, 8.81]
|
| 20 |
+
|
| 21 |
+
/** 以 2010 年为 1 的指数 */
|
| 22 |
+
export const M2_IDX = M2.map((v) => v / M2[0])
|
| 23 |
+
export const CPI_IDX = CPI_RATE.map((_, i) => CPI_RATE.slice(1, i + 1).reduce((a, r) => a * (1 + r / 100), 1))
|
| 24 |
+
const annual = Array.from({ length: 16 }, (_, y) => BIS_NOM.slice(y * 4, y * 4 + 4).reduce((a, b) => a + b, 0) / 4)
|
| 25 |
+
export const HOUSE_IDX = annual.map((v) => v / annual[0])
|
| 26 |
+
|
| 27 |
+
export type CityStatus = 'correct' | 'wrong' | 'disputed'
|
| 28 |
+
export interface City {
|
| 29 |
+
name: string
|
| 30 |
+
lon: number
|
| 31 |
+
lat: number
|
| 32 |
+
st: CityStatus
|
| 33 |
+
/** 标签方位 */
|
| 34 |
+
lab: 'l' | 'r' | 't' | 'b'
|
| 35 |
+
}
|
| 36 |
+
export const CITIES: City[] = [
|
| 37 |
+
{ name: '北京', lon: 116.4, lat: 39.9, st: 'correct', lab: 'l' },
|
| 38 |
+
{ name: '燕郊', lon: 116.9, lat: 40.25, st: 'correct', lab: 'r' },
|
| 39 |
+
{ name: '天津', lon: 117.4, lat: 39.0, st: 'disputed', lab: 'r' },
|
| 40 |
+
{ name: '石家庄', lon: 114.51, lat: 38.04, st: 'disputed', lab: 'l' },
|
| 41 |
+
{ name: '大连', lon: 121.61, lat: 38.91, st: 'disputed', lab: 'r' },
|
| 42 |
+
{ name: '青岛', lon: 120.38, lat: 36.07, st: 'disputed', lab: 'l' },
|
| 43 |
+
{ name: '乳山', lon: 121.54, lat: 36.92, st: 'correct', lab: 'r' },
|
| 44 |
+
{ name: '郑州', lon: 113.62, lat: 34.75, st: 'correct', lab: 'l' },
|
| 45 |
+
{ name: '西安', lon: 108.94, lat: 34.34, st: 'correct', lab: 'l' },
|
| 46 |
+
{ name: '合肥', lon: 117.23, lat: 31.82, st: 'correct', lab: 'l' },
|
| 47 |
+
{ name: '上海', lon: 121.47, lat: 31.23, st: 'correct', lab: 'r' },
|
| 48 |
+
{ name: '杭州', lon: 120.15, lat: 30.27, st: 'disputed', lab: 'b' },
|
| 49 |
+
{ name: '武汉', lon: 114.3, lat: 30.59, st: 'correct', lab: 't' },
|
| 50 |
+
{ name: '成都', lon: 104.07, lat: 30.67, st: 'disputed', lab: 'l' },
|
| 51 |
+
{ name: '重庆', lon: 106.55, lat: 29.56, st: 'wrong', lab: 'r' },
|
| 52 |
+
{ name: '长沙', lon: 112.94, lat: 28.23, st: 'correct', lab: 'l' },
|
| 53 |
+
{ name: '厦门', lon: 118.09, lat: 24.48, st: 'disputed', lab: 'r' },
|
| 54 |
+
{ name: '大理', lon: 100.23, lat: 25.6, st: 'disputed', lab: 'l' },
|
| 55 |
+
{ name: '昆明', lon: 102.83, lat: 24.88, st: 'wrong', lab: 'b' },
|
| 56 |
+
{ name: '广佛', lon: 113.2, lat: 23.08, st: 'correct', lab: 'l' },
|
| 57 |
+
{ name: '深圳', lon: 114.06, lat: 22.54, st: 'correct', lab: 'r' },
|
| 58 |
+
{ name: '南宁', lon: 108.37, lat: 22.82, st: 'wrong', lab: 'l' },
|
| 59 |
+
{ name: '三亚', lon: 109.51, lat: 18.25, st: 'correct', lab: 'r' },
|
| 60 |
+
]
|
kkndme/frontend/src/video/timeline.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { VO_LINES, type SceneKey } from './script'
|
| 2 |
+
|
| 3 |
+
export const SCENE_INFO: Record<SceneKey, { no: string; title: string; en: string }> = {
|
| 4 |
+
intro: { no: '01', title: '序章', en: 'PROLOGUE' },
|
| 5 |
+
method: { no: '02', title: '方法', en: 'METHODOLOGY' },
|
| 6 |
+
score: { no: '03', title: '总成绩', en: 'THE SCORECARD' },
|
| 7 |
+
price: { no: '04', title: '房价', en: 'HOUSING PRICES' },
|
| 8 |
+
cities: { no: '05', title: '城市', en: 'CITIES' },
|
| 9 |
+
money: { no: '06', title: '货币', en: 'MONEY & FX' },
|
| 10 |
+
policy: { no: '07', title: '政策', en: 'POLICY' },
|
| 11 |
+
rulers: { no: '08', title: '三把尺子', en: 'THREE RULERS' },
|
| 12 |
+
brier: { no: '09', title: '自信校准', en: 'CALIBRATION' },
|
| 13 |
+
blind: { no: '10', title: '盲区', en: 'BLIND SPOTS' },
|
| 14 |
+
pending: { no: '11', title: '未到期', en: 'STILL OPEN' },
|
| 15 |
+
outlook: { no: '12', title: '理论与展望', en: 'FRAMEWORK & OUTLOOK' },
|
| 16 |
+
outro: { no: '13', title: '结论', en: 'VERDICT' },
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
export interface TLine {
|
| 20 |
+
i: number
|
| 21 |
+
scene: SceneKey
|
| 22 |
+
text: string
|
| 23 |
+
start: number
|
| 24 |
+
end: number
|
| 25 |
+
/** 旁白音量包络(每秒 AMP_RATE 个点,0–1),用于字幕头像的音频动效 */
|
| 26 |
+
amp?: number[]
|
| 27 |
+
}
|
| 28 |
+
export interface TScene {
|
| 29 |
+
key: SceneKey
|
| 30 |
+
idx: number
|
| 31 |
+
start: number
|
| 32 |
+
end: number
|
| 33 |
+
lines: TLine[]
|
| 34 |
+
}
|
| 35 |
+
export interface Timeline {
|
| 36 |
+
lines: TLine[]
|
| 37 |
+
scenes: TScene[]
|
| 38 |
+
duration: number
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/** 片头封面停留时长 */
|
| 42 |
+
export const COVER = 1.0
|
| 43 |
+
const PRE_ROLL = 1.6
|
| 44 |
+
const GAP = 0.42
|
| 45 |
+
/** 章节之间:上一章收尾留白 + 章节标题卡 */
|
| 46 |
+
const SCENE_GAP = 3.1
|
| 47 |
+
/** 章节标题卡时长(场景开始到第一句旁白) */
|
| 48 |
+
export const CARD = 2.6
|
| 49 |
+
const END_HOLD = 7.5
|
| 50 |
+
/** 个别句子后需要额外留白给画面 */
|
| 51 |
+
const HOLD: Partial<Record<SceneKey, Record<number, number>>> = {
|
| 52 |
+
intro: { 0: 0.4, 1: 0.3, 2: 0.6, 3: 0.4, 5: 0.9 },
|
| 53 |
+
method: { 1: 0.5, 4: 0.6 },
|
| 54 |
+
score: { 1: 0.5, 2: 0.8 },
|
| 55 |
+
price: { 1: 0.6, 3: 0.6, 4: 0.4 },
|
| 56 |
+
cities: { 1: 0.4, 4: 0.5, 5: 1.0 },
|
| 57 |
+
money: { 1: 0.3, 2: 0.4, 4: 0.5 },
|
| 58 |
+
policy: { 4: 0.5 },
|
| 59 |
+
rulers: { 3: 0.6, 4: 0.6 },
|
| 60 |
+
brier: { 2: 0.4, 3: 0.9 },
|
| 61 |
+
blind: { 3: 0.4, 4: 1.0 },
|
| 62 |
+
pending: { 2: 0.5 },
|
| 63 |
+
outlook: { 0: 0.6, 1: 0.6, 2: 1.0, 3: 0.5, 4: 0.5, 5: 0.6, 6: 0.6, 7: 1.0 },
|
| 64 |
+
outro: { 1: 0.8, 2: 1.2, 3: 0.9, 4: 0.5, 5: 0.5, 6: 1.0 },
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
export function buildTimeline(durs: number[]): Timeline {
|
| 68 |
+
const lines: TLine[] = []
|
| 69 |
+
let t = COVER + PRE_ROLL
|
| 70 |
+
let local = 0
|
| 71 |
+
VO_LINES.forEach((l, i) => {
|
| 72 |
+
if (i > 0 && VO_LINES[i - 1].scene !== l.scene) {
|
| 73 |
+
t += SCENE_GAP
|
| 74 |
+
local = 0
|
| 75 |
+
}
|
| 76 |
+
const d = durs[i] ?? 4
|
| 77 |
+
lines.push({ i, scene: l.scene, text: l.text, start: t, end: t + d })
|
| 78 |
+
t += d + GAP + (HOLD[l.scene]?.[local] ?? 0)
|
| 79 |
+
local++
|
| 80 |
+
})
|
| 81 |
+
const duration = lines[lines.length - 1].end + END_HOLD
|
| 82 |
+
const keys: SceneKey[] = []
|
| 83 |
+
lines.forEach((l) => {
|
| 84 |
+
if (!keys.includes(l.scene)) keys.push(l.scene)
|
| 85 |
+
})
|
| 86 |
+
const scenes: TScene[] = keys.map((key, idx) => {
|
| 87 |
+
const ls = lines.filter((l) => l.scene === key)
|
| 88 |
+
return { key, idx, start: idx === 0 ? COVER : ls[0].start - CARD, end: 0, lines: ls }
|
| 89 |
+
})
|
| 90 |
+
scenes.forEach((s, k) => (s.end = k < scenes.length - 1 ? scenes[k + 1].start : duration))
|
| 91 |
+
return { lines, scenes, duration }
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
export const AMP_RATE = 30
|
| 95 |
+
|
| 96 |
+
/** 由旁白音频算出每句的音量包络 */
|
| 97 |
+
export function attachAmp(tl: Timeline, bufs: AudioBuffer[]) {
|
| 98 |
+
const raw: number[][] = bufs.map((b) => {
|
| 99 |
+
const d = b.getChannelData(0)
|
| 100 |
+
const win = Math.max(1, Math.floor(b.sampleRate / AMP_RATE))
|
| 101 |
+
const out: number[] = []
|
| 102 |
+
for (let s0 = 0; s0 < d.length; s0 += win) {
|
| 103 |
+
let acc = 0
|
| 104 |
+
const e = Math.min(d.length, s0 + win)
|
| 105 |
+
for (let k = s0; k < e; k += 4) acc += d[k] * d[k]
|
| 106 |
+
out.push(Math.sqrt(acc / Math.max(1, (e - s0) / 4)))
|
| 107 |
+
}
|
| 108 |
+
return out
|
| 109 |
+
})
|
| 110 |
+
const all = raw.flat().filter((v) => v > 0.004).sort((a, b) => a - b)
|
| 111 |
+
const ref = all[Math.floor(all.length * 0.97)] || 0.2
|
| 112 |
+
tl.lines.forEach((l, i) => {
|
| 113 |
+
l.amp = (raw[i] ?? []).map((v) => Math.round(Math.min(1, v / ref) * 100) / 100)
|
| 114 |
+
})
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
/** 当前时刻的旁白音量(0–1) */
|
| 118 |
+
export function ampAt(tl: Timeline, t: number) {
|
| 119 |
+
for (const l of tl.lines) {
|
| 120 |
+
if (t < l.start) return 0
|
| 121 |
+
if (t < l.end && l.amp) return l.amp[Math.floor((t - l.start) * AMP_RATE)] ?? 0
|
| 122 |
+
}
|
| 123 |
+
return 0
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
export function sceneAt(tl: Timeline, t: number): TScene {
|
| 127 |
+
if (t < tl.scenes[0].start) return tl.scenes[0]
|
| 128 |
+
for (const s of tl.scenes) if (t >= s.start && t < s.end) return s
|
| 129 |
+
return tl.scenes[tl.scenes.length - 1]
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
export const fmtTime = (s: number) => {
|
| 133 |
+
const m = Math.floor(s / 60)
|
| 134 |
+
const ss = Math.floor(s % 60)
|
| 135 |
+
return `${m}:${ss.toString().padStart(2, '0')}`
|
| 136 |
+
}
|
kkndme/frontend/src/vite-env.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
/// <reference types="vite/client" />
|
kkndme/frontend/tsconfig.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"compilerOptions": {
|
| 3 |
+
"target": "ES2020",
|
| 4 |
+
"useDefineForClassFields": true,
|
| 5 |
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
| 6 |
+
"module": "ESNext",
|
| 7 |
+
"skipLibCheck": true,
|
| 8 |
+
"moduleResolution": "bundler",
|
| 9 |
+
"allowImportingTsExtensions": true,
|
| 10 |
+
"isolatedModules": true,
|
| 11 |
+
"noEmit": true,
|
| 12 |
+
"jsx": "react-jsx",
|
| 13 |
+
"strict": true,
|
| 14 |
+
"noUnusedLocals": false,
|
| 15 |
+
"noUnusedParameters": false,
|
| 16 |
+
"noFallthroughCasesInSwitch": true,
|
| 17 |
+
"paths": {
|
| 18 |
+
"@/*": ["./src/*"]
|
| 19 |
+
}
|
| 20 |
+
},
|
| 21 |
+
"include": ["src"]
|
| 22 |
+
}
|
kkndme/frontend/vite.config.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import viteErrorReporter from "./.vulcan-error-reporter.js";
|
| 2 |
+
import path from 'path'
|
| 3 |
+
import { defineConfig } from 'vite'
|
| 4 |
+
import react from '@vitejs/plugin-react'
|
| 5 |
+
import tailwindcss from '@tailwindcss/vite'
|
| 6 |
+
|
| 7 |
+
export default defineConfig(() => {
|
| 8 |
+
const frontendPort = Number.parseInt(process.env.PORT || '', 10)
|
| 9 |
+
const backendPort = Number.parseInt(process.env.BACKEND_PORT || '', 10)
|
| 10 |
+
const base = process.env.BASE_PATH || './'
|
| 11 |
+
const hasAbsBase = base.startsWith('/')
|
| 12 |
+
const apiBasePrefix = hasAbsBase ? base.replace(/\/$/, '') : ''
|
| 13 |
+
|
| 14 |
+
const backendProxy = {
|
| 15 |
+
target: `http://127.0.0.1:${backendPort}`,
|
| 16 |
+
changeOrigin: true,
|
| 17 |
+
...(hasAbsBase && {
|
| 18 |
+
rewrite: (requestPath: string) => requestPath.replace(base, '/'),
|
| 19 |
+
}),
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
return {
|
| 23 |
+
cacheDir: process.env.VITE_CACHE_DIR || 'node_modules/.vite',
|
| 24 |
+
plugins: [
|
| 25 |
+
viteErrorReporter({ vulcanDir: "/workspaces/.vulcan" }),react(), tailwindcss()],
|
| 26 |
+
server: {
|
| 27 |
+
allowedHosts: true,
|
| 28 |
+
host: '0.0.0.0',
|
| 29 |
+
port: frontendPort || undefined,
|
| 30 |
+
proxy: {
|
| 31 |
+
[`${apiBasePrefix}/api`]: backendProxy,
|
| 32 |
+
},
|
| 33 |
+
hmr: {
|
| 34 |
+
path: 'ws/vite-hmr',
|
| 35 |
+
},
|
| 36 |
+
},
|
| 37 |
+
resolve: {
|
| 38 |
+
alias: {
|
| 39 |
+
'@': path.resolve(__dirname, './src'),
|
| 40 |
+
},
|
| 41 |
+
dedupe: ['react', 'react-dom'],
|
| 42 |
+
preserveSymlinks: true,
|
| 43 |
+
},
|
| 44 |
+
optimizeDeps: {
|
| 45 |
+
include: [
|
| 46 |
+
'react',
|
| 47 |
+
'react-dom',
|
| 48 |
+
'react-dom/client',
|
| 49 |
+
'react/jsx-dev-runtime',
|
| 50 |
+
'react/jsx-runtime',
|
| 51 |
+
'@tanstack/react-query',
|
| 52 |
+
'@tanstack/query-core',
|
| 53 |
+
],
|
| 54 |
+
},
|
| 55 |
+
base,
|
| 56 |
+
}
|
| 57 |
+
})
|