Struct ImageNode

Source
pub struct ImageNode {
    pub color: Color,
    pub image: Handle<Image>,
    pub texture_atlas: Option<TextureAtlas>,
    pub flip_x: bool,
    pub flip_y: bool,
    pub rect: Option<Rect>,
    pub image_mode: NodeImageMode,
}
Expand description

A UI Node that renders an image.

Fields§

§color: Color

The tint color used to draw the image.

This is multiplied by the color of each pixel in the image. The field value defaults to solid white, which will pass the image through unmodified.

§image: Handle<Image>

Handle to the texture.

This defaults to a TRANSPARENT_IMAGE_HANDLE, which points to a fully transparent 1x1 texture.

§texture_atlas: Option<TextureAtlas>

The (optional) texture atlas used to render the image.

§flip_x: bool

Whether the image should be flipped along its x-axis.

§flip_y: bool

Whether the image should be flipped along its y-axis.

§rect: Option<Rect>

An optional rectangle representing the region of the image to render, instead of rendering the full image. This is an easy one-off alternative to using a TextureAtlas.

When used with a TextureAtlas, the rect is offset by the atlas’s minimal (top-left) corner position.

§image_mode: NodeImageMode

Controls how the image is altered to fit within the layout and how the layout algorithm determines the space to allocate for the image.

Implementations§

Source§

impl ImageNode

Source

pub fn new(texture: Handle<Image>) -> ImageNode

Create a new ImageNode with the given texture.

