use crate::mesh::{Mesh, Meshable};
#[deprecated(
since = "0.13.0",
note = "please use the `RegularPolygon` primitive in `bevy_math` instead"
)]
#[derive(Debug, Copy, Clone)]
pub struct RegularPolygon {
pub radius: f32,
pub sides: usize,
}
impl Default for RegularPolygon {
fn default() -> Self {
Self {
radius: 0.5,
sides: 6,
}
}
}
impl RegularPolygon {
pub fn new(radius: f32, sides: usize) -> Self {
Self { radius, sides }
}
}
impl From<RegularPolygon> for Mesh {
fn from(polygon: RegularPolygon) -> Self {
bevy_math::primitives::RegularPolygon::new(polygon.radius, polygon.sides).mesh()
}
}
#[deprecated(
since = "0.13.0",
note = "please use the `Circle` primitive in `bevy_math` instead"
)]
#[derive(Debug, Copy, Clone)]
pub struct Circle {
pub radius: f32,
pub vertices: usize,
}
impl Default for Circle {
fn default() -> Self {
Self {
radius: 0.5,
vertices: 64,
}
}
}
impl Circle {
pub fn new(radius: f32) -> Self {
Self {
radius,
..Default::default()
}
}
}
impl From<Circle> for RegularPolygon {
fn from(circle: Circle) -> Self {
Self {
radius: circle.radius,
sides: circle.vertices,
}
}
}
impl From<Circle> for Mesh {
fn from(circle: Circle) -> Self {
Mesh::from(RegularPolygon::from(circle))
}
}