use crate::mark::Mark;
use crate::visual::color::SingleColor;
#[derive(Clone, Debug)]
pub struct MarkArea {
pub(crate) color: SingleColor,
pub(crate) opacity: f64,
pub(crate) stroke: SingleColor,
pub(crate) stroke_width: f64,
pub(crate) dash: Vec<f64>,
}
impl MarkArea {
pub(crate) fn new() -> Self {
Self {
color: SingleColor::new("gray"),
opacity: 1.0,
stroke: SingleColor::new("none"),
stroke_width: 1.0,
dash: vec![],
}
}
pub fn with_color(mut self, color: impl Into<SingleColor>) -> Self {
self.color = color.into();
self
}
pub fn with_opacity(mut self, opacity: f64) -> Self {
self.opacity = opacity.clamp(0.0, 1.0);
self
}
pub fn with_stroke(mut self, stroke: impl Into<SingleColor>) -> Self {
self.stroke = stroke.into();
self
}
pub fn with_stroke_width(mut self, width: f64) -> Self {
self.stroke_width = width;
self
}
pub fn with_dash(mut self, dash: impl Into<Vec<f64>>) -> Self {
self.dash = dash.into();
self
}
}
impl Default for MarkArea {
fn default() -> Self {
Self::new()
}
}
impl Mark for MarkArea {
fn mark_type(&self) -> &'static str {
"area"
}
}