gupaxx/src/free.rs
2023-10-22 17:14:02 -04:00

17 lines
No EOL
527 B
Rust

// Free functions.
//---------------------------------------------------------------------------------------------------- Use
use crate::constants::*;
//----------------------------------------------------------------------------------------------------
#[inline]
// Clamp the scaling resolution `f32` to a known good `f32`.
pub fn clamp_scale(scale: f32) -> f32 {
// Make sure it is finite.
if !scale.is_finite() {
return APP_DEFAULT_SCALE;
}
// Clamp between valid range.
scale.clamp(APP_MIN_SCALE, APP_MAX_SCALE)
}