use crate::{Error, Result};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct FrameSize {
pub width: usize,
pub height: usize,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct CellSize {
pub width: usize,
pub height: usize,
}
impl CellSize {
pub fn new(width: usize, height: usize) -> Result<Self> {
if width == 0 || height == 0 {
return Err(Error::InvalidCellSize);
}
Ok(Self { width, height })
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ResizeMode {
None,
Fit,
Fill,
Stretch,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct RenderOptions {
pub width: usize,
pub height: usize,
pub resize: ResizeMode,
pub cell: CellSize,
pub background: [u8; 3],
}
impl RenderOptions {
pub fn new(width: usize, height: usize) -> Result<Self> {
if width == 0 || height == 0 {
return Err(Error::InvalidTargetSize);
}
Ok(Self {
width,
height,
resize: ResizeMode::Fit,
cell: CellSize::new(1, 2)?,
background: [0, 0, 0],
})
}
}