#[derive(Clone, Copy, Debug, PartialEq, Eq)] #[derive(Default)]
pub enum PointShape {
#[default]
Circle = 0,
Square = 1,
Triangle = 2,
Star = 3,
Diamond = 4,
Pentagon = 5,
Hexagon = 6,
Octagon = 7,
}
impl PointShape {
pub fn gpu_id(&self) -> u32 {
*self as u32
}
pub(crate) const LEGEND_SHAPES: &'static [PointShape] = &[
PointShape::Circle,
PointShape::Square,
PointShape::Triangle,
PointShape::Star,
PointShape::Diamond,
PointShape::Pentagon,
PointShape::Hexagon,
PointShape::Octagon,
];
}
impl From<&str> for PointShape {
fn from(s: &str) -> Self {
match s.to_lowercase().as_str() {
"circle" => PointShape::Circle,
"square" => PointShape::Square,
"triangle" => PointShape::Triangle,
"star" => PointShape::Star,
"diamond" => PointShape::Diamond,
"pentagon" => PointShape::Pentagon,
"hexagon" => PointShape::Hexagon,
"octagon" => PointShape::Octagon,
_ => PointShape::Circle, }
}
}
impl From<String> for PointShape {
fn from(s: String) -> Self {
PointShape::from(s.as_str())
}
}