use super::{Color, Gradient};
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BackgroundOptions {
pub color: Color,
pub gradient: Option<Gradient>,
pub round: f64,
}
impl Default for BackgroundOptions {
fn default() -> Self {
Self {
color: Color::WHITE,
gradient: None,
round: 0.0,
}
}
}
impl BackgroundOptions {
pub fn new(color: Color) -> Self {
Self {
color,
..Default::default()
}
}
pub fn transparent() -> Self {
Self {
color: Color::TRANSPARENT,
gradient: None,
round: 0.0,
}
}
pub fn with_color(mut self, color: Color) -> Self {
self.color = color;
self
}
pub fn with_gradient(mut self, gradient: Gradient) -> Self {
self.gradient = Some(gradient);
self
}
pub fn with_round(mut self, round: f64) -> Self {
self.round = round.clamp(0.0, 0.5);
self
}
}