Skip to main content

slice

Function slice 

Source
pub fn slice(clip: &mut Clip, start_s: f64, end_s: f64, fps: f64)
Expand description

Keep only the keys inside [start, end] seconds (with a half-frame epsilon at fps absorbing float drift from earlier retimings) and retime them so the window starts at 0. Cubic tangent triplets move with their keys. The clip duration becomes end - start.

Boundary keys are snapped to the window, not carried past it: keys within the epsilon of start clamp to 0 and keys within it of end clamp to the new duration. When several keys land on a boundary, the one closest to the original boundary is kept and the rest dropped — so the output has at most one key at 0 and one at the end, stays time-monotonic, and round-trips its declared duration.

§Panics

Panics if a hand-built track violates the loader invariant that values contains one value per key for linear/step tracks, or one tangent-value-tangent triplet per key for cubic-spline tracks.