Use f32 for scale_factor

This commit is contained in:
Héctor Ramón Jiménez 2025-09-02 23:29:22 +02:00
parent ad0e4c53cf
commit 74b792b608
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
14 changed files with 56 additions and 51 deletions

View file

@ -5,19 +5,19 @@ use crate::core::{Size, Transformation};
pub struct Viewport {
physical_size: Size<u32>,
logical_size: Size<f32>,
scale_factor: f64,
scale_factor: f32,
projection: Transformation,
}
impl Viewport {
/// Creates a new [`Viewport`] with the given physical dimensions and scale
/// factor.
pub fn with_physical_size(size: Size<u32>, scale_factor: f64) -> Viewport {
pub fn with_physical_size(size: Size<u32>, scale_factor: f32) -> Viewport {
Viewport {
physical_size: size,
logical_size: Size::new(
(size.width as f64 / scale_factor) as f32,
(size.height as f64 / scale_factor) as f32,
size.width as f32 / scale_factor,
size.height as f32 / scale_factor,
),
scale_factor,
projection: Transformation::orthographic(size.width, size.height),
@ -45,7 +45,7 @@ impl Viewport {
}
/// Returns the scale factor of the [`Viewport`].
pub fn scale_factor(&self) -> f64 {
pub fn scale_factor(&self) -> f32 {
self.scale_factor
}