gemini_engine/primitives/
polygon.rsuse super::Triangle;
use crate::core::{CanDraw, ColChar, Vec2D};
pub struct Polygon {
    pub vertices: Vec<Vec2D>,
    pub fill_char: ColChar,
}
impl Polygon {
    #[must_use]
    pub fn new(vertices: &[Vec2D], fill_char: ColChar) -> Self {
        Self {
            vertices: vertices.to_vec(),
            fill_char,
        }
    }
}
impl CanDraw for Polygon {
    fn draw_to(&self, canvas: &mut impl crate::core::Canvas) {
        super::triangulate(&self.vertices)
            .into_iter()
            .map(|corners| Triangle::with_array(corners, self.fill_char))
            .for_each(|t| t.draw_to(canvas));
    }
}