Giter Site home page Giter Site logo

bevy_prototype_lyon's Introduction

Bevy + Lyon = ❤

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

How does it work?

Currently Bevy does not support drawing custom shapes in an easy way. This crate uses Bevy's SpriteComponents bundle and replaces its default quad mesh with a custom mesh.

Here the lyon crate is used to generate that custom mesh.

Usage

Add the following line in your cargo.toml manifest file, under the [dependencies] section:

bevy_prototype_lyon = "0.1.1"

Then, you can start by drawing simple shapes:

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

fn main() {
    App::build()
        .add_default_plugins()
        .add_startup_system(setup.system())
        .run();
}

fn setup(
    mut commands: Commands,
    mut materials: ResMut<Assets<ColorMaterial>>,
    mut meshes: ResMut<Assets<Mesh>>,
) {
    let material = materials.add(Color::rgb(0.8, 0.0, 0.0).into());

    commands
        .spawn(Camera2dComponents::default())
        .spawn(primitive(
            material,
            &mut meshes,
            ShapeType::Circle(60.0),
            TessellationMode::Fill(&FillOptions::default())
            Vec3::new(0.0, 0.0, 0.0).into(),
        ));
}

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

bevy_prototype_lyon's People

Contributors

nilirad avatar loriopatrick avatar will-hart avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.