use rootvg_core::color::PackedSrgb;
use crate::fill::FillStyle;
#[derive(Debug, Clone)]
pub struct Stroke<'a> {
pub style: FillStyle,
pub width: f32,
pub line_cap: LineCap,
pub line_join: LineJoin,
pub line_dash: LineDash<'a>,
}
impl<'a> Stroke<'a> {
pub fn with_color(self, color: PackedSrgb) -> Self {
Stroke {
style: FillStyle::Solid(color),
..self
}
}
pub fn with_width(self, width: f32) -> Self {
Stroke { width, ..self }
}
pub fn with_line_cap(self, line_cap: LineCap) -> Self {
Stroke { line_cap, ..self }
}
pub fn with_line_join(self, line_join: LineJoin) -> Self {
Stroke { line_join, ..self }
}
}
impl<'a> Default for Stroke<'a> {
fn default() -> Self {
Stroke {
style: FillStyle::Solid(PackedSrgb([0.0, 0.0, 0.0, 1.0])),
width: 1.0,
line_cap: LineCap::default(),
line_join: LineJoin::default(),
line_dash: LineDash::default(),
}
}
}
#[derive(Debug, Clone, Copy, Default)]
pub enum LineCap {
#[default]
Butt,
Square,
Round,
}
#[derive(Debug, Clone, Copy, Default)]
pub enum LineJoin {
#[default]
Miter,
Round,
Bevel,
}
#[derive(Debug, Clone, Copy, Default)]
pub struct LineDash<'a> {
pub segments: &'a [f32],
pub offset: usize,
}