use crate::mark::Mark;
use crate::visual::color::SingleColor;
#[derive(Debug, Clone)]
pub struct MarkBar {
pub(crate) color: SingleColor,
pub(crate) opacity: f64,
pub(crate) stroke: Option<SingleColor>,
pub(crate) stroke_width: Option<f64>,
pub(crate) width: Option<f64>,
pub(crate) spacing: Option<f64>,
pub(crate) span: Option<f64>,
}
impl MarkBar {
pub(crate) fn new() -> Self {
Self {
color: SingleColor::new("steelblue"),
opacity: 1.0,
stroke: None,
stroke_width: None,
width: None, spacing: None, span: None, }
}
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 = Some(stroke.into());
self
}
pub fn with_stroke_width(mut self, width: f64) -> Self {
self.stroke_width = Some(width);
self
}
pub fn with_width(mut self, width: f64) -> Self {
self.width = Some(width.clamp(0.0, 1.0));
self
}
pub fn with_spacing(mut self, spacing: f64) -> Self {
self.spacing = Some(spacing.clamp(0.0, 1.0));
self
}
pub fn with_span(mut self, span: f64) -> Self {
self.span = Some(span.clamp(0.0, 1.0));
self
}
}
impl Default for MarkBar {
fn default() -> Self {
Self::new()
}
}
impl Mark for MarkBar {
fn mark_type(&self) -> &'static str {
"bar"
}
}