 de004da8d5
			
		
	
	
		de004da8d5
		
			
		
	
	
	
	
		
			
			# Objective The migration process for `bevy_color` (#12013) will be fairly involved: there will be hundreds of affected files, and a large number of APIs. ## Solution To allow us to proceed granularly, we're going to keep both `bevy_color::Color` (new) and `bevy_render::Color` (old) around until the migration is complete. However, simply doing this directly is confusing! They're both called `Color`, making it very hard to tell when a portion of the code has been ported. As discussed in #12056, by renaming the old `Color` type, we can make it easier to gradually migrate over, one API at a time. ## Migration Guide THIS MIGRATION GUIDE INTENTIONALLY LEFT BLANK. This change should not be shipped to end users: delete this section in the final migration guide! --------- Co-authored-by: Alice Cecile <alice.i.cecil@gmail.com>
		
			
				
	
	
		
			126 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			126 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
| //! Example demonstrating bordered UI nodes
 | |
| 
 | |
| use bevy::prelude::*;
 | |
| 
 | |
| fn main() {
 | |
|     App::new()
 | |
|         .add_plugins(DefaultPlugins)
 | |
|         .add_systems(Startup, setup)
 | |
|         .run();
 | |
| }
 | |
| 
 | |
| fn setup(mut commands: Commands) {
 | |
|     commands.spawn(Camera2dBundle::default());
 | |
|     let root = commands
 | |
|         .spawn(NodeBundle {
 | |
|             style: Style {
 | |
|                 margin: UiRect::all(Val::Px(25.0)),
 | |
|                 align_self: AlignSelf::Stretch,
 | |
|                 justify_self: JustifySelf::Stretch,
 | |
|                 flex_wrap: FlexWrap::Wrap,
 | |
|                 justify_content: JustifyContent::FlexStart,
 | |
|                 align_items: AlignItems::FlexStart,
 | |
|                 align_content: AlignContent::FlexStart,
 | |
|                 ..Default::default()
 | |
|             },
 | |
|             background_color: BackgroundColor(LegacyColor::DARK_GRAY),
 | |
|             ..Default::default()
 | |
|         })
 | |
|         .id();
 | |
| 
 | |
|     // all the different combinations of border edges
 | |
|     let borders = [
 | |
|         UiRect::default(),
 | |
|         UiRect::all(Val::Px(10.)),
 | |
|         UiRect::left(Val::Px(10.)),
 | |
|         UiRect::right(Val::Px(10.)),
 | |
|         UiRect::top(Val::Px(10.)),
 | |
|         UiRect::bottom(Val::Px(10.)),
 | |
|         UiRect::horizontal(Val::Px(10.)),
 | |
|         UiRect::vertical(Val::Px(10.)),
 | |
|         UiRect {
 | |
|             left: Val::Px(10.),
 | |
|             top: Val::Px(10.),
 | |
|             ..Default::default()
 | |
|         },
 | |
|         UiRect {
 | |
|             left: Val::Px(10.),
 | |
|             bottom: Val::Px(10.),
 | |
|             ..Default::default()
 | |
|         },
 | |
|         UiRect {
 | |
|             right: Val::Px(10.),
 | |
|             top: Val::Px(10.),
 | |
|             ..Default::default()
 | |
|         },
 | |
|         UiRect {
 | |
|             right: Val::Px(10.),
 | |
|             bottom: Val::Px(10.),
 | |
|             ..Default::default()
 | |
|         },
 | |
|         UiRect {
 | |
|             right: Val::Px(10.),
 | |
|             top: Val::Px(10.),
 | |
|             bottom: Val::Px(10.),
 | |
|             ..Default::default()
 | |
|         },
 | |
|         UiRect {
 | |
|             left: Val::Px(10.),
 | |
|             top: Val::Px(10.),
 | |
|             bottom: Val::Px(10.),
 | |
|             ..Default::default()
 | |
|         },
 | |
|         UiRect {
 | |
|             left: Val::Px(10.),
 | |
|             right: Val::Px(10.),
 | |
|             top: Val::Px(10.),
 | |
|             ..Default::default()
 | |
|         },
 | |
|         UiRect {
 | |
|             left: Val::Px(10.),
 | |
|             right: Val::Px(10.),
 | |
|             bottom: Val::Px(10.),
 | |
|             ..Default::default()
 | |
|         },
 | |
|     ];
 | |
| 
 | |
|     for i in 0..64 {
 | |
|         let inner_spot = commands
 | |
|             .spawn(NodeBundle {
 | |
|                 style: Style {
 | |
|                     width: Val::Px(10.),
 | |
|                     height: Val::Px(10.),
 | |
|                     ..Default::default()
 | |
|                 },
 | |
|                 background_color: LegacyColor::YELLOW.into(),
 | |
|                 ..Default::default()
 | |
|             })
 | |
|             .id();
 | |
|         let bordered_node = commands
 | |
|             .spawn((
 | |
|                 NodeBundle {
 | |
|                     style: Style {
 | |
|                         width: Val::Px(50.),
 | |
|                         height: Val::Px(50.),
 | |
|                         border: borders[i % borders.len()],
 | |
|                         margin: UiRect::all(Val::Px(20.)),
 | |
|                         align_items: AlignItems::Center,
 | |
|                         justify_content: JustifyContent::Center,
 | |
|                         ..Default::default()
 | |
|                     },
 | |
|                     background_color: LegacyColor::MAROON.into(),
 | |
|                     border_color: LegacyColor::RED.into(),
 | |
|                     ..Default::default()
 | |
|                 },
 | |
|                 Outline {
 | |
|                     width: Val::Px(6.),
 | |
|                     offset: Val::Px(6.),
 | |
|                     color: LegacyColor::WHITE,
 | |
|                 },
 | |
|             ))
 | |
|             .add_child(inner_spot)
 | |
|             .id();
 | |
|         commands.entity(root).add_child(bordered_node);
 | |
|     }
 | |
| }
 |