Struct BorderRadius

Source
pub struct BorderRadius {
    pub top_left: Val,
    pub top_right: Val,
    pub bottom_left: Val,
    pub bottom_right: Val,
}
Expand description

Used to add rounded corners to a UI node. You can set a UI node to have uniformly rounded corners or specify different radii for each corner. If a given radius exceeds half the length of the smallest dimension between the node’s height or width, the radius will calculated as half the smallest dimension.

Elliptical nodes are not supported yet. Percentage values are based on the node’s smallest dimension, either width or height.

§Example

fn setup_ui(mut commands: Commands) {
    commands.spawn((
        Node {
            width: Val::Px(100.),
            height: Val::Px(100.),
            border: UiRect::all(Val::Px(2.)),
            ..Default::default()
        },
        BackgroundColor(BLUE.into()),
        BorderRadius::new(
            // top left
            Val::Px(10.),
            // top right
            Val::Px(20.),
            // bottom right
            Val::Px(30.),
            // bottom left
            Val::Px(40.),
        ),
    ));
}

https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius

Fields§

§top_left: Val§top_right: Val§bottom_left: Val§bottom_right: Val

Implementations§

Source§

impl BorderRadius

Source

pub const DEFAULT: BorderRadius = Self::ZERO

Source

pub const ZERO: BorderRadius

Zero curvature. All the corners will be right-angled.

Source

pub const MAX: BorderRadius

Maximum curvature. The UI Node will take a capsule shape or circular if width and height are equal.

Source

pub const fn all(radius: Val) -> BorderRadius

Set all four corners to the same curvature.

