split into two crates
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
//! Tape generation for [primitive shapes](bevy_shape).
|
||||
//!
|
||||
//! Primitives that support taping implement the [`Tapeable`] trait.
|
||||
//! Calling [`tape`](Tapeable::tape) will return either a [`Tape`] or a builder
|
||||
//! that can be used to specify shape-specific configuration for creating the
|
||||
//! [`Tape`].
|
||||
//!
|
||||
//! ```
|
||||
//! # use bevy_asset::Assets;
|
||||
//! # use bevy_ecs::prelude::ResMut;
|
||||
//! # use bevy_shape::Circle;
|
||||
//! # use bevy_tape_load::*;
|
||||
//! #
|
||||
//! # fn setup(mut tapes: ResMut<Assets<Tape>>) {
|
||||
//! // Create circle tape with default configuration
|
||||
//! let circle = tapes.add(Circle { radius: 25.0 });
|
||||
//!
|
||||
//! // Specify number of vertices
|
||||
//! let circle = tapes.add(Circle { radius: 25.0 }.tape().resolution(64));
|
||||
//! # }
|
||||
//! ```
|
||||
|
||||
pub mod sphere;
|
||||
|
||||
use super::Tape;
|
||||
|
||||
/// A trait for shapes that can be turned into a [`Tape`].
|
||||
pub trait Tapeable {
|
||||
/// The output of [`Self::tape`]. This will be a [`TapeBuilder`] used for
|
||||
/// creating a [`Tape`].
|
||||
type Output: TapeBuilder;
|
||||
|
||||
/// Creates a [`Tape`] for a shape.
|
||||
fn tape(&self) -> Self::Output;
|
||||
}
|
||||
|
||||
/// A trait used to build [`Tape`]s from a configuration
|
||||
pub trait TapeBuilder {
|
||||
/// Builds a [`Tape`] based on the configuration in `self`.
|
||||
fn build(&self) -> Tape;
|
||||
}
|
||||
|
||||
impl<T: TapeBuilder> From<T> for Tape {
|
||||
fn from(builder: T) -> Self {
|
||||
builder.build()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user