diff options
Diffstat (limited to 'src/utils/mod.rs')
| -rw-r--r-- | src/utils/mod.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 7d41b923..2fd1d8f8 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -90,6 +90,11 @@ pub fn center_f64(rect: Rectangle<f64, Logical>) -> Point<f64, Logical> { rect.loc + rect.size.downscale(2.0).to_point() } +/// Convert logical pixels to physical, rounding to physical pixels. +pub fn apply_scale(scale: f64, val: i32) -> i32 { + (f64::from(val) * scale).round() as i32 +} + pub fn output_size(output: &Output) -> Size<i32, Logical> { let output_scale = output.current_scale().integer_scale(); let output_transform = output.current_transform(); |
