#[derive(Debug, Clone)]
pub struct OfdPageGraphicsConfiguration {
pub dpi_x: u32,
pub dpi_y: u32,
pub color_depth: u32,
}
impl OfdPageGraphicsConfiguration {
#[must_use]
pub fn new() -> Self {
Self {
dpi_x: 96,
dpi_y: 96,
color_depth: 24,
}
}
#[must_use]
pub fn dpi(mut self, dpi: u32) -> Self {
self.dpi_x = dpi;
self.dpi_y = dpi;
self
}
#[must_use]
pub fn dpi_x(mut self, dpi: u32) -> Self {
self.dpi_x = dpi;
self
}
#[must_use]
pub fn dpi_y(mut self, dpi: u32) -> Self {
self.dpi_y = dpi;
self
}
#[must_use]
pub fn color_depth(mut self, depth: u32) -> Self {
self.color_depth = depth;
self
}
}
impl Default for OfdPageGraphicsConfiguration {
fn default() -> Self {
Self::new()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_new_defaults() {
let c = OfdPageGraphicsConfiguration::new();
assert_eq!(c.dpi_x, 96);
assert_eq!(c.dpi_y, 96);
assert_eq!(c.color_depth, 24);
}
#[test]
fn test_builder() {
let c = OfdPageGraphicsConfiguration::new().dpi(300).color_depth(32);
assert_eq!(c.dpi_x, 300);
assert_eq!(c.dpi_y, 300);
assert_eq!(c.color_depth, 32);
}
#[test]
fn test_separate_dpi() {
let c = OfdPageGraphicsConfiguration::new().dpi_x(150).dpi_y(200);
assert_eq!(c.dpi_x, 150);
assert_eq!(c.dpi_y, 200);
}
#[test]
fn test_default() {
let c = OfdPageGraphicsConfiguration::default();
assert_eq!(c.dpi_x, 96);
}
}