bevyuiexact_image

crates.io MIT/Apache 2.0 crates.io

image image image

#

Usage

Add the dependency to your bevy project:

cargo add bevy_ui_exact_image

Then to draw a sized image within a Bevy UI node:

```rust use bevy::prelude::; use bevy_ui_exact_image::prelude::;

fn spawnexample(mut commands: Commands, assets: Res) { commands.spawn(Camera2dBundle::default()); commands.spawn((ExactImageBundle { image: ExactImage { texture: assets.load("orientation.png"), // exact images have their own color, independent from the background color. color: Color::WHITE, // force the UI to display the texture at 300 x 200 size size: ExactSize::Exactly(Vec2::new(300., 200.)), // align the image to the bottom edge of the node, in the center. alignment: ImageAlignment::BottomCenter, // use Some(rads) to set rotation rotation: None, }, style: Style { size: Size::new(Val::Px(400.0), Val::Px(400.0)), ..Default::default() }, /// give the containing node a red color backgroundcolor: BackgroundColor(Color::RED), ..Default::default() },)); }

fn main() { App::new() .addplugins(DefaultPlugins.set(ImagePlugin::defaultnearest())) .addplugin(ExactImagePlugin) .addstartupsystem(spawnexample) .run(); } ```

Result:

image

#

Examples

cargo --run --example minimal cargo --run --example rotation cargo --run --example size cargo --run --example alignment

Limitations

Notes