Examples found in repository?
examples/testbed/ui.rs (line 79)
76    pub fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
77        commands.spawn((Camera2d, StateScoped(super::Scene::Image)));
78        commands.spawn((
79            ImageNode::new(asset_server.load("branding/bevy_logo_dark.png")),
80            StateScoped(super::Scene::Image),
81        ));
82    }
83}
84
85mod text {
86    use bevy::prelude::*;
87
88    pub fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
89        commands.spawn((Camera2d, StateScoped(super::Scene::Text)));
90        commands.spawn((
91            Text::new("Hello World."),
92            TextFont {
93                font: asset_server.load("fonts/FiraSans-Bold.ttf"),
94                font_size: 200.,
95                ..default()
96            },
97            StateScoped(super::Scene::Text),
98        ));
99    }
100}
101
102mod grid {
103    use bevy::{color::palettes::css::*, prelude::*};
104
105    pub fn setup(mut commands: Commands) {
106        commands.spawn((Camera2d, StateScoped(super::Scene::Grid)));
107        // Top-level grid (app frame)
108        commands
109            .spawn((
110                Node {
111                    display: Display::Grid,
112                    width: Val::Percent(100.0),
113                    height: Val::Percent(100.0),
114                    grid_template_columns: vec![GridTrack::min_content(), GridTrack::flex(1.0)],
115                    grid_template_rows: vec![
116                        GridTrack::auto(),
117                        GridTrack::flex(1.0),
118                        GridTrack::px(40.),
119                    ],
120                    ..default()
121                },
122                BackgroundColor(Color::WHITE),
123                StateScoped(super::Scene::Grid),
124            ))
125            .with_children(|builder| {
126                // Header
127                builder.spawn((
128                    Node {
129                        display: Display::Grid,
130                        grid_column: GridPlacement::span(2),
131                        padding: UiRect::all(Val::Px(40.0)),
132                        ..default()
133                    },
134                    BackgroundColor(RED.into()),
135                ));
136
137                // Main content grid (auto placed in row 2, column 1)
138                builder
139                    .spawn((
140                        Node {
141                            height: Val::Percent(100.0),
142                            aspect_ratio: Some(1.0),
143                            display: Display::Grid,
144                            grid_template_columns: RepeatedGridTrack::flex(3, 1.0),
145                            grid_template_rows: RepeatedGridTrack::flex(2, 1.0),
146                            row_gap: Val::Px(12.0),
147                            column_gap: Val::Px(12.0),
148                            ..default()
149                        },
150                        BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
151                    ))
152                    .with_children(|builder| {
153                        builder.spawn((Node::default(), BackgroundColor(ORANGE.into())));
154                        builder.spawn((Node::default(), BackgroundColor(BISQUE.into())));
155                        builder.spawn((Node::default(), BackgroundColor(BLUE.into())));
156                        builder.spawn((Node::default(), BackgroundColor(CRIMSON.into())));
157                        builder.spawn((Node::default(), BackgroundColor(AQUA.into())));
158                    });
159
160                // Right side bar (auto placed in row 2, column 2)
161                builder.spawn((Node::DEFAULT, BackgroundColor(BLACK.into())));
162            });
163    }
164}
165
166mod borders {
167    use bevy::{color::palettes::css::*, prelude::*};
168
169    pub fn setup(mut commands: Commands) {
170        commands.spawn((Camera2d, StateScoped(super::Scene::Borders)));
171        let root = commands
172            .spawn((
173                Node {
174                    flex_wrap: FlexWrap::Wrap,
175                    ..default()
176                },
177                StateScoped(super::Scene::Borders),
178            ))
179            .id();
180
181        // all the different combinations of border edges
182        let borders = [
183            UiRect::default(),
184            UiRect::all(Val::Px(20.)),
185            UiRect::left(Val::Px(20.)),
186            UiRect::vertical(Val::Px(20.)),
187            UiRect {
188                left: Val::Px(40.),
189                top: Val::Px(20.),
190                ..Default::default()
191            },
192            UiRect {
193                right: Val::Px(20.),
194                bottom: Val::Px(30.),
195                ..Default::default()
196            },
197            UiRect {
198                right: Val::Px(20.),
199                top: Val::Px(40.),
200                bottom: Val::Px(20.),
201                ..Default::default()
202            },
203            UiRect {
204                left: Val::Px(20.),
205                top: Val::Px(20.),
206                bottom: Val::Px(20.),
207                ..Default::default()
208            },
209            UiRect {
210                left: Val::Px(20.),
211                right: Val::Px(20.),
212                bottom: Val::Px(40.),
213                ..Default::default()
214            },
215        ];
216
217        let non_zero = |x, y| x != Val::Px(0.) && y != Val::Px(0.);
218        let border_size = |x, y| if non_zero(x, y) { f32::MAX } else { 0. };
219
220        for border in borders {
221            for rounded in [true, false] {
222                let border_node = commands
223                    .spawn((
224                        Node {
225                            width: Val::Px(100.),
226                            height: Val::Px(100.),
227                            border,
228                            margin: UiRect::all(Val::Px(30.)),
229                            align_items: AlignItems::Center,
230                            justify_content: JustifyContent::Center,
231                            ..default()
232                        },
233                        BackgroundColor(MAROON.into()),
234                        BorderColor(RED.into()),
235                        Outline {
236                            width: Val::Px(10.),
237                            offset: Val::Px(10.),
238                            color: Color::WHITE,
239                        },
240                    ))
241                    .id();
242
243                if rounded {
244                    let border_radius = BorderRadius::px(
245                        border_size(border.left, border.top),
246                        border_size(border.right, border.top),
247                        border_size(border.right, border.bottom),
248                        border_size(border.left, border.bottom),
249                    );
250                    commands.entity(border_node).insert(border_radius);
251                }
252
253                commands.entity(root).add_child(border_node);
254            }
255        }
256    }
257}
258
259mod box_shadow {
260    use bevy::{color::palettes::css::*, prelude::*};
261
262    pub fn setup(mut commands: Commands) {
263        commands.spawn((Camera2d, StateScoped(super::Scene::BoxShadow)));
264
265        commands
266            .spawn((
267                Node {
268                    width: Val::Percent(100.0),
269                    height: Val::Percent(100.0),
270                    padding: UiRect::all(Val::Px(30.)),
271                    column_gap: Val::Px(200.),
272                    flex_wrap: FlexWrap::Wrap,
273                    ..default()
274                },
275                BackgroundColor(GREEN.into()),
276                StateScoped(super::Scene::BoxShadow),
277            ))
278            .with_children(|commands| {
279                let example_nodes = [
280                    (
281                        Vec2::splat(100.),
282                        Vec2::ZERO,
283                        10.,
284                        0.,
285                        BorderRadius::bottom_right(Val::Px(10.)),
286                    ),
287                    (Vec2::new(200., 50.), Vec2::ZERO, 10., 0., BorderRadius::MAX),
288                    (
289                        Vec2::new(100., 50.),
290                        Vec2::ZERO,
291                        10.,
292                        10.,
293                        BorderRadius::ZERO,
294                    ),
295                    (
296                        Vec2::splat(100.),
297                        Vec2::splat(20.),
298                        10.,
299                        10.,
300                        BorderRadius::bottom_right(Val::Px(10.)),
301                    ),
302                    (
303                        Vec2::splat(100.),
304                        Vec2::splat(50.),
305                        0.,
306                        10.,
307                        BorderRadius::ZERO,
308                    ),
309                    (
310                        Vec2::new(50., 100.),
311                        Vec2::splat(10.),
312                        0.,
313                        10.,
314                        BorderRadius::MAX,
315                    ),
316                ];
317
318                for (size, offset, spread, blur, border_radius) in example_nodes {
319                    commands.spawn((
320                        Node {
321                            width: Val::Px(size.x),
322                            height: Val::Px(size.y),
323                            border: UiRect::all(Val::Px(2.)),
324                            ..default()
325                        },
326                        BorderColor(WHITE.into()),
327                        border_radius,
328                        BackgroundColor(BLUE.into()),
329                        BoxShadow::new(
330                            Color::BLACK.with_alpha(0.9),
331                            Val::Percent(offset.x),
332                            Val::Percent(offset.y),
333                            Val::Percent(spread),
334                            Val::Px(blur),
335                        ),
336                    ));
337                }
338            });
339    }
340}
341
342mod text_wrap {
343    use bevy::prelude::*;
344
345    pub fn setup(mut commands: Commands) {
346        commands.spawn((Camera2d, StateScoped(super::Scene::TextWrap)));
347
348        let root = commands
349            .spawn((
350                Node {
351                    flex_direction: FlexDirection::Column,
352                    width: Val::Px(200.),
353                    height: Val::Percent(100.),
354                    overflow: Overflow::clip_x(),
355                    ..default()
356                },
357                BackgroundColor(Color::BLACK),
358                StateScoped(super::Scene::TextWrap),
359            ))
360            .id();
361
362        for linebreak in [
363            LineBreak::AnyCharacter,
364            LineBreak::WordBoundary,
365            LineBreak::WordOrCharacter,
366            LineBreak::NoWrap,
367        ] {
368            let messages = [
369                "Lorem ipsum dolor sit amet, consectetur adipiscing elit.".to_string(),
370                "pneumonoultramicroscopicsilicovolcanoconiosis".to_string(),
371            ];
372
373            for (j, message) in messages.into_iter().enumerate() {
374                commands.entity(root).with_child((
375                    Text(message.clone()),
376                    TextLayout::new(JustifyText::Left, linebreak),
377                    BackgroundColor(Color::srgb(0.8 - j as f32 * 0.3, 0., 0.)),
378                ));
379            }
380        }
381    }
382}
383
384mod overflow {
385    use bevy::{color::palettes::css::*, prelude::*};
386
387    pub fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
388        commands.spawn((Camera2d, StateScoped(super::Scene::Overflow)));
389        let image = asset_server.load("branding/icon.png");
390
391        commands
392            .spawn((
393                Node {
394                    width: Val::Percent(100.),
395                    height: Val::Percent(100.),
396                    align_items: AlignItems::Center,
397                    justify_content: JustifyContent::SpaceAround,
398                    ..Default::default()
399                },
400                BackgroundColor(BLUE.into()),
401                StateScoped(super::Scene::Overflow),
402            ))
403            .with_children(|parent| {
404                for overflow in [
405                    Overflow::visible(),
406                    Overflow::clip_x(),
407                    Overflow::clip_y(),
408                    Overflow::clip(),
409                ] {
410                    parent
411                        .spawn((
412                            Node {
413                                width: Val::Px(100.),
414                                height: Val::Px(100.),
415                                padding: UiRect {
416                                    left: Val::Px(25.),
417                                    top: Val::Px(25.),
418                                    ..Default::default()
419                                },
420                                border: UiRect::all(Val::Px(5.)),
421                                overflow,
422                                ..default()
423                            },
424                            BorderColor(RED.into()),
425                            BackgroundColor(Color::WHITE),
426                        ))
427                        .with_children(|parent| {
428                            parent.spawn((
429                                ImageNode::new(image.clone()),
430                                Node {
431                                    min_width: Val::Px(100.),
432                                    min_height: Val::Px(100.),
433                                    ..default()
434                                },
435                                Interaction::default(),
436                                Outline {
437                                    width: Val::Px(2.),
438                                    offset: Val::Px(2.),
439                                    color: Color::NONE,
440                                },
441                            ));
442                        });
443                }
444            });
445    }
More examples
Hide additional examples
examples/ui/overflow_debug.rs (line 144)
137fn spawn_image(
138    parent: &mut ChildSpawnerCommands,
139    asset_server: &Res<AssetServer>,
140    update_transform: impl UpdateTransform + Component,
141) {
142    spawn_container(parent, update_transform, |parent| {
143        parent.spawn((
144            ImageNode::new(asset_server.load("branding/bevy_logo_dark_big.png")),
145            Node {
146                height: Val::Px(100.),
147                position_type: PositionType::Absolute,
148                top: Val::Px(-50.),
149                left: Val::Px(-200.),
150                ..default()
151            },
152        ));
153    });
154}
examples/games/game_menu.rs (line 86)
73    fn splash_setup(mut commands: Commands, asset_server: Res<AssetServer>) {
74        let icon = asset_server.load("branding/icon.png");
75        // Display the logo
76        commands.spawn((
77            Node {
78                align_items: AlignItems::Center,
79                justify_content: JustifyContent::Center,
80                width: Val::Percent(100.0),
81                height: Val::Percent(100.0),
82                ..default()
83            },
84            OnSplashScreen,
85            children![(
86                ImageNode::new(icon),
87                Node {
88                    // This will set the logo to be 200px wide, and auto adjust its height
89                    width: Val::Px(200.0),
90                    ..default()
91                },
92            )],
93        ));
94        // Insert the timer as a resource
95        commands.insert_resource(SplashTimer(Timer::from_seconds(1.0, TimerMode::Once)));
96    }
97
98    // Tick the timer, and change state when finished
99    fn countdown(
100        mut game_state: ResMut<NextState<GameState>>,
101        time: Res<Time>,
102        mut timer: ResMut<SplashTimer>,
103    ) {
104        if timer.tick(time.delta()).finished() {
105            game_state.set(GameState::Menu);
106        }
107    }
108}
109
110mod game {
111    use bevy::{
112        color::palettes::basic::{BLUE, LIME},
113        prelude::*,
114    };
115
116    use super::{despawn_screen, DisplayQuality, GameState, Volume, TEXT_COLOR};
117
118    // This plugin will contain the game. In this case, it's just be a screen that will
119    // display the current settings for 5 seconds before returning to the menu
120    pub fn game_plugin(app: &mut App) {
121        app.add_systems(OnEnter(GameState::Game), game_setup)
122            .add_systems(Update, game.run_if(in_state(GameState::Game)))
123            .add_systems(OnExit(GameState::Game), despawn_screen::<OnGameScreen>);
124    }
125
126    // Tag component used to tag entities added on the game screen
127    #[derive(Component)]
128    struct OnGameScreen;
129
130    #[derive(Resource, Deref, DerefMut)]
131    struct GameTimer(Timer);
132
133    fn game_setup(
134        mut commands: Commands,
135        display_quality: Res<DisplayQuality>,
136        volume: Res<Volume>,
137    ) {
138        commands.spawn((
139            Node {
140                width: Val::Percent(100.0),
141                height: Val::Percent(100.0),
142                // center children
143                align_items: AlignItems::Center,
144                justify_content: JustifyContent::Center,
145                ..default()
146            },
147            OnGameScreen,
148            children![(
149                Node {
150                    // This will display its children in a column, from top to bottom
151                    flex_direction: FlexDirection::Column,
152                    // `align_items` will align children on the cross axis. Here the main axis is
153                    // vertical (column), so the cross axis is horizontal. This will center the
154                    // children
155                    align_items: AlignItems::Center,
156                    ..default()
157                },
158                BackgroundColor(Color::BLACK),
159                children![
160                    (
161                        Text::new("Will be back to the menu shortly..."),
162                        TextFont {
163                            font_size: 67.0,
164                            ..default()
165                        },
166                        TextColor(TEXT_COLOR),
167                        Node {
168                            margin: UiRect::all(Val::Px(50.0)),
169                            ..default()
170                        },
171                    ),
172                    (
173                        Text::default(),
174                        Node {
175                            margin: UiRect::all(Val::Px(50.0)),
176                            ..default()
177                        },
178                        children![
179                            (
180                                TextSpan(format!("quality: {:?}", *display_quality)),
181                                TextFont {
182                                    font_size: 50.0,
183                                    ..default()
184                                },
185                                TextColor(BLUE.into()),
186                            ),
187                            (
188                                TextSpan::new(" - "),
189                                TextFont {
190                                    font_size: 50.0,
191                                    ..default()
192                                },
193                                TextColor(TEXT_COLOR),
194                            ),
195                            (
196                                TextSpan(format!("volume: {:?}", *volume)),
197                                TextFont {
198                                    font_size: 50.0,
199                                    ..default()
200                                },
201                                TextColor(LIME.into()),
202                            ),
203                        ]
204                    ),
205                ]
206            )],
207        ));
208        // Spawn a 5 seconds timer to trigger going back to the menu
209        commands.insert_resource(GameTimer(Timer::from_seconds(5.0, TimerMode::Once)));
210    }
211
212    // Tick the timer, and change state when finished
213    fn game(
214        time: Res<Time>,
215        mut game_state: ResMut<NextState<GameState>>,
216        mut timer: ResMut<GameTimer>,
217    ) {
218        if timer.tick(time.delta()).finished() {
219            game_state.set(GameState::Menu);
220        }
221    }
222}
223
224mod menu {
225    use bevy::{
226        app::AppExit,
227        color::palettes::css::CRIMSON,
228        ecs::spawn::{SpawnIter, SpawnWith},
229        prelude::*,
230    };
231
232    use super::{despawn_screen, DisplayQuality, GameState, Volume, TEXT_COLOR};
233
234    // This plugin manages the menu, with 5 different screens:
235    // - a main menu with "New Game", "Settings", "Quit"
236    // - a settings menu with two submenus and a back button
237    // - two settings screen with a setting that can be set and a back button
238    pub fn menu_plugin(app: &mut App) {
239        app
240            // At start, the menu is not enabled. This will be changed in `menu_setup` when
241            // entering the `GameState::Menu` state.
242            // Current screen in the menu is handled by an independent state from `GameState`
243            .init_state::<MenuState>()
244            .add_systems(OnEnter(GameState::Menu), menu_setup)
245            // Systems to handle the main menu screen
246            .add_systems(OnEnter(MenuState::Main), main_menu_setup)
247            .add_systems(OnExit(MenuState::Main), despawn_screen::<OnMainMenuScreen>)
248            // Systems to handle the settings menu screen
249            .add_systems(OnEnter(MenuState::Settings), settings_menu_setup)
250            .add_systems(
251                OnExit(MenuState::Settings),
252                despawn_screen::<OnSettingsMenuScreen>,
253            )
254            // Systems to handle the display settings screen
255            .add_systems(
256                OnEnter(MenuState::SettingsDisplay),
257                display_settings_menu_setup,
258            )
259            .add_systems(
260                Update,
261                (setting_button::<DisplayQuality>.run_if(in_state(MenuState::SettingsDisplay)),),
262            )
263            .add_systems(
264                OnExit(MenuState::SettingsDisplay),
265                despawn_screen::<OnDisplaySettingsMenuScreen>,
266            )
267            // Systems to handle the sound settings screen
268            .add_systems(OnEnter(MenuState::SettingsSound), sound_settings_menu_setup)
269            .add_systems(
270                Update,
271                setting_button::<Volume>.run_if(in_state(MenuState::SettingsSound)),
272            )
273            .add_systems(
274                OnExit(MenuState::SettingsSound),
275                despawn_screen::<OnSoundSettingsMenuScreen>,
276            )
277            // Common systems to all screens that handles buttons behavior
278            .add_systems(
279                Update,
280                (menu_action, button_system).run_if(in_state(GameState::Menu)),
281            );
282    }
283
284    // State used for the current menu screen
285    #[derive(Clone, Copy, Default, Eq, PartialEq, Debug, Hash, States)]
286    enum MenuState {
287        Main,
288        Settings,
289        SettingsDisplay,
290        SettingsSound,
291        #[default]
292        Disabled,
293    }
294
295    // Tag component used to tag entities added on the main menu screen
296    #[derive(Component)]
297    struct OnMainMenuScreen;
298
299    // Tag component used to tag entities added on the settings menu screen
300    #[derive(Component)]
301    struct OnSettingsMenuScreen;
302
303    // Tag component used to tag entities added on the display settings menu screen
304    #[derive(Component)]
305    struct OnDisplaySettingsMenuScreen;
306
307    // Tag component used to tag entities added on the sound settings menu screen
308    #[derive(Component)]
309    struct OnSoundSettingsMenuScreen;
310
311    const NORMAL_BUTTON: Color = Color::srgb(0.15, 0.15, 0.15);
312    const HOVERED_BUTTON: Color = Color::srgb(0.25, 0.25, 0.25);
313    const HOVERED_PRESSED_BUTTON: Color = Color::srgb(0.25, 0.65, 0.25);
314    const PRESSED_BUTTON: Color = Color::srgb(0.35, 0.75, 0.35);
315
316    // Tag component used to mark which setting is currently selected
317    #[derive(Component)]
318    struct SelectedOption;
319
320    // All actions that can be triggered from a button click
321    #[derive(Component)]
322    enum MenuButtonAction {
323        Play,
324        Settings,
325        SettingsDisplay,
326        SettingsSound,
327        BackToMainMenu,
328        BackToSettings,
329        Quit,
330    }
331
332    // This system handles changing all buttons color based on mouse interaction
333    fn button_system(
334        mut interaction_query: Query<
335            (&Interaction, &mut BackgroundColor, Option<&SelectedOption>),
336            (Changed<Interaction>, With<Button>),
337        >,
338    ) {
339        for (interaction, mut background_color, selected) in &mut interaction_query {
340            *background_color = match (*interaction, selected) {
341                (Interaction::Pressed, _) | (Interaction::None, Some(_)) => PRESSED_BUTTON.into(),
342                (Interaction::Hovered, Some(_)) => HOVERED_PRESSED_BUTTON.into(),
343                (Interaction::Hovered, None) => HOVERED_BUTTON.into(),
344                (Interaction::None, None) => NORMAL_BUTTON.into(),
345            }
346        }
347    }
348
349    // This system updates the settings when a new value for a setting is selected, and marks
350    // the button as the one currently selected
351    fn setting_button<T: Resource + Component + PartialEq + Copy>(
352        interaction_query: Query<(&Interaction, &T, Entity), (Changed<Interaction>, With<Button>)>,
353        selected_query: Single<(Entity, &mut BackgroundColor), With<SelectedOption>>,
354        mut commands: Commands,
355        mut setting: ResMut<T>,
356    ) {
357        let (previous_button, mut previous_button_color) = selected_query.into_inner();
358        for (interaction, button_setting, entity) in &interaction_query {
359            if *interaction == Interaction::Pressed && *setting != *button_setting {
360                *previous_button_color = NORMAL_BUTTON.into();
361                commands.entity(previous_button).remove::<SelectedOption>();
362                commands.entity(entity).insert(SelectedOption);
363                *setting = *button_setting;
364            }
365        }
366    }
367
368    fn menu_setup(mut menu_state: ResMut<NextState<MenuState>>) {
369        menu_state.set(MenuState::Main);
370    }
371
372    fn main_menu_setup(mut commands: Commands, asset_server: Res<AssetServer>) {
373        // Common style for all buttons on the screen
374        let button_node = Node {
375            width: Val::Px(300.0),
376            height: Val::Px(65.0),
377            margin: UiRect::all(Val::Px(20.0)),
378            justify_content: JustifyContent::Center,
379            align_items: AlignItems::Center,
380            ..default()
381        };
382        let button_icon_node = Node {
383            width: Val::Px(30.0),
384            // This takes the icons out of the flexbox flow, to be positioned exactly
385            position_type: PositionType::Absolute,
386            // The icon will be close to the left border of the button
387            left: Val::Px(10.0),
388            ..default()
389        };
390        let button_text_font = TextFont {
391            font_size: 33.0,
392            ..default()
393        };
394
395        let right_icon = asset_server.load("textures/Game Icons/right.png");
396        let wrench_icon = asset_server.load("textures/Game Icons/wrench.png");
397        let exit_icon = asset_server.load("textures/Game Icons/exitRight.png");
398
399        commands.spawn((
400            Node {
401                width: Val::Percent(100.0),
402                height: Val::Percent(100.0),
403                align_items: AlignItems::Center,
404                justify_content: JustifyContent::Center,
405                ..default()
406            },
407            OnMainMenuScreen,
408            children![(
409                Node {
410                    flex_direction: FlexDirection::Column,
411                    align_items: AlignItems::Center,
412                    ..default()
413                },
414                BackgroundColor(CRIMSON.into()),
415                children![
416                    // Display the game name
417                    (
418                        Text::new("Bevy Game Menu UI"),
419                        TextFont {
420                            font_size: 67.0,
421                            ..default()
422                        },
423                        TextColor(TEXT_COLOR),
424                        Node {
425                            margin: UiRect::all(Val::Px(50.0)),
426                            ..default()
427                        },
428                    ),
429                    // Display three buttons for each action available from the main menu:
430                    // - new game
431                    // - settings
432                    // - quit
433                    (
434                        Button,
435                        button_node.clone(),
436                        BackgroundColor(NORMAL_BUTTON),
437                        MenuButtonAction::Play,
438                        children![
439                            (ImageNode::new(right_icon), button_icon_node.clone()),
440                            (
441                                Text::new("New Game"),
442                                button_text_font.clone(),
443                                TextColor(TEXT_COLOR),
444                            ),
445                        ]
446                    ),
447                    (
448                        Button,
449                        button_node.clone(),
450                        BackgroundColor(NORMAL_BUTTON),
451                        MenuButtonAction::Settings,
452                        children![
453                            (ImageNode::new(wrench_icon), button_icon_node.clone()),
454                            (
455                                Text::new("Settings"),
456                                button_text_font.clone(),
457                                TextColor(TEXT_COLOR),
458                            ),
459                        ]
460                    ),
461                    (
462                        Button,
463                        button_node,
464                        BackgroundColor(NORMAL_BUTTON),
465                        MenuButtonAction::Quit,
466                        children![
467                            (ImageNode::new(exit_icon), button_icon_node),
468                            (Text::new("Quit"), button_text_font, TextColor(TEXT_COLOR),),
469                        ]
470                    ),
471                ]
472            )],
473        ));
474    }
examples/ui/font_atlas_debug.rs (line 54)
38fn atlas_render_system(
39    mut commands: Commands,
40    mut state: ResMut<State>,
41    font_atlas_sets: Res<FontAtlasSets>,
42    images: Res<Assets<Image>>,
43) {
44    if let Some(set) = font_atlas_sets.get(&state.handle) {
45        if let Some((_size, font_atlases)) = set.iter().next() {
46            let x_offset = state.atlas_count as f32;
47            if state.atlas_count == font_atlases.len() as u32 {
48                return;
49            }
50            let font_atlas = &font_atlases[state.atlas_count as usize];
51            let image = images.get(&font_atlas.texture).unwrap();
52            state.atlas_count += 1;
53            commands.spawn((
54                ImageNode::new(font_atlas.texture.clone()),
55                Node {
56                    position_type: PositionType::Absolute,
57                    top: Val::ZERO,
58                    left: Val::Px(image.width() as f32 * x_offset),
59                    ..default()
60                },
61            ));
62        }
63    }
64}
examples/stress_tests/many_buttons.rs (line 293)
262fn spawn_button(
263    commands: &mut ChildSpawnerCommands,
264    background_color: Color,
265    buttons: f32,
266    column: usize,
267    row: usize,
268    spawn_text: bool,
269    border: UiRect,
270    border_color: BorderColor,
271    image: Option<Handle<Image>>,
272) {
273    let width = Val::Vw(90.0 / buttons);
274    let height = Val::Vh(90.0 / buttons);
275    let margin = UiRect::axes(width * 0.05, height * 0.05);
276    let mut builder = commands.spawn((
277        Button,
278        Node {
279            width,
280            height,
281            margin,
282            align_items: AlignItems::Center,
283            justify_content: JustifyContent::Center,
284            border,
285            ..default()
286        },
287        BackgroundColor(background_color),
288        border_color,
289        IdleColor(background_color),
290    ));
291
292    if let Some(image) = image {
293        builder.insert(ImageNode::new(image));
294    }
295
296    if spawn_text {
297        builder.with_children(|parent| {
298            // These labels are split to stress test multi-span text
299            parent
300                .spawn((
301                    Text(format!("{column}, ")),
302                    TextFont {
303                        font_size: FONT_SIZE,
304                        ..default()
305                    },
306                    TextColor(Color::srgb(0.5, 0.2, 0.2)),
307                ))
308                .with_child((
309                    TextSpan(format!("{row}")),
310                    TextFont {
311                        font_size: FONT_SIZE,
312                        ..default()
313                    },
314                    TextColor(Color::srgb(0.2, 0.2, 0.5)),
315                ));
316        });
317    }
318}
examples/ui/ui_scaling.rs (line 68)
24fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
25    commands.spawn(Camera2d);
26
27    let text_font = TextFont {
28        font_size: 13.,
29        ..default()
30    };
31
32    commands
33        .spawn((
34            Node {
35                width: Val::Percent(50.0),
36                height: Val::Percent(50.0),
37                position_type: PositionType::Absolute,
38                left: Val::Percent(25.),
39                top: Val::Percent(25.),
40                justify_content: JustifyContent::SpaceAround,
41                align_items: AlignItems::Center,
42                ..default()
43            },
44            BackgroundColor(ANTIQUE_WHITE.into()),
45        ))
46        .with_children(|parent| {
47            parent
48                .spawn((
49                    Node {
50                        width: Val::Px(40.0),
51                        height: Val::Px(40.0),
52                        ..default()
53                    },
54                    BackgroundColor(RED.into()),
55                ))
56                .with_children(|parent| {
57                    parent.spawn((Text::new("Size!"), text_font, TextColor::BLACK));
58                });
59            parent.spawn((
60                Node {
61                    width: Val::Percent(15.0),
62                    height: Val::Percent(15.0),
63                    ..default()
64                },
65                BackgroundColor(BLUE.into()),
66            ));
67            parent.spawn((
68                ImageNode::new(asset_server.load("branding/icon.png")),
69                Node {
70                    width: Val::Px(30.0),
71                    height: Val::Px(30.0),
72                    ..default()
73                },
74            ));
75        });
76}
Source

pub fn solid_color(color: Color) -> ImageNode

Create a solid color ImageNode.

This is primarily useful for debugging / mocking the extents of your image.

Source

pub fn from_atlas_image(image: Handle<Image>, atlas: TextureAtlas) -> ImageNode

Create a ImageNode from an image, with an associated texture atlas

Examples found in repository?
examples/ui/ui_texture_atlas.rs (lines 47-50)
20fn setup(
21    mut commands: Commands,
22    asset_server: Res<AssetServer>,
23    mut texture_atlases: ResMut<Assets<TextureAtlasLayout>>,
24) {
25    // Camera
26    commands.spawn(Camera2d);
27
28    let text_font = TextFont::default();
29
30    let texture_handle = asset_server.load("textures/rpg/chars/gabe/gabe-idle-run.png");
31    let texture_atlas = TextureAtlasLayout::from_grid(UVec2::splat(24), 7, 1, None, None);
32    let texture_atlas_handle = texture_atlases.add(texture_atlas);
33
34    // root node
35    commands
36        .spawn(Node {
37            width: Val::Percent(100.0),
38            height: Val::Percent(100.0),
39            flex_direction: FlexDirection::Column,
40            justify_content: JustifyContent::Center,
41            align_items: AlignItems::Center,
42            row_gap: Val::Px(text_font.font_size * 2.),
43            ..default()
44        })
45        .with_children(|parent| {
46            parent.spawn((
47                ImageNode::from_atlas_image(
48                    texture_handle,
49                    TextureAtlas::from(texture_atlas_handle),
50                ),
51                Node {
52                    width: Val::Px(256.),
53                    height: Val::Px(256.),
54                    ..default()
55                },
56                BackgroundColor(ANTIQUE_WHITE.into()),
57                Outline::new(Val::Px(8.0), Val::ZERO, CRIMSON.into()),
58            ));
59            parent
60                .spawn((Text::new("press "), text_font.clone()))
61                .with_child((
62                    TextSpan::new("space"),
63                    TextColor(YELLOW.into()),
64                    text_font.clone(),
65                ))
66                .with_child((TextSpan::new(" to advance frames"), text_font));
67        });
68}
More examples
Hide additional examples
examples/ui/ui_texture_atlas_slice.rs (lines 85-91)
50fn setup(
51    mut commands: Commands,
52    asset_server: Res<AssetServer>,
53    mut texture_atlases: ResMut<Assets<TextureAtlasLayout>>,
54) {
55    let texture_handle = asset_server.load("textures/fantasy_ui_borders/border_sheet.png");
56    let atlas_layout =
57        TextureAtlasLayout::from_grid(UVec2::new(50, 50), 6, 6, Some(UVec2::splat(2)), None);
58    let atlas_layout_handle = texture_atlases.add(atlas_layout);
59
60    let slicer = TextureSlicer {
61        border: BorderRect::all(24.0),
62        center_scale_mode: SliceScaleMode::Stretch,
63        sides_scale_mode: SliceScaleMode::Stretch,
64        max_corner_scale: 1.0,
65    };
66    // ui camera
67    commands.spawn(Camera2d);
68    commands
69        .spawn(Node {
70            width: Val::Percent(100.0),
71            height: Val::Percent(100.0),
72            align_items: AlignItems::Center,
73            justify_content: JustifyContent::Center,
74            ..default()
75        })
76        .with_children(|parent| {
77            for (idx, [w, h]) in [
78                (0, [150.0, 150.0]),
79                (7, [300.0, 150.0]),
80                (13, [150.0, 300.0]),
81            ] {
82                parent
83                    .spawn((
84                        Button,
85                        ImageNode::from_atlas_image(
86                            texture_handle.clone(),
87                            TextureAtlas {
88                                index: idx,
89                                layout: atlas_layout_handle.clone(),
90                            },
91                        )
92                        .with_mode(NodeImageMode::Sliced(slicer.clone())),
93                        Node {
94                            width: Val::Px(w),
95                            height: Val::Px(h),
96                            // horizontally center child text
97                            justify_content: JustifyContent::Center,
98                            // vertically center child text
99                            align_items: AlignItems::Center,
100                            margin: UiRect::all(Val::Px(20.0)),
101                            ..default()
102                        },
103                    ))
104                    .with_children(|parent| {
105                        parent.spawn((
106                            Text::new("Button"),
107                            TextFont {
108                                font: asset_server.load("fonts/FiraSans-Bold.ttf"),
109                                font_size: 33.0,
110                                ..default()
111                            },
112                            TextColor(Color::srgb(0.9, 0.9, 0.9)),
113                        ));
114                    });
115            }
116        });
117}
Source

pub const fn with_color(self, color: Color) -> ImageNode

Set the color tint

Source

pub const fn with_flip_x(self) -> ImageNode

Flip the image along its x-axis

Source

pub const fn with_flip_y(self) -> ImageNode

Flip the image along its y-axis

Source

pub const fn with_rect(self, rect: Rect) -> ImageNode

Source

pub const fn with_mode(self, mode: NodeImageMode) -> ImageNode

Examples found in repository?
examples/ui/ui_texture_atlas_slice.rs (line 92)
50fn setup(
51    mut commands: Commands,
52    asset_server: Res<AssetServer>,
53    mut texture_atlases: ResMut<Assets<TextureAtlasLayout>>,
54) {
55    let texture_handle = asset_server.load("textures/fantasy_ui_borders/border_sheet.png");
56    let atlas_layout =
57        TextureAtlasLayout::from_grid(UVec2::new(50, 50), 6, 6, Some(UVec2::splat(2)), None);
58    let atlas_layout_handle = texture_atlases.add(atlas_layout);
59
60    let slicer = TextureSlicer {
61        border: BorderRect::all(24.0),
62        center_scale_mode: SliceScaleMode::Stretch,
63        sides_scale_mode: SliceScaleMode::Stretch,
64        max_corner_scale: 1.0,
65    };
66    // ui camera
67    commands.spawn(Camera2d);
68    commands
69        .spawn(Node {
70            width: Val::Percent(100.0),
71            height: Val::Percent(100.0),
72            align_items: AlignItems::Center,
73            justify_content: JustifyContent::Center,
74            ..default()
75        })
76        .with_children(|parent| {
77            for (idx, [w, h]) in [
78                (0, [150.0, 150.0]),
79                (7, [300.0, 150.0]),
80                (13, [150.0, 300.0]),
81            ] {
82                parent
83                    .spawn((
84                        Button,
85                        ImageNode::from_atlas_image(
86                            texture_handle.clone(),
87                            TextureAtlas {
88                                index: idx,
89                                layout: atlas_layout_handle.clone(),
90                            },
91                        )
92                        .with_mode(NodeImageMode::Sliced(slicer.clone())),
93                        Node {
94                            width: Val::Px(w),
95                            height: Val::Px(h),
96                            // horizontally center child text
97                            justify_content: JustifyContent::Center,
98                            // vertically center child text
99                            align_items: AlignItems::Center,
100                            margin: UiRect::all(Val::Px(20.0)),
101                            ..default()
102                        },
103                    ))
104                    .with_children(|parent| {
105                        parent.spawn((
106                            Text::new("Button"),
107                            TextFont {
108                                font: asset_server.load("fonts/FiraSans-Bold.ttf"),
109                                font_size: 33.0,
110                                ..default()
111                            },
112                            TextColor(Color::srgb(0.9, 0.9, 0.9)),
113                        ));
114                    });
115            }
116        });
117}
More examples
Hide additional examples
examples/testbed/full_ui.rs (line 321)
27fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
28    // Camera
29    commands.spawn((Camera2d, IsDefaultUiCamera, BoxShadowSamples(6)));
30
31    // root node
32    commands
33        .spawn(Node {
34            width: Val::Percent(100.0),
35            height: Val::Percent(100.0),
36            justify_content: JustifyContent::SpaceBetween,
37            ..default()
38        })
39        .insert(Pickable::IGNORE)
40        .with_children(|parent| {
41            // left vertical fill (border)
42            parent
43                .spawn((
44                    Node {
45                        width: Val::Px(200.),
46                        border: UiRect::all(Val::Px(2.)),
47                        ..default()
48                    },
49                    BackgroundColor(Color::srgb(0.65, 0.65, 0.65)),
50                ))
51                .with_children(|parent| {
52                    // left vertical fill (content)
53                    parent
54                        .spawn((
55                            Node {
56                                width: Val::Percent(100.),
57                                flex_direction: FlexDirection::Column,
58                                padding: UiRect::all(Val::Px(5.)),
59                                row_gap: Val::Px(5.),
60                                ..default()
61                            },
62                            BackgroundColor(Color::srgb(0.15, 0.15, 0.15)),
63                            Visibility::Visible,
64                        ))
65                        .with_children(|parent| {
66                            // text
67                            parent.spawn((
68                                Text::new("Text Example"),
69                                TextFont {
70                                    font: asset_server.load("fonts/FiraSans-Bold.ttf"),
71                                    font_size: 25.0,
72                                    ..default()
73                                },
74                                // Because this is a distinct label widget and
75                                // not button/list item text, this is necessary
76                                // for accessibility to treat the text accordingly.
77                                Label,
78                            ));
79
80                            #[cfg(feature = "bevy_ui_debug")]
81                            {
82                                // Debug overlay text
83                                parent.spawn((
84                                    Text::new("Press Space to toggle debug outlines."),
85                                    TextFont {
86                                        font: asset_server.load("fonts/FiraSans-Bold.ttf"),
87                                        ..default()
88                                    },
89                                    Label,
90                                ));
91
92                                parent.spawn((
93                                    Text::new("V: toggle UI root's visibility"),
94                                    TextFont {
95                                        font: asset_server.load("fonts/FiraSans-Bold.ttf"),
96                                        font_size: 12.,
97                                        ..default()
98                                    },
99                                    Label,
100                                ));
101
102                                parent.spawn((
103                                    Text::new("S: toggle outlines for hidden nodes"),
104                                    TextFont {
105                                        font: asset_server.load("fonts/FiraSans-Bold.ttf"),
106                                        font_size: 12.,
107                                        ..default()
108                                    },
109                                    Label,
110                                ));
111                                parent.spawn((
112                                    Text::new("C: toggle outlines for clipped nodes"),
113                                    TextFont {
114                                        font: asset_server.load("fonts/FiraSans-Bold.ttf"),
115                                        font_size: 12.,
116                                        ..default()
117                                    },
118                                    Label,
119                                ));
120                            }
121                            #[cfg(not(feature = "bevy_ui_debug"))]
122                            parent.spawn((
123                                Text::new("Try enabling feature \"bevy_ui_debug\"."),
124                                TextFont {
125                                    font: asset_server.load("fonts/FiraSans-Bold.ttf"),
126                                    ..default()
127                                },
128                                Label,
129                            ));
130                        });
131                });
132            // right vertical fill
133            parent
134                .spawn(Node {
135                    flex_direction: FlexDirection::Column,
136                    justify_content: JustifyContent::Center,
137                    align_items: AlignItems::Center,
138                    width: Val::Px(200.),
139                    ..default()
140                })
141                .with_children(|parent| {
142                    // Title
143                    parent.spawn((
144                        Text::new("Scrolling list"),
145                        TextFont {
146                            font: asset_server.load("fonts/FiraSans-Bold.ttf"),
147                            font_size: 21.,
148                            ..default()
149                        },
150                        Label,
151                    ));
152                    // Scrolling list
153                    parent
154                        .spawn((
155                            Node {
156                                flex_direction: FlexDirection::Column,
157                                align_self: AlignSelf::Stretch,
158                                height: Val::Percent(50.),
159                                overflow: Overflow::scroll_y(),
160                                ..default()
161                            },
162                            BackgroundColor(Color::srgb(0.10, 0.10, 0.10)),
163                        ))
164                        .with_children(|parent| {
165                            // List items
166                            for i in 0..25 {
167                                parent
168                                    .spawn((
169                                        Text(format!("Item {i}")),
170                                        TextFont {
171                                            font: asset_server.load("fonts/FiraSans-Bold.ttf"),
172                                            ..default()
173                                        },
174                                        Label,
175                                        AccessibilityNode(Accessible::new(Role::ListItem)),
176                                    ))
177                                    .insert(Pickable {
178                                        should_block_lower: false,
179                                        ..default()
180                                    });
181                            }
182                        });
183                });
184
185            parent
186                .spawn(Node {
187                    left: Val::Px(210.),
188                    bottom: Val::Px(10.),
189                    position_type: PositionType::Absolute,
190                    ..default()
191                })
192                .with_children(|parent| {
193                    parent
194                        .spawn((
195                            Node {
196                                width: Val::Px(200.0),
197                                height: Val::Px(200.0),
198                                border: UiRect::all(Val::Px(20.)),
199                                flex_direction: FlexDirection::Column,
200                                justify_content: JustifyContent::Center,
201                                ..default()
202                            },
203                            BorderColor(LIME.into()),
204                            BackgroundColor(Color::srgb(0.8, 0.8, 1.)),
205                        ))
206                        .with_children(|parent| {
207                            parent.spawn((
208                                ImageNode::new(asset_server.load("branding/bevy_logo_light.png")),
209                                // Uses the transform to rotate the logo image by 45 degrees
210                                Transform::from_rotation(Quat::from_rotation_z(0.25 * PI)),
211                                BorderRadius::all(Val::Px(10.)),
212                                Outline {
213                                    width: Val::Px(2.),
214                                    offset: Val::Px(4.),
215                                    color: DARK_GRAY.into(),
216                                },
217                            ));
218                        });
219                });
220
221            let shadow_style = ShadowStyle {
222                color: Color::BLACK.with_alpha(0.5),
223                blur_radius: Val::Px(2.),
224                x_offset: Val::Px(10.),
225                y_offset: Val::Px(10.),
226                ..default()
227            };
228
229            // render order test: reddest in the back, whitest in the front (flex center)
230            parent
231                .spawn(Node {
232                    width: Val::Percent(100.0),
233                    height: Val::Percent(100.0),
234                    position_type: PositionType::Absolute,
235                    align_items: AlignItems::Center,
236                    justify_content: JustifyContent::Center,
237                    ..default()
238                })
239                .insert(Pickable::IGNORE)
240                .with_children(|parent| {
241                    parent
242                        .spawn((
243                            Node {
244                                width: Val::Px(100.0),
245                                height: Val::Px(100.0),
246                                ..default()
247                            },
248                            BackgroundColor(Color::srgb(1.0, 0.0, 0.)),
249                            BoxShadow::from(shadow_style),
250                        ))
251                        .with_children(|parent| {
252                            parent.spawn((
253                                Node {
254                                    // Take the size of the parent node.
255                                    width: Val::Percent(100.0),
256                                    height: Val::Percent(100.0),
257                                    position_type: PositionType::Absolute,
258                                    left: Val::Px(20.),
259                                    bottom: Val::Px(20.),
260                                    ..default()
261                                },
262                                BackgroundColor(Color::srgb(1.0, 0.3, 0.3)),
263                                BoxShadow::from(shadow_style),
264                            ));
265                            parent.spawn((
266                                Node {
267                                    width: Val::Percent(100.0),
268                                    height: Val::Percent(100.0),
269                                    position_type: PositionType::Absolute,
270                                    left: Val::Px(40.),
271                                    bottom: Val::Px(40.),
272                                    ..default()
273                                },
274                                BackgroundColor(Color::srgb(1.0, 0.5, 0.5)),
275                                BoxShadow::from(shadow_style),
276                            ));
277                            parent.spawn((
278                                Node {
279                                    width: Val::Percent(100.0),
280                                    height: Val::Percent(100.0),
281                                    position_type: PositionType::Absolute,
282                                    left: Val::Px(60.),
283                                    bottom: Val::Px(60.),
284                                    ..default()
285                                },
286                                BackgroundColor(Color::srgb(0.0, 0.7, 0.7)),
287                                BoxShadow::from(shadow_style),
288                            ));
289                            // alpha test
290                            parent.spawn((
291                                Node {
292                                    width: Val::Percent(100.0),
293                                    height: Val::Percent(100.0),
294                                    position_type: PositionType::Absolute,
295                                    left: Val::Px(80.),
296                                    bottom: Val::Px(80.),
297                                    ..default()
298                                },
299                                BackgroundColor(Color::srgba(1.0, 0.9, 0.9, 0.4)),
300                                BoxShadow::from(ShadowStyle {
301                                    color: Color::BLACK.with_alpha(0.3),
302                                    ..shadow_style
303                                }),
304                            ));
305                        });
306                });
307            // bevy logo (flex center)
308            parent
309                .spawn(Node {
310                    width: Val::Percent(100.0),
311                    position_type: PositionType::Absolute,
312                    justify_content: JustifyContent::Center,
313                    align_items: AlignItems::FlexStart,
314                    ..default()
315                })
316                .with_children(|parent| {
317                    // bevy logo (image)
318                    parent
319                        .spawn((
320                            ImageNode::new(asset_server.load("branding/bevy_logo_dark_big.png"))
321                                .with_mode(NodeImageMode::Stretch),
322                            Node {
323                                width: Val::Px(500.0),
324                                height: Val::Px(125.0),
325                                margin: UiRect::top(Val::VMin(5.)),
326                                ..default()
327                            },
328                        ))
329                        .with_children(|parent| {
330                            // alt text
331                            // This UI node takes up no space in the layout and the `Text` component is used by the accessibility module
332                            // and is not rendered.
333                            parent.spawn((
334                                Node {
335                                    display: Display::None,
336                                    ..default()
337                                },
338                                Text::new("Bevy logo"),
339                            ));
340                        });
341                });
342
343            // four bevy icons demonstrating image flipping
344            parent
345                .spawn(Node {
346                    width: Val::Percent(100.0),
347                    height: Val::Percent(100.0),
348                    position_type: PositionType::Absolute,
349                    justify_content: JustifyContent::Center,
350                    align_items: AlignItems::FlexEnd,
351                    column_gap: Val::Px(10.),
352                    padding: UiRect::all(Val::Px(10.)),
353                    ..default()
354                })
355                .insert(Pickable::IGNORE)
356                .with_children(|parent| {
357                    for (flip_x, flip_y) in
358                        [(false, false), (false, true), (true, true), (true, false)]
359                    {
360                        parent.spawn((
361                            ImageNode {
362                                image: asset_server.load("branding/icon.png"),
363                                flip_x,
364                                flip_y,
365                                ..default()
366                            },
367                            Node {
368                                // The height will be chosen automatically to preserve the image's aspect ratio
369                                width: Val::Px(75.),
370                                ..default()
371                            },
372                        ));
373                    }
374                });
375        });
376}

