Skip to main content

fit_within

Function fit_within 

Source
pub fn fit_within(intrinsic: (u32, u32), max_w: u32, max_h: u32) -> (u32, u32)
Expand description

The pixel box an image fits into: as wide as max_w allows but never upscaled past the source’s own pixels, and as tall as that width makes it, capped at max_h (shrinking the width back to keep the aspect ratio).

In pixels on purpose: the terminal’s non-square cells and a GUI’s points are both a rounding step after this policy, so the frontends can share the sizing rule and differ only in the rounding.