Files
BoilR/src/ui/images/image_resize.rs
T
Philip KristoffersenandGitHub 7a5c88c61e Move image render functions into pages (#291)
Move image page renderes into seperate files
2022-12-29 09:36:36 +01:00

11 lines
261 B
Rust

pub fn clamp_to_width(size: &mut egui::Vec2, max_width: f32) {
let mut x = size.x;
let mut y = size.y;
if size.x > max_width {
let ratio = size.y / size.x;
x = max_width;
y = x * ratio;
}
size.x = x;
size.y = y;
}