Git Product home page Git Product logo

bevy_mod_ui_texture_atlas_image's Introduction

bevy_mod_ui_texture_atlas_image

crates.io MIT/Apache 2.0 crates.io

Draw images from texture atlases with the Bevy UI.

image

  • Versions 0.3 and 0.4 support Bevy 0.10
  • Version 0.2 supports Bevy 0.9
  • Version 0.1 supports Bevy 0.8

Details

To use this crate, add its dependency to your project's Cargo.toml:

bevy_mod_ui_texture_atlas_image = "0.3"

or with Cargo:

cargo add bevy_mod_ui_texture_atlas_image

Components

  • UiAtlasImage

    The texture atlas image of the node.

  • ImageTint

    The tint color of the image.

Bundles

  • AtlasImageBundle

    The bundle of components needed to display an image from a TextureAtlas with the Bevy UI.

Plugin

The UiAtlasImagePlugin plugin must be added to your Bevy App:

use bevy_mod_ui_texture_atlas_image::*;

fn main () {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugin(UiAtlasImagePlugin)
        // ..rest of app
        .run()
}

Then you can spawn an AtlasImageBundle to draw images from a TextureAtlas with the Bevy UI:

commands
    .spawn(AtlasImageBundle {
        atlas_image: UiAtlasImage { 
            atlas: texture_atlas_handle.clone(),
            index: 5
        },
        ..Default::default()
    });

The differences between an AtlasImageBundle and an ImageBundle are that

  • Instead of a UiImage component, AtlasImageBundle has a UiAtlasImage component that sets the image displayed by the node.
  • Instead of a BackgroundColor component, AtlasImageBundle has an ImageTint component that sets the color tint of the image.

Examples

  • Displaying a single image from a texture atlas:
    cargo --run --example minimal
    
  • Displaying three tiles from a texture atlas grid alongside the atlas's source image:
    cargo --run --example tiles
    
  • Displaying images from a texture atlas with an alpha channel.
    cargo --run --example alpha
    
  • Displaying images from a texture atlas with clipping.
    cargo --run --example clipped
    

bevy_mod_ui_texture_atlas_image's People

Contributors

ickshonpe avatar monamayrhofer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.