use bevy::color::{Color, ColorToComponents};
use lyon_tessellation::{
self as tess, FillVertex, FillVertexConstructor, StrokeVertex, StrokeVertexConstructor,
};
type IndexType = u32;
pub type VertexBuffers = tess::VertexBuffers<Vertex, IndexType>;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Vertex {
pub position: [f32; 2],
pub color: [f32; 4],
}
pub struct VertexConstructor {
pub color: Color,
}
impl FillVertexConstructor<Vertex> for VertexConstructor {
fn new_vertex(&mut self, vertex: FillVertex) -> Vertex {
Vertex {
position: [vertex.position().x, vertex.position().y],
color: self.color.to_linear().to_f32_array(),
}
}
}
impl StrokeVertexConstructor<Vertex> for VertexConstructor {
fn new_vertex(&mut self, vertex: StrokeVertex) -> Vertex {
Vertex {
position: [vertex.position().x, vertex.position().y],
color: self.color.to_linear().to_f32_array(),
}
}
}