Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ickshonpe/bevy_ui_style_builder
https://github.com/ickshonpe/bevy_ui_style_builder
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ickshonpe/bevy_ui_style_builder
- Owner: ickshonpe
- License: mit
- Created: 2023-02-09T15:07:47.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-02-09T17:37:12.000Z (almost 2 years ago)
- Last Synced: 2024-03-15T12:27:10.873Z (10 months ago)
- Language: Rust
- Size: 368 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bevy_ui_style_builder
[![crates.io](https://img.shields.io/crates/v/bevy_ui_style_builder)](https://crates.io/crates/bevy_ui_style_builder)
[![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](https://github.com/ickshonpe/bevy_ui_style_builder)
[![crates.io](https://img.shields.io/crates/d/bevy_ui_style_builder)](https://crates.io/crates/bevy_ui_style_builder)Experimental Bevy UI helper extension methods.
Supports Bevy 0.9
# Usage
Add the dependency to your project:
```
cargo add bevy_ui_style_builder
```Then the following example draws a red rectangle in the middle of the window:
```rust
use bevy::prelude::*;
use bevy_ui_style_builder::prelude::*;fn spawn_example(
mut commands: Commands,
) {
commands.spawn(Camera2dBundle::default());
commands.spawn(
node()
.width(Val::Percent(100.0))
.height(Val::Percent(100.0))
.justify_content_center()
.align_items_center()
).with_children(|builder| {
builder.spawn(
node()
.width(Val::Px(150.0))
.height(Val::Px(100.0))
.background_color(Color::RED)
);
});
}fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_startup_system(spawn_example)
.run();
}
```There is a larger example based on Bevy's UI example in the examples folder.
You can run it with:```
cargo run --example ui
```