mirror of
https://github.com/bevyengine/bevy
synced 2024-11-14 00:47:32 +00:00
847c26b8dc
# Objective I was about to submit a PR to add these two examples to `bevy-website` and re-discovered the inconsistency. Although it's not a major issue on the website where only the filenames are shown, this would help to visually distinguish the two examples in the list because the names are very prominent. This also helps out when fuzzy-searching the codebase for these files. ## Solution Rename `shapes` to `2d_shapes`. Now the filename matches the example name, and the naming structure matches the 3d example. ## Notes @Nilirad proposed this in https://github.com/bevyengine/bevy/pull/4613#discussion_r862455631 but it had slipped away from my brain at that time.
44 lines
1.2 KiB
Rust
44 lines
1.2 KiB
Rust
//! Shows how to render simple primitive shapes with a single color.
|
|
|
|
use bevy::{prelude::*, sprite::MaterialMesh2dBundle};
|
|
|
|
fn main() {
|
|
App::new()
|
|
.add_plugins(DefaultPlugins)
|
|
.add_startup_system(setup)
|
|
.run();
|
|
}
|
|
|
|
fn setup(
|
|
mut commands: Commands,
|
|
mut meshes: ResMut<Assets<Mesh>>,
|
|
mut materials: ResMut<Assets<ColorMaterial>>,
|
|
) {
|
|
commands.spawn(Camera2dBundle::default());
|
|
|
|
// Rectangle
|
|
commands.spawn(SpriteBundle {
|
|
sprite: Sprite {
|
|
color: Color::rgb(0.25, 0.25, 0.75),
|
|
custom_size: Some(Vec2::new(50.0, 100.0)),
|
|
..default()
|
|
},
|
|
..default()
|
|
});
|
|
|
|
// Circle
|
|
commands.spawn(MaterialMesh2dBundle {
|
|
mesh: meshes.add(shape::Circle::new(50.).into()).into(),
|
|
material: materials.add(ColorMaterial::from(Color::PURPLE)),
|
|
transform: Transform::from_translation(Vec3::new(-100., 0., 0.)),
|
|
..default()
|
|
});
|
|
|
|
// Hexagon
|
|
commands.spawn(MaterialMesh2dBundle {
|
|
mesh: meshes.add(shape::RegularPolygon::new(50., 6).into()).into(),
|
|
material: materials.add(ColorMaterial::from(Color::TURQUOISE)),
|
|
transform: Transform::from_translation(Vec3::new(100., 0., 0.)),
|
|
..default()
|
|
});
|
|
}
|