Surf commited on
Commit
e8aa02b
·
1 Parent(s): 2d40a4f

画面:移除顶部标注并加入语音结束奥德彪签名(推送 #16)

Browse files
Files changed (1) hide show
  1. src/film/core/renderer.ts +28 -22
src/film/core/renderer.ts CHANGED
@@ -4,7 +4,7 @@ import { Post, defaultPost, type PostParams } from './post'
4
  import { FONT } from './assets'
5
  import { drawVideo, type Rect } from './fx'
6
  import { adv, breakClause, drawChar, placeTrackedLine, txt } from './typo'
7
- import { clamp, ease, pad2, smooth } from './util'
8
 
9
  const SUB = '#F6F0E6'
10
  const GOLD = '#F5C518'
@@ -37,26 +37,6 @@ function rule(g: CanvasRenderingContext2D, x: number, y: number, w: number, p: n
37
  g.restore()
38
  }
39
 
40
- /** 纪录片式角标:用留白、细线和两套字体建立字幕的编辑系统。 */
41
- function drawEditorialMeta(g: CanvasRenderingContext2D, w: number, h: number, f: Film, t: number, portrait: boolean, u: number) {
42
- const a = smooth((t - 0.35) / 0.75)
43
- if (a <= 0) return
44
- const x = portrait ? w * 0.1 : w * 0.055
45
- const y = portrait ? h * 0.075 : h * 0.09
46
- const s = Math.min(w, h)
47
- g.save()
48
- g.globalAlpha = a
49
- g.shadowColor = 'rgba(0,0,0,0.5)'
50
- g.shadowBlur = 12 * u
51
- g.fillStyle = SUB
52
- g.textAlign = 'left'
53
- txt(g, 'ODEBIAO / FIELD NOTES', x, y - s * 0.018, `400 ${s * (portrait ? 0.018 : 0.014)}px ${FONT.mono}`, MUTED, 'left', 0.08)
54
- txt(g, f.chapter, x, y + s * 0.024, `500 ${s * (portrait ? 0.032 : 0.026)}px ${FONT.serif}`, SUB, 'left', 0.12)
55
- rule(g, x, y + s * 0.062, s * (portrait ? 0.19 : 0.12), 1, GOLD, Math.max(1, u * 1.5))
56
- txt(g, `№ ${pad2(f.id)} / 43`, w - (portrait ? w * 0.1 : w * 0.055), y, `400 ${s * (portrait ? 0.019 : 0.014)}px ${FONT.mono}`, MUTED, 'right', 0.08)
57
- g.restore()
58
- }
59
-
60
  /** 绘制一页“编辑设计”字幕:主句、关键词、细框与章节信息各自有层级。 */
61
  function drawEditorialSubtitle(g: CanvasRenderingContext2D, w: number, h: number, f: Film, t: number, portrait: boolean, u: number): number {
62
  const page = f.pageAt(t)
@@ -171,6 +151,31 @@ function drawEnglishAfterglow(g: CanvasRenderingContext2D, w: number, h: number,
171
  g.restore()
172
  }
173
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  export function videoRect(w: number, h: number): Rect {
175
  if (w >= h) return { x: 0, y: 0, w, h }
176
  const vh = (w * 9) / 16
@@ -193,9 +198,10 @@ export function drawFilmFrame(g: CanvasRenderingContext2D, w: number, h: number,
193
  g.fillStyle = shade
194
  g.fillRect(0, portrait ? h * 0.52 : h * 0.54, w, h * 0.48)
195
 
196
- drawEditorialMeta(g, w, h, f, t, portrait, u)
197
  const bottom = drawEditorialSubtitle(g, w, h, f, t, portrait, u)
198
  drawEnglishAfterglow(g, w, h, f, t, bottom, portrait, u)
 
199
 
200
  // 淡入淡出仍然由同一条时间线控制,导出与播放保持一致。
201
  const fin = smooth(t / 0.8)
 
4
  import { FONT } from './assets'
5
  import { drawVideo, type Rect } from './fx'
6
  import { adv, breakClause, drawChar, placeTrackedLine, txt } from './typo'
7
+ import { clamp, ease, smooth } from './util'
8
 
9
  const SUB = '#F6F0E6'
10
  const GOLD = '#F5C518'
 
37
  g.restore()
38
  }
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  /** 绘制一页“编辑设计”字幕:主句、关键词、细框与章节信息各自有层级。 */
41
  function drawEditorialSubtitle(g: CanvasRenderingContext2D, w: number, h: number, f: Film, t: number, portrait: boolean, u: number): number {
42
  const page = f.pageAt(t)
 
151
  g.restore()
152
  }
153
 
154
+ /** 每条语音结束后的片尾签名:不增加角标,只留下“奥德彪”这一句余韵。 */
155
+ function drawSignature(g: CanvasRenderingContext2D, w: number, h: number, f: Film, t: number, portrait: boolean, u: number) {
156
+ const inA = smooth((t - f.ve - 0.12) / 0.55)
157
+ const outA = smooth((f.T - t) / 0.55)
158
+ const a = Math.min(inA, outA)
159
+ if (a <= 0) return
160
+ const s = Math.min(w, h)
161
+ const size = s * (portrait ? 0.085 : 0.072)
162
+ const x = portrait ? w * 0.5 : w * 0.78
163
+ const y = portrait ? h * 0.72 : h * 0.72
164
+ g.save()
165
+ g.globalAlpha = a
166
+ g.font = `400 ${size}px ${FONT.brush}`
167
+ g.textAlign = 'center'
168
+ g.textBaseline = 'middle'
169
+ g.shadowColor = 'rgba(0,0,0,0.58)'
170
+ g.shadowBlur = 18 * u
171
+ g.shadowOffsetY = 2 * u
172
+ g.fillStyle = GOLD
173
+ g.fillText('奥德彪', x, y - (1 - ease.outCubic(inA)) * size * 0.18)
174
+ const textW = g.measureText('奥德彪').width
175
+ rule(g, x - textW * 0.5, y + size * 0.66, textW, a, GOLD, Math.max(1, u * 1.15))
176
+ g.restore()
177
+ }
178
+
179
  export function videoRect(w: number, h: number): Rect {
180
  if (w >= h) return { x: 0, y: 0, w, h }
181
  const vh = (w * 9) / 16
 
198
  g.fillStyle = shade
199
  g.fillRect(0, portrait ? h * 0.52 : h * 0.54, w, h * 0.48)
200
 
201
+ // 顶部不再放角标或章节标注,让原片画面保持完整留白。
202
  const bottom = drawEditorialSubtitle(g, w, h, f, t, portrait, u)
203
  drawEnglishAfterglow(g, w, h, f, t, bottom, portrait, u)
204
+ drawSignature(g, w, h, f, t, portrait, u)
205
 
206
  // 淡入淡出仍然由同一条时间线控制,导出与播放保持一致。
207
  const fin = smooth(t / 0.8)