#bevy #shapes #graphics #gamedev #game-engine #game

bevy_prototype_lyon

Draw 2D shapes and paths in the Bevy game engine

18 releases (10 breaking)

0.11.0 Feb 19, 2024
0.10.0 Nov 6, 2023
0.9.0 Jul 10, 2023
0.8.0 Mar 7, 2023
0.1.3 Nov 4, 2020

#29 in Game dev

Download history 1047/week @ 2023-12-23 513/week @ 2023-12-30 1301/week @ 2024-01-06 1313/week @ 2024-01-13 1107/week @ 2024-01-20 1059/week @ 2024-01-27 782/week @ 2024-02-03 893/week @ 2024-02-10 1543/week @ 2024-02-17 1045/week @ 2024-02-24 1273/week @ 2024-03-02 1349/week @ 2024-03-09 1318/week @ 2024-03-16 1399/week @ 2024-03-23 1564/week @ 2024-03-30 879/week @ 2024-04-06

5,259 downloads per month
Used in 29 crates (26 directly)

MIT/Apache

165KB
779 lines

Bevy + Lyon = ❤

Crates.io Crates.io Downloads GitHub Repo stars CI Bevy tracking

bevy_prototype_lyon enables Bevy users to draw 2D shapes and paths, like triangles, circles, rectangles, lines, arcs and beziers.

Try out the live demo! Regular polygon demo

How does it work?

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.

Usage

Add bevy_prototype_lyon to your cargo project:

cargo add bevy_prototype_lyon

Then, you can start by drawing simple shapes:

use bevy::prelude::*;
use bevy_prototype_lyon::prelude::*;

fn main() {
    App::new()
        .insert_resource(Msaa::Sample4)
        .add_plugins(DefaultPlugins)
        .add_plugins(ShapePlugin)
        .add_systems(Startup, setup_system)
        .run();
}

fn setup_system(mut commands: Commands) {
    let shape = shapes::RegularPolygon {
        sides: 6,
        feature: shapes::RegularPolygonFeature::Radius(200.0),
        ..shapes::RegularPolygon::default()
    };

    commands.spawn(Camera2dBundle::default());
    commands.spawn((
        ShapeBundle {
            path: GeometryBuilder::build_as(&shape),
            ..default()
        },
        Fill::color(Color::CYAN),
        Stroke::new(Color::BLACK, 10.0),
    ));
}

Don't forget to check out the examples to learn more!

Bevy versions supported

I strive to support the latest version of Bevy. Support for a version of Bevy is dropped as soon as a new one is released.

The following table shows the latest version of bevy_prototype_lyon that supports a certain version of Bevy.

bevy bevy_prototype_lyon license
0.13 0.11 MIT/Apache 2.0
0.12 0.10 MIT/Apache 2.0
0.11 0.9 MIT/Apache 2.0
0.10 0.8 MIT/Apache 2.0
0.9 0.7 MIT/Apache 2.0
0.8 0.6 MIT/Apache 2.0
0.7 0.5 MIT/Apache 2.0
0.6 0.4 MIT/Apache 2.0
0.5 0.3 MIT
0.4 0.2 MIT

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~42–82MB
~1.5M SLoC