Examples found in repository?
examples/3d/clustered_decals.rs (line 295)
281fn spawn_drag_button<'a>(
282    commands: &'a mut ChildSpawnerCommands,
283    label: &str,
284) -> EntityCommands<'a> {
285    let mut kid = commands.spawn(Node {
286        border: BUTTON_BORDER,
287        justify_content: JustifyContent::Center,
288        align_items: AlignItems::Center,
289        padding: BUTTON_PADDING,
290        ..default()
291    });
292    kid.insert((
293        Button,
294        BackgroundColor(Color::BLACK),
295        BorderRadius::all(BUTTON_BORDER_RADIUS_SIZE),
296        BUTTON_BORDER_COLOR,
297    ))
298    .with_children(|parent| {
299        widgets::spawn_ui_text(parent, label, Color::WHITE);
300    });
301    kid
302}
More examples
Hide additional examples
examples/ui/ui_material.rs (line 51)
19fn setup(
20    mut commands: Commands,
21    mut ui_materials: ResMut<Assets<CustomUiMaterial>>,
22    asset_server: Res<AssetServer>,
23) {
24    // Camera so we can see UI
25    commands.spawn(Camera2d);
26
27    commands
28        .spawn(Node {
29            width: Val::Percent(100.0),
30            height: Val::Percent(100.0),
31            align_items: AlignItems::Center,
32            justify_content: JustifyContent::Center,
33            ..default()
34        })
35        .with_children(|parent| {
36            let banner_scale_factor = 0.5;
37            parent.spawn((
38                Node {
39                    position_type: PositionType::Absolute,
40                    width: Val::Px(905.0 * banner_scale_factor),
41                    height: Val::Px(363.0 * banner_scale_factor),
42                    border: UiRect::all(Val::Px(20.)),
43                    ..default()
44                },
45                MaterialNode(ui_materials.add(CustomUiMaterial {
46                    color: LinearRgba::WHITE.to_f32_array().into(),
47                    slider: Vec4::splat(0.5),
48                    color_texture: asset_server.load("branding/banner.png"),
49                    border_color: LinearRgba::WHITE.to_f32_array().into(),
50                })),
51                BorderRadius::all(Val::Px(20.)),
52                // UI material nodes can have outlines and shadows like any other UI node
53                Outline {
54                    width: Val::Px(2.),
55                    offset: Val::Px(100.),
56                    color: DARK_BLUE.into(),
57                },
58            ));
59        });
60}
examples/animation/animation_masks.rs (line 259)
227fn add_mask_group_control(
228    parent: &mut ChildSpawnerCommands,
229    label: &str,
230    width: Val,
231    mask_group_id: u32,
232) {
233    let button_text_style = (
234        TextFont {
235            font_size: 14.0,
236            ..default()
237        },
238        TextColor::WHITE,
239    );
240    let selected_button_text_style = (button_text_style.0.clone(), TextColor::BLACK);
241    let label_text_style = (
242        button_text_style.0.clone(),
243        TextColor(Color::Srgba(LIGHT_GRAY)),
244    );
245
246    parent
247        .spawn((
248            Node {
249                border: UiRect::all(Val::Px(1.0)),
250                width,
251                flex_direction: FlexDirection::Column,
252                justify_content: JustifyContent::Center,
253                align_items: AlignItems::Center,
254                padding: UiRect::ZERO,
255                margin: UiRect::ZERO,
256                ..default()
257            },
258            BorderColor(Color::WHITE),
259            BorderRadius::all(Val::Px(3.0)),
260            BackgroundColor(Color::BLACK),
261        ))
262        .with_children(|builder| {
263            builder
264                .spawn((
265                    Node {
266                        border: UiRect::ZERO,
267                        width: Val::Percent(100.0),
268                        justify_content: JustifyContent::Center,
269                        align_items: AlignItems::Center,
270                        padding: UiRect::ZERO,
271                        margin: UiRect::ZERO,
272                        ..default()
273                    },
274                    BackgroundColor(Color::BLACK),
275                ))
276                .with_child((
277                    Text::new(label),
278                    label_text_style.clone(),
279                    Node {
280                        margin: UiRect::vertical(Val::Px(3.0)),
281                        ..default()
282                    },
283                ));
284
285            builder
286                .spawn((
287                    Node {
288                        width: Val::Percent(100.0),
289                        flex_direction: FlexDirection::Row,
290                        justify_content: JustifyContent::Center,
291                        align_items: AlignItems::Center,
292                        border: UiRect::top(Val::Px(1.0)),
293                        ..default()
294                    },
295                    BorderColor(Color::WHITE),
296                ))
297                .with_children(|builder| {
298                    for (index, label) in [
299                        AnimationLabel::Run,
300                        AnimationLabel::Walk,
301                        AnimationLabel::Idle,
302                        AnimationLabel::Off,
303                    ]
304                    .iter()
305                    .enumerate()
306                    {
307                        builder
308                            .spawn((
309                                Button,
310                                BackgroundColor(if index > 0 {
311                                    Color::BLACK
312                                } else {
313                                    Color::WHITE
314                                }),
315                                Node {
316                                    flex_grow: 1.0,
317                                    border: if index > 0 {
318                                        UiRect::left(Val::Px(1.0))
319                                    } else {
320                                        UiRect::ZERO
321                                    },
322                                    ..default()
323                                },
324                                BorderColor(Color::WHITE),
325                                AnimationControl {
326                                    group_id: mask_group_id,
327                                    label: *label,
328                                },
329                            ))
330                            .with_child((
331                                Text(format!("{:?}", label)),
332                                if index > 0 {
333                                    button_text_style.clone()
334                                } else {
335                                    selected_button_text_style.clone()
336                                },
337                                TextLayout::new_with_justify(JustifyText::Center),
338                                Node {
339                                    flex_grow: 1.0,
340                                    margin: UiRect::vertical(Val::Px(3.0)),
341                                    ..default()
342                                },
343                            ));
344                    }
345                });
346        });
347}
examples/ui/directional_navigation.rs (line 180)
103fn setup_ui(
104    mut commands: Commands,
105    mut directional_nav_map: ResMut<DirectionalNavigationMap>,
106    mut input_focus: ResMut<InputFocus>,
107) {
108    const N_ROWS: u16 = 5;
109    const N_COLS: u16 = 3;
110
111    // Rendering UI elements requires a camera
112    commands.spawn(Camera2d);
113
114    // Create a full-screen background node
115    let root_node = commands
116        .spawn(Node {
117            width: Val::Percent(100.0),
118            height: Val::Percent(100.0),
119            ..default()
120        })
121        .id();
122
123    // Add instruction to the left of the grid
124    let instructions = commands
125        .spawn((
126            Text::new("Use arrow keys or D-pad to navigate. \
127            Click the buttons, or press Enter / the South gamepad button to interact with the focused button."),
128            Node {
129                width: Val::Px(300.0),
130                justify_content: JustifyContent::Center,
131                align_items: AlignItems::Center,
132                margin: UiRect::all(Val::Px(12.0)),
133                ..default()
134            },
135        ))
136        .id();
137
138    // Set up the root entity to hold the grid
139    let grid_root_entity = commands
140        .spawn(Node {
141            display: Display::Grid,
142            // Allow the grid to take up the full height and the rest of the width of the window
143            width: Val::Percent(100.),
144            height: Val::Percent(100.),
145            // Set the number of rows and columns in the grid
146            // allowing the grid to automatically size the cells
147            grid_template_columns: RepeatedGridTrack::auto(N_COLS),
148            grid_template_rows: RepeatedGridTrack::auto(N_ROWS),
149            ..default()
150        })
151        .id();
152
153    // Add the instructions and grid to the root node
154    commands
155        .entity(root_node)
156        .add_children(&[instructions, grid_root_entity]);
157
158    let mut button_entities: HashMap<(u16, u16), Entity> = HashMap::default();
159    for row in 0..N_ROWS {
160        for col in 0..N_COLS {
161            let button_name = format!("Button {}-{}", row, col);
162
163            let button_entity = commands
164                .spawn((
165                    Button,
166                    Node {
167                        width: Val::Px(200.0),
168                        height: Val::Px(120.0),
169                        // Add a border so we can show which element is focused
170                        border: UiRect::all(Val::Px(4.0)),
171                        // Center the button's text label
172                        justify_content: JustifyContent::Center,
173                        align_items: AlignItems::Center,
174                        // Center the button within the grid cell
175                        align_self: AlignSelf::Center,
176                        justify_self: JustifySelf::Center,
177                        ..default()
178                    },
179                    ResetTimer::default(),
180                    BorderRadius::all(Val::Px(16.0)),
181                    BackgroundColor::from(NORMAL_BUTTON),
182                    Name::new(button_name.clone()),
183                ))
184                // Add a text element to the button
185                .with_child((
186                    Text::new(button_name),
187                    // And center the text if it flows onto multiple lines
188                    TextLayout {
189                        justify: JustifyText::Center,
190                        ..default()
191                    },
192                ))
193                .id();
194
195            // Add the button to the grid
196            commands.entity(grid_root_entity).add_child(button_entity);
197
198            // Keep track of the button entities so we can set up our navigation graph
199            button_entities.insert((row, col), button_entity);
200        }
201    }
202
203    // Connect all of the buttons in the same row to each other,
204    // looping around when the edge is reached.
205    for row in 0..N_ROWS {
206        let entities_in_row: Vec<Entity> = (0..N_COLS)
207            .map(|col| button_entities.get(&(row, col)).unwrap())
208            .copied()
209            .collect();
210        directional_nav_map.add_looping_edges(&entities_in_row, CompassOctant::East);
211    }
212
213    // Connect all of the buttons in the same column to each other,
214    // but don't loop around when the edge is reached.
215    // While looping is a very reasonable choice, we're not doing it here to demonstrate the different options.
216    for col in 0..N_COLS {
217        let entities_in_column: Vec<Entity> = (0..N_ROWS)
218            .map(|row| button_entities.get(&(row, col)).unwrap())
219            .copied()
220            .collect();
221
222        directional_nav_map.add_edges(&entities_in_column, CompassOctant::South);
223    }
224
225    // When changing scenes, remember to set an initial focus!
226    let top_left_entity = *button_entities.get(&(0, 0)).unwrap();
227    input_focus.set(top_left_entity);
228}
examples/ui/box_shadow.rs (line 148)
30fn setup(mut commands: Commands) {
31    // `from_env` panics on the web
32    #[cfg(not(target_arch = "wasm32"))]
33    let args: Args = argh::from_env();
34    #[cfg(target_arch = "wasm32")]
35    let args = Args::from_args(&[], &[]).unwrap();
36
37    // ui camera
38    commands.spawn((Camera2d, BoxShadowSamples(args.samples)));
39
40    commands
41        .spawn((
42            Node {
43                width: Val::Percent(100.0),
44                height: Val::Percent(100.0),
45                padding: UiRect::all(Val::Px(30.)),
46                column_gap: Val::Px(30.),
47                flex_wrap: FlexWrap::Wrap,
48                ..default()
49            },
50            BackgroundColor(DEEP_SKY_BLUE.into()),
51        ))
52        .with_children(|commands| {
53            let example_nodes = [
54                (
55                    Vec2::splat(50.),
56                    Vec2::ZERO,
57                    10.,
58                    0.,
59                    BorderRadius::bottom_right(Val::Px(10.)),
60                ),
61                (Vec2::new(50., 25.), Vec2::ZERO, 10., 0., BorderRadius::ZERO),
62                (Vec2::splat(50.), Vec2::ZERO, 10., 0., BorderRadius::MAX),
63                (Vec2::new(100., 25.), Vec2::ZERO, 10., 0., BorderRadius::MAX),
64                (
65                    Vec2::splat(50.),
66                    Vec2::ZERO,
67                    10.,
68                    0.,
69                    BorderRadius::bottom_right(Val::Px(10.)),
70                ),
71                (Vec2::new(50., 25.), Vec2::ZERO, 0., 10., BorderRadius::ZERO),
72                (
73                    Vec2::splat(50.),
74                    Vec2::ZERO,
75                    0.,
76                    10.,
77                    BorderRadius::bottom_right(Val::Px(10.)),
78                ),
79                (Vec2::new(100., 25.), Vec2::ZERO, 0., 10., BorderRadius::MAX),
80                (
81                    Vec2::splat(50.),
82                    Vec2::splat(25.),
83                    0.,
84                    0.,
85                    BorderRadius::ZERO,
86                ),
87                (
88                    Vec2::new(50., 25.),
89                    Vec2::splat(25.),
90                    0.,
91                    0.,
92                    BorderRadius::ZERO,
93                ),
94                (
95                    Vec2::splat(50.),
96                    Vec2::splat(10.),
97                    0.,
98                    0.,
99                    BorderRadius::bottom_right(Val::Px(10.)),
100                ),
101                (
102                    Vec2::splat(50.),
103                    Vec2::splat(25.),
104                    0.,
105                    10.,
106                    BorderRadius::ZERO,
107                ),
108                (
109                    Vec2::new(50., 25.),
110                    Vec2::splat(25.),
111                    0.,
112                    10.,
113                    BorderRadius::ZERO,
114                ),
115                (
116                    Vec2::splat(50.),
117                    Vec2::splat(10.),
118                    0.,
119                    10.,
120                    BorderRadius::bottom_right(Val::Px(10.)),
121                ),
122                (
123                    Vec2::splat(50.),
124                    Vec2::splat(10.),
125                    0.,
126                    3.,
127                    BorderRadius::ZERO,
128                ),
129                (
130                    Vec2::new(50., 25.),
131                    Vec2::splat(10.),
132                    0.,
133                    3.,
134                    BorderRadius::ZERO,
135                ),
136                (
137                    Vec2::splat(50.),
138                    Vec2::splat(10.),
139                    0.,
140                    3.,
141                    BorderRadius::bottom_right(Val::Px(10.)),
142                ),
143                (
144                    Vec2::splat(50.),
145                    Vec2::splat(10.),
146                    0.,
147                    3.,
148                    BorderRadius::all(Val::Px(20.)),
149                ),
150                (
151                    Vec2::new(50., 25.),
152                    Vec2::splat(10.),
153                    0.,
154                    3.,
155                    BorderRadius::all(Val::Px(20.)),
156                ),
157                (
158                    Vec2::new(25., 50.),
159                    Vec2::splat(10.),
160                    0.,
161                    3.,
162                    BorderRadius::MAX,
163                ),
164                (
165                    Vec2::splat(50.),
166                    Vec2::splat(10.),
167                    0.,
168                    10.,
169                    BorderRadius::all(Val::Px(20.)),
170                ),
171                (
172                    Vec2::new(50., 25.),
173                    Vec2::splat(10.),
174                    0.,
175                    10.,
176                    BorderRadius::all(Val::Px(20.)),
177                ),
178                (
179                    Vec2::new(25., 50.),
180                    Vec2::splat(10.),
181                    0.,
182                    10.,
183                    BorderRadius::MAX,
184                ),
185            ];
186
187            for (size, offset, spread, blur, border_radius) in example_nodes {
188                commands.spawn(box_shadow_node_bundle(
189                    size,
190                    offset,
191                    spread,
192                    blur,
193                    border_radius,
194                ));
195            }
196
197            // Demonstrate multiple shadows on one node
198            commands.spawn((
199                Node {
200                    width: Val::Px(40.),
201                    height: Val::Px(40.),
202                    border: UiRect::all(Val::Px(4.)),
203                    ..default()
204                },
205                BorderColor(LIGHT_SKY_BLUE.into()),
206                BorderRadius::all(Val::Px(20.)),
207                BackgroundColor(DEEP_SKY_BLUE.into()),
208                BoxShadow(vec![
209                    ShadowStyle {
210                        color: RED.with_alpha(0.7).into(),
211                        x_offset: Val::Px(-20.),
212                        y_offset: Val::Px(-5.),
213                        spread_radius: Val::Percent(10.),
214                        blur_radius: Val::Px(3.),
215                    },
216                    ShadowStyle {
217                        color: BLUE.with_alpha(0.7).into(),
218                        x_offset: Val::Px(-5.),
219                        y_offset: Val::Px(-20.),
220                        spread_radius: Val::Percent(10.),
221                        blur_radius: Val::Px(3.),
222                    },
223                    ShadowStyle {
224                        color: YELLOW.with_alpha(0.7).into(),
225                        x_offset: Val::Px(20.),
226                        y_offset: Val::Px(5.),
227                        spread_radius: Val::Percent(10.),
228                        blur_radius: Val::Px(3.),
229                    },
230                    ShadowStyle {
231                        color: GREEN.with_alpha(0.7).into(),
232                        x_offset: Val::Px(5.),
233                        y_offset: Val::Px(20.),
234                        spread_radius: Val::Percent(10.),
235                        blur_radius: Val::Px(3.),
236                    },
237                ]),
238            ));
239        });
240}
examples/testbed/full_ui.rs (line 211)
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}
Source

pub const fn new( top_left: Val, top_right: Val, bottom_right: Val, bottom_left: Val, ) -> BorderRadius

Source

pub const fn px( top_left: f32, top_right: f32, bottom_right: f32, bottom_left: f32, ) -> BorderRadius

Sets the radii to logical pixel values.

Examples found in repository?
examples/testbed/ui.rs (lines 244-249)
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    }
More examples
Hide additional examples
examples/ui/borders.rs (lines 189-194)
12fn setup(mut commands: Commands) {
13    commands.spawn(Camera2d);
14    let root = commands
15        .spawn((
16            Node {
17                margin: UiRect::all(Val::Px(25.0)),
18                align_self: AlignSelf::Stretch,
19                justify_self: JustifySelf::Stretch,
20                flex_wrap: FlexWrap::Wrap,
21                justify_content: JustifyContent::FlexStart,
22                align_items: AlignItems::FlexStart,
23                align_content: AlignContent::FlexStart,
24                ..default()
25            },
26            BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
27        ))
28        .id();
29
30    let root_rounded = commands
31        .spawn((
32            Node {
33                margin: UiRect::all(Val::Px(25.0)),
34                align_self: AlignSelf::Stretch,
35                justify_self: JustifySelf::Stretch,
36                flex_wrap: FlexWrap::Wrap,
37                justify_content: JustifyContent::FlexStart,
38                align_items: AlignItems::FlexStart,
39                align_content: AlignContent::FlexStart,
40                ..default()
41            },
42            BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
43        ))
44        .id();
45
46    // labels for the different border edges
47    let border_labels = [
48        "None",
49        "All",
50        "Left",
51        "Right",
52        "Top",
53        "Bottom",
54        "Horizontal",
55        "Vertical",
56        "Top Left",
57        "Bottom Left",
58        "Top Right",
59        "Bottom Right",
60        "Top Bottom Right",
61        "Top Bottom Left",
62        "Top Left Right",
63        "Bottom Left Right",
64    ];
65
66    // all the different combinations of border edges
67    // these correspond to the labels above
68    let borders = [
69        UiRect::default(),
70        UiRect::all(Val::Px(10.)),
71        UiRect::left(Val::Px(10.)),
72        UiRect::right(Val::Px(10.)),
73        UiRect::top(Val::Px(10.)),
74        UiRect::bottom(Val::Px(10.)),
75        UiRect::horizontal(Val::Px(10.)),
76        UiRect::vertical(Val::Px(10.)),
77        UiRect {
78            left: Val::Px(20.),
79            top: Val::Px(10.),
80            ..Default::default()
81        },
82        UiRect {
83            left: Val::Px(10.),
84            bottom: Val::Px(20.),
85            ..Default::default()
86        },
87        UiRect {
88            right: Val::Px(20.),
89            top: Val::Px(10.),
90            ..Default::default()
91        },
92        UiRect {
93            right: Val::Px(10.),
94            bottom: Val::Px(10.),
95            ..Default::default()
96        },
97        UiRect {
98            right: Val::Px(10.),
99            top: Val::Px(20.),
100            bottom: Val::Px(10.),
101            ..Default::default()
102        },
103        UiRect {
104            left: Val::Px(10.),
105            top: Val::Px(10.),
106            bottom: Val::Px(10.),
107            ..Default::default()
108        },
109        UiRect {
110            left: Val::Px(20.),
111            right: Val::Px(10.),
112            top: Val::Px(10.),
113            ..Default::default()
114        },
115        UiRect {
116            left: Val::Px(10.),
117            right: Val::Px(10.),
118            bottom: Val::Px(20.),
119            ..Default::default()
120        },
121    ];
122
123    for (label, border) in border_labels.into_iter().zip(borders) {
124        let inner_spot = commands
125            .spawn((
126                Node {
127                    width: Val::Px(10.),
128                    height: Val::Px(10.),
129                    ..default()
130                },
131                BackgroundColor(YELLOW.into()),
132            ))
133            .id();
134        let border_node = commands
135            .spawn((
136                Node {
137                    width: Val::Px(50.),
138                    height: Val::Px(50.),
139                    border,
140                    margin: UiRect::all(Val::Px(20.)),
141                    align_items: AlignItems::Center,
142                    justify_content: JustifyContent::Center,
143                    ..default()
144                },
145                BackgroundColor(MAROON.into()),
146                BorderColor(RED.into()),
147                Outline {
148                    width: Val::Px(6.),
149                    offset: Val::Px(6.),
150                    color: Color::WHITE,
151                },
152            ))
153            .add_child(inner_spot)
154            .id();
155        let label_node = commands
156            .spawn((
157                Text::new(label),
158                TextFont {
159                    font_size: 9.0,
160                    ..Default::default()
161                },
162            ))
163            .id();
164        let container = commands
165            .spawn(Node {
166                flex_direction: FlexDirection::Column,
167                align_items: AlignItems::Center,
168                ..default()
169            })
170            .add_children(&[border_node, label_node])
171            .id();
172        commands.entity(root).add_child(container);
173    }
174
175    for (label, border) in border_labels.into_iter().zip(borders) {
176        let inner_spot = commands
177            .spawn((
178                Node {
179                    width: Val::Px(10.),
180                    height: Val::Px(10.),
181                    ..default()
182                },
183                BorderRadius::MAX,
184                BackgroundColor(YELLOW.into()),
185            ))
186            .id();
187        let non_zero = |x, y| x != Val::Px(0.) && y != Val::Px(0.);
188        let border_size = |x, y| if non_zero(x, y) { f32::MAX } else { 0. };
189        let border_radius = BorderRadius::px(
190            border_size(border.left, border.top),
191            border_size(border.right, border.top),
192            border_size(border.right, border.bottom),
193            border_size(border.left, border.bottom),
194        );
195        let border_node = commands
196            .spawn((
197                Node {
198                    width: Val::Px(50.),
199                    height: Val::Px(50.),
200                    border,
201                    margin: UiRect::all(Val::Px(20.)),
202                    align_items: AlignItems::Center,
203                    justify_content: JustifyContent::Center,
204                    ..default()
205                },
206                BackgroundColor(MAROON.into()),
207                BorderColor(RED.into()),
208                border_radius,
209                Outline {
210                    width: Val::Px(6.),
211                    offset: Val::Px(6.),
212                    color: Color::WHITE,
213                },
214            ))
215            .add_child(inner_spot)
216            .id();
217        let label_node = commands
218            .spawn((
219                Text::new(label),
220                TextFont {
221                    font_size: 9.0,
222                    ..Default::default()
223                },
224            ))
225            .id();
226        let container = commands
227            .spawn(Node {
228                flex_direction: FlexDirection::Column,
229                align_items: AlignItems::Center,
230                ..default()
231            })
232            .add_children(&[border_node, label_node])
233            .id();
234        commands.entity(root_rounded).add_child(container);
235    }
236
237    let border_label = commands
238        .spawn((
239            Node {
240                margin: UiRect {
241                    left: Val::Px(25.0),
242                    right: Val::Px(25.0),
243                    top: Val::Px(25.0),
244                    bottom: Val::Px(0.0),
245                },
246                ..default()
247            },
248            BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
249        ))
250        .with_children(|builder| {
251            builder.spawn((
252                Text::new("Borders"),
253                TextFont {
254                    font_size: 20.0,
255                    ..Default::default()
256                },
257            ));
258        })
259        .id();
260
261    let border_rounded_label = commands
262        .spawn((
263            Node {
264                margin: UiRect {
265                    left: Val::Px(25.0),
266                    right: Val::Px(25.0),
267                    top: Val::Px(25.0),
268                    bottom: Val::Px(0.0),
269                },
270                ..default()
271            },
272            BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
273        ))
274        .with_children(|builder| {
275            builder.spawn((
276                Text::new("Borders Rounded"),
277                TextFont {
278                    font_size: 20.0,
279                    ..Default::default()
280                },
281            ));
282        })
283        .id();
284
285    commands
286        .spawn((
287            Node {
288                margin: UiRect::all(Val::Px(25.0)),
289                flex_direction: FlexDirection::Column,
290                align_self: AlignSelf::Stretch,
291                justify_self: JustifySelf::Stretch,
292                flex_wrap: FlexWrap::Wrap,
293                justify_content: JustifyContent::FlexStart,
294                align_items: AlignItems::FlexStart,
295                align_content: AlignContent::FlexStart,
296                ..default()
297            },
298            BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
299        ))
300        .add_child(border_label)
301        .add_child(root)
302        .add_child(border_rounded_label)
303        .add_child(root_rounded);
304}
Source

pub const fn percent( top_left: f32, top_right: f32, bottom_right: f32, bottom_left: f32, ) -> BorderRadius

Sets the radii to percentage values.

Source

pub const fn top_left(radius: Val) -> BorderRadius

Sets the radius for the top left corner. Remaining corners will be right-angled.

Source

pub const fn top_right(radius: Val) -> BorderRadius

Sets the radius for the top right corner. Remaining corners will be right-angled.

Source

pub const fn bottom_right(radius: Val) -> BorderRadius

Sets the radius for the bottom right corner. Remaining corners will be right-angled.

Examples found in repository?
examples/testbed/ui.rs (line 285)
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    }
More examples
Hide additional examples
examples/ui/box_shadow.rs (line 59)
30fn setup(mut commands: Commands) {
31    // `from_env` panics on the web
32    #[cfg(not(target_arch = "wasm32"))]
33    let args: Args = argh::from_env();
34    #[cfg(target_arch = "wasm32")]
35    let args = Args::from_args(&[], &[]).unwrap();
36
37    // ui camera
38    commands.spawn((Camera2d, BoxShadowSamples(args.samples)));
39
40    commands
41        .spawn((
42            Node {
43                width: Val::Percent(100.0),
44                height: Val::Percent(100.0),
45                padding: UiRect::all(Val::Px(30.)),
46                column_gap: Val::Px(30.),
47                flex_wrap: FlexWrap::Wrap,
48                ..default()
49            },
50            BackgroundColor(DEEP_SKY_BLUE.into()),
51        ))
52        .with_children(|commands| {
53            let example_nodes = [
54                (
55                    Vec2::splat(50.),
56                    Vec2::ZERO,
57                    10.,
58                    0.,
59                    BorderRadius::bottom_right(Val::Px(10.)),
60                ),
61                (Vec2::new(50., 25.), Vec2::ZERO, 10., 0., BorderRadius::ZERO),
62                (Vec2::splat(50.), Vec2::ZERO, 10., 0., BorderRadius::MAX),
63                (Vec2::new(100., 25.), Vec2::ZERO, 10., 0., BorderRadius::MAX),
64                (
65                    Vec2::splat(50.),
66                    Vec2::ZERO,
67                    10.,
68                    0.,
69                    BorderRadius::bottom_right(Val::Px(10.)),
70                ),
71                (Vec2::new(50., 25.), Vec2::ZERO, 0., 10., BorderRadius::ZERO),
72                (
73                    Vec2::splat(50.),
74                    Vec2::ZERO,
75                    0.,
76                    10.,
77                    BorderRadius::bottom_right(Val::Px(10.)),
78                ),
79                (Vec2::new(100., 25.), Vec2::ZERO, 0., 10., BorderRadius::MAX),
80                (
81                    Vec2::splat(50.),
82                    Vec2::splat(25.),
83                    0.,
84                    0.,
85                    BorderRadius::ZERO,
86                ),
87                (
88                    Vec2::new(50., 25.),
89                    Vec2::splat(25.),
90                    0.,
91                    0.,
92                    BorderRadius::ZERO,
93                ),
94                (
95                    Vec2::splat(50.),
96                    Vec2::splat(10.),
97                    0.,
98                    0.,
99                    BorderRadius::bottom_right(Val::Px(10.)),
100                ),
101                (
102                    Vec2::splat(50.),
103                    Vec2::splat(25.),
104                    0.,
105                    10.,
106                    BorderRadius::ZERO,
107                ),
108                (
109                    Vec2::new(50., 25.),
110                    Vec2::splat(25.),
111                    0.,
112                    10.,
113                    BorderRadius::ZERO,
114                ),
115                (
116                    Vec2::splat(50.),
117                    Vec2::splat(10.),
118                    0.,
119                    10.,
120                    BorderRadius::bottom_right(Val::Px(10.)),
121                ),
122                (
123                    Vec2::splat(50.),
124                    Vec2::splat(10.),
125                    0.,
126                    3.,
127                    BorderRadius::ZERO,
128                ),
129                (
130                    Vec2::new(50., 25.),
131                    Vec2::splat(10.),
132                    0.,
133                    3.,
134                    BorderRadius::ZERO,
135                ),
136                (
137                    Vec2::splat(50.),
138                    Vec2::splat(10.),
139                    0.,
140                    3.,
141                    BorderRadius::bottom_right(Val::Px(10.)),
142                ),
143                (
144                    Vec2::splat(50.),
145                    Vec2::splat(10.),
146                    0.,
147                    3.,
148                    BorderRadius::all(Val::Px(20.)),
149                ),
150                (
151                    Vec2::new(50., 25.),
152                    Vec2::splat(10.),
153                    0.,
154                    3.,
155                    BorderRadius::all(Val::Px(20.)),
156                ),
157                (
158                    Vec2::new(25., 50.),
159                    Vec2::splat(10.),
160                    0.,
161                    3.,
162                    BorderRadius::MAX,
163                ),
164                (
165                    Vec2::splat(50.),
166                    Vec2::splat(10.),
167                    0.,
168                    10.,
169                    BorderRadius::all(Val::Px(20.)),
170                ),
171                (
172                    Vec2::new(50., 25.),
173                    Vec2::splat(10.),
174                    0.,
175                    10.,
176                    BorderRadius::all(Val::Px(20.)),
177                ),
178                (
179                    Vec2::new(25., 50.),
180                    Vec2::splat(10.),
181                    0.,
182                    10.,
183                    BorderRadius::MAX,
184                ),
185            ];
186
187            for (size, offset, spread, blur, border_radius) in example_nodes {
188                commands.spawn(box_shadow_node_bundle(
189                    size,
190                    offset,
191                    spread,
192                    blur,
193                    border_radius,
194                ));
195            }
196
197            // Demonstrate multiple shadows on one node
198            commands.spawn((
199                Node {
200                    width: Val::Px(40.),
201                    height: Val::Px(40.),
202                    border: UiRect::all(Val::Px(4.)),
203                    ..default()
204                },
205                BorderColor(LIGHT_SKY_BLUE.into()),
206                BorderRadius::all(Val::Px(20.)),
207                BackgroundColor(DEEP_SKY_BLUE.into()),
208                BoxShadow(vec![
209                    ShadowStyle {
210                        color: RED.with_alpha(0.7).into(),
211                        x_offset: Val::Px(-20.),
212                        y_offset: Val::Px(-5.),
213                        spread_radius: Val::Percent(10.),
214                        blur_radius: Val::Px(3.),
215                    },
216                    ShadowStyle {
217                        color: BLUE.with_alpha(0.7).into(),
218                        x_offset: Val::Px(-5.),
219                        y_offset: Val::Px(-20.),
220                        spread_radius: Val::Percent(10.),
221                        blur_radius: Val::Px(3.),
222                    },
223                    ShadowStyle {
224                        color: YELLOW.with_alpha(0.7).into(),
225                        x_offset: Val::Px(20.),
226                        y_offset: Val::Px(5.),
227                        spread_radius: Val::Percent(10.),
228                        blur_radius: Val::Px(3.),
229                    },
230                    ShadowStyle {
231                        color: GREEN.with_alpha(0.7).into(),
232                        x_offset: Val::Px(5.),
233                        y_offset: Val::Px(20.),
234                        spread_radius: Val::Percent(10.),
235                        blur_radius: Val::Px(3.),
236                    },
237                ]),
238            ));
239        });
240}
Source

pub const fn bottom_left(radius: Val) -> BorderRadius

Sets the radius for the bottom left corner. Remaining corners will be right-angled.

Source

pub const fn left(radius: Val) -> BorderRadius

Sets the radii for the top left and bottom left corners. Remaining corners will be right-angled.

Source

pub const fn right(radius: Val) -> BorderRadius

Sets the radii for the top right and bottom right corners. Remaining corners will be right-angled.

Source

pub const fn top(radius: Val) -> BorderRadius

Sets the radii for the top left and top right corners. Remaining corners will be right-angled.

Source

pub const fn bottom(radius: Val) -> BorderRadius

Sets the radii for the bottom left and bottom right corners. Remaining corners will be right-angled.

Source

pub const fn with_top_left(self, radius: Val) -> BorderRadius

Returns the BorderRadius with its top_left field set to the given value.

Source

pub const fn with_top_right(self, radius: Val) -> BorderRadius

Returns the BorderRadius with its top_right field set to the given value.

Source

pub const fn with_bottom_right(self, radius: Val) -> BorderRadius

Returns the BorderRadius with its bottom_right field set to the given value.

Source

pub const fn with_bottom_left(self, radius: Val) -> BorderRadius

Returns the BorderRadius with its bottom_left field set to the given value.

Source

pub const fn with_left(self, radius: Val) -> BorderRadius

Returns the BorderRadius with its top_left and bottom_left fields set to the given value.

Examples found in repository?
examples/3d/../helpers/widgets.rs (lines 86-90)
57pub fn spawn_option_button<T>(
58    parent: &mut ChildSpawnerCommands,
59    option_value: T,
60    option_name: &str,
61    is_selected: bool,
62    is_first: bool,
63    is_last: bool,
64) where
65    T: Clone + Send + Sync + 'static,
66{
67    let (bg_color, fg_color) = if is_selected {
68        (Color::WHITE, Color::BLACK)
69    } else {
70        (Color::BLACK, Color::WHITE)
71    };
72
73    // Add the button node.
74    parent
75        .spawn((
76            Button,
77            Node {
78                border: BUTTON_BORDER.with_left(if is_first { Val::Px(1.0) } else { Val::Px(0.0) }),
79                justify_content: JustifyContent::Center,
80                align_items: AlignItems::Center,
81                padding: BUTTON_PADDING,
82                ..default()
83            },
84            BUTTON_BORDER_COLOR,
85            BorderRadius::ZERO
86                .with_left(if is_first {
87                    BUTTON_BORDER_RADIUS_SIZE
88                } else {
89                    Val::Px(0.0)
90                })
91                .with_right(if is_last {
92                    BUTTON_BORDER_RADIUS_SIZE
93                } else {
94                    Val::Px(0.0)
95                }),
96            BackgroundColor(bg_color),
97        ))
98        .insert(RadioButton)
99        .insert(WidgetClickSender(option_value.clone()))
100        .with_children(|parent| {
101            spawn_ui_text(parent, option_name, fg_color)
102                .insert(RadioButtonText)
103                .insert(WidgetClickSender(option_value));
104        });
105}
Source

pub const fn with_right(self, radius: Val) -> BorderRadius

Returns the BorderRadius with its top_right and bottom_right fields set to the given value.

Examples found in repository?
examples/3d/../helpers/widgets.rs (lines 91-95)
57pub fn spawn_option_button<T>(
58    parent: &mut ChildSpawnerCommands,
59    option_value: T,
60    option_name: &str,
61    is_selected: bool,
62    is_first: bool,
63    is_last: bool,
64) where
65    T: Clone + Send + Sync + 'static,
66{
67    let (bg_color, fg_color) = if is_selected {
68        (Color::WHITE, Color::BLACK)
69    } else {
70        (Color::BLACK, Color::WHITE)
71    };
72
73    // Add the button node.
74    parent
75        .spawn((
76            Button,
77            Node {
78                border: BUTTON_BORDER.with_left(if is_first { Val::Px(1.0) } else { Val::Px(0.0) }),
79                justify_content: JustifyContent::Center,
80                align_items: AlignItems::Center,
81                padding: BUTTON_PADDING,
82                ..default()
83            },
84            BUTTON_BORDER_COLOR,
85            BorderRadius::ZERO
86                .with_left(if is_first {
87                    BUTTON_BORDER_RADIUS_SIZE
88                } else {
89                    Val::Px(0.0)
90                })
91                .with_right(if is_last {
92                    BUTTON_BORDER_RADIUS_SIZE
93                } else {
94                    Val::Px(0.0)
95                }),
96            BackgroundColor(bg_color),
97        ))
98        .insert(RadioButton)
99        .insert(WidgetClickSender(option_value.clone()))
100        .with_children(|parent| {
101            spawn_ui_text(parent, option_name, fg_color)
102                .insert(RadioButtonText)
103                .insert(WidgetClickSender(option_value));
104        });
105}
Source

pub const fn with_top(self, radius: Val) -> BorderRadius

Returns the BorderRadius with its top_left and top_right fields set to the given value.

Source

pub const fn with_bottom(self, radius: Val) -> BorderRadius

Returns the BorderRadius with its bottom_left and bottom_right fields set to the given value.

Source

pub fn resolve_single_corner( radius: Val, node_size: Vec2, viewport_size: Vec2, scale_factor: f32, ) -> f32

Resolve the border radius for a single corner from the given context values. Returns the radius of the corner in physical pixels.

Source

pub fn resolve( &self, node_size: Vec2, viewport_size: Vec2, scale_factor: f32, ) -> ResolvedBorderRadius

Resolve the border radii for the corners from the given context values. Returns the radii of the each corner in physical pixels.

Trait Implementations§

Source§

impl Clone for BorderRadius

Source§

fn clone(&self) -> BorderRadius

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 BorderRadius
where BorderRadius: Send + Sync + 'static,

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 BorderRadius

Source§

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

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

impl Default for BorderRadius

Source§

fn default() -> BorderRadius

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for BorderRadius

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<BorderRadius, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl FromArg for &'static BorderRadius
where BorderRadius: Any + Send + Sync, Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

type This<'from_arg> = &'from_arg BorderRadius

The type to convert into. Read more
Source§

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

Creates an item from an argument. Read more
Source§

impl FromArg for &'static mut BorderRadius
where BorderRadius: Any + Send + Sync, Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

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

The type to convert into. Read more
Source§

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

Creates an item from an argument. Read more
Source§

impl FromArg for BorderRadius
where BorderRadius: Any + Send + Sync, Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

type This<'from_arg> = BorderRadius

The type to convert into. Read more
Source§

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

Creates an item from an argument. Read more
Source§

impl FromReflect for BorderRadius
where BorderRadius: Any + Send + Sync, Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

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

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 &BorderRadius
where BorderRadius: Any + Send + Sync, Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl GetOwnership for &mut BorderRadius
where BorderRadius: Any + Send + Sync, Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl GetOwnership for BorderRadius
where BorderRadius: Any + Send + Sync, Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl GetTypeRegistration for BorderRadius
where BorderRadius: Any + Send + Sync, Val: 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 &BorderRadius
where BorderRadius: Any + Send + Sync, Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

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

Converts Self into a Return value.
Source§

impl IntoReturn for &mut BorderRadius
where BorderRadius: Any + Send + Sync, Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

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

Converts Self into a Return value.
Source§

impl IntoReturn for BorderRadius
where BorderRadius: Any + Send + Sync, Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

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

Converts Self into a Return value.
Source§

impl PartialEq for BorderRadius

Source§

fn eq(&self, other: &BorderRadius) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialReflect for BorderRadius
where BorderRadius: Any + Send + Sync, Val: 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<BorderRadius>) -> ReflectOwned

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

fn try_into_reflect( self: Box<BorderRadius>, ) -> 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<BorderRadius>) -> 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 BorderRadius
where BorderRadius: Any + Send + Sync, Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn into_any(self: Box<BorderRadius>) -> 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<BorderRadius>) -> 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 Serialize for BorderRadius

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Struct for BorderRadius
where BorderRadius: Any + Send + Sync, Val: 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 BorderRadius

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 BorderRadius
where BorderRadius: Any + Send + Sync, Val: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn type_info() -> &'static TypeInfo

Returns the compile-time info for the underlying type.
Source§

impl Copy for BorderRadius

Source§

impl StructuralPartialEq for BorderRadius

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 + Sync + Send>

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> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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,