Skip to main content

fit_contain

Function fit_contain 

Source
pub fn fit_contain(
    src_w: u32,
    src_h: u32,
    box_w: u32,
    box_h: u32,
) -> (u32, u32, u32, u32)
Expand description

元 src_w × src_h を縦横比を保って box_w × box_h に収める。 戻り値は箱内の (x, y, w, h)(中央寄せ。余白は呼び出し側が黒で塗る)。