use crate::mark::Mark;
use crate::visual::color::SingleColor;
#[derive(Clone)]
pub struct MarkTick {
pub(crate) color: SingleColor,
pub(crate) stroke: SingleColor,
pub(crate) thickness: f64,
pub(crate) band_size: f64,
pub(crate) opacity: f64,
}
impl MarkTick {
pub(crate) fn new() -> Self {
Self {
color: SingleColor::new("black"),
stroke: SingleColor::new("none"),
thickness: 1.0,
band_size: 7.0,
opacity: 1.0,
}
}
pub fn with_color(mut self, color: impl Into<SingleColor>) -> Self {
self.color = color.into();
self
}
pub fn with_stroke(mut self, stroke: impl Into<SingleColor>) -> Self {
self.stroke = stroke.into();
self
}
pub fn with_thickness(mut self, thickness: f64) -> Self {
self.thickness = thickness.max(0.0);
self
}
pub fn with_band_size(mut self, band_size: f64) -> Self {
self.band_size = band_size.max(0.0);
self
}
pub fn with_opacity(mut self, opacity: f64) -> Self {
self.opacity = opacity.clamp(0.0, 1.0);
self
}
}
impl Default for MarkTick {
fn default() -> Self {
Self::new()
}
}
impl Mark for MarkTick {
fn mark_type(&self) -> &'static str {
"tick"
}
}