use bevy::render::color::Color;
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.as_linear_rgba_f32(),
}
}
}
impl StrokeVertexConstructor<Vertex> for VertexConstructor {
fn new_vertex(&mut self, vertex: StrokeVertex) -> Vertex {
Vertex {
position: [vertex.position().x, vertex.position().y],
color: self.color.as_linear_rgba_f32(),
}
}
}