UiRect

UiRect

  • left : bevy_ui::geometry::Val
  • right : bevy_ui::geometry::Val
  • top : bevy_ui::geometry::Val
  • bottom : bevy_ui::geometry::Val

Description

A type which is commonly used to define margins, paddings and borders.

Examples

Margin

A margin is used to create space around UI elements, outside of any defined borders.

# use bevy_ui::{UiRect, Val};
#
let margin = UiRect::all(Val::Auto); // Centers the UI element

Padding

A padding is used to create space around UI elements, inside of any defined borders.

# use bevy_ui::{UiRect, Val};
#
let padding = UiRect {
    left: Val::Px(10.0),
    right: Val::Px(20.0),
    top: Val::Px(30.0),
    bottom: Val::Px(40.0),
};

Borders

A border is used to define the width of the border of a UI element.

# use bevy_ui::{UiRect, Val};
#
let border = UiRect {
    left: Val::Px(10.0),
    right: Val::Px(20.0),
    top: Val::Px(30.0),
    bottom: Val::Px(40.0),
};

Functions