bevy_prototype_lyon enables Bevy users to draw 2D shapes and paths, like triangles, circles, rectangles, lines, arcs and beziers.
Currently Bevy does not support drawing custom shapes in an easy way. This crate uses a variation of Bevy's SpriteBundle with custom meshes to draw shapes. The lyon crate is used to generate those custom mesh.
- Complete API reworking
- Regular polygon support
- Extensible shape system through
Geometrytrait
- updated dependency to
lyon_tessellation v0.17 - with
lyon_tessellation v0.17, unfortunately rectangles with rounded borders are no longer supported. Quad,TriangleandPolylinehave been substituted by a general-purposePolygonshape.
Add the following line in your cargo.toml manifest file, under the [dependencies] section:
bevy_prototype_lyon = "0.2"Then, you can start by drawing simple shapes:
use bevy::prelude::*;
use bevy_prototype_lyon::prelude::*;
fn main() {
App::build()
.add_plugins(DefaultPlugins)
.add_plugin(ShapePlugin)
.add_startup_system(setup.system())
.run();
}
fn setup(commands: &mut Commands, mut materials: ResMut<Assets<ColorMaterial>>) {
let circle = shapes::Circle {
radius: 100.0,
..shapes::Circle::default()
};
commands
.spawn(Camera2dBundle::default())
.spawn(GeometryBuilder::build_as(
&circle,
materials.add(ColorMaterial::color(Color::AQUAMARINE)),
TessellationMode::Fill(FillOptions::default()),
Transform::default(),
));
}Don't forget to check out the examples to learn more!
