Skip to main content

aspect_fit_scale

Function aspect_fit_scale 

Source
pub fn aspect_fit_scale(
    surface_w: u32,
    surface_h: u32,
    video_w: u32,
    video_h: u32,
) -> Vec2
Expand description

Letterbox/pillarbox scale that fits a video_w × video_h source into a surface_w × surface_h viewport, expressed as a Vec2 for the wisp sprite’s transform scale.

The fully-covered axis returns 2.0 (the full NDC [-1, +1] range applied to a default unit-quad sprite); the bound axis returns the proportional fraction of 2.0.

Returns Vec2::splat(1.0) when any dimension is zero — guard for edge cases (window minimized, decoder reports a malformed stream) without risking NaN in the transform.