mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
11 lines
261 B
Rust
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;
|
|
} |