text overlay x & y pos as params

This commit is contained in:
Dmitry Sergeev
2026-09-15 19:16:15 +03:00
parent 38016f0d04
commit 72939c3be7
2 changed files with 27 additions and 5 deletions
+5 -3
View File
@@ -48,7 +48,7 @@ func LoadFace(path string, size float64) (font.Face, error) {
// NewTextOverlay rasterizes text (white, anti-aliased) onto a black backing
// box, centered horizontally. Box width and x are multiples of 6 so the box
// covers whole v210 blocks and the per-frame copy is word-aligned.
func NewTextOverlay(text string, frameW, frameH int, face font.Face) (*TextOverlay, error) {
func NewTextOverlay(text string, frameW, frameH, posX, posY int, face font.Face) (*TextOverlay, error) {
if text == "" {
return nil, fmt.Errorf("text: empty string")
}
@@ -89,10 +89,12 @@ func NewTextOverlay(text string, frameW, frameH int, face font.Face) (*TextOverl
return nil, fmt.Errorf("text: box %dpx does not fit frame height %dpx", topMargin+h, frameH)
}
// posX = ((frameW - w) / 2 / 6) * 6
// posY = topMargin
o := &TextOverlay{
frameW: frameW,
x: ((frameW - w) / 2 / 6) * 6,
y: topMargin,
x: posX,
y: posY,
w: w,
h: h,
cov: make([]byte, w*h),