use kurbo::Stroke;
#[derive(Copy, Clone, Default, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[repr(u8)]
pub enum Fill {
#[default]
NonZero = 0,
EvenOdd = 1,
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Style {
Fill(Fill),
Stroke(Stroke),
}
impl From<Fill> for Style {
fn from(fill: Fill) -> Self {
Self::Fill(fill)
}
}
impl From<Stroke> for Style {
fn from(stroke: Stroke) -> Self {
Self::Stroke(stroke)
}
}
#[derive(Debug, Copy, Clone)]
pub enum StyleRef<'a> {
Fill(Fill),
Stroke(&'a Stroke),
}
impl StyleRef<'_> {
#[must_use]
pub fn to_owned(&self) -> Style {
match self {
Self::Fill(fill) => Style::Fill(*fill),
Self::Stroke(stroke) => Style::Stroke((*stroke).clone()),
}
}
}
impl From<Fill> for StyleRef<'_> {
fn from(fill: Fill) -> Self {
Self::Fill(fill)
}
}
impl<'a> From<&'a Stroke> for StyleRef<'a> {
fn from(stroke: &'a Stroke) -> Self {
Self::Stroke(stroke)
}
}
impl<'a> From<&'a Style> for StyleRef<'a> {
fn from(draw: &'a Style) -> Self {
match draw {
Style::Fill(fill) => Self::Fill(*fill),
Style::Stroke(stroke) => Self::Stroke(stroke),
}
}
}