mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 06:30:19 +00:00
de004da8d5
# Objective The migration process for `bevy_color` (#12013) will be fairly involved: there will be hundreds of affected files, and a large number of APIs. ## Solution To allow us to proceed granularly, we're going to keep both `bevy_color::Color` (new) and `bevy_render::Color` (old) around until the migration is complete. However, simply doing this directly is confusing! They're both called `Color`, making it very hard to tell when a portion of the code has been ported. As discussed in #12056, by renaming the old `Color` type, we can make it easier to gradually migrate over, one API at a time. ## Migration Guide THIS MIGRATION GUIDE INTENTIONALLY LEFT BLANK. This change should not be shipped to end users: delete this section in the final migration guide! --------- Co-authored-by: Alice Cecile <alice.i.cecil@gmail.com>
41 lines
1.2 KiB
Rust
41 lines
1.2 KiB
Rust
//! Demonstrates how to use transparency in 2D.
|
|
//! Shows 3 bevy logos on top of each other, each with a different amount of transparency.
|
|
|
|
use bevy::prelude::*;
|
|
|
|
fn main() {
|
|
App::new()
|
|
.add_plugins(DefaultPlugins)
|
|
.add_systems(Startup, setup)
|
|
.run();
|
|
}
|
|
|
|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|
commands.spawn(Camera2dBundle::default());
|
|
|
|
let sprite_handle = asset_server.load("branding/icon.png");
|
|
|
|
commands.spawn(SpriteBundle {
|
|
texture: sprite_handle.clone(),
|
|
..default()
|
|
});
|
|
commands.spawn(SpriteBundle {
|
|
sprite: Sprite {
|
|
// Alpha channel of the color controls transparency.
|
|
color: LegacyColor::rgba(0.0, 0.0, 1.0, 0.7),
|
|
..default()
|
|
},
|
|
texture: sprite_handle.clone(),
|
|
transform: Transform::from_xyz(100.0, 0.0, 0.0),
|
|
..default()
|
|
});
|
|
commands.spawn(SpriteBundle {
|
|
sprite: Sprite {
|
|
color: LegacyColor::rgba(0.0, 1.0, 0.0, 0.3),
|
|
..default()
|
|
},
|
|
texture: sprite_handle,
|
|
transform: Transform::from_xyz(200.0, 0.0, 0.0),
|
|
..default()
|
|
});
|
|
}
|