#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum Rotation {
Clockwise90,
Clockwise180,
Clockwise270,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Layer {
Background,
Foreground,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Position {
Center,
TopLeft(f32, f32),
TopRight(f32, f32),
BottomLeft(f32, f32),
BottomRight(f32, f32),
Exact(f32, f32),
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct WatermarkOptions {
#[allow(dead_code)]
pub(crate) position: Position,
pub(crate) rotation_degrees: f32,
pub(crate) opacity: f32,
pub(crate) layer: Layer,
pub(crate) font_size: f32,
pub(crate) color_rgb: (f32, f32, f32),
}
impl Default for WatermarkOptions {
fn default() -> Self {
Self {
position: Position::Center,
rotation_degrees: 0.0,
opacity: 0.5,
layer: Layer::Foreground,
font_size: 48.0,
color_rgb: (0.6, 0.6, 0.6),
}
}
}
impl WatermarkOptions {
pub fn centered() -> Self {
Self::default()
}
pub fn rotated(mut self, degrees: f32) -> Self {
self.rotation_degrees = degrees;
self
}
pub fn opacity(mut self, alpha: f32) -> Self {
self.opacity = alpha;
self
}
pub fn layer(mut self, layer: Layer) -> Self {
self.layer = layer;
self
}
pub fn font_size(mut self, pt: f32) -> Self {
self.font_size = pt;
self
}
pub fn color(mut self, r: f32, g: f32, b: f32) -> Self {
self.color_rgb = (r, g, b);
self
}
}