Skip to content

Instantly share code, notes, and snippets.

@barlog-m
Created April 26, 2025 02:24
Show Gist options
  • Save barlog-m/b1c943a63368e5bcee25266f5e606d38 to your computer and use it in GitHub Desktop.
Save barlog-m/b1c943a63368e5bcee25266f5e606d38 to your computer and use it in GitHub Desktop.
use bevy::prelude::*;
fn main() {
App::new()
.insert_resource(ClearColor(Color::BLACK))
.add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
title: env!("CARGO_PKG_NAME").to_string(),
..Default::default()
}),
..Default::default()
}))
.add_systems(Startup, spawn_text)
.run();
}
fn spawn_text(mut commands: Commands) {
commands.spawn(Camera2d);
commands
.spawn((
Node {
width: Val::Percent(100.),
height: Val::Percent(100.),
margin: UiRect::all(Val::Percent(2.)),
padding: UiRect::all(Val::Percent(2.)),
flex_direction: FlexDirection::Row,
column_gap: Val::Percent(2.),
..Default::default()
},
BackgroundColor(Color::srgb(0.25, 0.25, 0.25)),
))
.with_children(|builder| {
builder.spawn((
Node {
width: Val::Percent(50.),
..Default::default()
},
BackgroundColor(Color::srgb(0.25, 0.75, 0.25)),
));
builder.spawn((
Node {
width: Val::Percent(50.),
..Default::default()
},
BackgroundColor(Color::srgb(0.75, 0.25, 0.25)),
));
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment