use crate::prelude::*;
use nalgebra::{Point2, Transform2};
#[derive(Default, Debug, Clone, PartialEq, Shape)]
pub struct Diamond {
#[local_transform]
pub local_transform: Transform2<f32>,
pub width: f32,
pub height_top: f32,
pub height_bottom: f32,
}
impl From<Diamond> for Curve {
fn from(
Diamond {
local_transform,
width,
height_top,
height_bottom,
}: Diamond,
) -> Self {
let right = Point2::new(width / 2.0, 0.);
let top = Point2::new(0., height_top);
let left = Point2::new(-width / 2.0, 0.);
let bottom = Point2::new(0., -height_bottom);
dessin!(Curve(
transform = local_transform,
then = right,
then = top,
then = left,
then = bottom,
closed,
))
}
}
impl From<Diamond> for Shape {
fn from(v: Diamond) -> Self {
Curve::from(v).into()
}
}