Trait Implementations§

Source§

impl Clone for ImageNode

Source§

fn clone(&self) -> ImageNode

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Component for ImageNode
where ImageNode: Send + Sync + 'static,

Required Components: Node, ImageNodeSize, ContentSize.

A component’s Required Components are inserted whenever it is inserted. Note that this will also insert the required components of the required components, recursively, in depth-first order.

Source§

const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table

A constant indicating the storage type used for this component.
Source§

type Mutability = Mutable

A marker type to assist Bevy with determining if this component is mutable, or immutable. Mutable components will have [Component<Mutability = Mutable>], while immutable components will instead have [Component<Mutability = Immutable>]. Read more
Source§

fn register_required_components( requiree: ComponentId, components: &mut ComponentsRegistrator<'_>, required_components: &mut RequiredComponents, inheritance_depth: u16, recursion_check_stack: &mut Vec<ComponentId>, )

Registers required components.
Source§

fn clone_behavior() -> ComponentCloneBehavior

Called when registering this component, allowing to override clone function (or disable cloning altogether) for this component. Read more
Source§

fn register_component_hooks(hooks: &mut ComponentHooks)

👎Deprecated since 0.16.0: Use the individual hook methods instead (e.g., Component::on_add, etc.)
Called when registering this component, allowing mutable access to its ComponentHooks.
Source§

fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_add ComponentHook for this Component if one is defined.
Source§

fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_insert ComponentHook for this Component if one is defined.
Source§

fn on_replace() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_replace ComponentHook for this Component if one is defined.
Source§

fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_remove ComponentHook for this Component if one is defined.
Source§

fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_despawn ComponentHook for this Component if one is defined.
Source§

fn map_entities<E>(_this: &mut Self, _mapper: &mut E)
where E: EntityMapper,

Maps the entities on this component using the given EntityMapper. This is used to remap entities in contexts like scenes and entity cloning. When deriving Component, this is populated by annotating fields containing entities with #[entities] Read more
Source§

impl Debug for ImageNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for ImageNode

Source§

fn default() -> ImageNode

A transparent 1x1 image with a solid white tint.

§Warning

This will be invisible by default. To set this to a visible image, you need to set the texture field to a valid image handle, or use Handle<Image>’s default 1x1 solid white texture (as is done in ImageNode::solid_color).

Source§

impl From<Handle<Image>> for ImageNode

Source§

fn from(texture: Handle<Image>) -> ImageNode

Converts to this type from the input type.
Source§

impl FromArg for &'static ImageNode
where ImageNode: Any + Send + Sync, Color: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Handle<Image>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<TextureAtlas>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<Rect>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, NodeImageMode: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

type This<'from_arg> = &'from_arg ImageNode

The type to convert into. Read more
Source§

fn from_arg( arg: Arg<'_>, ) -> Result<<&'static ImageNode as FromArg>::This<'_>, ArgError>

Creates an item from an argument. Read more
Source§

impl FromArg for &'static mut ImageNode
where ImageNode: Any + Send + Sync, Color: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Handle<Image>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<TextureAtlas>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<Rect>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, NodeImageMode: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

type This<'from_arg> = &'from_arg mut ImageNode

The type to convert into. Read more
Source§

fn from_arg( arg: Arg<'_>, ) -> Result<<&'static mut ImageNode as FromArg>::This<'_>, ArgError>

Creates an item from an argument. Read more
Source§

impl FromArg for ImageNode
where ImageNode: Any + Send + Sync, Color: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Handle<Image>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<TextureAtlas>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<Rect>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, NodeImageMode: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

type This<'from_arg> = ImageNode

The type to convert into. Read more
Source§

fn from_arg(arg: Arg<'_>) -> Result<<ImageNode as FromArg>::This<'_>, ArgError>

Creates an item from an argument. Read more
Source§

impl FromReflect for ImageNode
where ImageNode: Any + Send + Sync, Color: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Handle<Image>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<TextureAtlas>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<Rect>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, NodeImageMode: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn from_reflect(reflect: &(dyn PartialReflect + 'static)) -> Option<ImageNode>

Constructs a concrete instance of Self from a reflected value.
Source§

fn take_from_reflect( reflect: Box<dyn PartialReflect>, ) -> Result<Self, Box<dyn PartialReflect>>

Attempts to downcast the given value to Self using, constructing the value using from_reflect if that fails. Read more
Source§

impl GetOwnership for &ImageNode
where ImageNode: Any + Send + Sync, Color: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Handle<Image>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<TextureAtlas>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<Rect>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, NodeImageMode: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl GetOwnership for &mut ImageNode
where ImageNode: Any + Send + Sync, Color: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Handle<Image>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<TextureAtlas>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<Rect>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, NodeImageMode: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl GetOwnership for ImageNode
where ImageNode: Any + Send + Sync, Color: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Handle<Image>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<TextureAtlas>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<Rect>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, NodeImageMode: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl GetTypeRegistration for ImageNode
where ImageNode: Any + Send + Sync, Color: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Handle<Image>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<TextureAtlas>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<Rect>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, NodeImageMode: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn get_type_registration() -> TypeRegistration

Returns the default TypeRegistration for this type.
Source§

fn register_type_dependencies(registry: &mut TypeRegistry)

Registers other types needed by this type. Read more
Source§

impl IntoReturn for &ImageNode
where ImageNode: Any + Send + Sync, Color: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Handle<Image>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<TextureAtlas>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<Rect>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, NodeImageMode: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn into_return<'into_return>(self) -> Return<'into_return>
where &ImageNode: 'into_return,

Converts Self into a Return value.
Source§

impl IntoReturn for &mut ImageNode
where ImageNode: Any + Send + Sync, Color: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Handle<Image>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<TextureAtlas>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<Rect>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, NodeImageMode: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn into_return<'into_return>(self) -> Return<'into_return>
where &mut ImageNode: 'into_return,

Converts Self into a Return value.
Source§

impl IntoReturn for ImageNode
where ImageNode: Any + Send + Sync, Color: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Handle<Image>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<TextureAtlas>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<Rect>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, NodeImageMode: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn into_return<'into_return>(self) -> Return<'into_return>
where ImageNode: 'into_return,

Converts Self into a Return value.
Source§

impl PartialReflect for ImageNode
where ImageNode: Any + Send + Sync, Color: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Handle<Image>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<TextureAtlas>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<Rect>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, NodeImageMode: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn get_represented_type_info(&self) -> Option<&'static TypeInfo>

Returns the TypeInfo of the type represented by this value. Read more
Source§

fn try_apply( &mut self, value: &(dyn PartialReflect + 'static), ) -> Result<(), ApplyError>

Tries to apply a reflected value to this value. Read more
Source§

fn reflect_kind(&self) -> ReflectKind

Returns a zero-sized enumeration of “kinds” of type. Read more
Source§

fn reflect_ref(&self) -> ReflectRef<'_>

Returns an immutable enumeration of “kinds” of type. Read more
Source§

fn reflect_mut(&mut self) -> ReflectMut<'_>

Returns a mutable enumeration of “kinds” of type. Read more
Source§

fn reflect_owned(self: Box<ImageNode>) -> ReflectOwned

Returns an owned enumeration of “kinds” of type. Read more
Source§

fn try_into_reflect( self: Box<ImageNode>, ) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>

Attempts to cast this type to a boxed, fully-reflected value.
Source§

fn try_as_reflect(&self) -> Option<&(dyn Reflect + 'static)>

Attempts to cast this type to a fully-reflected value.
Source§

fn try_as_reflect_mut(&mut self) -> Option<&mut (dyn Reflect + 'static)>

Attempts to cast this type to a mutable, fully-reflected value.
Source§

fn into_partial_reflect(self: Box<ImageNode>) -> Box<dyn PartialReflect>

Casts this type to a boxed, reflected value. Read more
Source§

fn as_partial_reflect(&self) -> &(dyn PartialReflect + 'static)

Casts this type to a reflected value. Read more
Source§

fn as_partial_reflect_mut(&mut self) -> &mut (dyn PartialReflect + 'static)

Casts this type to a mutable, reflected value. Read more
Source§

fn reflect_partial_eq( &self, value: &(dyn PartialReflect + 'static), ) -> Option<bool>

Returns a “partial equality” comparison result. Read more
Source§

fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Debug formatter for the value. Read more
Source§

fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>

Attempts to clone Self using reflection. Read more
Source§

fn apply(&mut self, value: &(dyn PartialReflect + 'static))

Applies a reflected value to this value. Read more
Source§

fn clone_value(&self) -> Box<dyn PartialReflect>

👎Deprecated since 0.16.0: to clone reflected values, prefer using reflect_clone. To convert reflected values to dynamic ones, use to_dynamic.
Clones Self into its dynamic representation. Read more
Source§

fn to_dynamic(&self) -> Box<dyn PartialReflect>

Converts this reflected value into its dynamic representation based on its kind. Read more
Source§

fn reflect_hash(&self) -> Option<u64>

Returns a hash of the value (which includes the type). Read more
Source§

fn is_dynamic(&self) -> bool

Indicates whether or not this type is a dynamic type. Read more
Source§

impl Reflect for ImageNode
where ImageNode: Any + Send + Sync, Color: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Handle<Image>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<TextureAtlas>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<Rect>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, NodeImageMode: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn into_any(self: Box<ImageNode>) -> Box<dyn Any>

Returns the value as a Box<dyn Any>. Read more
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Returns the value as a &dyn Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Returns the value as a &mut dyn Any. Read more
Source§

fn into_reflect(self: Box<ImageNode>) -> Box<dyn Reflect>

Casts this type to a boxed, fully-reflected value.
Source§

fn as_reflect(&self) -> &(dyn Reflect + 'static)

Casts this type to a fully-reflected value.
Source§

fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)

Casts this type to a mutable, fully-reflected value.
Source§

fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>

Performs a type-checked assignment of a reflected value to this value. Read more
Source§

impl Struct for ImageNode
where ImageNode: Any + Send + Sync, Color: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Handle<Image>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<TextureAtlas>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<Rect>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, NodeImageMode: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn field(&self, name: &str) -> Option<&(dyn PartialReflect + 'static)>

Returns a reference to the value of the field named name as a &dyn PartialReflect.
Source§

fn field_mut( &mut self, name: &str, ) -> Option<&mut (dyn PartialReflect + 'static)>

Returns a mutable reference to the value of the field named name as a &mut dyn PartialReflect.
Source§

fn field_at(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>

Returns a reference to the value of the field with index index as a &dyn PartialReflect.
Source§

fn field_at_mut( &mut self, index: usize, ) -> Option<&mut (dyn PartialReflect + 'static)>

Returns a mutable reference to the value of the field with index index as a &mut dyn PartialReflect.
Source§

fn name_at(&self, index: usize) -> Option<&str>

Returns the name of the field with index index.
Source§

fn field_len(&self) -> usize

Returns the number of fields in the struct.
Source§

fn iter_fields(&self) -> FieldIter<'_>

Returns an iterator over the values of the reflectable fields for this struct.
Source§

fn to_dynamic_struct(&self) -> DynamicStruct

Source§

fn clone_dynamic(&self) -> DynamicStruct

👎Deprecated since 0.16.0: use to_dynamic_struct instead
Clones the struct into a DynamicStruct.
Source§

fn get_represented_struct_info(&self) -> Option<&'static StructInfo>

Will return None if TypeInfo is not available.
Source§

impl TypePath for ImageNode
where ImageNode: Any + Send + Sync,

Source§

fn type_path() -> &'static str

Returns the fully qualified path of the underlying type. Read more
Source§

fn short_type_path() -> &'static str

Returns a short, pretty-print enabled path to the type. Read more
Source§

fn type_ident() -> Option<&'static str>

Returns the name of the type, or None if it is anonymous. Read more
Source§

fn crate_name() -> Option<&'static str>

Returns the name of the crate the type is in, or None if it is anonymous. Read more
Source§

fn module_path() -> Option<&'static str>

Returns the path to the module the type is in, or None if it is anonymous. Read more
Source§

impl Typed for ImageNode
where ImageNode: Any + Send + Sync, Color: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Handle<Image>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<TextureAtlas>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection, Option<Rect>: FromReflect + TypePath + MaybeTyped + RegisterForReflection, NodeImageMode: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn type_info() -> &'static TypeInfo

Returns the compile-time info for the underlying type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

Source§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<C> Bundle for C
where C: Component,

Source§

fn component_ids( components: &mut ComponentsRegistrator<'_>, ids: &mut impl FnMut(ComponentId), )

Source§

fn register_required_components( components: &mut ComponentsRegistrator<'_>, required_components: &mut RequiredComponents, )

Registers components that are required by the components in this Bundle.
Source§

fn get_component_ids( components: &Components, ids: &mut impl FnMut(Option<ComponentId>), )

Gets this Bundle’s component ids. This will be None if the component has not been registered.
Source§

impl<C> BundleFromComponents for C
where C: Component,

Source§

unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> C
where F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a>,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<C> DynamicBundle for C
where C: Component,

Source§

type Effect = ()

An operation on the entity that happens after inserting this bundle.
Source§

fn get_components( self, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect

Source§

impl<T> DynamicTypePath for T
where T: TypePath,

Source§

impl<T> DynamicTyped for T
where T: Typed,

Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> FromWorld for T
where T: Default,

Source§

fn from_world(_world: &mut World) -> T

Creates Self using default().

Source§

impl<S> GetField for S
where S: Struct,

Source§

fn get_field<T>(&self, name: &str) -> Option<&T>
where T: Reflect,

Returns a reference to the value of the field named name, downcast to T.
Source§

fn get_field_mut<T>(&mut self, name: &str) -> Option<&mut T>
where T: Reflect,

Returns a mutable reference to the value of the field named name, downcast to T.
Source§

impl<T> GetPath for T
where T: Reflect + ?Sized,

Source§

fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a reference to the value specified by path. Read more
Source§

fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a mutable reference to the value specified by path. Read more
Source§

fn path<'p, T>( &self, path: impl ReflectPath<'p>, ) -> Result<&T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed reference to the value specified by path. Read more
Source§

fn path_mut<'p, T>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed mutable reference to the value specified by path. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> Reflectable for T

Source§

impl<T> Settings for T
where T: 'static + Send + Sync,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,