pub enum CommonTool {
GenerateImage(GenerateImage),
}
impl Into<CommonTool> for GenerateImage {
fn into(self) -> CommonTool { CommonTool::GenerateImage(self) }
}
pub struct GenerateImage {
pub background: ImageBackground,
pub quality: ImageQuality,
pub size: Option<ImageSize>,
pub partial_images: u32,
}
impl Default for GenerateImage {
fn default() -> Self {
Self {
background: ImageBackground::default(),
quality: ImageQuality::default(),
size: None,
partial_images: 1,
}
}
}
impl GenerateImage {
pub fn with_size(self, width: u32, height: u32) -> Self {
Self {
size: Some(ImageSize { width, height }),
..self
}
}
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, strum::Display)]
pub enum ImageBackground {
#[default]
Auto,
Opaque,
Transparent,
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, strum::Display)]
pub enum ImageQuality {
#[default]
Auto,
Low,
Medium,
High,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ImageSize {
width: u32,
height: u32,
}
impl Default for ImageSize {
fn default() -> Self {
Self {
width: 1024,
height: 1024,
}
}
}
impl std::fmt::Display for ImageSize {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}x{}", self.width, self.height)
}
}