Repository navigation
Expand file tree
/
Copy pathinline_image.rs
More file actions
54 lines (51 loc) · 1.61 KB
/
Copy pathinline_image.rs
File metadata and controls
54 lines (51 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! Demonstrates how to display images inline with text.
use bevy::prelude::*;
fn main() {
let mut app = App::new();
app.add_plugins(DefaultPlugins).add_systems(Startup, setup);
app.run();
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn(Camera2d);
commands.spawn((
Text::new("[Text]"),
TextFont::from_font_size(px(40.)),
Node {
margin: px(25).all(),
justify_self: JustifySelf::Center,
align_self: AlignSelf::Center,
..default()
},
BackgroundColor(bevy::color::palettes::css::MAROON.into()),
Outline {
width: px(2),
..default()
},
children![
(
TextSpan::new("[span before image]"),
TextFont::from_font_size(px(40)),
),
(InlineImage {
color: bevy::color::palettes::css::RED.into(),
image: asset_server.load("branding/bevy_logo_dark.png"),
height: Some(30.),
..default()
},),
(
TextSpan::new("[span between images]"),
TextFont::from_font_size(px(40.)),
),
(InlineImage {
color: bevy::color::palettes::css::YELLOW.into(),
image: asset_server.load("branding/bevy_bird_dark.png"),
width: Some(30.),
..default()
},),
(
TextSpan::new("[span after image]"),
TextFont::from_font_size(px(40.)),
),
],
));
}