shared/types/
resolution.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use serde::{Deserialize, Serialize};

/// Represents the resolution of an image or a grid, defined by the number of pixels or cells along the x and y axes.
///
/// Attributes:
/// - `nx`: A `u16` representing the number of pixels or cells along the x-axis (width).
/// - `ny`: A `u16` representing the number of pixels or cells along the y-axis (height).
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct Resolution {
    pub nx: u16,
    pub ny: u16,
}

impl Resolution {
    /// Creates a new `Resolution` with the specified number of pixels along the x and y axes.
    ///
    /// # Arguments
    ///
    /// * `nx` - A `u16` representing the number of pixels along the x-axis (width).
    /// * `ny` - A `u16` representing the number of pixels along the y-axis (height).
    ///
    /// # Returns
    ///
    /// A new `Resolution` with the specified number of pixels along the x and y axes.
    pub fn new(nx: u16, ny: u16) -> Resolution {
        Resolution { nx, ny }
    }
}