implamented Aroll cuter

This commit is contained in:
2026-02-25 23:27:31 -08:00
parent 2233d08fb5
commit 0a88623264
13 changed files with 277 additions and 4 deletions

45
transcode/timeline.go Normal file
View File

@@ -0,0 +1,45 @@
package transcode
// HandlerZoom holds the current scroll center for timeline zoom calculations.
type HandlerZoom struct {
Center float64 // center of the visible window in seconds
}
// ZoomResult is the result of a TimelineZoom calculation.
type ZoomResult struct {
Type string `json:"type"`
Percent float64 `json:"percent"`
ViewStart float64 `json:"viewStart"`
ViewEnd float64 `json:"viewEnd"`
}
// TimelineZoom computes the visible time window for the given zoomPercentage
// (1100, where 100 = full duration visible) centered on h.Center.
func (h *HandlerZoom) TimelineZoom(zoomPercentage, duration float64) *ZoomResult {
visibleDuration := duration * (zoomPercentage / 100)
half := visibleDuration / 2
viewStart := h.Center - half
viewEnd := h.Center + half
// Clamp to [0, duration], shifting the window rather than just truncating
// so the visible span stays the same size when near the edges.
if viewStart < 0 {
viewEnd -= viewStart
viewStart = 0
}
if viewEnd > duration {
viewStart -= viewEnd - duration
viewEnd = duration
}
if viewStart < 0 {
viewStart = 0
}
return &ZoomResult{
Type: "zoom",
Percent: zoomPercentage,
ViewStart: viewStart,
ViewEnd: viewEnd,
}
}